hexsha
stringlengths
40
40
size
int64
5
1.05M
ext
stringclasses
588 values
lang
stringclasses
305 values
max_stars_repo_path
stringlengths
3
363
max_stars_repo_name
stringlengths
5
118
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
10
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringdate
2015-01-01 00:00:35
2022-03-31 23:43:49
max_stars_repo_stars_event_max_datetime
stringdate
2015-01-01 12:37:38
2022-03-31 23:59:52
max_issues_repo_path
stringlengths
3
363
max_issues_repo_name
stringlengths
5
118
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
10
max_issues_count
float64
1
134k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
363
max_forks_repo_name
stringlengths
5
135
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
10
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringdate
2015-01-01 00:01:02
2022-03-31 23:27:27
max_forks_repo_forks_event_max_datetime
stringdate
2015-01-03 08:55:07
2022-03-31 23:59:24
content
stringlengths
5
1.05M
avg_line_length
float64
1.13
1.04M
max_line_length
int64
1
1.05M
alphanum_fraction
float64
0
1
a0434b717529f1e66f3e3e2f57fbc294cc370683
3,650
h
C
third-party/libfabric/libfabric-src/include/rbtree.h
jhh67/chapel
f041470e9b88b5fc4914c75aa5a37efcb46aa08f
[ "ECL-2.0", "Apache-2.0" ]
1,602
2015-01-06T11:26:31.000Z
2022-03-30T06:17:21.000Z
third-party/libfabric/libfabric-src/include/rbtree.h
jhh67/chapel
f041470e9b88b5fc4914c75aa5a37efcb46aa08f
[ "ECL-2.0", "Apache-2.0" ]
11,789
2015-01-05T04:50:15.000Z
2022-03-31T23:39:19.000Z
third-party/libfabric/libfabric-src/include/rbtree.h
jhh67/chapel
f041470e9b88b5fc4914c75aa5a37efcb46aa08f
[ "ECL-2.0", "Apache-2.0" ]
498
2015-01-08T18:58:18.000Z
2022-03-20T15:37:45.000Z
/* * Copyright (c) 2015 Cray Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /* * Copied from http://oopweb.com/Algorithms/Documents/Sman/VolumeFrames.html?/Algorithms/Documents/Sman/Volume/RedBlackTrees_files/s_rbt.htm * * Disclosure from the author's main page: * (http://oopweb.com/Algorithms/Documents/Sman/VolumeFrames.html?/Algorithms/Documents/Sman/Volume/RedBlackTrees_files/s_rbt.htm) * * Source code when part of a software project may be used freely * without reference to the author. * */ #ifndef RBTREE_H_ #define RBTREE_H_ typedef enum { RBT_STATUS_OK, RBT_STATUS_MEM_EXHAUSTED, RBT_STATUS_DUPLICATE_KEY, RBT_STATUS_KEY_NOT_FOUND } RbtStatus; typedef void *RbtIterator; typedef void *RbtHandle; RbtHandle rbtNew(int(*compare)(void *a, void *b)); // create red-black tree // parameters: // compare pointer to function that compares keys // return 0 if a == b // return < 0 if a < b // return > 0 if a > b // returns: // handle use handle in calls to rbt functions void rbtDelete(RbtHandle h); // destroy red-black tree RbtStatus rbtInsert(RbtHandle h, void *key, void *value); // insert key/value pair RbtStatus rbtErase(RbtHandle h, RbtIterator i); // delete node in tree associated with iterator // this function does not free the key/value pointers RbtIterator rbtNext(RbtHandle h, RbtIterator i); // return ++i RbtIterator rbtBegin(RbtHandle h); // return pointer to first node RbtIterator rbtEnd(RbtHandle h); // return pointer to one past last node void rbtKeyValue(RbtHandle h, RbtIterator i, void **key, void **value); // returns key/value pair associated with iterator RbtIterator rbtFindLeftmost(RbtHandle h, void *key, int(*compare)(void *a, void *b)); // returns iterator associated with left-most match. This is useful when a new // key might invalidate the uniqueness property of the tree. RbtIterator rbtFind(RbtHandle h, void *key); // returns iterator associated with key void rbtTraversal(RbtHandle h, RbtIterator it, void *handler_arg, void(*handler)(void *arg, RbtIterator it)); // tree traversal that visits (applies handler()) each node in the tree data // strucutre exactly once. void *rbtRoot(RbtHandle h); // returns the root of the tree #endif /* RBTREE_H_ */
34.11215
140
0.725479
53df052a5dfe83f627a792d7a57fa32c368a36d4
1,028
h
C
DiscuzQ_Mobile/DiscuzQ/Classes/Module/DZ_Media/SubFrame/VideoScan/View/Header/HomeCollectionView.h
webersongao/DiscuzQ_iOS
71ee9bdbcce2fcadc18e1916febcea8d3470e704
[ "Apache-2.0" ]
27
2020-04-05T14:02:58.000Z
2021-09-13T02:14:12.000Z
DiscuzQ_Mobile/DiscuzQ/Classes/Module/DZ_Media/SubFrame/VideoScan/View/Header/HomeCollectionView.h
webersongao/DiscuzQ_iOS
71ee9bdbcce2fcadc18e1916febcea8d3470e704
[ "Apache-2.0" ]
null
null
null
DiscuzQ_Mobile/DiscuzQ/Classes/Module/DZ_Media/SubFrame/VideoScan/View/Header/HomeCollectionView.h
webersongao/DiscuzQ_iOS
71ee9bdbcce2fcadc18e1916febcea8d3470e704
[ "Apache-2.0" ]
6
2020-07-18T11:36:11.000Z
2022-01-30T06:09:48.000Z
// // HomeCollectionView.h // DiscuzQ // 联系作者:微信: ChinaMasker gao@btbk.org // Github :https://github.com/webersongao/DiscuzQ_iOS // Created by WebersonGao on 2019/11/19. // Copyright © 2019 WebersonGao. All rights reserved. // #import <UIKit/UIKit.h> #import "MediaHeader.h" #import "HomeCollectionCell.h" @class HomeCollectionView,HomeCollectionCell; @protocol HeaderCollectionDelegate <NSObject> @optional - (void)collectionView:(HomeCollectionView *)collectionView didSelectItemCell:(HomeCollectionCell *)itemCell; - (void)collectionView:(HomeCollectionView *)collectionView longPressItemCell:(HomeCollectionCell *)itemCell; - (void)collectionView:(HomeCollectionView *)collectionView scrollDidScroll:(CGFloat)offsetY; - (void)collectionViewWillBeginDragging; - (void)collectionViewDidEndScroll; @end @interface HomeCollectionView : UICollectionView @property(nonatomic,weak) id<HeaderCollectionDelegate> headerDelegate; // 重置 列表数组数据 的唯一方法 -(void)reloadDataSource:(NSArray <DZThreadCateM *>*)array; @end
25.073171
109
0.790856
5b0daa25c2c656c541b0309dc754a85f07069387
3,784
c
C
Kernel/Formats/sigproc/swap_bytes.c
rwharton/dspsr_dsn
135cc86c43931311424beeb5a459ba570f1f83f7
[ "AFL-2.1" ]
null
null
null
Kernel/Formats/sigproc/swap_bytes.c
rwharton/dspsr_dsn
135cc86c43931311424beeb5a459ba570f1f83f7
[ "AFL-2.1" ]
null
null
null
Kernel/Formats/sigproc/swap_bytes.c
rwharton/dspsr_dsn
135cc86c43931311424beeb5a459ba570f1f83f7
[ "AFL-2.1" ]
null
null
null
#include "sigproc.h" #include <stdlib.h> /* some useful routines written by Jeff Hagen for swapping bytes of data between Big Endian and Little Endian formats: Big Endian - most significant byte in the lowest memory address, which is the address of the data. Since TCP defines the byte ordering for network data, end-nodes must call a processor-specific convert utility (which would do nothing if the machine's native byte-ordering is the same as TCP's) that acts on the TCP and IP header information only. In a TCP/IP packet, the first transmitted data is the most significant byte. Most UNIXes (for example, all System V) and the Internet are Big Endian. Motorola 680x0 microprocessors (and therefore Macintoshes), Hewlett-Packard PA-RISC, and Sun SuperSPARC processors are Big Endian. The Silicon Graphics MIPS and IBM/Motorola PowerPC processors are both Little and Big Endian (bi-endian). Little Endian - least significant byte in the lowest-memory address, which is the address of the data. The Intel 80X86 and Pentium and DEC Alpha RISC processors are Little Endian. Windows NT and OSF/1 are Little Endian. Little Endian is the less common UNIX implementation. The term is used because of an analogy with the story Gulliver's Travels, in which Jonathan Swift imagined a never-ending fight between the kingdoms of the Big-Endians and the Little-Endians, whose only difference is in where they crack open a hard-boiled egg. */ void swap_short( unsigned short *ps ) /* includefile */ { unsigned char t; unsigned char *pc; pc = ( unsigned char *)ps; t = pc[0]; pc[0] = pc[1]; pc[1] = t; } void swap_int( int *pi ) /* includefile */ { unsigned char t; unsigned char *pc; pc = (unsigned char *)pi; t = pc[0]; pc[0] = pc[3]; pc[3] = t; t = pc[1]; pc[1] = pc[2]; pc[2] = t; } void swap_float( float *pf ) /* includefile */ { unsigned char t; unsigned char *pc; pc = (unsigned char *)pf; t = pc[0]; pc[0] = pc[3]; pc[3] = t; t = pc[1]; pc[1] = pc[2]; pc[2] = t; } void swap_ulong( unsigned long *pi ) /* includefile */ { unsigned char t; unsigned char *pc; pc = (unsigned char *)pi; t = pc[0]; pc[0] = pc[3]; pc[3] = t; t = pc[1]; pc[1] = pc[2]; pc[2] = t; } void swap_long( long *pi ) /* includefile */ { unsigned char t; unsigned char *pc; pc = (unsigned char *)pi; t = pc[0]; pc[0] = pc[3]; pc[3] = t; t = pc[1]; pc[1] = pc[2]; pc[2] = t; } void swap_double( double *pd ) /* includefile */ { unsigned char t; unsigned char *pc; pc = (unsigned char *)pd; t = pc[0]; pc[0] = pc[7]; pc[7] = t; t = pc[1]; pc[1] = pc[6]; pc[6] = t; t = pc[2]; pc[2] = pc[5]; pc[5] = t; t = pc[3]; pc[3] = pc[4]; pc[4] = t; } void swap_longlong( long long *pl ) /* includefile */ { unsigned char t; unsigned char *pc; pc = (unsigned char *)pl; t = pc[0]; pc[0] = pc[7]; pc[7] = t; t = pc[1]; pc[1] = pc[6]; pc[6] = t; t = pc[2]; pc[2] = pc[5]; pc[5] = t; t = pc[3]; pc[3] = pc[4]; pc[4] = t; } #include <stdio.h> int little_endian() /*includefile*/ { char *ostype; if((ostype = (char *)getenv("OSTYPE")) == NULL ) error_message("environment variable OSTYPE not set!"); if (strings_equal(ostype,"linux")) return 1; if (strings_equal(ostype,"hpux")) return 0; if (strings_equal(ostype,"solaris")) return 0; if (strings_equal(ostype,"darwin")) return 0; fprintf(stderr,"Your OSTYPE environment variable is defined but not recognized!\n"); fprintf(stderr,"Consult and edit little_endian in swap_bytes.c and then recompile\n"); fprintf(stderr,"the code if necessary... Contact dunc@naic.edu for further help\n"); exit(0); } int big_endian() /*includefile*/ { return (!little_endian()); }
20.791209
88
0.642706
3e33951168f8a86ef82f3ba9e1d659220b34da63
6,531
h
C
VecGeom/volumes/PlacedTrd.h
cxwx/VecGeom
c86c00bd7d4db08f4fc20a625020da329784aaac
[ "ECL-2.0", "Apache-2.0" ]
1
2020-06-27T18:43:36.000Z
2020-06-27T18:43:36.000Z
VecGeom/volumes/PlacedTrd.h
cxwx/VecGeom
c86c00bd7d4db08f4fc20a625020da329784aaac
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
VecGeom/volumes/PlacedTrd.h
cxwx/VecGeom
c86c00bd7d4db08f4fc20a625020da329784aaac
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
// This file is part of VecGeom and is distributed under the // conditions in the file LICENSE.txt in the top directory. // For the full list of authors see CONTRIBUTORS.txt and `git log`. /// Declaration of the placed Trd volume /// @file volumes/PlacedTrd.h /// @author Georgios Bitzes #ifndef VECGEOM_VOLUMES_PLACEDTRD_H_ #define VECGEOM_VOLUMES_PLACEDTRD_H_ #include "VecGeom/base/Global.h" #ifndef VECCORE_CUDA #include "VecGeom/base/RNG.h" #include <cmath> #endif #include "VecGeom/volumes/PlacedVolume.h" #include "VecGeom/volumes/UnplacedVolume.h" #include "VecGeom/volumes/kernel/TrdImplementation.h" #include "VecGeom/volumes/PlacedVolImplHelper.h" #include "VecGeom/volumes/UnplacedTrd.h" namespace vecgeom { VECGEOM_DEVICE_FORWARD_DECLARE(class PlacedTrd;); VECGEOM_DEVICE_DECLARE_CONV(class, PlacedTrd); inline namespace VECGEOM_IMPL_NAMESPACE { /// Class for the positioned Trd volume class PlacedTrd : public VPlacedVolume { public: using VPlacedVolume::VPlacedVolume; #ifndef VECCORE_CUDA /// Constructor /// @param label Name of logical volume. /// @param logicalVolume The logical volume to be positioned. /// @param transformation The positioning transformation. /// @param boundingBox Pointer to bounding box (may be null); To be deprecated PlacedTrd(char const *const label, LogicalVolume const *const logicalVolume, Transformation3D const *const transformation, vecgeom::PlacedBox const *const boundingBox) : VPlacedVolume(label, logicalVolume, transformation, boundingBox) { } /// Constructor /// @param logicalVolume The logical volume to be positioned. /// @param transformation The positioning transformation. /// @param boundingBox Pointer to bounding box (may be null); To be deprecated PlacedTrd(LogicalVolume const *const logicalVolume, Transformation3D const *const transformation, vecgeom::PlacedBox const *const boundingBox) : PlacedTrd("", logicalVolume, transformation, boundingBox) { } #else /// CUDA version of constructor VECCORE_ATT_DEVICE PlacedTrd(LogicalVolume const *const logicalVolume, Transformation3D const *const transformation, PlacedBox const *const boundingBox, const int id, const int copy_no, const int child_id) : VPlacedVolume(logicalVolume, transformation, boundingBox, id, copy_no, child_id) { } #endif /// Destructor VECCORE_ATT_HOST_DEVICE virtual ~PlacedTrd() {} /// Getter for unplaced volume VECCORE_ATT_HOST_DEVICE UnplacedTrd const *GetUnplacedVolume() const { return static_cast<UnplacedTrd const *>(GetLogicalVolume()->GetUnplacedVolume()); } /// Getter for half-length along x at -dz VECCORE_ATT_HOST_DEVICE VECGEOM_FORCE_INLINE Precision dx1() const { return GetUnplacedVolume()->dx1(); } /// Getter for half-length along x at +dz VECCORE_ATT_HOST_DEVICE VECGEOM_FORCE_INLINE Precision dx2() const { return GetUnplacedVolume()->dx2(); } /// Getter for half-length along y at -dz VECCORE_ATT_HOST_DEVICE VECGEOM_FORCE_INLINE Precision dy1() const { return GetUnplacedVolume()->dy1(); } /// Getter for half-length along y at +dz VECCORE_ATT_HOST_DEVICE VECGEOM_FORCE_INLINE Precision dy2() const { return GetUnplacedVolume()->dy2(); } /// Getter for half-length along z VECCORE_ATT_HOST_DEVICE VECGEOM_FORCE_INLINE Precision dz() const { return GetUnplacedVolume()->dz(); } /// Getter for half-length along x at -dz Precision GetXHalfLength1() const { return GetUnplacedVolume()->dx1(); } /// Getter for half-length along x at +dz Precision GetXHalfLength2() const { return GetUnplacedVolume()->dx2(); } /// Getter for half-length along y at -dz Precision GetYHalfLength1() const { return GetUnplacedVolume()->dy1(); } /// Getter for half-length along y at +dz Precision GetYHalfLength2() const { return GetUnplacedVolume()->dy2(); } /// Getter for half-length along z Precision GetZHalfLength() const { return GetUnplacedVolume()->dz(); } /// Setter for half-length along x at -dz void SetXHalfLength1(Precision arg) { const_cast<UnplacedTrd *>(GetUnplacedVolume())->SetXHalfLength1(arg); } /// Setter for half-length along x at +dz void SetXHalfLength2(Precision arg) { const_cast<UnplacedTrd *>(GetUnplacedVolume())->SetXHalfLength2(arg); } /// Setter for half-length along y at -dz void SetYHalfLength1(Precision arg) { const_cast<UnplacedTrd *>(GetUnplacedVolume())->SetYHalfLength1(arg); } /// Setter for half-length along y at +dz void SetYHalfLength2(Precision arg) { const_cast<UnplacedTrd *>(GetUnplacedVolume())->SetYHalfLength2(arg); } /// Setter for half-length along z void SetZHalfLength(Precision arg) { const_cast<UnplacedTrd *>(GetUnplacedVolume())->SetZHalfLength(arg); } /// Setter for all parameters /// @param x1 Half-length along x at the surface positioned at -dz /// @param x2 Half-length along x at the surface positioned at +dz /// @param y1 Half-length along y at the surface positioned at -dz /// @param y2 Half-length along y at the surface positioned at +dz /// @param z Half-length along z axis void SetAllParameters(Precision x1, Precision x2, Precision y1, Precision y2, Precision z) { const_cast<UnplacedTrd *>(GetUnplacedVolume())->SetAllParameters(x1, x2, y1, y2, z); } VECCORE_ATT_HOST_DEVICE void Extent(Vector3D<Precision> &aMin, Vector3D<Precision> &aMax) const override { GetUnplacedVolume()->Extent(aMin, aMax); } #ifndef VECCORE_CUDA virtual Precision Capacity() override { return GetUnplacedVolume()->Capacity(); } VECCORE_ATT_HOST_DEVICE bool Normal(Vector3D<Precision> const &point, Vector3D<Precision> &normal) const override { return GetUnplacedVolume()->Normal(point, normal); } /// Returns memory size in bytes VECGEOM_FORCE_INLINE virtual int MemorySize() const override { return sizeof(*this); } virtual VPlacedVolume const *ConvertToUnspecialized() const override; #ifdef VECGEOM_ROOT virtual TGeoShape const *ConvertToRoot() const override; #endif #ifdef VECGEOM_GEANT4 G4VSolid const *ConvertToGeant4() const override; #endif #endif // VECCORE_CUDA }; template <typename UnplacedTrd_t> class SPlacedTrd : public PlacedVolumeImplHelper<UnplacedTrd_t, PlacedTrd> { using Base = PlacedVolumeImplHelper<UnplacedTrd_t, PlacedTrd>; public: typedef UnplacedTrd UnplacedShape_t; using Base::Base; }; } // namespace VECGEOM_IMPL_NAMESPACE } // namespace vecgeom #endif // VECGEOM_VOLUMES_PLACEDTUBE_H_
35.302703
119
0.745215
eb6667194e6e11173fd53dbb2653f5336760bbe2
1,595
h
C
include/tcp.h
mastoo/yanes
0e4a7381d0cbd7c19d29a95fcddbce0f5b962063
[ "MIT" ]
1
2016-09-07T21:12:43.000Z
2016-09-07T21:12:43.000Z
include/tcp.h
mastoo/yanes
0e4a7381d0cbd7c19d29a95fcddbce0f5b962063
[ "MIT" ]
null
null
null
include/tcp.h
mastoo/yanes
0e4a7381d0cbd7c19d29a95fcddbce0f5b962063
[ "MIT" ]
null
null
null
#ifndef TCP_H #define TCP_H #include "netdev.h" struct tcphdr { uint16_t src; /* source port */ uint16_t dst; /* dest port */ uint16_t seq_low; /* sequence number */ uint16_t seq_high; /* sequence number */ uint16_t ackn_low; /* acknowledgment number */ uint16_t ackn_high; /* acknowledgment number */ #if __BYTE_ORDER == __LITTLE_ENDIAN uint16_t reserved:4; uint16_t doff:4; /* data offset(head length)in 32 bits long */ /* control bits */ uint16_t fin:1; uint16_t syn:1; uint16_t rst:1; uint16_t psh:1; /* push */ uint16_t ack:1; /* acknowlegment */ uint16_t urg:1; /* urgent */ uint16_t ece:1; /* See RFC 3168 */ uint16_t cwr:1; /* See RFC 3168 */ #elif __BYTE_ORDER == __BIG_ENDIAN uint16_t doff:4; /* data offset(head length)in 32 bits long */ uint16_t reserved:4; /* control bits */ uint16_t cwr:1; /* See RFC 3168 */ uint16_t ece:1; /* See RFC 3168 */ uint16_t urg:1; /* urgent */ uint16_t ack:1; /* acknowlegment */ uint16_t psh:1; /* push */ uint16_t rst:1; uint16_t syn:1; uint16_t fin:1; #endif uint16_t window; uint16_t checksum; uint16_t urgptr; /* urgent pointer */ uint8_t data[]; } __attribute__((packed)); void tcp_init(struct netdev *dev_ ); void tcp_incoming(struct eth_hdr *hdr); int accept_new_tcp_conn(uint16_t prt); //create a client socket void connect_to(int * sk, uint16_t saddr_low, uint16_t saddr_high, uint16_t sprt, uint16_t dprt); int is_connected(int sk); int is_tcp_closed(int sk); int tcp_recv(int sk,void *buf, uint32_t len); int tcp_send(int sk,void *buf, uint32_t len); void handle_tcp_outcoming_data(); #endif
25.725806
98
0.705956
acb469a87c8536a281768141377de13b171ccf19
2,018
h
C
montage-tech/inc/kware/network/HTTPC/http_download_mini.h
kuikuitage/NewCool-UC-3.1.0-priv
16198d4eae1dd1a1bf4f4ba4b54652688078c018
[ "Apache-2.0" ]
null
null
null
montage-tech/inc/kware/network/HTTPC/http_download_mini.h
kuikuitage/NewCool-UC-3.1.0-priv
16198d4eae1dd1a1bf4f4ba4b54652688078c018
[ "Apache-2.0" ]
null
null
null
montage-tech/inc/kware/network/HTTPC/http_download_mini.h
kuikuitage/NewCool-UC-3.1.0-priv
16198d4eae1dd1a1bf4f4ba4b54652688078c018
[ "Apache-2.0" ]
3
2016-05-03T05:57:19.000Z
2021-11-10T21:34:00.000Z
#ifndef __HTTP_DOWNLOAD_MINI_H__ #define __HTTP_DOWNLOAD_MINI_H__ #include <fcntl.h> #include <stddef.h> /* for NULL */ #include <string.h> #include <stdlib.h> /* for exit() */ #include <unistd.h> #ifdef __LINUX__ #include <dirent.h> #endif #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> #include <sys/stat.h> #include <pthread.h> #include "eventSink.h" #include <http_download.h> #include <download_api.h> typedef enum http_mini_state_ { HTTP_MINI_COMPLETE, HTTP_MINI_ERR, HTTP_MINI_TIMEOUT, HTTP_MINI_ABORT, HTTP_MINI_ABORT_BY_USER, } http_mini_state; typedef struct _http_download_mini_speed { http_mini_state state; int size; int connectMS; int downloadMS; } HttpDownloadMiniSpeed; class http_download_mini { private: http_state state; void * contex; void downloader(unsigned int timeoutMS, unsigned char * abort_flag); void clean_data(void); public: http_download_mini(void); ~http_download_mini(void); int http_connect(char * url, unsigned int timeoutMS, bool isPost, const char * extraHeaders, const char * body, unsigned int bodyLen); int http_receive(unsigned char *buffer, unsigned int bufferlen, int *writelen); void http_close(); void abort(); /* * download this url, return download length:byte */ HttpDownloadMiniSpeed download(char * url, unsigned int timeoutMS, char * writeFileName, unsigned char * abort_flag, bool isPost, const char * extraHeaders, const char * body, unsigned int bodyLen, HTTP_rsp_header_t *rsp_header = NULL); /* * get direct ts url ,which can play directly */ const char * get_direct_ts_url_from_m3u8(bool *isLive); /* * get redirect url */ const char * get_redirect_url(); /* * get final url if it has been redirected */ const char * get_final_url(); const char* get_ContentType_from_response(); }; #endif
24.609756
152
0.673935
3a1a322a0c16b4c04ec147f7482e0c64cdd7975c
215
h
C
Wooow/Classes/Other/Login/LoginBaseViewController.h
Anonymous-Monk/Wow
8f1652e6ceaef33a5995e0f774e707b7f45b7dfa
[ "MIT" ]
null
null
null
Wooow/Classes/Other/Login/LoginBaseViewController.h
Anonymous-Monk/Wow
8f1652e6ceaef33a5995e0f774e707b7f45b7dfa
[ "MIT" ]
null
null
null
Wooow/Classes/Other/Login/LoginBaseViewController.h
Anonymous-Monk/Wow
8f1652e6ceaef33a5995e0f774e707b7f45b7dfa
[ "MIT" ]
null
null
null
// // LoginBaseViewController.h // 车改联盟 // // Created by zero on 16/6/18. // Copyright © 2016年 zero. All rights reserved. // #import <UIKit/UIKit.h> @interface LoginBaseViewController : UIViewController @end
15.357143
53
0.702326
b198ec1e8fc2efd8494e9a9e41799804f53991bc
387
c
C
kw/samples/nop/pulp/pulp.c
stmach/micro-benchmarks
784280fea7f87be97bcde7a23a46b00f90351da6
[ "Apache-2.0" ]
3
2019-02-15T12:10:51.000Z
2020-02-20T23:43:18.000Z
kw/samples/nop/pulp/pulp.c
stmach/micro-benchmarks
784280fea7f87be97bcde7a23a46b00f90351da6
[ "Apache-2.0" ]
1
2021-08-08T15:11:12.000Z
2021-08-08T15:11:12.000Z
kw/samples/nop/pulp/pulp.c
stmach/micro-benchmarks
784280fea7f87be97bcde7a23a46b00f90351da6
[ "Apache-2.0" ]
2
2019-02-15T12:11:04.000Z
2020-04-03T14:21:37.000Z
// Copyright (c) 2017 OPRECOMP Project // Fabian Schuiki <fschuiki@iis.ee.ethz.ch> #include "rt/rt_api.h" #include <stdio.h> #include <stdint.h> int main(uint64_t wed) { printf("[%d, %d] Hello from the loaded PULP binary!\n", rt_cluster_id(), rt_core_id()); printf("[%d, %d] WED is 0x%08lx%08lx\n", rt_cluster_id(), rt_core_id(), (uint32_t)(wed >> 32), (uint32_t)wed); return 0; }
27.642857
111
0.671835
38a13c60145f32fe6c5ab76ac249ee4a1feb1930
5,291
h
C
plugins/ios/WeexSDK/weex_core/Source/include/JavaScriptCore/bytecode/BytecodeGraph.h
Hunter968/eeui-template
e573ec739415b1027caadf17085dc3e8c97338b8
[ "MIT" ]
677
2017-09-23T16:03:12.000Z
2022-03-26T08:32:10.000Z
plugins/ios/WeexSDK/weex_core/Source/include/JavaScriptCore/bytecode/BytecodeGraph.h
Hunter968/eeui-template
e573ec739415b1027caadf17085dc3e8c97338b8
[ "MIT" ]
12
2019-07-09T05:55:28.000Z
2019-07-31T01:12:28.000Z
plugins/ios/WeexSDK/weex_core/Source/include/JavaScriptCore/bytecode/BytecodeGraph.h
Hunter968/eeui-template
e573ec739415b1027caadf17085dc3e8c97338b8
[ "MIT" ]
92
2017-09-21T14:21:27.000Z
2022-03-25T13:29:42.000Z
/* * Copyright (C) 2016 Yusuke Suzuki <utatane.tea@gmail.com> * Copyright (C) 2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once #include "BytecodeBasicBlock.h" #include <wtf/IndexedContainerIterator.h> #include <wtf/IteratorRange.h> #include <wtf/Vector.h> namespace JSC { class BytecodeBasicBlock; template<typename Block> class BytecodeGraph { WTF_MAKE_FAST_ALLOCATED; WTF_MAKE_NONCOPYABLE(BytecodeGraph); public: typedef Block CodeBlock; typedef typename Block::Instruction Instruction; typedef Vector<std::unique_ptr<BytecodeBasicBlock>> BasicBlocksVector; typedef WTF::IndexedContainerIterator<BytecodeGraph<Block>> iterator; inline BytecodeGraph(Block*, typename Block::UnpackedInstructions&); Block* codeBlock() const { return m_codeBlock; } typename Block::UnpackedInstructions& instructions() { return m_instructions; } WTF::IteratorRange<BasicBlocksVector::reverse_iterator> basicBlocksInReverseOrder() { return WTF::makeIteratorRange(m_basicBlocks.rbegin(), m_basicBlocks.rend()); } static bool blockContainsBytecodeOffset(BytecodeBasicBlock* block, unsigned bytecodeOffset) { unsigned leaderOffset = block->leaderOffset(); return bytecodeOffset >= leaderOffset && bytecodeOffset < leaderOffset + block->totalLength(); } BytecodeBasicBlock* findBasicBlockForBytecodeOffset(unsigned bytecodeOffset) { /* for (unsigned i = 0; i < m_basicBlocks.size(); i++) { if (blockContainsBytecodeOffset(m_basicBlocks[i].get(), bytecodeOffset)) return m_basicBlocks[i].get(); } return 0; */ std::unique_ptr<BytecodeBasicBlock>* basicBlock = approximateBinarySearch<std::unique_ptr<BytecodeBasicBlock>, unsigned>(m_basicBlocks, m_basicBlocks.size(), bytecodeOffset, [] (std::unique_ptr<BytecodeBasicBlock>* basicBlock) { return (*basicBlock)->leaderOffset(); }); // We found the block we were looking for. if (blockContainsBytecodeOffset((*basicBlock).get(), bytecodeOffset)) return (*basicBlock).get(); // Basic block is to the left of the returned block. if (bytecodeOffset < (*basicBlock)->leaderOffset()) { ASSERT(basicBlock - 1 >= m_basicBlocks.data()); ASSERT(blockContainsBytecodeOffset(basicBlock[-1].get(), bytecodeOffset)); return basicBlock[-1].get(); } // Basic block is to the right of the returned block. ASSERT(&basicBlock[1] <= &m_basicBlocks.last()); ASSERT(blockContainsBytecodeOffset(basicBlock[1].get(), bytecodeOffset)); return basicBlock[1].get(); } BytecodeBasicBlock* findBasicBlockWithLeaderOffset(unsigned leaderOffset) { return (*tryBinarySearch<std::unique_ptr<BytecodeBasicBlock>, unsigned>(m_basicBlocks, m_basicBlocks.size(), leaderOffset, [] (std::unique_ptr<BytecodeBasicBlock>* basicBlock) { return (*basicBlock)->leaderOffset(); })).get(); } unsigned size() const { return m_basicBlocks.size(); } BytecodeBasicBlock* at(unsigned index) const { return m_basicBlocks[index].get(); } BytecodeBasicBlock* operator[](unsigned index) const { return at(index); } iterator begin() const { return iterator(*this, 0); } iterator end() const { return iterator(*this, size()); } BytecodeBasicBlock* first() { return at(0); } BytecodeBasicBlock* last() { return at(size() - 1); } private: Block* m_codeBlock; BasicBlocksVector m_basicBlocks; typename Block::UnpackedInstructions& m_instructions; }; template<typename Block> BytecodeGraph<Block>::BytecodeGraph(Block* codeBlock, typename Block::UnpackedInstructions& instructions) : m_codeBlock(codeBlock) , m_instructions(instructions) { ASSERT(m_codeBlock); BytecodeBasicBlock::compute(m_codeBlock, instructions.begin(), instructions.size(), m_basicBlocks); ASSERT(m_basicBlocks.size()); } } // namespace JSC
41.992063
278
0.717823
1da5eb245d1d684b77a3e4c2105029b4d550c8e9
1,513
c
C
src/Table_des_chaines.c
ielomariala/MyCustomCompiler
0feeeaad1e1ea63e86205d27948e21aa80a69ae2
[ "MIT" ]
null
null
null
src/Table_des_chaines.c
ielomariala/MyCustomCompiler
0feeeaad1e1ea63e86205d27948e21aa80a69ae2
[ "MIT" ]
null
null
null
src/Table_des_chaines.c
ielomariala/MyCustomCompiler
0feeeaad1e1ea63e86205d27948e21aa80a69ae2
[ "MIT" ]
null
null
null
/* * Table des chaines.c * * Created by Janin on 12/10/10. * Copyright 2010 LaBRI. All rights reserved. * */ #include "Table_des_chaines.h" #include <stdlib.h> #include <string.h> #include <stdio.h> /* good old string copy function with malloc */ char * string_copy(char *s) { if (!s) return NULL; char * sc = malloc(strlen(s)*sizeof(char)+2); //printf("printing s = %s\n", s); return strcpy(sc, s); } /* The storage structure is implemented as a linked chain. A more efficient structure would be (why so ?) a hash table */ /* linked element def */ typedef struct elem { char * value; struct elem * next; } elem; /* linked chain initial element */ static elem * storage=NULL; /* insert a string into the storage structure giving back its (unique) sid */ sid string_to_sid(char * s) { elem * tracker; /* check s is a real string */ if (!s) return NULL; /* look for the presence of s in storage and returns its copy if there */ tracker = storage; while (tracker) { if (!strcmp(tracker->value, s)) return tracker->value; tracker = tracker -> next; } /* otherwise insert it at head of storage */ tracker = malloc(sizeof(elem)); tracker -> value = string_copy(s); tracker -> next = storage; storage = tracker; return storage -> value; } /* check the validity of an sid as being present in the storage structure */ int sid_valid(sid i) { elem * tracker=storage; while (tracker) { if (tracker->value==i) return 1; tracker=tracker->next; } return 0; }
20.726027
77
0.664904
ce7893782213c2dcf0397ac30e90db1b5704d17a
11,255
c
C
rt-smart/kernel/components/lwp/lwp_console.c
dengchow/rt_smart_imx6ull-
4d9879e3d543a4e4ddd4b73ce0d30668127f5c5a
[ "Apache-2.0" ]
null
null
null
rt-smart/kernel/components/lwp/lwp_console.c
dengchow/rt_smart_imx6ull-
4d9879e3d543a4e4ddd4b73ce0d30668127f5c5a
[ "Apache-2.0" ]
null
null
null
rt-smart/kernel/components/lwp/lwp_console.c
dengchow/rt_smart_imx6ull-
4d9879e3d543a4e4ddd4b73ce0d30668127f5c5a
[ "Apache-2.0" ]
2
2021-11-10T12:07:35.000Z
2022-01-17T14:24:56.000Z
/* * Copyright (c) 2006-2020, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2020-02-23 Jesven first version */ #include <rthw.h> #include <rtdevice.h> #include "lwp_console.h" #define DBG_TAG "CONSOLE" #define DBG_LVL DBG_INFO #include <rtdbg.h> #define CHAR_CTRL_D 0x4 #define CHAR_CTRL_C 0x3 enum { CONSOLE_INIT_FLAG_NONE = 0, CONSOLE_INIT_FLAG_REGED, CONSOLE_INIT_FLAG_INITED, }; static struct rt_console_device _console; rt_inline struct rt_wqueue *wait_queue_get(struct rt_lwp * lwp) { if (lwp == RT_PROCESS_KERNEL) { return &_console.wait_queue; } return &lwp->wait_queue; } rt_inline struct rt_wqueue *wait_queue_current_get(void) { return wait_queue_get(_console.foreground); } static void console_wakeup_check(struct rt_console_device *console) { rt_size_t len; struct rt_wqueue *wq; len = rt_ringbuffer_data_len(&console->input_rb); if (len) { wq = wait_queue_current_get(); rt_wqueue_wakeup(wq, (void*)POLLIN); } } static void console_rx_notify(struct rt_device *dev) { struct rt_console_device *console; rt_size_t len; rt_uint8_t ch; console = (struct rt_console_device *)dev; RT_ASSERT(console != RT_NULL); while (1) { len = rt_device_read(console->iodev, -1, &ch, 1); if (len == 0) { break; } if (ch == CHAR_CTRL_D) /* ctrl-d */ { console->foreground = RT_PROCESS_KERNEL; } else if (ch == CHAR_CTRL_C) /* ctrl-c */ { lwp_terminate(console->foreground); } else { rt_ringbuffer_put_force(&console->input_rb, &ch, 1); } } console_wakeup_check(console); } void rt_console_set_foreground(struct rt_lwp *lwp) { rt_base_t level; level = rt_hw_interrupt_disable(); if (_console.init_flag != CONSOLE_INIT_FLAG_INITED) { goto exit; } _console.foreground = lwp; console_wakeup_check(&_console); exit: rt_hw_interrupt_enable(level); } struct rt_lwp * rt_console_get_foreground(void) { struct rt_lwp *lwp; rt_base_t level; level = rt_hw_interrupt_disable(); lwp = _console.foreground; rt_hw_interrupt_enable(level); return lwp; } static void iodev_close(struct rt_console_device *console) { struct rt_device_notify rx_notify; rx_notify.notify = RT_NULL; rx_notify.dev = RT_NULL; /* clear notify */ rt_device_control(console->iodev, RT_DEVICE_CTRL_NOTIFY_SET, &rx_notify); rt_device_close(console->iodev); } static rt_err_t iodev_open(struct rt_console_device *console) { rt_err_t ret; struct rt_device_notify rx_notify; rt_uint16_t oflags; rt_device_control(console->iodev, RT_DEVICE_CTRL_CONSOLE_OFLAG, &oflags); ret = rt_device_open(console->iodev, oflags); if (ret != RT_EOK) { return RT_ERROR; } rx_notify.notify = console_rx_notify; rx_notify.dev = (struct rt_device *)console; rt_device_control(console->iodev, RT_DEVICE_CTRL_NOTIFY_SET, &rx_notify); return RT_EOK; } struct rt_device *rt_console_get_iodev(void) { rt_base_t level; struct rt_device *iodev; level = rt_hw_interrupt_disable(); iodev = _console.iodev; rt_hw_interrupt_enable(level); return iodev; } struct rt_device *rt_console_set_iodev(struct rt_device *iodev) { rt_base_t level; struct rt_device *io_before; struct rt_console_device *console; RT_ASSERT(iodev != RT_NULL); console = &_console; level = rt_hw_interrupt_disable(); RT_ASSERT(console->init_flag >= CONSOLE_INIT_FLAG_REGED); io_before = console->iodev; if (iodev == io_before) { goto exit; } if (console->init_flag >= CONSOLE_INIT_FLAG_INITED) { /* close old device */ iodev_close(console); } console->iodev = iodev; if (console->init_flag >= CONSOLE_INIT_FLAG_INITED) { rt_err_t ret; /* open new device */ ret = iodev_open(console); RT_ASSERT(ret == RT_EOK); } exit: rt_hw_interrupt_enable(level); return io_before; } #ifdef RT_USING_POSIX /* fops for console */ static int console_fops_open(struct dfs_fd *fd) { int ret; struct rt_device * device; device = (struct rt_device *)fd->data; RT_ASSERT(device != RT_NULL); ret = rt_device_open(device, fd->flags); return ret; } static int console_fops_close(struct dfs_fd *fd) { int ret; struct rt_device * device; device = (struct rt_device *)fd->data; RT_ASSERT(device != RT_NULL); ret = rt_device_close(device); return ret; } static int console_fops_read(struct dfs_fd *fd, void *buf, size_t count) { rt_base_t level; int size = 0; struct rt_console_device *console; struct rt_lwp *lwp; struct rt_wqueue *wq; console = (struct rt_console_device *)fd->data; RT_ASSERT(console != RT_NULL); RT_ASSERT(console->init_flag == CONSOLE_INIT_FLAG_INITED); lwp = (struct rt_lwp *)(rt_thread_self()->lwp); wq = wait_queue_get(lwp); level = rt_hw_interrupt_disable(); while (count) { size = rt_device_read((struct rt_device *)console, -1, buf, count); if (size > 0) { break; } if (fd->flags & O_NONBLOCK) { break; } rt_wqueue_wait(wq, 0, RT_WAITING_FOREVER); } rt_hw_interrupt_enable(level); return size; } static int console_fops_write(struct dfs_fd *fd, const void *buf, size_t count) { int size; struct rt_device * device; device = (struct rt_device *)fd->data; RT_ASSERT(device != RT_NULL); size = rt_device_write(device, -1, buf, count); return size; } static int console_fops_poll(struct dfs_fd *fd, struct rt_pollreq *req) { rt_base_t level; int mask = POLLOUT; struct rt_device * device; struct rt_console_device *console; struct rt_wqueue *wq; struct rt_lwp *lwp; device = (struct rt_device *)fd->data; RT_ASSERT(device != RT_NULL); console = (struct rt_console_device *)device; RT_ASSERT(console->init_flag == CONSOLE_INIT_FLAG_INITED); lwp = (struct rt_lwp *)(rt_thread_self()->lwp); wq = wait_queue_get(lwp); rt_poll_add(wq, req); level = rt_hw_interrupt_disable(); if (lwp == console->foreground) { rt_size_t len; len = rt_ringbuffer_data_len(&console->input_rb); if (len) { mask |= POLLIN; } } rt_hw_interrupt_enable(level); return mask; } const static struct dfs_file_ops _console_fops = { console_fops_open, console_fops_close, RT_NULL, console_fops_read, console_fops_write, RT_NULL, /* flush */ RT_NULL, /* lseek */ RT_NULL, /* getdents */ console_fops_poll, }; #endif /* RT-Thread Device Interface */ /* * This function initializes console device. */ static rt_err_t rt_console_init(struct rt_device *dev) { rt_base_t level; rt_err_t result; struct rt_console_device *console; RT_ASSERT(dev != RT_NULL); console = (struct rt_console_device *)dev; level = rt_hw_interrupt_disable(); RT_ASSERT(console->init_flag == CONSOLE_INIT_FLAG_REGED); result = iodev_open(console); if (result != RT_EOK) { goto exit; } console->init_flag = CONSOLE_INIT_FLAG_INITED; exit: rt_hw_interrupt_enable(level); return result; } static rt_err_t rt_console_open(struct rt_device *dev, rt_uint16_t oflag) { rt_err_t result = RT_EOK; struct rt_console_device *console; RT_ASSERT(dev != RT_NULL); console = (struct rt_console_device *)dev; RT_ASSERT(console != RT_NULL); RT_ASSERT(console->init_flag == CONSOLE_INIT_FLAG_INITED); return result; } static rt_err_t rt_console_close(struct rt_device *dev) { rt_err_t result = RT_EOK; struct rt_console_device *console; console = (struct rt_console_device *)dev; RT_ASSERT(console != RT_NULL); RT_ASSERT(console->init_flag == CONSOLE_INIT_FLAG_INITED); return result; } static rt_size_t rt_console_read(struct rt_device *dev, rt_off_t pos, void *buffer, rt_size_t size) { rt_base_t level; rt_size_t len = 0; struct rt_lwp *lwp; struct rt_console_device *console; console = (struct rt_console_device *)dev; RT_ASSERT(console != RT_NULL); RT_ASSERT(console->init_flag == CONSOLE_INIT_FLAG_INITED); level = rt_hw_interrupt_disable(); if (size) { lwp = lwp_self(); if (lwp == console->foreground) { len = rt_ringbuffer_data_len(&console->input_rb); if (len > size) { len = size; } if (len) { len = rt_ringbuffer_get(&console->input_rb, buffer, len); } } } rt_hw_interrupt_enable(level); return len; } static rt_size_t rt_console_write(struct rt_device *dev, rt_off_t pos, const void *buffer, rt_size_t size) { rt_base_t level; rt_size_t len = 0; struct rt_console_device *console; console = (struct rt_console_device *)dev; RT_ASSERT(console != RT_NULL); RT_ASSERT(console->init_flag == CONSOLE_INIT_FLAG_INITED); level = rt_hw_interrupt_disable(); len = rt_device_write((struct rt_device *)console->iodev, -1, buffer, size); rt_hw_interrupt_enable(level); return len; } #ifdef RT_USING_DEVICE_OPS const static struct rt_device_ops console_ops = { rt_console_init, rt_console_open, rt_console_close, rt_console_read, rt_console_write, RT_NULL, }; #endif /* * console register */ rt_err_t rt_console_register(const char *name, struct rt_device *iodev) { rt_base_t level; rt_err_t ret; struct rt_device *device; struct rt_console_device *console = &_console; level = rt_hw_interrupt_disable(); RT_ASSERT(console->init_flag == CONSOLE_INIT_FLAG_NONE); RT_ASSERT(iodev != RT_NULL); device = &(console->parent); device->type = RT_Device_Class_Char; #ifdef RT_USING_DEVICE_OPS device->ops = &console_ops; #else device->init = rt_console_init; device->open = rt_console_open; device->close = rt_console_close; device->read = rt_console_read; device->write = rt_console_write; device->control = RT_NULL; #endif /* register a character device */ ret = rt_device_register(device, name, 0); if (ret != RT_EOK) { goto exit; } #ifdef RT_USING_POSIX /* set fops */ device->fops = &_console_fops; #endif console->iodev = iodev; console->foreground = RT_PROCESS_KERNEL; rt_wqueue_init(&(console->wait_queue)); RT_ASSERT(LWP_CONSOLE_INPUT_BUFFER_SIZE > 0); rt_ringbuffer_init(&console->input_rb, console->input_buf, LWP_CONSOLE_INPUT_BUFFER_SIZE); console->init_flag = CONSOLE_INIT_FLAG_REGED; exit: rt_hw_interrupt_enable(level); return ret; }
22.51
94
0.649756
e080a0c6ead2ee0ff1eb2eb09faeebb8a4341956
2,084
h
C
src/qt/bdapaccounttablemodel.h
blackrangersoftware/brs-dynamic-core
21d2e1d944acaf50fead74e3137a67082658da6f
[ "MIT" ]
1
2020-12-29T15:35:45.000Z
2020-12-29T15:35:45.000Z
src/qt/bdapaccounttablemodel.h
yangbaitu/Dynamic
21d2e1d944acaf50fead74e3137a67082658da6f
[ "MIT" ]
null
null
null
src/qt/bdapaccounttablemodel.h
yangbaitu/Dynamic
21d2e1d944acaf50fead74e3137a67082658da6f
[ "MIT" ]
null
null
null
// Copyright (c) 2016-2019 Duality Blockchain Solutions Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef DYNAMIC_QT_BDAPACCOUNTTABLEMODEL_H #define DYNAMIC_QT_BDAPACCOUNTTABLEMODEL_H #include <QAbstractTableModel> #include <QObject> #include <QStringList> #include <QTableWidget> #include <QLabel> #include <memory> class BdapPage; class BdapAccountTablePriv; QT_BEGIN_NAMESPACE class QTimer; QT_END_NAMESPACE struct CAccountStats { unsigned int count; }; /** Qt model providing information about BDAP users and groups. */ class BdapAccountTableModel : public QAbstractTableModel { Q_OBJECT public: explicit BdapAccountTableModel(BdapPage* parent = 0); ~BdapAccountTableModel(); void startAutoRefresh(); void stopAutoRefresh(); void refreshUsers(); void refreshGroups(); enum ColumnIndex { CommonName = 0, ObjectFullPath = 1, ExpirationDate = 2 }; /** @name Methods overridden from QAbstractTableModel @{*/ int rowCount(const QModelIndex& parent) const; int columnCount(const QModelIndex& parent) const; QVariant data(const QModelIndex& index, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const; QModelIndex index(int row, int column, const QModelIndex& parent) const; Qt::ItemFlags flags(const QModelIndex& index) const; void sort(int column, Qt::SortOrder order); /*@}*/ public Q_SLOTS: void refresh(); private: BdapPage* bdapPage; QStringList columns; std::unique_ptr<BdapAccountTablePriv> priv; QTimer* timer; int currentIndex; QTableWidget* userTable; QTableWidget* groupTable; QLabel* userStatus; QLabel* groupStatus; bool myUsersChecked; bool myGroupsChecked; std::string searchUserCommon; std::string searchUserPath; std::string searchGroupCommon; std::string searchGroupPath; }; #endif // DYNAMIC_QT_BDAPACCOUNTTABLEMODEL_H
25.414634
82
0.728407
d4b2399314e8fae581c7706ca668fb13c79d69f8
7,537
c
C
src/intcgm/intcgm1.c
isabella232/cd
902db126ad1e89266d672e3b9a33405d6bfe83f7
[ "MIT" ]
5
2015-07-08T06:24:22.000Z
2020-07-30T21:55:56.000Z
src/intcgm/intcgm1.c
LuaDist/cd
902db126ad1e89266d672e3b9a33405d6bfe83f7
[ "MIT" ]
1
2022-01-13T13:16:50.000Z
2022-01-13T13:16:50.000Z
src/intcgm/intcgm1.c
isabella232/cd
902db126ad1e89266d672e3b9a33405d6bfe83f7
[ "MIT" ]
3
2019-04-13T12:06:10.000Z
2022-01-13T11:58:08.000Z
#define _INTCGM1_C_ #include <stdio.h> /* FILE, ftell, fseek, fputc, fopen, fclose, fputs, fprintf */ #include <stdlib.h> /* malloc, free */ #include <string.h> /* strlen */ #include <math.h> /* floor */ #ifdef SunOS #include <unistd.h> /* SEEK_SET, SEEK_END */ #endif #include <float.h> /* FLT_MIN, FLT_MAX */ #include <limits.h> /* INT_MIN, INT_MAX */ #include "cd.h" #include "cdcgm.h" #include "list.h" #include "types.h" #include "intcgm2.h" #include "intcgm.h" #include "bparse.h" static int isitbin ( char *fname ) { unsigned char ch[2]; int erro, c, id; unsigned short b; FILE *f = fopen ( fname, "rb" ); if (!f) return 0; erro = fread ( ch, 1, 2, f ); b = (ch[0] << 8) + ch[1]; id = ( b & 0x0FE0 ) >> 5; c = ( b & 0xF000 ) >> 12; fclose(f); if ( c==0 && id==1 ) return 1; else return 0; } static int cgmplay ( char* filename, int xmn, int xmx, int ymn, int ymx ) { intcgm_view_xmin = xmn; intcgm_view_xmax = xmx; intcgm_view_ymin = ymn; intcgm_view_ymax = ymx; intcgm_scale_factor_x = 1; intcgm_scale_factor_y = 1; intcgm_scale_factor = 1; intcgm_block = 500; intcgm_npoints = 500; intcgm_cgm.buff.size = 1024; intcgm_point_list = (tpoint *) malloc ( sizeof(tpoint)*intcgm_npoints); intcgm_cgm.buff.dados = (char *) malloc ( sizeof(char) * intcgm_cgm.buff.size ); if ( isitbin(filename) ) { intcgm_cgm.fp = fopen ( filename, "rb" ); if (!intcgm_cgm.fp) { free(intcgm_point_list); free(intcgm_cgm.buff.dados); return CD_ERROR; } fseek ( intcgm_cgm.fp, 0, SEEK_END ); intcgm_cgm.file_size = ftell ( intcgm_cgm.fp ); fseek ( intcgm_cgm.fp, 0, SEEK_SET ); intcgm_cgm.mode = 1; intcgm_cgm.cgmf = intcgm_funcs[intcgm_cgm.mode]; intcgm_cgm.int_prec.b_prec = 1; intcgm_cgm.real_prec.b_prec = 2; intcgm_cgm.ix_prec.b_prec = 1; intcgm_cgm.cd_prec = 0; intcgm_cgm.cix_prec = 0; intcgm_cgm.vdc_int.b_prec = 1; intcgm_cgm.vdc_real.b_prec = 2; } else { intcgm_cgm.fp = fopen ( filename, "r" ); if (!intcgm_cgm.fp) { free(intcgm_point_list); free(intcgm_cgm.buff.dados); return CD_ERROR; } fseek ( intcgm_cgm.fp, 0, SEEK_END ); intcgm_cgm.file_size = ftell ( intcgm_cgm.fp ); fseek ( intcgm_cgm.fp, 0, SEEK_SET ); intcgm_cgm.mode = 2; intcgm_cgm.cgmf = intcgm_funcs[intcgm_cgm.mode]; intcgm_cgm.int_prec.t_prec.minint = -32767; intcgm_cgm.int_prec.t_prec.maxint = 32767; intcgm_cgm.real_prec.t_prec.minreal = -32767; intcgm_cgm.real_prec.t_prec.maxreal = 32767; intcgm_cgm.real_prec.t_prec.digits = 4; intcgm_cgm.ix_prec.t_prec.minint = 0; intcgm_cgm.ix_prec.t_prec.maxint = 127; intcgm_cgm.cd_prec = 127; intcgm_cgm.vdc_int.t_prec.minint = -32767; intcgm_cgm.vdc_int.t_prec.maxint = 32767; intcgm_cgm.vdc_real.t_prec.minreal = 0; intcgm_cgm.vdc_real.t_prec.maxreal = 1; intcgm_cgm.vdc_real.t_prec.digits = 4; } intcgm_cgm.first = 1; intcgm_cgm.len = 0; intcgm_cgm.vdc_type = INTEGER; intcgm_cgm.max_cix = 63; intcgm_cgm.scaling_mode.mode = ABSTRACT; intcgm_cgm.scaling_mode.scale_factor = 1.; intcgm_cgm.drawing_mode = ABSTRACT; intcgm_cgm.clrsm = INDEXED; intcgm_cgm.lnwsm = SCALED; intcgm_cgm.mkssm = SCALED; intcgm_cgm.edwsm = SCALED; intcgm_cgm.vdc_ext.first.x = 0; intcgm_cgm.vdc_ext.first.y = 0; intcgm_cgm.vdc_ext.second.x = 32767; intcgm_cgm.vdc_ext.second.y = 32767; intcgm_cgm.back_color.red = 0; intcgm_cgm.back_color.green = 0; intcgm_cgm.back_color.blue = 0; intcgm_cgm.aux_color.rgb.red = 0; intcgm_cgm.aux_color.rgb.green = 0; intcgm_cgm.aux_color.rgb.blue = 0; intcgm_cgm.color_ext.black.red = 0; intcgm_cgm.color_ext.black.green = 0; intcgm_cgm.color_ext.black.blue = 0; intcgm_cgm.color_ext.white.red = 255; intcgm_cgm.color_ext.white.green = 255; intcgm_cgm.color_ext.white.blue = 255; intcgm_cgm.transparency = ON; intcgm_cgm.clip_rect.first.x = 0; intcgm_cgm.clip_rect.first.y = 0; intcgm_cgm.clip_rect.second.x = 32767; intcgm_cgm.clip_rect.second.y = 32767; intcgm_cgm.clip_ind = ON; intcgm_cgm.bc = 0; intcgm_cgm.bl= 0; intcgm_cgm.cl = 0; intcgm_line_att.index = 1; intcgm_line_att.type = LINE_SOLID; intcgm_line_att.width = 1; intcgm_line_att.color.ind = 1; intcgm_marker_att.index = 1; intcgm_marker_att.type = 1; intcgm_marker_att.size = 1; intcgm_marker_att.color.ind = 1; intcgm_text_att.index = 1; intcgm_text_att.font_index = 1; intcgm_text_att.font_list = NULL; intcgm_text_att.font = 0; intcgm_text_att.style = CD_PLAIN; intcgm_text_att.size = 8; intcgm_text_att.prec = STRING; intcgm_text_att.exp_fact = 1; intcgm_text_att.char_spacing = 0; intcgm_text_att.color.ind = 1; intcgm_text_att.height = 1; intcgm_text_att.char_up.x = 0; intcgm_text_att.char_up.y = 1; intcgm_text_att.char_base.x = 1; intcgm_text_att.char_base.y = 0; intcgm_text_att.path = PATH_RIGHT; intcgm_text_att.alignment.hor = NORMHORIZ; intcgm_text_att.alignment.ver = NORMVERT; intcgm_text_att.alignment.cont_hor = 0; intcgm_text_att.alignment.cont_ver = 0; intcgm_fill_att.index = 1; intcgm_fill_att.int_style = HOLLOW; intcgm_fill_att.color.ind = 1; intcgm_fill_att.hatch_index = 1; intcgm_fill_att.pat_index = 1; intcgm_fill_att.ref_pt.x = 0; intcgm_fill_att.ref_pt.y = 0; intcgm_fill_att.pat_list = NULL; intcgm_fill_att.pat_size.height.x = 0; intcgm_fill_att.pat_size.height.y = 0; intcgm_fill_att.pat_size.height.x = 0; intcgm_fill_att.pat_size.width.y = 0; intcgm_edge_att.index = 1; intcgm_edge_att.type = EDGE_SOLID; intcgm_edge_att.width = 1; intcgm_edge_att.color.ind = 1; intcgm_edge_att.visibility = OFF; cdCanvasLineWidth(intcgm_canvas, 1); intcgm_color_table = (trgb *) malloc ( sizeof(trgb)*intcgm_cgm.max_cix); intcgm_color_table[0].red = 255; intcgm_color_table[0].green = 255; intcgm_color_table[0].blue = 255; intcgm_color_table[1].red = 0; intcgm_color_table[1].green = 0; intcgm_color_table[1].blue = 0; while ( !(*intcgm_cgm.cgmf)() ){}; if ( intcgm_point_list!=NULL ) { free(intcgm_point_list); intcgm_point_list = NULL; } if ( intcgm_cgm.buff.dados!=NULL ) { free(intcgm_cgm.buff.dados); intcgm_cgm.buff.dados = NULL; } if ( intcgm_color_table!=NULL ) { free(intcgm_color_table); intcgm_color_table = NULL; } fclose(intcgm_cgm.fp); return CD_OK; } _cdcgmsizecb cdcgmsizecb = NULL; _cdcgmbegmtfcb cdcgmbegmtfcb = NULL; _cdcgmcountercb cdcgmcountercb = NULL; _cdcgmsclmdecb cdcgmsclmdecb = NULL; _cdcgmvdcextcb cdcgmvdcextcb = NULL; _cdcgmbegpictcb cdcgmbegpictcb = NULL; _cdcgmbegpictbcb cdcgmbegpictbcb = NULL; int cdRegisterCallbackCGM(int cb, cdCallback func) { switch (cb) { case CD_SIZECB: cdcgmsizecb = (_cdcgmsizecb)func; return CD_OK; case CD_CGMBEGMTFCB: cdcgmbegmtfcb = (_cdcgmbegmtfcb)func; return CD_OK; case CD_CGMCOUNTERCB: cdcgmcountercb = (_cdcgmcountercb)func; return CD_OK; case CD_CGMSCLMDECB: cdcgmsclmdecb = (_cdcgmsclmdecb)func; return CD_OK; case CD_CGMVDCEXTCB: cdcgmvdcextcb = (_cdcgmvdcextcb)func; return CD_OK; case CD_CGMBEGPICTCB: cdcgmbegpictcb = (_cdcgmbegpictcb)func; return CD_OK; case CD_CGMBEGPICTBCB: cdcgmbegpictbcb = (_cdcgmbegpictbcb)func; return CD_OK; } return CD_ERROR; } int cdplayCGM(cdCanvas* _canvas, int xmin, int xmax, int ymin, int ymax, void *data) { int ret; intcgm_canvas = _canvas; ret = cgmplay((char*)data, xmin, xmax, ymin, ymax); _canvas = NULL; return ret; }
25.811644
86
0.707974
dcc3df647f7c07cee16c1a595c9806d63ab515c0
1,450
c
C
bsp/boards/python/cryptoengine.c
TimothyClaeys/openwsn-fw
6efd450843c2d18337836f5e555277b7a95e59d0
[ "BSD-3-Clause" ]
null
null
null
bsp/boards/python/cryptoengine.c
TimothyClaeys/openwsn-fw
6efd450843c2d18337836f5e555277b7a95e59d0
[ "BSD-3-Clause" ]
2
2020-08-05T14:55:46.000Z
2020-10-26T13:22:34.000Z
bsp/boards/python/cryptoengine.c
TimothyClaeys/openwsn-fw
6efd450843c2d18337836f5e555277b7a95e59d0
[ "BSD-3-Clause" ]
null
null
null
/** \brief Wrapper of software implementation of CCM. \author Malisa Vucinic <malishav@gmail.com>, March 2015. */ #include "cryptoengine.h" owerror_t cryptoengine_aes_ccms_enc(uint8_t *a, uint8_t len_a, uint8_t *m, uint8_t *len_m, uint8_t *nonce, uint8_t l, uint8_t key[16], uint8_t len_mac) { (void) a; (void) len_a; (void) len_m; (void) m; (void) nonce; (void) l; (void) key; (void) len_mac; return E_FAIL; } owerror_t cryptoengine_aes_ccms_dec(uint8_t *a, uint8_t len_a, uint8_t *m, uint8_t *len_m, uint8_t *nonce, uint8_t l, uint8_t key[16], uint8_t len_mac) { (void) a; (void) len_a; (void) len_m; (void) m; (void) nonce; (void) l; (void) key; (void) len_mac; return E_FAIL; } owerror_t cryptoengine_aes_ecb_enc(uint8_t *buffer, uint8_t *key) { (void) buffer; (void) key; return E_FAIL; } owerror_t cryptoengine_init(void) { return E_FAIL; }
23.770492
67
0.424828
4728b9fde56dca285ddba500bac8a3f4f2cf5ff1
167
c
C
CheckTri/main.c
Yogendraman/Practice_C
f2012584e705ba01dbb4996fc7823e3b9c869ead
[ "Apache-2.0" ]
null
null
null
CheckTri/main.c
Yogendraman/Practice_C
f2012584e705ba01dbb4996fc7823e3b9c869ead
[ "Apache-2.0" ]
null
null
null
CheckTri/main.c
Yogendraman/Practice_C
f2012584e705ba01dbb4996fc7823e3b9c869ead
[ "Apache-2.0" ]
null
null
null
#include"fun.h" #include<stdio.h> int main() { // Given sides of triangle int x = 8, y = 7, z = 9; // Function call ccktri(x, y, z); }
13.916667
30
0.48503
69266082bb6116cb11467f3d56ab45470b896f64
1,517
h
C
code/utf32/common/osal_utf32.h
iocafe/eosal
e71239d4d6600c5e14f71a5434c2d56901c7bee8
[ "MIT" ]
1
2020-04-28T23:26:32.000Z
2020-04-28T23:26:32.000Z
code/utf32/common/osal_utf32.h
iocafe/eosal
e71239d4d6600c5e14f71a5434c2d56901c7bee8
[ "MIT" ]
null
null
null
code/utf32/common/osal_utf32.h
iocafe/eosal
e71239d4d6600c5e14f71a5434c2d56901c7bee8
[ "MIT" ]
1
2021-06-18T06:03:44.000Z
2021-06-18T06:03:44.000Z
/** @file utf32/common/osal_char32.h @brief Character classification and conversion. @author Pekka Lehtikoski @version 1.0 @date 26.4.2021 This header file contains macros and function prototypes for character classification and conversion. Copyright 2020 Pekka Lehtikoski. This file is part of the eosal and shall only be used, modified, and distributed under the terms of the project licensing. By continuing to use, modify, or distribute this file you indicate that you have read the license and understand and accept it fully. **************************************************************************************************** */ #pragma once #ifndef OSAL_UTF32_H_ #define OSAL_UTF32_H_ #include "eosal.h" #if OSAL_UTF8 /** **************************************************************************************************** @name UTF8 - UTF32 Conversion Functions The osal_char_utf32_to_utf8() function converts an UTF32 character to UTF8 encoding. This results from 1 to six bytes. The osal_char_utf8_to_utf32() converts character in UTF8 encoding to UTF32 character. **************************************************************************************************** */ /*@{*/ /* Convert an UTF32 character to UTF8 encoding. */ os_int osal_char_utf32_to_utf8( os_char *buf, os_memsz buf_sz, os_uint c32); /* Convert an UTF8 character to UTF32 character. */ os_uint osal_char_utf8_to_utf32( const os_char **c8ptr); /*@}*/ #endif #endif
28.092593
100
0.593935
505f3b696ae3db71ab1568c395dd4461a0930645
2,507
c
C
src/Regular_expressions/read_next_token.c
ajuven63/cdfa
a6bb98096a6b113d9d7c14e42655b0743db236ae
[ "Unlicense" ]
null
null
null
src/Regular_expressions/read_next_token.c
ajuven63/cdfa
a6bb98096a6b113d9d7c14e42655b0743db236ae
[ "Unlicense" ]
null
null
null
src/Regular_expressions/read_next_token.c
ajuven63/cdfa
a6bb98096a6b113d9d7c14e42655b0743db236ae
[ "Unlicense" ]
null
null
null
/* * read_next_token.c * * Created on: 22 oct. 2017 * Author: juven */ #include "cdfa_regular_expression_intern.h" #define CDFA_RETURN_TOKEN_IF_MATCH(token_type,c) \ case c : \ tok.type = token_type; \ return tok; cdfa__token cdfa__get_next_token_and_shift_cursor(const char ** cursor) { cdfa__token tok; if (cursor == NULL || *cursor == NULL){ tok.type = CDFA_INVALID_TOKEN; return tok; } tok.character = **cursor; while (isspace(tok.character)){ (*cursor)++; tok.character = **cursor; } if (tok.character == '\0'){ tok.type = CDFA_END_OF_STRING; return tok; } (*cursor)++; switch (tok.character){ CDFA_RETURN_TOKEN_IF_MATCH(CDFA_LEFT_BRACKET,'('); CDFA_RETURN_TOKEN_IF_MATCH(CDFA_RIGHT_BRACKET,')'); CDFA_RETURN_TOKEN_IF_MATCH(CDFA_LEFT_CURVED_BRACKET,'{'); CDFA_RETURN_TOKEN_IF_MATCH(CDFA_RIGHT_CURVED_BRACKET,'}'); CDFA_RETURN_TOKEN_IF_MATCH(CDFA_LEFT_SQUARE_BRACKET,'['); CDFA_RETURN_TOKEN_IF_MATCH(CDFA_RIGHT_SQUARE_BRACKET,']'); CDFA_RETURN_TOKEN_IF_MATCH(CDFA_PLUS,'+'); CDFA_RETURN_TOKEN_IF_MATCH(CDFA_STAR,'*'); CDFA_RETURN_TOKEN_IF_MATCH(CDFA_MINUS,'-'); CDFA_RETURN_TOKEN_IF_MATCH(CDFA_OR,'|'); CDFA_RETURN_TOKEN_IF_MATCH(CDFA_AND,'&'); CDFA_RETURN_TOKEN_IF_MATCH(CDFA_COMA,','); CDFA_RETURN_TOKEN_IF_MATCH(CDFA_QUESTION_MARK,'?'); CDFA_RETURN_TOKEN_IF_MATCH(CDFA_DOT, '.'); case '\\': tok.character = **cursor; if (tok.character == '\0'){ tok.type = CDFA_INVALID_TOKEN; return tok; } (*cursor)++; switch (tok.character){ case 'n': tok.character = '\n'; tok.type = CDFA_LETTER; return tok; case 't': tok.character = '\t'; tok.type = CDFA_LETTER; return tok; case 'v': tok.character = '\v'; tok.type = CDFA_LETTER; return tok; case 'r': tok.character = '\r'; tok.type = CDFA_LETTER; return tok; case 'f': tok.character = '\f'; tok.type = CDFA_LETTER; return tok; case '(': case ')': case '{': case '}': case '[': case ']': case '+': case '*': case '-': case '|': case '&': case ',': case '?': case '\\': case ' ': case '.': tok.type = CDFA_LETTER; return tok; default: tok.type = CDFA_INVALID_TOKEN; return tok; } break; default: tok.type = CDFA_LETTER; return tok; } } cdfa__token cdfa__next_token(const char ** const cursor) { const char * new_cursor = *cursor; cdfa__token next_token = cdfa__get_next_token_and_shift_cursor(&new_cursor); return next_token; }
17.171233
77
0.658556
744f8924d925ed81de1d30883e6e44e4d2fbbfb8
1,736
h
C
openair2/LAYER2/MAC/slicing/slicing_internal.h
shadansari/onos-cu-cp
16cbf4828bd11e4c7319e7a009a26b6f39fde628
[ "Apache-2.0" ]
6
2019-12-27T00:55:47.000Z
2021-11-16T11:36:20.000Z
openair2/LAYER2/MAC/slicing/slicing_internal.h
shadansari/onos-cu-cp
16cbf4828bd11e4c7319e7a009a26b6f39fde628
[ "Apache-2.0" ]
2
2021-06-17T05:01:55.000Z
2021-11-24T14:23:54.000Z
openair2/LAYER2/MAC/slicing/slicing_internal.h
shadansari/onos-cu-cp
16cbf4828bd11e4c7319e7a009a26b6f39fde628
[ "Apache-2.0" ]
15
2019-12-27T00:55:51.000Z
2022-03-28T02:13:45.000Z
/* * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The OpenAirInterface Software Alliance licenses this file to You under * the OAI Public License, Version 1.1 (the "License"); you may not use this file * except in compliance with the License. * You may obtain a copy of the License at * * http://www.openairinterface.org/?page_id=698 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *------------------------------------------------------------------------------- * For more information about the OpenAirInterface (OAI) Software Alliance: * contact@openairinterface.org */ /*! * \file slicing_internal.h * \brief Internal slice helper functions * \author Robert Schmidt * \date 2020 * \email robert.schmidt@eurecom.fr */ #ifndef __SLICING_INTERNAL_H__ #define __SLICING_INTERNAL_H__ #include "slicing.h" void slicing_add_UE(slice_info_t *si, int UE_id); void _remove_UE(slice_t **s, uint8_t *assoc, int UE_id); void slicing_remove_UE(slice_info_t *si, int UE_id); void _move_UE(slice_t **s, uint8_t *assoc, int UE_id, int to); void slicing_move_UE(slice_info_t *si, int UE_id, int idx); slice_t *_add_slice(uint8_t *n, slice_t **s); slice_t *_remove_slice(uint8_t *n, slice_t **s, uint8_t *assoc, int idx); #endif /* __SLICING_INTERNAL_H__ */
36.93617
82
0.718318
927c8dc6ad9ed6f2d736b7fe3861a4a4103ff9d9
15,028
c
C
slkq/kernel/slkq.c
charmingdisorder/code-bits
130090e298fc7de51e563ba50b9c48967075cfd2
[ "MIT" ]
1
2019-02-17T18:06:01.000Z
2019-02-17T18:06:01.000Z
slkq/kernel/slkq.c
charmingdisorder/code-bits
130090e298fc7de51e563ba50b9c48967075cfd2
[ "MIT" ]
null
null
null
slkq/kernel/slkq.c
charmingdisorder/code-bits
130090e298fc7de51e563ba50b9c48967075cfd2
[ "MIT" ]
null
null
null
/* * slkq.c: Linux kernel module that implements in-kernel queue with on-disk * spool * * Copyright (C) 2019 Alexey Mikhailov * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "../common/slkq.h" #include <linux/module.h> #include <linux/kernel.h> #include <linux/kfifo.h> #include <linux/kthread.h> #include <linux/mutex.h> #include <linux/unistd.h> #include <linux/fs.h> #include <linux/device.h> #include <linux/cdev.h> #include <linux/types.h> #include <linux/uaccess.h> #include <linux/falloc.h> #include <linux/slab.h> #include <linux/proc_fs.h> #include <linux/atomic.h> MODULE_LICENSE("GPL"); MODULE_AUTHOR("Alexey Mikhailov <alexey.mikhailov@gmail.com>"); MODULE_DESCRIPTION("Simple Linux Kernel Queue"); MODULE_VERSION("0.1"); /** * In-kernel FIFO queue being maintained with spool using on-disk file * as backing device. Interaction between in-kernel spool and external stoarge can * be described in simple way. There is kernel thread serving such interaction, * it wakes up (waitqueue) in following cases: * * - On 'push': kernel FIFO becomes full after enquing message (slkq_dev_write) * - On 'pop': kernel FIFO has enough space to accommodate more elements and on-disk * spool is not empty after dequing message (slkq_dev_read) * * This behavior is controlled by constants defined below: * * - SLKQ_FIFO_SHRINK_TO: number of elements (length) that FIFO gets shrinked to when overfulls * - SLKQ_FIFO_EXTEND_(LIMIT|TO): if queue length is lower than SLKQ_FIFO_EXTEND_LIMIT and * on-disk spool is not empty, queue gets populated from spool (to SLKQ_FIFO_EXTEND_TO * elements at max) */ #define SLKQ_FIFO_LENGTH 1024 struct slkq_fifo_msg { u_int16_t size; unsigned char *buf; }; DECLARE_KFIFO(msg_fifo, struct slkq_fifo_msg, SLKQ_FIFO_LENGTH); #define SLKQ_FIFO_EXTEND_LIMIT ((SLKQ_FIFO_LENGTH * 1) / 2) #define SLKQ_FIFO_EXTEND_TO ((SLKQ_FIFO_LENGTH * 3) / 4) #define SLKQ_FIFO_EXTEND_COND() \ ((kfifo_len(&msg_fifo) <= SLKQ_FIFO_EXTEND_LIMIT) \ && (atomic_read(&spool_size) > 0)) #define SLKQ_FIFO_SHRINK_TO ((SLKQ_FIFO_LENGTH * 3) / 4) /** * This module uses single on-disk file as queue spool. File gets extended as data * being pushed. File being read from the beginning while extracting (popping) data out, * pointer (offset) being maintained/used for this. This scheme has obvious disadvatange: * on-disk spool will keep growing. To eliminate this issue, FALLOC_FL_COLLAPSE_RANGE * being used (refer to fallocate(2)). SLKQ_SPOOL_COLLAPSE_LIMIT defines threshold * which is used to decide when to "cut" the beginning of file. So collapse happens * when offset becomes greater than threshold value. * * It must be noted that FALLOC_FL_COLLAPSE_RANGE is currently only supported * by ext4 and XFS filesystem (see fallocate(2)). */ #define SLKQ_SPOOL_COLLAPSE_LIMIT (4096 * 1024) #define SLKQ_DISK_BLK_SIZE 4096 static wait_queue_head_t msg_new_q; /* (dev_write && NEW) => dev_read unblocks */ static wait_queue_head_t msg_spool_q; /* (dev_write && FULL) || (dev_read && EXTEND_COND) => spool_thread wakes*/ static struct mutex in_fifo_lock; static struct mutex out_fifo_lock; static struct file *spool_f; static atomic_t spool_size = ATOMIC_INIT(0); static loff_t spool_pos = 0; static struct task_struct *spool_thr; /* slab allocator is used for in-kernel queue elements (messages) */ static struct kmem_cache *msg_cache; /** * /dev/slkq character device is used for communication between kernel-space * and user-space applications. read() syscall implies 'pop' operation and * write() is used for 'push' */ static dev_t dev; static struct device *devp; static struct cdev chr_dev; static struct class *dev_cls = NULL; /** * /proc/slkq_status is used to get queue's statistics * * Status string consists of 4 numbers: used elements, free elements, total elements, * spool size. E.g. * * $ cat /proc/slkq_status * 768 256 1024 259 * * There is in-kernel queue with total of 1024 elements (768 used, 256 free), and on-disk * spool holds 259 elements */ static struct proc_dir_entry *status_ent; /** * __unload_to_spool -- shrinks in-kernel queue by moving elements to disk spool * * Must be called with out_fifo_lock down (race with slkq_dev_read) */ static ssize_t __unload_to_spool (void) { ssize_t ret = 0; struct slkq_fifo_msg m; loff_t pos; dev_dbg(devp, "shrinking to %d\n", SLKQ_FIFO_SHRINK_TO); while (kfifo_len(&msg_fifo) > SLKQ_FIFO_SHRINK_TO && kfifo_get(&msg_fifo, &m)) { pos = vfs_llseek(spool_f, 0, SEEK_END); /** * Spool file uses variable record format where the record's first two * bytes indicate the length of the record. */ ret = kernel_write(spool_f, (char *)&(m.size), 2, pos); if (ret != 2) { dev_err(devp, "%s\n", __func__); if (ret > 0) ret = -ENOMEM; ret = -1; break; } pos += 2; ret = kernel_write(spool_f, m.buf, m.size, pos); if (ret != m.size) { dev_err(devp, "%s\n", __func__); if (ret > 0) ret = -ENOMEM; ret = -1; break; } atomic_inc(&spool_size); ret = 0; } dev_dbg(devp, "unload done, %u\n", kfifo_len(&msg_fifo)); kmem_cache_free(msg_cache, m.buf); return ret; } /** * __load_from_spool -- loads messages to queue from disk spool * * Must be called with in_fifo_lock down (race with slkq_dev_write) */ static int __load_from_spool (void) { u_int16_t siz; struct slkq_fifo_msg m; dev_dbg(devp, "extend_to = %d, len = %d, spool_size = %d\n", SLKQ_FIFO_EXTEND_TO, kfifo_len(&msg_fifo), atomic_read(&spool_size)); while ((kfifo_len(&msg_fifo) < SLKQ_FIFO_EXTEND_TO) && (atomic_read(&spool_size) > 0) && (!kfifo_is_full(&msg_fifo))) { loff_t pos = spool_pos; if ((kernel_read(spool_f, pos, (void *)&siz, 2)) != 2) { dev_err(devp, "%s: kernel_read (size)\n", __func__); return -EIO; } m.size = siz; m.buf = kmem_cache_alloc(msg_cache, GFP_KERNEL); pos += 2; if ((kernel_read(spool_f, pos, m.buf, siz)) != siz) { dev_err(devp, "%s: kernel_read (data) %u\n", __func__, siz); kmem_cache_free(msg_cache, m.buf); return -EIO; } pos += siz; if (kfifo_put(&msg_fifo, m) != 1) { kmem_cache_free(msg_cache, m.buf); return -EIO; } spool_pos = pos;; atomic_dec(&spool_size); } /* "Cut" the beginning of file using FALLOCATE (if limit is reached) */ if (spool_pos > SLKQ_SPOOL_COLLAPSE_LIMIT) { dev_dbg(devp, "%s: going to collapse\n", __func__); if (vfs_fallocate(spool_f, FALLOC_FL_COLLAPSE_RANGE, 0, (spool_pos / SLKQ_DISK_BLK_SIZE) * SLKQ_DISK_BLK_SIZE)) { dev_dbg(devp, "%s: vfs_fallocate() failed\n", __func__); } else { spool_pos = spool_pos % SLKQ_DISK_BLK_SIZE; } } return 0; } /** * slkq_dev_read -- pops queue element which is triggered by reading /dev/slkq * * Note that the ordering can't be guaranteed because first blocks of queue are * moved to on-disk storage when it's full, and it gets recovered only when enough * space available (as we try to minimize amount of I/O) * */ static ssize_t slkq_dev_read (struct file *file, char __user *ubuf, size_t len, loff_t *off) { ssize_t ret; unsigned int copied; struct slkq_fifo_msg m; ret = mutex_lock_interruptible(&out_fifo_lock); if (ret) return ret; while (kfifo_is_empty(&msg_fifo)) { mutex_unlock(&out_fifo_lock); if (file->f_flags & O_NONBLOCK) { return -EAGAIN; } ret = wait_event_interruptible(msg_new_q, !kfifo_is_empty(&msg_fifo)); if (ret) { return ret; } ret = mutex_lock_interruptible(&out_fifo_lock); if (ret) { return ret; } } /* Just peeking at this point because message size can be larger than * user provided buffer so syscall is going to fail */ ret = kfifo_peek(&msg_fifo, &m); if (ret != 1) { dev_err(devp, "kfifo_peek failed\n"); goto unlock; } if (m.size > len) { dev_err(devp, "buffer is too small (%u > %lu)\n", m.size, len); ret = -EFAULT; goto unlock; } ret = copy_to_user(ubuf, m.buf, m.size); if (WARN_ON(ret)) { dev_err(devp, "copy_to_user failed\n"); ret = -EFAULT; goto unlock; } /* Safe to skip at this point */ kfifo_skip(&msg_fifo); mutex_unlock(&out_fifo_lock); if (SLKQ_FIFO_EXTEND_COND()) { wake_up_interruptible(&msg_spool_q); } return (m.size); unlock: mutex_unlock(&out_fifo_lock); return (ret) ? (ret) : (copied); } /** * slkq_dev_write -- push element to queue element which is trigerred by * writing to /dev/slkq * * Note that the ordering can't be guaranteed because first blocks of queue are * moved to on-disk storage when it's full, and it gets recovered only when enough * space available (as we try to minimize amount of I/O) */ static ssize_t slkq_dev_write (struct file *file, const char __user *ubuf, size_t len, loff_t *off) { ssize_t ret; struct slkq_fifo_msg m; if (len > SLKQ_MSG_MAX_SIZE) { dev_err(devp, "%s: wrong len = %lu\n", __func__, len); return -EINVAL; } if (*off != 0) { dev_err(devp, "%s: offset specified\n", __func__); return -EINVAL; } ret = mutex_trylock(&in_fifo_lock); if ((ret == 0) && (file->f_flags & O_NONBLOCK)) { return -EAGAIN; } else if (ret == 0) { ret = mutex_lock_interruptible(&in_fifo_lock); } if (kfifo_is_full(&msg_fifo)) { mutex_unlock(&in_fifo_lock); wake_up_interruptible(&msg_spool_q); dev_err(devp, "%s: FATAL queue_full, this shouldn't happen\n", __func__); return -1; } m.buf = kmem_cache_alloc(msg_cache, GFP_KERNEL); if (!m.buf) { dev_err(devp, "kmem_cache_alloc failed\n"); goto err1; } ret = copy_from_user(m.buf, ubuf, len); if (ret) { dev_err(devp, "user => kernel failed\n"); goto err; } m.size = len; ret = kfifo_put(&msg_fifo, m); if (ret != 1) { dev_err(devp, "kfifo_put returned %zd\n", ret); goto err; } if (kfifo_is_full(&msg_fifo)) { dev_dbg(devp, "%s: full, waking spool_thread\n", __func__); wake_up_interruptible(&msg_spool_q); } wake_up_interruptible(&msg_new_q); mutex_unlock(&in_fifo_lock); return len; err: kmem_cache_free(msg_cache, m.buf); err1: mutex_unlock(&in_fifo_lock); return -EFAULT; } static const struct file_operations slkq_dev_ops = { .owner = THIS_MODULE, .write = slkq_dev_write, .read = slkq_dev_read, }; /** * slkq_status_read -- return status string that is accessed by reading * /proc/slkq_status entry */ static ssize_t slkq_status_read (struct file *file, char __user *ubuf, size_t count, loff_t *off) { char buf[128]; int len = 0; if (*off) { return 0; } len += sprintf(buf, "%u %u %u %d\n", kfifo_len(&msg_fifo), kfifo_avail(&msg_fifo), kfifo_size(&msg_fifo), atomic_read(&spool_size)); if (copy_to_user(ubuf, buf, len)) { return -EFAULT; } *off = len; return len; } static const struct file_operations slkq_status_ops = { .owner = THIS_MODULE, .read = slkq_status_read, }; /** * slkq_spool_thread() handles in-kernel queue <=> spool interaction described above */ static int slkq_spool_thread (void *data) { for (;;) { ssize_t ret; wait_event_interruptible(msg_spool_q, kthread_should_stop() || kfifo_is_full(&msg_fifo) || SLKQ_FIFO_EXTEND_COND()); if (kthread_should_stop()) { return 0; } /* FIFO is full and part of it must be unloaded to disk */ if (kfifo_is_full(&msg_fifo)) { dev_dbg(devp, "%s: going to unload\n", __func__); ret = mutex_lock_interruptible(&out_fifo_lock); if (ret) continue; __unload_to_spool(); mutex_unlock(&out_fifo_lock); continue; } /* Check if there is enough room for more elements, and load * from spool if available */ if (SLKQ_FIFO_EXTEND_COND()) { dev_dbg(devp, "%s: going to load\n", __func__); ret = mutex_lock_interruptible(&in_fifo_lock); if (ret) continue; if (__load_from_spool() != 0) { dev_err(devp, "%s: load_from_spool() failed\n", __func__); mutex_unlock(&in_fifo_lock); BUG(); /* XXX: shouldn't happen */ return -1; } mutex_unlock(&in_fifo_lock); continue; } BUG(); } return 0; } static int slkq_init (void) { int ret; INIT_KFIFO(msg_fifo); init_waitqueue_head(&msg_new_q); init_waitqueue_head(&msg_spool_q); mutex_init(&in_fifo_lock); mutex_init(&out_fifo_lock); if ((ret = alloc_chrdev_region(&dev, 0, 1, SLKQ_NAME)) < 0) { pr_err("%s: failed to alloc dev region (ret = %d)", __func__, ret); goto err0; } cdev_init(&chr_dev, &slkq_dev_ops); if ((ret = cdev_add(&chr_dev, dev, 1))) { pr_err("%s: failed to add device (ret = %d)\n", __func__, ret); goto err1; } dev_cls = class_create(THIS_MODULE, SLKQ_NAME); if (dev_cls == NULL) { pr_err("%s: failed to register device class\n", __func__); goto err2; } devp = device_create(dev_cls, NULL, dev, NULL, SLKQ_NAME); if (IS_ERR(devp)) { pr_err("%s: failed to create device\n", __func__); goto err3; } spool_f = filp_open(SLKQ_SPOOL_FILENAME, O_RDWR | O_TRUNC | O_CREAT | O_SYNC, 0); if (IS_ERR(spool_f)) { pr_err("%s: failed to open spool file\n", __func__); goto err4; } msg_cache = kmem_cache_create(SLKQ_NAME, SLKQ_MSG_MAX_SIZE, 0, 0, NULL); if (!msg_cache) { pr_err("%s: failed to create cache\n", __func__); goto err5; } spool_thr = kthread_run(slkq_spool_thread, NULL, "slkq_spool_thr"); if (IS_ERR(spool_thr)) { pr_err("%s: start of spool thread failed\n", __func__); goto err6; } status_ent = proc_create(SLKQ_PROC_STATUS_FILENAME, 0, NULL, &slkq_status_ops); if (!status_ent) { pr_err("%s: failed to create proc file\n", __func__); goto err7; } dev_dbg(devp, "started\n"); return 0; remove_proc_entry(SLKQ_PROC_STATUS_FILENAME, NULL); err7: kthread_stop(spool_thr); err6: kmem_cache_destroy(msg_cache); err5: filp_close(spool_f, NULL); err4: device_destroy(dev_cls, dev); err3: class_destroy(dev_cls); err2: cdev_del(&chr_dev); err1: unregister_chrdev_region(dev, 1); err0: kfifo_free(&msg_fifo); return -ENODEV; } static void slkq_exit (void) { remove_proc_entry(SLKQ_PROC_STATUS_FILENAME, NULL); kthread_stop(spool_thr); kmem_cache_destroy(msg_cache); filp_close(spool_f, NULL); device_destroy(dev_cls, dev); cdev_del(&chr_dev); unregister_chrdev_region(dev, 1); class_destroy(dev_cls); kfifo_free(&msg_fifo); return; } module_init(slkq_init); module_exit(slkq_exit);
24.757825
95
0.692973
de9455e9dc05f8105046675237095baceb4edd6a
674
c
C
test/istime_test.c
icesky1stm/islib
14d4b496ebc57f13944081fd751aa956f441462d
[ "Apache-2.0" ]
1
2021-01-01T04:44:34.000Z
2021-01-01T04:44:34.000Z
test/istime_test.c
icesky1stm/islib
14d4b496ebc57f13944081fd751aa956f441462d
[ "Apache-2.0" ]
null
null
null
test/istime_test.c
icesky1stm/islib
14d4b496ebc57f13944081fd751aa956f441462d
[ "Apache-2.0" ]
null
null
null
// // Created by suitm on 2020/12/30. // #include <string.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include "../src/istime.h" int main(){ printf( "timezone = [%ld]\n", timezone); printf("istime_version = [%s]\n", istime_version()); printf("istime_us = [%llu]\n", istime_us()); char isodate[20]; memset( isodate, 0x00, sizeof(isodate)); istime_iso8601(isodate, sizeof(isodate)-1, istime_us()); printf( "istime_iso8601 = [%s]\n", isodate); printf( "istime_longdate = [%ld]\n", istime_longdate()); printf( "istime_longtime = [%ld]\n", istime_longtime()); printf( "timezone = [%ld]\n", timezone); return 0; }
24.071429
60
0.617211
d30a580112b32c0655aec1c3e2e7ed298ce51cc3
3,485
c
C
app/util/calendar.c
tisan-kit/ds1307-plug-demo
027cfe22bfebe803907272dd8615438d951851c9
[ "MIT" ]
3
2017-09-25T13:11:36.000Z
2019-10-17T12:12:30.000Z
app/util/calendar.c
tisan-kit/ds1307-plug-demo
027cfe22bfebe803907272dd8615438d951851c9
[ "MIT" ]
null
null
null
app/util/calendar.c
tisan-kit/ds1307-plug-demo
027cfe22bfebe803907272dd8615438d951851c9
[ "MIT" ]
3
2016-03-25T15:41:12.000Z
2019-10-17T12:12:32.000Z
/* * calendar.c * * Created on: 2015年12月17日 * Author: Administrator */ #include "calendar.h" //Monthly revisions table uint8 const week_amend_table[12]={0,3,3,6,1,4,6,2,5,0,3,5}; //amount of day of each month in common year const uint8 day_month_table[12]={31,28,31,30,31,30,31,31,30,31,30,31}; /** * @brief judge if it is leap year * @param year: * @retval 1: is a leap year; 0: is not a leap year * */ uint8 is_leap_year(uint16 year) { if(year%4==0) { if(year%100==0) { if(year%400==0)return 1; else return 0; }else return 1; }else return 0; } /** * @brief get rtc counter, thr return value can be the param to the RTC_SetCounter(seccount) directly * @param year: * @param month: * @param day: day * @param hour: * @param min: * @param sec: * @retval second counter */ uint32 get_rtc_counter(uint16 year,uint8 month,uint8 day,uint8 hour,uint8 min,uint8 sec) { uint16 t; uint32 seccount; if(year<1970||year>2099)return 1; for(t=1970;t<year;t++) //add all the second of the year before from 1970 { if(is_leap_year(t))seccount+=31622400;//the amount of second of leap year else seccount+=31536000; //common year } month-=1; for(t=0;t<month;t++) //add all the second of the month before { seccount+=(uint32)day_month_table[t]*86400; if(is_leap_year(year)&&t==1)seccount+=86400; } seccount+=(uint32)(day-1)*86400; seccount+=(uint32)hour*3600; seccount+=(uint32)min*60; seccount+=(uint32)sec; return seccount; } uint32 get_day_counter(uint8 hour,uint8 min,uint8 sec) { uint32 seccount = 0; seccount+=(uint32)hour*3600; seccount+=(uint32)min*60; seccount+=(uint32)sec; return seccount; } /** * * @brief get what day is it. the Gregorian calendar(1901 ¡«¡¡2099) * @param year: * @param month: * @param day: * @retval the num of the week */ uint8_t get_weekday(uint16 year,uint8 month,uint8 day) { uint16 temp2; uint8 yearH,yearL; yearH=year/100; yearL=year%100; // if (yearH>19)yearL+=100; // temp2 = yearL+yearL/4; temp2 = temp2%7; temp2 = temp2 + day + week_amend_table[month-1]; if ((yearL%4 == 0) && (month<3))temp2--; return(temp2 % 7); } /** * * @brief get the calendar from time_value and time_zone * @param time_value: * @param time_zone: * @param cal: out * @retval the num of the week */ void get_calendar(uint32 time_value, int time_zone, struct calendar *cal) { static uint16 daycnt = 0; uint16 temp1 = 0; uint32 temp = 0;//time_value / 86400; //a day of second is( 24 * 60 * 60 = 86400) int zone = 0; if(time_zone > 12) //east 12 time zone { time_zone = 12; } else if(time_zone < -12) //west 12 time zone { time_zone = -12; } temp = (time_value + time_zone * 3600)/86400; if(daycnt != temp) { daycnt = temp; temp1 = 1970; while(temp >= 365) { if(is_leap_year(temp1)) { if(temp >= 366){temp -= 366; } else{ temp1++; break;} } else temp -= 365; temp1++; } cal->year = temp1; temp1 = 0; while(temp >= 28) { if(is_leap_year(cal->year) && (temp1 == 1)) { if(temp >= 29) temp -= 29; else break; } else { if(temp >= day_month_table[temp1]) { temp -= day_month_table[temp1]; } else break; } temp1++; } cal->month = temp1 + 1; cal->date = temp + 1; } temp = (time_value + time_zone * 3600) % 86400; cal->hour = temp/3600; cal->min = (temp%3600)/60; cal->sec = temp%3600%60; cal->weekday = get_weekday(cal->year, cal->month, cal->date); }
19.914286
100
0.632425
541b2ed134ffdc19016d93b67eff1756adafa681
3,403
h
C
Engine/Plugins/Media/PixelStreaming/Source/PixelStreaming/Private/PixelStreamingVideoEncoder.h
denfrost/UE5MainStreaming
b16e03a9bf01987d390f066f500bcff4b75ea790
[ "MIT" ]
2
2021-11-26T13:33:32.000Z
2021-12-31T08:52:21.000Z
Engine/Plugins/Media/PixelStreaming/Source/PixelStreaming/Private/PixelStreamingVideoEncoder.h
denfrost/UE5MainStreaming
b16e03a9bf01987d390f066f500bcff4b75ea790
[ "MIT" ]
null
null
null
Engine/Plugins/Media/PixelStreaming/Source/PixelStreaming/Private/PixelStreamingVideoEncoder.h
denfrost/UE5MainStreaming
b16e03a9bf01987d390f066f500bcff4b75ea790
[ "MIT" ]
1
2021-10-11T10:05:52.000Z
2021-10-11T10:05:52.000Z
// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "PlayerId.h" #include "HAL/ThreadSafeBool.h" #include "WebRTCIncludes.h" #include "VideoEncoder.h" #include "Templates/SharedPointer.h" #include "Misc/Optional.h" class IPixelStreamingSessions; class FPlayerSession; struct FEncoderContext; // Implementation that is a WebRTC video encoder that allows us tie to our actually underlying non-WebRTC video encoder. class FPixelStreamingVideoEncoder : public webrtc::VideoEncoder { public: FPixelStreamingVideoEncoder(const IPixelStreamingSessions* InPixelStreamingSessions, FEncoderContext* InContext); virtual ~FPixelStreamingVideoEncoder() override; // WebRTC Interface virtual int InitEncode(webrtc::VideoCodec const* codec_settings, webrtc::VideoEncoder::Settings const& settings) override; virtual int32 RegisterEncodeCompleteCallback(webrtc::EncodedImageCallback* callback) override; virtual int32 Release() override; virtual int32 Encode(webrtc::VideoFrame const& frame, std::vector<webrtc::VideoFrameType> const* frame_types) override; virtual void SetRates(RateControlParameters const& parameters) override; virtual webrtc::VideoEncoder::EncoderInfo GetEncoderInfo() const override; // Note: These funcs can also be overriden but are not pure virtual // virtual void SetFecControllerOverride(FecControllerOverride* fec_controller_override) override; // virtual void OnPacketLossRateUpdate(float packet_loss_rate) override; // virtual void OnRttUpdate(int64_t rtt_ms) override; // virtual void OnLossNotification(const LossNotification& loss_notification) override; // End WebRTC Interface. AVEncoder::FVideoEncoder::FLayerConfig GetConfig() const { return EncoderConfig; } void SendEncodedImage(webrtc::EncodedImage const& encoded_image, webrtc::CodecSpecificInfo const* codec_specific_info, webrtc::RTPFragmentationHeader const* fragmentation); FPlayerId GetPlayerId() const; bool IsRegisteredWithWebRTC(); void ForceKeyFrame() { ForceNextKeyframe = true; } int32_t GetSmoothedAverageQP() const; private: void UpdateConfig(AVEncoder::FVideoEncoder::FLayerConfig const& Config); void HandlePendingRateChange(); void CreateAVEncoder(TSharedPtr<AVEncoder::FVideoEncoderInput> encoderInput); // We store this so we can restore back to it if the user decides to use then stop using the PixelStreaming.Encoder.TargetBitrate CVar. int32 WebRtcProposedTargetBitrate = 5000000; FEncoderContext* Context; AVEncoder::FVideoEncoder::FLayerConfig EncoderConfig; webrtc::EncodedImageCallback* OnEncodedImageCallback = nullptr; // Note: Each encoder is associated with a player/peer. // However, only one encoder controls the quality of the stream, all the others just get this peer's quality. // The alternative is encoding separate streams for each peer, which is not tenable while NVENC sessions are limited. FPlayerId OwnerPlayerId; bool ForceNextKeyframe = false; // USed for checks such as whether a given player id is associated with the quality controlling player. const IPixelStreamingSessions* PixelStreamingSessions; // WebRTC may request a bitrate/framerate change using SetRates(), we only respect this if this encoder is actually encoding // so we use this optional object to store a rate change and act upon it when this encoder does its next call to Encode(). TOptional<RateControlParameters> PendingRateChange; };
46.616438
173
0.809874
b8d36169ee324b676c9265e68ee58283f8efe23e
5,347
h
C
src/Kernel/Math/StdFunction.h
cea-trust-platform/trust-code
c4f42d8f8602a8cc5e0ead0e29dbf0be8ac52f72
[ "BSD-3-Clause" ]
12
2021-06-30T18:50:38.000Z
2022-03-23T09:03:16.000Z
src/Kernel/Math/StdFunction.h
pledac/trust-code
46ab5c5da3f674185f53423090f526a38ecdbad1
[ "BSD-3-Clause" ]
null
null
null
src/Kernel/Math/StdFunction.h
pledac/trust-code
46ab5c5da3f674185f53423090f526a38ecdbad1
[ "BSD-3-Clause" ]
2
2021-10-04T09:19:39.000Z
2021-12-15T14:21:04.000Z
/**************************************************************************** * Copyright (c) 2021, CEA * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ ////////////////////////////////////////////////////////////////////////////// // // File: StdFunction.h // Directory: $TRUST_ROOT/src/Kernel/Math // Version: /main/16 // ////////////////////////////////////////////////////////////////////////////// #ifndef StdFunction_included #define StdFunction_included #include <UnaryFunction.h> #include <cmath> #include <Double.h> /////////////////////////////////////////////////////////////////////////= //// .DESCRIPTION //// StdFunction //// .SECTION voir aussi ///////////////////////////////////////////////////////////////////////////= // default functions for parser double drand(double x) ; class StdFunction : public UnaryFunction { Declare_base(StdFunction); public: const Nom& getName() const { return que_suis_je(); } }; class Sin : public StdFunction { Declare_instanciable(Sin); public: double eval(double x) { return sin(x); } }; class Asin : public StdFunction { Declare_instanciable(Asin); public: double eval(double x) { return asin(x); } }; class Cos : public StdFunction { Declare_instanciable(Cos); public: double eval(double x) { return cos(x); } }; class Acos : public StdFunction { Declare_instanciable(Acos); public: double eval(double x) { return acos(x); } }; class Tan : public StdFunction { Declare_instanciable(Tan); public: double eval(double x) { return tan(x); } }; class Atan : public StdFunction { Declare_instanciable(Atan); public: double eval(double x) { return atan(x); } }; class Ln : public StdFunction { Declare_instanciable(Ln); public: double eval(double x) { if (x<=0) { Cerr << "x=" << x << " for LN(x) function used." << finl << "Check your data file." << finl; exit(); } return log(x); } }; class Exp : public StdFunction { Declare_instanciable(Exp); public: double eval(double x) { return exp(x); } }; class Sqrt : public StdFunction { Declare_instanciable(Sqrt); public: double eval(double x) { if (x<0) { Cerr << "x=" << x << " for SQRT(x) function used." << finl << "Check your data file." << finl; exit(); } return sqrt(x); } }; class Int : public StdFunction { Declare_instanciable(Int); public: double eval(double x) { return (int) x; } }; class Erf : public StdFunction { Declare_instanciable(Erf); public: double eval(double x) #ifndef MICROSOFT { return erf(x); } #else { Cerr << "erf(x) fonction not implemented on Windows version." << finl; exit(); return eval(x); } #endif }; class Rnd : public StdFunction { Declare_instanciable(Rnd); public: double eval(double x) { return drand(x); } }; class Cosh : public StdFunction { Declare_instanciable(Cosh); public: double eval(double x) { return cosh(x); } }; class Sinh : public StdFunction { Declare_instanciable(Sinh); public: double eval(double x) { return sinh(x); } }; class Tanh : public StdFunction { Declare_instanciable(Tanh); public: double eval(double x) { return tanh(x); } }; class Atanh : public StdFunction { Declare_instanciable(Atanh); public: double eval(double x) { return atanh(x); } }; class Not : public StdFunction { Declare_instanciable(Not); public: double eval(double x) { if (x==0) return 1 ; else return 0; } }; class Abs : public StdFunction { Declare_instanciable(Abs); public: double eval(double x) { return dabs(x); } }; class Sgn : public StdFunction { Declare_instanciable(Sgn); public: double eval(double x) { return (x > 0) - (x < 0); } }; #endif
20.724806
260
0.623714
4bbc689afd0c0d6a4a4cdbd098b064f6316a1184
185
h
C
LGPopView/LGPopView.h
LGLee/LGPopShow
23bbbb131f855abfec72328c1692148f5dfe0596
[ "Apache-2.0" ]
1
2016-12-06T10:18:14.000Z
2016-12-06T10:18:14.000Z
LGPopView/LGPopView.h
LGLee/LGPopShow
23bbbb131f855abfec72328c1692148f5dfe0596
[ "Apache-2.0" ]
null
null
null
LGPopView/LGPopView.h
LGLee/LGPopShow
23bbbb131f855abfec72328c1692148f5dfe0596
[ "Apache-2.0" ]
null
null
null
// // LGPopView.h // LGPopView // // Created by lingo on 16/11/17. // Copyright © 2016年 lingo. All rights reserved. // #import <UIKit/UIKit.h> @interface LGPopView : UIView @end
13.214286
49
0.654054
d4577cccd1d4a6857db3d07b63d466a339b0f703
1,011
h
C
runtime/basis/cpointer.h
shwestrick/mpl
9f52b733504278151ab169fc0ebe5a1bf0883537
[ "HPND" ]
709
2015-01-23T19:05:15.000Z
2022-03-31T01:55:48.000Z
runtime/basis/cpointer.h
shwestrick/mpl
9f52b733504278151ab169fc0ebe5a1bf0883537
[ "HPND" ]
172
2015-03-01T10:26:54.000Z
2022-03-27T20:22:11.000Z
runtime/basis/cpointer.h
shwestrick/mpl
9f52b733504278151ab169fc0ebe5a1bf0883537
[ "HPND" ]
129
2015-01-23T19:05:28.000Z
2022-03-27T21:55:32.000Z
PRIVATE INLINE Pointer CPointer_add (Pointer p, C_Size_t s); PRIVATE INLINE C_Size_t CPointer_diff (Pointer p1, Pointer p2); PRIVATE INLINE Bool CPointer_equal (Pointer p1, Pointer p2); PRIVATE INLINE Pointer CPointer_fromWord (C_Pointer_t x); PRIVATE INLINE Bool CPointer_lt (Pointer p1, Pointer p2); PRIVATE INLINE Pointer CPointer_sub (Pointer p, C_Size_t s); PRIVATE INLINE C_Pointer_t CPointer_toWord (Pointer p); PRIVATE INLINE Pointer CPointer_add (Pointer p, C_Size_t s) { return (p + s); } PRIVATE INLINE C_Size_t CPointer_diff (Pointer p1, Pointer p2) { return (size_t)(p1 - p2); } PRIVATE INLINE Bool CPointer_equal (Pointer p1, Pointer p2) { return (p1 == p2); } PRIVATE INLINE Pointer CPointer_fromWord (C_Pointer_t x) { return (Pointer)x; } PRIVATE INLINE Bool CPointer_lt (Pointer p1, Pointer p2) { return (p1 < p2); } PRIVATE INLINE Pointer CPointer_sub (Pointer p, C_Size_t s) { return (p - s); } PRIVATE INLINE C_Pointer_t CPointer_toWord (Pointer p) { return (C_Pointer_t)p; }
22.977273
49
0.757666
d4a2614517fd90d555d18f4077e21e8e3e2d9aac
119
h
C
src/ClipboardManager/App.xaml.h
DP458/ClipboardManager
ce85b7ed35e5e1184ea59fc26e39b9f3ff06921e
[ "MIT" ]
null
null
null
src/ClipboardManager/App.xaml.h
DP458/ClipboardManager
ce85b7ed35e5e1184ea59fc26e39b9f3ff06921e
[ "MIT" ]
null
null
null
src/ClipboardManager/App.xaml.h
DP458/ClipboardManager
ce85b7ed35e5e1184ea59fc26e39b9f3ff06921e
[ "MIT" ]
null
null
null
#pragma once #include "App.g.h" namespace ClipboardManager { public ref class App sealed { public: App(); }; }
9.916667
28
0.663866
b49f45bf3bfa6b1ee9f7a7d0871290d3bffff382
3,339
c
C
Game/SDL2/Nes模拟器/nes_main.c
qaiu/c4droid-code
5aaddbd5c72794d9dbdf9da27fb364f1e8074351
[ "MIT" ]
54
2020-11-27T17:57:59.000Z
2022-03-28T01:48:09.000Z
Game/SDL2/Nes模拟器/nes_main.c
qaiu/c4droid-code
5aaddbd5c72794d9dbdf9da27fb364f1e8074351
[ "MIT" ]
null
null
null
Game/SDL2/Nes模拟器/nes_main.c
qaiu/c4droid-code
5aaddbd5c72794d9dbdf9da27fb364f1e8074351
[ "MIT" ]
17
2020-11-28T06:36:19.000Z
2022-01-28T03:05:27.000Z
#include "nes_main.h" #include "stdio.h" #include"Timer.h" extern SDLglue_Surface *chuang; extern int8 KEY[8]; extern void keyinit(); uint8 FrameCnt; SDLglue_Event event, event2; Timer time; void NEStimer(int32 data) { uint32 clocks; // CPU执行时间 FrameCnt++; // 帧计数器 SpriteHitFlag = FALSE; for (PPU_scanline = 0; PPU_scanline < 20; PPU_scanline++) { exec6502(CLOCKS_PER_SCANLINE); } exec6502(CLOCKS_PER_SCANLINE); PPU_scanline++; // 20++ PPU_Reg.R2 &= ~R2_SPR0_HIT; for (PPU_scanline = 21; PPU_scanline < SCAN_LINE_DISPALY_END_NUM; PPU_scanline++) { if ((SpriteHitFlag == TRUE) && ((PPU_Reg.R2 & R2_SPR0_HIT) == 0)) { clocks = sprite[0].x * CLOCKS_PER_SCANLINE / NES_DISP_WIDTH; exec6502(clocks); // 需重点优化 PPU_Reg.R2 |= R2_SPR0_HIT; exec6502(CLOCKS_PER_SCANLINE - clocks); } else { exec6502(CLOCKS_PER_SCANLINE); // 耗时大户 } if (PPU_Reg.R1 & (R1_BG_VISIBLE | R1_SPR_VISIBLE)) { // 若为假,关闭显示 if (SpriteHitFlag == FALSE) { NES_GetSpr0HitFlag(PPU_scanline - SCAN_LINE_DISPALY_START_NUM); } } // if (FrameCnt % 2 == 0) { // 每3帧显示一次 // 耗时大户 // 调帧 NES_RenderLine(PPU_scanline - SCAN_LINE_DISPALY_START_NUM); FrameCnt = 0; } } exec6502(CLOCKS_PER_SCANLINE); PPU_Reg.R2 |= R2_VBlank_Flag; // 设置VBANK 标志 if (PPU_Reg.R0 & R0_VB_NMI_EN) { NMI_Flag = SET1; // 完成一帧扫描,产生NMI中断 SDLglue_UpdateRect(chuang, 0, 0, 240, 240); if (UsableButton == SDL_TRUE) { SDLglue_FixButtonRect(); SDLglue_ShowButton(); } SDLglue_Flush(); } } void event_down() // 按键 { if (event.type == SDLglue_KEYDOWN) { switch (event.key.keysym.sym) { case SDLK_UP: KEY[3] = 1; break; case SDLK_DOWN: KEY[2] = 1; break; case SDLK_LEFT: KEY[1] = 1; break; case SDLK_RIGHT: KEY[0] = 1; break; case SDLK_4: KEY[7] = 1; break; case SDLK_3: KEY[6] = 1; break; case SDLK_RETURN: KEY[4] = 1; break; case SDLK_ESCAPE: KEY[5] = 1; break; } } else { if (event.type == SDLglue_KEYUP) { switch (event.key.keysym.sym) { case SDLK_UP: KEY[3] = 0; break; case SDLK_DOWN: KEY[2] = 0; break; case SDLK_LEFT: KEY[1] = 0; break; case SDLK_RIGHT: KEY[0] = 0; break; case SDLK_4: KEY[7] = 0; break; case SDLK_3: KEY[6] = 0; break; case SDLK_RETURN: KEY[4] = 0; break; case SDLK_ESCAPE: KEY[5] = 0; break; } } } } uint16 *LCDBUF; void NesFrameCycle(void) { FrameCnt = 0; LCDBUF = (uint16 *) (chuang->pixels); // 获取数据流写入初始位置 while (1) { time.start(); while (SDLglue_PollEvent(&event)) { SDLglue_HookButton(&event); event_down(); } NEStimer(0); if (time.get_ticks() < 1000 / 50) SDLglue_Delay(1000 / 50 - time.get_ticks()); } } void nes_main(void) { NesHeader *neshreader = (NesHeader *) rom_file; NES_JoyPadInit(); init6502mem(0, 0, (&rom_file[0x10]), neshreader->romnum); /* FILE *fp; fp=fopen("/mnt/sdcard/RX/nes.txt","wb"); fprintf(fp,"%d,%d,%s,%d,%d",neshreader->romnum,neshreader->vromnum ,neshreader->filetype,neshreader->romfeature,neshreader->rommappernum ); fclose(fp); */ reset6502(); PPU_Init((&rom_file[0x10] + (neshreader->romnum * 0x4000)), (neshreader->romfeature & 0x01)); /* PPU_初始化 */ NesFrameCycle(); }
18.447514
133
0.619647
81dccab07f1cc90e5993f5786fead7e25f0050f3
1,152
h
C
PrivateFrameworks/CloudDocsDaemon.framework/BRCBookmark.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
36
2016-04-20T04:19:04.000Z
2018-10-08T04:12:25.000Z
PrivateFrameworks/CloudDocsDaemon.framework/BRCBookmark.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
null
null
null
PrivateFrameworks/CloudDocsDaemon.framework/BRCBookmark.h
shaojiankui/iOS10-Runtime-Headers
6b0d842bed0c52c2a7c1464087b3081af7e10c43
[ "MIT" ]
10
2016-06-16T02:40:44.000Z
2019-01-15T03:31:45.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/CloudDocsDaemon.framework/CloudDocsDaemon */ @interface BRCBookmark : NSObject { BRCAppLibrary * _appLibrary; NSData * _bookmarkData; bool _containsItemID; bool _dataResolved; BRCAccountSession * _session; BRCLocalItem * _target; BRCRelativePath * _targetRelpath; bool _targetResolved; BRCServerZone * _targetServerZone; } @property (nonatomic, readonly) bool containsItemID; @property (nonatomic, readonly) BRCLocalItem *target; @property (nonatomic, readonly) BRCServerZone *targetServerZone; + (id)createName; + (void)unlinkAliasAtPath:(id)arg1; - (void).cxx_destruct; - (void)_computeSignature:(unsigned char)arg1; - (bool)_resolveDataWithError:(id*)arg1; - (bool)_resolveTargetWithError:(id*)arg1; - (int)_validateSignatureWithFd:(int)arg1; - (bool)containsItemID; - (id)initWithRelpath:(id)arg1; - (id)initWithTarget:(id)arg1 owningAppLibrary:(id)arg2 path:(id)arg3 session:(id)arg4; - (bool)resolveWithError:(id*)arg1; - (id)target; - (id)targetServerZone; - (id)writeUnderParent:(id)arg1 name:(id)arg2 error:(id*)arg3; @end
30.315789
87
0.751736
dedc54e8feac5e63b67a08e4f1ac5bab5efe1d39
63
h
C
ext/hal/st/stm32cube/stm32f4xx/drivers/include/stm32f4xx_hal_hash_ex.h
dmgerman/zephyrd3
b6a23cc9c5d534c352e33fd18fff7799ac3c2886
[ "Apache-2.0" ]
null
null
null
ext/hal/st/stm32cube/stm32f4xx/drivers/include/stm32f4xx_hal_hash_ex.h
dmgerman/zephyrd3
b6a23cc9c5d534c352e33fd18fff7799ac3c2886
[ "Apache-2.0" ]
null
null
null
ext/hal/st/stm32cube/stm32f4xx/drivers/include/stm32f4xx_hal_hash_ex.h
dmgerman/zephyrd3
b6a23cc9c5d534c352e33fd18fff7799ac3c2886
[ "Apache-2.0" ]
null
null
null
DECL|__STM32F4xx_HAL_HASH_EX_H|macro|__STM32F4xx_HAL_HASH_EX_H
31.5
62
0.936508
a6b0f5fd8094c22733fe0d50954192da5ec16a67
3,356
h
C
include/mcusim/avr/sim/simcore.h
paweo90/mcusim
2422dcc830f245be0887abb3bf0ae1775d0472b0
[ "BSD-3-Clause" ]
null
null
null
include/mcusim/avr/sim/simcore.h
paweo90/mcusim
2422dcc830f245be0887abb3bf0ae1775d0472b0
[ "BSD-3-Clause" ]
null
null
null
include/mcusim/avr/sim/simcore.h
paweo90/mcusim
2422dcc830f245be0887abb3bf0ae1775d0472b0
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (c) 2017, 2018, * Dmitry Salychev <darkness.bsd@gmail.com>, * Alexander Salychev <ppsalex@rambler.ru> et al. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the <organization> nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ #ifndef MSIM_AVR_SIMCORE_H_ #define MSIM_AVR_SIMCORE_H_ 1 #ifndef MSIM_MAIN_HEADER_H_ #error "Please, include mcusim/mcusim.h instead of this header." #endif #include <stdio.h> #include <stdint.h> #include "mcusim/mcusim.h" #include "mcusim/avr/sim/init.h" #ifdef __cplusplus extern "C" { #endif /* Main simulation routine. It performs a required number of * steps (instructions). * * Zero number of steps could be used to run an infinite simulation * (until the end of the program or first breakpoint appeared). * The infinite simulation could be interrupted by the execution process * reached the given address. Addresses within the program space are taken * into account, only. * * Simulator can be started in firmware test mode, i.e. no debuggers or * any external events are necessary to perform a simulation. */ int MSIM_AVR_Simulate(struct MSIM_AVR *mcu, unsigned long steps, unsigned long addr, unsigned char firmware_test); /* Initializes an MCU into specific model determined by the given name. * It is, generally, a good idea to prepare specific MCU model using this * function instead of MSIM_XXXInit() ones. */ int MSIM_AVR_Init(struct MSIM_AVR *mcu, const char *mcu_name, unsigned char *pm, unsigned long pm_size, unsigned char *dm, unsigned long dm_size, unsigned char *mpm, FILE *fp); /* Functions to work with a stack inside MCU */ void MSIM_AVR_StackPush(struct MSIM_AVR *mcu, unsigned char val); uint8_t MSIM_AVR_StackPop(struct MSIM_AVR *mcu); /* Prints supported AVR parts. */ void MSIM_AVR_PrintParts(void); #ifdef __cplusplus } #endif #endif /* MSIM_AVR_SIMCORE_H_ */
41.432099
78
0.741359
818ad5ffb3749657af05a2ba93f4b01207f97531
9,038
c
C
freebsd4/sys/i386/isa/sound/trix.c
MarginC/kame
2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30
[ "BSD-3-Clause" ]
91
2015-01-05T15:18:31.000Z
2022-03-11T16:43:28.000Z
freebsd4/sys/i386/isa/sound/trix.c
MarginC/kame
2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30
[ "BSD-3-Clause" ]
1
2016-02-25T15:57:55.000Z
2016-02-25T16:01:02.000Z
freebsd4/sys/i386/isa/sound/trix.c
MarginC/kame
2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30
[ "BSD-3-Clause" ]
21
2015-02-07T08:23:07.000Z
2021-12-14T06:01:49.000Z
/* * sound/trix.c * * Low level driver for the MediaTriX AudioTriX Pro (MT-0002-PC Control Chip) * * Copyright by Hannu Savolainen 1995 * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. 2. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include <i386/isa/sound/sound_config.h> #if NTRIX > 0 #ifdef INCLUDE_TRIX_BOOT #include <i386/isa/sound/trix_boot.h> #endif #if (NSB > 0) extern int sb_no_recording; #endif static int kilroy_was_here = 0; /* Don't detect twice */ static int sb_initialized = 0; static sound_os_info *trix_osp = NULL; static u_char trix_read(int addr) { outb(0x390, (u_char) addr); /* MT-0002-PC ASIC address */ return inb(0x391); /* MT-0002-PC ASIC data */ } static void trix_write(int addr, int data) { outb(0x390, (u_char) addr); /* MT-0002-PC ASIC address */ outb(0x391, (u_char) data); /* MT-0002-PC ASIC data */ } static void download_boot(int base) { #ifdef INCLUDE_TRIX_BOOT int i = 0, n = sizeof(trix_boot); trix_write(0xf8, 0x00); /* ??????? */ outb(base + 6, 0x01); /* Clear the internal data pointer */ outb(base + 6, 0x00); /* Restart */ /* * Write the boot code to the RAM upload/download register. Each * write increments the internal data pointer. */ outb(base + 6, 0x01); /* Clear the internal data pointer */ outb(0x390, 0x1A); /* Select RAM download/upload port */ for (i = 0; i < n; i++) outb(0x391, trix_boot[i]); for (i = n; i < 10016; i++) /* Clear up to first 16 bytes of data RAM */ outb(0x391, 0x00); outb(base + 6, 0x00); /* Reset */ outb(0x390, 0x50); /* ?????? */ #endif } static int trix_set_wss_port(struct address_info * hw_config) { u_char addr_bits; if (0) { printf("AudioTriX: Config port I/O conflict\n"); return 0; } if (kilroy_was_here) /* Already initialized */ return 0; if (trix_read(0x15) != 0x71) { /* No asic signature */ DDB(printf("No AudioTriX ASIC signature found\n")); return 0; } kilroy_was_here = 1; /* * Reset some registers. */ trix_write(0x13, 0); trix_write(0x14, 0); /* * Configure the ASIC to place the codec to the proper I/O location */ switch (hw_config->io_base) { case 0x530: addr_bits = 0; break; case 0x604: addr_bits = 1; break; case 0xE80: addr_bits = 2; break; case 0xF40: addr_bits = 3; break; default: return 0; } trix_write(0x19, (trix_read(0x19) & 0x03) | addr_bits); return 1; } /* * Probe and attach routines for the Windows Sound System mode of AudioTriX * Pro */ int probe_trix_wss(struct address_info * hw_config) { /* * Check if the IO port returns valid signature. The original MS * Sound system returns 0x04 while some cards (AudioTriX Pro for * example) return 0x00. */ if (0) { printf("AudioTriX: MSS I/O port conflict\n"); return 0; } trix_osp = hw_config->osp; if (!trix_set_wss_port(hw_config)) return 0; if ((inb(hw_config->io_base + 3) & 0x3f) != 0x00) { DDB(printf("No MSS signature detected on port 0x%x\n", hw_config->io_base)); return 0; } if (hw_config->irq > 11) { printf("AudioTriX: Bad WSS IRQ %d\n", hw_config->irq); return 0; } if (hw_config->dma != 0 && hw_config->dma != 1 && hw_config->dma != 3) { printf("AudioTriX: Bad WSS DMA %d\n", hw_config->dma); return 0; } if (hw_config->dma2 != -1) if (hw_config->dma2 != 0 && hw_config->dma2 != 1 && hw_config->dma2 != 3) { printf("AudioTriX: Bad capture DMA %d\n", hw_config->dma2); return 0; } /* * Check that DMA0 is not in use with a 8 bit board. */ if (hw_config->dma == 0 && inb(hw_config->io_base + 3) & 0x80) { printf("AudioTriX: Can't use DMA0 with a 8 bit card\n"); return 0; } if (hw_config->irq > 7 && hw_config->irq != 9 && inb(hw_config->io_base + 3) & 0x80) { printf("AudioTriX: Can't use IRQ%d with a 8 bit card\n", hw_config->irq); return 0; } return ad1848_detect(hw_config->io_base + 4, NULL, hw_config->osp); } void attach_trix_wss(struct address_info * hw_config) { static u_char interrupt_bits[12] = {-1, -1, -1, -1, -1, -1, -1, 0x08, -1, 0x10, 0x18, 0x20}; char bits; static u_char dma_bits[4] = {1, 2, 0, 3}; int config_port = hw_config->io_base + 0, version_port = hw_config->io_base + 3; int dma1 = hw_config->dma, dma2 = hw_config->dma2; trix_osp = hw_config->osp; if (!kilroy_was_here) { DDB(printf("AudioTriX: Attach called but not probed yet???\n")); return ; } /* * Set the IRQ and DMA addresses. */ bits = interrupt_bits[hw_config->irq]; if (bits == -1) { printf("AudioTriX: Bad IRQ (%d)\n", hw_config->irq); return ; } outb(config_port, bits | 0x40); if ((inb(version_port) & 0x40) == 0) printf("[IRQ Conflict?]"); if (hw_config->dma2 == -1) { /* Single DMA mode */ bits |= dma_bits[dma1]; dma2 = dma1; } else { u_char tmp; tmp = trix_read(0x13) & ~30; trix_write(0x13, tmp | 0x80 | (dma1 << 4)); tmp = trix_read(0x14) & ~30; trix_write(0x14, tmp | 0x80 | (dma2 << 4)); } outb(config_port, bits);/* Write IRQ+DMA setup */ ad1848_init("AudioTriX Pro", hw_config->io_base + 4, hw_config->irq, dma1, dma2, 0, hw_config->osp); return ; } int probe_trix_sb(struct address_info * hw_config) { int tmp; u_char conf; static char irq_translate[] = {-1, -1, -1, 0, 1, 2, -1, 3}; #ifndef INCLUDE_TRIX_BOOT return 0; /* No boot code -> no fun */ #endif if (!kilroy_was_here) return 0; /* AudioTriX Pro has not been detected earlier */ if (sb_initialized) return 0; if ((hw_config->io_base & 0xffffff8f) != 0x200) return 0; tmp = hw_config->irq; if (tmp > 7) return 0; if (irq_translate[tmp] == -1) return 0; tmp = hw_config->dma; if (tmp != 1 && tmp != 3) return 0; conf = 0x84; /* DMA and IRQ enable */ conf |= hw_config->io_base & 0x70; /* I/O address bits */ conf |= irq_translate[hw_config->irq]; if (hw_config->dma == 3) conf |= 0x08; trix_write(0x1b, conf); download_boot(hw_config->io_base); sb_initialized = 1; return 1; } void attach_trix_sb(struct address_info * hw_config) { #if (NSB > 0) sb_dsp_disable_midi(); sb_no_recording = 1; #endif conf_printf("AudioTriX (SB)", hw_config); } void attach_trix_mpu(struct address_info * hw_config) { #if (defined(CONFIG_MPU401) || defined(CONFIG_MPU_EMU)) && defined(CONFIG_MIDI) attach_mpu401(hw_config); #endif } int probe_trix_mpu(struct address_info * hw_config) { #if (defined(CONFIG_MPU401) || defined(CONFIG_MPU_EMU)) && defined(CONFIG_MIDI) u_char conf; static char irq_bits[] = {-1, -1, -1, 1, 2, 3, -1, 4, -1, 5}; if (!kilroy_was_here) { DDB(printf("Trix: WSS and SB modes must be initialized before MPU\n")); return 0; /* AudioTriX Pro has not been detected earlier */ } if (!sb_initialized) { DDB(printf("Trix: SB mode must be initialized before MPU\n")); return 0; } if (mpu_initialized) { DDB(printf("Trix: MPU mode already initialized\n")); return 0; } if (hw_config->irq > 9) { printf("AudioTriX: Bad MPU IRQ %d\n", hw_config->irq); return 0; } if (irq_bits[hw_config->irq] == -1) { printf("AudioTriX: Bad MPU IRQ %d\n", hw_config->irq); return 0; } switch (hw_config->io_base) { case 0x330: conf = 0x00; break; case 0x370: conf = 0x04; break; case 0x3b0: conf = 0x08; break; case 0x3f0: conf = 0x0c; break; default: return 0; /* Invalid port */ } conf |= irq_bits[hw_config->irq] << 4; trix_write(0x19, (trix_read(0x19) & 0x83) | conf); mpu_initialized = 1; return probe_mpu401(hw_config); #else return 0; #endif } #endif
24.493225
90
0.63742
edbc9a9353ff13bdaf1f39c033abf20c5bf8506d
604
h
C
System/Library/PrivateFrameworks/NeutrinoCore.framework/NUImagePropertiesJob.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
1
2020-11-04T15:43:01.000Z
2020-11-04T15:43:01.000Z
System/Library/PrivateFrameworks/NeutrinoCore.framework/NUImagePropertiesJob.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/NeutrinoCore.framework/NUImagePropertiesJob.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.0 * on Sunday, September 27, 2020 at 11:45:07 AM Mountain Standard Time * Operating System: Version 14.0 (Build 18A373) * Image Source: /System/Library/PrivateFrameworks/NeutrinoCore.framework/NeutrinoCore * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ #import <NeutrinoCore/NURenderJob.h> @protocol NUImageProperties; @interface NUImagePropertiesJob : NURenderJob { id<NUImageProperties> _imageProperties; } -(id)result; -(BOOL)prepare:(out id*)arg1 ; -(BOOL)wantsRenderStage; -(BOOL)wantsCompleteStage; @end
26.26087
85
0.774834
54a71d2d6d615a45d047fbbf16e499d1773f5324
2,149
h
C
src/databases/PLY/avtPLYWriter.h
visit-dav/vis
c08bc6e538ecd7d30ddc6399ec3022b9e062127e
[ "BSD-3-Clause" ]
226
2018-12-29T01:13:49.000Z
2022-03-30T19:16:31.000Z
src/databases/PLY/avtPLYWriter.h
visit-dav/vis
c08bc6e538ecd7d30ddc6399ec3022b9e062127e
[ "BSD-3-Clause" ]
5,100
2019-01-14T18:19:25.000Z
2022-03-31T23:08:36.000Z
src/databases/PLY/avtPLYWriter.h
visit-dav/vis
c08bc6e538ecd7d30ddc6399ec3022b9e062127e
[ "BSD-3-Clause" ]
84
2019-01-24T17:41:50.000Z
2022-03-10T10:01:46.000Z
// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt // Project developers. See the top-level LICENSE file for dates and other // details. No copyright assignment is required to contribute to VisIt. // ************************************************************************* // // avtPLYWriter.h // // ************************************************************************* // #ifndef AVT_PLY_WRITER_H #define AVT_PLY_WRITER_H #include <avtDatabaseWriter.h> #include <string> class DBOptionsAttributes; class vtkPolyData; class vtkScalarsToColors; // **************************************************************************** // Class: avtPLYWriter // // Purpose: // A module that writes out PLY files. // // Programmer: pugmire -- generated by xml2avt // Creation: Tue Apr 16 08:57:58 PDT 2013 // // Modifications: // Dave Pugmire, Fri Apr 26 12:33:39 EDT 2013 // Add color table options. // // Brad Whitlock, Tue Sep 8 17:03:17 PDT 2015 // Rely on base class for geometry aggregation. // // **************************************************************************** class avtPLYWriter : public avtDatabaseWriter { public: avtPLYWriter(const DBOptionsAttributes *); virtual ~avtPLYWriter() {} protected: std::string stem; virtual void OpenFile(const std::string &, int nb); virtual void WriteHeaders(const avtDatabaseMetaData *, const std::vector<std::string> &, const std::vector<std::string> &, const std::vector<std::string> &); virtual void WriteChunk(vtkDataSet *, int); virtual void CloseFile(void); virtual bool CreateTrianglePolyData() const; virtual CombineMode GetCombineMode(const std::string &plotName) const; private: vtkScalarsToColors * GetColorTable(); bool doBinary, doColor; std::string colorTable; double colorTableMin, colorTableMax; }; #endif
31.144928
79
0.52443
90ac7c5dfb6b935ebb357c0f3d481ab7332de412
380
h
C
Framework/Sources/Helpers/SRGProgram+SRGLetterbox.h
crymscom/srgletterbox-ios
e208007bacad44d8d12385682e748add647e81b4
[ "MIT" ]
null
null
null
Framework/Sources/Helpers/SRGProgram+SRGLetterbox.h
crymscom/srgletterbox-ios
e208007bacad44d8d12385682e748add647e81b4
[ "MIT" ]
null
null
null
Framework/Sources/Helpers/SRGProgram+SRGLetterbox.h
crymscom/srgletterbox-ios
e208007bacad44d8d12385682e748add647e81b4
[ "MIT" ]
null
null
null
// // Copyright (c) SRG SSR. All rights reserved. // // License information is available from the LICENSE file. // #import <SRGDataProvider/SRGDataProvider.h> NS_ASSUME_NONNULL_BEGIN @interface SRGProgram (SRGLetterbox) /** * Returns `YES` iff the program is on air on the specified date. */ - (BOOL)srgletterbox_containsDate:(NSDate *)date; @end NS_ASSUME_NONNULL_END
18.095238
66
0.742105
1172e522e4feb93aa313f9225c90a38d221e946f
28
h
C
src/openssl-1.0.1u/include/openssl/krb5_asn.h
l0k1verloren/legacy
f709194e16960103834b0d0e25aec06c3d84f85b
[ "MIT" ]
278
2015-11-03T03:01:20.000Z
2022-01-20T18:21:05.000Z
src/openssl-1.0.1u/include/openssl/krb5_asn.h
l0k1verloren/legacy
f709194e16960103834b0d0e25aec06c3d84f85b
[ "MIT" ]
374
2015-11-03T12:37:22.000Z
2021-12-17T14:18:08.000Z
src/openssl-1.0.1u/include/openssl/krb5_asn.h
l0k1verloren/legacy
f709194e16960103834b0d0e25aec06c3d84f85b
[ "MIT" ]
96
2015-11-22T07:47:26.000Z
2022-01-20T19:52:19.000Z
../../crypto/krb5/krb5_asn.h
28
28
0.678571
698f549c5df6c4d9667337bc9d615f740d2efa06
2,517
h
C
medusa_control/static_thruster_allocation/include/thruster_allocation.h
gshubham96/medusa_base
1f6e8776ac115951eea13d227ce8c370abd2ea0e
[ "MIT" ]
null
null
null
medusa_control/static_thruster_allocation/include/thruster_allocation.h
gshubham96/medusa_base
1f6e8776ac115951eea13d227ce8c370abd2ea0e
[ "MIT" ]
1
2022-02-21T16:50:47.000Z
2022-02-21T16:50:47.000Z
medusa_control/static_thruster_allocation/include/thruster_allocation.h
gshubham96/medusa_base
1f6e8776ac115951eea13d227ce8c370abd2ea0e
[ "MIT" ]
2
2022-02-02T11:00:14.000Z
2022-03-01T08:42:05.000Z
#include <Eigen/Dense> #include <auv_msgs/BodyForceRequest.h> #include <dsor_msgs/Thruster.h> #include <medusa_gimmicks_library/MedusaGimmicks.h> #include <ros/ros.h> /** * @brief ROS implementation of the thrust allocation. Receives forces applied to the vehicle and calculates the desired forces to each thruster based on the pseudo inverse of the thrust allocation matrix */ class ThrustAllocation { public: /** * @brief Thrust Allocation class constructor * * @param nh ROS nodehandle to publish, subscribe and read relevant * parameters */ ThrustAllocation(ros::NodeHandle &nh); /** * @brief Function to initialize subscribers * * @param nh ROS nodehandle to publish, subscribe and read relevant */ void initializeSubscribers(ros::NodeHandle &nh); /** * @brief Function to initialize publishers * * @param nh ROS nodehandle to publish, subscribe and read relevant */ void initializePublishers(ros::NodeHandle &nh); /** * @brief Function to read parameters. Reads the thruster allocation matrix and computes its pseudo inverse * * @param nh ROS nodehandle to publish, subscribe and read relevant */ void loadParams(ros::NodeHandle &nh); /** * @brief Given a force vector for each thruster, saturate the norm of the vector based on the maximum force of the thruster */ void saturateVector(Eigen::VectorXd &thr_thrust); /** * @brief Function to read a thruster allocation matrix and compute its pseudo inverse * * @param nh */ void readTAM(ros::NodeHandle &nh); /** * @brief Function to read the ct parameters (conversion from thrust to RPM and vice versa) * * @param nh */ void readCT(ros::NodeHandle &nh); /** * @brief Function to read the actuators gain (RPM max value / 100). * * @param nh */ void readRPMGain(ros::NodeHandle &nh); /** * @brief Callback function of the topic with the tau (force request) * * @param msg Variable containing the force request */ void thrusterAllocation(const auv_msgs::BodyForceRequest &msg); private: ros::Subscriber ft_sub_; // thruster publishers ros::Publisher hor_left_thr_pub_; ros::Publisher hor_right_thr_pub_; ros::Publisher ver_back_thr_pub_; ros::Publisher ver_front_thr_pub_, thrusters_pub_; // max and min parameters float max_thrust_norm_; float min_thrust_norm_; Eigen::VectorXd rpm_gain_; Eigen::MatrixXd b_inv_; Eigen::Vector3d ctf_; Eigen::Vector3d ctb_; };
27.064516
205
0.706397
fd33f90209e879b09b960b09458ec961d5c68013
1,705
c
C
parse.c
w-haibara/hcc
3773663983c660218c9dc613a486ce9715e99d16
[ "MIT" ]
null
null
null
parse.c
w-haibara/hcc
3773663983c660218c9dc613a486ce9715e99d16
[ "MIT" ]
null
null
null
parse.c
w-haibara/hcc
3773663983c660218c9dc613a486ce9715e99d16
[ "MIT" ]
null
null
null
#include <ctype.h> #include <stdarg.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "hcc.h" // 現在着目しているトークン extern Token *token; // 入力プログラム extern char *user_input; // エラー箇所を報告する void error_at(char *loc, char *fmt, ...) { va_list ap; va_start(ap, fmt); int pos = loc - user_input; fprintf(stderr, "%s\n", user_input); fprintf(stderr, "%*s", pos, ""); // pos個の空白を出力 fprintf(stderr, "^ "); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); exit(1); } // エラーを報告するための関数 // printfと同じ引数を取る void error(char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); exit(1); } bool at_eof() { return token->kind == TK_EOF; } // 新しいトークンを作成してcurに繋げる Token *new_token(TokenKind kind, Token *cur, char *str, int len) { Token *tok = calloc(1, sizeof(Token)); tok->kind = kind; tok->str = str; tok->len = len; cur->next = tok; return tok; } // 入力文字列pをトークナイズしてそれを返す Token *tokenize(char *p) { Token head; head.next = NULL; Token *cur = &head; while (*p) { // 空白文字をスキップ if (isspace(*p)) { p++; continue; } if(!memcmp(p, "==", 2) || !memcmp(p, "!=", 2) || !memcmp(p, "<=", 2) || !memcmp(p, ">=", 2)){ cur = new_token(TK_RESERVED, cur, p, 2); p += 2; continue; } if (*p == '<' || *p == '>' || *p == '+' || *p == '-' || *p == '*' || *p == '/' || *p == '(' || *p == ')') { cur = new_token(TK_RESERVED, cur, p++, 1); continue; } if (isdigit(*p)) { cur = new_token(TK_NUM, cur, p, 0); char *q = p; cur->val = strtol(p, &p, 10); cur->len = p - q; continue; } error_at(cur->str, "トークナイズできません"); } new_token(TK_EOF, cur, p, 0); return head.next; }
18.532609
109
0.56129
59ab03d3a105acb955c608ee1459481312965729
26,898
h
C
include/nodecpp/http_socket_at_server.h
node-dot-cpp/node.cpp
41067613b2b1064db848b15b05bacb7950730936
[ "BSD-3-Clause" ]
30
2019-02-25T15:00:07.000Z
2022-02-04T10:58:10.000Z
include/nodecpp/http_socket_at_server.h
sthagen/node.cpp
57c04ced2b211a3c8596a41aecfb78c998f895cb
[ "BSD-3-Clause" ]
66
2019-11-29T19:25:07.000Z
2020-05-19T10:44:55.000Z
include/nodecpp/http_socket_at_server.h
sthagen/node.cpp
57c04ced2b211a3c8596a41aecfb78c998f895cb
[ "BSD-3-Clause" ]
4
2020-02-19T12:16:32.000Z
2022-02-04T10:58:15.000Z
/* ------------------------------------------------------------------------------- * Copyright (c) 2018, OLogN Technologies AG * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the OLogN Technologies AG nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL OLogN Technologies AG BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * -------------------------------------------------------------------------------*/ #ifndef HTTP_SOCKET_AT_SERVER_H #define HTTP_SOCKET_AT_SERVER_H #include "http_server_common.h" #include "socket_common.h" #include "url.h" #include <algorithm> #include <cctype> #include <string> // NOTE: current implementation is anty-optimal; it's just a sketch of what could be in use namespace nodecpp { namespace net { class IncomingHttpMessageAtServer; // forward declaration class HttpServerResponse; // forward declaration class HttpSocketBase : public nodecpp::net::SocketBase { friend class IncomingHttpMessageAtServer; friend class HttpServerResponse; #ifndef NODECPP_NO_COROUTINES static constexpr size_t maxHeaderSize = 0x4000; Buffer lineBuffer; #endif // NODECPP_NO_COROUTINES ::nodecpp::awaitable<CoroStandardOutcomes> getRequest( IncomingHttpMessageAtServer& message ); struct RRPair { nodecpp::owning_ptr<IncomingHttpMessageAtServer> request; nodecpp::owning_ptr<HttpServerResponse> response; bool active = false; }; template<size_t sizeExp> class RRQueue { RRPair* cbuff = nullptr; uint64_t head = 0; uint64_t tail = 0; size_t idxToStorageIdx(size_t idx ) { return idx & ((((size_t)1)<<sizeExp)-1); } size_t capacity() { return ((size_t)1)<<sizeExp; } public: RRQueue() {} ~RRQueue() { if ( cbuff != nullptr ) { size_t size = ((size_t)1 << sizeExp); nodecpp::dealloc( cbuff, size ); } } void init( nodecpp::soft_ptr<HttpSocketBase> ); bool canPush() { return head - tail < ((uint64_t)1<<sizeExp); } bool release( size_t idx ) { NODECPP_ASSERT( nodecpp::module_id, ::nodecpp::assert::AssertLevel::critical, idx >= tail, "{} vs. {}", idx, tail ); NODECPP_ASSERT( nodecpp::module_id, ::nodecpp::assert::AssertLevel::critical, idx < head, "{} vs. {}", idx, head ); size_t storageIdx = idxToStorageIdx( idx ); NODECPP_ASSERT( nodecpp::module_id, ::nodecpp::assert::AssertLevel::critical, storageIdx < capacity(), "{} vs. {}", storageIdx, capacity() ); cbuff[storageIdx].active = false; if ( idx == tail ) { do { ++tail; } while ( tail < head && !cbuff[idxToStorageIdx(tail)].active ); } return canPush(); } RRPair& getHead() { NODECPP_ASSERT( nodecpp::module_id, ::nodecpp::assert::AssertLevel::critical, canPush() ); auto& ret = cbuff[idxToStorageIdx(head)]; ret.active = true; ret.request->idx = head; ret.response->idx = head; ++head; return ret; } }; RRQueue<0> rrQueue; bool release( size_t idx ) { return rrQueue.release( idx ); } awaitable_handle_t ahd_continueGetting = nullptr; #ifndef NODECPP_NO_COROUTINES auto a_continueGetting() { struct continue_getting_awaiter { std::experimental::coroutine_handle<> myawaiting = nullptr; HttpSocketBase& socket; continue_getting_awaiter(HttpSocketBase& socket_) : socket( socket_ ) {} continue_getting_awaiter(const continue_getting_awaiter &) = delete; continue_getting_awaiter &operator = (const continue_getting_awaiter &) = delete; ~continue_getting_awaiter() {} bool await_ready() { return false; } void await_suspend(std::experimental::coroutine_handle<> awaiting) { nodecpp::initCoroData(awaiting); socket.ahd_continueGetting = awaiting; myawaiting = awaiting; } auto await_resume() { NODECPP_ASSERT( nodecpp::module_id, ::nodecpp::assert::AssertLevel::critical, myawaiting != nullptr ); if ( nodecpp::isCoroException(myawaiting) ) throw nodecpp::getCoroException(myawaiting); } }; return continue_getting_awaiter(*this); } ::nodecpp::awaitable<CoroStandardOutcomes> readLine(nodecpp::string& line) { lineBuffer.clear(); CoroStandardOutcomes ret = co_await a_readUntil( lineBuffer, '\n' ); if ( ret == CoroStandardOutcomes::ok ) { #ifdef NODECPP_USE_SAFE_MEMORY_CONTAINERS line.assign_unsafe( (const char*)(lineBuffer.begin()), lineBuffer.size() ); #else line.assign( (const char*)(lineBuffer.begin()), lineBuffer.size() ); #endif // NODECPP_USE_SAFE_MEMORY_CONTAINERS CO_RETURN CoroStandardOutcomes::ok; } NODECPP_ASSERT( nodecpp::module_id, ::nodecpp::assert::AssertLevel::critical, ret == CoroStandardOutcomes::insufficient_buffer ); CO_RETURN ret; } #endif // NODECPP_NO_COROUTINES public: HttpSocketBase(); virtual ~HttpSocketBase() {} #ifndef NODECPP_NO_COROUTINES nodecpp::handler_ret_type run() { for(;;) { // now we can reasonably expect a new request auto& rrPair = rrQueue.getHead(); CoroStandardOutcomes status = co_await getRequest( *(rrPair.request) ); if ( status == CoroStandardOutcomes::ok ) // the most likely outcome { soft_ptr_static_cast<HttpServerBase>(myServerSocket)->onNewRequest( rrPair.request, rrPair.response ); if ( rrQueue.canPush() ) continue; auto cg = a_continueGetting(); co_await cg; } else { // TODO: switch status, report the other side an error, if applicable ( "413 Entity Too Large" for insufficient_buffer, for instance) end(); CO_RETURN; } } CO_RETURN; } void proceedToNext() { if ( rrQueue.canPush() && ahd_continueGetting != nullptr ) { auto hr = ahd_continueGetting; ahd_continueGetting = nullptr; hr(); } } void forceReleasingAllCoroHandles() { if ( ahd_continueGetting != nullptr ) { auto hr = ahd_continueGetting; nodecpp::setCoroException(hr, std::exception()); // TODO: switch to our exceptions ASAP! ahd_continueGetting = nullptr; hr(); } } #else void forceReleasingAllCoroHandles() {} #endif // NODECPP_NO_COROUTINES }; template<class RequestT, class DataParentT> class HttpSocket : public HttpSocketBase, public ::nodecpp::DataParent<DataParentT> { public: using DataParentType = DataParentT; HttpSocket() {}; HttpSocket(DataParentT* dataParent ) : HttpSocketBase(), ::nodecpp::DataParent<DataParentT>( dataParent ) {}; virtual ~HttpSocket() {} }; template<class RequestT> class HttpSocket<RequestT, void> : public HttpSocketBase { public: using DataParentType = void; HttpSocket() {}; virtual ~HttpSocket() {} }; class IncomingHttpMessageAtServer : protected HttpMessageBase // TODO: candidate for being a part of lib { friend class HttpSocketBase; private: struct Method // so far a struct { nodecpp::string name; nodecpp::string url; nodecpp::string version; void clear() { name.clear(); url.clear(); version.clear(); } }; Method method; nodecpp::Buffer body; enum ReadStatus { noinit, in_hdr, in_body, completed }; ReadStatus readStatus = ReadStatus::noinit; size_t bodyBytesRetrieved = 0; private: public: IncomingHttpMessageAtServer() {} IncomingHttpMessageAtServer(const IncomingHttpMessageAtServer&) = delete; IncomingHttpMessageAtServer operator = (const IncomingHttpMessageAtServer&) = delete; IncomingHttpMessageAtServer(IncomingHttpMessageAtServer&& other) { method = std::move( other.method ); header = std::move( other.header ); readStatus = other.readStatus; contentLength = other.contentLength; other.readStatus = ReadStatus::noinit; } IncomingHttpMessageAtServer& operator = (IncomingHttpMessageAtServer&& other) { method = std::move( other.method ); header = std::move( other.header ); readStatus = other.readStatus; other.readStatus = ReadStatus::noinit; contentLength = other.contentLength; other.contentLength = 0; return *this; } void clear() // TODO: ensure necessity (added for reuse purposes) { method.clear(); header.clear(); body.clear(); contentLength = 0; readStatus = ReadStatus::noinit; bodyBytesRetrieved = 0; } #ifndef NODECPP_NO_COROUTINES nodecpp::handler_ret_type a_readBody( Buffer& b ) { if ( bodyBytesRetrieved < getContentLength() ) { b.clear(); co_await sock->a_read( b, getContentLength() - bodyBytesRetrieved ); bodyBytesRetrieved += b.size(); } if ( bodyBytesRetrieved == getContentLength() ) sock->proceedToNext(); CO_RETURN; } #endif // NODECPP_NO_COROUTINES bool parseMethod( const nodecpp::string& line ) { NODECPP_ASSERT( nodecpp::module_id, ::nodecpp::assert::AssertLevel::critical, readStatus == ReadStatus::noinit ); size_t start = line.find_first_not_of( " \t" ); if ( start == nodecpp::string::npos || line[start] == '\r' || line[start] == '\n' ) return false; bool found = false; // Method name for ( size_t i=0; i<MethodCount; ++i ) if ( line.size() > MethodNames[i].second + start && memcmp( line.c_str() + start, MethodNames[i].first, MethodNames[i].second ) == 0 && line.c_str()[ MethodNames[i].second] == ' ' ) // TODO: cthink about rfind(*,0) { method.name = MethodNames[i].first; start += MethodNames[i].second + 1; start = line.find_first_not_of( " \t", start ); found = true; break; } if ( !found ) return false; // URI size_t endOfURI = line.find_first_of(" \t\r\n", start + 1 ); method.url = line.substr( start, endOfURI - start ); if ( method.url.size() == 0 ) return false; start = line.find_first_not_of( " \t", endOfURI ); // HTTP version size_t end = line.find_last_not_of(" \t\r\n" ); if ( memcmp( line.c_str() + start, "HTTP/", 5 ) != 0 ) return false; start += 5; method.version = line.substr( start, end - start + 1 ); readStatus = ReadStatus::in_hdr; return true; } bool parseHeaderEntry( const nodecpp::string& line ) { NODECPP_ASSERT( nodecpp::module_id, ::nodecpp::assert::AssertLevel::critical, readStatus == ReadStatus::in_hdr ); size_t end = line.find_last_not_of(" \t\r\n" ); if ( end == nodecpp::string::npos ) { if ( !( line.size() == 2 && line[0] == '\r' && line[1] == '\n' ) ) // last empty line return true; // TODO: what should we do with this line of spaces? - just ignore or report a parsing error? parseContentLength(); readStatus = contentLength ? ReadStatus::in_body : ReadStatus::completed; return false; } size_t start = line.find_first_not_of( " \t" ); size_t idx = line.find(':', start); if ( idx >= end ) return false; size_t valStart = line.find_first_not_of( " \t", idx + 1 ); nodecpp::string key = line.substr( start, idx-start ); header.insert( nodecpp::make_pair( makeLower( key ), line.substr( valStart, end - valStart + 1 ) )); return true; } const nodecpp::string& getMethod() { return method.name; } const nodecpp::string& getUrl() { return method.url; } const nodecpp::string& getHttpVersion() { return method.version; } size_t getContentLength() const { return contentLength; } void dbgTrace() { nodecpp::log::default_log::info( nodecpp::log::ModuleID(nodecpp::nodecpp_module_id), " [->] {} {} HTTP/{}", method.name, method.url, method.version ); for ( auto& entry : header ) nodecpp::log::default_log::info( nodecpp::log::ModuleID(nodecpp::nodecpp_module_id), " [->] {}: {}", entry.first, entry.second ); nodecpp::log::default_log::info( nodecpp::log::ModuleID(nodecpp::nodecpp_module_id), "[CL = {}, Conn = {}]", getContentLength(), connStatus == ConnStatus::keep_alive ? "keep-alive" : "close" ); nodecpp::log::default_log::info( nodecpp::log::ModuleID(nodecpp::nodecpp_module_id), "" ); } }; class HttpServerResponse : protected HttpMessageBase // TODO: candidate for being a part of lib { friend class HttpSocketBase; friend class RRQueue; Buffer headerBuff; private: nodecpp::soft_ptr<IncomingHttpMessageAtServer> myRequest; typedef nodecpp::map<nodecpp::string, nodecpp::string> header_t; header_t header; size_t contentLength = 0; nodecpp::Buffer body; ConnStatus connStatus = ConnStatus::keep_alive; enum WriteStatus { notyet, hdr_serialized, hdr_flushed, in_body, completed }; WriteStatus writeStatus = WriteStatus::notyet; nodecpp::string replyStatus; //size_t bodyBytesWritten = 0; private: nodecpp::handler_ret_type serializeHeaders() { NODECPP_ASSERT( nodecpp::module_id, ::nodecpp::assert::AssertLevel::critical, writeStatus == WriteStatus::notyet ); // TODO: add real implementation if ( replyStatus.size() ) // NOTE: this makes sense only if no headers were added via writeHeader() headerBuff.appendString( replyStatus ); headerBuff.append( "\r\n", 2 ); for ( auto h: header ) { headerBuff.appendString( h.first ); headerBuff.append( ": ", 2 ); headerBuff.appendString( h.second ); headerBuff.append( "\r\n", 2 ); } headerBuff.append( "\r\n", 2 ); parseContentLength(); parseConnStatus(); writeStatus = WriteStatus::hdr_serialized; header.clear(); CO_RETURN; } public: HttpServerResponse() : headerBuff(0x1000) {} HttpServerResponse(const HttpServerResponse&) = delete; HttpServerResponse operator = (const HttpServerResponse&) = delete; HttpServerResponse(HttpServerResponse&& other) { replyStatus = std::move( other.replyStatus ); header = std::move( other.header ); contentLength = other.contentLength; headerBuff = std::move( other.headerBuff ); } HttpServerResponse& operator = (HttpServerResponse&& other) { replyStatus = std::move( other.replyStatus ); header = std::move( other.header ); headerBuff = std::move( other.headerBuff ); contentLength = other.contentLength; other.contentLength = 0; return *this; } void clear() // TODO: ensure necessity (added for reuse purposes) { replyStatus.clear(); header.clear(); body.clear(); headerBuff.clear(); contentLength = 0; writeStatus = WriteStatus::notyet; } void dbgTrace() { nodecpp::log::default_log::info( nodecpp::log::ModuleID(nodecpp::nodecpp_module_id), " [<-] {}", replyStatus ); for ( auto& entry : header ) nodecpp::log::default_log::info( nodecpp::log::ModuleID(nodecpp::nodecpp_module_id), " [<-] {}: {}", entry.first, entry.second ); nodecpp::log::default_log::info( nodecpp::log::ModuleID(nodecpp::nodecpp_module_id), "" ); } template< class Str1, class Str2, size_t N> void writeHead( size_t statusCode, Str1 statusMessage, nodecpp::pair<nodecpp::string, nodecpp::string> headers[N] ) { replyStatus = statusCode; setStatus( nodecpp::format( "{} {} {}", myRequest->getHttpVersion(), statusCode, statusMessage ) ); for ( size_t i=0; i<N; ++i ) { header.insert( headers[i] ); } } struct HeaderHolder { const char* key = nullptr; enum ValType { undef, str, num }; ValType valType = undef; const char* valStr = nullptr; size_t valNum = 0; HeaderHolder( const char* key_, const char* val ) { key = key_; valType = ValType::str; valStr = val; } HeaderHolder( nodecpp::string key_, const char* val ) { key = key_.c_str(); valType = ValType::str; valStr = val; } HeaderHolder( nodecpp::string_literal key_, const char* val ) { key = key_.c_str(); valType = ValType::str; valStr = val; } HeaderHolder( const char* key_, nodecpp::string val ) { key = key_; valType = ValType::str; valStr = val.c_str(); } HeaderHolder( nodecpp::string key_, nodecpp::string val ) { key = key_.c_str(); valType = ValType::str; valStr = val.c_str(); } HeaderHolder( nodecpp::string_literal key_, nodecpp::string val ) { key = key_.c_str(); valType = ValType::str; valStr = val.c_str(); } HeaderHolder( const char* key_, nodecpp::string_literal val ) { key = key_; valType = ValType::str; valStr = val.c_str(); } HeaderHolder( nodecpp::string key_, nodecpp::string_literal val ) { key = key_.c_str(); valType = ValType::str; valStr = val.c_str(); } HeaderHolder( nodecpp::string_literal key_, nodecpp::string_literal val ) { key = key_.c_str(); valType = ValType::str; valStr = val.c_str(); } HeaderHolder( const char* key_, size_t val ) { key = key_; valType = ValType::num; valNum = val; } HeaderHolder( nodecpp::string key_, size_t val ) { key = key_.c_str(); valType = ValType::num; valNum = val; } HeaderHolder( nodecpp::string_literal key_, size_t val ) { key = key_.c_str(); valType = ValType::num; valNum = val; } nodecpp::string toStr() const { switch ( valType ) { case str: return nodecpp::format( "{}: {}\r\n", key, valStr ); case num: return nodecpp::format( "{}: {}\r\n", key, valNum ); default: NODECPP_ASSERT( nodecpp::module_id, ::nodecpp::assert::AssertLevel::critical, false, "unexpected value {}", (size_t)valType ); return nodecpp::string( "" ); } } const char* getKey() { return key; } }; template< class Str1> void writeHead( size_t statusCode, Str1 statusMessage, std::initializer_list<HeaderHolder> headers ) { setStatus( nodecpp::format( "HTTP/{} {} {}\r\n", myRequest->getHttpVersion(), statusCode, statusMessage ) ); for ( auto& h : headers ) { if ( strncmp( h.key, "Content-Length", sizeof("Content-Length")-1) != 0 ) replyStatus.append( h.toStr() ); } replyStatus.erase( replyStatus.end() - 2, replyStatus.end() ); } void writeHead( size_t statusCode, std::initializer_list<HeaderHolder> headers ) { setStatus( nodecpp::format( "HTTP/{} {}\r\n", myRequest->getHttpVersion(), statusCode ) ); for ( auto& h : headers ) { if ( strncmp( h.key, "Content-Length", sizeof("Content-Length")-1) != 0 ) replyStatus.append( h.toStr() ); } replyStatus.erase( replyStatus.end() - 2, replyStatus.end() ); } template< class Str> void writeHead( size_t statusCode, Str statusMessage ) { setStatus( nodecpp::format( "HTTP/{} {} {}", myRequest->getHttpVersion(), statusCode, statusMessage ) ); } void writeHead( size_t statusCode ) { setStatus( nodecpp::format( "HTTP/{} {}", myRequest->getHttpVersion(), statusCode ) ); } void addHeader( nodecpp::string key, nodecpp::string value ) { NODECPP_ASSERT( nodecpp::module_id, ::nodecpp::assert::AssertLevel::critical, writeStatus == WriteStatus::notyet ); // TODO: sanitize if ( key != "Content-Length" ) header.insert( nodecpp::make_pair( key, value ) ); } void setStatus( nodecpp::string status ) // temporary stub; TODO: ... { replyStatus = status; } #ifndef NODECPP_NO_COROUTINES nodecpp::handler_ret_type flushHeaders() { if ( writeStatus == WriteStatus::notyet ) serializeHeaders(); NODECPP_ASSERT( nodecpp::module_id, ::nodecpp::assert::AssertLevel::critical, writeStatus == WriteStatus::hdr_serialized ); try { co_await sock->a_write( headerBuff ); headerBuff.clear(); writeStatus = WriteStatus::hdr_flushed; } catch(...) { // TODO: revise!!! should we close the socket? what should be done with other pipelined requests (if any)? sock->end(); clear(); sock->release( idx ); sock->proceedToNext(); } CO_RETURN; } nodecpp::handler_ret_type writeBodyPart(Buffer& b) { if ( writeStatus == WriteStatus::notyet ) serializeHeaders(); NODECPP_ASSERT( nodecpp::module_id, ::nodecpp::assert::AssertLevel::critical, writeStatus == WriteStatus::hdr_serialized || writeStatus == WriteStatus::hdr_flushed ); try { if ( writeStatus == WriteStatus::hdr_serialized ) { headerBuff.append( b ); co_await sock->a_write( headerBuff ); headerBuff.clear(); writeStatus = WriteStatus::hdr_flushed; } else co_await sock->a_write( b ); writeStatus = WriteStatus::in_body; } catch(...) { // TODO: revise!!! should we close the socket? what should be done with other pipelined requests (if any)? sock->end(); clear(); sock->release( idx ); sock->proceedToNext(); } CO_RETURN; } NODECPP_NO_AWAIT nodecpp::handler_ret_type end(Buffer& b) { if ( writeStatus != WriteStatus::in_body ) { NODECPP_ASSERT( nodecpp::module_id, ::nodecpp::assert::AssertLevel::critical, writeStatus == WriteStatus::notyet ); header.insert( nodecpp::make_pair( nodecpp::string("Content-Length"), format( "{}", b.size() ) ) ); } //dbgTrace(); co_await writeBodyPart(b); myRequest->clear(); if ( connStatus != ConnStatus::keep_alive ) { sock->end(); clear(); CO_RETURN; } clear(); sock->release( idx ); sock->proceedToNext(); CO_RETURN; } NODECPP_NO_AWAIT nodecpp::handler_ret_type end(const char* s) { // TODO: potentially, quite temporary implementation size_t ln = strlen( s ); Buffer b( ln ); b.append( s, ln ); co_await end( b ); CO_RETURN; } NODECPP_NO_AWAIT nodecpp::handler_ret_type end(nodecpp::string s) { // TODO: potentially, quite temporary implementation Buffer b; b.appendString( s ); co_await end( b ); } NODECPP_NO_AWAIT nodecpp::handler_ret_type end(nodecpp::string_literal s) { // TODO: potentially, quite temporary implementation Buffer b; b.appendString( s ); co_await end( b ); } NODECPP_NO_AWAIT nodecpp::handler_ret_type end() { if ( writeStatus != WriteStatus::hdr_flushed ) co_await flushHeaders(); myRequest->clear(); if ( connStatus != ConnStatus::keep_alive ) { sock->end(); clear(); CO_RETURN; } //dbgTrace(); clear(); sock->release( idx ); sock->proceedToNext(); CO_RETURN; } #endif // NODECPP_NO_COROUTINES }; inline void HttpServerBase::onNewRequest( nodecpp::soft_ptr<IncomingHttpMessageAtServer> request, nodecpp::soft_ptr<HttpServerResponse> response ) { //printf( "entering onNewRequest() %s\n", ahd_request.h == nullptr ? "ahd_request.h is nullptr" : "" ); if ( ahd_request.h != nullptr ) { ahd_request.request = request; ahd_request.response = response; auto hr = ahd_request.h; ahd_request.h = nullptr; //printf( "about to rezume ahd_request.h\n" ); hr(); } else if ( dataForHttpCommandProcessing.isIncomingRequesEventHandler() ) dataForHttpCommandProcessing.handleIncomingRequesEvent( myThis.getSoftPtr<HttpServerBase>(this), request, response ); else if ( eHttpRequest.listenerCount() ) eHttpRequest.emit( *request, *response ); } inline ::nodecpp::awaitable<CoroStandardOutcomes> HttpSocketBase::getRequest( IncomingHttpMessageAtServer& message ) { nodecpp::string line; CoroStandardOutcomes status = co_await readLine(line); if ( status == CoroStandardOutcomes::ok ) { // nodecpp::log::default_log::info( nodecpp::log::ModuleID(nodecpp::nodecpp_module_id), "line [{} bytes]: {}", lb.size() - 1, reinterpret_cast<char*>(lb.begin()) ); if ( !message.parseMethod( line ) ) { // TODO: report error CO_RETURN CoroStandardOutcomes::failed; } } else CO_RETURN status; do { status = co_await readLine(line); // nodecpp::log::default_log::info( nodecpp::log::ModuleID(nodecpp::nodecpp_module_id), "line [{} bytes]: {}", lb.size() - 1, reinterpret_cast<char*>(lb.begin()) ); } while ( status == CoroStandardOutcomes::ok && message.parseHeaderEntry( line ) ); CO_RETURN message.readStatus == IncomingHttpMessageAtServer::ReadStatus::in_body || message.readStatus == IncomingHttpMessageAtServer::ReadStatus::completed ? CoroStandardOutcomes::ok : CoroStandardOutcomes::failed; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline HttpSocketBase::HttpSocketBase() { #ifndef NODECPP_NO_COROUTINES lineBuffer.reserve(maxHeaderSize); #endif // NODECPP_NO_COROUTINES rrQueue.init( myThis.getSoftPtr<HttpSocketBase>(this) ); run(); // TODO: think about proper time for this call } template<size_t sizeExp> void HttpSocketBase::RRQueue<sizeExp>::init( nodecpp::soft_ptr<HttpSocketBase> socket ) { size_t size = ((size_t)1 << sizeExp); cbuff = nodecpp::alloc<RRPair>( size ); // TODO: use nodecpp::a //cbuff = new RRPair [size]; for ( size_t i=0; i<size; ++i ) { cbuff[i].request = nodecpp::make_owning<IncomingHttpMessageAtServer>(); cbuff[i].response = nodecpp::make_owning<HttpServerResponse>(); nodecpp::soft_ptr<IncomingHttpMessageAtServer> tmprq = (cbuff[i].request); nodecpp::soft_ptr<HttpServerResponse> tmrsp = (cbuff[i].response); cbuff[i].response->counterpart = nodecpp::soft_ptr_reinterpret_cast<HttpMessageBase>(tmprq); cbuff[i].request->counterpart = nodecpp::soft_ptr_reinterpret_cast<HttpMessageBase>(tmrsp); cbuff[i].request->sock = socket; cbuff[i].response->sock = socket; cbuff[i].response->myRequest = cbuff[i].request; } } } //namespace net } //namespace nodecpp #endif // HTTP_SOCKET_AT_SERVER_H
35.252949
219
0.658822
50dc43a230efaaa2083726ec1a070a3444156e47
42,868
c
C
chmon/chmon.c
gbraad/chameleon
aa2e7b9e38fb9327b00e7d2dcd3dc19de065dd85
[ "BSD-4-Clause" ]
null
null
null
chmon/chmon.c
gbraad/chameleon
aa2e7b9e38fb9327b00e7d2dcd3dc19de065dd85
[ "BSD-4-Clause" ]
null
null
null
chmon/chmon.c
gbraad/chameleon
aa2e7b9e38fb9327b00e7d2dcd3dc19de065dd85
[ "BSD-4-Clause" ]
null
null
null
/* TODO: * Page Boundaries Disassembly * implement Transfer Memory Command * TRACE ?! */ /* changelog: * 03.03.2007: fixed dir output from command line * 02.03.2007: added Makefile * 02.03.2007: added support for filtered directory * 02.03.2007: changd tokenizer, changes in string treatment, strings in quotation marks etc... * 01.03.2007: fixed wrong memory end address display at PUT * 01.03.2007: added libreadline functions for Linux * 01.03.2007: added feature: give cmomands at command-line * 28.02./ 01.03.2007: rewrote network stuff for also compiling for WIN32 * some minor changes... */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <time.h> #include <ctype.h> #ifdef _WIN32 //#include <winsock.h> #include <windows.h> #include <io.h> #else #include <sys/types.h> #include <unistd.h> #ifdef LINUX #include <readline/readline.h> #include <readline/history.h> #endif extern int h_errno; #endif /* chmon Constant Data */ const char version[] = "v0.2"; #define COMMANDS 29 const char command_table[COMMANDS][8] = { "m", /* 00 */ "i", /* 01 */ "d", /* 02 */ "g", /* 03 */ "h", /* 04 */ "f", /* 05 */ "c", /* 06 */ "put", /* 07 */ "get", /* 08 */ "poke", /* 09 */ "$", /* 10 */ "@", /* 11 */ "#", /* 12 */ "read", /* 13 */ "write", /* 14 */ "run", /* 15 */ "basic", /* 16 */ "ram", /* 17 */ "rom", /* 18 */ "reu", /* 19 */ "help", /* 20 */ "?", /* 21 */ "quit", /* 22 */ "x", /* 23 */ "status", /* 24 */ "init", /* 25 */ "call", /* 26 */ "cmd" /* 27 */ }; enum { INIT, PUT, GET, READ, WRITE, XWRITE, XDONE, RUN, JUMP, SYS, BASIC, DIR, DISKCOMMAND, SETRAM, POKE, TELLDEV, SETDEV, FILL, STATUS, }; /* These are used by the disassembler */ enum { IMPL,IMM,ABS,ABSX,ABSY,IND,INDX,INDY,ZP,ZPX,ZPY,REL,AKKU }; char mnemo[256][4] = { "brk","ora","???","???","???","ora","asl","???", "php","ora","asl","???","???","ora","asl","???", "bpl","ora","???","???","???","ora","asl","???", "clc","ora","???","???","???","ora","asl","???", "jsr","ans","???","???","bit","and","rol","???", "plp","and","rol","???","bit","and","rol","???", "bmi","and","???","???","???","and","rol","???", "sec","and","???","???","???","and","rol","???", "rti","eor","???","???","???","eor","lsr","???", "pha","eor","lsr","???","jmp","eor","lsr","???", "bvc","eor","???","???","???","eor","lsr","???", "cli","eor","???","???","???","eor","lsr","???", "rts","adc","???","???","???","adc","ror","???", "pla","adc","ror","???","jmp","adc","ror","???", "bvs","adc","???","???","???","adc","ror","???", "sei","adc","???","???","???","adc","ror","???", "???","sta","???","???","sty","sta","stx","???", "dey","???","txa","???","sty","sta","stx","???", "bcc","sta","???","???","sty","sta","stx","???", "tya","sta","txs","???","???","sta","???","???", "ldy","lda","ldx","???","ldy","lda","ldx","???", "tay","lda","tax","???","ldy","lda","ldx","???", "bcc","lda","???","???","ldy","lda","ldx","???", "clv","lda","tsx","???","ldy","lda","ldx","???", "cpy","cmp","???","???","cpy","cmp","dec","???", "iny","cmp","dex","???","cpy","cmp","dec","???", "bne","mcp","???","???","???","cmp","dec","???", "cld","cmp","???","???","???","cmp","dec","???", "cpx","sbc","???","???","cpx","sbc","inc","???", "inx","sbc","nop","???","cpx","sbc","inc","???", "beq","sbc","???","???","???","sbc","inc","???", "sed","sbc","???","???","???","sbc","inc","???" }; int table1[32] = { IMPL,INDX,IMPL,IMPL,IMPL,ZP,ZP,IMPL,IMPL,IMM,AKKU,IMPL,ABS,ABS,ABS,IMPL, REL,INDY,IMPL,IMPL,IMPL,ZPX,ZPX,IMPL,IMPL,ABSY,IMPL,IMPL,IMPL,ABSX,ABSX,IMPL }; int table2[32] = { IMM,INDX,IMPL,IMPL,ZP,ZP,ZP,IMPL,IMPL,IMM,IMPL,IMPL,ABS,ABS,ABS,IMPL, REL,INDY,IMPL,IMPL,ZPX,ZPX,ZPY,IMPL,IMPL,ABSY,IMPL,IMPL,IMPL,ABSX,ABSX,IMPL }; /* textstrings */ const char helptext[COMMANDS][400] = { "m [from [to]]\n" " memory peek: transfer mem from c64 and display in hex, ascii and petascii\n", "i [from [to]]\n" " interrogate: transfer mem from c64 and display as petascii\n", "d [from [to]]\n" " disassembly: transfer mem from c64 and display as disassembly\n", "g addr\n" " goto: tell c64 to jump to specified address\n", "h from to pattern\n" " hunt: find occurances of the given search pattern in memory area specified by from and to\n" " search pattern is given either as string in quotes or as series of hex values\n", "f from to value\n" " fill: fill the c64's memory area specified by from and to with value\n", "c from to with\n" " compare: compare the memory segment specified by from and to with the one starting at with\n", "put filename [loadaddr]\n" " put: transfer the contents of a local file into c64 memory, if loadaddr is not specified\n" " the load address is taken from the file's first two bytes (cbm standard)\n", "get from to filename\n" " get: transfer the memory segment specified by from and to from c64 and store in filename\n", "poke addr string | value[value...]]\n" " poke: write to c64 memory address. Value(s) are given as a series of hex numbers or as a string in quotation marks\n", "$[pattern]\n" " directory: display disk directory of current device. If no pattern is given '$*' is assumed.\n" " Patterns are passed directly to the disk device, so everything that your device understands is allowed,\n" " e.g. '$*=seq' on a cbm1541 to list all SEQ files.\n", "@[string]\n" " disk command: send any following string to command channel, read command channel and print to stdout\n", "#[dev]\n" " device: set the current device to dev. if dev is not specified, the current device is displayed\n", "read remotefile [localfile]\n" " read: read remotefile from c64's current device, transfer the data and store in localfile\n" " if localfile is not specified remotefile will be used as filename.\n", "write localfile [remotefile]\n" " write: write contents of localfile to remotefile on c64's current device\n" " if remotefile is not specified localfile will be used as filename.\n", "run\n" " tell c64 to perform a BASIC RUN Statement\n", "basic\n" " c64 will return to basic (quit server)\n", "ram\n" " switch acces mode to RAM: all memory write accesses will go to c64 internal RAM ($01 = #$34)\n", "rom\n" " switch access mode to ROM: all memory read aceesses will read from ROM ($01 = #$37)\n", "reu\n" " switch access mode to REU: all memory read and write accesses will go to expanded memory\n", "help\n" " show some help: you may get help for a specific command by typing help command\n", "?\n" " show some help: you may get help for a specific command by typing ? command\n", "quit\n" " quit the chmon shell\n", "x\n" " quit the chmon shell\n", "status\n" " get server status\n", "init\n" " initialize chserv\n", "call addr [a[x[y[sr]]]]\n" " call subroutine:specify values for .A,.X,.Y and status register before call\n", "cmd command [parameter [parameter...]]\n" " system command: send the following string to the system's command interpreter\n" }; const char usage[] = "chmon\n\n" "-s --send send server program (chmon.prg)\n" "-c --command [cmd] direct command, type chmon -c help for a full list of\n" " available commands or chmon -c help name for usage of the\n" " given command\n" "-v --version print version number\n" "-h --help this help message\n"; /* the commands table */ /* default values */ const char prompt[] = "[:.]"; //const char default_ip[] = "192.168.0.64"; //const char default_port[] = "3172"; #include "chacolib.h" #include "chbidir.c" void send_memory_request(unsigned base,unsigned size); // ----------------------------------------------------------------------------- int senddatablock(unsigned char *buf, unsigned int len) { unsigned char x = len; usb_write_bytes(&x,1); // printf("senddatablock len:%d\n", x); len = usb_write_bytes(buf,x); // printf("after senddatablock len:%d\n", len); return len; } #define send(fd,buf,len,x) senddatablock(buf,len) int recvdatablock(unsigned char *buf, unsigned int len) { unsigned char x = len; usb_read_bytes(&x,1); // printf("recvdatablock len:%d\n", x); len = usb_read_bytes(buf,x); // printf("->'%s'\n", buf); // printf("after recvdatablock got:%d\n", len); return len; } #define recv(fd,buf,len,x) recvdatablock(buf,len) // ----------------------------------------------------------------------------- void execute_sys(int addr) { unsigned char buf[10]; int n; /* put RUN into keyboard buffer */ buf[0] = 0; if (chameleon_writememory(buf, 1, 198) < 0) { LOGERR("error writing to chameleon memory.\n"); exit(cleanup(EXIT_FAILURE)); } buf[0] = 83; buf[1] = 217; buf[2] = 32; buf[3] = 32; buf[4] = 32; buf[5] = 32; buf[6] = 32; buf[7] = 32; addr &= 0xffff; n = sprintf((char*)&buf[2], "%d", addr); buf[n+2] = 13; if (chameleon_writememory(buf, 8, 631) < 0) { LOGERR("error writing to chameleon memory.\n"); exit(cleanup(EXIT_FAILURE)); } buf[0] = n+3; if (chameleon_writememory(buf, 1, 198) < 0) { LOGERR("error writing to chameleon memory.\n"); exit(cleanup(EXIT_FAILURE)); } } void execute_run(void) { unsigned char buf[4]; /* put RUN into keyboard buffer */ buf[0] = 0; if (chameleon_writememory(buf, 1, 198) < 0) { LOGERR("error writing to chameleon memory.\n"); exit(cleanup(EXIT_FAILURE)); } buf[0] = 82; buf[1] = 85; buf[2] = 78; buf[3] = 13; if (chameleon_writememory(buf, 4, 631) < 0) { LOGERR("error writing to chameleon memory.\n"); exit(cleanup(EXIT_FAILURE)); } buf[0] = 4; if (chameleon_writememory(buf, 1, 198) < 0) { LOGERR("error writing to chameleon memory.\n"); exit(cleanup(EXIT_FAILURE)); } } int read_memory_block(unsigned char *buf, unsigned int len, unsigned int addr) { static int isrom [16] = { 0,0,0,0, 0,0,0,0, 0,0,1,1, 0,1,1,1 }; int end, slow; /* we can only use the DMA read when actual RAM is read */ end = addr + len - 1; slow = isrom[(addr >> 12) & 0xf] || isrom[(end >> 12) & 0xf]; if (!slow) { if (chameleon_readmemory(buf, len, addr) < 0) { LOGERR("error reading chameleon memory.\n"); exit(cleanup(EXIT_FAILURE)); } } else { send_memory_request(addr,len); len = recv(fd, buf, len,0); } return len; } // ----------------------------------------------------------------------------- int cmd,old_cmd; unsigned int tokens; char string[100]; char *token[256]; unsigned char sendbuffer[512],filebuffer[512]; int next[4096]; /* kmp search algorithm */ void init_next(char *pattern,int m){ int i,j; i = 0; j = next[0] = -1; while (i < m){ while( j > -1 && pattern[i] != pattern[j]) j = next[j]; ++i;++j; (pattern[i] == pattern[j]) ? (next[i] = next[j]) : (next[i] = j); } } int kmp_search(char *pattern, char *string, unsigned size, unsigned base){ int i = 0, j = 0; int m = strlen(pattern); int n = size; init_next (pattern,m); while(i < n){ while (j>=0 && string[i] != pattern[j]) j = next[j]; ++i; ++j; if (j == m){ printf("%04x\n",base + i-j); j = next[j]; } } return -1; } /* PetASCII <--> ASCII Converting */ char pet2asc(char c){ c &= 0x7f; if (c == 13 || c == 10 || c == 9) return c; if (c < 32) return '.'; if (c < 65) return c; if (c < 91) return c + 32; return c - 32; } int string2pet(char *s){ int i,len = strlen(s); for (i=0;i<len;++i) s[i] = pet2asc(s[i]); return len; } /* parse input string into tokens */ unsigned int tokenize(char *s){ unsigned int i = 0; while (1){ while (*s == ' ') ++s; //skip leading spaces if (*s == '\0') return i; //end of input string? then return number of tokens read if (*s == '"'){ token[i++] = s++; //set the token to the first char after the quot.mark while (*s != '"') //search the next quot.mark or end of input string if (*s++ == '\0') return i; *s++ = '\0'; //replace the quot.mark by delimiter, advance in input string and loop continue; } token[i++] = s; //else we have a token while (*s != ' ') //read the token until next space or end of input string if (*s++ == '\0') return i; *s++ = '\0'; } } /* send a request for memory transfer of size bytes from address base to c64 */ void send_memory_request(unsigned base,unsigned size){ sendbuffer[0] = GET; sendbuffer[1] = size; sendbuffer[3] = (base & 0x0000ff); sendbuffer[4] = (base & 0x00ff00) >> 8; sendbuffer[5] = (base & 0xff0000) >> 16; send (fd,sendbuffer,6,0); } // ----------------------------------------------------------------------------- /* $ * - send request for directory dislplay of current device and print to stdout */ void directory(char *s){ int i,len = string2pet(s); sendbuffer[0] = DIR; sendbuffer[1] = len; memcpy(&sendbuffer[2],s,len); send(fd,sendbuffer,len+2,0); do{ len = recv(fd,filebuffer,sizeof(filebuffer),0); if (len){ for(i=0;i<len;++i) { if (filebuffer[i] == 0) { printf("\n"); return; } else if (filebuffer[i] == 13) { printf("\n"); } else if (filebuffer[i] == 10) { printf("\r"); } else { putchar(pet2asc(filebuffer[i])); } } } }while(len); } /* read * - read remotefile from c64's current device, transfer the data and store in localfile */ void read_file(void){ int fnlen,len; char *localfile,*remotefile; FILE *f; if (tokens < 2 || tokens > 3) puts(helptext[cmd]); else { if (token[1][0] == '"') remotefile = &token[1][1]; else remotefile = &token[1][0]; if (tokens == 2) localfile = remotefile; else localfile = token[2]; if ((f = fopen(localfile,"wb"))==NULL){ perror(localfile); return; } string2pet(remotefile); fnlen = strlen(remotefile); sendbuffer[0] = READ; sendbuffer[1] = fnlen; memcpy(&sendbuffer[2],remotefile,fnlen); send(fd,sendbuffer,fnlen+2,0); do{ len = recv(fd,filebuffer,sizeof(filebuffer),0); // len = recv(fd, filebuffer, len,0); if (len) fwrite (filebuffer,1,len,f); }while(len == 128); fclose(f); } } /* write * - write contents of localfile to remotefile on c64's current device */ void write_file(void){ int fnlen,len; char *localfile,*remotefile; FILE *f; if (tokens < 2 || tokens > 3) puts(helptext[cmd]); else { localfile = token[1]; if (tokens == 2) remotefile = localfile; else{ if (token[2][0] == '"') remotefile = &token[2][1]; else remotefile = &token[2][0]; } if ((f = fopen(localfile,"rb")) == NULL){ perror(localfile); return; } string2pet(remotefile); fnlen = strlen(remotefile); /* first we send request to open the write file */ sendbuffer[0] = WRITE; sendbuffer[1] = fnlen; memcpy(&sendbuffer[2],remotefile,fnlen); send (fd,sendbuffer,fnlen+2,0); /* and wait for OK from c64 */ // len = recv(fd,sendbuffer,sizeof(sendbuffer),0); len = recv(fd, sendbuffer, 2,0); if (sendbuffer[0]){ puts("an error occured..."); fclose(f); return; } /* now we transfer the file */ while (!feof(f)){ len = fread(filebuffer,1,128,f); sendbuffer[0] = XWRITE; sendbuffer[1] = len; memcpy(&sendbuffer[2],filebuffer,len); send(fd,sendbuffer,len+2,0); /* and wait after each packet for a (any) response from c64 */ // len = recv(fd,sendbuffer,sizeof(sendbuffer),0); len = recv(fd, sendbuffer, 2,0); } /* at last we send a OK, so the c64 can close the file */ sendbuffer[0] = XDONE; send(fd,sendbuffer,1,0); fclose(f); } } /* put * - transfer a file from pc to c64 memory */ void put(void){ FILE *f; char *filename; unsigned load_addr,len,bytes = 0; // char hi,lo; if (tokens < 2 || tokens > 3) puts(helptext[cmd]); else{ filename = token[1]; if ((f = fopen(filename,"rb")) == NULL){ perror(filename); return; } /* if no load addres is given read it from file, else use the given one */ if (tokens == 3) sscanf(token[2],"%x",&load_addr); else load_addr = fgetc(f) + fgetc(f) * 256; printf("sending %s to $%04x ",filename,load_addr); /* now send the file's data packet-wise */ while(!feof(f)){ len = fread(filebuffer,1,128,f); //read len bytes data from file sendbuffer[0] = PUT; // setup "put" request... sendbuffer[1] = len; sendbuffer[2] = 0; //unused... sendbuffer[3] = (load_addr & 0x0000ff); sendbuffer[4] = (load_addr & 0x00ff00) >> 8; sendbuffer[5] = (load_addr & 0xff0000) >> 16; memcpy(&sendbuffer[6],filebuffer,len); //copy the actual data into the packet send(fd,sendbuffer,len+6,0); //and send it... load_addr += len; bytes += len; len = recv(fd,filebuffer,2,0); // wait for response and loop } printf("- $%04x\n",load_addr); fclose(f); printf("%d bytes transferred\n",bytes); } } /* get * - get memory from c64 and save to a file */ void get(void){ unsigned from, to; char *filename; FILE *f; int len; if (tokens != 4) puts(helptext[cmd]); else{ sscanf(token[1],"%x",&from); sscanf(token[2],"%x",&to); filename = token[3]; if ((f = fopen(filename,"wb")) == NULL){ perror(filename); return; } fputc(from & 0xff,f); fputc(from >> 8 ,f); while (from < to){ if ((len = to - from) >= 128) len = 128; #if 0 send_memory_request(from,len); // len = recv(fd,filebuffer,sizeof(filebuffer),0); len = recv(fd, filebuffer, len > sizeof(filebuffer) ? sizeof(filebuffer) : len,0); #else read_memory_block(filebuffer, len, from); #endif fwrite(filebuffer,len,1,f); from += len; } fclose(f); } } /* g * - make c64 jump to the given address */ void jump(void){ unsigned jump_addr; if (tokens != 2) puts(helptext[cmd]); else{ sscanf(token[1],"%x",&jump_addr); sendbuffer[0] = JUMP; sendbuffer[1] = (jump_addr & 0xff); sendbuffer[2] = (jump_addr & 0xff00) >> 8; send(fd,sendbuffer,3,0); } } /* call * - call subroutine at the given address, wait for RTS */ void call(void){ unsigned sys_addr; unsigned a,x,y,s,i; a = x = y = s = 0; if (tokens <2 || tokens > 6) puts(helptext[cmd]); else{ sscanf(token[1],"%x",&sys_addr); if (tokens > 2) sscanf(token[2],"%x",&a); if (tokens > 3) sscanf(token[3],"%x",&x); if (tokens > 4) sscanf(token[4],"%x",&y); if (tokens > 5) sscanf(token[5],"%x",&s); sendbuffer[0] = SYS; sendbuffer[1] = sys_addr & 0xff; sendbuffer[2] = sys_addr >> 8; sendbuffer[3] = a; sendbuffer[4] = x; sendbuffer[5] = y; sendbuffer[6] = s; send(fd,sendbuffer,7,0); recv(fd,sendbuffer,4,0); a = sendbuffer[0]; x = sendbuffer[1]; y = sendbuffer[2]; s = sendbuffer[3]; printf("returned from $%04x with\n.A .X .Y SR NV-BDIZC\n%02x %02x %02x %02x ",sys_addr,a,x,y,s); for (i=0;i<8;++i){ s & 0x80 ? putchar('1') : putchar('0'); s <<= 1; } putchar('\n'); } } /* detect address mode for a given opcode; used for disassembly */ int mode (unsigned char opcode){ if (opcode == 0x20) return ABS; if (opcode < 0x80){ if (opcode == 0x24) return ZP; if (opcode == 0x6c) return IND; opcode &= 0x1f; if (opcode == 0) return IMPL; if (opcode == 1) return INDX; return table1[opcode]; } else{ if (opcode == 0x80) return IMPL; if (opcode == 0xa2) return IMM; if (opcode == 0x89) return IMPL; if (opcode == 0xd4) return IMPL; if (opcode == 0xf4) return IMPL; if (opcode == 0xd6) return ZPX; if (opcode == 0xf6) return ZPX; if (opcode == 0xbc) return ABSX; if (opcode == 0x9e) return IMPL; if (opcode == 0xbe) return ABSY; opcode &= 0x1f; return table2[opcode]; } } /* d * - get data from c64, disassemble and print to stdout */ /* this one is a late night hack, could suerly be optimized...! but it works.*/ void disassembly (void) { static unsigned from = 0; unsigned to; int len,i,j = 1; unsigned char *p; // unsigned char opcode; if (tokens > 3) puts (helptext[cmd]); else { if (tokens > 1) sscanf(token[1],"%x",&from); to = from + 0x30; if (tokens > 2) sscanf(token[2],"%x",&to); while (from < to){ if ((len = to - from) >= 128) len = 128; #if 0 send_memory_request(from,len); // len = recv(fd, filebuffer, sizeof(filebuffer),0); len = recv(fd, filebuffer, len > sizeof(filebuffer) ? sizeof(filebuffer) : len,0); #else read_memory_block(filebuffer, len, from); #endif p = &filebuffer[0]; for (i = 0; i < len; i += j){ printf("%04x ",from + i); switch (mode(*p)){ case IMM: printf("%02x %02x ",*p,*(p+1)); printf(" %s #$%02x",mnemo[*p],*(p+1)); j = 2; break; case ABS: printf("%02x %02x %02x ",*p,*(p+1),*(p+2)); printf(" %s $%04x",mnemo[*p],*(p+1) + *(p+2) * 256); j = 3; break; case ABSX: printf("%02x %02x %02x ",*p,*(p+1),*(p+2)); printf(" %s $%04x,x",mnemo[*p],*(p+1) + *(p+2) * 256); j = 3; break; case ABSY: printf("%02x %02x %02x ",*p,*(p+1),*(p+2)); printf(" %s $%04x,y",mnemo[*p],*(p+1) + *(p+2) * 256); j = 3; break; case ZP: printf("%02x %02x ",*p,*(p+1)); printf(" %s $%02x",mnemo[*p],*(p+1)); j = 2; break; case ZPX: printf("%02x %02x ",*p,*(p+1)); printf(" %s $%02x,x",mnemo[*p],*(p+2)); j = 2; break; case ZPY: printf("%02x %02x ",*p,*(p+1)); printf(" %s $%02x,y",mnemo[*p],*(p+1)); j = 2; break; case AKKU: printf("%02x ",*p); printf(" %s a",mnemo[*p]); j = 1; break; case INDX: printf("%02x %02x ",*p,*(p+1)); printf(" %s ($%02x,x)",mnemo[*p],*(p+1)); j = 2; break; case INDY: printf("%02x %02x ",*p,*(p+1)); printf(" %s ($%02x),y",mnemo[*p],*(p+1)); j = 2; break; case REL: printf("%02x %02x ",*p,*(p+1)); printf(" %s $%04x",mnemo[*p],(from + i + 2) + (signed char)*(p+1)); j = 2; break; case IND: printf("%02x %02x %02x ",*p,*(p+1),*(p+2)); printf(" %s ($%04x)",mnemo[*p],*(p+1) + *(p+2) * 256); j = 3; break; case IMPL: printf("%02x ",*p); printf(" %s",mnemo[*p]); j = 1; } putchar('\n'); p += j; } from += len; } } } /* m * - memory peek of c64 memory */ void mon(void){ static unsigned from = 0; unsigned to; int len,i,j,col; char c; int width = 8; //bytes per line, adjust to your preferences...! if (tokens > 3) puts(helptext[cmd]); else{ /* parse parameters: m [from [to]] */ if (tokens > 1) sscanf(token[1],"%x",&from); to = from + 0x100; if (tokens > 2) sscanf(token[2],"%x",&to); /* request memory from c64 */ while (from < to){ if ((len = to - from) >= 128) len = 128; #if 0 send_memory_request(from,len); // len = recv(fd, filebuffer, sizeof(filebuffer),0); len = recv(fd, filebuffer, len > sizeof(filebuffer) ? sizeof(filebuffer) : len,0); #else read_memory_block(filebuffer, len, from); #endif /* display it to stdout */ for(i=0;i<len;i+=j){ printf("\n%04x : ",from + i); col = 7; for(j=0;j<width;++j){ if (i+j >= len) break; printf("%02x ",filebuffer[i+j]); col += 3; } while (col++ < (7 + width*3)) putchar(' '); printf(" | "); col += 3; for(j=0;j<width;++j){ if (i+j >= len) break; putchar(isprint(filebuffer[i+j])?filebuffer[i+j]:'.'); ++col; } while(col++ < (10+width*3+width)) putchar(' '); printf(" | "); for(j=0;j<width;++j){ if (i+j >= len) break; c = pet2asc(filebuffer[i+j]); putchar(isprint(c)?c:'.'); } } from += len; } puts("\n"); } } /* i * - petascii dump */ void interrogate(void){ static unsigned from; unsigned to; int len,i; char c; if (tokens > 3) puts(helptext[cmd]); else{ if (tokens > 1) sscanf(token[1],"%x",&from); to = from + 0x400; if (tokens > 2) sscanf(token[2],"%x",&to); while (from < to){ if ((len = to - from) >= 128) len = 128; #if 0 send_memory_request(from,len); // len = recv(fd, filebuffer, sizeof(filebuffer),0); len = recv(fd, filebuffer, len > sizeof(filebuffer) ? sizeof(filebuffer) : len,0); #else read_memory_block(filebuffer, len, from); #endif for (i=0;i<len;i++){ if ((i & 63)==0) printf("\n%04x : ",from + i); c = pet2asc(filebuffer[i]); putchar(isprint(c)?c:'.'); } from += len; } printf("\n"); } } /* # * - set/ tell device number of current device */ void device(char *s){ unsigned device; device = atoi(s); if (device == 0){ sendbuffer[0] = TELLDEV; send(fd,sendbuffer,1,0); recv(fd,sendbuffer,2,0); printf("current device is #%d\n",sendbuffer[0]); } else{ sendbuffer[0] = SETDEV; sendbuffer[1] = device; send(fd,sendbuffer,2,0); } } /* @ * - send disk command/ read command channel */ void disk_command(char *s){ unsigned len; string2pet(s); len = strlen(s); sendbuffer[0] = DISKCOMMAND; sendbuffer[1] = len; memcpy(&sendbuffer[2],s,len); send(fd,sendbuffer,len+2,0); len = recv(fd,sendbuffer,sizeof(sendbuffer),0); puts((char*)sendbuffer); } /* f * - send request to fill memory */ void fill(void){ unsigned from,to,value; if (tokens != 4) puts(helptext[cmd]); else{ sscanf(token[1],"%x",&from); sscanf(token[2],"%x",&to); sscanf(token[3],"%x",&value); sendbuffer[0] = FILL; sendbuffer[1] = value; sendbuffer[2] = (from & 0xff); sendbuffer[3] = (from >> 8); sendbuffer[4] = (to & 0xff); sendbuffer[5] = (to >> 8); send (fd,sendbuffer,6,0); } } /* h * - get memory and hunt for occurances of search pattern */ void hunt(void){ unsigned i,len; char pattern[128],*mem; unsigned from,to,size; if (tokens < 4) puts(helptext[cmd]); else { sscanf(token[1],"%x",&from); sscanf(token[2],"%x",&to); if (from >= to) return; size = to - from; if ((mem = (char*)malloc(size))==NULL){ perror(NULL); return; } if (token[3][0] == '"'){ strncpy(pattern,&token[3][1],sizeof(pattern)); string2pet(pattern); } else{ len = 0; for (i=3;i<tokens;++i) { int tmp; sscanf(token[i],"%x",&tmp); pattern[len++] = tmp; } pattern[len++] = 0; } for (i = 0; i < size ;i += len){ if ((len = size - i) >= 128) len = 128; #if 0 send_memory_request(from + i,len); // len = recv(fd,filebuffer,sizeof(filebuffer),0); len = recv(fd, filebuffer, len > sizeof(filebuffer) ? sizeof(filebuffer) : len,0); #else read_memory_block(filebuffer, len, from + i); #endif memcpy(mem + i,filebuffer,len); } kmp_search(pattern,mem,size,from); free(mem); } } /* c * - get two memory areas and compare them, print differences to stdout */ void compare(void){ unsigned from,to,with,size,i,len,rlen,missmatch; char *buf1,*buf2,*b1,*b2; if (tokens != 4) puts(helptext[cmd]); else{ sscanf(token[1],"%x",&from); sscanf(token[2],"%x",&to); sscanf(token[3],"%x",&with); if (from >= to) return; size = to - from; if ((buf1 = (char*)malloc(size)) == NULL){ perror(NULL); return; } if ((buf2 = (char*)malloc(size)) == NULL){ perror(NULL); return; } for (i = 0; i < size; i += len){ if ((len = size - i) >= 128) len = 128; #if 0 send_memory_request(from + i,len); // rlen = recv(fd,filebuffer,sizeof(filebuffer),0); rlen = recv(fd, filebuffer, len > sizeof(filebuffer) ? sizeof(filebuffer) : len,0); #else rlen = read_memory_block(filebuffer, len, from + i); #endif memcpy(buf1 + i,filebuffer,rlen); #if 0 send_memory_request(with + i,len); // rlen = recv(fd,filebuffer,sizeof(filebuffer),0); rlen = recv(fd, filebuffer, len > sizeof(filebuffer) ? sizeof(filebuffer) : len,0); #else rlen = read_memory_block(filebuffer, len, with + i); #endif memcpy(buf2 + i,filebuffer,rlen); } missmatch = 0; b1 = buf1; b2 = buf2; for (i=0;i<size;++i){ if (*b1 != *b2){ printf("%04x %02x - %04x %02x\n",from+i,*b1,with+i,*b2); ++missmatch; } ++b1; ++b2; } if (missmatch) printf("%d ",missmatch); else printf("no "); puts("mismatches found."); free(buf1); free(buf2); } } /* poke * - send memory write request */ void poke(void){ unsigned address,len,i; // unsigned char values[128],*p; char values[128]; if (tokens < 3) puts(helptext[cmd]); else{ //string...?! if (token[2][0] == '"'){ strncpy(values,&token[2][1],sizeof(values)); string2pet(values); len = strlen(values); } //values else{ len = 0; for (i=2;i<tokens;++i) { int tmp; sscanf(token[i],"%x",&tmp); values[len]= tmp; len++; } } sscanf(token[1],"%x",&address); sendbuffer[0] = POKE; sendbuffer[1] = len; sendbuffer[2] = address & 0xff; sendbuffer[3] = address >> 8; memcpy(&sendbuffer[4],values,len); send(fd,sendbuffer,len+4,0); } } /* help * ? * - help that poor user...! */ void help(void){ int i; if (tokens == 1){ for (i=0;i < COMMANDS;++i) puts(helptext[i]); } else{ for (i = 0;i < COMMANDS; ++i) if (strcmp(token[1],command_table[i])==0) break; if (i == COMMANDS) printf("no help available for %s\n",token[1]); else puts(helptext[i]); } } /* ram * rom * reu * - set ram access mode */ void setram(void){ int access; if (tokens > 2) puts (helptext[cmd]); if (strcmp(token[0],"rom") == 0) access = 0x37; else if (strcmp(token[0],"reu") == 0) access = 0xff; else{ if (tokens == 1) access = 0x34; else sscanf(token[1],"%x",&access); } sendbuffer[0] = SETRAM; sendbuffer[1] = access; send(fd,sendbuffer,2,0); } /* status * - tell server status */ void status(void){ // int len; sendbuffer[0] = STATUS; send(fd,sendbuffer,1,0); /*len = */ recv(fd,sendbuffer,2,0); printf("server reports:\nmemory access is $%02x",sendbuffer[0]); if (sendbuffer[0] & 0x80) printf("(REU)"); printf("\ncurrent device is %d\n",sendbuffer[1]); } /* cmd * - call system command */ void command(char *cmd) { int ret; if ((ret = system(cmd)) < 0) { printf("err: %s returned %d\n", cmd, ret); } } // ----------------------------------------------------------------------------- int cleanup(int n) { chameleon_close(); return n; } #define C64_RAM_SIZE 0x10000 unsigned char buffer[C64_RAM_SIZE]; int main (int argc, char ** argv) { unsigned int n,direct_flag = 0,len,addr; int i; #ifdef LINUX /* for readline */ char *cline = NULL; #endif char *name = NULL, *fname; /* set default values */ old_cmd = 0; /* parse command line for options (-ip, -p)*/ for (i=1;i<argc;++i){ if (strcmp (argv[i] ,"--help") == 0 || strcmp (argv[i],"-h") == 0 || strcmp(argv[i],"-?") == 0){ puts(usage); return 0; } else if (strcmp (argv[i],"--version") == 0 || strcmp (argv[i],"-v") == 0){ printf("chmon version %s\n",version); return 0; } else if (strcmp (argv[i] ,"--command") == 0 || strcmp (argv[i],"-c") == 0){ while (++i < argc){ strncat(string, argv[i], sizeof(string) - 1); if (i != argc-1) strncat(string," ",sizeof(string) - 1); } direct_flag = 1; break; } else if (!strcmp (argv[i] ,"--send") || !strcmp("-s", argv[i])) { name = "chmon.prg"; } else { printf("invalid option: %s\ntry %s -h\n",argv[i],argv[0]); exit(EXIT_FAILURE); } } chameleon_setlogfunc(logfunc); if (chameleon_init() < 0) { LOGERR("initialization failed.\n"); exit(EXIT_FAILURE); } if (name) { FILE *f; /* write .prg file to memory and SYS to its start addr */ if ((f = fopen(name, "rb")) == NULL) { fname = malloc(5 + strlen(argv[0])); sprintf(fname, "%s.prg", argv[0]); f = fopen(fname, "rb"); free(fname); if (f == NULL) { LOGERR("error opening: '%s'\n", name); exit(cleanup(EXIT_FAILURE)); } } addr = fgetc(f); addr += ((int)fgetc(f) << 8); len = fread(buffer, 1, C64_RAM_SIZE - addr, f); fclose(f); printf("sending '%s' ($%04x bytes to $%04x.)...\n", name, len, addr); if (chameleon_writememory(buffer, len, addr) < 0) { LOGERR("error writing to chameleon memory.\n"); exit(cleanup(EXIT_FAILURE)); } execute_sys(addr); } //command interpreter loop do{ if (!direct_flag){ #ifndef LINUX printf("\n%s",prompt); fgets(string,sizeof(string),stdin); for (i=0;i< (int)strlen(string);++i){ if (string[i] == '\n'){ string[i] = '\0'; break; } } #else if (cline){ free(cline); cline = NULL; } cline = readline(prompt); if (cline && *cline) add_history(cline); strncpy(string,cline,sizeof(string)); #endif } /* if not "m","i" or "d", ignore "empty" input */ if (strlen(string) == 0){ if (old_cmd > 2) continue; else cmd = old_cmd; } else { //treat special commands: $,#,@ if (string[0] == '@'){ disk_command(&string[1]); continue; } else if (string[0] == '$'){ directory(string); continue; } else if (string[0] == '#'){ device(&string[1]); continue; } // parse input into tokens tokens = tokenize(string); if (tokens == 0) continue; //let's look, if the first token is a known command... for(cmd = 0; cmd < COMMANDS; ++cmd){ if (strcmp(token[0],command_table[cmd]) == 0) break; } //not found...?! what a pity. if (cmd == COMMANDS){ printf("what exactly do you mean by: '%s'\ntype 'help' to get some help\n",token[0]); continue; } old_cmd = cmd; } if (cmd == 22 || cmd == 23) break; //"quit" or "x" // call the according function, then loop switch (cmd){ case 0: mon(); break; case 1: interrogate(); break; case 2: disassembly(); break; case 3: jump(); break; case 4: hunt(); break; case 5: fill(); break; case 6: compare(); break; case 7: put(); break; case 8: get(); break; case 9: poke(); break; //10 $ directory //11 @ disk_command //12 # device case 13: read_file(); break; case 14: write_file(); break; case 15: sendbuffer[0] = RUN; send (fd,sendbuffer,1,0); break; case 16: sendbuffer[0] = BASIC; send (fd,sendbuffer,1,0); break; case 17: case 18: case 19: setram(); break; case 20: case 21: help(); break; //22 quit //23 x case 24: status(); break; case 25: sendbuffer[0] = INIT; send (fd,sendbuffer,1,0); break; case 26: call(); break; case 27: string[0] = '\0'; for (n=1;n<tokens;++n){ strcat(string,token[n]); strcat(string," "); } command(string); } }while(direct_flag == 0); return EXIT_SUCCESS; }
30.38129
128
0.455795
1c50b8e766167389fcdffd5c62b3d0c1ddf59b41
1,076
h
C
B2G/gecko/other-licenses/7zstub/src/7zip/Common/LSBFEncoder.h
wilebeast/FireFox-OS
43067f28711d78c429a1d6d58c77130f6899135f
[ "Apache-2.0" ]
3
2015-08-31T15:24:31.000Z
2020-04-24T20:31:29.000Z
B2G/gecko/other-licenses/7zstub/src/7zip/Common/LSBFEncoder.h
wilebeast/FireFox-OS
43067f28711d78c429a1d6d58c77130f6899135f
[ "Apache-2.0" ]
null
null
null
B2G/gecko/other-licenses/7zstub/src/7zip/Common/LSBFEncoder.h
wilebeast/FireFox-OS
43067f28711d78c429a1d6d58c77130f6899135f
[ "Apache-2.0" ]
3
2015-07-29T07:17:15.000Z
2020-11-04T06:55:37.000Z
// Stream/LSBFEncoder.h #ifndef __STREAM_LSBFENCODER_H #define __STREAM_LSBFENCODER_H #include "../IStream.h" #include "OutBuffer.h" namespace NStream { namespace NLSBF { class CEncoder { COutBuffer m_Stream; int m_BitPos; Byte m_CurByte; public: bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); } void SetStream(ISequentialOutStream *outStream) { m_Stream.SetStream(outStream); } void ReleaseStream() { m_Stream.ReleaseStream(); } void Init() { m_Stream.Init(); m_BitPos = 8; m_CurByte = 0; } HRESULT Flush() { FlushByte(); return m_Stream.Flush(); } void FlushByte() { if(m_BitPos < 8) m_Stream.WriteByte(m_CurByte); m_BitPos = 8; m_CurByte = 0; } void WriteBits(UInt32 value, int numBits); UInt32 GetBitPosition() const { return (8 - m_BitPos); } UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; } void WriteByte(Byte b) { m_Stream.WriteByte(b);} }; }} #endif
20.692308
85
0.641264
ea753566e101b209d916c6d8d5f2b2109f1801f4
510
h
C
vendors/st/boards/stm32l496_discovery/aws_demos/application_code/st_code/bg96_modem.h
weichihl/afr-stm32l496-bg96-water-meter
6223e5813a4c14a2bc20a788237fda636144d09c
[ "MIT" ]
1
2021-01-15T02:08:12.000Z
2021-01-15T02:08:12.000Z
vendors/st/boards/stm32l496_discovery/aws_demos/application_code/st_code/bg96_modem.h
weichihl/afr-stm32l496-bg96-water-meter
6223e5813a4c14a2bc20a788237fda636144d09c
[ "MIT" ]
null
null
null
vendors/st/boards/stm32l496_discovery/aws_demos/application_code/st_code/bg96_modem.h
weichihl/afr-stm32l496-bg96-water-meter
6223e5813a4c14a2bc20a788237fda636144d09c
[ "MIT" ]
null
null
null
/* * Copyright (C) 2018, Verizon, Inc. All rights reserved. */ /** * @file aws_BG96_modem.h * @brief BG96 modem interface. */ #ifndef _BG96_MODEM_H_ #define _BG96_MODEM_H_ typedef enum { network_is_up = 1, network_is_down = 0 } BG96_network_status_t; /** * @brief Initialize the BG96 HAL. * * This function initializes the low level hardware drivers and must be called * before calling any other modem API * */ void BG96_HAL_Init(void); #endif /* _BG96_MODEM_H_ */
18.214286
79
0.672549
209590537d8dce9d2cc2fd37438bf4271b967260
431
h
C
GUIText.h
sknjpn/SyDesk
ae240d7cff2844822720abe80dac70acf1480e8a
[ "MIT" ]
2
2020-01-01T01:20:26.000Z
2020-11-09T07:46:00.000Z
GUIText.h
sknjpn/SyDesk
ae240d7cff2844822720abe80dac70acf1480e8a
[ "MIT" ]
null
null
null
GUIText.h
sknjpn/SyDesk
ae240d7cff2844822720abe80dac70acf1480e8a
[ "MIT" ]
null
null
null
#pragma once #include "EasyViewer.h" class GUIText : public EasyViewer { public: String m_text; Font m_font; Color m_color; enum class Mode { DrawAtCenter, DrawInBox, DrawLeftCenter, } m_mode; public: GUIText(const String& text, const Font& font, Mode mode = Mode::DrawAtCenter, Color color = Palette::Black) : m_text(text) , m_font(font) , m_mode(mode) , m_color(color) {} void update() override; };
14.366667
108
0.689095
e14a91a9f6748ac9348767bd7f1da2a2cbea03df
220
h
C
GOpenSourceModules/SettingsModule/GosSettingsViewController.h
gizwits/gokit-ios
2bf3db6623601bca6b334c7c152a50a5c3b2e0a0
[ "MIT" ]
8
2015-01-26T08:03:25.000Z
2018-06-18T21:16:20.000Z
GOpenSourceModules/SettingsModule/GosSettingsViewController.h
gizwits/gokit-ios
2bf3db6623601bca6b334c7c152a50a5c3b2e0a0
[ "MIT" ]
2
2016-06-21T14:17:05.000Z
2016-12-04T09:49:46.000Z
GOpenSourceModules/SettingsModule/GosSettingsViewController.h
gizwits/gokit-ios
2bf3db6623601bca6b334c7c152a50a5c3b2e0a0
[ "MIT" ]
12
2015-01-13T02:07:15.000Z
2019-04-02T07:17:27.000Z
// // SettingsViewController.h // GBOSA // // Created by Zono on 16/5/12. // Copyright © 2016年 Gizwits. All rights reserved. // #import <UIKit/UIKit.h> @interface GosSettingsViewController : UIViewController @end
15.714286
55
0.709091
2dcc86dbd5534c2537f0f9d42314cf48f04679b0
529
h
C
src/shp_font.h
tpimh/CadZinho
5157ad9b0740112bc84893e9c5e2cd3067347193
[ "MIT" ]
74
2018-10-10T20:00:00.000Z
2022-03-14T16:34:14.000Z
src/shp_font.h
tpimh/CadZinho
5157ad9b0740112bc84893e9c5e2cd3067347193
[ "MIT" ]
18
2018-11-10T23:57:27.000Z
2022-03-21T11:16:10.000Z
src/shp_font.h
tpimh/CadZinho
5157ad9b0740112bc84893e9c5e2cd3067347193
[ "MIT" ]
14
2018-11-11T00:02:48.000Z
2022-03-16T09:06:56.000Z
#ifndef _SHP_FONT #define _SHP_FONT const char * shp_font_romant(); const char * shp_font_gothicg(); const char * shp_font_isocp(); const char * shp_font_scriptc(); const char * shp_font_simplex(); const char * shp_font_gothici(); const char * shp_font_romans(); const char * shp_font_romanc(); const char * shp_font_complex(); const char * shp_font_scripts(); const char * shp_font_italic(); const char * shp_font_gothice(); const char * shp_font_ltypeshp(); const char * shp_font_txt(); const char * shp_font_romand(); #endif
26.45
33
0.756144
7b5fa8916fadbab650ac3653159f7c2570366931
683
h
C
MFCampaignEngagement/MFCampaignEngagement/Utilities/MFAlertWindow.h
leo9763/MFEngagement
db17b57666fca9e407aceffcfbfe2ff818d98a7f
[ "MIT" ]
null
null
null
MFCampaignEngagement/MFCampaignEngagement/Utilities/MFAlertWindow.h
leo9763/MFEngagement
db17b57666fca9e407aceffcfbfe2ff818d98a7f
[ "MIT" ]
null
null
null
MFCampaignEngagement/MFCampaignEngagement/Utilities/MFAlertWindow.h
leo9763/MFEngagement
db17b57666fca9e407aceffcfbfe2ff818d98a7f
[ "MIT" ]
null
null
null
// // MFAlertWindow.h // MFCampaignEngagement // // Created by NeroMilk on 12/27/15. // Copyright © 2015 MingFung. All rights reserved. // #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @protocol MFAlertWindowDelegate <NSObject> @required - (void)dismissWithClickedButtonIndex:(NSUInteger)index; @end @interface MFAlertWindow : UIWindow @property (assign , nonatomic) id<MFAlertWindowDelegate> delegate; + (MFAlertWindow *)alertWindow; + (void)showAlertWithTitle:(NSString *)title message:(NSString *)message controller:(UIViewController *)controller compeletedHandler:(void(^)(NSUInteger clickedIndex))handler buttonTitles:(NSString *)buttonTitles,...; @end
24.392857
217
0.765739
3cdd5d4a3f5408f56dfab987e0399d4a547cb851
800
h
C
FirmwareUpdate/Classes/Fota/BtNotify/utils/SPC_LogUtils.h
xuezou/DFUAssistant
f8d965c0c9b3cb043d6d50ee872ada12e203dd9b
[ "MIT" ]
1
2019-04-01T08:18:30.000Z
2019-04-01T08:18:30.000Z
FirmwareUpdate/Classes/Fota/BtNotify/utils/SPC_LogUtils.h
xuezou/DFUAssistant
f8d965c0c9b3cb043d6d50ee872ada12e203dd9b
[ "MIT" ]
null
null
null
FirmwareUpdate/Classes/Fota/BtNotify/utils/SPC_LogUtils.h
xuezou/DFUAssistant
f8d965c0c9b3cb043d6d50ee872ada12e203dd9b
[ "MIT" ]
2
2019-05-27T13:20:33.000Z
2020-09-27T16:08:08.000Z
// // SPC_LogUtils.h // MTKBleManager // // Created by user on 2017/2/17. // Copyright © 2017年 ___MTK___. All rights reserved. // #ifndef __LOG_UTILS_H__ #define __LOG_UTILS_H__ // Define debug log #ifdef DEBUG #define LOG_D(tag, fmt, ...) NSLog(@"[D][BtNotify][%@][%d] - %@", tag, __LINE__, [NSString stringWithFormat:fmt, __VA_ARGS__]) #else #define LOG_D(tag, fmt, ...) #endif //DEBUG // Define information log //#ifdef INFO #define LOG_I(tag, fmt, ...) NSLog(@"[I][BtNotify][%@][%d] - %@", tag, __LINE__, [NSString stringWithFormat:fmt, __VA_ARGS__]) //#else //#define LOG_I(tag, fmt, ...) //#endif // INFO // Define error log #define LOG_E(tag, fmt, ...) NSLog(@"[E][BtNotify][%@][%d] - %@", tag, __LINE__, [NSString stringWithFormat:fmt, __VA_ARGS__]) #endif
25
133
0.6325
7157f9191b041e995420e234a9d447721f12b9cc
759
c
C
nvim/native.c
LuaDist-testing/nvim-client
c0ff82c80d9bc3024b3ccaae7d96d89ee195a713
[ "Apache-2.0" ]
null
null
null
nvim/native.c
LuaDist-testing/nvim-client
c0ff82c80d9bc3024b3ccaae7d96d89ee195a713
[ "Apache-2.0" ]
null
null
null
nvim/native.c
LuaDist-testing/nvim-client
c0ff82c80d9bc3024b3ccaae7d96d89ee195a713
[ "Apache-2.0" ]
null
null
null
#define LUA_LIB #include <lua.h> #include <lauxlib.h> #define UNUSED(x) ((void)x) #ifdef _WIN32 static int pid_wait(lua_State *L) { (void)(L); return 0; } #else #include <sys/wait.h> #include <signal.h> static int pid_wait(lua_State *L) { int status; pid_t pid = luaL_checkint(L, 1); /* Work around libuv bug that leaves defunct children: * https://github.com/libuv/libuv/issues/154 */ while (!kill(pid, 0)) waitpid(pid, &status, WNOHANG); return 0; } #endif static const luaL_Reg native_lib_f[] = { {"pid_wait", pid_wait}, {NULL, NULL} }; int luaopen_nvim_native(lua_State *L) { lua_newtable(L); #if LUA_VERSION_NUM >= 502 luaL_setfuncs(L, native_lib_f, NULL); #else luaL_register(L, NULL, native_lib_f); #endif return 1; }
18.975
56
0.683794
21ae81a1c66c1f24fd7bd6d52a8aafae6a48895b
5,125
h
C
hex-2020/GroupePredicate.h
benevolarX/hex-2020
630f1d550649bc6f1dfb535cdd2d3f14b01ed322
[ "MIT" ]
null
null
null
hex-2020/GroupePredicate.h
benevolarX/hex-2020
630f1d550649bc6f1dfb535cdd2d3f14b01ed322
[ "MIT" ]
null
null
null
hex-2020/GroupePredicate.h
benevolarX/hex-2020
630f1d550649bc6f1dfb535cdd2d3f14b01ed322
[ "MIT" ]
null
null
null
#pragma once #include <vector> #include <algorithm> #include "Predicate.h" namespace hex { template<class T> struct Predicate; template<class T> struct GroupePredicate : public Predicate<std::vector<T>> { public: GroupePredicate() : Predicate<std::vector<T> >() {} GroupePredicate(T e) : Predicate<std::vector<T> >(), elem(e) {} virtual std::string get_msg_error() { return "erreur inconnue de GroupePredicate"; } protected: T elem; }; template<class T> struct GroupePredicate; template<class T> struct NoDoublon : public GroupePredicate<T> { public: NoDoublon() : GroupePredicate<T>() {} virtual std::string get_msg_error() { return "erreur inconnue de NoDoublon"; } protected: virtual bool test(const std::vector<T>& v) const { std::sort(v.begin(), v.end()); auto last = std::unique(v.begin(), v.end()); return std::distance(v.begin(), last) == v.size(); } }; template<class T> struct GroupePredicate; template<class T> struct MaxN : public GroupePredicate<T> { public: MaxN(int n) : GroupePredicate<T>(), mon_max(n) {} virtual std::string get_msg_error() { return "erreur inconnue de MaxN"; } protected: virtual bool test(const std::vector<T>& v) const { for (T e : v) { if (this.mon_max > std::count(v.begin(), v.end(), e)) { return false; } } return true; } int mon_max; }; template<class T> struct GroupePredicate; template<class T> struct Contains : public GroupePredicate<T> { public: Contains(T e) : GroupePredicate<T>(e) {} virtual std::string get_msg_error() { return "erreur inconnue de Contains"; } protected: virtual bool test(const std::vector<T>& v) const { return std::find(v.begin(), v.end(), this->elem) != v.end(); } }; template<class T> struct GroupePredicate; template<class T> struct Predicate; template<class T> struct MatchAll : public GroupePredicate<T> { public: MatchAll(Predicate<T>* t) : GroupePredicate<T>(), mon_test(t) {} virtual std::string get_msg_error() { return "erreur inconnue de MatchAll"; } protected: virtual bool test(const std::vector<T>& v) const { return std::any_of(v.begin(), v.end(), mon_test); } Predicate<T> mon_test; }; template<class T> struct GroupePredicate; template<class T> struct Predicate; template<class T> struct MatchNone : public GroupePredicate<T> { public: MatchNone(Predicate<T>* t) : GroupePredicate<T>(), mon_test(t) {} virtual std::string get_msg_error() { return "erreur inconnue de MatchNone"; } protected: virtual bool test(const std::vector<T>& v) const { return std::none_of(v.begin(), v.end(), mon_test); } Predicate<T> mon_test; }; template<class T> struct GroupePredicate; template<class T> struct Predicate; template<class T> struct Sorted : public GroupePredicate<T> { public: Sorted() : GroupePredicate<T>() {} virtual std::string get_msg_error() { return "erreur inconnue de Sorted"; } protected: virtual bool test(const std::vector<T>& v) const { return std::is_sorted(v.begin(), v.end()); } }; template<class T> struct GroupePredicate; template<class T> struct Predicate; template<class T> struct MaxElem : public GroupePredicate<T> { public: MaxElem(T e) : GroupePredicate<T>(e) {} virtual std::string get_msg_error() { return "erreur inconnue de MaxElem"; } protected: virtual bool test(const std::vector<T>& v) const { return this->elem >= std::max_element(v.begin(), v.end()); } }; template<class T> struct GroupePredicate; template<class T> struct Predicate; template<class T> struct MinElem : public GroupePredicate<T> { public: MinElem(T e) : GroupePredicate<T>(e) {} virtual std::string get_msg_error() { return "erreur inconnue de MinElem"; } protected: virtual bool test(const std::vector<T>& v) const { return this->elem <= std::min_element(v.begin(), v.end()); } }; template<class T> struct GroupePredicate; template<class T> struct Predicate; template<class T> struct Size : public GroupePredicate<T> { public: Size(int n) : GroupePredicate<T>(), taille(n) {} virtual std::string get_msg_error() { return "erreur inconnue de Size"; } protected: virtual bool test(const std::vector<T>& v) const { return this->mon_max == v.size(); } int taille; }; }
28.792135
73
0.570341
90c0f56d9f8f56b59ba89bded83287cbec0d07b2
10,970
c
C
extra/gplugin/files/gplugin/gplugin/gplugin-loader.c
sauzerOS/repo-fork
ade082ad1f0dc8a098e7fc9821779ab70ce57950
[ "MIT" ]
null
null
null
extra/gplugin/files/gplugin/gplugin/gplugin-loader.c
sauzerOS/repo-fork
ade082ad1f0dc8a098e7fc9821779ab70ce57950
[ "MIT" ]
null
null
null
extra/gplugin/files/gplugin/gplugin/gplugin-loader.c
sauzerOS/repo-fork
ade082ad1f0dc8a098e7fc9821779ab70ce57950
[ "MIT" ]
null
null
null
/* * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see <https://www.gnu.org/licenses/>. */ #include <gplugin/gplugin-core.h> #include <gplugin/gplugin-loader.h> /** * SECTION:gplugin-loader * @title: Plugin Loader * @short_description: Abstract class for loading plugins * * GPluginLoader defines the base behavior for loaders of all languages. */ /** * GPLUGIN_TYPE_LOADER: * * The standard _get_type macro for #GPluginLoader. */ /** * GPluginLoader: * * An abstract class that should not be accessed directly. */ /** * GPluginLoaderClass: * @supported_extensions: The supported_extensions vfunc returns a #GList of * file extensions that this loader supports without the * leading dot. For example: 'so', 'dll', 'py', etc. * @query: The query vfunc is called when the plugin manager needs to query a * plugin that has a file extension from @supported_extensions. * @load: The load vfunc is called when the plugin manager wants to load a * plugin that was previously queried by this loader. * @unload: The unload vfunc is called when the plugin manager wants to unload * a previously loaded plugin from this loader. * * #GPluginLoaderClass defines the behavior for loading plugins. */ typedef struct { gchar *id; } GPluginLoaderPrivate; enum { PROP_0, PROP_ID, N_PROPERTIES, }; static GParamSpec *properties[N_PROPERTIES] = { NULL, }; G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE( GPluginLoader, gplugin_loader, G_TYPE_OBJECT); /****************************************************************************** * Helpers *****************************************************************************/ static void gplugin_loader_set_id(GPluginLoader *loader, const gchar *id) { GPluginLoaderPrivate *priv = gplugin_loader_get_instance_private(loader); g_free(priv->id); priv->id = g_strdup(id); g_object_notify_by_pspec(G_OBJECT(loader), properties[PROP_ID]); } /****************************************************************************** * GObject Implementation *****************************************************************************/ static void gplugin_loader_get_property( GObject *obj, guint param_id, GValue *value, GParamSpec *pspec) { GPluginLoader *loader = GPLUGIN_LOADER(obj); switch(param_id) { case PROP_ID: g_value_set_string(value, gplugin_loader_get_id(loader)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); break; } } static void gplugin_loader_set_property( GObject *obj, guint param_id, const GValue *value, GParamSpec *pspec) { GPluginLoader *loader = GPLUGIN_LOADER(obj); switch(param_id) { case PROP_ID: gplugin_loader_set_id(loader, g_value_get_string(value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); break; } } static void gplugin_loader_finalize(GObject *obj) { GPluginLoader *loader = NULL; GPluginLoaderPrivate *priv = NULL; loader = GPLUGIN_LOADER(obj); priv = gplugin_loader_get_instance_private(loader); g_clear_pointer(&priv->id, g_free); G_OBJECT_CLASS(gplugin_loader_parent_class)->finalize(obj); } static void gplugin_loader_init(G_GNUC_UNUSED GPluginLoader *loader) { } static void gplugin_loader_class_init(G_GNUC_UNUSED GPluginLoaderClass *klass) { GObjectClass *obj_class = G_OBJECT_CLASS(klass); obj_class->get_property = gplugin_loader_get_property; obj_class->set_property = gplugin_loader_set_property; obj_class->finalize = gplugin_loader_finalize; /** * GPluginLoader::id: * * The identifier of the loader. * * Since: 0.34.0 */ properties[PROP_ID] = g_param_spec_string( "id", "id", "The identifier of the loader", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_properties(obj_class, N_PROPERTIES, properties); } /****************************************************************************** * API *****************************************************************************/ /** * gplugin_loader_get_id: * @loader: The #GPluginLoader instance. * * Gets the identifier of @loader. * * Returns: The ID of @loader. * * Since: 0.34.0 */ const gchar * gplugin_loader_get_id(GPluginLoader *loader) { GPluginLoaderPrivate *priv = NULL; g_return_val_if_fail(GPLUGIN_IS_LOADER(loader), NULL); priv = gplugin_loader_get_instance_private(loader); return priv->id; } /** * gplugin_loader_query_plugin: * @loader: The #GPluginLoader instance performing the query. * @filename: The filename to query. * @error: (nullable): The return location for a #GError, or %NULL. * * This function is called by the plugin manager to ask @loader to query * @filename and determine if it's a usable plugin. * * Return value: (transfer full): A #GPluginPlugin instance or %NULL on * failure. */ GPluginPlugin * gplugin_loader_query_plugin( GPluginLoader *loader, const gchar *filename, GError **error) { GPluginLoaderClass *klass = NULL; GPluginPlugin *plugin = NULL; GError *real_error = NULL; g_return_val_if_fail(loader != NULL, NULL); g_return_val_if_fail(GPLUGIN_IS_LOADER(loader), NULL); g_return_val_if_fail(filename, NULL); g_return_val_if_fail(error != NULL, NULL); klass = GPLUGIN_LOADER_GET_CLASS(loader); if(klass != NULL && klass->query != NULL) { plugin = klass->query(loader, filename, &real_error); } if(!GPLUGIN_IS_PLUGIN(plugin)) { if(real_error == NULL) { real_error = g_error_new_literal( GPLUGIN_DOMAIN, 0, "Failed to query plugin : unknown"); } g_propagate_error(error, real_error); } else { /* If the plugin successfully queried but returned an error, ignore the * error. */ g_clear_error(&real_error); /* Likewise, make sure the plugin's error is set to NULL. */ g_object_set(G_OBJECT(plugin), "error", NULL, NULL); gplugin_plugin_set_state(plugin, GPLUGIN_PLUGIN_STATE_QUERIED); } return plugin; } /** * gplugin_loader_load_plugin: * @loader: The #GPluginLoader instance performing the load. * @plugin: The #GPluginPlugin instance to load. * @error: (nullable): The return location for a #GError, or %NULL. * * This function is called by the plugin manager to ask @loader to load * @plugin. * * Return value: %TRUE if @plugin was loaded successfully, %FALSE otherwise. */ gboolean gplugin_loader_load_plugin( GPluginLoader *loader, GPluginPlugin *plugin, GError **error) { GPluginLoaderClass *klass = NULL; GError *real_error = NULL; gboolean ret = FALSE; g_return_val_if_fail(loader != NULL, FALSE); g_return_val_if_fail(GPLUGIN_IS_LOADER(loader), FALSE); g_return_val_if_fail(GPLUGIN_IS_PLUGIN(plugin), FALSE); /* if the plugin is already loaded there's nothing for us to do */ if(gplugin_plugin_get_state(plugin) == GPLUGIN_PLUGIN_STATE_LOADED) { return TRUE; } klass = GPLUGIN_LOADER_GET_CLASS(loader); if(klass != NULL && klass->load != NULL) { ret = klass->load(loader, plugin, &real_error); } if(!ret) { if(real_error == NULL) { real_error = g_error_new_literal( GPLUGIN_DOMAIN, 0, "Failed to load plugin : unknown"); } /* Set the error on the plugin as well. This has to be before we * propagate the error, because error is invalidate at that point. */ g_object_set(plugin, "error", real_error, NULL); /* Set the state after the error is set, because people might connect * to the notify signal on the state property. */ gplugin_plugin_set_state(plugin, GPLUGIN_PLUGIN_STATE_LOAD_FAILED); g_propagate_error(error, real_error); } else { /* If the plugin successfully loaded but returned an error, ignore the * error. */ g_clear_error(&real_error); /* Likewise, make sure the plugin's error is set to NULL. */ g_object_set(G_OBJECT(plugin), "error", NULL, NULL); gplugin_plugin_set_state(plugin, GPLUGIN_PLUGIN_STATE_LOADED); } return ret; } /** * gplugin_loader_unload_plugin: * @loader: The #GPluginLoader instance performing the unload. * @plugin: The #GPluginPlugin instance to unload. * @error: (nullable): The return location for a #GError, or %NULL. * * This function is called by the plugin manager to ask @loader to unload * @plugin. * * Return value: %TRUE if @plugin was unloaded successfully, %FALSE otherwise. */ gboolean gplugin_loader_unload_plugin( GPluginLoader *loader, GPluginPlugin *plugin, GError **error) { GPluginLoaderClass *klass = NULL; GError *real_error = NULL; gboolean ret = FALSE; g_return_val_if_fail(loader != NULL, FALSE); g_return_val_if_fail(GPLUGIN_IS_LOADER(loader), FALSE); g_return_val_if_fail(GPLUGIN_IS_PLUGIN(plugin), FALSE); if(gplugin_plugin_get_state(plugin) != GPLUGIN_PLUGIN_STATE_LOADED) { return TRUE; } klass = GPLUGIN_LOADER_GET_CLASS(loader); if(klass != NULL && klass->unload != NULL) { ret = klass->unload(loader, plugin, &real_error); } if(!ret) { if(real_error == NULL) { real_error = g_error_new_literal( GPLUGIN_DOMAIN, 0, "Failed to unload plugin : unknown"); } g_object_set(G_OBJECT(plugin), "error", real_error, NULL); /* Set the state after the error is set, because people might connect * to the notify signal on the state property. */ gplugin_plugin_set_state(plugin, GPLUGIN_PLUGIN_STATE_UNLOAD_FAILED); g_propagate_error(error, real_error); } else { /* If the plugin successfully unloaded but returned an error, ignore the * error. */ g_clear_error(error); gplugin_plugin_set_state(plugin, GPLUGIN_PLUGIN_STATE_QUERIED); } return ret; } /** * gplugin_loader_get_supported_extensions: * @loader: The #GPluginLoader instance. * * Returns a #GSList of strings containing the extensions that the loader * supports. Each extension should not include the dot. For example: so, * dll, py, etc. * * Return value: (element-type utf8) (transfer container): A #GSList of * extensions that the loader supports. */ GSList * gplugin_loader_get_supported_extensions(GPluginLoader *loader) { GPluginLoaderClass *klass = NULL; g_return_val_if_fail(GPLUGIN_IS_LOADER(loader), NULL); klass = GPLUGIN_LOADER_GET_CLASS(loader); if(klass != NULL && klass->supported_extensions) { return klass->supported_extensions(loader); } return NULL; }
26.433735
80
0.696992
90dae9c3a3db5f08285f158bba80f04697371ba6
2,868
h
C
Graph/MatrixGraph.h
PurpleSky-NS/Graph
bfd0dd6f13c08b8ee8020c3317d815753408788d
[ "Apache-2.0" ]
1
2020-04-30T10:34:21.000Z
2020-04-30T10:34:21.000Z
Graph/MatrixGraph.h
PurpleSky-NS/Graph
bfd0dd6f13c08b8ee8020c3317d815753408788d
[ "Apache-2.0" ]
null
null
null
Graph/MatrixGraph.h
PurpleSky-NS/Graph
bfd0dd6f13c08b8ee8020c3317d815753408788d
[ "Apache-2.0" ]
null
null
null
#pragma once #include "GraphBase.h" /*邻接矩阵图的父类,实现了一些邻接矩阵图的共有操作*/ template<class T, class W> class MatrixGraph :public GraphBase<T, W> { public: using typename GraphBase<T, W>::VertexPosType; using typename GraphBase<T, W>::OnPassVertex; using typename GraphBase<T, W>::OnPassEdge; /*插入一条边,对于无向图,两个参数顺序无所谓 O(1)*/ virtual void InsertEdge(VertexPosType from, VertexPosType to, const W& weight)override; /*查找从from到to是否存在边 O(1)*/ virtual bool ExistEdge(VertexPosType from, VertexPosType to)const override; /*删除边 O(1)*/ virtual void RemoveEdge(VertexPosType from, VertexPosType to)override; /*遍历出邻接点 O(VertexNum)*/ virtual void ForeachOutNeighbor(VertexPosType v, OnPassVertex func)const override; /*遍历入邻接点 O(VertexNum)*/ virtual void ForeachInNeighbor(VertexPosType v, OnPassVertex func)const override; /*遍历出邻接点*/ virtual void ForeachOutNeighbor(VertexPosType v, OnPassEdge func)const override; /*遍历入邻接点(在无向图中与@GetOutNeighbor功能相同)*/ virtual void ForeachInNeighbor(VertexPosType v, OnPassEdge func)const override; /*收缩内存占用,在每次移除一个顶点时并不会真的释放内存,从而提高再次插入顶点效率,详见@vector 如果不需要插入顶点或者需要收缩内存,请调用这个 内部调用@vector.shrink_to_fit*/ virtual void Shrink_To_Fit() = 0; virtual constexpr bool IsMatrix()const override; }; template<class T, class W> inline void MatrixGraph<T, W>::InsertEdge(VertexPosType from, VertexPosType to, const W& weight) { if (ExistEdge(from, to)) return; ++this->m_edgeNum; this->SetWeight(from, to, weight); } template<class T, class W> inline bool MatrixGraph<T, W>::ExistEdge(VertexPosType from, VertexPosType to) const { return this->GetWeight(from, to) != (W)0; } template<class T, class W> inline void MatrixGraph<T, W>::RemoveEdge(VertexPosType from, VertexPosType to) { if (!ExistEdge(from, to)) return; --this->m_edgeNum; this->SetWeight(from, to, (W)0); } template<class T, class W> inline void MatrixGraph<T, W>::ForeachOutNeighbor(VertexPosType v, OnPassVertex func) const { for (VertexPosType i = 0; i < this->m_vertexData.size(); ++i) if (ExistEdge(v, i)) func(i); } template<class T, class W> inline void MatrixGraph<T, W>::ForeachInNeighbor(VertexPosType v, OnPassVertex func) const { for (VertexPosType i = 0; i < this->m_vertexData.size(); ++i) if (this->ExistEdge(i, v)) func(i); } template<class T, class W> inline void MatrixGraph<T, W>::ForeachOutNeighbor(VertexPosType v, OnPassEdge func) const { for (VertexPosType i = 0; i < this->m_vertexData.size(); ++i) if (ExistEdge(v, i)) func(v, i, this->GetWeight(v, i)); } template<class T, class W> inline void MatrixGraph<T, W>::ForeachInNeighbor(VertexPosType v, OnPassEdge func) const { for (VertexPosType i = 0; i < this->m_vertexData.size(); ++i) if (this->ExistEdge(i, v)) func(i, v, this->GetWeight(i, v)); } template<class T, class W> inline constexpr bool MatrixGraph<T, W>::IsMatrix() const { return true; }
27.056604
96
0.733961
90e745ab0f08018663fa3242111bfaa26c34599c
4,144
h
C
third_party/WebKit/Source/bindings/tests/results/core/DoubleOrStringOrDoubleOrStringSequence.h
metux/chromium-deb
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
third_party/WebKit/Source/bindings/tests/results/core/DoubleOrStringOrDoubleOrStringSequence.h
metux/chromium-deb
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
third_party/WebKit/Source/bindings/tests/results/core/DoubleOrStringOrDoubleOrStringSequence.h
metux/chromium-deb
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file has been auto-generated by code_generator_v8.py. // DO NOT MODIFY! // This file has been generated from the Jinja2 template in // third_party/WebKit/Source/bindings/templates/union_container.h.tmpl // clang-format off #ifndef DoubleOrStringOrDoubleOrStringSequence_h #define DoubleOrStringOrDoubleOrStringSequence_h #include "bindings/core/v8/Dictionary.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/NativeValueTraits.h" #include "bindings/core/v8/V8BindingForCore.h" #include "core/CoreExport.h" #include "platform/heap/Handle.h" namespace blink { class DoubleOrString; class CORE_EXPORT DoubleOrStringOrDoubleOrStringSequence final { DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); public: DoubleOrStringOrDoubleOrStringSequence(); bool isNull() const { return m_type == SpecificTypeNone; } bool isDouble() const { return m_type == SpecificTypeDouble; } double getAsDouble() const; void setDouble(double); static DoubleOrStringOrDoubleOrStringSequence fromDouble(double); bool isDoubleOrStringSequence() const { return m_type == SpecificTypeDoubleOrStringSequence; } const HeapVector<DoubleOrString>& getAsDoubleOrStringSequence() const; void setDoubleOrStringSequence(const HeapVector<DoubleOrString>&); static DoubleOrStringOrDoubleOrStringSequence fromDoubleOrStringSequence(const HeapVector<DoubleOrString>&); bool isString() const { return m_type == SpecificTypeString; } const String& getAsString() const; void setString(const String&); static DoubleOrStringOrDoubleOrStringSequence fromString(const String&); DoubleOrStringOrDoubleOrStringSequence(const DoubleOrStringOrDoubleOrStringSequence&); ~DoubleOrStringOrDoubleOrStringSequence(); DoubleOrStringOrDoubleOrStringSequence& operator=(const DoubleOrStringOrDoubleOrStringSequence&); DECLARE_TRACE(); private: enum SpecificTypes { SpecificTypeNone, SpecificTypeDouble, SpecificTypeDoubleOrStringSequence, SpecificTypeString, }; SpecificTypes m_type; double m_double; HeapVector<DoubleOrString> m_doubleOrStringSequence; String m_string; friend CORE_EXPORT v8::Local<v8::Value> ToV8(const DoubleOrStringOrDoubleOrStringSequence&, v8::Local<v8::Object>, v8::Isolate*); }; class V8DoubleOrStringOrDoubleOrStringSequence final { public: CORE_EXPORT static void toImpl(v8::Isolate*, v8::Local<v8::Value>, DoubleOrStringOrDoubleOrStringSequence&, UnionTypeConversionMode, ExceptionState&); }; CORE_EXPORT v8::Local<v8::Value> ToV8(const DoubleOrStringOrDoubleOrStringSequence&, v8::Local<v8::Object>, v8::Isolate*); template <class CallbackInfo> inline void V8SetReturnValue(const CallbackInfo& callbackInfo, DoubleOrStringOrDoubleOrStringSequence& impl) { V8SetReturnValue(callbackInfo, ToV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate())); } template <class CallbackInfo> inline void V8SetReturnValue(const CallbackInfo& callbackInfo, DoubleOrStringOrDoubleOrStringSequence& impl, v8::Local<v8::Object> creationContext) { V8SetReturnValue(callbackInfo, ToV8(impl, creationContext, callbackInfo.GetIsolate())); } template <> struct NativeValueTraits<DoubleOrStringOrDoubleOrStringSequence> : public NativeValueTraitsBase<DoubleOrStringOrDoubleOrStringSequence> { CORE_EXPORT static DoubleOrStringOrDoubleOrStringSequence NativeValue(v8::Isolate*, v8::Local<v8::Value>, ExceptionState&); }; template <> struct V8TypeOf<DoubleOrStringOrDoubleOrStringSequence> { typedef V8DoubleOrStringOrDoubleOrStringSequence Type; }; } // namespace blink // We need to set canInitializeWithMemset=true because HeapVector supports // items that can initialize with memset or have a vtable. It is safe to // set canInitializeWithMemset=true for a union type object in practice. // See https://codereview.chromium.org/1118993002/#msg5 for more details. WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::DoubleOrStringOrDoubleOrStringSequence); #endif // DoubleOrStringOrDoubleOrStringSequence_h
39.846154
152
0.812017
5d82400c53f12ab675cc764bd3d0c9e6a174787f
1,251
h
C
models/SmaccmPhaseIII/include/sequence_numbered_accelerometer_sample_types.h
drwhomphd/formal-methods-workbench
4a530f3e39e5617311cba905f1425b71b52793b9
[ "BSD-3-Clause" ]
27
2015-01-12T19:08:40.000Z
2021-11-10T08:17:31.000Z
models/SmaccmPhaseIII/include/sequence_numbered_accelerometer_sample_types.h
drwhomphd/formal-methods-workbench
4a530f3e39e5617311cba905f1425b71b52793b9
[ "BSD-3-Clause" ]
99
2015-01-06T19:05:31.000Z
2018-12-11T14:24:34.000Z
models/SmaccmPhaseIII/include/sequence_numbered_accelerometer_sample_types.h
drwhomphd/formal-methods-workbench
4a530f3e39e5617311cba905f1425b71b52793b9
[ "BSD-3-Clause" ]
27
2015-02-24T06:22:50.000Z
2021-09-23T08:50:52.000Z
/* This file has been autogenerated by Ivory * Compiler version 0.1.0.2 */ #ifndef __SEQUENCE_NUMBERED_ACCELEROMETER_SAMPLE_TYPES_H__ #define __SEQUENCE_NUMBERED_ACCELEROMETER_SAMPLE_TYPES_H__ #ifdef __cplusplus extern "C" { #endif #include "accelerometer_sample_types.h" #include "ivory.h" #include "ivory_serialize.h" #include "sequence_num_types.h" typedef struct sequence_numbered_accelerometer_sample { uint32_t seqnum; struct accelerometer_sample val; } sequence_numbered_accelerometer_sample; void sequence_numbered_accelerometer_sample_get_le (const uint8_t * n_var0, uint32_t n_var1, struct sequence_numbered_accelerometer_sample * n_var2); void sequence_numbered_accelerometer_sample_get_be (const uint8_t * n_var0, uint32_t n_var1, struct sequence_numbered_accelerometer_sample * n_var2); void sequence_numbered_accelerometer_sample_set_le (uint8_t * n_var0, uint32_t n_var1, const struct sequence_numbered_accelerometer_sample * n_var2); void sequence_numbered_accelerometer_sample_set_be (uint8_t * n_var0, uint32_t n_var1, const struct sequence_numbered_accelerometer_sample * n_var2); #ifdef __cplusplus } #endif #endif /* __SEQUENCE_NUMBERED_ACCELEROMETER_SAMPLE_TYPES_H__ */
52.125
149
0.816946
8e071e7279108f9f49d8f50cb197e925753440ce
867
c
C
src/mx_get_minmaj.c
agrabchak/ULS
7a0b9890ec852691d4fc0ad41e426eee02beaf3d
[ "MIT" ]
null
null
null
src/mx_get_minmaj.c
agrabchak/ULS
7a0b9890ec852691d4fc0ad41e426eee02beaf3d
[ "MIT" ]
null
null
null
src/mx_get_minmaj.c
agrabchak/ULS
7a0b9890ec852691d4fc0ad41e426eee02beaf3d
[ "MIT" ]
null
null
null
#include "uls.h" static void hex(int number, t_const *cnst, int flag) { char *hexstr = mx_nbr_to_hex((unsigned long)number); char *result = mx_strnew(10); cnst->strmaj = NULL; cnst->strmin = NULL; *result = '0'; result[1] = 'x'; for (int i = 0; i != (8 - mx_strlen(hexstr)); i++) { result[i + 2] = '0'; } mx_strcat(result, hexstr); if (flag) { cnst->strmin = result; } else { cnst->strmaj = result; } free(hexstr); } void mx_get_minmaj(t_const *cnst) { cnst->min = MX_MINOR(cnst->rdev); cnst->maj = MX_MAJOR(cnst->rdev); if (cnst->min > 255) { hex(cnst->min, cnst, 1); } else { cnst->strmin = mx_itoa(cnst->min); } if (cnst->maj > 255) { hex(cnst->maj, cnst, 0); } else { cnst->strmaj = mx_itoa(cnst->maj); } }
21.146341
56
0.516724
05b602cdf66b6210fcf42efb70f3303e0ea294cf
3,055
h
C
inc/signalwire-client-c/blade/disconnect.h
space88man/signalwire-c
004126b9d950164c2db5a2268d454d39f67ed062
[ "MIT" ]
9
2019-01-08T02:42:43.000Z
2021-12-15T12:31:54.000Z
inc/signalwire-client-c/blade/disconnect.h
space88man/signalwire-c
004126b9d950164c2db5a2268d454d39f67ed062
[ "MIT" ]
31
2018-12-26T22:06:01.000Z
2022-01-25T23:30:47.000Z
inc/signalwire-client-c/blade/disconnect.h
space88man/signalwire-c
004126b9d950164c2db5a2268d454d39f67ed062
[ "MIT" ]
14
2019-02-12T07:43:00.000Z
2022-03-18T12:18:43.000Z
/* * Copyright (c) 2018 SignalWire, Inc * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #pragma once /* The method name for a disconnect request */ static const char *BLADE_DISCONNECT_METHOD = "blade.disconnect"; /* Flags for the command, in our case we don't get replies */ #define BLADE_DISCONNECT_FLAGS SWCLT_CMD_FLAG_NOREPLY /* Default time to live for disconnect */ #define BLADE_DISCONNECT_TTL_MS BLADE_DEFAULT_CMD_TTL_MS /* Create our disconnect request template */ typedef struct blade_disconnect_rqu_s { int unused; } blade_disconnect_rqu_t; SWCLT_JSON_MARSHAL_BEG(BLADE_DISCONNECT_RQU, blade_disconnect_rqu_t) SWCLT_JSON_MARSHAL_END() SWCLT_JSON_DESTROY_BEG(BLADE_DISCONNECT_RQU, blade_disconnect_rqu_t) SWCLT_JSON_DESTROY_END() SWCLT_JSON_PARSE_BEG(BLADE_DISCONNECT_RQU, blade_disconnect_rqu_t) SWCLT_JSON_PARSE_END() /** * CREATE_BLADE_DISCONNECT_CMD_ASYNC - Creates a command with a request * in it setup to submit a disconnect method to blade. */ static inline swclt_cmd_t CREATE_BLADE_DISCONNECT_CMD_ASYNC( swclt_cmd_cb_t cb, void *cb_data) { ks_json_t *obj = NULL; blade_disconnect_rqu_t disconnect_rqu; swclt_cmd_t cmd = KS_NULL_HANDLE; ks_pool_t *pool; if (ks_pool_open(&pool)) return cmd; /* Fill in the disconnect request then marshal it, it will create copies * of all the fields so caller doesn't lose ownership here */ if (!(obj = BLADE_DISCONNECT_RQU_MARSHAL(pool, &disconnect_rqu))) { ks_pool_close(&pool); /* Since params is last, on error here we can be sure params was * not freed so do not set the callers params to NULL */ return cmd; } /* Now give it to the new command */ if (swclt_cmd_create_ex( &cmd, &pool, cb, cb_data, BLADE_DISCONNECT_METHOD, &obj, BLADE_DISCONNECT_TTL_MS, BLADE_DISCONNECT_FLAGS, ks_uuid_null())) goto done; done: ks_json_delete(&obj); ks_pool_close(&pool); return cmd; } static inline swclt_cmd_t CREATE_BLADE_DISCONNECT_CMD() { return CREATE_BLADE_DISCONNECT_CMD_ASYNC( NULL, NULL); }
30.858586
81
0.768249
9594720d1daf10a2a256b52cd651e5bb01799ab8
17,163
c
C
hw2/main.c
madhukararora/CSCI-5229-Computer-Graphics
2451bb1dec56d7a5fe8a9ba5e5b4392bb539e486
[ "MIT" ]
null
null
null
hw2/main.c
madhukararora/CSCI-5229-Computer-Graphics
2451bb1dec56d7a5fe8a9ba5e5b4392bb539e486
[ "MIT" ]
null
null
null
hw2/main.c
madhukararora/CSCI-5229-Computer-Graphics
2451bb1dec56d7a5fe8a9ba5e5b4392bb539e486
[ "MIT" ]
null
null
null
/* CSCI 5229 Computer Graphics * University of Colorado Boulder * @author : Madhukar Arora * HW2 */ /* Disclaimer : Most of the code is not my own work but referred from the example codes provided by the instructor in the class. https://thepentamollisproject.blogspot.com/2018/02/setting-up-first-person-camera-in.html https://github.com/davidwparker/opengl-screencasts-1/blob/master/010.c Used example 8 and example 9 from the lectures. */ /* Includes */ #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <math.h> #include <stdbool.h> #ifdef USEGLEW #include <GL/glew.h> #endif // OpenGL with prototypes for glext #define GL_GLEXT_PROTOTYPES #ifdef __APPLE__ #include <GLUT/glut.h> #else #include <GL/glut.h> #endif // Default resolution // For Retina displays compile with -DRES=2 #ifndef RES #define RES 1 #endif //Globals int th=0; // Azimuth of view angle int ph=0; // Elevation of view angle double zh=0; // aeroplane flying int axes=0; // Display axes double dim = 5.0; /*dimension of orthogonal box*/ const char* text[] = {"Orthogonal","Perspective","First Person"}; int fov = 50; // field of view for perspective /* aspect ratio*/ double asp = 1; /* parameters for first person view*/ double fpX = -1.4; double fpZ = 4.8; int fpTh = 280; int fpPh = 20; // Cosine and Sine in degrees #define Cos(x) (cos((x)*3.1415927/180)) #define Sin(x) (sin((x)*3.1415927/180)) typedef enum{ ORTHOGONAL = 0, PERSPECTIVE, FIRSTPERSON, }MODE_T; MODE_T mode = ORTHOGONAL; #define LEN 8192 // Maximum amount of text /* function for text */ void Print(const char* format , ...) //DO NOT MODIFY { char buf[LEN]; // Text storage char* ch=buf; // Text pointer // Create text to be display va_list args; va_start(args,format); vsnprintf(buf,LEN,format,args); va_end(args); // Display text string while (*ch) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,*ch++); } /* prints message to stderr and exit */ void Fatal(const char* format, ...) //DO NOT MODIFY { va_list args; va_start(args,format); vfprintf(stderr,format,args); va_end(args); exit(1); } /* function to print any errors encountered */ void ErrCheck(char* where) //DO NOT MODIFY { int err = glGetError(); if(err) { fprintf(stderr,"ERROR: %s [%s]\n",gluErrorString(err),where); } } /* convenience function to draw the X-Y-Z axes*/ void drawXYZ(void) { glPointSize(10); glColor3f(1.0,1.0,1.0); //color - white glBegin(GL_LINES); glVertex3d(0,0,0); glVertex3d(1,0,0); //X-axis glVertex3d(0,0,0); glVertex3d(0,1,0); //Y-axis glVertex3d(0,0,0); glVertex3d(0,0,1); //Z-axis glEnd(); //Label Axes glRasterPos3d(1,0,0); Print("X"); glRasterPos3d(0,1,0); Print("Y"); glRasterPos3d(0,0,1); Print("Z"); /* update display */ glutPostRedisplay(); } /* * Draw a cube * at (x,y,z) * dimensions (dx,dy,dz) * rotated th about the y axis */ static void cube(double x,double y,double z, double dx,double dy,double dz, double th) { // Save transformation glPushMatrix(); // Offset glTranslated(x,y,z); glRotated(th,0,1,0); glScaled(dx,dy,dz); // Cube glBegin(GL_QUADS); // Front glColor3ub(204,204,0); glVertex3f(-1,-1, 1); glVertex3f(+1,-1, 1); glVertex3f(+1,+1, 1); glVertex3f(-1,+1, 1); // Back glColor3ub(204,204,0); glVertex3f(+1,-1,-1); glVertex3f(-1,-1,-1); glVertex3f(-1,+1,-1); glVertex3f(+1,+1,-1); // Right glColor3ub(204,204,0); glVertex3f(+1,-1,+1); glVertex3f(+1,-1,-1); glVertex3f(+1,+1,-1); glVertex3f(+1,+1,+1); // Left glColor3ub(204,204,0); glVertex3f(-1,-1,-1); glVertex3f(-1,-1,+1); glVertex3f(-1,+1,+1); glVertex3f(-1,+1,-1); // Top glColor3f(0,1,1); glVertex3f(-1,+1,+1); glVertex3f(+1,+1,+1); glVertex3f(+1,+1,-1); glVertex3f(-1,+1,-1); // Bottom glColor3f(1,0,1); glVertex3f(-1,-1,-1); glVertex3f(+1,-1,-1); glVertex3f(+1,-1,+1); glVertex3f(-1,-1,+1); // End glEnd(); // Undo transformations glPopMatrix(); } static void drawRoof(double x, double y, double z, double dx, double dy, double dz, double th) { // Save transformation glPushMatrix(); // Offset, scale glTranslated(x,y,z); glRotated(th,0,1,0); glScaled(dx,dy,dz); //front side glBegin(GL_TRIANGLES); glColor3ub(188,143,143); glVertex3f(+1.5,0,1.5); glVertex3f(-1.5,0,1.5); //symmetric about the x-axis glVertex3f(0,+2, 0); glEnd(); //back side glBegin(GL_TRIANGLES); glColor3ub(188,143,143); glVertex3f(-1.5,0,-1.5); glVertex3f(+1.5,0,-1.5); //symmetric about the x-axis glVertex3f(0,+2, 0); glEnd(); //left side glBegin(GL_TRIANGLES); glColor3ub(188,143,143); glVertex3f(-1.5,0,+1.5); glVertex3f(-1.5,0,-1.5); //symmetric about the z-axis glVertex3f(0,+2, 0); glEnd(); //right side glBegin(GL_TRIANGLES); glColor3ub(188,143,143); glVertex3f(+1.5,0,+1.5); glVertex3f(+1.5,0,-1.5); //symmetric about the z-axis glVertex3f(0,+2, 0); glEnd(); // Undo transformations glPopMatrix(); } static void house(double x,double y, double z, double width, double height, double length, double th) { cube(x,y,z,width,height,length,th); drawRoof(x,y+height,z,width,height/2,length+0.1,th); } /* function to draw a cylinder https://www.youtube.com/watch?v=Kujd0RTsaAQ */ static void cylinder(double x, double y, double z, double radius, double height) { const int delta_Deg = 5; // Save transformation glPushMatrix(); // Offset, scale glTranslated(x,y,z); glRotated(th,0,1,0); glScaled(radius,height,radius); /*sides*/ glBegin(GL_QUAD_STRIP); for(int j = 0; j <= 360; j+= delta_Deg) { glColor3ub(165,42,42); //brown glVertex3f(Cos(j),+1,Sin(j)); glVertex3f(Cos(j),-1,Sin(j)); } glEnd(); /* top and bottom circles */ /* reuse the texture on top and bottom */ for(int i = 1; i>= -1; i-=2) { glBegin(GL_TRIANGLE_FAN); glColor3ub(165,42,42); //brown glVertex3f(0,i,0); for(int k = 0; k <= 360; k+= delta_Deg){ glColor3ub(165,42,42); //brown glVertex3f(i*Cos(k),i,Sin(k)); } glEnd(); } // Undo transformations glPopMatrix(); } /* * function to generate a cone https://www.youtube.com/watch?v=Kujd0RTsaAQ */ static void cone(double x, double y, double z, double height, double radius) { const int deg = 5; int k; glPushMatrix(); /* Transformation */ glTranslated(x,y,z); glScaled(radius,height,radius); glRotated(-90,1,0,0); /* sides */ glBegin(GL_TRIANGLES); for (k=0;k<=360;k+=deg){ glColor3f(0.2,1.0,0.0); glVertex3f(0,0,1); glColor3f(0.2,1.0,0.0); glVertex3f(Cos(k),Sin(k),0); glColor3f(0.2,1.0,0.0); glVertex3f(Cos(k+deg),Sin(k+deg),0); } glEnd(); /* bottom circle */ /* rotate back */ glRotated(90,1,0,0); glBegin(GL_TRIANGLES); glColor3f(0.3,1.0,0.0); for (k=0;k<=360;k+=deg) { glVertex3f(0,0,0); glVertex3f(Cos(k),0,Sin(k)); glVertex3f(Cos(k+deg),0,Sin(k+deg)); } glEnd(); glPopMatrix(); } static void tree(double x, double y, double z, double radius, double height) { cylinder(x,y,z,radius/5,height); cone(x,y+height,z,radius,height); } /* * Draw solid airplane * at (x,y,z) * nose towards (dx,dy,dz) * up towards (ux,uy,uz) */ static void SolidPlane(double x,double y,double z, double dx,double dy,double dz, double ux,double uy, double uz) { // Dimensions used to size airplane const double wid=0.05; const double nose=+0.50; const double cone= 0.20; const double wing= 0.00; const double strk=-0.20; const double tail=-0.50; // Unit vector in direction of flght double D0 = sqrt(dx*dx+dy*dy+dz*dz); double X0 = dx/D0; double Y0 = dy/D0; double Z0 = dz/D0; // Unit vector in "up" direction double D1 = sqrt(ux*ux+uy*uy+uz*uz); double X1 = ux/D1; double Y1 = uy/D1; double Z1 = uz/D1; // Cross product gives the third vector double X2 = Y0*Z1-Y1*Z0; double Y2 = Z0*X1-Z1*X0; double Z2 = X0*Y1-X1*Y0; // Rotation matrix double mat[16]; mat[0] = X0; mat[4] = X1; mat[ 8] = X2; mat[12] = 0; mat[1] = Y0; mat[5] = Y1; mat[ 9] = Y2; mat[13] = 0; mat[2] = Z0; mat[6] = Z1; mat[10] = Z2; mat[14] = 0; mat[3] = 0; mat[7] = 0; mat[11] = 0; mat[15] = 1; // Save current transforms glPushMatrix(); // Offset, scale and rotate glTranslated(x,y,z); glMultMatrixd(mat); // Nose glColor3f(0,0,1); glBegin(GL_TRIANGLE_FAN); glVertex3d(nose, 0.0, 0.0); for (int th=0;th<=360;th+=30) glVertex3d(cone,wid*Cos(th),wid*Sin(th)); glEnd(); // Fuselage glBegin(GL_QUAD_STRIP); for (int th=0;th<=360;th+=30) { glVertex3d(cone,wid*Cos(th),wid*Sin(th)); glVertex3d(tail,wid*Cos(th),wid*Sin(th)); } glEnd(); // Tailpipe glBegin(GL_TRIANGLE_FAN); glVertex3d(tail, 0.0, 0.0); for (int th=0;th<=360;th+=30) glVertex3d(tail,wid*Cos(th),wid*Sin(th)); glEnd(); // Wings glColor3f(1,1,0); glBegin(GL_TRIANGLES); glVertex3d(wing, 0.0, wid); glVertex3d(tail, 0.0, wid); glVertex3d(tail, 0.0, 0.5); glVertex3d(wing, 0.0,-wid); glVertex3d(tail, 0.0,-wid); glVertex3d(tail, 0.0,-0.5); glEnd(); // Vertical tail glColor3f(1,0,0); glBegin(GL_TRIANGLES); glVertex3d(strk, 0.0, 0.0); glVertex3d(tail, 0.3, 0.0); glVertex3d(tail, 0.0, 0.0); glEnd(); // Undo transformations glPopMatrix(); } void airplane() { SolidPlane(1.5*Cos(zh),1.5,0.25*Sin(zh), -Sin(zh),0,Cos(zh), -0.30*Cos(zh),1,-0.45*Sin(zh)); } void renderScene(void) { double dist = 0.5; house(0,0,0,0.3,0.5,0.5,0); tree(dist, 0, dist, 0.1, 0.1); house(-dist*3, 0, -dist*4, 0.2, 1, 0.3, 45); tree(dist*1.5, 0, -dist, 0.1, 0.4); house(dist*4, 0, 0, 0.5, 0.4, 0.6, 30); tree(-dist*2, 0, dist*2, 0.2, 0.6); house(dist*1.5, 0, -dist*4, 0.2, 1, 0.3, 20); tree(dist, 0, -dist*2, 0.2, 0.5); house(-dist*4, 0, dist*2, 0.3, 0.7, 0.4, 80); tree(dist*2, 0, -dist, 0.1, 0.2); } void projection(void) { // inform OpenGL we want to manipulate the projection matrix glMatrixMode(GL_PROJECTION); //reset transformation - clears changes made earlier glLoadIdentity(); if(mode == PERSPECTIVE) { gluPerspective(fov,asp,dim/8,8*dim); } else { glOrtho(-asp*dim,+asp*dim,-dim,+dim,-dim,+dim); } glMatrixMode(GL_MODELVIEW); //reset transformation glLoadIdentity(); } /* function called by GLUT to display the scene */ void display(void) { double Ex, Ey, Ez; /* clear screen and Z-Buffer*/ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* reset transformation - clears changes made earlier */ glLoadIdentity(); /* draw the axis */ if(axes){ drawXYZ(); } switch(mode) { case ORTHOGONAL: glRotatef(ph,1,0,0); glRotatef(th,0,1,0); // Display parameters glColor3f(1.0,1.0,1.0); glWindowPos2i(5,5); Print("Angle= x: %d,y :%d Projection=%s",th,ph,text[mode]); break; case PERSPECTIVE: Ex = -2*dim*Sin(th)*Cos(ph); Ey = +2*dim*Sin(ph); Ez = +2*dim*Cos(th)*Cos(ph); /* camera/eye position*/ gluLookAt(Ex,Ey,Ez,0,0,0,0,Cos(ph),0); glColor3f(1.0,1.0,1.0); glWindowPos2i(5,5); Print("Angle= x: %d,y :%d Dim:%.1f FOV = %d Projection=%s",th,ph,dim,fov,text[mode]); break; case FIRSTPERSON: // imitate first person movement gluLookAt(fpX,-1.4,fpZ,Cos(fpTh)+fpX,Sin(fpPh)-1.4,Sin(fpTh)+fpZ, 0,1,0); glColor3f(1.0,1.0,1.0); glWindowPos2i(5,5); Print("Angle=%d,%d Position=%.1f,%.1f Projection=%s",fpTh,fpPh,fpX,fpZ,"First Person"); break; default: break; } glPushMatrix(); airplane(); renderScene(); glPopMatrix(); /* Sanity check */ ErrCheck("display"); /* make scene visible */ glFlush(); /* swap double buffer */ glutSwapBuffers(); } /* function called by GLUT when special keys are pressed*/ void special(int key,int x, int y) { if(mode != FIRSTPERSON){ switch(key) { case GLUT_KEY_RIGHT: th = (th + 5) % 360; break; case GLUT_KEY_LEFT: th = (th - 5) % 360; break; case GLUT_KEY_UP: ph = (ph + 5) % 360; break; case GLUT_KEY_DOWN: ph = (ph - 5) % 360; break; } } else { switch(key) { case GLUT_KEY_RIGHT: fpTh = (th + 5) % 360; break; case GLUT_KEY_LEFT: fpTh = (th - 5) % 360; break; case GLUT_KEY_UP: fpPh = (ph + 5); break; case GLUT_KEY_DOWN: fpPh = (ph - 5); break; if(fpPh > 90) fpPh = 90; if(fpPh < -90) fpPh = -90; } } projection(); /* update the display */ glutPostRedisplay(); } void key(unsigned char ch,int x, int y) { // Exit on ESC if (ch == 27) { exit(0); } else if (ch == 'm' || ch == 'M') { mode += 1; mode %= 3; } if (mode != 2) //mode not first person { // Reset view angle if (ch == '0') { th = ph = 0; } // Change field of view angle else if (ch == '-' && ch>1) { fov--; } else if (ch == '+' && ch<179) { fov++; } else if(ch == 'a' || ch == 'A') { axes = 1 - axes; } } else //first person { if (ch == '0') { fpX = -1.4; fpZ = 4.8; fpTh = 180; fpPh = 20; } else if (ch == 'w') { fpX += 0.2*Cos(fpTh); fpZ += 0.2*Sin(fpTh); } else if (ch == 's') { fpX -= 0.2*Cos(fpTh); fpZ -= 0.2*Sin(fpTh); } else if (ch == 'd') { fpZ += 0.1*Cos(fpTh); fpX += -0.1*Sin(fpTh); } else if (ch == 'a') { fpZ -= 0.1*Cos(fpTh); fpX -= -0.1*Sin(fpTh); } // Change field of view angle else if (ch == '-' && ch>1) { dim -= 0.1; } else if (ch == '+' && ch<179) { dim += 0.1; } } projection(); /* update the display */ glutPostRedisplay(); } /* function called by GLUT when window is resized */ void reshape(int width,int height) //DO NOT MODIFY { // Set viewport as entire window glViewport(0,0, RES*width,RES*height); // Select projection matrix glMatrixMode(GL_PROJECTION); // Set projection to identity glLoadIdentity(); // Orthogonal projection: unit cube adjusted for aspect ratio const double dim = 2.5; double asp = (height>0) ? (double)width/height : 1; glOrtho(-asp*dim,+asp*dim, -dim,+dim, -dim,+dim); // Select model view matrix glMatrixMode(GL_MODELVIEW); // Set model view to identity glLoadIdentity(); } /* function called by GLUT when idle */ void idle(void) //DO NOT MODIFY { /* get elapsed time in seconds */ double t = glutGet(GLUT_ELAPSED_TIME)/1000.0; /* spin angle - 90 degrees/second */ zh = fmod(90*t,360); /* update display */ glutPostRedisplay(); } int main(int argc,char* argv[]) { /* initialize OpenGL Utility Tool */ glutInit(&argc,argv); /* Request double bufferred true color window */ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); //GLUT_DEPTH adds z-buffer /* Request 940 x 640 pixel window */ glutInitWindowSize(940,640); /* Create Window */ glutCreateWindow("Madhukar's Scene Creation"); #ifdef USEGLEW // Initialize GLEW if (glewInit()!=GLEW_OK) Fatal("Error initializing GLEW\n"); #endif /* Register function used to display scene window resizing idle function handle Special key presses handle keyboard key presses */ glutDisplayFunc(display); glutReshapeFunc(reshape); glutIdleFunc(idle); glutSpecialFunc(special); glutKeyboardFunc(key); /* enable z-buffer depth test */ glEnable(GL_DEPTH_TEST); /* pass control for GLUT for events */ glutMainLoop(); /* return to OS */ return 0; }
22.612648
102
0.553924
9f74e2e41cbca4d468fad9910f9d3a057d703f58
2,456
h
C
software/src/Light.h
realrolfje/dreammachine
4e05ec9fe8af8922a450b599faf70ded165f7396
[ "MIT" ]
null
null
null
software/src/Light.h
realrolfje/dreammachine
4e05ec9fe8af8922a450b599faf70ded165f7396
[ "MIT" ]
null
null
null
software/src/Light.h
realrolfje/dreammachine
4e05ec9fe8af8922a450b599faf70ded165f7396
[ "MIT" ]
null
null
null
#ifndef LIGHT_H #define LIGHT_H #include <Arduino.h> #include <Adafruit_NeoPixel.h> #define NEOPIXEL_PIN 8 #define NUM_LEDS 60 #define NUM_LED_ROWS 6 #define NUM_LEDS_PER_ROW NUM_LEDS/NUM_LED_ROWS #define SUNRISE_STEPS 255 const static uint32_t Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { return ((uint32_t)w << 24) | ((uint32_t)r << 16) | ((uint32_t)g << 8) | b; } class Light { public: Light(); void setup(); void showSkyAt(byte time); void off(); void fullWhite(); void test(); private: void chase(uint32_t c); uint32_t getcolor(byte index); // ------------------ Migrated from Arduino playground to get interpolation // working static const byte sourceXArraySize = 3; static const byte targetXArraySize = NUM_LEDS_PER_ROW; static const byte targetXStepSize = targetXArraySize / (sourceXArraySize - 1); static const byte sourceYArraySize = 7; static const byte targetYArraySize = SUNRISE_STEPS; static const byte targetYStepSize = targetYArraySize / (sourceYArraySize - 1); Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, NEOPIXEL_PIN, NEO_GRBW + NEO_KHZ800); /* * Colors of the sunrise. * In this case the horizontal rows are the "x axis" and represent a complete * set of colors for the led strip. The vertical list is the "y axis" and * represents time. * * The first row is the "sun down" color set, * the last row is the "sun up" color set. */ const uint32_t fyx[ sourceYArraySize][sourceXArraySize] = { // Bottom Middle Top {Color( 0, 0, 0, 0), Color( 0, 0, 0, 0), Color( 0, 0, 0, 0)}, // t = 0 {Color( 12, 2, 1, 0), Color( 2, 0, 1, 0), Color( 0, 0, 0, 0)}, // t = 1 {Color (50, 20, 10, 0), Color( 40, 9, 2, 0), Color( 5, 10, 20, 0)}, // t = 2 {Color(130, 89, 30, 0), Color(100, 50, 10, 0), Color( 36, 33, 50, 0)}, // t = 3 {Color(200,185, 70, 0), Color(180,120, 40, 0), Color(103, 99, 80, 0)}, // t = 4 {Color(242,255,100, 50), Color(240,230,110, 50), Color(242,255,100, 50)}, // t = 5 {Color(242,255,100,255), Color(242,255,150,255), Color(242,255,100,255)}, // t = 6 }; uint32_t getInterpolatedColorAt(byte x, byte y); byte getDecimatedIndex(byte arraysize, byte targetsize, byte i); byte interpolate(int x1, int z1, int x2, int z2, byte x); uint32_t interpolate(int x1, uint32_t z1, int x2, uint32_t z2, byte x); }; #endif // LIGHT_H
34.111111
86
0.637215
b5e945055a5dd326e5be16e7b89929094450bb48
1,234
c
C
ft_strjoin.c
leonrudowicz/42libft
a53e07ad6da9be5b8e0e9df249677a6f9d4e7381
[ "WTFPL" ]
null
null
null
ft_strjoin.c
leonrudowicz/42libft
a53e07ad6da9be5b8e0e9df249677a6f9d4e7381
[ "WTFPL" ]
null
null
null
ft_strjoin.c
leonrudowicz/42libft
a53e07ad6da9be5b8e0e9df249677a6f9d4e7381
[ "WTFPL" ]
null
null
null
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strjoin.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lrudowic <lrudowic@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/05/01 13:39:30 by lrudowic #+# #+# */ /* Updated: 2019/05/20 16:41:15 by lrudowic ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" char *ft_strjoin(char const *s1, char const *s2) { char *str; int c; int i; i = -1; c = -1; if (!s1 || !s2) return (NULL); if (!(str = ft_strnew(ft_strlen(s1) + ft_strlen(s2) + 1))) return (NULL); while (s1[++i]) str[i] = s1[i]; while (s2[++c]) str[i + c] = s2[c]; str[i + c] = '\0'; return (str); }
36.294118
80
0.227715
a769e566a6041c63adf17d96f4a04b5c4333fc5f
1,235
h
C
java/jni/JniEntityHandler.h
jongsunglee/test_iotivity
809ccf01cc31e663e177e0292e17099dc06502bd
[ "Apache-2.0" ]
1,433
2015-04-30T09:26:53.000Z
2022-03-26T12:44:12.000Z
AllJoyn/Samples/OICAdapter/iotivity-1.0.0/android/android_api/base/jni/JniEntityHandler.h
buocnhay/samples-1
ddd614bb5ae595f03811e3dfa15a5d107005d0fc
[ "MIT" ]
530
2015-05-02T09:12:48.000Z
2018-01-03T17:52:01.000Z
AllJoyn/Samples/OICAdapter/iotivity-1.0.0/android/android_api/base/jni/JniEntityHandler.h
buocnhay/samples-1
ddd614bb5ae595f03811e3dfa15a5d107005d0fc
[ "MIT" ]
1,878
2015-04-30T04:18:57.000Z
2022-03-15T16:51:17.000Z
/* * //****************************************************************** * // * // Copyright 2015 Intel Corporation. * // * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= * // * // Licensed under the Apache License, Version 2.0 (the "License"); * // you may not use this file except in compliance with the License. * // You may obtain a copy of the License at * // * // http://www.apache.org/licenses/LICENSE-2.0 * // * // Unless required by applicable law or agreed to in writing, software * // distributed under the License is distributed on an "AS IS" BASIS, * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * // See the License for the specific language governing permissions and * // limitations under the License. * // * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */ #include "JniOcStack.h" #ifndef _Included_org_iotivity_base_JniEntityHandler #define _Included_org_iotivity_base_JniEntityHandler class JniEntityHandler { public: JniEntityHandler(JNIEnv *env, jobject listener); ~JniEntityHandler(); OCEntityHandlerResult handleEntity(const std::shared_ptr<OC::OCResourceRequest> request); private: jobject m_jListener; }; #endif
31.666667
93
0.609717
80b3c93982ad6d7732123a257e5ad13b0f96b67b
244
h
C
src/HangmanGame.h
SizzlingCalamari/hangman_for_rowpieces
d55faff3783dd49ec894395e78238f48b01c14f5
[ "MIT" ]
1
2016-10-31T19:33:02.000Z
2016-10-31T19:33:02.000Z
src/HangmanGame.h
SizzlingCalamari/hangman_for_rowpieces
d55faff3783dd49ec894395e78238f48b01c14f5
[ "MIT" ]
null
null
null
src/HangmanGame.h
SizzlingCalamari/hangman_for_rowpieces
d55faff3783dd49ec894395e78238f48b01c14f5
[ "MIT" ]
1
2016-10-31T05:02:41.000Z
2016-10-31T05:02:41.000Z
#pragma once #include "GuessTracker.h" #include "Word.h" class HangmanGame { public: HangmanGame(size_t numGuesses, std::string secret); int Run(); private: GuessTracker m_guessTracker; Word m_secret; Word m_answer; };
12.842105
55
0.692623
b9045cffd7bdb69fc42a88223e3c50b4399af54d
989
h
C
src/operators/opFunctionDefined.h
athanor/athanor
0e7a654c360be05dc6f6e50427b2ee3df92c1aaf
[ "BSD-3-Clause" ]
4
2018-08-31T09:44:52.000Z
2021-03-01T19:10:00.000Z
src/operators/opFunctionDefined.h
athanor/athanor
0e7a654c360be05dc6f6e50427b2ee3df92c1aaf
[ "BSD-3-Clause" ]
21
2019-12-29T08:33:34.000Z
2020-11-22T16:38:37.000Z
src/operators/opFunctionDefined.h
athanor/athanor
0e7a654c360be05dc6f6e50427b2ee3df92c1aaf
[ "BSD-3-Clause" ]
null
null
null
#ifndef SRC_OPERATORS_OPFUNCTIONDEFINED_H_ #define SRC_OPERATORS_OPFUNCTIONDEFINED_H_ #include "operators/simpleOperator.h" #include "operators/simpleTrigger.h" #include "types/function.h" #include "types/set.h" struct OpFunctionDefined; template <> struct OperatorTrates<OpFunctionDefined> { struct OperandTrigger; }; struct OpFunctionDefined : public SimpleUnaryOperator<SetView, FunctionView, OpFunctionDefined> { using SimpleUnaryOperator<SetView, FunctionView, OpFunctionDefined>::SimpleUnaryOperator; void reevaluateImpl(FunctionView& operandView); void updateVarViolationsImpl(const ViolationContext& vioContext, ViolationContainer& vioContainer) final; void copy(OpFunctionDefined& newOp) const; std::ostream& dumpState(std::ostream& os) const final; std::string getOpName() const final; void debugSanityCheckImpl() const final; }; #endif /* SRC_OPERATORS_OPFUNCTIONDEFINED_H_ */
36.62963
76
0.748231
fe7855add6c946d545718acda060e240c94c73ed
356
h
C
examples/decl_rarray.h
Nukami/Metaresc
b3e8c94f249ee589e61be1dcfa28db9df86a18c8
[ "MIT" ]
72
2015-11-26T15:06:28.000Z
2022-03-31T04:59:22.000Z
examples/decl_rarray.h
Nukami/Metaresc
b3e8c94f249ee589e61be1dcfa28db9df86a18c8
[ "MIT" ]
4
2019-12-11T03:03:18.000Z
2021-06-24T14:02:40.000Z
examples/decl_rarray.h
Nukami/Metaresc
b3e8c94f249ee589e61be1dcfa28db9df86a18c8
[ "MIT" ]
13
2016-05-07T18:43:11.000Z
2022-02-06T08:28:02.000Z
#include <metaresc.h> TYPEDEF_STRUCT (employee_t, (char *, firstname), (char *, lastname), int salary ) TYPEDEF_STRUCT (organization_t, (char *, name), (employee_t *, employees, /* suffix */ , /* meta */ , { "size" }, "string"), VOID (ssize_t, size), )
23.733333
78
0.460674
7004bd29453733af9eabe67497a4cffc225c778a
69
c
C
2022-S1/W1/hola.c
BoomlabsInc/BCSF
5bde1a113ac6fa7bf45dcf9bea9ec32f78b8e129
[ "MIT" ]
2
2020-11-20T18:47:29.000Z
2022-03-19T12:52:44.000Z
2022-S1/W1/hola.c
DLozanoNavas/BCSF_Repo
d2776837c772b29008817cddf7eea241b0813809
[ "MIT" ]
null
null
null
2022-S1/W1/hola.c
DLozanoNavas/BCSF_Repo
d2776837c772b29008817cddf7eea241b0813809
[ "MIT" ]
null
null
null
#include <stdio.h> int main(void){ printf("¡Hola Mundo!\n"); }
9.857143
29
0.57971
6319f4e4908382d71464a1b57faab676de77aead
5,595
h
C
linux-4.14.90-dev/linux-4.14.90/arch/blackfin/include/asm/bfin_dma.h
bingchunjin/1806_SDK
d5ed0258fc22f60e00ec025b802d175f33da6e41
[ "MIT" ]
55
2019-12-20T03:25:14.000Z
2022-01-16T07:19:47.000Z
linux-4.14.90-dev/linux-4.14.90/arch/blackfin/include/asm/bfin_dma.h
bingchunjin/1806_SDK
d5ed0258fc22f60e00ec025b802d175f33da6e41
[ "MIT" ]
5
2020-04-04T09:24:09.000Z
2020-04-19T12:33:55.000Z
linux-4.14.90-dev/linux-4.14.90/arch/blackfin/include/asm/bfin_dma.h
bingchunjin/1806_SDK
d5ed0258fc22f60e00ec025b802d175f33da6e41
[ "MIT" ]
30
2018-05-02T08:43:27.000Z
2022-01-23T03:25:54.000Z
/* * bfin_dma.h - Blackfin DMA defines/structures/etc... * * Copyright 2004-2010 Analog Devices Inc. * * Licensed under the GPL-2 or later. */ #ifndef __ASM_BFIN_DMA_H__ #define __ASM_BFIN_DMA_H__ #include <linux/types.h> /* DMA_CONFIG Masks */ #define DMAEN 0x0001 /* DMA Channel Enable */ #define WNR 0x0002 /* Channel Direction (W/R*) */ #define WDSIZE_8 0x0000 /* Transfer Word Size = 8 */ #define PSIZE_8 0x00000000 /* Transfer Word Size = 16 */ #ifdef CONFIG_BF60x #define PSIZE_16 0x00000010 /* Transfer Word Size = 16 */ #define PSIZE_32 0x00000020 /* Transfer Word Size = 32 */ #define PSIZE_64 0x00000030 /* Transfer Word Size = 32 */ #define WDSIZE_16 0x00000100 /* Transfer Word Size = 16 */ #define WDSIZE_32 0x00000200 /* Transfer Word Size = 32 */ #define WDSIZE_64 0x00000300 /* Transfer Word Size = 32 */ #define WDSIZE_128 0x00000400 /* Transfer Word Size = 32 */ #define WDSIZE_256 0x00000500 /* Transfer Word Size = 32 */ #define DMA2D 0x04000000 /* DMA Mode (2D/1D*) */ #define RESTART 0x00000004 /* DMA Buffer Clear SYNC */ #define DI_EN_X 0x00100000 /* Data Interrupt Enable in X count */ #define DI_EN_Y 0x00200000 /* Data Interrupt Enable in Y count */ #define DI_EN_P 0x00300000 /* Data Interrupt Enable in Peripheral */ #define DI_EN DI_EN_X /* Data Interrupt Enable */ #define NDSIZE_0 0x00000000 /* Next Descriptor Size = 1 */ #define NDSIZE_1 0x00010000 /* Next Descriptor Size = 2 */ #define NDSIZE_2 0x00020000 /* Next Descriptor Size = 3 */ #define NDSIZE_3 0x00030000 /* Next Descriptor Size = 4 */ #define NDSIZE_4 0x00040000 /* Next Descriptor Size = 5 */ #define NDSIZE_5 0x00050000 /* Next Descriptor Size = 6 */ #define NDSIZE_6 0x00060000 /* Next Descriptor Size = 7 */ #define NDSIZE 0x00070000 /* Next Descriptor Size */ #define NDSIZE_OFFSET 16 /* Next Descriptor Size Offset */ #define DMAFLOW_LIST 0x00004000 /* Descriptor List Mode */ #define DMAFLOW_LARGE DMAFLOW_LIST #define DMAFLOW_ARRAY 0x00005000 /* Descriptor Array Mode */ #define DMAFLOW_LIST_DEMAND 0x00006000 /* Descriptor Demand List Mode */ #define DMAFLOW_ARRAY_DEMAND 0x00007000 /* Descriptor Demand Array Mode */ #define DMA_RUN_DFETCH 0x00000100 /* DMA Channel Running Indicator (DFETCH) */ #define DMA_RUN 0x00000200 /* DMA Channel Running Indicator */ #define DMA_RUN_WAIT_TRIG 0x00000300 /* DMA Channel Running Indicator (WAIT TRIG) */ #define DMA_RUN_WAIT_ACK 0x00000400 /* DMA Channel Running Indicator (WAIT ACK) */ #else #define PSIZE_16 0x0000 /* Transfer Word Size = 16 */ #define PSIZE_32 0x0000 /* Transfer Word Size = 32 */ #define WDSIZE_16 0x0004 /* Transfer Word Size = 16 */ #define WDSIZE_32 0x0008 /* Transfer Word Size = 32 */ #define DMA2D 0x0010 /* DMA Mode (2D/1D*) */ #define RESTART 0x0020 /* DMA Buffer Clear */ #define DI_SEL 0x0040 /* Data Interrupt Timing Select */ #define DI_EN 0x0080 /* Data Interrupt Enable */ #define DI_EN_X 0x00C0 /* Data Interrupt Enable in X count*/ #define DI_EN_Y 0x0080 /* Data Interrupt Enable in Y count*/ #define NDSIZE_0 0x0000 /* Next Descriptor Size = 0 (Stop/Autobuffer) */ #define NDSIZE_1 0x0100 /* Next Descriptor Size = 1 */ #define NDSIZE_2 0x0200 /* Next Descriptor Size = 2 */ #define NDSIZE_3 0x0300 /* Next Descriptor Size = 3 */ #define NDSIZE_4 0x0400 /* Next Descriptor Size = 4 */ #define NDSIZE_5 0x0500 /* Next Descriptor Size = 5 */ #define NDSIZE_6 0x0600 /* Next Descriptor Size = 6 */ #define NDSIZE_7 0x0700 /* Next Descriptor Size = 7 */ #define NDSIZE_8 0x0800 /* Next Descriptor Size = 8 */ #define NDSIZE_9 0x0900 /* Next Descriptor Size = 9 */ #define NDSIZE 0x0f00 /* Next Descriptor Size */ #define NDSIZE_OFFSET 8 /* Next Descriptor Size Offset */ #define DMAFLOW_ARRAY 0x4000 /* Descriptor Array Mode */ #define DMAFLOW_SMALL 0x6000 /* Small Model Descriptor List Mode */ #define DMAFLOW_LARGE 0x7000 /* Large Model Descriptor List Mode */ #define DFETCH 0x0004 /* DMA Descriptor Fetch Indicator */ #define DMA_RUN 0x0008 /* DMA Channel Running Indicator */ #endif #define DMAFLOW 0x7000 /* Flow Control */ #define DMAFLOW_STOP 0x0000 /* Stop Mode */ #define DMAFLOW_AUTO 0x1000 /* Autobuffer Mode */ /* DMA_IRQ_STATUS Masks */ #define DMA_DONE 0x0001 /* DMA Completion Interrupt Status */ #define DMA_ERR 0x0002 /* DMA Error Interrupt Status */ #ifdef CONFIG_BF60x #define DMA_PIRQ 0x0004 /* DMA Peripheral Error Interrupt Status */ #else #define DMA_PIRQ 0 #endif /* * All Blackfin system MMRs are padded to 32bits even if the register * itself is only 16bits. So use a helper macro to streamline this. */ #define __BFP(m) u16 m; u16 __pad_##m /* * bfin dma registers layout */ struct bfin_dma_regs { u32 next_desc_ptr; u32 start_addr; #ifdef CONFIG_BF60x u32 cfg; u32 x_count; u32 x_modify; u32 y_count; u32 y_modify; u32 pad1; u32 pad2; u32 curr_desc_ptr; u32 prev_desc_ptr; u32 curr_addr; u32 irq_status; u32 curr_x_count; u32 curr_y_count; u32 pad3; u32 bw_limit_count; u32 curr_bw_limit_count; u32 bw_monitor_count; u32 curr_bw_monitor_count; #else __BFP(config); u32 __pad0; __BFP(x_count); __BFP(x_modify); __BFP(y_count); __BFP(y_modify); u32 curr_desc_ptr; u32 curr_addr; __BFP(irq_status); __BFP(peripheral_map); __BFP(curr_x_count); u32 __pad1; __BFP(curr_y_count); u32 __pad2; #endif }; #ifndef CONFIG_BF60x /* * bfin handshake mdma registers layout */ struct bfin_hmdma_regs { __BFP(control); __BFP(ecinit); __BFP(bcinit); __BFP(ecurgent); __BFP(ecoverflow); __BFP(ecount); __BFP(bcount); }; #endif #undef __BFP #endif
33.704819
84
0.727435
a49eb60a207495d5fb5c6c2c43756d02a464787f
4,233
c
C
xp_comm_proj/extrnode/extrnode.c
avs/express-community
c699a68330d3b678b7e6bcea823e0891b874049c
[ "Apache-2.0" ]
3
2020-08-03T08:52:20.000Z
2021-04-10T11:55:49.000Z
xp_comm_proj/extrnode/extrnode.c
avs/express-community
c699a68330d3b678b7e6bcea823e0891b874049c
[ "Apache-2.0" ]
null
null
null
xp_comm_proj/extrnode/extrnode.c
avs/express-community
c699a68330d3b678b7e6bcea823e0891b874049c
[ "Apache-2.0" ]
1
2021-06-08T18:16:45.000Z
2021-06-08T18:16:45.000Z
#include "gen.h" /*#define DEBUG /**/ int ExtractNodeData(OMobj_id Extract_Node_Data_id, OMevent_mask event_mask, int seq_num) { OMobj_id input_data_id; int input_data_data_type; char *input_data_data; int input_data_veclen; int input_data_ncomp; int input_data_ndata; int node_index_size; float *output_ptr; int output_size; int *node_index; float *output; int offset; int i, j; /*Added by Ma YingLiang 6th August,2001*/ int data_component; /* Get node_index's and offset's value */ node_index = (int *)OMret_name_array_ptr(Extract_Node_Data_id, OMstr_to_name("node_index"), OM_GET_ARRAY_RD, &node_index_size, NULL); if( node_index == NULL ) { fprintf( stderr, "ExtractNodeData: Unable to read node_index array\n" ); return( 0 ); } if (OMget_name_int_val(Extract_Node_Data_id, OMstr_to_name("offset"), &offset) != 1) offset = 0; /* Get field id */ input_data_id = OMfind_subobj(Extract_Node_Data_id, OMstr_to_name("input_data"), OM_OBJ_RD); /*Get data component*/ if (OMget_name_int_val(Extract_Node_Data_id, OMstr_to_name("data_component"), &data_component) != 1) data_component = 0; /* Get number of node data components */ FLDget_node_data_ncomp (input_data_id, &input_data_ncomp); /* Allocate output array */ output_size = input_data_ncomp * node_index_size; output = (float *)ARRalloc(NULL, DTYPE_FLOAT, output_size, NULL); /* For each node data component get veclen, type and data arry itself */ for( i = 0; i < input_data_ncomp; i++ ) { /* Get veclen */ FLDget_node_data_veclen(input_data_id, i, &input_data_veclen); if( input_data_veclen != 1 ) { fprintf( stderr, "Extract_Node_Data: veclen != 1 not supported\n" ); return( 0 ); } /* Get node data */ FLDget_node_data(input_data_id, ((i + offset) % input_data_ncomp), &input_data_data_type, &input_data_data, &input_data_ndata, OM_GET_ARRAY_RD); #ifdef DEBUG fprintf(stderr,"input_data_ndata: %i\n",input_data_ndata); #endif if (input_data_data) { for( j = 0; j < node_index_size; j++ ) { if (node_index[j] >= input_data_ndata) { fprintf(stderr,"Extract_Node_Data: invalid node_index[%i]: %i\n", j, node_index[j]); continue; } output_ptr = output + (j * input_data_ncomp) + i; switch( input_data_data_type ) { case OM_TYPE_BYTE: case OM_TYPE_CHAR: *output_ptr = (float)*(((char *)input_data_data) + node_index[j]); break; case OM_TYPE_SHORT: *output_ptr = (float)*(((short *)input_data_data) + node_index[j]); break; case OM_TYPE_INT: *output_ptr = (float)*(((int *)input_data_data) + node_index[j]); break; case OM_TYPE_FLOAT: *output_ptr = (float)*(((float *)input_data_data) + node_index[j]); break; case OM_TYPE_DOUBLE: *output_ptr = (float)*(((double *)input_data_data) + node_index[j]); break; default: fprintf( stderr, "Extract_Node_Data: Unrecognized data format %d\n", input_data_data_type ); return( 0 ); } } ARRfree((char *)input_data_data); } else { fprintf( stderr, "Extract_Node_Data: Error reading node data for component %d\n", ((i + offset) % input_data_ncomp) ); return( 0 ); } } /* fill in array output */ OMset_name_array(Extract_Node_Data_id, OMstr_to_name("output"), DTYPE_FLOAT, (void *)output, output_size, OM_SET_ARRAY_FREE); /* Free up input array */ if (node_index != NULL) ARRfree((char *)node_index); return(1); }
30.89781
111
0.563903
2b7728f8597a9dfc8a52837ceed54346754c490c
3,810
c
C
modules/rtos/sw_services/usb/msc/msc_flashdisk.c
danielpieczko/xcore_sdk
abb3bdc62d72fa8c13e77f778312ba9f8b29c0f4
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
modules/rtos/sw_services/usb/msc/msc_flashdisk.c
danielpieczko/xcore_sdk
abb3bdc62d72fa8c13e77f778312ba9f8b29c0f4
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
modules/rtos/sw_services/usb/msc/msc_flashdisk.c
danielpieczko/xcore_sdk
abb3bdc62d72fa8c13e77f778312ba9f8b29c0f4
[ "Naumen", "Condor-1.1", "MS-PL" ]
null
null
null
// Copyright 2021 XMOS LIMITED. // This Software is subject to the terms of the XMOS Public Licence: Version 1. #define DEBUG_UNIT MSC_FLASHDISK #include <stdio.h> #include "rtos_osal.h" #include "rtos/drivers/qspi_flash/api/rtos_qspi_flash.h" #include "msc_disk_manager.h" #include "tusb.h" #ifndef QSPI_FLASH_SECTOR_SIZE #define QSPI_FLASH_SECTOR_SIZE 4096 #endif __attribute__((fptrgroup("disk_init_fptr_grp"))) __attribute__((weak)) bool qspi_flash_disk_init(disk_desc_t *disk_ctx) { rtos_printf("flash_disk default init callback\n"); return true; } __attribute__((fptrgroup("disk_ready_fptr_grp"))) __attribute__((weak)) bool qspi_flash_disk_ready(disk_desc_t *disk_ctx) { rtos_printf("flash_disk default ready callback\n"); return true; } __attribute__((fptrgroup("disk_start_stop_fptr_grp"))) __attribute__((weak)) bool qspi_flash_disk_start_stop(disk_desc_t *disk_ctx, uint8_t power_condition, bool start, bool load_eject) { rtos_printf("flash_disk default start_stop callback\n"); return true; } __attribute__((fptrgroup("disk_read_fptr_grp"))) __attribute__((weak)) int32_t qspi_flash_disk_read(disk_desc_t *disk_ctx, uint8_t *buffer, uint32_t lba, uint32_t offset, uint32_t bufsize) { rtos_qspi_flash_t *flash_ctx = (rtos_qspi_flash_t*)disk_ctx->args; rtos_printf("flash_disk default read callback\n"); rtos_qspi_flash_read( flash_ctx, (uint8_t*)buffer, (unsigned)(disk_ctx->starting_addr + (lba * disk_ctx->block_size) + offset), (size_t)bufsize); return bufsize; } __attribute__((fptrgroup("disk_write_fptr_grp"))) __attribute__((weak)) int32_t qspi_flash_disk_write(disk_desc_t *disk_ctx, const uint8_t *buffer, uint32_t lba, uint32_t offset, uint32_t bufsize) { rtos_qspi_flash_t *flash_ctx = (rtos_qspi_flash_t*)disk_ctx->args; rtos_printf("flash_disk default write callback adr: 0x%x, size: %u lba: %u offset: %u\n", disk_ctx->starting_addr + (lba * disk_ctx->block_size), bufsize, lba, offset); xassert(bufsize <= QSPI_FLASH_SECTOR_SIZE); uint8_t *tmp_buf = rtos_osal_malloc( sizeof(uint8_t) * QSPI_FLASH_SECTOR_SIZE); rtos_qspi_flash_lock(flash_ctx); { rtos_qspi_flash_read( flash_ctx, tmp_buf, (unsigned)(disk_ctx->starting_addr + (lba * disk_ctx->block_size)), (size_t)QSPI_FLASH_SECTOR_SIZE); memcpy(tmp_buf + offset, buffer, bufsize); rtos_qspi_flash_erase( flash_ctx, (unsigned)(disk_ctx->starting_addr + (lba * disk_ctx->block_size)), (size_t)QSPI_FLASH_SECTOR_SIZE); rtos_qspi_flash_write( flash_ctx, (uint8_t *) tmp_buf, (unsigned)(disk_ctx->starting_addr + (lba * disk_ctx->block_size)), (size_t)QSPI_FLASH_SECTOR_SIZE); rtos_qspi_flash_unlock(flash_ctx); } rtos_osal_free(tmp_buf); return bufsize; } __attribute__((fptrgroup("disk_scsi_command_fptr_grp"))) __attribute__((weak)) int32_t qspi_flash_disk_scsi_command(disk_desc_t *disk_ctx, uint8_t lun, uint8_t *buffer, const uint8_t *scsi_cmd, uint16_t bufsize) { rtos_printf("flash_disk default scsi command callback %s\n", scsi_cmd); uint16_t resplen = 0; #if (CFG_TUD_MSC == 1) switch (scsi_cmd[0]) { case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL: case SCSI_CMD_START_STOP_UNIT: resplen = 0; break; default: // Set Sense = Invalid Command Operation tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00); // negative means error -> tinyusb could stall and/or response with failed status resplen = -1; break; } #endif /* CFG_TUD_MSC */ return resplen; }
33.421053
172
0.697375
449b1f3c9ed8192bf72169332b27bc749193b1e7
6,222
h
C
Engine/Source/Runtime/ClothingSystemRuntime/Public/Utils/ClothingMeshUtils.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
1
2022-01-29T18:36:12.000Z
2022-01-29T18:36:12.000Z
Engine/Source/Runtime/ClothingSystemRuntime/Public/Utils/ClothingMeshUtils.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
Engine/Source/Runtime/ClothingSystemRuntime/Public/Utils/ClothingMeshUtils.h
windystrife/UnrealEngine_NVIDIAGameWork
b50e6338a7c5b26374d66306ebc7807541ff815e
[ "MIT" ]
null
null
null
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #pragma once #include "SkeletalMeshTypes.h" DECLARE_LOG_CATEGORY_EXTERN(LogClothingMeshUtils, Log, All); namespace ClothingMeshUtils { struct CLOTHINGSYSTEMRUNTIME_API ClothMeshDesc { ClothMeshDesc(TArrayView<const FVector> InPositions, TArrayView<const FVector> InNormals, TArrayView<const uint32> InIndices) : Positions(InPositions) , Normals(InNormals) , Indices(InIndices) {} bool HasValidMesh() const { return Positions.Num() == Normals.Num() && Indices.Num() % 3 == 0; } TArrayView<const FVector> Positions; TArrayView<const FVector> Normals; TArrayView<const uint32> Indices; }; /** * Given mesh information for two meshes, generate a list of skinning data to embed mesh0 in mesh1 * @param OutSkinningData - Final skinning data to map mesh0 to mesh1 * @param TargetMesh - Mesh data for the mesh we are embedding * @param TargetTangents - Optional Tangents for the mesh we are embedding * @param Mesh1Normals - Vertex normals for Mesh1 * @param Mesh1Indices - Triangle indices for Mesh1 */ void CLOTHINGSYSTEMRUNTIME_API GenerateMeshToMeshSkinningData( TArray<FMeshToMeshVertData>& OutSkinningData, const ClothMeshDesc& TargetMesh, const TArray<FVector>* TargetTangents, const ClothMeshDesc& SourceMesh); /** * Embeds a list of positions into a source mesh * @param SourceMesh The mesh to embed in * @param Positions The positions to embed in SourceMesh * @param OutEmbeddedPositions Embedded version of the original positions, a barycentric coordinate and distance along the normal of the triangle * @param OutSourceIndices Source index list for the embedded positions, 3 per position to denote the source triangle */ void CLOTHINGSYSTEMRUNTIME_API GenerateEmbeddedPositions( const ClothMeshDesc& SourceMesh, TArrayView<const FVector> Positions, TArray<FVector4>& OutEmbeddedPositions, TArray<int32>& OutSourceIndices); /** * Given a triangle ABC with normals at each vertex NA, NB and NC, get a barycentric coordinate * and corresponding distance from the triangle encoded in an FVector4 where the components are * (BaryX, BaryY, BaryZ, Dist) * @param A - Position of triangle vertex A * @param B - Position of triangle vertex B * @param C - Position of triangle vertex C * @param NA - Normal at vertex A * @param NB - Normal at vertex B * @param NC - Normal at vertex C * @param Point - Point to calculate Bary+Dist for */ FVector4 GetPointBaryAndDist( const FVector& A, const FVector& B, const FVector& C, const FVector& NA, const FVector& NB, const FVector& NC, const FVector& Point); /** * Object used to map vertex parameters between two meshes using the * same barycentric mesh to mesh mapping data we use for clothing */ class CLOTHINGSYSTEMRUNTIME_API FVertexParameterMapper { public: FVertexParameterMapper() = delete; FVertexParameterMapper(const FVertexParameterMapper& Other) = delete; FVertexParameterMapper(TArrayView<const FVector> InMesh0Positions, TArrayView<const FVector> InMesh0Normals, TArrayView<const FVector> InMesh1Positions, TArrayView<const FVector> InMesh1Normals, TArrayView<const uint32> InMesh1Indices) : Mesh0Positions(InMesh0Positions) , Mesh0Normals(InMesh0Normals) , Mesh1Positions(InMesh1Positions) , Mesh1Normals(InMesh1Normals) , Mesh1Indices(InMesh1Indices) { } /** Generic mapping function, can be used to map any type with a provided callable */ template<typename T, typename Lambda> void Map(TArrayView<const T>& SourceData, TArray<T>& DestData, const Lambda& Func) { // Enforce the interp func signature (returns T and takes a bary and 3 Ts) // If you hit this then either the return type isn't T or your arguments aren't convertible to T static_assert(TAreTypesEqual<T, typename TDecay<decltype(Func(DeclVal<FVector>(), DeclVal<T>(), DeclVal<T>(), DeclVal<T>()))>::Type>::Value, "Invalid Lambda signature passed to Map"); const int32 NumMesh0Positions = Mesh0Positions.Num(); const int32 NumMesh0Normals = Mesh0Normals.Num(); const int32 NumMesh1Positions = Mesh1Positions.Num(); const int32 NumMesh1Normals = Mesh1Normals.Num(); const int32 NumMesh1Indices = Mesh1Indices.Num(); // Validate mesh data check(NumMesh0Positions == NumMesh0Normals); check(NumMesh1Positions == NumMesh1Normals); check(NumMesh1Indices % 3 == 0); check(SourceData.Num() == NumMesh1Positions); if(DestData.Num() != NumMesh0Positions) { DestData.Reset(); DestData.AddUninitialized(NumMesh0Positions); } ClothMeshDesc SourceMeshDesc(Mesh1Positions, Mesh1Normals, Mesh1Indices); TArray<FVector4> EmbeddedPositions; TArray<int32> SourceIndices; ClothingMeshUtils::GenerateEmbeddedPositions(SourceMeshDesc, Mesh0Positions, EmbeddedPositions, SourceIndices); for(int32 DestVertIndex = 0 ; DestVertIndex < NumMesh0Positions ; ++DestVertIndex) { // Truncate the distance from the position data FVector Bary = EmbeddedPositions[DestVertIndex]; const int32 SourceTriBaseIdx = DestVertIndex * 3; T A = SourceData[SourceIndices[SourceTriBaseIdx + 0]]; T B = SourceData[SourceIndices[SourceTriBaseIdx + 1]]; T C = SourceData[SourceIndices[SourceTriBaseIdx + 2]]; T& DestVal = DestData[DestVertIndex]; // If we're super close to a vertex just take it's value. // Otherwise call the provided interp lambda const static FVector OneVec(1.0f, 1.0f, 1.0f); FVector DiffVec = OneVec - Bary; if(FMath::Abs(DiffVec.X) <= SMALL_NUMBER) { DestVal = A; } else if(FMath::Abs(DiffVec.Y) <= SMALL_NUMBER) { DestVal = B; } else if(FMath::Abs(DiffVec.Z) <= SMALL_NUMBER) { DestVal = C; } else { DestData[DestVertIndex] = Func(Bary, A, B, C); } } } // Defined type mappings for brevity void Map(TArrayView<const float> Source, TArray<float>& Dest); private: TArrayView<const FVector> Mesh0Positions; TArrayView<const FVector> Mesh0Normals; TArrayView<const FVector> Mesh1Positions; TArrayView<const FVector> Mesh1Normals; TArrayView<const uint32> Mesh1Indices; }; }
34.566667
186
0.735776
28b4ddd2ba18d3710aa0685cf5f0cb0c56cdf930
1,798
h
C
src/opts.h
Quipyowert2/zzuf
e598eef77a98d77dc6aec6fd2c845e3cd07dc4fd
[ "WTFPL" ]
415
2015-01-05T11:40:17.000Z
2022-03-29T08:50:37.000Z
src/opts.h
Quipyowert2/zzuf
e598eef77a98d77dc6aec6fd2c845e3cd07dc4fd
[ "WTFPL" ]
24
2015-01-05T23:53:40.000Z
2020-12-01T02:09:02.000Z
src/opts.h
Quipyowert2/zzuf
e598eef77a98d77dc6aec6fd2c845e3cd07dc4fd
[ "WTFPL" ]
88
2015-03-16T04:55:25.000Z
2021-11-18T05:04:03.000Z
/* * zzuf - general purpose fuzzer * * Copyright © 2002—2015 Sam Hocevar <sam@hocevar.net> * * This program is free software. It comes without any warranty, to * the extent permitted by applicable law. You can redistribute it * and/or modify it under the terms of the Do What the Fuck You Want * to Public License, Version 2, as published by the WTFPL Task Force. * See http://www.wtfpl.net/ for more details. */ #pragma once /* * opts.h: configuration handling */ #include "util/hex.h" #include "util/md5.h" #ifdef _WIN32 # include <windows.h> #endif typedef struct zzuf_opts zzuf_opts_t; typedef struct zzuf_child zzuf_child_t; zzuf_opts_t *zzuf_create_opts(void); void zzuf_destroy_opts(zzuf_opts_t *); struct zzuf_child { enum status { STATUS_FREE, STATUS_RUNNING, STATUS_SIGTERM, STATUS_SIGKILL, STATUS_EOF, } status; pid_t pid; #ifdef _WIN32 HANDLE process_handle; #endif int fd[3]; /* 0 is debug, 1 is stderr, 2 is stdout */ int bytes, seed; double ratio; int64_t date; zzuf_md5sum_t *md5; zzuf_hexdump_t *hex; char **newargv; }; struct zzuf_opts { enum opmode { OPMODE_PRELOAD, OPMODE_COPY, OPMODE_NULL, } opmode; char **oldargv; int oldargc; char *fuzzing, *bytes, *list, *ports, *protect, *refuse, *allow; uint32_t seed; uint32_t endseed; double minratio; double maxratio; int b_md5; int b_hex; int b_checkexit; int b_verbose; int b_quiet; int maxbytes; int maxcpu; int maxmem; int64_t starttime; int64_t maxtime; int64_t maxusertime; int64_t delay; int64_t lastlaunch; int maxchild, nchild, maxcrashes, crashes; zzuf_child_t *child; };
18.926316
71
0.654616
fa5f6839ed79ff2983461e2c0b9996b43040b2c6
4,106
c
C
src/Events.c
matt-attack/pubsub
fbd804b7b41695462007c889ee7b540a9d04fd16
[ "MIT" ]
1
2021-03-20T03:01:13.000Z
2021-03-20T03:01:13.000Z
src/Events.c
matt-attack/pubsub
fbd804b7b41695462007c889ee7b540a9d04fd16
[ "MIT" ]
13
2019-11-27T04:25:38.000Z
2021-05-23T19:03:42.000Z
src/Events.c
matt-attack/pubsub
fbd804b7b41695462007c889ee7b540a9d04fd16
[ "MIT" ]
null
null
null
#include <pubsub/Events.h> #include <stdbool.h> #ifndef WIN32 #include <unistd.h> #include <sys/epoll.h> #include <sys/eventfd.h> #else #include <WinSock2.h> #endif void ps_event_set_create(struct ps_event_set_t* set) { #ifdef WIN32 set->num_handles = 1; set->handles = (HANDLE*)malloc(sizeof(HANDLE)); set->sockets = (int*)malloc(sizeof(int)); set->handles[0] = WSACreateEvent(); set->sockets[0] = -1; #else set->fd = epoll_create(1); set->num_events = 0; // create the pipe for manual triggers set->event_fd = eventfd(0, 0); struct epoll_event event; event.events = EPOLLIN; epoll_ctl(set->fd, EPOLL_CTL_ADD, set->event_fd, &event); #endif } void ps_event_set_destroy(struct ps_event_set_t* set) { #ifdef WIN32 for (unsigned int i = 0; i < set->num_handles; i++) { WSACloseEvent(set->handles[i]); } free(set->handles); free(set->sockets); #else set->num_events = 0; close(set->event_fd); close(set->fd); #endif } void ps_event_set_add_socket(struct ps_event_set_t* set, int socket) { #ifdef WIN32 // allocate a new spot int cur_size = set->num_handles; HANDLE* new_handles = (HANDLE*)malloc(sizeof(HANDLE)*(cur_size + 1)); int* new_sockets = (int*)malloc(sizeof(int)*(cur_size + 1)); for (int i = 0; i < cur_size; i++) { new_handles[i] = set->handles[i]; new_sockets[i] = set->sockets[i]; } free(set->handles); free(set->sockets); set->handles = new_handles; set->sockets = new_sockets; set->num_handles++; set->handles[cur_size + 0] = WSACreateEvent(); set->sockets[cur_size + 0] = socket; WSAEventSelect(socket, set->handles[cur_size + 0], FD_READ); #else struct epoll_event event; event.events = EPOLLIN; epoll_ctl(set->fd, EPOLL_CTL_ADD, socket, &event); set->num_events++; #endif } void ps_event_set_remove_socket(struct ps_event_set_t* set, int socket) { #ifdef WIN32 // find the socket to remove then remove it bool found = false; int index = 0; for (; index < set->num_handles; index++) { if (set->sockets[index] == socket) { found = true; break; } } if (!found) { printf("ERROR: Could not find socket to remove!"); return; } // remove the one at that index WSACloseEvent(set->handles[index]); int cur_size = set->num_handles; HANDLE* new_handles = (HANDLE*)malloc(sizeof(HANDLE)*(cur_size - 1)); int* new_sockets = (int*)malloc(sizeof(int)*(cur_size - 1)); // copy those before the spot for (int i = 0; i < index; i++) { new_sockets[i] = set->sockets[i]; new_handles[i] = set->handles[i]; } // copy those after the spot for (int i = index + 1; i < cur_size - 1; i++) { new_sockets[i - 1] = set->sockets[i]; new_handles[i - 1] = set->handles[i]; } set->num_handles--; free(set->handles); free(set->sockets); set->handles = new_handles; set->sockets = new_sockets; #else struct epoll_event event; event.events = EPOLLIN; epoll_ctl(set->fd, EPOLL_CTL_DEL, socket, &event); set->num_events++; #endif } void ps_event_set_trigger(struct ps_event_set_t* set) { if (!set) { return; } #ifdef WIN32 WSASetEvent(set->handles[0]); #else uint64_t val = 1; write(set->event_fd, &val, 8); #endif } unsigned int ps_event_set_count(const struct ps_event_set_t* set) { #ifdef WIN32 return set->num_handles-1; #else return set->num_events; #endif } void ps_event_set_wait(struct ps_event_set_t* set, unsigned int timeout_ms) { #ifdef WIN32 DWORD event = WSAWaitForMultipleEvents(set->num_handles, set->handles, false, timeout_ms, false); if (event == WSA_WAIT_TIMEOUT) return; // Reset the signaled event int id = event - WSA_WAIT_EVENT_0; bool bResult = WSAResetEvent(set->handles[id]); if (bResult == false) { printf("WSAResetEvent failed with error = %d\n", WSAGetLastError()); } #else //printf("waiting for %i events\n", set->num_events); struct epoll_event events[10]; int num_ready = epoll_wait(set->fd, events, 10, timeout_ms); //printf("%i ready to read\n", num_ready); if (num_ready < 0) { perror("poll error"); } #endif }
22.315217
99
0.663176
78507721a094e824d8e6d854e37684bf1e2857c6
96
c
C
benchmarks/Angha_small/extr_func_patternCompare/extr_func_patternCompare.c
ComputerSystemsLab/OptimizationCache
9c30ae120673e57b772ea42e29e087f775aa9de9
[ "Apache-2.0" ]
2
2021-03-11T00:46:25.000Z
2021-07-08T16:44:58.000Z
benchmarks/Angha_small/extr_func_patternCompare/extr_func_patternCompare.c
ComputerSystemsLab/OptimizationCache
9c30ae120673e57b772ea42e29e087f775aa9de9
[ "Apache-2.0" ]
null
null
null
benchmarks/Angha_small/extr_func_patternCompare/extr_func_patternCompare.c
ComputerSystemsLab/OptimizationCache
9c30ae120673e57b772ea42e29e087f775aa9de9
[ "Apache-2.0" ]
null
null
null
a, b, c, d; e() { while (f()) { if (d) continue; g(); } return c ? a : b; }
9.6
19
0.333333
a3ab2d69a182c433557e7db90aa15dd7b524b78e
1,640
h
C
software/firmware/arduino/src/PiCommunication/PiCommunication.h
rhotter/ventilator
249f74423a576d5f0de6258a24443c4c226f8d10
[ "MIT" ]
20
2020-04-08T23:08:49.000Z
2020-07-22T11:40:32.000Z
software/firmware/arduino/src/PiCommunication/PiCommunication.h
rhotter/covid19-ventilator
249f74423a576d5f0de6258a24443c4c226f8d10
[ "MIT" ]
32
2020-04-08T03:11:35.000Z
2020-04-30T05:40:40.000Z
software/firmware/arduino/src/PiCommunication/PiCommunication.h
breeze-ventilator/covid19-ventilator
249f74423a576d5f0de6258a24443c4c226f8d10
[ "MIT" ]
2
2020-04-16T10:09:16.000Z
2020-05-09T20:39:09.000Z
#ifndef PI_COMMUNICATION_H #define PI_COMMUNICATION_H #define LITERS_TO_TENTH_OF_A_LITER 10 #include "../Defs/errors.h" #include "../Data/Data.h" #include "../State/State.h" #include "../Defs/errors.h" #include "../Defs/defs.h" #include "../Helpers/helpers.h" #include "../Controller/Controller.h" #include <math.h> #include "../Parameters/Parameters.h" // TODO: remove #define MAX_SERIAL_WAIT_TIME 1000 #define WELCOME_MESSAGE 200 #define CONNECTED_MESSAGE 2 #define WRONG_RESPONSE_MESSAGE 3 #define MESSAGE_LENGTH_FROM_PI 14 class PiCommunication { public: PiCommunication(int baudRate, int timeBetweenPiSending); int initCommunication(int pingInterval, Controller &controller); void getParametersFromPi(); void tellPiThatWeGotParameters(); void sendDataToPi(Data &data, State &state); int isPiSendingUsNewParameters(); char getMessageType(); void flush(); int isDataAvailable(); void updateValuesForPiUponBreathCompleted(Data &data, State &state); void updateErrors(State &state, Data &data); // int isChecksumValid(String piString); int isTimeToSendDataToPi(); uint8_t parametersBuffer[PARAMETER_BYTE_LENGTH]; private: void resetValuesForPi(); int _baudRate; unsigned long _timeBetweenPiSending; unsigned long _lastSentDataTime; uint8_t _breathCompletedToSend; uint8_t _tidalVolumeToSend; uint8_t _apneaTimeExceededError; uint8_t _minPressure; uint8_t _maxPressure; }; #endif
30.943396
77
0.679268
b13ed87a452cae59854a3d190f2a3e9706c7e4b7
550
h
C
modules/task_1/khismatulina_k_gradient/seq.h
qunaturm/pp_2021_spring_engineers
6a1a14027f5d06445a72c4bd4f779e1c8fd490a3
[ "BSD-3-Clause" ]
null
null
null
modules/task_1/khismatulina_k_gradient/seq.h
qunaturm/pp_2021_spring_engineers
6a1a14027f5d06445a72c4bd4f779e1c8fd490a3
[ "BSD-3-Clause" ]
null
null
null
modules/task_1/khismatulina_k_gradient/seq.h
qunaturm/pp_2021_spring_engineers
6a1a14027f5d06445a72c4bd4f779e1c8fd490a3
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2021 Khismatulina Karina #ifndef MODULES_TASK_1_KHISMATULINA_K_SEQ_SEQ_H_ #define MODULES_TASK_1_KHISMATULINA_K_SEQ_SEQ_H_ #include <vector> std::vector<double> getRandomVector(int size); std::vector<double> getRandomMatrix(int size); double multVV(std::vector<double> A, std::vector<double> B); std::vector<double> multMV(std::vector<double> m, std::vector<double> v); std::vector<double> gradientSeq(const std::vector<double>& matrix, const std::vector<double>& vector, int size); #endif // MODULES_TASK_1_KHISMATULINA_K_SEQ_SEQ_H_
42.307692
112
0.794545
7f36f2059fb96341b77843dd5419cf2629336d9f
472
h
C
ios/versioned/sdk43/ExpoModulesCore/Services/ABI43_0_0EXLogManager.h
zakharchenkoAndrii/expo
f6b009d204b9124d43df59b75eb6affc2f0ba5bd
[ "Apache-2.0", "MIT" ]
16,461
2017-03-24T19:59:01.000Z
2022-03-31T21:52:45.000Z
ios/versioned/sdk43/ExpoModulesCore/Services/ABI43_0_0EXLogManager.h
zakharchenkoAndrii/expo
f6b009d204b9124d43df59b75eb6affc2f0ba5bd
[ "Apache-2.0", "MIT" ]
13,016
2017-03-25T22:49:31.000Z
2022-03-31T23:23:58.000Z
ios/versioned/sdk43/ExpoModulesCore/Services/ABI43_0_0EXLogManager.h
zakharchenkoAndrii/expo
f6b009d204b9124d43df59b75eb6affc2f0ba5bd
[ "Apache-2.0", "MIT" ]
3,945
2017-03-25T07:12:57.000Z
2022-03-31T20:55:18.000Z
// Copyright 2019-present 650 Industries. All rights reserved. #import <Foundation/Foundation.h> #import <ABI43_0_0ExpoModulesCore/ABI43_0_0EXSingletonModule.h> #import <ABI43_0_0ExpoModulesCore/ABI43_0_0EXDefines.h> NS_ASSUME_NONNULL_BEGIN @interface ABI43_0_0EXLogManager : ABI43_0_0EXSingletonModule - (void)info:(NSString *)message; - (void)warn:(NSString *)message; - (void)error:(NSString *)message; - (void)fatal:(NSError *)error; @end NS_ASSUME_NONNULL_END
23.6
63
0.798729
2c640e3be823887b753cd23789964837d9f77bec
2,194
c
C
Fully Persistent BST/Impl_Trie.c
kavitawagh/Persistent-Data-structures
c53fb972d31dd7bd9f0eb24ea76869c6e838029b
[ "MIT" ]
null
null
null
Fully Persistent BST/Impl_Trie.c
kavitawagh/Persistent-Data-structures
c53fb972d31dd7bd9f0eb24ea76869c6e838029b
[ "MIT" ]
null
null
null
Fully Persistent BST/Impl_Trie.c
kavitawagh/Persistent-Data-structures
c53fb972d31dd7bd9f0eb24ea76869c6e838029b
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include "Version_List.h" #include "FatNode.h" #include "Trie.h" FatNode *_GetLeafNode(int i, FatNode *fn); int InitTrie(Trie *T) { if(!T) return 1; T->latestV=0; T->root[0]=NULL; InsertVersion(-1, 0); return 0; } int InsertNode_Trie(Trie *T, int parentV, int dt) { int childV=T->latestV+1; FatNode *child=CreateFatNode(childV, dt); if(T->latestV==0) { T->latestV=1; T->root[1]=child; InsertVersion(0, 1); return T->latestV; } FatNode *parent=_GetLeafNode(parentV, T->root[parentV]); child->p=parent; if(parent->modCount==0) { parent->childMods=CreateModbox(parent->childCount, child, childV); parent->childCount++; parent->modCount++; } else if(parent->modCount==1) { if(parent->childMods->V==childV) parent->childMods->fieldVal=child; else { parent->childMods->next=CreateModbox(parent->childCount, child, childV); parent->childCount++; parent->modCount++; } } else { Modbox *m=parent->childMods; while(m->next) { if(m->V==childV) { m->fieldVal=child; break; } m=m->next; } if(!m->next) { if(m->V==childV) { m->fieldVal=child; } else { m->next=CreateModbox(parent->childCount, child, childV); parent->childCount++; parent->modCount++; } } } InsertVersion(parentV, childV); T->latestV=childV; T->root[T->latestV]=T->root[T->latestV-1]; return T->latestV; } int getPath(Trie *T, int i, int *p) { FatNode *l=_GetLeafNode(i, T->root[i]); int temp[i]; int j=0; while(l){ printf("%d ", l->data); temp[j++]=l->data; l=l->p; } i=0; while(i<j) p[i]=temp[j-i-1]; return j; } FatNode *_GetLeafNode(int i, FatNode *fn) { if(fn) { if(fn->modCount==0) return fn; int versions[fn->modCount]; Modbox *m=fn->childMods; int k=0; while(m) { versions[k++]=m->V; m=m->next; } int v=GetLatestVersion(versions, k, i); if(v==-1) return fn; m=fn->childMods; while(m) { if(m->V==v) if(!m->fieldVal) return fn; else return _GetLeafNode(i, m->fieldVal); m=m->next; } } }
20.504673
78
0.578851
2cd2fc5b933a8161d377defa2b297ed8b0a5bdac
4,101
h
C
simulator/mips/mips_instr_decode.h
VasiliyMatr/mipt-mips
6331f0f07a061d5fbd849b24d996d363f343fef9
[ "MIT" ]
351
2015-09-23T08:30:41.000Z
2022-03-19T09:25:05.000Z
simulator/mips/mips_instr_decode.h
VasiliyMatr/mipt-mips
6331f0f07a061d5fbd849b24d996d363f343fef9
[ "MIT" ]
1,098
2016-04-14T18:24:01.000Z
2022-03-28T09:15:05.000Z
simulator/mips/mips_instr_decode.h
Lazareva-Katya/kursach_avs
782cb08d93d01d6fa72750c6c81bcb5025664622
[ "MIT" ]
243
2016-01-03T02:46:01.000Z
2021-11-23T14:49:09.000Z
/** * mips_instr_decode.h - instruction decoder for mips * @author Andrey Agrachev agrachev.af@phystech.edu * Copyright 2018 MIPT-MIPS */ #ifndef MIPS_INSTR_DECODE_H #define MIPS_INSTR_DECODE_H #include <infra/macro.h> #include <infra/types.h> #include "mips_register/mips_register.h" enum class MIPSReg : uint8 { RS, RT, RD, CP0_RD, SR, EPC, FR, FT, FS, FD, FCSR, ZERO, RA, HI, LO, HI_LO }; using Dst = MIPSReg; using Src = MIPSReg; static inline bool is_explicit_register( MIPSReg type) { return type == MIPSReg::RS || type == MIPSReg::RT || type == MIPSReg::RD || type == MIPSReg::CP0_RD || type == MIPSReg::FR || type == MIPSReg::FT || type == MIPSReg::FS || type == MIPSReg::FD || type == MIPSReg::FCSR; } struct MIPSInstrDecoder { const uint32 funct; const uint32 shamt; const uint32 rd; const uint32 rt; const uint32 rs; const uint32 opcode; const uint32 imm; const uint32 jump; const uint32 bytes; const uint32 fd; const uint32 fs; const uint32 ft; const uint32 fmt; static constexpr uint32 apply_mask(uint32 bytes, uint32 mask) noexcept { // NOLINTNEXTLINE(hicpp-signed-bitwise) rhs must be positive return ( bytes & mask) >> std::countr_zero( mask); } uint32 get_immediate_value( char type) const { switch ( type) { case 'N': return 0; case 'S': return shamt; case 'J': return jump; default: return imm; } } template<typename R> static R get_immediate( char type, uint32 value) noexcept { switch ( type) { case 'N': case 'S': case 'J': case 'L': return value; default: return sign_extension<16, R>( value); } } MIPSRegister get_register( MIPSReg type) const { switch ( type) { case MIPSReg::ZERO: break; case MIPSReg::HI: return MIPSRegister::mips_hi(); case MIPSReg::LO: return MIPSRegister::mips_lo(); case MIPSReg::RA: return MIPSRegister::return_address(); case MIPSReg::RS: return MIPSRegister::from_cpu_index( rs); case MIPSReg::RT: return MIPSRegister::from_cpu_index( rt); case MIPSReg::RD: return MIPSRegister::from_cpu_index( rd); case MIPSReg::CP0_RD: return MIPSRegister::from_cp0_index( rd); case MIPSReg::SR: return MIPSRegister::status(); case MIPSReg::EPC: return MIPSRegister::epc(); case MIPSReg::FD: return MIPSRegister::from_cp1_index( fd); case MIPSReg::FS: return MIPSRegister::from_cp1_index( fs); case MIPSReg::FT: return MIPSRegister::from_cp1_index( ft); case MIPSReg::FR: return MIPSRegister::from_cp1_index( fmt); case MIPSReg::FCSR: return MIPSRegister::mips_fcsr(); default: assert(0); } return MIPSRegister::zero(); } explicit constexpr MIPSInstrDecoder(uint32 raw) noexcept : funct ( apply_mask( raw, 0b00000000'00000000'00000000'00111111)) , shamt ( apply_mask( raw, 0b00000000'00000000'00000111'11000000)) , rd ( apply_mask( raw, 0b00000000'00000000'11111000'00000000)) , rt ( apply_mask( raw, 0b00000000'00011111'00000000'00000000)) , rs ( apply_mask( raw, 0b00000011'11100000'00000000'00000000)) , opcode ( apply_mask( raw, 0b11111100'00000000'00000000'00000000)) , imm ( apply_mask( raw, 0b00000000'00000000'11111111'11111111)) , jump ( apply_mask( raw, 0b00000011'11111111'11111111'11111111)) , bytes ( apply_mask( raw, 0b11111111'11111111'11111111'11111111)) , fd ( apply_mask( raw, 0b00000000'00000000'00000111'11000000)) , fs ( apply_mask( raw, 0b00000000'00000000'11111000'00000000)) , ft ( apply_mask( raw, 0b00000000'00011111'00000000'00000000)) , fmt ( apply_mask( raw, 0b00000011'11100000'00000000'00000000)) { } }; #endif // MIPS_INSTR_DECODE_H
32.039063
76
0.620093
d618d1e53ace58eaadcfc3e1439591c756eaf9f1
1,427
c
C
.vim/sourceCode/glibc-2.16.0/stdio-common/errlist.c
lakehui/Vim_config
6cab80dc1209b34bf6379f42b1a92790bd0c146b
[ "MIT" ]
null
null
null
.vim/sourceCode/glibc-2.16.0/stdio-common/errlist.c
lakehui/Vim_config
6cab80dc1209b34bf6379f42b1a92790bd0c146b
[ "MIT" ]
null
null
null
.vim/sourceCode/glibc-2.16.0/stdio-common/errlist.c
lakehui/Vim_config
6cab80dc1209b34bf6379f42b1a92790bd0c146b
[ "MIT" ]
null
null
null
/* Copyright (C) 1991, 1994, 1997, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ #include <stddef.h> const char *const _sys_errlist[] = { "Error 0", /* 0 */ "Argument out of function's domain", /* 1 = EDOM */ "Result out of range", /* 2 = ERANGE */ "Operation not implemented", /* 3 = ENOSYS */ "Invalid argument", /* 4 = EINVAL */ "Illegal seek", /* 5 = ESPIPE */ "Bad file descriptor", /* 6 = EBADF */ "Cannot allocate memory", /* 7 = ENOMEM */ "Permission denied", /* 8 = EACCES */ "Too many open files in system", /* 9 = ENFILE */ "Too many open files", /* 10 = EMFILE */ }; const int _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]);
38.567568
71
0.665732
328a19c2cbe59332648dbb6a4cab728423774299
4,005
h
C
3rdparty/webkit/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.h
mchiasson/PhaserNative
f867454602c395484bf730a7c43b9c586c102ac2
[ "MIT" ]
null
null
null
3rdparty/webkit/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.h
mchiasson/PhaserNative
f867454602c395484bf730a7c43b9c586c102ac2
[ "MIT" ]
null
null
null
3rdparty/webkit/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.h
mchiasson/PhaserNative
f867454602c395484bf730a7c43b9c586c102ac2
[ "MIT" ]
1
2019-01-25T13:55:25.000Z
2019-01-25T13:55:25.000Z
/* * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #pragma once #include "JSDOMGlobalObject.h" #include "JSDOMWrapper.h" #if ENABLE(SERVICE_WORKER) #include "ServiceWorkerGlobalScope.h" #endif namespace WebCore { class JSDedicatedWorkerGlobalScope; class JSWorkerGlobalScope; class WorkerGlobalScope; #if ENABLE(SERVICE_WORKER) class JSServiceWorkerGlobalScope; #endif class JSWorkerGlobalScopeBase : public JSDOMGlobalObject { typedef JSDOMGlobalObject Base; public: static void destroy(JSC::JSCell*); DECLARE_INFO; WorkerGlobalScope& wrapped() const { return *m_wrapped; } JSC::JSProxy* proxy() const { ASSERT(m_proxy); return m_proxy.get(); } ScriptExecutionContext* scriptExecutionContext() const; static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) { return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::GlobalObjectType, StructureFlags), info()); } static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable; static bool supportsRichSourceInfo(const JSC::JSGlobalObject*); static bool shouldInterruptScript(const JSC::JSGlobalObject*); static bool shouldInterruptScriptBeforeTimeout(const JSC::JSGlobalObject*); static JSC::RuntimeFlags javaScriptRuntimeFlags(const JSC::JSGlobalObject*); static void queueTaskToEventLoop(JSC::JSGlobalObject&, Ref<JSC::Microtask>&&); void clearDOMGuardedObjects(); protected: JSWorkerGlobalScopeBase(JSC::VM&, JSC::Structure*, RefPtr<WorkerGlobalScope>&&); void finishCreation(JSC::VM&, JSC::JSProxy*); static void visitChildren(JSC::JSCell*, JSC::SlotVisitor&); private: RefPtr<WorkerGlobalScope> m_wrapped; JSC::WriteBarrier<JSC::JSProxy> m_proxy; }; // Returns a JSWorkerGlobalScope or jsNull() // Always ignores the execState and passed globalObject, WorkerGlobalScope is itself a globalObject and will always use its own prototype chain. JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, WorkerGlobalScope&); inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WorkerGlobalScope* scope) { return scope ? toJS(exec, globalObject, *scope) : JSC::jsNull(); } JSC::JSValue toJS(JSC::ExecState*, WorkerGlobalScope&); inline JSC::JSValue toJS(JSC::ExecState* exec, WorkerGlobalScope* scope) { return scope ? toJS(exec, *scope) : JSC::jsNull(); } JSDedicatedWorkerGlobalScope* toJSDedicatedWorkerGlobalScope(JSC::VM&, JSC::JSValue); JSWorkerGlobalScope* toJSWorkerGlobalScope(JSC::VM&, JSC::JSValue); #if ENABLE(SERVICE_WORKER) JSServiceWorkerGlobalScope* toJSServiceWorkerGlobalScope(JSC::VM&, JSC::JSValue); #endif } // namespace WebCore
41.28866
174
0.765293
32934979881ae9c33aaf56cb0f667576bd644f9e
1,524
h
C
CoreSystem/lib/CGAL/include/CGAL/Box_intersection_d/box_limits.h
josuehfa/DAASystem
a1fe61ffc19f0781eeeddcd589137eefde078a45
[ "MIT" ]
1
2020-03-17T01:13:02.000Z
2020-03-17T01:13:02.000Z
CoreSystem/lib/CGAL/include/CGAL/Box_intersection_d/box_limits.h
josuehfa/DAASystem
a1fe61ffc19f0781eeeddcd589137eefde078a45
[ "MIT" ]
null
null
null
CoreSystem/lib/CGAL/include/CGAL/Box_intersection_d/box_limits.h
josuehfa/DAASystem
a1fe61ffc19f0781eeeddcd589137eefde078a45
[ "MIT" ]
1
2021-12-02T11:11:36.000Z
2021-12-02T11:11:36.000Z
// Copyright (c) 2004 Max-Planck-Institute Saarbruecken (Germany). // All rights reserved. // // This file is part of CGAL (www.cgal.org). // // $URL: https://github.com/CGAL/cgal/blob/releases/CGAL-5.0.2/Box_intersection_d/include/CGAL/Box_intersection_d/box_limits.h $ // $Id: box_limits.h 254d60f 2019-10-19T15:23:19+02:00 Sébastien Loriot // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Lutz Kettner <kettner@mpi-sb.mpg.de> // Andreas Meyer <ameyer@mpi-sb.mpg.de> #ifndef CGAL_BOX_INTERSECTION_D_BOX_LIMITS_H #define CGAL_BOX_INTERSECTION_D_BOX_LIMITS_H #include <CGAL/license/Box_intersection_d.h> #include <CGAL/basic.h> #include <limits> namespace CGAL { namespace Box_intersection_d { template<class T> struct box_limits {}; template<> struct box_limits<int> { static int inf() { return (std::numeric_limits<int>::min)(); } static int sup() { return (std::numeric_limits<int>::max)(); } }; template<> struct box_limits<unsigned int> { static int inf() { return 0; } static int sup() { return (std::numeric_limits<unsigned int>::max)(); } }; template<> struct box_limits<float> { static float inf() { return -sup(); } static float sup() { return (std::numeric_limits<float>::max)(); } }; template<> struct box_limits<double> { static double inf() { return -sup(); } static double sup() { return (std::numeric_limits<double>::max)(); } }; } // end namespace Box_intersection_d } //namespace CGAL #endif
24.580645
128
0.689633
65fa1e6cfb17f63dac74b2ef1eba5c16557def98
180
c
C
fffc/templates/structure_mutator.c
williamcroberts/fffc
599f0d3fb10f45fe15e6596c07b2e67cdf96214c
[ "MIT" ]
16
2020-04-09T00:03:53.000Z
2022-01-06T15:36:06.000Z
fffc/templates/structure_mutator.c
williamcroberts/fffc
599f0d3fb10f45fe15e6596c07b2e67cdf96214c
[ "MIT" ]
2
2020-04-21T16:24:05.000Z
2020-04-22T15:09:58.000Z
fffc/templates/structure_mutator.c
williamcroberts/fffc
599f0d3fb10f45fe15e6596c07b2e67cdf96214c
[ "MIT" ]
2
2020-04-13T16:22:16.000Z
2021-02-17T11:02:18.000Z
typedef void __TARGET_TYPE__; typedef long long int ssize_t; typedef unsigned long long int size_t; static int fffc_mutator_for_target_type(__TARGET_TYPE__ storage) { return 0; }
25.714286
66
0.827778
6847cedb4cea77dbeafd8d55393a837faf0b1169
15,593
c
C
src/patches/clawpatch/fclaw2d_clawpatch_conservation.c
mattzett/forestclaw
8c2d012c259e0d9121e44c1ee78dfe2ab4839ec8
[ "BSD-2-Clause" ]
34
2017-09-26T13:39:44.000Z
2022-03-11T08:56:23.000Z
src/patches/clawpatch/fclaw2d_clawpatch_conservation.c
mattzett/forestclaw
8c2d012c259e0d9121e44c1ee78dfe2ab4839ec8
[ "BSD-2-Clause" ]
75
2017-08-02T19:56:00.000Z
2022-03-31T12:36:32.000Z
src/patches/clawpatch/fclaw2d_clawpatch_conservation.c
mattzett/forestclaw
8c2d012c259e0d9121e44c1ee78dfe2ab4839ec8
[ "BSD-2-Clause" ]
23
2018-02-21T00:10:58.000Z
2022-03-14T19:08:36.000Z
/* Copyright (c) 2012-2021 Carsten Burstedde, Donna Calhoun All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "fclaw2d_clawpatch_conservation.h" #include "fclaw2d_clawpatch_conservation_fort.h" #include <fclaw2d_time_sync.h> #include "fclaw2d_clawpatch.h" #include "fclaw2d_clawpatch_options.h" #include <fclaw2d_patch.h> #include <fclaw2d_options.h> #include <fclaw2d_global.h> #include <fclaw_math.h> /* ------------------------------------------------------------- Four routines here : 1. fclaw2d_clawpatch_cons_update_new 2. fclaw2d_clawpatch_cons_update_reset 3. fclaw2d_clawpatch_cons_update_delete 4. fclaw2d_clawpatch_time_sync_fine_to_coarse 5. fclaw2d_clawpatch_time_sync_copy */ void fclaw2d_clawpatch_time_sync_new (fclaw2d_global_t* glob, fclaw2d_patch_t* this_patch, int blockno,int patchno, fclaw2d_clawpatch_registers_t **registers) { fclaw2d_clawpatch_options_t* clawpatch_opt = fclaw2d_clawpatch_get_options(glob); int k; int mx = clawpatch_opt->mx; int my = clawpatch_opt->my; int meqn = clawpatch_opt->meqn; fclaw2d_clawpatch_registers_t *cr = *registers; /* cr = clawpatch registers */ cr = FCLAW_ALLOC(fclaw2d_clawpatch_registers_t,1); *registers = cr; /* Iterate over sides 0,1,3,4 */ for(k = 0; k < 2; k++) { /* Accumulators */ cr->fp[k] = FCLAW_ALLOC_ZERO(double,my*meqn); cr->fm[k] = FCLAW_ALLOC_ZERO(double,my*meqn); cr->gp[k] = FCLAW_ALLOC_ZERO(double,mx*meqn); cr->gm[k] = FCLAW_ALLOC_ZERO(double,mx*meqn); cr->edge_fluxes[k] = FCLAW_ALLOC_ZERO(double,2*my*meqn); cr->edge_fluxes[k+2] = FCLAW_ALLOC_ZERO(double,2*mx*meqn); cr->edgelengths[k] = FCLAW_ALLOC(double,my); cr->edgelengths[k+2] = FCLAW_ALLOC(double,mx); cr->area[k] = FCLAW_ALLOC(double,my); cr->area[k+2] = FCLAW_ALLOC(double,mx); } } void fclaw2d_clawpatch_time_sync_pack_registers(fclaw2d_global_t *glob, fclaw2d_patch_t *this_patch, double *qpack, int frsize, fclaw2d_clawpatch_packmode_t packmode, int *ierror) { fclaw2d_clawpatch_options_t* clawpatch_opt = fclaw2d_clawpatch_get_options(glob); int mx = clawpatch_opt->mx; int my = clawpatch_opt->my; int meqn = clawpatch_opt->meqn; fclaw2d_clawpatch_registers_t* cr = fclaw2d_clawpatch_get_registers(glob,this_patch); int cnt = 0; /* Cycle over four edges */ for(int k = 0; k < 4; k++) { int idir = k/2; if (idir == 0) { /* k = 0,1 : Pack registers at faces 0,1 */ for(int j = 0; j < meqn*my; j++) { if(packmode == CLAWPATCH_REGISTER_PACK) { qpack[cnt++] = cr->fm[k][j]; qpack[cnt++] = cr->fp[k][j]; qpack[cnt++] = cr->edge_fluxes[k][j]; qpack[cnt++] = cr->edge_fluxes[k][j+meqn*my]; } else { cr->fm[k][j] = qpack[cnt++]; cr->fp[k][j] = qpack[cnt++]; cr->edge_fluxes[k][j] = qpack[cnt++]; cr->edge_fluxes[k][j+meqn*my] = qpack[cnt++]; } } for(int j = 0; j < my; j++) { if (packmode == CLAWPATCH_REGISTER_PACK) { qpack[cnt++] = cr->edgelengths[k][j]; qpack[cnt++] = cr->area[k][j]; } else { cr->edgelengths[k][j] = qpack[cnt++]; cr->area[k][j] = qpack[cnt++]; } } } else if (idir == 1) { /* k = 2,3 : Pack registers at faces 2,3 */ for(int i = 0; i < meqn*mx; i++) { if(packmode == CLAWPATCH_REGISTER_PACK) { qpack[cnt++] = cr->gm[k-2][i]; qpack[cnt++] = cr->gp[k-2][i]; qpack[cnt++] = cr->edge_fluxes[k][i]; qpack[cnt++] = cr->edge_fluxes[k][i + meqn*mx]; } else { cr->gm[k-2][i] = qpack[cnt++]; cr->gp[k-2][i] = qpack[cnt++]; cr->edge_fluxes[k][i] = qpack[cnt++]; cr->edge_fluxes[k][i + meqn*mx] = qpack[cnt++]; } } for(int i = 0; i < mx; i++) { if (packmode == CLAWPATCH_REGISTER_PACK) { qpack[cnt++] = cr->edgelengths[k][i]; qpack[cnt++] = cr->area[k][i]; } else { cr->edgelengths[k][i] = qpack[cnt++]; cr->area[k][i] = qpack[cnt++]; } } } } /* Check that we packed exactly the right number of elements */ *ierror = (cnt == frsize) ? 0 : 1; } void fclaw2d_clawpatch_time_sync_reset(fclaw2d_global_t *glob, fclaw2d_patch_t *this_patch, int coarse_level, int reset_mode) { int mx,my,meqn; int i,j,k,idir; fclaw2d_clawpatch_options_t* clawpatch_opt = fclaw2d_clawpatch_get_options(glob); fclaw2d_clawpatch_registers_t* cr = fclaw2d_clawpatch_get_registers(glob,this_patch); mx = clawpatch_opt->mx; my = clawpatch_opt->my; meqn = clawpatch_opt->meqn; fclaw2d_patch_data_t* pdata = fclaw2d_patch_get_patch_data(this_patch); int fine_level = coarse_level+1; int reset_flux; for(k = 0; k < 4; k++) { idir = k/2; reset_flux = 0; if (reset_mode == FCLAW2D_TIME_SYNC_RESET_F2C) { /* Reset registers at interface between levels 'coarse_level' and 'fine_level' */ int is_coarse = (pdata->face_neighbors[k] == FCLAW2D_PATCH_HALFSIZE) && (this_patch->level == coarse_level); int is_fine = (pdata->face_neighbors[k] == FCLAW2D_PATCH_DOUBLESIZE) && (this_patch->level == fine_level); reset_flux = is_coarse || is_fine; } else if (reset_mode == FCLAW2D_TIME_SYNC_RESET_SAMESIZE) { /* Reset registers at interfaces between same size grids on coarse level */ reset_flux = (pdata->face_neighbors[k] == FCLAW2D_PATCH_SAMESIZE) && (this_patch->level == coarse_level); } else if (reset_mode == FCLAW2D_TIME_SYNC_RESET_PHYS) { /* Reset flux registers at physical boundaries (not actually used, but they are accumulated, so should be cleared out) */ reset_flux = pdata->face_neighbors[k] == FCLAW2D_PATCH_BOUNDARY; } if (reset_flux) { if (idir == 0) { for(j = 0; j < meqn*my; j++) { /* k = 0,1 */ cr->fm[k][j] = 0; cr->fp[k][j] = 0; cr->edge_fluxes[k][j] = 0; cr->edge_fluxes[k][j+meqn*my] = 0; /* Two fluxes stored at each edge point */ } } else { for(i = 0; i < meqn*mx; i++) { /* k = 2,3 */ cr->gm[k-2][i] = 0; cr->gp[k-2][i] = 0; cr->edge_fluxes[k][i] = 0; cr->edge_fluxes[k][i + meqn*mx] = 0; } } } } } void fclaw2d_clawpatch_time_sync_delete (fclaw2d_clawpatch_registers_t **registers) { int k; fclaw2d_clawpatch_registers_t *cr = *registers; for(k = 0; k < 2; k++) { /* Accumulators */ FCLAW_FREE(cr->fp[k]); FCLAW_FREE(cr->fm[k]); FCLAW_FREE(cr->gp[k]); FCLAW_FREE(cr->gm[k]); /* COARSE GRID information */ FCLAW_FREE(cr->edge_fluxes[k]); FCLAW_FREE(cr->edge_fluxes[k+2]); FCLAW_FREE(cr->edgelengths[k]); FCLAW_FREE(cr->area[k]); FCLAW_FREE(cr->edgelengths[k+2]); FCLAW_FREE(cr->area[k+2]); } FCLAW_FREE(*registers); *registers = NULL; } void fclaw2d_clawpatch_time_sync_setup(fclaw2d_global_t* glob, fclaw2d_patch_t* this_patch, int blockno,int patchno) { int mx,my,mbc; double dx,dy,xlower,ylower; double *area, *edgelengths, *curvature; fclaw2d_clawpatch_registers_t *cr = fclaw2d_clawpatch_get_registers(glob,this_patch); const fclaw_options_t *fclaw_opt = fclaw2d_get_options(glob); fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); fclaw2d_clawpatch_metric_scalar(glob,this_patch, &area, &edgelengths,&curvature); if (fclaw_opt->manifold) { /* only need area != NULL if manifold == 1 */ FCLAW_ASSERT(area != NULL); } CLAWPATCH_TIME_SYNC_SETUP(&mx,&my,&mbc,&dx,&dy,area,edgelengths, cr->area[0],cr->area[1], cr->area[2],cr->area[3], cr->edgelengths[0],cr->edgelengths[1], cr->edgelengths[2],cr->edgelengths[3], &fclaw_opt->manifold); } /* This is a patch call-back */ void fclaw2d_clawpatch_time_sync_f2c(fclaw2d_global_t* glob, fclaw2d_patch_t* coarse_patch, fclaw2d_patch_t* fine_patch, int coarse_blockno, int fine_blockno, int coarse_patchno, int idir, int igrid, int iface_coarse, int time_interp, fclaw2d_patch_transform_data_t *transform_data) { fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(); /* We don't correct time interpolated grids, since we assume that the time interpolated average will already have correction information from times n and n+1 patches. But we do correct ghost patches, since corrections will be needed for copying and interpolation. */ double *qcoarse; int meqn; fclaw2d_clawpatch_soln_data(glob,coarse_patch,&qcoarse,&meqn); double *qfine; fclaw2d_clawpatch_soln_data(glob,fine_patch,&qfine,&meqn); int mx,my,mbc; double dx,dy,xlower,ylower; fclaw2d_clawpatch_grid_data(glob,coarse_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); fclaw2d_clawpatch_registers_t* crcoarse = fclaw2d_clawpatch_get_registers(glob,coarse_patch); fclaw2d_clawpatch_registers_t* crfine = fclaw2d_clawpatch_get_registers(glob,fine_patch); /* create dummy fine grid to handle indexing between blocks */ double *qneighbor_dummy = FCLAW_ALLOC_ZERO(double,meqn*(mx+4*mbc)*(my+4*mbc)); int normal_match = fclaw2d_patch_normal_match(glob->domain, coarse_blockno, coarse_patchno, iface_coarse); /* This function is defined in fc2d_clawpack4.6 and fc2d_clawpack5 */ clawpatch_vt->fort_time_sync_f2c(&mx,&my,&mbc,&meqn,&idir,&iface_coarse, &coarse_blockno, &fine_blockno, &normal_match, crcoarse->area[0], crcoarse->area[1], crcoarse->area[2], crcoarse->area[3], qcoarse, crcoarse->fp[0],crcoarse->fm[1], crcoarse->gp[0],crcoarse->gm[1], crfine->fm[0],crfine->fp[1], crfine->gm[0],crfine->gp[1], crcoarse->edge_fluxes[0], crcoarse->edge_fluxes[1], crcoarse->edge_fluxes[2], crcoarse->edge_fluxes[3], crfine->edge_fluxes[0], crfine->edge_fluxes[1], crfine->edge_fluxes[2], crfine->edge_fluxes[3], qneighbor_dummy, &transform_data); FCLAW_FREE(qneighbor_dummy); } void fclaw2d_clawpatch_time_sync_samesize (struct fclaw2d_global* glob, struct fclaw2d_patch* this_patch, struct fclaw2d_patch* neighbor_patch, int this_iface,int idir, fclaw2d_patch_transform_data_t *transform_data) { /* We don't correct time interpolated grids, since we assume that the time interpolated average will already have correction information from times n and n+1 patches. But we do correct ghost patches, since corrections will be needed for copying and interpolation. */ fclaw2d_clawpatch_vtable_t *clawpatch_vt = fclaw2d_clawpatch_vt(); double *qthis; int meqn; fclaw2d_clawpatch_soln_data(glob,this_patch,&qthis,&meqn); int mx,my,mbc; double dx,dy,xlower,ylower; fclaw2d_clawpatch_grid_data(glob,this_patch,&mx,&my,&mbc, &xlower,&ylower,&dx,&dy); fclaw2d_clawpatch_registers_t* crthis = fclaw2d_clawpatch_get_registers(glob,this_patch); fclaw2d_clawpatch_registers_t* crneighbor = fclaw2d_clawpatch_get_registers(glob,neighbor_patch); /* create dummy fine grid to handle indexing between blocks */ double *qneighbor_dummy = FCLAW_ALLOC_ZERO(double,meqn*(mx+2*mbc)*(my+2*mbc)); /* Include this for debugging */ int this_blockno, this_patchno,globnum,level; int neighbor_blockno, neighbor_patchno; fclaw2d_patch_get_info2(glob->domain,this_patch,&this_blockno, &this_patchno, &globnum,&level); fclaw2d_patch_get_info2(glob->domain,neighbor_patch,&neighbor_blockno, &neighbor_patchno,&globnum,&level); /* This function is defined in fc2d_clawpack4.6 and fc2d_clawpack5 */ /* Distribute 0.5 of each correction from each side */ clawpatch_vt->fort_time_sync_samesize(&mx,&my,&mbc,&meqn,&idir,&this_iface, &this_blockno, &neighbor_blockno, crthis->area[0], crthis->area[1], crthis->area[2], crthis->area[3], qthis, crthis->fp[0],crthis->fm[1], crthis->gp[0],crthis->gm[1], crneighbor->fm[0],crneighbor->fp[1], crneighbor->gm[0],crneighbor->gp[1], crthis->edge_fluxes[0], crthis->edge_fluxes[1], crthis->edge_fluxes[2], crthis->edge_fluxes[3], crneighbor->edge_fluxes[0], crneighbor->edge_fluxes[1], crneighbor->edge_fluxes[2], crneighbor->edge_fluxes[3], qneighbor_dummy, &transform_data); FCLAW_FREE(qneighbor_dummy); }
33.318376
87
0.589944
d08e72506973fd0041accbd1f7b46773bf251629
251
h
C
ColorPicker/ColorPickerPreview.h
jiangxiaoxin/Color-Picker-Pro
3050c898ed1f0038e1366d1822755539035e2d69
[ "MIT", "Unlicense" ]
216
2015-01-05T13:11:06.000Z
2022-02-05T01:32:24.000Z
ColorPicker/ColorPickerPreview.h
jiangxiaoxin/Color-Picker-Pro
3050c898ed1f0038e1366d1822755539035e2d69
[ "MIT", "Unlicense" ]
3
2015-09-16T18:53:29.000Z
2017-10-06T13:07:08.000Z
ColorPicker/ColorPickerPreview.h
jiangxiaoxin/Color-Picker-Pro
3050c898ed1f0038e1366d1822755539035e2d69
[ "MIT", "Unlicense" ]
31
2015-01-21T12:54:58.000Z
2021-03-26T02:22:46.000Z
// // ColorPickerPreview.h // ColorPicker // // Created by Oscar Del Ben on 8/22/11. // Copyright 2011 DibiStore. All rights reserved. // #import <Cocoa/Cocoa.h> @interface ColorPickerPreview : NSView @property (retain) NSImage *preview; @end
15.6875
50
0.705179
ca7f6f2f7216c091dcfe5a60f90a7c05b374cb7d
3,402
h
C
aws-cpp-sdk-backup/include/aws/backup/model/ExportBackupPlanTemplateResult.h
neil-b/aws-sdk-cpp
1602b75abbca880b770c12788f6d2bac0c87176a
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-backup/include/aws/backup/model/ExportBackupPlanTemplateResult.h
neil-b/aws-sdk-cpp
1602b75abbca880b770c12788f6d2bac0c87176a
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-backup/include/aws/backup/model/ExportBackupPlanTemplateResult.h
neil-b/aws-sdk-cpp
1602b75abbca880b770c12788f6d2bac0c87176a
[ "Apache-2.0" ]
null
null
null
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/backup/Backup_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <utility> namespace Aws { template<typename RESULT_TYPE> class AmazonWebServiceResult; namespace Utils { namespace Json { class JsonValue; } // namespace Json } // namespace Utils namespace Backup { namespace Model { class AWS_BACKUP_API ExportBackupPlanTemplateResult { public: ExportBackupPlanTemplateResult(); ExportBackupPlanTemplateResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); ExportBackupPlanTemplateResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); /** * <p>The body of a backup plan template in JSON format.</p> <note> <p>This is a * signed JSON document that cannot be modified before being passed to * <code>GetBackupPlanFromJSON.</code> </p> </note> */ inline const Aws::String& GetBackupPlanTemplateJson() const{ return m_backupPlanTemplateJson; } /** * <p>The body of a backup plan template in JSON format.</p> <note> <p>This is a * signed JSON document that cannot be modified before being passed to * <code>GetBackupPlanFromJSON.</code> </p> </note> */ inline void SetBackupPlanTemplateJson(const Aws::String& value) { m_backupPlanTemplateJson = value; } /** * <p>The body of a backup plan template in JSON format.</p> <note> <p>This is a * signed JSON document that cannot be modified before being passed to * <code>GetBackupPlanFromJSON.</code> </p> </note> */ inline void SetBackupPlanTemplateJson(Aws::String&& value) { m_backupPlanTemplateJson = std::move(value); } /** * <p>The body of a backup plan template in JSON format.</p> <note> <p>This is a * signed JSON document that cannot be modified before being passed to * <code>GetBackupPlanFromJSON.</code> </p> </note> */ inline void SetBackupPlanTemplateJson(const char* value) { m_backupPlanTemplateJson.assign(value); } /** * <p>The body of a backup plan template in JSON format.</p> <note> <p>This is a * signed JSON document that cannot be modified before being passed to * <code>GetBackupPlanFromJSON.</code> </p> </note> */ inline ExportBackupPlanTemplateResult& WithBackupPlanTemplateJson(const Aws::String& value) { SetBackupPlanTemplateJson(value); return *this;} /** * <p>The body of a backup plan template in JSON format.</p> <note> <p>This is a * signed JSON document that cannot be modified before being passed to * <code>GetBackupPlanFromJSON.</code> </p> </note> */ inline ExportBackupPlanTemplateResult& WithBackupPlanTemplateJson(Aws::String&& value) { SetBackupPlanTemplateJson(std::move(value)); return *this;} /** * <p>The body of a backup plan template in JSON format.</p> <note> <p>This is a * signed JSON document that cannot be modified before being passed to * <code>GetBackupPlanFromJSON.</code> </p> </note> */ inline ExportBackupPlanTemplateResult& WithBackupPlanTemplateJson(const char* value) { SetBackupPlanTemplateJson(value); return *this;} private: Aws::String m_backupPlanTemplateJson; }; } // namespace Model } // namespace Backup } // namespace Aws
36.978261
152
0.70341
b74a9a64f123c4af82788c97dbeca8d4d8a9d26d
856
h
C
include/music/Duration.h
etrange02/Fux
2f49bcd8ec82eb521092c9162e01c8b0d00222ab
[ "CECILL-B" ]
2
2016-03-21T10:48:34.000Z
2017-03-17T19:50:34.000Z
include/music/Duration.h
etrange02/Fux
2f49bcd8ec82eb521092c9162e01c8b0d00222ab
[ "CECILL-B" ]
null
null
null
include/music/Duration.h
etrange02/Fux
2f49bcd8ec82eb521092c9162e01c8b0d00222ab
[ "CECILL-B" ]
null
null
null
#ifndef DURATION_H #define DURATION_H namespace music { /** * @struct Duration * @brief Abstraction of music time in minute, second and full time in second */ class Duration { public: Duration(); virtual ~Duration(); Duration& operator=(const Duration& other); unsigned int GetMinute(); void SetMinute(unsigned int val); unsigned int GetSeconde(); void SetSeconde(unsigned int val); unsigned int GetMSecondeTot(); void SetMSecondeTot(unsigned int val); private: unsigned int m_minute; //!< Member variable "m_minute" unsigned int m_seconde; //!< Member variable "m_seconde" unsigned int m_msecondeTot; //!< Member variable "m_msecondeTot" }; } #endif // DUREE_H
27.612903
81
0.587617
318f3aaf3c991911ce406d417610479b8c41353c
2,337
h
C
lib/cef/libcef_dll/ctocpp/image_ctocpp.h
devcxx/zephyros
3ba2c63c5d11bfab66b896e8e09287e222f645a2
[ "Unlicense", "MIT" ]
11
2015-01-02T14:11:58.000Z
2021-01-29T02:45:17.000Z
lib/cef/libcef_dll/ctocpp/image_ctocpp.h
devcxx/zephyros
3ba2c63c5d11bfab66b896e8e09287e222f645a2
[ "Unlicense", "MIT" ]
null
null
null
lib/cef/libcef_dll/ctocpp/image_ctocpp.h
devcxx/zephyros
3ba2c63c5d11bfab66b896e8e09287e222f645a2
[ "Unlicense", "MIT" ]
1
2021-03-08T08:07:00.000Z
2021-03-08T08:07:00.000Z
// Copyright (c) 2017 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that // can be found in the LICENSE file. // // --------------------------------------------------------------------------- // // This file was generated by the CEF translator tool. If making changes by // hand only do so within the body of existing method and function // implementations. See the translator.README.txt file in the tools directory // for more information. // #ifndef CEF_LIBCEF_DLL_CTOCPP_IMAGE_CTOCPP_H_ #define CEF_LIBCEF_DLL_CTOCPP_IMAGE_CTOCPP_H_ #pragma once #if !defined(WRAPPING_CEF_SHARED) #error This file can be included wrapper-side only #endif #include "include/cef_image.h" #include "include/capi/cef_image_capi.h" #include "libcef_dll/ctocpp/ctocpp.h" // Wrap a C structure with a C++ class. // This class may be instantiated and accessed wrapper-side only. class CefImageCToCpp : public CefCToCpp<CefImageCToCpp, CefImage, cef_image_t> { public: CefImageCToCpp(); // CefImage methods. bool IsEmpty() OVERRIDE; bool IsSame(CefRefPtr<CefImage> that) OVERRIDE; bool AddBitmap(float scale_factor, int pixel_width, int pixel_height, cef_color_type_t color_type, cef_alpha_type_t alpha_type, const void* pixel_data, size_t pixel_data_size) OVERRIDE; bool AddPNG(float scale_factor, const void* png_data, size_t png_data_size) OVERRIDE; bool AddJPEG(float scale_factor, const void* jpeg_data, size_t jpeg_data_size) OVERRIDE; size_t GetWidth() OVERRIDE; size_t GetHeight() OVERRIDE; bool HasRepresentation(float scale_factor) OVERRIDE; bool RemoveRepresentation(float scale_factor) OVERRIDE; bool GetRepresentationInfo(float scale_factor, float& actual_scale_factor, int& pixel_width, int& pixel_height) OVERRIDE; CefRefPtr<CefBinaryValue> GetAsBitmap(float scale_factor, cef_color_type_t color_type, cef_alpha_type_t alpha_type, int& pixel_width, int& pixel_height) OVERRIDE; CefRefPtr<CefBinaryValue> GetAsPNG(float scale_factor, bool with_transparency, int& pixel_width, int& pixel_height) OVERRIDE; CefRefPtr<CefBinaryValue> GetAsJPEG(float scale_factor, int quality, int& pixel_width, int& pixel_height) OVERRIDE; }; #endif // CEF_LIBCEF_DLL_CTOCPP_IMAGE_CTOCPP_H_
40.293103
80
0.75353
c8bad448a5574ba76f77312f6b15623fa2bef06b
16,661
h
C
include/bluetooth/audio/vcs.h
psychogenic/zephyr
b0e05e8cac3a24bfee2901898a15aa4306f01d66
[ "Apache-2.0" ]
6,224
2016-06-24T20:04:19.000Z
2022-03-31T20:33:45.000Z
include/bluetooth/audio/vcs.h
psychogenic/zephyr
b0e05e8cac3a24bfee2901898a15aa4306f01d66
[ "Apache-2.0" ]
32,027
2017-03-24T00:02:32.000Z
2022-03-31T23:45:53.000Z
include/bluetooth/audio/vcs.h
bfrog/zephyr
9c638f727d7bd70c77db8569a94f5015ccbacec9
[ "Apache-2.0" ]
4,374
2016-08-11T07:28:47.000Z
2022-03-31T14:44:59.000Z
/* * Copyright (c) 2020-2021 Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ #ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_VCS_H_ #define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_VCS_H_ /** * @brief Volume Control Service (VCS) * * @defgroup bt_gatt_vcs Volume Control Service (VCS) * * @ingroup bluetooth * @{ * * [Experimental] Users should note that the APIs can change * as a part of ongoing development. */ #include <zephyr/types.h> #include <bluetooth/audio/aics.h> #include <bluetooth/audio/vocs.h> #ifdef __cplusplus extern "C" { #endif #if defined(CONFIG_BT_VCS) #define BT_VCS_VOCS_CNT CONFIG_BT_VCS_VOCS_INSTANCE_COUNT #define BT_VCS_AICS_CNT CONFIG_BT_VCS_AICS_INSTANCE_COUNT #else #define BT_VCS_VOCS_CNT 0 #define BT_VCS_AICS_CNT 0 #endif /* CONFIG_BT_VCS */ /** Volume Control Service Error codes */ #define BT_VCS_ERR_INVALID_COUNTER 0x80 #define BT_VCS_ERR_OP_NOT_SUPPORTED 0x81 /** Volume Control Service Mute Values */ #define BT_VCS_STATE_UNMUTED 0x00 #define BT_VCS_STATE_MUTED 0x01 /** @brief Opaque Volume Control Service instance. */ struct bt_vcs; /** Register structure for Volume Control Service */ struct bt_vcs_register_param { /** Initial step size (1-255) */ uint8_t step; /** Initial mute state (0-1) */ uint8_t mute; /** Initial volume level (0-255) */ uint8_t volume; /** Register parameters for Volume Offset Control Services */ struct bt_vocs_register_param vocs_param[BT_VCS_VOCS_CNT]; /** Register parameters for Audio Input Control Services */ struct bt_aics_register_param aics_param[BT_VCS_AICS_CNT]; /** Volume Control Service callback structure. */ struct bt_vcs_cb *cb; }; /** * @brief Volume Control Service included services * * Used for to represent the Volume Control Service included service instances, * for either a client or a server. The instance pointers either represent * local server instances, or remote service instances. */ struct bt_vcs_included { /** Number of Volume Offset Control Service instances */ uint8_t vocs_cnt; /** Array of pointers to Volume Offset Control Service instances */ struct bt_vocs **vocs; /** Number of Audio Input Control Service instances */ uint8_t aics_cnt; /** Array of pointers to Audio Input Control Service instances */ struct bt_aics **aics; }; /** * @brief Register the Volume Control Service. * * This will register and enable the service and make it discoverable by * clients. * * @param param Volume Control Service register parameters. * @param[out] vcs Pointer to the registered Volume Control Service. * This will still be valid if the return value is -EALREADY. * * @return 0 if success, errno on failure. */ int bt_vcs_register(struct bt_vcs_register_param *param, struct bt_vcs **vcs); /** * @brief Get Volume Control Service included services. * * Returns a pointer to a struct that contains information about the * Volume Control Service included service instances, such as pointers to the * Volume Offset Control Service (Volume Offset Control Service) or * Audio Input Control Service (AICS) instances. * * @param vcs Volume Control Service instance pointer. * @param[out] included Pointer to store the result in. * * @return 0 if success, errno on failure. */ int bt_vcs_included_get(struct bt_vcs *vcs, struct bt_vcs_included *included); /** * @brief Get the connection pointer of a client instance * * Get the Bluetooth connection pointer of a Volume Control Service * client instance. * * @param vcs Volume Control Service client instance pointer. * @param[out] conn Connection pointer. * * @return 0 if success, errno on failure. */ int bt_vcs_client_conn_get(const struct bt_vcs *vcs, struct bt_conn **conn); /** * @brief Callback function for bt_vcs_discover. * * This callback is only used for the client. * * @param vcs Volume Control Service instance pointer. * @param err Error value. 0 on success, GATT error on positive value * or errno on negative value. * @param vocs_count Number of Volume Offset Control Service instances * on peer device. * @param aics_count Number of Audio Input Control Service instances on * peer device. */ typedef void (*bt_vcs_discover_cb)(struct bt_vcs *vcs, int err, uint8_t vocs_count, uint8_t aics_count); /** * @brief Callback function for Volume Control Service volume state. * * Called when the value is locally read as the server. * Called when the value is remotely read as the client. * Called if the value is changed by either the server or client. * * @param vcs Volume Control Service instance pointer. * @param err Error value. 0 on success, GATT error on positive value * or errno on negative value. * @param volume The volume of the Volume Control Service server. * @param mute The mute setting of the Volume Control Service server. */ typedef void (*bt_vcs_state_cb)(struct bt_vcs *vcs, int err, uint8_t volume, uint8_t mute); /** * @brief Callback function for Volume Control Service flags. * * Called when the value is locally read as the server. * Called when the value is remotely read as the client. * Called if the value is changed by either the server or client. * * @param vcs Volume Control Service instance pointer. * @param err Error value. 0 on success, GATT error on positive value * or errno on negative value. * @param flags The flags of the Volume Control Service server. */ typedef void (*bt_vcs_flags_cb)(struct bt_vcs *vcs, int err, uint8_t flags); /** * @brief Callback function for writes. * * This callback is only used for the client. * * @param vcs Volume Control Service instance pointer. * @param err Error value. 0 on success, GATT error on fail. */ typedef void (*bt_vcs_write_cb)(struct bt_vcs *vcs, int err); struct bt_vcs_cb { /* Volume Control Service */ bt_vcs_state_cb state; bt_vcs_flags_cb flags; #if defined(CONFIG_BT_VCS_CLIENT) bt_vcs_discover_cb discover; bt_vcs_write_cb vol_down; bt_vcs_write_cb vol_up; bt_vcs_write_cb mute; bt_vcs_write_cb unmute; bt_vcs_write_cb vol_down_unmute; bt_vcs_write_cb vol_up_unmute; bt_vcs_write_cb vol_set; /* Volume Offset Control Service */ struct bt_vocs_cb vocs_cb; /* Audio Input Control Service */ struct bt_aics_cb aics_cb; #endif /* CONFIG_BT_VCS_CLIENT */ }; /** * @brief Discover Volume Control Service and included services. * * This will start a GATT discovery and setup handles and subscriptions. * This shall be called once before any other actions can be * executed for the peer device, and the @ref bt_vcs_discover_cb callback * will notify when it is possible to start remote operations. * * This shall only be done as the client, * * @param conn The connection to discover Volume Control Service for. * @param[out] vcs Valid remote instance object on success. * * @return 0 if success, errno on failure. */ int bt_vcs_discover(struct bt_conn *conn, struct bt_vcs **vcs); /** * @brief Set the Volume Control Service volume step size. * * Set the value that the volume changes, when changed relatively with e.g. * @ref bt_vcs_vol_down or @ref bt_vcs_vol_up. * * This can only be done as the server. * * @param volume_step The volume step size (1-255). * * @return 0 if success, errno on failure. */ int bt_vcs_vol_step_set(uint8_t volume_step); /** * @brief Read the Volume Control Service volume state. * * @param vcs Volume Control Service instance pointer. * * @return 0 if success, errno on failure. */ int bt_vcs_vol_get(struct bt_vcs *vcs); /** * @brief Read the Volume Control Service flags. * * @param vcs Volume Control Service instance pointer. * * @return 0 if success, errno on failure. */ int bt_vcs_flags_get(struct bt_vcs *vcs); /** * @brief Turn the volume down by one step on the server. * * @param vcs Volume Control Service instance pointer. * * @return 0 if success, errno on failure. */ int bt_vcs_vol_down(struct bt_vcs *vcs); /** * @brief Turn the volume up by one step on the server. * * @param vcs Volume Control Service instance pointer. * * @return 0 if success, errno on failure. */ int bt_vcs_vol_up(struct bt_vcs *vcs); /** * @brief Turn the volume down and unmute the server. * * @param vcs Volume Control Service instance pointer. * * @return 0 if success, errno on failure. */ int bt_vcs_unmute_vol_down(struct bt_vcs *vcs); /** * @brief Turn the volume up and unmute the server. * * @param vcs Volume Control Service instance pointer. * * @return 0 if success, errno on failure. */ int bt_vcs_unmute_vol_up(struct bt_vcs *vcs); /** * @brief Set the volume on the server * * @param vcs Volume Control Service instance pointer. * @param volume The absolute volume to set. * * @return 0 if success, errno on failure. */ int bt_vcs_vol_set(struct bt_vcs *vcs, uint8_t volume); /** * @brief Unmute the server. * * @param vcs Volume Control Service instance pointer. * * @return 0 if success, errno on failure. */ int bt_vcs_unmute(struct bt_vcs *vcs); /** * @brief Mute the server. * * @param vcs Volume Control Service instance pointer. * * @return 0 if success, errno on failure. */ int bt_vcs_mute(struct bt_vcs *vcs); /** * @brief Read the Volume Offset Control Service offset state. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Volume Offset Control Service instance. * * @return 0 if success, errno on failure. */ int bt_vcs_vocs_state_get(struct bt_vcs *vcs, struct bt_vocs *inst); /** * @brief Read the Volume Offset Control Service location. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Volume Offset Control Service instance. * * @return 0 if success, errno on failure. */ int bt_vcs_vocs_location_get(struct bt_vcs *vcs, struct bt_vocs *inst); /** * @brief Set the Volume Offset Control Service location. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Volume Offset Control Service instance. * @param location The location to set. * * @return 0 if success, errno on failure. */ int bt_vcs_vocs_location_set(struct bt_vcs *vcs, struct bt_vocs *inst, uint8_t location); /** * @brief Set the Volume Offset Control Service offset state. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Volume Offset Control Service instance. * @param offset The offset to set (-255 to 255). * * @return 0 if success, errno on failure. */ int bt_vcs_vocs_state_set(struct bt_vcs *vcs, struct bt_vocs *inst, int16_t offset); /** * @brief Read the Volume Offset Control Service output description. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Volume Offset Control Service instance. * * @return 0 if success, errno on failure. */ int bt_vcs_vocs_description_get(struct bt_vcs *vcs, struct bt_vocs *inst); /** * @brief Set the Volume Offset Control Service description. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Volume Offset Control Service instance. * @param description The description to set. * * @return 0 if success, errno on failure. */ int bt_vcs_vocs_description_set(struct bt_vcs *vcs, struct bt_vocs *inst, const char *description); /** * @brief Deactivates an Audio Input Control Service instance. * * Audio Input Control Services are activated by default, but this will allow * the server to deactivate an Audio Input Control Service. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Audio Input Control Service instance. * * @return 0 if success, errno on failure. */ int bt_vcs_aics_deactivate(struct bt_vcs *vcs, struct bt_aics *inst); /** * @brief Activates an Audio Input Control Service instance. * * Audio Input Control Services are activated by default, but this will allow * the server to reactivate an Audio Input Control Service instance after it has * been deactivated with @ref bt_vcs_aics_deactivate. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Audio Input Control Service instance. * * @return 0 if success, errno on failure. */ int bt_vcs_aics_activate(struct bt_vcs *vcs, struct bt_aics *inst); /** * @brief Read the Audio Input Control Service input state. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Audio Input Control Service instance. * * @return 0 if success, errno on failure. */ int bt_vcs_aics_state_get(struct bt_vcs *vcs, struct bt_aics *inst); /** * @brief Read the Audio Input Control Service gain settings. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Audio Input Control Service instance. * * @return 0 if success, errno on failure. */ int bt_vcs_aics_gain_setting_get(struct bt_vcs *vcs, struct bt_aics *inst); /** * @brief Read the Audio Input Control Service input type. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Audio Input Control Service instance. * * @return 0 if success, errno on failure. */ int bt_vcs_aics_type_get(struct bt_vcs *vcs, struct bt_aics *inst); /** * @brief Read the Audio Input Control Service input status. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Audio Input Control Service instance. * * @return 0 if success, errno on failure. */ int bt_vcs_aics_status_get(struct bt_vcs *vcs, struct bt_aics *inst); /** * @brief Mute the Audio Input Control Service input. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Audio Input Control Service instance. * * @return 0 if success, errno on failure. */ int bt_vcs_aics_mute(struct bt_vcs *vcs, struct bt_aics *inst); /** * @brief Unmute the Audio Input Control Service input. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Audio Input Control Service instance. * * @return 0 if success, errno on failure. */ int bt_vcs_aics_unmute(struct bt_vcs *vcs, struct bt_aics *inst); /** * @brief Set input gain to manual. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Audio Input Control Service instance. * * @return 0 if success, errno on failure. */ int bt_vcs_aics_manual_gain_set(struct bt_vcs *vcs, struct bt_aics *inst); /** * @brief Set the input gain to automatic. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Audio Input Control Service instance. * * @return 0 if success, errno on failure. */ int bt_vcs_aics_automatic_gain_set(struct bt_vcs *vcs, struct bt_aics *inst); /** * @brief Set the input gain. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Audio Input Control Service instance. * @param gain The gain in dB to set (-128 to 127). * * @return 0 if success, errno on failure. */ int bt_vcs_aics_gain_set(struct bt_vcs *vcs, struct bt_aics *inst, int8_t gain); /** * @brief Read the Audio Input Control Service description. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Audio Input Control Service instance. * * @return 0 if success, errno on failure. */ int bt_vcs_aics_description_get(struct bt_vcs *vcs, struct bt_aics *inst); /** * @brief Set the Audio Input Control Service description. * * @param vcs Volume Control Service instance pointer. * @param inst Pointer to the Audio Input Control Service instance. * @param description The description to set. * * @return 0 if success, errno on failure. */ int bt_vcs_aics_description_set(struct bt_vcs *vcs, struct bt_aics *inst, const char *description); /** * @brief Registers the callbacks used by the Volume Control Service client. * * @param cb The callback structure. * * @return 0 if success, errno on failure. */ int bt_vcs_client_cb_register(struct bt_vcs_cb *cb); #ifdef __cplusplus } #endif /** * @} */ #endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_VCS_H_ */
30.458867
80
0.713042
83616dbca7c3f4a11e47f60c88eb1e24095e373b
684
h
C
AK/Hex.h
AristodamusAdairs/SegueBaseOS
36e8546009cfea6acd25f111b1cd0ce766271a77
[ "BSD-2-Clause", "MIT" ]
1
2021-07-05T13:51:23.000Z
2021-07-05T13:51:23.000Z
AK/Hex.h
AristodamusAdairs/SegueBaseOS
36e8546009cfea6acd25f111b1cd0ce766271a77
[ "BSD-2-Clause", "MIT" ]
1
2021-08-02T21:33:29.000Z
2021-08-06T21:22:19.000Z
AK/Hex.h
AristodamusAdairs/SegueBaseOS
36e8546009cfea6acd25f111b1cd0ce766271a77
[ "BSD-2-Clause", "MIT" ]
null
null
null
/* * Copyright (c) 2020, Andreas Kling <kling@seguebaseos.org> * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include <AK/ByteBuffer.h> #include <AK/Optional.h> #include <AK/String.h> #include <AK/StringView.h> namespace AK { constexpr u8 decode_hex_digit(char digit) { if (digit >= '0' && digit <= '9') return digit - '0'; if (digit >= 'a' && digit <= 'f') return 10 + (digit - 'a'); if (digit >= 'A' && digit <= 'F') return 10 + (digit - 'A'); return 255; } Optional<ByteBuffer> decode_hex(const StringView&); String encode_hex(ReadonlyBytes); } using AK::decode_hex; using AK::decode_hex_digit; using AK::encode_hex;
19
60
0.624269
4d0053a3a9faee7cc0f412ebeac36ea68dc9e22d
3,021
c
C
src/screen_ending.c
skejeton/raylib5k-jam
26a1716db3586097be2232837b1eae338014c8d4
[ "Zlib" ]
null
null
null
src/screen_ending.c
skejeton/raylib5k-jam
26a1716db3586097be2232837b1eae338014c8d4
[ "Zlib" ]
null
null
null
src/screen_ending.c
skejeton/raylib5k-jam
26a1716db3586097be2232837b1eae338014c8d4
[ "Zlib" ]
null
null
null
/********************************************************************************************** * * raylib - Advance Game template * * Ending Screen Functions Definitions (Init, Update, Draw, Unload) * * Copyright (c) 2014-2022 Ramon Santamaria (@raysan5) * * This software is provided "as-is", without any express or implied warranty. In no event * will the authors be held liable for any damages arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, including commercial * applications, and to alter it and redistribute it freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not claim that you * wrote the original software. If you use this software in a product, an acknowledgment * in the product documentation would be appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and must not be misrepresented * as being the original software. * * 3. This notice may not be removed or altered from any source distribution. * **********************************************************************************************/ #include "raylib.h" #include "screens.h" //---------------------------------------------------------------------------------- // Module Variables Definition (local) //---------------------------------------------------------------------------------- static int framesCounter = 0; static int finishScreen = 0; double scoreDeathCount = 0.0; double scoreTime = 0.0; double scoreKicks = 0.0; //---------------------------------------------------------------------------------- // Ending Screen Functions Definition //---------------------------------------------------------------------------------- // Ending Screen Initialization logic void InitEndingScreen(void) { // TODO: Initialize ENDING screen variables here! framesCounter = 0; finishScreen = 0; } // Ending Screen Update logic void UpdateEndingScreen(void) { } // Ending Screen Draw logic void DrawEndingScreen(void) { // TODO: Draw ENDING screen here! DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLACK); Vector2 pos = { 20, 20 }; DrawTextEx(font, TextFormat("DEATHS: %d", (int)scoreDeathCount), pos, font.baseSize*3, 3, DARKRED); pos.y += font.baseSize*3+10; DrawTextEx(font, TextFormat("TIME: %d seconds", (int)scoreTime), pos, font.baseSize*3, 3, DARKBLUE); pos.y += font.baseSize*3+10; DrawTextEx(font, TextFormat("KICKS: %d", (int)scoreKicks), pos, font.baseSize*3, 3, GOLD); pos.y += font.baseSize*3+10; DrawTextEx(font, TextFormat("SCORE: %d (more is better)", (int)((scoreKicks/(scoreTime*scoreDeathCount))*10000)), pos, font.baseSize*3, 3, RAYWHITE); } // Ending Screen Unload logic void UnloadEndingScreen(void) { // TODO: Unload ENDING screen variables here! } // Ending Screen should finish? int FinishEndingScreen(void) { return finishScreen; }
37.296296
153
0.59285
031e9bd0712ac84e3597e87a9beb3282c4d3d566
15,781
h
C
adium/Frameworks/Adium Framework/Source/AIContactAlertsControllerProtocol.h
sin-ivan/AdiumPipeEvent
1f3b215a07729868d25197c40200e181e06f6de5
[ "BSD-3-Clause" ]
null
null
null
adium/Frameworks/Adium Framework/Source/AIContactAlertsControllerProtocol.h
sin-ivan/AdiumPipeEvent
1f3b215a07729868d25197c40200e181e06f6de5
[ "BSD-3-Clause" ]
null
null
null
adium/Frameworks/Adium Framework/Source/AIContactAlertsControllerProtocol.h
sin-ivan/AdiumPipeEvent
1f3b215a07729868d25197c40200e181e06f6de5
[ "BSD-3-Clause" ]
null
null
null
/* * Adium is the legal property of its developers, whose names are listed in the copyright file included * with this source distribution. * * This program is free software; you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details. * * You should have received a copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #import <Adium/AIControllerProtocol.h> @class AIListObject, AIChat, AIActionDetailsPane; @protocol AIEventHandler, AIActionHandler; //Event preferences #define PREF_GROUP_CONTACT_ALERTS @"Contact Alerts" #define KEY_CONTACT_ALERTS @"Contact Alerts" #define KEY_DEFAULT_EVENT_ID @"Default Event ID" #define KEY_DEFAULT_ACTION_ID @"Default Action ID" //Event Dictionary keys #define KEY_EVENT_ID @"EventID" #define KEY_ACTION_ID @"ActionID" #define KEY_ACTION_DETAILS @"ActionDetails" #define KEY_ONE_TIME_ALERT @"OneTime" typedef enum { AIContactsEventHandlerGroup = 0, AIMessageEventHandlerGroup, AIAccountsEventHandlerGroup, AIFileTransferEventHandlerGroup, AIOtherEventHandlerGroup } AIEventHandlerGroupType; #define EVENT_HANDLER_GROUP_COUNT 5 @protocol AIContactAlertsController <AIController> /*! * @brief Register an event * * An event must have a unique eventID. handler is responsible for providing information * about the event, such as short and long descriptions. The group determines how the event will be displayed in the events * preferences; events in the same group are displayed together. * * @param eventID Unique event ID * @param handler The handler, which must conform to AIEventHandler * @param inGroup The group * @param global If YES, the event will only be displayed in the global Events preferences; if NO, the event is available for contacts and groups via Get Info, as well. */ - (void)registerEventID:(NSString *)eventID withHandler:(id <AIEventHandler>)handler inGroup:(AIEventHandlerGroupType)inGroup globalOnly:(BOOL)global; /*! * @brief Generate an event, returning a set of the actionIDs which were performed. * * This should be called when eventID occurs; it triggers all associated actions. * * @param eventID The event which occurred * @param listObject The object for which the event occurred * @param userInfo Event-specific user info * @param previouslyPerformedActionIDs If non-nil, a set of actionIDs which should be treated as if they had already been performed in this invocation. * * @result The set of actions which were performed, suitable for being passed back in for another event generation via previouslyPerformedActionIDs */ - (NSSet *)generateEvent:(NSString *)eventID forListObject:(AIListObject *)listObject userInfo:(id)userInfo previouslyPerformedActionIDs:(NSSet *)previouslyPerformedActionIDs; /*! * @brief Return all event IDs */ - (NSArray *)allEventIDs; /*! * @brief Return all event IDs for groups/contacts (but not global ones) */ - (NSArray *)nonGlobalEventIDs; /*! * @brief Returns a menu of all events * * A menu item's represented object is the dictionary describing the event it represents * * @param target The target on which @selector(selectEvent:) will be called on selection. * @param global If YES, the events listed will include global ones (such as Error Occurred) in addition to contact-specific ones. * @result An NSMenu of the events */ - (NSMenu *)menuOfEventsWithTarget:(id)target forGlobalMenu:(BOOL)global; /*! * @brief Sort an array of event IDs * * Given an array of various event IDs, this sorts them by category. * * @brief inArray The array of eventIDs to sort * @return Sorted version of inArray */ - (NSArray *)sortedArrayOfEventIDsFromArray:(NSArray *)inArray; /*! * @brief Return the default event ID for a new alert */ - (NSString *)defaultEventID; #pragma mark Descriptions /*! * @brief Find the eventID associated with an English name * * This exists for compatibility with old AdiumXtras... */ - (NSString*)eventIDForEnglishDisplayName:(NSString *)displayName; /*! * @brief Return a short description to describe eventID when considered globally */ - (NSString *)globalShortDescriptionForEventID:(NSString *)eventID; /*! * @brief Return a description to describe eventID; this is more verbose than the short description * @param listObject The object for which the eventID should be described. If nil, it will be described globally. */ - (NSString *)longDescriptionForEventID:(NSString *)eventID forListObject:(AIListObject *)listObject; /*! * @brief Return a natural language, localized description for an event * * This will be suitable for display to the user such as in a message window or a Growl notification * * @param eventID The event * @param listObject The object for which the event occurred * @param userInfo Event-specific userInfo * @param includeSubject If YES, the return value is a complete sentence. If NO, the return value is suitable for display after a name or other identifier. * @result The natural language description */ - (NSString *)naturalLanguageDescriptionForEventID:(NSString *)eventID listObject:(AIListObject *)listObject userInfo:(id)userInfo includeSubject:(BOOL)includeSubject; /*! * @brief Return the image associated with an event */ - (NSImage *)imageForEventID:(NSString *)eventID; /*! * @brief The description for multiple combined events. * * @param eventID The event * @param listObject The object for which the event references * @param chat The chat for which the event references * @param count The count of combined events * * @return The description of the event * */ - (NSString *)descriptionForCombinedEventID:(NSString *)eventID forListObject:(AIListObject *)listObject forChat:(AIChat *)chat withCount:(NSUInteger)count; #pragma mark Event types /*! * @brief Is the passed event a message event? * * Examples of messages events are "message sent" and "message received." * * @result YES if it is a message event */ - (BOOL)isMessageEvent:(NSString *)eventID; /*! * @brief Is the passed event a contact status event? * * Examples of messages events are "contact signed on" and "contact went away." * * @result YES if it is a contact status event */ - (BOOL)isContactStatusEvent:(NSString *)eventID; #pragma mark Actions /*! * @brief Register an actionID and its handler * * When an event occurs -- that is, when the event is generated via * -[id<AIContactAlertsController> generateEvent:forListObject:userInfo:] -- the handler for each action * associated with that event within the appropriate list object's heirarchy (object -> containing group -> global) * will be called as per the AIActionHandler protocol. * * @param actionID The actionID * @param handler The handler, which must conform to the AIActionHandler protocol */ - (void)registerActionID:(NSString *)actionID withHandler:(id <AIActionHandler>)handler; /*! * @brief Return a dictionary whose keys are action IDs and whose objects are objects conforming to AIActionHandler */ - (NSDictionary *)actionHandlers; /*! * @brief Returns a menu of all actions * * A menu item's represented object is the dictionary describing the action it represents * * @param target The target on which @selector(selectAction:) will be called on selection * @result The NSMenu, which does not send validateMenuItem: messages */ - (NSMenu *)menuOfActionsWithTarget:(id)target; /*! * @brief Return the default action ID for a new alert */ - (NSString *)defaultActionID; #pragma mark Alerts /*! * @brief Returns an array of all the alerts of a given list object * * This calls alertsForListObject:withEventID:actionID with nil for eventID and actionID. * * @param listObject The object */ - (NSArray *)alertsForListObject:(AIListObject *)listObject; /*! * @brief Return an array of all alerts for a list object with filtering * * @param listObject The object, or nil for global * @param eventID If specified, only return events matching eventID. If nil, don't filter based on events. * @param actionID If specified, only return actions matching actionID. If nil, don't filter based on actionID. */ - (NSArray *)alertsForListObject:(AIListObject *)listObject withEventID:(NSString *)eventID actionID:(NSString *)actionID; /*! * @brief Add an alert (passed as a dictionary) to a list object * * @param newAlert The alert to add * @param listObject The object to which to add, or nil for global * @param setAsNewDefaults YES to make the type and details of newAlert be the new default for new alerts */ - (void)addAlert:(NSDictionary *)alert toListObject:(AIListObject *)listObject setAsNewDefaults:(BOOL)setAsNewDefaults; /*! * @brief Add an alert at the global level */ - (void)addGlobalAlert:(NSDictionary *)newAlert; /*! * @brief Remove an alert from a listObject * * @param victimAlert The alert to remove; it will be tested against existing alerts using isEqual: so must be identical * @param listObject The object (or nil, for global) from which to remove victimAlert */ - (void)removeAlert:(NSDictionary *)victimAlert fromListObject:(AIListObject *)listObject; /*! * @brief Remove all current global alerts and replace them with the alerts in allGlobalAlerts * * Used for setting a preset of events */ - (void)setAllGlobalAlerts:(NSArray *)allGlobalAlerts; /*! * @brief Remove all global (root-level) alerts with a given action ID */ - (void)removeAllGlobalAlertsWithActionID:(NSString *)actionID; /*! * @brief Move all contact alerts from oldObject to newObject * * This is useful when adding oldObject to the metaContact newObject so that any existing contact alerts for oldObject * are applied at the contact-general level, displayed and handled properly for the new, combined contact. * * @param oldObject The object from which to move contact alerts * @param newObject The object to which to we want to add the moved contact alerts */ - (void)mergeAndMoveContactAlertsFromListObject:(AIListObject *)oldObject intoListObject:(AIListObject *)newObject; @end /*! * @protocol AIEventHandler * @brief Protocol for a class which posts and supplies information about an Event * * Example Events are Account Connected, Contact Signed On, New Message Received */ @protocol AIEventHandler <NSObject> /*! * @brief Short description * @result A short localized description of the passed event */ - (NSString *)shortDescriptionForEventID:(NSString *)eventID; /*! * @brief Global short description for an event * @result A short localized description of the passed event in the case that it is not associated with an object */ - (NSString *)globalShortDescriptionForEventID:(NSString *)eventID; /*! * @brief English, non-translated global short description for an event * * This exists because old X(tras) relied upon matching the description of event IDs, and I don't feel like making * a converter for old packs. If anyone wants to fix this situation, please feel free :) * * @result English global short description which should only be used internally */ - (NSString *)englishGlobalShortDescriptionForEventID:(NSString *)eventID; /*! * @brief Long description for an event * @result A localized description of an event, for listObject if passed, which is more verbose than the short description. */ - (NSString *)longDescriptionForEventID:(NSString *)eventID forListObject:(AIListObject *)listObject; /*! * @brief Natural language description for an event * * @param eventID The event identifier * @param listObject The listObject triggering the event * @param userInfo Event-specific userInfo * @param includeSubject If YES, return a full sentence. If not, return a fragment. * @result The natural language description. */ - (NSString *)naturalLanguageDescriptionForEventID:(NSString *)eventID listObject:(AIListObject *)listObject userInfo:(id)userInfo includeSubject:(BOOL)includeSubject; /*! * @brief Return an image icon for the specified eventID. */ - (NSImage *)imageForEventID:(NSString *)eventID; /*! * @brief The description for multiple combined events. * * @param eventID The event * @param listObject The object for which the event references * @param chat The chat for which the event references * @param count The count of combined events * * @return The description of the event * */ - (NSString *)descriptionForCombinedEventID:(NSString *)eventID forListObject:(AIListObject *)listObject forChat:(AIChat *)chat withCount:(NSUInteger)count; @end /*! * @protocol AIActionHandler * @brief Protocol for an Action which can be taken in response to an Event * * An action may optionally supply a details pane. If it does, it can store information in a details dictionary * which will be passed back to the action when it is triggered as well as when it is queried for a long description. * * Example Actions are Play Sound, Speak Event, Display Growl Notification */ @protocol AIActionHandler <NSObject> /*! * @brief Short description * @result A short localized description of the action */ - (NSString *)shortDescriptionForActionID:(NSString *)actionID; /*! * @brief Long description * @result A longer localized description of the action which should take into account the details dictionary as appropraite. */ - (NSString *)longDescriptionForActionID:(NSString *)actionID withDetails:(NSDictionary *)details; /*! * @brief Image */ - (NSImage *)imageForActionID:(NSString *)actionID; /*! * @brief Details pane * @result An <tt>AIActionDetailsPane</tt> to use for configuring this action, or nil if no configuration is possible. */ - (AIActionDetailsPane *)detailsPaneForActionID:(NSString *)actionID; /*! * @brief Perform an action * * @param actionID The ID of the action to perform * @param listObject The listObject associated with the event triggering the action. It may be nil * @param details If set by the details pane when the action was created, the details dictionary for this particular action * @param eventID The eventID which triggered this action * @param userInfo Additional information associated with the event; userInfo's type will vary with the actionID. * * @result YES if the action was performed successfully. If NO, other actions of the same type will be attempted even if allowMultipleActionsWithID: returns NO for eventID. */ - (BOOL)performActionID:(NSString *)actionID forListObject:(AIListObject *)listObject withDetails:(NSDictionary *)details triggeringEventID:(NSString *)eventID userInfo:(id)userInfo; /*! * @brief Allow multiple actions? * * If this method returns YES, every one of this action associated with the triggering event will be executed. * If this method returns NO, only the first will be. * * Example of relevance: An action which plays a sound may return NO so that if the user has sound actions associated * with the "Message Received (Initial)" and "Message Received" events will hear the "Message Received (Initial)" * sound [which is triggered first] and not the "Message Received" sound when an initial message is received. If this * method returned YES, both sounds would be played. */ - (BOOL)allowMultipleActionsWithID:(NSString *)actionID; @end
38.026506
182
0.753818
0370ff3a0ea00b29afb6dc2a5d20a2116c033ad0
12,640
h
C
src/qe/qe.h
abarth/z3
c8931a7bba6e9250e5c92d4c520ecfcf6a51f5d3
[ "MIT" ]
1
2021-08-13T08:20:58.000Z
2021-08-13T08:20:58.000Z
src/qe/qe.h
abarth/z3
c8931a7bba6e9250e5c92d4c520ecfcf6a51f5d3
[ "MIT" ]
null
null
null
src/qe/qe.h
abarth/z3
c8931a7bba6e9250e5c92d4c520ecfcf6a51f5d3
[ "MIT" ]
null
null
null
/*++ Copyright (c) 2010 Microsoft Corporation Module Name: qe.h Abstract: Quantifier-elimination procedures Author: Nikolaj Bjorner (nbjorner) 2010-02-19 Revision History: --*/ #ifndef QE_H_ #define QE_H_ #include "ast.h" #include "smt_params.h" #include "statistics.h" #include "lbool.h" #include "expr_functors.h" #include "simplifier.h" #include "rewriter.h" #include "model.h" #include "params.h" namespace qe { class i_nnf_atom { public: virtual void operator()(expr* e, bool pol, expr_ref& result) = 0; }; typedef obj_hashtable<app> atom_set; class qe_solver_plugin; class i_solver_context { protected: class is_relevant : public i_expr_pred { i_solver_context& m_s; public: is_relevant(i_solver_context& s):m_s(s) {} virtual bool operator()(expr* e); }; class mk_atom_fn : public i_nnf_atom { i_solver_context& m_s; public: mk_atom_fn(i_solver_context& s) : m_s(s) {} void operator()(expr* e, bool p, expr_ref& result); }; is_relevant m_is_relevant; mk_atom_fn m_mk_atom; ptr_vector<qe_solver_plugin> m_plugins; // fid -> plugin public: i_solver_context():m_is_relevant(*this), m_mk_atom(*this) {} virtual ~i_solver_context(); void add_plugin(qe_solver_plugin* p); bool has_plugin(app* x); qe_solver_plugin& plugin(app* x); qe_solver_plugin& plugin(unsigned fid) { return *m_plugins[fid]; } void mk_atom(expr* e, bool p, expr_ref& result); virtual ast_manager& get_manager() = 0; // set of atoms in current formula. virtual atom_set const& pos_atoms() const = 0; virtual atom_set const& neg_atoms() const = 0; // Access current set of variables to solve virtual unsigned get_num_vars() const = 0; virtual app* get_var(unsigned idx) const = 0; virtual app*const* get_vars() const = 0; virtual bool is_var(expr* e, unsigned& idx) const; virtual contains_app& contains(unsigned idx) = 0; // callback to replace variable at index 'idx' with definition 'def' and updated formula 'fml' virtual void elim_var(unsigned idx, expr* fml, expr* def) = 0; // callback to add new variable to branch. virtual void add_var(app* x) = 0; // callback to add constraints in branch. virtual void add_constraint(bool use_var, expr* l1 = 0, expr* l2 = 0, expr* l3 = 0) = 0; // eliminate finite domain variable 'var' from fml. virtual void blast_or(app* var, expr_ref& fml) = 0; i_expr_pred& get_is_relevant() { return m_is_relevant; } i_nnf_atom& get_mk_atom() { return m_mk_atom; } }; class conj_enum { ast_manager& m; expr_ref_vector m_conjs; public: conj_enum(ast_manager& m, expr* e); class iterator { conj_enum* m_super; unsigned m_index; public: iterator(conj_enum& c, bool first) : m_super(&c), m_index(first?0:c.m_conjs.size()) {} expr* operator*() { return m_super->m_conjs[m_index].get(); } iterator& operator++() { m_index++; return *this; } bool operator==(iterator const& it) const { return m_index == it.m_index; } bool operator!=(iterator const& it) const { return m_index != it.m_index; } }; void extract_equalities(expr_ref_vector& eqs); iterator begin() { return iterator(*this, true); } iterator end() { return iterator(*this, false); } }; // // interface for plugins to eliminate quantified variables. // class qe_solver_plugin { protected: ast_manager& m; family_id m_fid; i_solver_context& m_ctx; public: qe_solver_plugin(ast_manager& m, family_id fid, i_solver_context& ctx) : m(m), m_fid(fid), m_ctx(ctx) {} virtual ~qe_solver_plugin() {} family_id get_family_id() { return m_fid; } /** \brief Return number of case splits for variable x in fml. */ virtual bool get_num_branches(contains_app& x, expr* fml, rational& num_branches) = 0; /** \brief Given a case split index 'vl' assert the constraints associated with it. */ virtual void assign(contains_app& x, expr* fml, rational const& vl) = 0; /** \brief The case splits associated with 'vl' are satisfiable. Apply the elimination for fml corresponding to case split. If def is non-null, then retrieve the realizer corresponding to the case split. */ virtual void subst(contains_app& x, rational const& vl, expr_ref& fml, expr_ref* def) = 0; /** \brief solve quantified variable. */ virtual bool solve(conj_enum& conjs, expr* fml) = 0; /** \brief project variable x for fml given model. Assumption: model |= fml[x] Projection updates fml to fml', such that: - fml' -> fml - model |= fml' - fml' does not contain x return false if the method is not implemented. */ virtual bool project(contains_app& x, model_ref& model, expr_ref& fml) { return false; } /** \brief assign branching penalty to variable x for 'fml'. */ virtual unsigned get_weight(contains_app& x, expr* fml) { return UINT_MAX; } /** \brief simplify formula. */ virtual bool simplify(expr_ref& fml) { return false; } /** \brief Normalize literal during NNF conversion. */ virtual bool mk_atom(expr* e, bool p, expr_ref& result) { return false; } /** \brief Determine whether sub-term is uninterpreted with respect to quantifier elimination. */ virtual bool is_uninterpreted(app* f) { return true; } }; qe_solver_plugin* mk_datatype_plugin(i_solver_context& ctx); qe_solver_plugin* mk_bool_plugin(i_solver_context& ctx); qe_solver_plugin* mk_bv_plugin(i_solver_context& ctx); qe_solver_plugin* mk_dl_plugin(i_solver_context& ctx); qe_solver_plugin* mk_array_plugin(i_solver_context& ctx); qe_solver_plugin* mk_arith_plugin(i_solver_context& ctx, bool produce_models, smt_params& p); class def_vector { func_decl_ref_vector m_vars; expr_ref_vector m_defs; def_vector& operator=(def_vector const& other); public: def_vector(ast_manager& m): m_vars(m), m_defs(m) {} def_vector(def_vector const& other): m_vars(other.m_vars), m_defs(other.m_defs) {} void push_back(func_decl* v, expr* e) { m_vars.push_back(v); m_defs.push_back(e); } void reset() { m_vars.reset(); m_defs.reset(); } void append(def_vector const& o) { m_vars.append(o.m_vars); m_defs.append(o.m_defs); } unsigned size() const { return m_defs.size(); } void shrink(unsigned sz) { m_vars.shrink(sz); m_defs.shrink(sz); } bool empty() const { return m_defs.empty(); } func_decl* var(unsigned i) const { return m_vars[i]; } expr* def(unsigned i) const { return m_defs[i]; } expr_ref_vector::element_ref def_ref(unsigned i) { return m_defs[i]; } void normalize(); void project(unsigned num_vars, app* const* vars); }; /** \brief Guarded definitions. A realizer to a an existential quantified formula is a disjunction together with a substitution from the existentially quantified variables to terms such that: 1. The original formula (exists (vars) fml) is equivalent to the disjunction of guards. 2. Each guard is equivalent to fml where 'vars' are replaced by the substitution associated with the guard. */ class guarded_defs { expr_ref_vector m_guards; vector<def_vector> m_defs; bool inv(); public: guarded_defs(ast_manager& m): m_guards(m) { SASSERT(inv()); } void add(expr* guard, def_vector const& defs); unsigned size() const { return m_guards.size(); } def_vector const& defs(unsigned i) const { return m_defs[i]; } expr* guard(unsigned i) const { return m_guards[i]; } std::ostream& display(std::ostream& out) const; void project(unsigned num_vars, app* const* vars); }; class quant_elim; class expr_quant_elim { ast_manager& m; smt_params const& m_fparams; params_ref m_params; expr_ref_vector m_trail; obj_map<expr,expr*> m_visited; quant_elim* m_qe; expr* m_assumption; public: expr_quant_elim(ast_manager& m, smt_params const& fp, params_ref const& p = params_ref()); ~expr_quant_elim(); void operator()(expr* assumption, expr* fml, expr_ref& result); void collect_statistics(statistics & st) const; void updt_params(params_ref const& p); void collect_param_descrs(param_descrs& r); /** \brief try to eliminate 'vars' and find first satisfying assignment. return l_true if satisfiable, l_false if unsatisfiable, l_undef if the formula could not be satisfied modulo eliminating the quantified variables. */ lbool first_elim(unsigned num_vars, app* const* vars, expr_ref& fml, def_vector& defs); /** \brief solve for (exists (var) fml). Return false if operation failed. Return true and list of pairs (t_i, fml_i) in <terms, fmls> such that fml_1 \/ ... \/ fml_n == (exists (var) fml) and fml_i => fml[t_i] */ bool solve_for_var(app* var, expr* fml, guarded_defs& defs); bool solve_for_vars(unsigned num_vars, app* const* vars, expr* fml, guarded_defs& defs); private: void instantiate_expr(expr_ref_vector& bound, expr_ref& fml); void abstract_expr(unsigned sz, expr* const* bound, expr_ref& fml); void elim(expr_ref& result); void init_qe(); }; class expr_quant_elim_star1 : public simplifier { protected: expr_quant_elim m_quant_elim; expr* m_assumption; virtual bool visit_quantifier(quantifier * q); virtual void reduce1_quantifier(quantifier * q); virtual bool is_target(quantifier * q) const { return q->get_num_patterns() == 0 && q->get_num_no_patterns() == 0; } public: expr_quant_elim_star1(ast_manager & m, smt_params const& p); virtual ~expr_quant_elim_star1() {} void collect_statistics(statistics & st) const { m_quant_elim.collect_statistics(st); } void reduce_with_assumption(expr* ctx, expr* fml, expr_ref& result); lbool first_elim(unsigned num_vars, app* const* vars, expr_ref& fml, def_vector& defs) { return m_quant_elim.first_elim(num_vars, vars, fml, defs); } }; void hoist_exists(expr_ref& fml, app_ref_vector& vars); void mk_exists(unsigned num_vars, app* const* vars, expr_ref& fml); void get_nnf(expr_ref& fml, i_expr_pred& pred, i_nnf_atom& mk_atom, atom_set& pos, atom_set& neg); class simplify_rewriter_cfg : public default_rewriter_cfg { class impl; impl* imp; public: simplify_rewriter_cfg(ast_manager& m); ~simplify_rewriter_cfg(); bool reduce_quantifier( quantifier * old_q, expr * new_body, expr * const * new_patterns, expr * const * new_no_patterns, expr_ref & result, proof_ref & result_pr); bool pre_visit(expr* e); void updt_params(params_ref const& p); }; class simplify_rewriter_star : public rewriter_tpl<simplify_rewriter_cfg> { simplify_rewriter_cfg m_cfg; public: simplify_rewriter_star(ast_manager& m): rewriter_tpl<simplify_rewriter_cfg>(m, false, m_cfg), m_cfg(m) {} void updt_params(params_ref const& p) { m_cfg.updt_params(p); } }; }; #endif
32.493573
124
0.603006
d8052f9d3a0ca12854d0659cf57420e3744812c0
3,483
h
C
Transmitters/Old Version/X_CTRL_STM32F10x/RC_CTRL_II_v4.5/USER/Basic/RC_Protocol.h
FASTSHIFT/X-CTRL
683ffe3b40222e1da6ff156b6595c691cd09fec1
[ "MIT" ]
181
2019-09-20T15:49:09.000Z
2022-03-23T01:27:29.000Z
Transmitters/Old Version/X_CTRL_STM32F10x/RC_CTRL_II_v4.5/USER/Basic/RC_Protocol.h
DogDod/X-CTRL
683ffe3b40222e1da6ff156b6595c691cd09fec1
[ "MIT" ]
null
null
null
Transmitters/Old Version/X_CTRL_STM32F10x/RC_CTRL_II_v4.5/USER/Basic/RC_Protocol.h
DogDod/X-CTRL
683ffe3b40222e1da6ff156b6595c691cd09fec1
[ "MIT" ]
75
2019-10-25T02:53:27.000Z
2022-03-23T01:25:00.000Z
/** @Author: _VIFEXTech * @Describe: 通用的遥控协议 * @Finished: UNKNOWTIME - v1.0 能用了 * @Upgrade: UNKNOWTIME - v1.1 改了一些结构体 * @Upgrade: 2018.12.25 - v1.2 去除TimePoint_Tran, 添加握手协议与时钟基准 * @Upgrade: 2018.12.26 - v1.3 握手协议调试成功 * @Upgrade: 2019.2.13 - v1.4 使用单字节对齐,保证跨平台兼容性 */ #ifndef __RC_PROTOCOL_H #define __RC_PROTOCOL_H #define _RC_PROTOCOL_VERSION "v1.4" #include "stdint.h" #include "binary.h" #ifdef __cplusplus extern "C" { #endif #define CtrlOutput_MaxValue 1000 #pragma pack (1) /********** Enum **********/ typedef enum { X_COMMON, CAR_DifferentalSteering, CAR_ServoSteering } CtrlObject_Type; typedef enum { Pattern_NRF, //Pattern_USART } Pattern_Type; typedef enum { CtrlMode_Tank, CtrlMode_Race, CtrlMode_Expert } CtrlMode_Type; typedef enum { BT_UP = B00000001, BT_DOWN = B00000010, BT_LEFT = B00000100, BT_RIGHT = B00001000, BT_L1 = B00010000, BT_L2 = B00100000, BT_R1 = B01000000, BT_R2 = B10000000 } KeyValue_t; #define BT_OK BT_RIGHT #define BT_BACK BT_LEFT typedef enum { CMD_AgreeConnect = 1, CMD_AttachConnect, CMD_Disconnect, CMD_ReqConnect }Commond_Type; typedef enum { HandshakeState_Prepare, HandshakeState_Search, HandshakeState_ReqConnect, HandshakeState_ReConnect, HandshakeState_Connected }HandshakeState_Type; /********** Basic Struct **********/ typedef struct { int16_t Min; int16_t Mid; int16_t Max; } Calibrat_t; typedef struct { int16_t X; int16_t Xmin; int16_t Xmid; int16_t Xmax; int16_t Y; int16_t Ymin; int16_t Ymid; int16_t Ymax; } Joystick_t; typedef struct { uint8_t CtrlObject; uint8_t CtrlMode; uint8_t DataPackage_Num; } RC_Info_t; typedef struct { int16_t X; int16_t Y; } Axis_t; typedef struct { int16_t L; int16_t R; } Direction_t; /********** Protocol Struct **********/ #define FreqList_Length 10 typedef struct{ uint16_t HeadCode; uint8_t ID; char Description[10]; uint8_t CtrlType; bool SupportPassback; uint8_t Commond; uint8_t Speed; uint8_t Address[5]; uint8_t FerqList[FreqList_Length]; }Protocol_Handshake_t; typedef struct { RC_Info_t Info; uint8_t Key; Direction_t KnobLimit; Direction_t KnobCab; Direction_t MotorSpeed; uint32_t ReferenceClock; } Protocol_CarDS_t; typedef struct { RC_Info_t Info; uint8_t Key; Direction_t KnobLimit; Direction_t KnobCab; int16_t MotorSpeed; int16_t SteerAngle; uint32_t ReferenceClock; } Protocol_CarSS_t; typedef struct { RC_Info_t Info; uint8_t Key; Direction_t KnobLimit; Direction_t KnobCab; Axis_t Left; Axis_t Right; uint32_t ReferenceClock; } Protocol_Common_t; typedef struct { float Channel_1; float Channel_2; float Channel_3; float Channel_4; float Channel_5; float Channel_6; float Channel_7; float Channel_8; } Protocol_Passback_8xChannel_t; typedef struct { uint8_t X; uint8_t Y; uint8_t TextSize; uint16_t TextColor; uint16_t BackColor; char Text[32 - 3 * sizeof(uint8_t) - 2 * sizeof(uint16_t)]; } Protocol_Passback_CommonDisplay_t; /********** State **********/ typedef struct { bool IsConnect; bool IsCorrect; uint8_t Pattern; uint32_t TimePoint_Recv; } ConnectState_t; #pragma pack () #ifdef __cplusplus }// extern "C" #endif #endif
18.235602
63
0.672696
9cb3b34e660448eb865fa235247489a8662ebdae
3,051
c
C
windows/pw5e.official/Chap16/AllColor/AllColor.c
nnaabbcc/exercise
255fd32b39473b3d0e7702d4b1a8a97bed2a68f8
[ "MIT" ]
1
2016-11-23T08:18:08.000Z
2016-11-23T08:18:08.000Z
windows/pw5e.official/Chap16/AllColor/AllColor.c
nnaabbcc/exercise
255fd32b39473b3d0e7702d4b1a8a97bed2a68f8
[ "MIT" ]
null
null
null
windows/pw5e.official/Chap16/AllColor/AllColor.c
nnaabbcc/exercise
255fd32b39473b3d0e7702d4b1a8a97bed2a68f8
[ "MIT" ]
1
2016-11-23T08:17:34.000Z
2016-11-23T08:17:34.000Z
/*----------------------------------------- ALLCOLOR.C -- Palette Animation Demo (c) Charles Petzold, 1998 -----------------------------------------*/ #include <windows.h> #define ID_TIMER 1 TCHAR szAppName [] = TEXT ("AllColor") ; TCHAR szTitle [] = TEXT ("AllColor: Palette Animation Demo") ; static int iIncr ; static PALETTEENTRY pe ; HPALETTE CreateRoutine (HWND hwnd) { HDC hdc ; HPALETTE hPalette ; LOGPALETTE lp ; // Determine the color resolution and set iIncr hdc = GetDC (hwnd) ; iIncr = 1 << (8 - GetDeviceCaps (hdc, COLORRES) / 3) ; ReleaseDC (hwnd, hdc) ; // Create the logical palette lp.palVersion = 0x0300 ; lp.palNumEntries = 1 ; lp.palPalEntry[0].peRed = 0 ; lp.palPalEntry[0].peGreen = 0 ; lp.palPalEntry[0].peBlue = 0 ; lp.palPalEntry[0].peFlags = PC_RESERVED ; hPalette = CreatePalette (&lp) ; // Save global for less typing pe = lp.palPalEntry[0] ; SetTimer (hwnd, ID_TIMER, 10, NULL) ; return hPalette ; } void DisplayRGB (HDC hdc, PALETTEENTRY * ppe) { TCHAR szBuffer [16] ; wsprintf (szBuffer, TEXT (" %02X-%02X-%02X "), ppe->peRed, ppe->peGreen, ppe->peBlue) ; TextOut (hdc, 0, 0, szBuffer, lstrlen (szBuffer)) ; } void PaintRoutine (HDC hdc, int cxClient, int cyClient) { HBRUSH hBrush ; RECT rect ; // Draw Palette Index 0 on entire window hBrush = CreateSolidBrush (PALETTEINDEX (0)) ; SetRect (&rect, 0, 0, cxClient, cyClient) ; FillRect (hdc, &rect, hBrush) ; DeleteObject (SelectObject (hdc, GetStockObject (WHITE_BRUSH))) ; // Display the RGB value DisplayRGB (hdc, &pe) ; return ; } void TimerRoutine (HDC hdc, HPALETTE hPalette) { static BOOL bRedUp = TRUE, bGreenUp = TRUE, bBlueUp = TRUE ; // Define new color value pe.peBlue += (bBlueUp ? iIncr : -iIncr) ; if (pe.peBlue == (BYTE) (bBlueUp ? 0 : 256 - iIncr)) { pe.peBlue = (bBlueUp ? 256 - iIncr : 0) ; bBlueUp ^= TRUE ; pe.peGreen += (bGreenUp ? iIncr : -iIncr) ; if (pe.peGreen == (BYTE) (bGreenUp ? 0 : 256 - iIncr)) { pe.peGreen = (bGreenUp ? 256 - iIncr : 0) ; bGreenUp ^= TRUE ; pe.peRed += (bRedUp ? iIncr : -iIncr) ; if (pe.peRed == (BYTE) (bRedUp ? 0 : 256 - iIncr)) { pe.peRed = (bRedUp ? 256 - iIncr : 0) ; bRedUp ^= TRUE ; } } } // Animate the palette AnimatePalette (hPalette, 0, 1, &pe) ; DisplayRGB (hdc, &pe) ; return ; } void DestroyRoutine (HWND hwnd, HPALETTE hPalette) { KillTimer (hwnd, ID_TIMER) ; DeleteObject (hPalette) ; return ; }
26.301724
71
0.50213
6c65a7f1a9da6570a4fa4aa3f36c58af5c99e967
3,202
h
C
Code/Editor/TrackView/TrackViewSequenceManager.h
BreakerOfThings/o3de
f4c59f868c726470ec910623facd836047d059c3
[ "Apache-2.0", "MIT" ]
11
2021-07-08T09:58:26.000Z
2022-03-17T17:59:26.000Z
Code/Editor/TrackView/TrackViewSequenceManager.h
BreakerOfThings/o3de
f4c59f868c726470ec910623facd836047d059c3
[ "Apache-2.0", "MIT" ]
29
2021-07-06T19:33:52.000Z
2022-03-22T10:27:49.000Z
Code/Editor/TrackView/TrackViewSequenceManager.h
BreakerOfThings/o3de
f4c59f868c726470ec910623facd836047d059c3
[ "Apache-2.0", "MIT" ]
4
2021-07-06T19:24:43.000Z
2022-03-31T12:42:27.000Z
/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #ifndef CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWSEQUENCEMANAGER_H #define CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWSEQUENCEMANAGER_H #pragma once #include "TrackViewSequence.h" #include <AzCore/Component/EntityBus.h> class CTrackViewSequenceManager : public IEditorNotifyListener , public ITrackViewSequenceManager , public AZ::EntitySystemBus::Handler { public: CTrackViewSequenceManager(); ~CTrackViewSequenceManager(); void OnEditorNotifyEvent(EEditorNotifyEvent event) override; unsigned int GetCount() const { return static_cast<int>(m_sequences.size()); } void CreateSequence(QString name, SequenceType sequenceType); void DeleteSequence(CTrackViewSequence* pSequence); void RenameNode(CTrackViewAnimNode* pAnimNode, const char* newName) const; CTrackViewSequence* GetSequenceByName(QString name) const override; CTrackViewSequence* GetSequenceByEntityId(const AZ::EntityId& entityId) const override; CTrackViewSequence* GetSequenceByIndex(unsigned int index) const; CTrackViewSequence* GetSequenceByAnimSequence(IAnimSequence* pAnimSequence) const; CTrackViewAnimNodeBundle GetAllRelatedAnimNodes(AZ::EntityId entityId) const; CTrackViewAnimNode* GetActiveAnimNode(AZ::EntityId entityId) const; void AddListener(ITrackViewSequenceManagerListener* pListener) { stl::push_back_unique(m_listeners, pListener); } void RemoveListener(ITrackViewSequenceManagerListener* pListener) { stl::find_and_erase(m_listeners, pListener); } // ITrackViewSequenceManager Overrides // Callback from SequenceObject IAnimSequence* OnCreateSequenceObject(QString name, bool isLegacySequence = true, AZ::EntityId entityId = AZ::EntityId()) override; void OnDeleteSequenceEntity(const AZ::EntityId& entityId) override; void OnCreateSequenceComponent(AZStd::intrusive_ptr<IAnimSequence>& sequence) override; void OnSequenceActivated(const AZ::EntityId& entityId) override; //~ ITrackViewSequenceManager Overrides private: void AddTrackViewSequence(CTrackViewSequence* sequenceToAdd); void RemoveSequenceInternal(CTrackViewSequence* sequence); void SortSequences(); void ResumeAllSequences(); void OnSequenceAdded(CTrackViewSequence* pSequence); void OnSequenceRemoved(CTrackViewSequence* pSequence); // AZ::EntitySystemBus void OnEntityNameChanged(const AZ::EntityId& entityId, const AZStd::string& name) override; void OnEntityDestruction(const AZ::EntityId& entityId) override; std::vector<ITrackViewSequenceManagerListener*> m_listeners; std::vector<std::unique_ptr<CTrackViewSequence> > m_sequences; // Set to hold sequences that existed when undo transaction began std::set<CTrackViewSequence*> m_transactionSequences; bool m_bUnloadingLevel; // Used to handle object attach/detach std::unordered_map<CTrackViewNode*, Matrix34> m_prevTransforms; }; #endif // CRYINCLUDE_EDITOR_TRACKVIEW_TRACKVIEWSEQUENCEMANAGER_H
39.04878
135
0.788882
88dc43fe81b95f48300bc6b333c5697d1ca27f20
7,018
h
C
src/util/constdualmap.h
PhDP/alchemy2
fd6291ab23bc3fb3848d6c301ff63f82fe5377b9
[ "MIT" ]
21
2015-07-13T19:56:45.000Z
2021-11-09T17:25:39.000Z
src/util/constdualmap.h
PhDP/alchemy2
fd6291ab23bc3fb3848d6c301ff63f82fe5377b9
[ "MIT" ]
1
2017-01-14T16:12:26.000Z
2017-01-14T17:17:44.000Z
src/util/constdualmap.h
PhDP/alchemy2
fd6291ab23bc3fb3848d6c301ff63f82fe5377b9
[ "MIT" ]
9
2015-09-27T16:51:31.000Z
2020-12-15T10:09:05.000Z
/* * All of the documentation and software included in the * Alchemy Software is copyrighted by Stanley Kok, Parag * Singla, Matthew Richardson, Pedro Domingos, Marc * Sumner, Hoifung Poon, Daniel Lowd, and Jue Wang. * * Copyright [2004-09] Stanley Kok, Parag Singla, Matthew * Richardson, Pedro Domingos, Marc Sumner, Hoifung * Poon, Daniel Lowd, and Jue Wang. All rights reserved. * * Contact: Pedro Domingos, University of Washington * (pedrod@cs.washington.edu). * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that * the following conditions are met: * * 1. Redistributions of source code must retain the above * copyright notice, this list of conditions and the * following disclaimer. * * 2. Redistributions in binary form must reproduce the * above copyright notice, this list of conditions and the * following disclaimer in the documentation and/or other * materials provided with the distribution. * * 3. All advertising materials mentioning features or use * of this software must display the following * acknowledgment: "This product includes software * developed by Stanley Kok, Parag Singla, Matthew * Richardson, Pedro Domingos, Marc Sumner, Hoifung * Poon, Daniel Lowd, and Jue Wang in the Department of * Computer Science and Engineering at the University of * Washington". * * 4. Your publications acknowledge the use or * contribution made by the Software to your research * using the following citation(s): * Stanley Kok, Parag Singla, Matthew Richardson and * Pedro Domingos (2005). "The Alchemy System for * Statistical Relational AI", Technical Report, * Department of Computer Science and Engineering, * University of Washington, Seattle, WA. * http://alchemy.cs.washington.edu. * * 5. Neither the name of the University of Washington nor * the names of its contributors may be used to endorse or * promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF WASHINGTON * AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY * OF WASHINGTON OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifndef CONSTDUALMAP_H_JUN_21_2005 #define CONSTDUALMAP_H_JUN_21_2005 #include <limits> #include <ext/hash_map> //using namespace __gnu_cxx; #include "array.h" #include "strint.h" // StrInt stores the constant name & its type id typedef hash_map<const StrInt*, int, HashStrInt, EqualStrInt> StrIntToIntMap; // Maps int to StrInt* and vice versa. class ConstDualMap { public: ConstDualMap() { intToStrIntArr_ = new Array<const StrInt*>; strIntToIntMap_ = new StrIntToIntMap; } ~ConstDualMap() { for (int i = 0; i < intToStrIntArr_->size(); i++) delete (*intToStrIntArr_)[i]; delete intToStrIntArr_; delete strIntToIntMap_; } // Returns const char* corresponding to i or NULL if there is no such char*. // The returned const char* should not be deleted. const char* getStr(const int& i) { if (0 <= i && i < intToStrIntArr_->size()) return (*intToStrIntArr_)[i]->str_; return NULL; } // Returns the ints_ of StrInt corresponding to i; returns NULL if there is // no such StrInt. Should not be deleted by caller. Array<int>* getInt2(const int& i) { if (0 <= i && i < intToStrIntArr_->size()) return (*intToStrIntArr_)[i]->ints_; return NULL; } // Returns the ints_ of StrInt corresponding to i; returns NULL if there is // no such StrInt. Caller should delete s if required, but not returned Array. Array<int>* getInt2(const char* const & s) { int i = getInt(s); if (i < 0) return NULL; return getInt2(i); } // Returns int corresponding to str or -1 if there is no such str. // Caller should delete s if required. // Making this function const causes the compiler to complain. int getInt(const char* const & s) { StrInt str(s); StrIntToIntMap::iterator it; if ((it=strIntToIntMap_->find(&str)) == strIntToIntMap_->end()) return -1; return (*it).second; } // Returns corresponding int (which increases by one each time addType() is // called), or -1 is str has been added before. // Caller should delete s if required. int insert(const char* const & s, const int& ii) { // See if string already present Array<int>* oldInts = getInt2(s); if (oldInts != NULL) { if (!oldInts->contains(ii)) oldInts->append(ii); StrInt str(s); StrIntToIntMap::iterator it; it = strIntToIntMap_->find(&str); return (*it).second; } StrInt* strInt = new StrInt(s,ii); StrIntToIntMap::iterator it; if ((it=strIntToIntMap_->find(strInt)) != strIntToIntMap_->end()) { cout << "Warning: In ConstDualMap::insert(), tried to insert duplicate " << strInt->str_ << ", prev id " << (*it).second << endl; delete strInt; return -1; } if (((int)intToStrIntArr_->size()) >= numeric_limits<int>::max()) { cout << "Error: In ConstDualMap::insert(), reach int max limit when " << "inserting " << strInt->str_ << endl; delete strInt; exit(-1); } intToStrIntArr_->append(strInt); int i = intToStrIntArr_->size()-1; (*strIntToIntMap_)[strInt] = i; return i; } int getNumInt() const { return intToStrIntArr_->size(); } // Caller should not delete the returned Array<StrInt*>*. const Array<const StrInt*>* getIntToStrIntArr() const { return intToStrIntArr_; } // Caller should delete the returned Array<const char*>* but not its // contents const Array<const char*>* getIntToStrArr() const { Array<const char*>* a = new Array<const char*>; for (int i = 0; i < intToStrIntArr_->size(); i++) a->append((*intToStrIntArr_)[i]->str_); return a; } // Caller should delete the returned Array<int>*. /* const Array<int>* getIntToInt2Arr() const { Array<int>* a = new Array<int>; for (int i = 0; i < intToStrIntArr_->size(); i++) a->append((*intToStrIntArr_)[i]->int_); return a; } */ void compress() { intToStrIntArr_->compress(); } private: Array<const StrInt*>* intToStrIntArr_; StrIntToIntMap* strIntToIntMap_; }; #endif
31.330357
82
0.679966
18484eeb127117701f03e31ea5a1293b0ed1824e
925
h
C
swift_two/swift_two/Classes/Others/ShareSDK/Support/Optional/ShareSDKUI.framework/Headers/SSUIShareActionSheetController.h
oceanfive/swift
32c71ec0d25ab8742accc53f8aa5b72707ff35ab
[ "MIT" ]
475
2015-11-12T09:07:20.000Z
2021-11-17T04:24:43.000Z
swift_two/swift_two/Classes/Others/ShareSDK/Support/Optional/ShareSDKUI.framework/Headers/SSUIShareActionSheetController.h
oceanfive/swift
32c71ec0d25ab8742accc53f8aa5b72707ff35ab
[ "MIT" ]
8
2016-05-20T18:18:38.000Z
2019-11-27T03:06:49.000Z
swift_two/swift_two/Classes/Others/ShareSDK/Support/Optional/ShareSDKUI.framework/Headers/SSUIShareActionSheetController.h
oceanfive/swift
32c71ec0d25ab8742accc53f8aa5b72707ff35ab
[ "MIT" ]
293
2015-11-23T06:47:55.000Z
2022-02-13T11:54:11.000Z
// // SSUIShareActionSheet.h // ShareSDKUI // // Created by 刘 靖煌 on 15/6/18. // Copyright (c) 2015年 mob. All rights reserved. // #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import "SSUITypeDef.h" /** * 分享菜单 */ @interface SSUIShareActionSheetController : NSObject /** * 支持点击分享菜单栏平台后直接分享的平台(不显示分享编辑页面),默认支持微信和QQ平台。 */ @property (nonatomic, strong) NSMutableSet *directSharePlatforms; /** * 初始化分享菜单 * * @param items 菜单项集合 * * @return 分享菜单控制器对象 */ - (instancetype)initWithItems:(NSArray *)items; /** * 显示分享菜单 * * @param view 要显示菜单的视图 */ - (void)showInView:(UIView *)view; /** * 使分享菜单消失 */ - (void)dismiss; /** * 菜单项点击事件 * * @param itemClickHandler 菜单项点击事件处理器 */ - (void)onItemClick:(SSUIShareActionSheetItemClickHandler)itemClickHandler; /** * 分享菜单取消事件 * * @param cancelHandler 取消事件处理器 */ - (void)onCancel:(SSUIShareActionSheetCancelHandler)cancelHandler; @end
15.677966
75
0.681081
1885570ed3e071d821628b8ecdd333fd655f775f
2,377
h
C
src/src/lib/geneial/core/operations/replacement/BaseReplacementOperation.h
geneial/geneial
5e525c32b7c1e1e88788644e448e9234c93b55e2
[ "MIT" ]
5
2015-08-25T15:40:09.000Z
2020-03-15T19:33:22.000Z
src/src/lib/geneial/core/operations/replacement/BaseReplacementOperation.h
geneial/geneial
5e525c32b7c1e1e88788644e448e9234c93b55e2
[ "MIT" ]
null
null
null
src/src/lib/geneial/core/operations/replacement/BaseReplacementOperation.h
geneial/geneial
5e525c32b7c1e1e88788644e448e9234c93b55e2
[ "MIT" ]
3
2019-01-24T13:14:51.000Z
2022-01-03T07:30:20.000Z
#pragma once #include <geneial/namespaces.h> #include <geneial/core/operations/replacement/BaseReplacementSettings.h> #include <geneial/core/population/management/BaseManager.h> #include <geneial/core/population/Population.h> geneial_private_namespace(geneial) { geneial_private_namespace(operation) { geneial_private_namespace(replacement) { using ::geneial::population::Population; using ::geneial::operation::crossover::BaseCrossoverOperation; using ::geneial::operation::selection::BaseSelectionOperation; using ::geneial::population::management::BaseManager; using ::geneial::utility::Buildable; geneial_export_namespace { template<typename FITNESS_TYPE> class BaseReplacementOperation : public Buildable<BaseReplacementOperation<FITNESS_TYPE>> { protected: std::shared_ptr<const BaseReplacementSettings> _settings; public: using ptr = std::shared_ptr<BaseReplacementOperation<FITNESS_TYPE>>; using const_ptr = std::shared_ptr<BaseReplacementOperation<FITNESS_TYPE>>; explicit BaseReplacementOperation(const std::shared_ptr<const BaseReplacementSettings> &settings) : _settings(settings) { } virtual ~BaseReplacementOperation() { } virtual void doReplace(Population<FITNESS_TYPE> &population, const typename selection::BaseSelectionOperation<FITNESS_TYPE>::selection_result_set &parents, typename coupling::BaseCouplingOperation<FITNESS_TYPE>::offspring_result_set &offspring, BaseManager<FITNESS_TYPE> &manager) const = 0; const BaseReplacementSettings& getSettings() const { return *_settings; } void setSettings(const BaseReplacementSettings& settings) { _settings = settings; } class Builder : public Buildable<BaseReplacementOperation<FITNESS_TYPE>>::Builder { protected: std::shared_ptr<BaseReplacementSettings> _settings; public: Builder():_settings(new BaseReplacementSettings) { } BaseReplacementSettings& getSettings() { return *_settings; } void setSettings(const std::shared_ptr<BaseReplacementSettings>& settings) { _settings = settings; } }; }; } /* geneial_export_namespace */ } /* private namespace replacement */ } /* private namespace operation */ } /* private namespace geneial */
27.321839
106
0.725284
e4907493d61d49646d89230720a64a0ecc4e5359
272
h
C
project2D/ComponentIncludes.h
deadglow/AIE-AI-Assessment
c010dadb55b1c7152f983d11868055e275c42b42
[ "MIT" ]
null
null
null
project2D/ComponentIncludes.h
deadglow/AIE-AI-Assessment
c010dadb55b1c7152f983d11868055e275c42b42
[ "MIT" ]
null
null
null
project2D/ComponentIncludes.h
deadglow/AIE-AI-Assessment
c010dadb55b1c7152f983d11868055e275c42b42
[ "MIT" ]
null
null
null
#pragma once //Lis of all components #include "Component.h" #include "Transform.h" #include "Sprite.h" #include "ColliderPolygon.h" #include "ColliderBox.h" #include "ColliderCircle.h" #include "PhysObject.h" #include "Player.h" #include "AIAgent.h" #include "Throwable.h"
22.666667
28
0.75
c4637fefc42bfb34ece14820d0c96cc93efed4e8
32,911
h
C
src/ff7.h
Tsunamods/FFNx
46652a1e6184fbe7b058fdc8bdaa45867c345bba
[ "MIT" ]
null
null
null
src/ff7.h
Tsunamods/FFNx
46652a1e6184fbe7b058fdc8bdaa45867c345bba
[ "MIT" ]
null
null
null
src/ff7.h
Tsunamods/FFNx
46652a1e6184fbe7b058fdc8bdaa45867c345bba
[ "MIT" ]
null
null
null
/* * FFNx - Complete OpenGL replacement of the Direct3D renderer used in * the original ports of Final Fantasy VII and Final Fantasy VIII for the PC. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* * ff7.h - data structures and functions used internally by FF7 */ #pragma once #include <ddraw.h> #include <stdio.h> #include "types.h" #include "common.h" #include "matrix.h" /* * Primitive types supported by the engine, mostly a 1:1 mapping to PSX GPU * capabilities. * * Key: * T/S/L - triangle/square(quad)/line * F/G - flat/gouraud * T - textured * 2D/3D - self explanatory except 2D means no transforms at all, billboard sprites etc are still "3D" */ enum polygon_types { PT_TF2D = 0, PT_TF3D, PT_TG2D, PT_TG3D, PT_T2D, PT_T3D, PT_TGT2D, PT_TGT3D, PT_SF2D, PT_SF3D, PT_SG2D, PT_SG3D, PT_S2D, PT_S3D, PT_SGT2D, PT_SGT3D, polygon_type_10, polygon_type_11, PT_LF2D, PT_L2D, }; // FF7 modules, unknowns are either unused or not relevant to rendering enum ff7_game_modes { FF7_MODE_FIELD = 1, FF7_MODE_BATTLE, FF7_MODE_WORLDMAP, FF7_MODE_UNKNOWN4, FF7_MODE_MENU, FF7_MODE_HIGHWAY, FF7_MODE_CHOCOBO, FF7_MODE_SNOWBOARD, FF7_MODE_CONDOR, FF7_MODE_SUBMARINE, FF7_MODE_COASTER, FF7_MODE_CDCHECK, FF7_MODE_UNKNOWN13, FF7_MODE_SNOWBOARD2, FF7_MODE_UNKNOWN15, FF7_MODE_UNKNOWN16, FF7_MODE_BATTLE_MENU, FF7_MODE_UNKNOWN18, FF7_MODE_EXIT, FF7_MODE_MAIN_MENU, FF7_MODE_UNKNOWN21, FF7_MODE_UNKNOWN22, FF7_MODE_SWIRL, FF7_MODE_UNKNOWN24, FF7_MODE_UNKNOWN25, FF7_MODE_GAMEOVER, FF7_MODE_CREDITS, FF7_MODE_UNKNOWN28, }; // 3D model flags enum model_modes { MDL_ROOT_ROTATION = 0x0001, MDL_ROOT_ROTATION_NEGX = 0x0002, MDL_ROOT_ROTATION_NEGY = 0x0004, MDL_ROOT_ROTATION_NEGZ = 0x0008, MDL_ROOT_TRANSLATION = 0x0010, MDL_ROOT_TRANSLATION_NEGX = 0x0020, MDL_ROOT_TRANSLATION_NEGY = 0x0040, MDL_ROOT_TRANSLATION_NEGZ = 0x0080, MDL_USE_STRUC110_MATRIX = 0x4000, MDL_USE_CAMERA_MATRIX = 0x8000, }; // internal structure for menu sprites (global values, may not be a structure at all) struct menu_objects { struct ff7_graphics_object *unknown1; struct ff7_graphics_object *unused; struct ff7_graphics_object *btl_win_a; struct ff7_graphics_object *btl_win_b; struct ff7_graphics_object *btl_win_c; struct ff7_graphics_object *btl_win_d; struct ff7_graphics_object *_btl_win; struct ff7_graphics_object *blend_btl_win_a; struct ff7_graphics_object *add_btl_win_a; struct ff7_graphics_object *add_btl_win_b; struct ff7_graphics_object *add_btl_win_c; struct ff7_graphics_object *add_btl_win_d; struct ff7_graphics_object *window_bg; struct ff7_graphics_object *blend_window_bg; struct ff7_graphics_object *unknown2; struct ff7_graphics_object *unknown3; struct ff7_graphics_object *unknown4; struct ff7_graphics_object *unknown5; struct ff7_graphics_object *menu_fade; struct ff7_graphics_object *font_a; struct ff7_graphics_object *font_b; struct ff7_graphics_object *menu_avatars[3]; struct ff7_graphics_object *menu_avatars2[9]; struct ff7_graphics_object *buster_tex; struct ff7_graphics_object *font; struct ff7_graphics_object *btl_win; struct ff7_graphics_object *blend_btl_win; struct ff7_graphics_object *add_btl_win; }; // file modes enum { FF7_FMODE_READ = 0, FF7_FMODE_READ_TEXT, FF7_FMODE_WRITE, FF7_FMODE_CREATE, }; /* * This section defines some structures used internally by the FF7 game engine. * * Documentation for some of them can be found on the Qhimm wiki, a lot of * information can be gleaned from the source code to this program but in many * cases nothing is known except the size and general layout of the structure. * * Variable and structure names are mostly based on what they contain rather * than what they are for, a lot of names may be wrong, inappropriate or * downright misleading. Thread with caution! */ struct list { uint use_assert_alloc; uint field_4; uint nodes; struct list_node *head; struct list_node *tail; void *destructor; void *recursive_find_cb; uint field_1C; }; struct list_node { struct list_node *next; void *object; }; struct file_context { uint mode; uint use_lgp; uint lgp_num; void (*name_mangler)(char *, char *); }; struct ff7_file { char *name; struct lgp_file *fd; struct file_context context; }; struct ff7_indexed_vertices { uint field_0; uint field_4; uint count; uint vertexcount; uint field_10; struct nvertex *vertices; uint indexcount; uint field_1C; word *indices; uint field_24; unsigned char *palettes; uint field_2C; struct ff7_graphics_object *graphics_object; }; struct ff7_graphics_object { uint polytype; uint field_4; uint field_8; struct p_hundred *hundred_data; struct matrix_set *matrix_set; struct polygon_set *polygon_set; uint field_18; uint field_1C; uint field_20; float u_offset; float v_offset; void *dx_sfx_2C; void *graphics_instance; uint field_34; uint vertices_per_shape; uint indices_per_shape; uint vertex_offset; uint index_offset; uint field_48; uint field_4C; uint field_50; uint field_54; uint field_58; uint field_5C; uint field_60; uint field_64; uint field_68; uint field_6C; uint field_70; uint field_74; uint field_78; uint field_7C; uint field_80; uint field_84; uint field_88; struct ff7_indexed_vertices *indexed_vertices; gfx_polysetrenderstate *func_90; gfx_draw_vertices *func_94; uint use_matrix_pointer; struct matrix *matrix_pointer; struct matrix matrix; }; struct polygon_group { uint field_0; uint numvert; void *driver_data; uint field_C; uint normindexes; uint vertices; uint vertex_colors; uint texcoords; uint texture_set; }; struct struc_106 { uint field_0; uint color; struct point3d point; struct bgra_color d3dcol; }; struct ff7_light { uint flags; uint field_4; struct struc_106 *struc_106_1; struct struc_106 *struc_106_2; struct struc_106 *struc_106_3; struct bgra_color d3dcol4; struct bgra_color normd3dcol4; uint color4; struct matrix field_38; struct matrix field_78; struct matrix field_B8; struct matrix field_F8; uint field_138; struct matrix field_13C; uint field_17C; uint field_180; uint field_184; uint field_188; uint field_18C; uint field_190; uint field_194; uint field_198; struct matrix *matrix_pointer; uint field_1A0; uint field_1A4[256]; uint field_5A4; uint color; }; struct ff7_polygon_set { uint field_0; uint field_4; uint field_8; uint field_C; uint numgroups; struct struc_49 field_14; uint field_2C; struct polygon_data *polygon_data; struct p_hundred *hundred_data; uint per_group_hundreds; struct p_hundred **hundred_data_group_array; struct matrix_set *matrix_set; struct ff7_light *light; uint field_48; void *execute_buffers; // IDirect3DExecuteBuffer ** struct indexed_primitive **indexed_primitives; uint field_54; uint field_58; struct polygon_group *polygon_group_array; uint field_60; uint field_64; uint field_68; uint field_6C; uint field_70; uint field_74; uint field_78; uint field_7C; uint field_80; uint field_84; uint field_88; uint field_8C; uint field_90; uint has_struc_173; uint field_98; struct struc_173 *struc_173; uint field_A0; uint field_A4; uint field_A8; uint field_AC; }; struct ff7_tex_header { uint version; uint field_4; uint color_key; uint field_C; uint field_10; union { struct { uint minbitspercolor; uint maxbitspercolor; uint minalphabits; uint maxalphabits; } v1_1; struct { uint x; uint y; uint w; uint h; } fb_tex; }; union { struct { uint minbitsperpixel; uint maxbitsperpixel; } v1_2; struct { char *psx_name; char *pc_name; } file; }; uint field_2C; uint palettes; // ? uint palette_entries; // ? uint bpp; struct texture_format tex_format; uint use_palette_colorkey; char *palette_colorkey; uint reference_alpha; uint blend_mode; uint field_CC; uint palette_index; unsigned char *image_data; unsigned char *old_palette_data; uint field_DC; uint field_E0; uint field_E4; uint field_E8; }; struct ff7_texture_set { union { struct { void *ddsurface1; void *d3d2texture1; void *ddsurface2; void *d3d2texture2; } d3d; struct { uint external; struct gl_texture_set *gl_set; uint width; uint height; } ogl; }; uint field_10; uint field_14; uint refcount; uint field_1C; uint field_20; uint field_24; uint field_28; uint field_2C; uint field_30; uint field_34; uint field_38; uint field_3C; uint field_40; uint field_44; uint field_48; uint field_4C; uint field_50; uint field_54; uint field_58; uint field_5C; uint field_60; uint field_64; uint field_68; uint field_6C; uint field_70; uint field_74; uint field_78; uint *texturehandle; struct texture_format *texture_format; struct tex_header *tex_header; uint palette_index; struct palette *palette; uint field_90; uint field_94; uint field_98; uint field_9C; }; struct field_layer { struct ff7_tex_header *tex_header; void *image_data; struct ff7_graphics_object *graphics_object; uint present; uint field_10; uint field_14; word field_18; word type; }; struct field_object { char name[256]; char field_100[256]; char hrc_filename[256]; char field_300[33]; char field_321; char field_322; char field_323; char field_324; char field_325; char field_326; unsigned char r_ambient; unsigned char g_ambient; unsigned char b_ambient; unsigned char r_light1; unsigned char g_light1; unsigned char b_light1; unsigned char r_light2; unsigned char g_light2; unsigned char b_light2; unsigned char r_light3; unsigned char g_light3; unsigned char b_light3; unsigned char field_333; short x_light1; short y_light1; short z_light1; short x_light2; short y_light2; short z_light2; short x_light3; short y_light3; short z_light3; word field_346; word field_348; word num_animations; char anim_filenames[8880]; char field_25FC[592]; char field_284C[60]; uint field_2888; }; struct struc_110 { uint field_0; struct point3d position; struct point3d rotation; struct point3d scale; float scale_factor; struct matrix matrix; struct point3d *bone_positions; struct matrix *bone_matrices; }; struct battle_chdir_struc { uint sucess; char olddir[200]; }; struct battle_hrc_bone { uint parent; float bone_length; uint num_rsd; }; struct battle_hrc_header { uint field_0; uint field_4; uint field_8; uint bones; uint field_10; uint field_14; uint num_textures; uint num_animations_1; uint animations_2_start_index; uint num_weapons; uint num_animations_2; uint field_2C; struct battle_hrc_bone *bone_data; }; struct anim_frame_header { struct point3d root_rotation; struct point3d root_translation; }; struct anim_frame { struct anim_frame_header *header; struct point3d *data; }; struct anim_header { union { struct { uint version; } version; struct { char *pc_name; } file; }; uint num_frames; uint num_bones; char rotation_order[4]; void *frame_data; struct anim_frame *anim_frames; uint use_matrix_array; struct matrix *matrix_array; struct matrix *current_matrix_array; }; struct hrc_data { uint field_0; uint field_4; uint debug; uint flags; uint num_bones; struct hrc_bone *bones; uint field_18; struct list *bone_list; struct ff7_game_obj *game_object; struct matrix field_24; struct matrix field_64; uint *field_A4; }; struct hrc_bone { char *bone_name; char *bone_parent; uint parent_index; float bone_length; uint num_rsd; char **rsd_names; struct rsd_array_member *rsd_array; }; struct bone_list_member { word bone_type; word bone_index; }; struct rsd_array_member { uint field_0; struct rsd_data *rsd_data; }; struct rsd_data { struct matrix_set *matrix_set; struct ff7_polygon_set *polygon_set; struct pd_data *pd_data; }; struct lgp_toc_entry { char name[16]; uint offset; word unknown1; word conflict; }; struct lookup_table_entry { unsigned short toc_offset; unsigned short num_files; }; struct conflict_entry { char name[128]; unsigned short toc_index; }; struct conflict_list { uint num_conflicts; struct conflict_entry *conflict_entries; }; struct lgp_folders { struct conflict_list conflicts[1000]; }; struct hpmp_bar { word x; word y; word w; word h; word value1; word max_value; word healing_animation; word value2; uint color; }; struct savemap_char { char id; char level; char field_2; char field_3; char field_4; char field_5; char dex; char field_7; char field_8; char field_9; char field_A; char field_B; char field_C; char field_D; char current_limit_level; unsigned char current_limit_bar; char name[12]; char equipped_weapon; char equipped_armor; char field_1E; char flags; char field_20; unsigned char level_progress_bar; word field_22; word field_24; word field_26; word field_28; word field_2A; word hp; word base_hp; word mp; word base_mp; uint field_34; word max_hp; word max_mp; uint current_exp; uint field_40; uint field_44; uint field_48; uint field_4C; uint field_50; uint field_54; uint field_58; uint field_5C; uint field_60; uint field_64; uint field_68; uint field_6C; uint field_70; uint field_74; uint field_78; uint field_7C; uint exp_to_next_level; }; #pragma pack(push,1) struct savemap { uint checksum; char preview_level; char preview_portraits[3]; char preview_char_name[16]; word preview_hp; word preview_maxhp; word preview_mp; word preview_maxmp; uint preview_gil; uint preview_seconds; char preview_location[32]; char ul_window_red; char ul_window_green; char ul_window_blue; char ur_window_red; char ur_window_green; char ur_window_blue; char ll_window_red; char ll_window_green; char ll_window_blue; char lr_window_red; char lr_window_green; char lr_window_blue; struct savemap_char chars[9]; unsigned char party_members[3]; char field_4FB; word items[320]; uint materia[200]; uint stolen_materia[48]; uint field_B5C; uint field_B60; uint field_B64; uint field_B68; uint field_B6C; uint field_B70; uint field_B74; uint field_B78; uint gil; uint seconds; uint field_B84; uint field_B88; uint field_B8C; uint field_B90; word current_mode; word current_location; word field_B98; word x; word y; word z_walkmeshtri; char field_BA0; char field_BA1; char field_BA2; char field_BA3; char field_BA4[256]; char field_CA4[256]; char field_DA4[256]; char field_EA4[256]; char field_FA4[256]; word phs_lock2; char field_10A6; char field_10A7; char field_10A8; char field_10A9; char field_10AA; char field_10AB; char field_10AC; word phs_lock; word phs_visi; char field_10B1; word field_10B2; uint field_10B4; uint field_10B8; uint field_10BC; uint field_10C0; uint field_10C4; uint field_10C8; uint field_10CC; uint field_10D0; uint field_10D4; char battle_speed; char battle_msg_speed; char field_10DA; char field_10DB; uint field_10DC; uint field_10E0; uint field_10E4; uint field_10E8; char message_speed; char field_10ED; word field_10EE; uint field_10F0; }; struct weapon_data { char field_0; char field_1; char field_2; char field_3; unsigned char attack_stat; char field_5; char field_6; char field_7; char field_8; char field_9; char field_A; char field_B; word field_C; word field_E; word field_10; word field_12; char stat_increase_types[4]; char stat_increase_amounts[4]; char field_1C[8]; char field_24; char field_25; char field_26; char field_27; word field_28; word field_2A; }; struct armor_data { char field_0; char field_1; unsigned char defense_stat; unsigned char mdef_stat; char field_4; char field_5; char field_6; word field_7; char field_9[8]; char field_11; word field_12; word field_14; word field_16; uint field_18; uint field_1C; word field_20; word field_22; }; struct party_member_data { char field_0; char field_1; char field_2; char field_3; char field_4; char field_5; char field_6; char field_7; word field_8; word field_A; word field_C; word field_E; word hp; word max_hp; word mp; word max_mp; word field_18; word field_1A; word field_1C; word field_1E; char field_20; char field_21; char field_22; char field_23; char field_24[24]; word field_3C; word field_3E; word field_40; word field_42; uint field_44; uint field_48; uint field_4C[24]; char field_AC[8]; uint field_B4[21]; uint field_108[112]; uint field_2C8[32]; uint field_348[48]; struct weapon_data weapon_data; uint field_434; uint field_438; uint field_43C; }; #pragma pack(pop) struct field_tile { short x; short y; float z; word field_8; word field_A; word img_x; word img_y; float u; float v; word fx_img_x; word fx_img_y; uint field_1C; uint field_20; uint field_24; uint field_28; word tile_size_x; word tile_size_y; word palette_index; word flags; char anim_group; char anim_bitmask; word field_36; char field_38[4096]; word field_1038; word field_103A; uint use_fx_page; uint field_1040; uint field_1044; uint field_1048; uint field_104C; char field_1050; char field_1051; char field_1052; char field_1053; word blend_mode; word page; word fx_page; word field_105A; }; struct struc_3 { uint field_0; uint field_4; uint convert_animations; uint create_matrix_set; uint field_10; uint matrix_set_size; struct graphics_instance *graphics_instance; uint field_1C; uint blend_mode; uint base_directory; struct ff7_tex_header *tex_header; uint field_2C; uint light; uint field_34; float bone_scale_factor; uint field_3C; struct file_context file_context; uint field_50; uint field_54; uint field_58; uint palette_index; uint field_60; uint field_64; uint field_68; uint field_6C; uint field_70; }; struct wordmatrix { word _11; word _12; word _13; word _21; word _22; word _23; word _31; word _32; word _33; uint _41; uint _42; uint _43; }; struct struc_154_2 { short field_0; word field_2; word field_4; word field_6; word field_8; word field_A; word field_C; word field_E; uint field_10; uint field_14; unsigned char field_18[8]; }; struct struc_154_3 { short field_0; word field_2; word field_4; word field_6; word field_8; word field_A; word field_C; word field_E; uint field_10; uint field_14; unsigned char field_18[8]; }; struct struc_154 { short field_0; word field_2; word field_4; word field_6; word field_8; word field_A; word field_C; word field_E; uint field_10; uint field_14; unsigned char field_18[8]; }; struct struc_205 { short field_0; word field_2; word field_4; word field_6; word field_8; word field_A; word field_C; word field_E; uint field_10; uint field_14; unsigned char field_18[16]; }; struct movie_obj { void *ddstream; uint field_4; void *mediastream; uint loop; uint field_10; DDSURFACEDESC movie_sdesc; void *graphbuilder; uint movie_surfaceheight; uint field_88; void *amms; void *movie_surface; void *sample; uint movie_left; uint movie_top; uint movie_right; uint movie_bottom; uint target_left; uint target_top; uint target_right; uint target_bottom; void *sts1; void *vts1; void *sts2; void *vts2; void *st1; void *vt1; void *st2; void *vt2; uint vt1handle; uint vt2handle; uint field_E0; uint movie_surfacewidth; uint field_E8; struct nvertex movie_vt2prim[4]; struct nvertex movie_vt1prim[4]; void *mediaseeking; uint graphics_mode; uint field_1F4; uint field_1F8; uint is_playing; uint movie_end; uint global_movie_flag; }; struct dll_gfx_externals { void *(*assert_free)(void *, const char *, uint); void *(*assert_malloc)(uint, const char *, uint); void *(*assert_calloc)(uint, uint, const char *, uint); struct texture_format *(*create_texture_format)(); void (*add_texture_format)(struct texture_format *, struct game_obj *); struct game_obj *(*get_game_object)(); uint free_driver; uint create_gfx_driver; void (*make_pixelformat)(uint, uint, uint, uint, uint, struct texture_format *); uint gltexformat2texformat; uint sub_686143; uint sub_6861EC; uint sub_68631E; uint sub_686351; uint pal_pixel2bgra; uint pal_pixel2bgra_8bit; uint texture_set_destroy_pal; struct palette *(*create_palette_for_tex)(uint, struct tex_header *, struct texture_set *); uint convert_texture; uint texture_set_decref; struct texture_set *(*create_texture_set)(); uint write_palette; uint rgba2d3dcol; uint sub_6A5FEB; uint sub_6A604A; uint destroy_palette; uint create_palette; uint call_gfx_write_palette; uint call_gfx_palette_changed; uint sub_6A5A70; uint sub_6A5BA0; uint sub_6A5C3B; uint sub_6A5CE2; void *(*sub_6A2865)(void *); gfx_load_group *generic_load_group; gfx_light_polygon_set *generic_light_polygon_set; }; struct ff7_game_obj { uint unknown_0; uint devicecaps_4; uint devicecaps_8; uint dcdepth; uint field_10; uint field_14; uint field_18; uint field_1C; uint field_20; uint field_24; uint field_28; uint field_2C; double countspersecond; time_t _countspersecond; uint field_40; uint field_44; double fps; uint tsc; uint field_54; // tsc high bits? HINSTANCE hinstance; HWND hwnd; uint field_60; uint field_64; uint field_68; uint field_6C; uint field_70; void *dddevice; void *dd2interface; void *front_surface[3]; DDSURFACEDESC front_surface_desc[3]; uint field_1CC; uint field_1D0; IDirectDrawClipper* dd_clipper; uint field_1D8; DDSURFACEDESC d3d_surfacedesc; void *dd_interface; uint field_24C; DDSURFACEDESC dd_surfacedesc; struct list *d3ddev_list; void *d3dinterface; void *surface_d3ddev; // IDirect3DDevice struct list *textureformat_list; void *d3ddev_struct; void *d3dviewport; void *d3dmaterial; uint field_2D8; void *d3d2interface; void *d3d2device; void *d3dviewport2; struct list *list_2E8; struct polygon_set *polygon_set_2EC; struct polygon_set *polygon_set_2F0; struct stack *matrix_stack1; struct stack *matrix_stack2; struct matrix *camera_matrix; struct graphics_instance *graphics_instance; uint field_304; uint field_308; uint field_30C; uint field_310; uint field_314; uint field_318; uint field_31C; uint field_320; D3DDEVICEDESC d3d_halcaps; D3DDEVICEDESC d3d_helcaps; DDCAPS_DX5 halcaps; DDCAPS_DX5 helcaps; uint field_794; uint field_798; struct texture_format surface_tex_format; uint in_scene; struct p_hundred *hundred_array[5]; void *applog_debug1; uint applog_debug2; void *dxdbg_file; uint field_840; uint field_844; uint _res_x; uint _res_y; uint _res_w; uint _res_h; uint field_858; uint field_85C; uint field_860; uint field_864; uint field_868; uint field_86C; uint field_870; uint field_874; uint field_878; uint field_87C; uint field_880; uint field_884; uint field_888; uint field_88C; struct matrix matrix_890; struct matrix matrix_8D0; void *dx_sfx_something; struct list *tex_list_pointer; struct stack *stack_918; uint field_91C; void *_3d2d_something; uint field_924; uint field_928; uint field_92C; uint field_930; struct gfx_driver *gfx_driver; void *_3dobject_pool; uint field_93C; struct p_hundred *current_hundred; struct struc_81 *field_944; uint field_948; uint field_94C; uint field_950; uint res_w; uint res_h; uint colordepth; uint field_960; uint field_964; uint field_968; uint no_hardware; uint field_970; uint field_974; uint colorkey; uint field_97C; uint field_980; uint d3d2_flag; uint field_988; uint field_98C; uint field_990; uint field_994; uint matrix_stack_size; uint field_99C; uint field_9A0; uint field_9A4; uint field_9A8; uint field_9AC; uint random_seed; char *window_title; char *window_class; uint field_9BC; WNDCLASSA wndclass_struct; uint field_9E8; uint field_9EC; struct main_obj main_obj_9F0; struct main_obj main_obj_A0C; void *wm_activate; uint field_A2C; uint field_A30; uint field_A34; uint field_A38; uint field_A3C; uint field_A40; uint field_A44; uint field_A48; uint field_A4C; uint field_A50; uint field_A54; uint field_A58; uint field_A5C; uint current_gfx_driver; uint field_A64; uint field_A68; uint field_A6C; uint field_A70; uint field_A74; uint field_A78; void *gfx_driver_data; uint field_A80; uint field_A84; void *create_gfx_driver; struct dll_gfx_externals *externals; uint nvidia_fix; uint tnt_fix; uint no_riva_fix; uint field_A9C; }; struct ff7_gfx_driver { gfx_init *init; gfx_cleanup *cleanup; gfx_lock *lock; gfx_unlock *unlock; gfx_flip *flip; gfx_clear *clear; gfx_clear_all *clear_all; gfx_setviewport *setviewport; gfx_setbg *setbg; uint field_24; struct bgra_color field_28; // ? uint field_38; uint field_3C; gfx_prepare_polygon_set *prepare_polygon_set; gfx_load_group *load_group; gfx_setmatrix *setmatrix; gfx_unload_texture *unload_texture; gfx_load_texture *load_texture; gfx_palette_changed *palette_changed; gfx_write_palette *write_palette; gfx_blendmode *blendmode; gfx_light_polygon_set *light_polygon_set; gfx_field_64 *field_64; gfx_setrenderstate *setrenderstate; gfx_setrenderstate *_setrenderstate; gfx_setrenderstate *__setrenderstate; gfx_field_74 *field_74; gfx_field_78 *field_78; gfx_draw_deferred *draw_deferred; gfx_field_80 *field_80; gfx_field_84 *field_84; gfx_begin_scene *begin_scene; gfx_end_scene *end_scene; gfx_field_90 *field_90; gfx_polysetrenderstate *setrenderstate_flat2D; gfx_polysetrenderstate *setrenderstate_smooth2D; gfx_polysetrenderstate *setrenderstate_textured2D; gfx_polysetrenderstate *setrenderstate_paletted2D; gfx_polysetrenderstate *_setrenderstate_paletted2D; gfx_draw_vertices *draw_flat2D; gfx_draw_vertices *draw_smooth2D; gfx_draw_vertices *draw_textured2D; gfx_draw_vertices *draw_paletted2D; gfx_polysetrenderstate *setrenderstate_flat3D; gfx_polysetrenderstate *setrenderstate_smooth3D; gfx_polysetrenderstate *setrenderstate_textured3D; gfx_polysetrenderstate *setrenderstate_paletted3D; gfx_polysetrenderstate *_setrenderstate_paletted3D; gfx_draw_vertices *draw_flat3D; gfx_draw_vertices *draw_smooth3D; gfx_draw_vertices *draw_textured3D; gfx_draw_vertices *draw_paletted3D; gfx_polysetrenderstate *setrenderstate_flatlines; gfx_polysetrenderstate *setrenderstate_smoothlines; gfx_draw_vertices *draw_flatlines; gfx_draw_vertices *draw_smoothlines; gfx_field_EC *field_EC; }; // --------------- end of FF7 imports --------------- // memory addresses and function pointers from FF7.exe struct ff7_externals { uint chocobo_fix; uint midi_fix; void *snowboard_fix; uint cdcheck; uint get_inserted_cd_sub; uint requiredCD; struct movie_obj *movie_object; void (*movie_sub_415231)(char *); void (*sub_665D9A)(struct matrix *, struct nvertex *, struct indexed_primitive *, struct p_hundred *, struct struc_186 *, struct ff7_game_obj *); void (*sub_671742)(uint, struct p_hundred *, struct struc_186 *); void (*sub_6B27A9)(struct matrix *, struct indexed_primitive *, struct ff7_polygon_set *, struct p_hundred *, struct p_group *, void *, struct ff7_game_obj *); void (*sub_68D2B8)(uint, struct ff7_polygon_set *, void *); void (*sub_665793)(struct matrix *, uint, struct indexed_primitive *, struct ff7_polygon_set *, struct p_hundred *, struct p_group *, struct ff7_game_obj *); void (*matrix3x4)(struct matrix *); uint matrix4x3_multiply; void *(*sub_6A2865)(void *); uint sub_6B26C0; uint sub_6B2720; uint sub_673F5C; struct savemap *savemap; struct menu_objects *menu_objects; uint magic_thread_start; void (*destroy_magic_effects)(); uint lgp_open_file; uint lgp_read_file; uint lgp_read; uint lgp_get_filesize; uint lgp_seek_file; void (*draw_character)(uint, uint, char *, uint, float); uint destroy_field_bk; uint destroy_field_tiles; struct field_layer **field_layers; word *num_field_entities; struct field_object **field_objects; uint open_field_file; char *field_file_name; uint read_field_file; uint battle_loop; uint battle_sub_429AC0; uint battle_b3ddata_sub_428B12; uint graphics_render_sub_68A638; uint create_dx_sfx_something; uint load_p_file; struct polygon_data *(*create_polygon_data)(uint, uint); void (*create_polygon_lists)(struct polygon_data *); void (*free_polygon_data)(struct polygon_data *); uint battle_sub_42A0E7; uint load_battle_stage; uint load_battle_stage_pc; uint read_battle_hrc; void (*battle_regular_chdir)(struct battle_chdir_struc *); void (*battle_context_chdir)(struct file_context *, struct battle_chdir_struc *); void (*swap_extension)(char *, char *, char *); void (*destroy_battle_hrc)(uint, struct battle_hrc_header *); void (*battle_regular_olddir)(struct battle_chdir_struc *); void (*battle_context_olddir)(struct file_context *, struct battle_chdir_struc *); uint load_animation; uint field_load_animation; uint field_load_models; uint field_sub_60DCED; void (*destroy_animation)(struct anim_header *); uint context_chdir; uint lgp_chdir; struct lookup_table_entry **lgp_lookup_tables; struct lgp_toc_entry **lgp_tocs; struct lgp_folders *lgp_folders; uint __read; uint load_lgp; uint open_lgp_file; FILE **lgp_fds; uint battle_sub_437DB0; uint sub_5CB2CC; uint *midi_volume_control; uint *midi_initialized; uint menu_sub_6CDA83; uint menu_sub_6CBD43; uint menu_sub_701EE4; uint phs_menu_sub; uint menu_draw_party_member_stats; uint *party_member_to_char_map; uint menu_sub_6CB56A; uint *menu_subs_call_table; uint status_menu_sub; uint draw_status_limit_level_stats; char *(*get_kernel_text)(uint, uint, uint); uint sub_5CF282; uint get_equipment_stats; struct weapon_data *weapon_data_array; struct armor_data *armor_data_array; uint field_sub_6388EE; uint field_draw_everything; uint field_pick_tiles_make_vertices; uint field_layer2_pick_tiles; uint *field_special_y_offset; uint *field_layer2_tiles_num; uint **field_layer2_palette_sort; struct field_tile **field_layer2_tiles; char *field_anim_state; void (*add_page_tile)(float, float, float, float, float, uint, uint); uint field_load_textures; void (*field_convert_type2_layers)(); void (*make_struc3)(uint, struct struc_3 *); void (*make_field_tex_header_pal)(struct ff7_tex_header *); void (*make_field_tex_header)(struct ff7_tex_header *); struct ff7_graphics_object *(*_load_texture)(uint, uint, struct struc_3 *, char *, void *); uint read_field_background_data; word *layer2_end_page; uint create_d3d2_indexed_primitive; uint destroy_d3d2_indexed_primitive; uint enter_main; uint kernel_init; uint kernel_load_kernel2; uint kernel2_reset_counters; uint sub_4012DA; uint kernel2_add_section; uint kernel2_get_text; uint draw_3d_model; void (*stack_push)(struct stack *); void *(*stack_top)(struct stack *); void (*stack_pop)(struct stack *); void (*_root_animation)(struct matrix *, struct anim_frame *, struct anim_header *, struct hrc_data *); void (*_frame_animation)(uint, struct matrix *, struct point3d *, struct anim_frame *, struct anim_header *, struct hrc_bone *, struct hrc_data *); void (*root_animation)(struct matrix *, struct anim_frame *, struct anim_header *, struct hrc_data *); void (*frame_animation)(uint, struct matrix *, struct point3d *, struct anim_frame *, struct anim_header *, struct hrc_bone *, struct hrc_data *); uint *model_mode; uint name_menu_sub_6CBD32; uint name_menu_sub_719C08; uint menu_sub_71894B; uint menu_sub_718DBE; uint menu_sub_719B81; uint set_default_input_settings_save; uint keyboard_name_input; uint restore_input_settings; uint dinput_getdata2; uint dinput_getstate2; uint init_stuff; uint init_game; uint sub_41A1B0; uint init_directinput; uint dinput_createdevice_mouse; uint dinput_acquire_keyboard; void (*sub_69C69F)(struct matrix *, struct ff7_light *); uint coaster_sub_5E9051; uint coaster_sub_5EE150; uint cleanup_game; uint cleanup_midi; }; uint ff7gl_load_group(uint group_num, struct matrix_set *matrix_set, struct p_hundred *hundred_data, struct p_group *group_data, struct polygon_data *polygon_data, struct ff7_polygon_set *polygon_set, struct ff7_game_obj *game_object); void ff7gl_field_78(struct ff7_polygon_set *polygon_set, struct ff7_game_obj *game_object); struct ff7_gfx_driver *ff7_load_driver(struct ff7_game_obj *game_object); void ff7_post_init();
20.803413
235
0.771627
3fea6324905d68d13f6fa56f339e23dcf7979feb
11,006
h
C
kernel-3.10/fs/rawfs/rawfs.h
zhengdejin/SC1_Code
dccccf55f2875fb64ec621f4356c625cd48bef7e
[ "Apache-2.0" ]
null
null
null
kernel-3.10/fs/rawfs/rawfs.h
zhengdejin/SC1_Code
dccccf55f2875fb64ec621f4356c625cd48bef7e
[ "Apache-2.0" ]
null
null
null
kernel-3.10/fs/rawfs/rawfs.h
zhengdejin/SC1_Code
dccccf55f2875fb64ec621f4356c625cd48bef7e
[ "Apache-2.0" ]
null
null
null
#ifndef __RAWFS_H__ #define __RAWFS_H__ #include <asm/byteorder.h> #include <linux/list.h> #if defined(CONFIG_MT_ENG_BUILD) /* log is only enabled in eng load */ #define RAWFS_DBG pr_warn #endif #define RAWFS_BLOCK_FILE /* #define RAWFS_RAM_DISK */ #define RAWFS_VERSION 0x01 /* Debug Message Mask */ enum rawfs_debug_level_enum { RAWFS_DBG_SUPER = 0x0001, RAWFS_DBG_DEVICE = 0x0002, RAWFS_DBG_INODE = 0x0004, RAWFS_DBG_FILE = 0x0008, RAWFS_DBG_DIR = 0x0010, RAWFS_DBG_DENTRY = 0x0020, RAWFS_DBG_INIT = 0x0040, RAWFS_DBG_GC = 0x0080, RAWFS_DBG_MOUNT = 0x0100 }; extern int rawfs_debug_msg_mask; #define RAWFS_DEBUG_MSG_DEFAULT (RAWFS_DBG_SUPER | RAWFS_DBG_DEVICE | \ RAWFS_DBG_INODE | RAWFS_DBG_FILE | \ RAWFS_DBG_DIR | RAWFS_DBG_DENTRY | \ RAWFS_DBG_INIT | RAWFS_DBG_GC | RAWFS_DBG_MOUNT) #ifdef RAWFS_DBG #define RAWFS_PRINT(category, str, ...) do { \ if (category & rawfs_debug_msg_mask) { \ RAWFS_DBG("rawfs: " str, ##__VA_ARGS__); \ } } while (0) #else #define RAWFS_PRINT(...) #endif #define RAWFS_MAX_FILENAME_LEN 60 #define RAWFS_MNT_RAM 0x01 #define RAWFS_MNT_MTD 0x02 #define RAWFS_MNT_CASE 0x10 #define RAWFS_MNT_BLOCKFILE 0x40 #define RAWFS_MNT_FIRSTBOOT 0x80 /* RAW FS super block info */ #define RAWFS_HASH_BITS 2 #define RAWFS_HASH_SIZE (1UL << RAWFS_HASH_BITS) /* Interface to MTD block device */ struct rawfs_dev { int (*erase_block) (struct super_block *sb, int block_no); int (*read_page_user) (struct super_block *sb, int block_no, int addr, const struct iovec *iov, unsigned long nr_segs, int size); int (*write_page) (struct super_block *sb, int block_no, int page_no, void *buffer); int (*read_page) (struct super_block *sb, int block_no, int page_no, void *buffer); }; /* RAW FS super block info */ struct rawfs_sb_info { /* File System Context */ struct list_head fs_context; struct super_block *super; struct proc_dir_entry *s_proc; /* Driver context */ void *driver_context; struct rawfs_dev dev; /* Device Info */ int total_blocks; int pages_per_block; int sectors_per_page; int block_size; int page_size; int page_data_size; /* Managment */ int data_block; int data_block_free_page_index; int data_block_gcmarker_page_index; int empty_block; __u32 sequence_number; __u32 erase_count_max; int flags; char *fake_block; struct mutex rawfs_lock; struct nls_table *local_nls; /* Codepage used on disk */ /* File List */ struct list_head folder_list; struct list_head file_list; struct mutex file_list_lock; /* Inode Hash Table */ spinlock_t inode_hash_lock; struct hlist_head inode_hashtable[RAWFS_HASH_SIZE]; /* Misc */ unsigned int rsize; unsigned int wsize; }; #define RAWFS_NAND_BLOCKS(sb) ((sb)?2:0) /* We use only two block */ #define RAWFS_NAND_PAGES(sb) (sb->pages_per_block) #define RAWFS_NAND_PAGE_SIZE(sb) (sb->page_size) #define RAWFS_NAND_BLOCK_SIZE(sb) (sb->block_size) #define RAWFS_NAND_PAGE_SECTORS(sb) (sb->sectors_per_page) #define RAWFS_NAND_PAGE_DATA_SIZE(sb) (sb->page_data_size) /* RAW FS inode info */ struct rawfs_inode_info { spinlock_t cache_lru_lock; struct list_head cache_lru; int nr_caches; unsigned int cache_valid_id; /* NOTE: mmu_private is 64bits, so must hold ->i_mutex to access */ loff_t mmu_private; /* physically allocated size */ int i_location_block; /* File Location: block */ int i_location_page; /* File Location: starting page */ int i_location_page_count; int i_id; int i_parent_folder_id; /* Parent folder ID */ char i_name[RAWFS_MAX_FILENAME_LEN+4]; struct hlist_node i_rawfs_hash; /* hash by i_name */ struct rw_semaphore truncate_lock; /* protect bmap against truncate */ struct inode vfs_inode; }; static inline struct rawfs_sb_info * RAWFS_SB(struct super_block *sb) { return sb->s_fs_info; } static inline struct rawfs_inode_info * RAWFS_I(struct inode *inode) { return container_of(inode, struct rawfs_inode_info, vfs_inode); } static inline struct mtd_info * RAWFS_MTD(struct super_block *sb) { return RAWFS_SB(sb)->driver_context; } #define RAWFS_CACHE_VALID 0 #define RAWFS_ROOT_DIR_ID 1 /* RAWFS inode number */ #define RAWFS_ROOT_INO 1 #define RAWFS_BLOCK0_INO 2 #define RAWFS_BLOCK1_INO 3 #define RAWFS_MAX_RESERVED_INO 64 /* Page Signatures */ #define RAWFS_NAND_BLOCK_SIG_HEAD 0x44484B42 /* BKHD */ #define RAWFS_NAND_PAGE_SIG_HEAD 0x44484750 /* PGHD */ #define RAWFS_NAND_PAGE_SIG_FOOT 0x54464750 /* PGFT */ #define RAWFS_NAND_GC_MARKER_SIG_HEAD 0x44484347 /* GCHD */ #define RAWFS_NAND_PAGE_SIG_EMPTY 0xFFFFFFFF enum rawfs_block_stat_enum { RAWFS_BLOCK_STAT_INVALID_HEAD = 0, RAWFS_BLOCK_STAT_EMPTY = 1, RAWFS_BLOCK_STAT_INVALID_DATA = 2, RAWFS_BLOCK_STAT_DATA = 3 }; enum rawfs_page_stat_enum { RAWFS_PAGE_STAT_EMPTY = 0, RAWFS_PAGE_STAT_DELETED = 1, RAWFS_PAGE_STAT_VALID = 2, RAWFS_PAGE_STAT_BLOCK_HEAD = 3, RAWFS_PAGE_STAT_GC_MARKER = 4, RAWFS_PAGE_STAT_UNCORRECTABLE = 5, RAWFS_PAGE_STAT_INVALID = 6 }; struct rawfs_block_header { __u32 i_signature_head; __u32 i_rawfs_version; __u32 i_sequence_number; __u32 i_sequence_number_last; __u32 i_erase_count; __u32 i_crc; } __packed; struct rawfs_gc_marker_page { __u32 i_signature_head; __u32 i_src_block_index; __u32 i_src_block_sequence_number; __u32 i_src_block_erase_count; __u32 i_crc; } __packed; struct rawfs_file_info { /* dentry */ char i_name[RAWFS_MAX_FILENAME_LEN+4]; int i_chunk_index; int i_chunk_total; struct timespec i_atime; struct timespec i_mtime; struct timespec i_ctime; umode_t i_mode; uid_t i_uid; gid_t i_gid; loff_t i_size; int i_parent_folder_id; int i_id; /* 0 for normal file */ }; struct rawfs_file_list_entry { struct list_head list; struct rawfs_file_info file_info; int i_location_block; /* File Location: block */ int i_location_page; /* File Location: starting page */ int i_location_page_count; }; struct rawfs_page { __u32 i_signature_head; __u32 i_crc; union { struct rawfs_file_info i_file_info; __u8 padding[488]; } i_info; __u8 i_data[1]; } __packed; /* Inode operations */ int __init rawfs_init_inodecache(void); void __exit rawfs_destroy_inodecache(void); void rawfs_hash_init(struct super_block *sb); struct inode *rawfs_alloc_inode(struct super_block *sb); void rawfs_destroy_inode(struct inode *inode); int rawfs_fill_inode(struct inode *inode, struct rawfs_file_info *file_info, int block_no, int page_no, umode_t mode, dev_t dev); struct inode *rawfs_iget(struct super_block *sb, const char *name, int folder); /* Mount-time analysis */ int rawfs_block_level_analysis(struct super_block *sb); int rawfs_page_level_analysis(struct super_block *sb); int rawfs_file_level_analysis(struct super_block *sb); int rawfs_page_get(struct super_block *sb, int block_no, int page_no, struct rawfs_file_info *file_info, void *data); int rawfs_block_is_valid(struct super_block *sb, int block_no, struct rawfs_block_header *block_head_out, struct rawfs_gc_marker_page *gc_page_out); /* Device Operation */ int rawfs_dev_free_space(struct super_block *sb); int rawfs_dev_garbage_collection(struct super_block *sb); void rawfs_page_signature(struct super_block *sb, void *buf); int rawfs_dev_mtd_erase_block(struct super_block *sb, int block_no); int rawfs_dev_mtd_read_page_user(struct super_block *sb, int block_no, int block_offset, const struct iovec *iov, unsigned long nr_segs, int size); int rawfs_dev_mtd_write_page(struct super_block *sb, int block_no, int page_no, void *buffer); int rawfs_dev_mtd_read_page(struct super_block *sb, int block_no, int page_no, void *buffer); int rawfs_dev_ram_erase_block(struct super_block *sb, int block_no); int rawfs_dev_ram_read_page_user(struct super_block *sb, int block_no, int block_offset, const struct iovec *iov, unsigned long nr_segs, int size); int rawfs_dev_ram_write_page(struct super_block *sb, int block_no, int page_no, void *buffer); int rawfs_dev_ram_read_page(struct super_block *sb, int block_no, int page_no, void *buffer); /* File Operations */ int rawfs_reg_file_delete(struct inode *dir, struct dentry *dentry); int rawfs_reg_file_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd); int rawfs_reg_file_copy(struct inode *src_dir, struct dentry *src_dentry, struct inode *dest_dir, struct dentry *dest_dentry); int rawfs_reserve_space(struct super_block *sb, int chunks); ssize_t rawfs_reg_file_aio_read(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos); ssize_t rawfs_reg_file_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos); ssize_t rawfs_block_file_aio_read(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos); ssize_t rawfs_block_file_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos); int rawfs_file_sync(struct file *file, loff_t start, loff_t end, int datasync); int rawfs_readdir(struct file *filp, void *dirent, filldir_t filldir); /* dentry operations */ int rawfs_delete_dentry(const struct dentry *dentry); /* File info */ void rawfs_fill_file_info(struct inode *inode, struct rawfs_file_info *file_info); void rawfs_fill_fileinfo_by_dentry(struct dentry *dentry, struct rawfs_file_info *file_info); /* File and Folder lists */ struct rawfs_file_list_entry *rawfs_file_list_get(struct super_block *sb, const char *name, int folder_id); struct rawfs_file_list_entry *rawfs_file_list_get_by_id( struct super_block *sb, umode_t mode, int id); void rawfs_file_list_init(struct super_block *sb); int rawfs_file_list_add(struct super_block *sb, struct rawfs_file_info *fi, int block_no, int page_no); void rawfs_file_list_remove(struct super_block *sb, struct rawfs_file_info *fi); void rawfs_file_list_destroy(struct super_block *sb); int rawfs_file_list_count(struct super_block *sb, unsigned int *entry_count, unsigned int *used_blocks, unsigned int *free_blocks); __u32 rawfs_page_crc_data(struct super_block *sb, void *data_page); __u32 rawfs_page_crc_gcmarker(struct super_block *sb, void *gcmarker_page); /* Address Space Operations: Block file & Normal file */ int rawfs_readpage(struct file *filp, struct page *page); int rawfs_write_begin(struct file *filp, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata); int rawfs_write_end(struct file *filp, struct address_space *mapping, loff_t pos, unsigned len, unsigned copied, struct page *pg, void *fsdata); /* Case in-sensitive dentry operations */ int rawfs_ci_hash(const struct dentry *dentry, const struct inode *inode, struct qstr *q); int rawfs_compare_dentry(const struct dentry *parent, const struct inode *pinode, const struct dentry *dentry, const struct inode *inode, unsigned int len, const char *str, const struct qstr *name); int rawfs_delete_dentry(const struct dentry *dentry); /* Utility */ uint32_t rawfs_div(uint64_t n, uint32_t base); #endif
31.17847
79
0.77803
274986cb02e1df0947d4bbe5c0393de3b20026f3
681
h
C
projects/atLib/include/Networking/HTTP/atHTTPRequest.h
mbatc/atLib
7e3a69515f504a05a312d234291f02863e291631
[ "MIT" ]
1
2019-09-17T18:02:16.000Z
2019-09-17T18:02:16.000Z
projects/atLib/include/Networking/HTTP/atHTTPRequest.h
mbatc/atLib
7e3a69515f504a05a312d234291f02863e291631
[ "MIT" ]
null
null
null
projects/atLib/include/Networking/HTTP/atHTTPRequest.h
mbatc/atLib
7e3a69515f504a05a312d234291f02863e291631
[ "MIT" ]
null
null
null
#ifndef atHTTPRequest_h__ #define atHTTPRequest_h__ #include "atHTTPHeader.h" class atHTTPRequest { public: atHTTPRequest(); atHTTPRequest(const atString &request); atHTTPRequest(const atHTTPMethod &method, const atString &uri = "/", const atHTTPProtocol &protocol = atHTTP_Ver_1_1); atString ToString() const; void SetURI(const atString &uri); void SetMethod(const atHTTPMethod &method); void SetProtocol(const atHTTPProtocol &protocol); const atString& URI() const; atHTTPMethod Method() const; atHTTPProtocol Protocol() const; atHTTPHeader header; atString body; }; atString atToString(const atHTTPRequest &header); #endif // atHTTPRequest_h__
22.7
120
0.762115
e935ab5912ea2f61771c0ff3d868939785f5b696
571
h
C
12_02_move/src/apps/space/player_manager_component.h
Thanalan/GameBookServer-master
506b4fe1eece1a3c0bd1100fe14764b63885b2bf
[ "MIT" ]
83
2019-12-03T08:42:15.000Z
2022-03-30T13:22:37.000Z
12_02_move/src/apps/space/player_manager_component.h
Thanalan/GameBookServer-master
506b4fe1eece1a3c0bd1100fe14764b63885b2bf
[ "MIT" ]
1
2021-08-06T10:40:57.000Z
2021-08-09T06:33:43.000Z
12_02_move/src/apps/space/player_manager_component.h
Thanalan/GameBookServer-master
506b4fe1eece1a3c0bd1100fe14764b63885b2bf
[ "MIT" ]
45
2020-05-29T03:22:48.000Z
2022-03-21T16:19:01.000Z
#pragma once #include "libserver/entity.h" #include "libplayer/player.h" class PlayerManagerComponent:public Entity<PlayerManagerComponent>, public IAwakeFromPoolSystem<> { public: void Awake() override; void BackToPool() override; Player* AddPlayer(uint64 playerSn, uint64 worldSn, NetIdentify* pNetIdentify); Player* GetPlayerBySn(uint64 playerSn); void RemovePlayerBySn(uint64 playerSn); void RemoveAllPlayers(NetIdentify* pNetIdentify); int OnlineSize() const; std::map<uint64, Player*>* GetAll(); private: std::map<uint64, Player*> _players; };
23.791667
97
0.767075
3a8e1c0a4c5073fd3b13cb98066fc09b01cbe691
453
h
C
src/lib/kernel/bitmap.h
yetao0806/OSExperiment
7ab64181260002aae3e5dab6292e99ac80e2ff2e
[ "MIT" ]
null
null
null
src/lib/kernel/bitmap.h
yetao0806/OSExperiment
7ab64181260002aae3e5dab6292e99ac80e2ff2e
[ "MIT" ]
null
null
null
src/lib/kernel/bitmap.h
yetao0806/OSExperiment
7ab64181260002aae3e5dab6292e99ac80e2ff2e
[ "MIT" ]
null
null
null
#ifndef __LIB_KERNEL_BITMAP_H #define __LIB_KERNEL_BITMAP_H #include "global.h" #define BITMAP_MASK 1 struct bitmap { uint32_t btmp_bytes_len; /* 在遍历位图时, 整体上以字节为单位, 细节上是以位为单位,所以此处位图的指针必须是单字节 */ uint8_t* bits; }; void bitmap_init (struct bitmap* btmp); int bitmap_scan_test(struct bitmap* btmp, uint32_t bit_idx); int bitmap_scan(struct bitmap* btmp, uint32_t cnt); void bitmap_set(struct bitmap* btmp, uint32_t bit_idx, int8_t value); #endif
25.166667
70
0.779249