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
fc85f01b9e987cc8691cb85ed47be297bbe5626a
338
c
C
benchmarks/Angha_small/extr_message_li_update_connect/extr_message_li_update_connect.c
ComputerSystemsLab/OptimizationCache
9c30ae120673e57b772ea42e29e087f775aa9de9
[ "Apache-2.0" ]
2
2021-03-11T00:46:25.000Z
2021-07-08T16:44:58.000Z
benchmarks/Angha_small/extr_message_li_update_connect/extr_message_li_update_connect.c
ComputerSystemsLab/OptimizationCache
9c30ae120673e57b772ea42e29e087f775aa9de9
[ "Apache-2.0" ]
null
null
null
benchmarks/Angha_small/extr_message_li_update_connect/extr_message_li_update_connect.c
ComputerSystemsLab/OptimizationCache
9c30ae120673e57b772ea42e29e087f775aa9de9
[ "Apache-2.0" ]
null
null
null
typedef a; struct { int *b } * c; d, e, f, g, h, i, j; k() { a l, m = h; if (i) c = e; if (c[l].b[m] & d) { for (; j < f; j++) if (j) c[l].b = d; for (; j < f; j++) if (g) c[g].b = d; } if (c[m].b[l] & d) for (; f; c) for (; j < f; j++) if (j) c[j].b = d; }
14.083333
24
0.278107
fcafe2208a6990172b9f6ffe5be3e50c2dccf186
814
h
C
AWARE/AWAREFramework/MQTT/AWAREMqtt.h
tetujin/aware-client-ios
28103d3cff320bb63f1e1502adafa451ace7295a
[ "Apache-2.0" ]
18
2015-12-03T21:04:08.000Z
2021-10-05T12:36:11.000Z
AWARE/AWAREFramework/MQTT/AWAREMqtt.h
tetujin/aware-client-ios
28103d3cff320bb63f1e1502adafa451ace7295a
[ "Apache-2.0" ]
10
2016-02-15T16:55:35.000Z
2018-09-05T21:42:43.000Z
AWARE/AWAREFramework/MQTT/AWAREMqtt.h
tetujin/aware-client-ios
28103d3cff320bb63f1e1502adafa451ace7295a
[ "Apache-2.0" ]
13
2016-06-16T15:30:01.000Z
2019-01-14T19:53:27.000Z
// // AWAREMqtt.h // AWARE // // Created by Yuuki Nishiyama on 12/10/15. // Copyright © 2015 Yuuki NISHIYAMA. All rights reserved. // #import <Foundation/Foundation.h> #import <MQTTKit/MQTTKit.h> #import <UIKit/UIKit.h> @interface AWAREMqtt : NSObject @property (nonatomic,strong) NSString * mqttServer;// = @""; @property (nonatomic,strong) NSString * oldStudyId;// = @""; @property (nonatomic,strong) NSString * mqttPassword;// = @""; @property (nonatomic,strong) NSString * mqttUserName;// = @""; @property (nonatomic,strong) NSString * studyId;// = @""; @property (nonatomic,strong) NSNumber * mqttPort;// = @1883; @property (nonatomic,strong) NSNumber * mqttKeepAlive;// = @600; @property (nonatomic,strong) NSNumber * mqttQos;// = @2; @property MQTTClient *client; - (void) connectMqttServer; @end
28.068966
64
0.692875
52891a8cb5036d2d01a9185f42bbc8105693b59f
492
h
C
src/turn.h
Lucas18503/Farkle
39367d066d33813db999173f19bc85a2ceb0de18
[ "Unlicense" ]
null
null
null
src/turn.h
Lucas18503/Farkle
39367d066d33813db999173f19bc85a2ceb0de18
[ "Unlicense" ]
null
null
null
src/turn.h
Lucas18503/Farkle
39367d066d33813db999173f19bc85a2ceb0de18
[ "Unlicense" ]
null
null
null
#ifndef TURN_H #define TURN_H #include "game.h" struct turn { struct game *game; struct player *player; char dice[DICE_SLOTS]; char num_remaining_dice; int score; char just_rolled; }; void reroll_dice(struct turn *trn); void print_dice(struct turn *trn); char action_can_roll_dice(struct turn *trn); char action_can_bank(struct turn *trn); int run_configure_dice(struct turn *trn); void configure_dice(struct turn *trn); char execute_turn(struct turn *trn); #endif
22.363636
45
0.739837
0a31f575c861a2502a6dcfa3a6cc4b64a4d89f40
1,166
h
C
include/Simulator/Engine.h
maerhart/llhd
08ee9b709e200391a6998fe7510956dc57c0f133
[ "Apache-2.0" ]
19
2020-05-27T15:08:17.000Z
2021-06-08T01:14:57.000Z
include/Simulator/Engine.h
maerhart/llhd
08ee9b709e200391a6998fe7510956dc57c0f133
[ "Apache-2.0" ]
10
2020-06-08T23:06:39.000Z
2020-06-16T17:59:16.000Z
include/Simulator/Engine.h
maerhart/llhd
08ee9b709e200391a6998fe7510956dc57c0f133
[ "Apache-2.0" ]
null
null
null
#ifndef LLHD_SIMULATOR_ENGINE_H #define LLHD_SIMULATOR_ENGINE_H #include "Dialect/LLHD/LLHDOps.h" #include "Simulator/State.h" #include "mlir/ExecutionEngine/ExecutionEngine.h" #include "mlir/IR/Module.h" namespace mlir { namespace llhd { namespace sim { class Engine { public: /// Initialize an LLHD simulation engine. This initializes the state, as well /// as the mlir::ExecutionEngine with the given module. Engine(llvm::raw_ostream &out, OwningModuleRef &module, MLIRContext &context, std::string root); /// Run simulation up to n steps. Pass n=0 to run indefinitely. int simulate(int n); /// Build the instance layout of the design. void buildLayout(ModuleOp module); /// Get a reference to the module ModuleOp *getModuleRef() { return &module; } /// Get the simulation state. State *getState() { return state.get(); } private: void walkEntity(EntityOp entity, Instance &child); llvm::raw_ostream &out; std::string root; std::unique_ptr<State> state; std::unique_ptr<ExecutionEngine> engine; ModuleOp module; }; } // namespace sim } // namespace llhd } // namespace mlir #endif // LLHD_SIMULATOR_ENGINE_H
24.291667
79
0.7247
92d0c34fb0d8bb51f4e669c4afc1c220560396d8
448
h
C
VRUIKitTools/VRNavigationBar.h
IvanRublev/VRUIKitTools
47f6dc977f5ac4bf8e5414f4a2f554de0b1767e7
[ "MIT" ]
null
null
null
VRUIKitTools/VRNavigationBar.h
IvanRublev/VRUIKitTools
47f6dc977f5ac4bf8e5414f4a2f554de0b1767e7
[ "MIT" ]
null
null
null
VRUIKitTools/VRNavigationBar.h
IvanRublev/VRUIKitTools
47f6dc977f5ac4bf8e5414f4a2f554de0b1767e7
[ "MIT" ]
null
null
null
// // VRNavigationBar.h // VRUIKitTools // // Created by Ivan Rublev on 11/2/14. // Copyright (c) 2014 Ivan Rublev http://ivanrublev.me. All rights reserved. // #import <UIKit/UIKit.h> @interface VRNavigationBar : UINavigationBar - (void)setBackgroundPatternImage:(UIImage *)backgroundPatternImage UI_APPEARANCE_SELECTOR; - (UIImage *)backgroundPatternImage UI_APPEARANCE_SELECTOR; @property (nonatomic, assign) BOOL ignoreHiddenChange; @end
28
91
0.772321
92fb24ad932d96c21f6161bbe58aecaf80ba8376
12,704
c
C
randlife.c
hikalium/randlife
ba7af104e6788dee3f2b30a4360a57addf4a78e9
[ "MIT" ]
null
null
null
randlife.c
hikalium/randlife
ba7af104e6788dee3f2b30a4360a57addf4a78e9
[ "MIT" ]
null
null
null
randlife.c
hikalium/randlife
ba7af104e6788dee3f2b30a4360a57addf4a78e9
[ "MIT" ]
null
null
null
// // randlife.c // by hikalium // 2012 - 2015 // #include <stdio.h> #include <stdlib.h> #include <string.h> // environment depended #ifdef _WIN32 #include <conio.h> // getch(); // kbhit(); int getchar_noWait(void) { if(kbhit()){ return getch(); } return -1; } void clearScreen(void) { system("cls"); } #endif #if defined(__APPLE__) || defined(__linux) #include <time.h> #include <termios.h> #include <unistd.h> #include <fcntl.h> int getchar_noWait(void) { // retv: -1 (no any inputs) or character code. struct termios oldt, newt; int ch, oldf; tcgetattr(STDIN_FILENO, &oldt); newt = oldt; newt.c_lflag &= ~(ICANON | ECHO); tcsetattr(STDIN_FILENO, TCSANOW, &newt); oldf = fcntl(STDIN_FILENO, F_GETFL, 0); fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK); ch = getchar(); tcsetattr(STDIN_FILENO, TCSANOW, &oldt); fcntl(STDIN_FILENO, F_SETFL, oldf); if(ch != EOF){ return ch; } return -1; } void clearScreen(void) { system("clear"); } #endif /*---from CHNOSProject----*/ /*boolean*/ #define True 1 #define False 0 /*null*/ #define Null 0 typedef unsigned char uchar; typedef unsigned int uint; typedef struct DATA_LOCATION_2DU { uint x; uint y; } DATA_Location2DU; /*----randlife----*/ #define CONSOLE_OUT #define VIEW_WAIT #define VIEW_WAIT_USEC 50000 //bitsize must be less than (1 << (16 - 2)). #define MATH_BINARY_MAP_2D_MAXSIZE 0x4000 #define RULE_BE_BORN 2 #define RULE_BE_ALIVE 1 #define RULE_DIE 0 #define TESTSIZEX 50 #define TESTSIZEY 50 typedef DATA_Location2DU DATA_Size2DU; typedef struct MATH_BINARY_MAP_2D { DATA_Size2DU bitsize; uint bytesize; uint *map; //uint=32bit } MATH_BinaryMap2D; typedef struct LIFEGAME { MATH_BinaryMap2D *mainmap, *submap; uint generation; uint livecells; uchar rule[9]; } AL_LifeGame; AL_LifeGame *AL_LifeGame_Initialize(uint bitx, uint bity); uint AL_LifeGame_SetRule(AL_LifeGame *lifegame, const uchar *rule); uint AL_LifeGame_Next(AL_LifeGame *lifegame); MATH_BinaryMap2D *MATH_BinaryMap2D_Initialize(uint bitx, uint bity); uint MATH_BinaryMap2D_Free(MATH_BinaryMap2D *map); uint MATH_BinaryMap2D_GetBit(MATH_BinaryMap2D *map, int bitx, int bity); uint MATH_BinaryMap2D_SetBit(MATH_BinaryMap2D *map, int bitx, int bity, uint data); uint MATH_BinaryMap2D_CopyMap(MATH_BinaryMap2D *destination, MATH_BinaryMap2D *source); FILE *logfile; FILE *maplogfile; int main(int argc, char *argv[]) { int x, y, i, k, count, c; AL_LifeGame *lifegame; uint livecells_old; uint nextflag; uint starttime; uchar rule[9] = { RULE_DIE, RULE_DIE, RULE_BE_ALIVE, RULE_BE_ALIVE | RULE_BE_BORN, RULE_DIE, RULE_DIE, RULE_DIE, RULE_DIE, RULE_DIE, }; MATH_BinaryMap2D *outmap; char s[1024]; //Log file setting snprintf(s, sizeof(s), "log-%dx%d.txt", TESTSIZEX, TESTSIZEY); logfile = fopen(s, "w"); if(logfile == Null){ printf("main:Log file error.\nAbort.\n"); exit(EXIT_FAILURE); } snprintf(s, sizeof(s), "log-%dx%d-map.txt", TESTSIZEX, TESTSIZEY); maplogfile = fopen(s, "w"); if(maplogfile == Null){ printf("main:Log file error.\nAbort.\n"); exit(EXIT_FAILURE); } nextflag = False; lifegame = AL_LifeGame_Initialize(TESTSIZEX, TESTSIZEY); outmap = MATH_BinaryMap2D_Initialize(TESTSIZEX, TESTSIZEY); #ifdef CONSOLE_OUT printf("%p\n", lifegame); #endif AL_LifeGame_SetRule(lifegame, rule); //MATH_BinaryMap2D_SetBit(lifegame->mainmap, 10, 10, True); //MATH_BinaryMap2D_SetBit(lifegame->mainmap, 10, 11, True); //MATH_BinaryMap2D_SetBit(lifegame->mainmap, 10, 12, True); //MATH_BinaryMap2D_SetBit(lifegame->mainmap, 11, 10, True); //MATH_BinaryMap2D_SetBit(lifegame->mainmap, 12, 11, True); //MATH_BinaryMap2D_SetBit(lifegame->mainmap, 15, 7, True); //MATH_BinaryMap2D_SetBit(lifegame->mainmap, 16, 7, True); //MATH_BinaryMap2D_SetBit(lifegame->mainmap, 17, 7, True); //MATH_BinaryMap2D_SetBit(lifegame->mainmap, 18, 7, True); //MATH_BinaryMap2D_SetBit(lifegame->mainmap, 19, 7, True); fprintf(logfile, "<randlife.c>\n\nMapSize = %dx%d = %d cells\n", lifegame->mainmap->bitsize.x, lifegame->mainmap->bitsize.y, lifegame->mainmap->bitsize.x * lifegame->mainmap->bitsize.y); starttime = time(Null); for(k = 0; k < 1024; k++){ count = 0; livecells_old = 0; srand(time(Null) + k); for(y = 0; y < (int)lifegame->mainmap->bitsize.y; y++){ for(x = 0; x < (int)lifegame->mainmap->bitsize.x; x++){ MATH_BinaryMap2D_SetBit(lifegame->mainmap, x, y, rand() & 1); } } MATH_BinaryMap2D_CopyMap(lifegame->submap, lifegame->mainmap); MATH_BinaryMap2D_CopyMap(outmap, lifegame->mainmap); lifegame->generation = 0; #ifdef CONSOLE_OUT clearScreen(); printf("%d:generation=%d:cells=Unknown / %d\n", k, lifegame->generation, lifegame->mainmap->bitsize.x * lifegame->mainmap->bitsize.y); printf(" "); for(x = 0; x < (int)lifegame->mainmap->bitsize.x; x++){ printf("%2d", x); } printf("\n"); for(y = 0; y < (int)lifegame->mainmap->bitsize.y; y++){ printf("%2d", y); for(x = 0; x < (int)lifegame->mainmap->bitsize.x; x++){ printf("%2c", MATH_BinaryMap2D_GetBit(lifegame->mainmap, x, y) ? 'O' : ' '); } printf("\n"); } printf("----\n"); printf("Press Ctrl + c to exit.\n"); #endif for(i = 0; i < 16384; i++){ #ifdef CONSOLE_OUT clearScreen(); printf("\n"); #endif AL_LifeGame_Next(lifegame); #ifdef CONSOLE_OUT printf("%d:generation=%d:cells=%d / %d\n", k, lifegame->generation, lifegame->livecells, lifegame->mainmap->bitsize.x * lifegame->mainmap->bitsize.y); printf(" "); for(x = 0; x < (int)lifegame->mainmap->bitsize.x; x++){ printf("%2d", x); } printf("\n"); for(y = 0; y < (int)lifegame->mainmap->bitsize.y; y++){ printf("%2d", y); for(x = 0; x < (int)lifegame->mainmap->bitsize.x; x++){ printf("%2c", MATH_BinaryMap2D_GetBit(lifegame->mainmap, x, y) ? 'O' : ' '); } printf("\n"); } printf("----\n"); printf("q: quit, n: nextWorld, other: pause.\n"); #endif if(livecells_old == lifegame->livecells){ if(count == 5){ #ifdef CONSOLE_OUT printf("\nEnd of growing. Go to next world."); #endif //fprintf(logfile,"%d:%d:End(livecells = %d)\n", k, i, lifegame->livecells); fprintf(logfile,"%d,%d,%d\n", k, i, lifegame->livecells); break; } else{ count++; } } else{ count = 0; livecells_old = lifegame->livecells; } c = getchar_noWait(); if(c != -1){ switch(c){ case 'n': #ifdef CONSOLE_OUT printf("\nEnd of growing. Go to next world."); #endif fprintf(logfile,"%d:%d(Force):End(livecells = %d)\n", k, i, lifegame->livecells); nextflag = True; break; case 'q': #ifdef CONSOLE_OUT printf("\nQuit.\n"); #endif fprintf(logfile,"%d:%d(Quit):End(livecells = %d)\n", k, i, lifegame->livecells); exit(EXIT_SUCCESS); default: #ifdef CONSOLE_OUT printf("\nPause."); #endif getchar(); break; } } if(nextflag){ nextflag = False; break; } #ifdef VIEW_WAIT usleep(VIEW_WAIT_USEC); #endif } if(i == 16384){ //fprintf(logfile,"%d:%d(MAX):End(livecells = %d)\n", k, i, lifegame->livecells); fprintf(logfile,"%d,%d,%d\n", k, i, lifegame->livecells); fprintf(maplogfile,"%d,%d,%d\n", k, i, lifegame->livecells); fprintf(maplogfile,"Map at generation 0.\n"); for(y = 0; y < (int)outmap->bitsize.y; y++){ for(x = 0; x < (int)outmap->bitsize.x; x++){ fprintf(maplogfile,"%c", MATH_BinaryMap2D_GetBit(outmap, x, y) ? '@' : ' '); } fprintf(maplogfile,"\n"); } fprintf(maplogfile,"Map at generation %d.\n", lifegame->generation); for(y = 0; y < (int)lifegame->mainmap->bitsize.y; y++){ for(x = 0; x < (int)lifegame->mainmap->bitsize.x; x++){ fprintf(maplogfile,"%2c", MATH_BinaryMap2D_GetBit(lifegame->mainmap, x, y) ? 'O' : ' '); } fprintf(maplogfile,"\n"); } fprintf(maplogfile,"----\n"); } } fprintf(logfile,"Processed in %ld seconds.\n", time(Null) - starttime); fclose(maplogfile); fclose(logfile); return 0; } AL_LifeGame *AL_LifeGame_Initialize(uint bitx, uint bity) { AL_LifeGame *lifegame; uint x, y; lifegame = malloc(sizeof(AL_LifeGame)); lifegame->mainmap = MATH_BinaryMap2D_Initialize(bitx, bity); lifegame->submap = MATH_BinaryMap2D_Initialize(bitx, bity); lifegame->generation = 0; lifegame->livecells = 0xffffffff; if(lifegame->mainmap == Null || lifegame->submap == Null){ #ifdef CONSOLE_OUT printf("AL_LifeGame_Initialize:Map initialize error.\nAbort.\n"); #endif exit(EXIT_FAILURE); } return lifegame; } uint AL_LifeGame_SetRule(AL_LifeGame *lifegame, const uchar *rule) { uint i; if(lifegame == Null){ return 1; } for(i = 0; i < 9; i++){ lifegame->rule[i] = rule[i]; } return 0; } uint AL_LifeGame_Next(AL_LifeGame *lifegame) { uint lives, livecells; int x, y; if(lifegame == Null){ return 1; } livecells = 0; for(y = 0; y < (int)lifegame->mainmap->bitsize.y; y++){ for(x = 0; x < (int)lifegame->mainmap->bitsize.x; x++){ lives = 0; lives += MATH_BinaryMap2D_GetBit(lifegame->mainmap, x - 1, y - 1); lives += MATH_BinaryMap2D_GetBit(lifegame->mainmap, x - 1, y + 0); lives += MATH_BinaryMap2D_GetBit(lifegame->mainmap, x - 1, y + 1); lives += MATH_BinaryMap2D_GetBit(lifegame->mainmap, x + 0, y - 1); lives += MATH_BinaryMap2D_GetBit(lifegame->mainmap, x + 0, y + 1); lives += MATH_BinaryMap2D_GetBit(lifegame->mainmap, x + 1, y - 1); lives += MATH_BinaryMap2D_GetBit(lifegame->mainmap, x + 1, y + 0); lives += MATH_BinaryMap2D_GetBit(lifegame->mainmap, x + 1, y + 1); if(lives >= 9){ #ifdef CONSOLE_OUT printf("AL_LifeGame_Next:lives error.\nAbort.\n"); #endif exit(EXIT_FAILURE); } livecells += lives; switch(lifegame->rule[lives]){ case RULE_DIE: MATH_BinaryMap2D_SetBit(lifegame->submap, x, y, False); break; case RULE_BE_BORN: case (RULE_BE_BORN | RULE_BE_ALIVE): MATH_BinaryMap2D_SetBit(lifegame->submap, x, y, True); break; } } } MATH_BinaryMap2D_CopyMap(lifegame->mainmap, lifegame->submap); lifegame->generation++; lifegame->livecells = (livecells >> 3); return 0; } MATH_BinaryMap2D *MATH_BinaryMap2D_Initialize(uint bitx, uint bity) { uint size; MATH_BinaryMap2D *map; size = ((bitx * bity) + (32 - 1)) >> (5 - 3); if(size > MATH_BINARY_MAP_2D_MAXSIZE){ printf("MATH_BinaryMap2D_Initialize:Too large map size.\nAbort.\n"); exit(EXIT_FAILURE); } map = malloc(sizeof(MATH_BinaryMap2D)); map->bitsize.x = bitx; map->bitsize.y = bity; map->bytesize = size; map->map = malloc(size); memset(map->map, 0, size); return map; } uint MATH_BinaryMap2D_Free(MATH_BinaryMap2D *map) { free(map->map); free(map); return 0; } uint MATH_BinaryMap2D_GetBit(MATH_BinaryMap2D *map, int bitx, int bity) { uint bit, modbit; if(map == Null){ return 0; } if(map->map == Null){ return 0; } if(bitx >= (int)map->bitsize.x){ if(bitx < (int)(map->bitsize.x << 1)){ bitx -= map->bitsize.x; } else{ bitx = bitx % map->bitsize.x; } } else if(bitx < 0){ if(bitx >= -(int)map->bitsize.x){ bitx += map->bitsize.x; } else{ bitx = 4 + (bitx % map->bitsize.x); } } if(bity >= (int)map->bitsize.y){ if(bity < (int)(map->bitsize.y << 1)){ bity -= map->bitsize.y; } else{ bity = bity % map->bitsize.y; } } else if(bity < 0){ if(bity >= -(int)map->bitsize.y){ bity += map->bitsize.y; } else{ bity = 4 + (bity % map->bitsize.y); } } bit = (bity * map->bitsize.x) + bitx; modbit = bit & (32 - 1); return ((map->map[bit >> 5] & (1 << modbit)) >> modbit); } uint MATH_BinaryMap2D_SetBit(MATH_BinaryMap2D *map, int bitx, int bity, uint data) { uint bit, modbit; if(map == Null){ return 1; } if(map->map == Null){ return 2; } if(bitx >= (int)map->bitsize.x){ if(bitx < (int)(map->bitsize.x << 1)){ bitx -= map->bitsize.x; } else{ bitx = bitx % map->bitsize.x; } } else if(bitx < 0){ if(bitx >= -(int)map->bitsize.x){ bitx += map->bitsize.x; } else{ bitx = 4 + (bitx % map->bitsize.x); } } if(bity >= (int)map->bitsize.y){ if(bity < (int)(map->bitsize.y << 1)){ bity -= map->bitsize.y; } else{ bity = bity % map->bitsize.y; } } else if(bity < 0){ if(bity >= -(int)map->bitsize.y){ bity += map->bitsize.y; } else{ bity = 4 + (bity % map->bitsize.y); } } bit = (bity * map->bitsize.x) + bitx; modbit = bit & ((1 << 5) - 1); if(data){ map->map[bit >> 5] = map->map[bit >> 5] | (1 << modbit); } else{ map->map[bit >> 5] = map->map[bit >> 5] & ~(1 << modbit); } return 0; } uint MATH_BinaryMap2D_CopyMap(MATH_BinaryMap2D *destination, MATH_BinaryMap2D *source) { memcpy(destination->map, source->map, destination->bytesize); return 0; }
24.106262
187
0.644679
a1d38caedcf457d12c7819b39983427cf01f9391
3,969
c
C
src/econRS.c
Argonne-National-Laboratory/ENPEP-windows
c74836cdd2ec1e6ecb1bf53b84729c02f75f6364
[ "BSD-3-Clause" ]
null
null
null
src/econRS.c
Argonne-National-Laboratory/ENPEP-windows
c74836cdd2ec1e6ecb1bf53b84729c02f75f6364
[ "BSD-3-Clause" ]
null
null
null
src/econRS.c
Argonne-National-Laboratory/ENPEP-windows
c74836cdd2ec1e6ecb1bf53b84729c02f75f6364
[ "BSD-3-Clause" ]
null
null
null
/******************************************************************* COPYRIGHT NOTIFICATION ******************************************************************** Copyright © 2021, UChicago Argonne, LLC All Rights Reserved Software Name: ENPEP- Balance By: Argonne National Laboratory OPEN SOURCE LICENSE ******************************************************************** 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. ******************************************************************** DISCLAIMER 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 <stdio.h> #include <math.h> #include "cmc_f2c.h" #include <stdlib.h> #include "f2c.h" #include "structures.h" void econRS(void) { extern int Roundup(double aValue); extern FILE *fp11, *fp6, *fp21, *fpReEcon; extern char LinkNodeNames[14][999][6]; extern char LinkNodeSector[14][999][6]; #define pprj_ref(a_1,a_2) res_1.pprj[(a_2)*75 + a_1 - 76] #define zen_ref(a_1,a_2,a_3) pri_1.zen[((a_3)*999 + (a_2))*2 + a_1 - 2001] double q, p1, p2; int i, iolk; integer ks; real rat; int studyEndYear; studyEndYear = var_1.iyrb + var_1.nper-1; for(i=1;i <= var_1.nnrep;i++) { iolk = res_1.iours[i - 1]; if(var_1.ntime == 1){ q = zen_ref(1, iolk, var_1.ntime); p1 = res_1.a[i - 1] - (res_1.b[i - 1]*q + res_1.ab[i - 1]*q*q); // price before baseyear p2 = res_1.noTaxPrice[i-1][var_1.ntime-1]; res_1.fuelCost[i-1][var_1.ntime-1] = p1*(q) + res_1.b[i - 1]*(q*q)/2 + res_1.ab[i - 1]*(q*q*q)/3; res_1.economicRent[i-1][var_1.ntime-1] = q*p2 - res_1.fuelCost[i-1][var_1.ntime-1]; } else { q = zen_ref(1, iolk, var_1.ntime); p1 = res_1.noTaxPrice[i-1][var_1.ntime-2]; //previous year price p2 = res_1.noTaxPrice[i-1][var_1.ntime-1]; // current year price ks = res_1.kpr[i - 1]; rat = pprj_ref(ks, var_1.ntime - 1) + 1.f; res_1.fuelCost[i-1][var_1.ntime-1] = p1 * rat * (q) + res_1.b[i - 1]*(q*q)/2 + res_1.ab[i - 1]*(q*q*q)/3; res_1.economicRent[i-1][var_1.ntime-1] = (q)*p2 - res_1.fuelCost[i-1][var_1.ntime-1]; } fprintf(fpReEcon, "%4d;%s;%s;%s;%15.2f;%10.2f;%15.2f;%15.2f;%4d\n", var_1.itime, LinkNodeSector[7][i], LinkNodeNames[7][i], "RS", q/units_1.unitcnvt[8], res_1.noTaxPrice[i-1][var_1.ntime-1]/units_1.unitcnvt[3], res_1.fuelCost[i-1][var_1.ntime-1]/units_1.unitcnvt[0], res_1.economicRent[i-1][var_1.ntime-1]/units_1.unitcnvt[0], studyEndYear); } // end of for loop } // end of econRS
38.163462
755
0.628874
dafa5682dfadc22a8e29cde848b992fca3b1086d
295
h
C
components/cloud/baidu/iotcore_client/src/_md5.h
flyghost/OneOS-V2.1.0
6fedab0558c07fe679d63ba1eb8ee9992c044d86
[ "Apache-2.0" ]
null
null
null
components/cloud/baidu/iotcore_client/src/_md5.h
flyghost/OneOS-V2.1.0
6fedab0558c07fe679d63ba1eb8ee9992c044d86
[ "Apache-2.0" ]
null
null
null
components/cloud/baidu/iotcore_client/src/_md5.h
flyghost/OneOS-V2.1.0
6fedab0558c07fe679d63ba1eb8ee9992c044d86
[ "Apache-2.0" ]
null
null
null
#pragma once typedef struct { unsigned int count[2]; unsigned int state[4]; unsigned char buffer[64]; } MD5_CTX; void _MD5Init(MD5_CTX *context); void _MD5Update(MD5_CTX *context, unsigned char *input, unsigned int inputlen); void _MD5Final(MD5_CTX *context, unsigned char digest[16]);
21.071429
79
0.749153
1ccc9731add971fd1f4b45af372e0f46f323a625
1,717
h
C
Liatris/src/Liatris/Renderer/PerspectiveCamera.h
briandl2000/LiatrisPublic
a4960eacc73b31e967e3716c7ce2dbfbc62a9925
[ "Apache-2.0" ]
null
null
null
Liatris/src/Liatris/Renderer/PerspectiveCamera.h
briandl2000/LiatrisPublic
a4960eacc73b31e967e3716c7ce2dbfbc62a9925
[ "Apache-2.0" ]
null
null
null
Liatris/src/Liatris/Renderer/PerspectiveCamera.h
briandl2000/LiatrisPublic
a4960eacc73b31e967e3716c7ce2dbfbc62a9925
[ "Apache-2.0" ]
null
null
null
#pragma once #include <glm/glm.hpp> #include <glm/ext/scalar_constants.hpp> namespace Liatris { class PerspectiveCamera { public: PerspectiveCamera(float fov, float aspect, float n, float f); const glm::vec3& GetPosition() const { return m_Position; } float GetRotationX() const { return m_UpAngle; } float GetRotationY() const { return m_RightAngle; } void SetPosition(const glm::vec3& position) { m_Position = position; RecalculateViewMatrix();} void SetRotateX(float rotation) { m_UpAngle = rotation; RecalculateViewMatrix();} void SetRotateY(float rotation) { m_RightAngle = rotation; RecalculateViewMatrix();} void AddRotateX(float rotation) { m_UpAngle += rotation; float clampRotation = glm::pi<float>() * 0.5; m_UpAngle = glm::clamp(m_UpAngle, -clampRotation, clampRotation); RecalculateViewMatrix(); } void AddRotateY(float rotation) { m_RightAngle += rotation; RecalculateViewMatrix();} void SetAspectRatio(float aspectRatio) { m_Aspect = aspectRatio; RecalculateProjectionMatrix(); } void SetFovRatio(float fov) { m_Fov = fov; RecalculateProjectionMatrix(); } const glm::mat4& GetProjectionMatrix() const { return m_ProjectionMatrix; } const glm::mat4& GetViewMatrix() const { return m_ViewMatrix; } const glm::mat4& GetViewProjectionMatrix() const { return m_ViewProjectionMatrix; } private: void RecalculateViewMatrix(); void RecalculateProjectionMatrix(); private: glm::mat4 m_ProjectionMatrix; glm::mat4 m_ViewMatrix; glm::mat4 m_ViewProjectionMatrix; glm::vec3 m_Position; float m_RightAngle = 0.; float m_UpAngle = 0.; float m_Fov; float m_Aspect = 0.; float m_Near = 0.; float m_Far = 0.; }; }
31.796296
99
0.726267
2d5fed37f10982fb76054e038a60c05fb5eff506
10,100
h
C
primesieve.h
clayne/PrimeSieve
444af521734a7112471f41d0e6b662a02c3b9f4f
[ "MIT" ]
2
2021-02-17T21:51:07.000Z
2022-01-29T03:05:17.000Z
primesieve.h
clayne/PrimeSieve
444af521734a7112471f41d0e6b662a02c3b9f4f
[ "MIT" ]
null
null
null
primesieve.h
clayne/PrimeSieve
444af521734a7112471f41d0e6b662a02c3b9f4f
[ "MIT" ]
1
2021-02-17T21:51:09.000Z
2021-02-17T21:51:09.000Z
/******************************************************************* * * Author: Kareem Omar * kareem.h.omar@gmail.com * https://github.com/komrad36 * * Last updated Jan 29, 2021 *******************************************************************/ #pragma once #include <cstdint> #include <immintrin.h> class PrimeSieve { // using decls using U32 = uint32_t; using U64 = uint64_t; // forward decls private: class FwdIterator; class FwdIteratorEndSentinel; class FwdIteratorFrom; class RevIterator; class RevIteratorEndSentinel; class RevIteratorFrom; // constants private: static constexpr U64 kBitsPerSeg = 3ULL * 5 * 7 * 11 * 13 * 17; static constexpr U64 kBlocksPerSeg = (kBitsPerSeg + 63) >> 6; static constexpr U64 kUnusedBitsPerSeg = 64 - (kBitsPerSeg & 63); static constexpr U64 kMaxThreads = 32; // static methods private: static U64 ComputeAutoNumThreads(); static void ComputeInternal(U64* __restrict const pSieve, U64 iStart, U64 iEnd); static U64 CountLeadingZeros(U64 x) { return _lzcnt_u64(x); } static U64 CountTrailingZeros(U64 x) { return _tzcnt_u64(x); } static U64 ShiftRight(U64 x, U32 i) { #if defined(__clang__) || defined(__GNUC__) return x >> (i & 63U); #else return _shrx_u64(x, i); #endif } static U64 ShiftRight(U64 x, U64 i) { #if defined(__clang__) || defined(__GNUC__) return x >> (i & 63ULL); #else return _shrx_u64(x, static_cast<U32>(i)); #endif } static U64 ShiftLeft(U64 x, U32 i) { #if defined(__clang__) || defined(__GNUC__) return x << (i & 63U); #else return _shlx_u64(x, i); #endif } static U64 ShiftLeft(U64 x, U64 i) { #if defined(__clang__) || defined(__GNUC__) return x << (i & 63ULL); #else return _shlx_u64(x, static_cast<U32>(i)); #endif } static U64 SmartRem(U64 a, U64 b) { // clang has a bug that results in suboptimal // codegen if you try this, but it generates // the right thing anyway if you don't #ifdef __clang__ return a % b; #else return static_cast<U32>((a | b) >> 32) ? a % b : static_cast<U32>(a) % static_cast<U32>(b); #endif } // public methods public: // x: initial value to compute sieve up to, i.e. so that primality queries <= x will then be constant time // 0 == no initial computation (default) // // numThreads: thread count for large computations // 0 == auto (default) PrimeSieve(U64 x = 0, U64 numThreads = 0) : m_numThreads(numThreads ? numThreads > kMaxThreads ? kMaxThreads : numThreads : ComputeAutoNumThreads()) { GrowTo(x); } ~PrimeSieve(); // compute sieve up to x, i.e. so that primality queries for <= x will then be constant time void GrowTo(U64 x) { if (x >= 3) GrowToInternal((x - 1) / (kBitsPerSeg << 1) + 1); } // query primality of x, automatically growing sieve as necessary to reach x bool IsPrime(U64 x) { if (x == 2) return true; if (!(x & 1)) return false; const U64 iSeg = x / (kBitsPerSeg << 1); if (iSeg >= m_numSegsComputed) GrowToInternal(iSeg + 1); x = (x >> 1) + kUnusedBitsPerSeg * iSeg; return !(m_pSieve[x >> 6] & (1ULL << (x & 63))); } // returns an object which iterates up through primes, // starting at the next prime after (and not including) x // and continues forever FwdIteratorFrom IterateForwardFrom(U64 x) { return FwdIteratorFrom(*this, x); } // returns an object which iterates down through primes, // starting at the previous prime before (and not including) x // and continues until all primes are visited (i.e. ends after visiting 2) RevIteratorFrom IterateBackwardFrom(U64 x) { return RevIteratorFrom(*this, x); } // return next prime after (and not including) x U64 NextPrime(U64 x) { return *IterateForwardFrom(x).begin(); } // return the previous prime before (and not including) x // behavior is undefined for x <= 2 U64 PrevPrime(U64 x) { return *IterateBackwardFrom(x).begin(); } FwdIterator begin() { return *this; } FwdIteratorEndSentinel end() { return FwdIteratorEndSentinel(); } // forward iterator private: class FwdIteratorEndSentinel {}; class FwdIterator { friend class PrimeSieve; FwdIterator(PrimeSieve& sieve) : m_sieve(sieve), m_pSieve(m_sieve.m_pSieve), m_block(0), m_iBlock(~0ULL), m_iEndBlock(PrimeSieve::kBlocksPerSeg * m_sieve.m_numSegsComputed), m_x(2) {} FwdIterator(PrimeSieve& sieve, U64 x) : m_sieve(sieve) { const U64 iBit_NativeSpace = (x + 1) >> 1; const U64 iSeg = iBit_NativeSpace / PrimeSieve::kBitsPerSeg; if (iSeg >= sieve.m_numSegsComputed) m_sieve.GrowToInternal(iSeg + 1); const U64 iBit_SegSpace = iBit_NativeSpace + PrimeSieve::kUnusedBitsPerSeg * iSeg; m_iEndBlock = PrimeSieve::kBlocksPerSeg * m_sieve.m_numSegsComputed; m_pSieve = m_sieve.m_pSieve; m_iBlock = iBit_SegSpace >> 6; m_block = (~m_pSieve[m_iBlock]) & (~0ULL << (iBit_SegSpace & 63)); AdvanceInternal(); } void AdvanceInternal() { while (!m_block) { if (++m_iBlock >= m_iEndBlock) { m_sieve.GrowToInternal(m_sieve.m_numSegsComputed + 1); m_iEndBlock = PrimeSieve::kBlocksPerSeg * m_sieve.m_numSegsComputed; m_pSieve = m_sieve.m_pSieve; } m_block = ~m_pSieve[m_iBlock]; } m_x = (m_iBlock << 7) + (CountTrailingZeros(m_block) << 1) - (kUnusedBitsPerSeg << 1) * (m_iBlock / kBlocksPerSeg) + 1; } public: bool operator==(const PrimeSieve::FwdIteratorEndSentinel&) { return false; } bool operator!=(const PrimeSieve::FwdIteratorEndSentinel&) { return true; } void operator++() { m_block &= m_block - 1; AdvanceInternal(); } U64 operator*() const { return m_x; } private: PrimeSieve& m_sieve; const U64* __restrict m_pSieve; U64 m_block; U64 m_iBlock; U64 m_iEndBlock; U64 m_x; }; class FwdIteratorFrom { friend class PrimeSieve; FwdIteratorFrom(PrimeSieve& sieve, U64 x) : m_sieve(sieve), m_x(x) {} public: FwdIterator begin() { return m_x >= 2 ? FwdIterator(m_sieve, m_x) : FwdIterator(m_sieve); } FwdIteratorEndSentinel end() { return FwdIteratorEndSentinel(); } private: PrimeSieve& m_sieve; U64 m_x; }; // reverse iterator private: class RevIteratorEndSentinel {}; class RevIterator { friend class PrimeSieve; RevIterator(PrimeSieve& sieve, U64 x) : m_sieve(sieve) { if (x <= 2) { m_x = 1; return; } const U64 iBit_NativeSpace = x >> 1; const U64 iSeg = iBit_NativeSpace / PrimeSieve::kBitsPerSeg; if (iSeg >= sieve.m_numSegsComputed) m_sieve.GrowToInternal(iSeg + 1); const U64 iBit_SegSpace = iBit_NativeSpace + PrimeSieve::kUnusedBitsPerSeg * iSeg; m_pSieve = m_sieve.m_pSieve; m_iBlock = iBit_SegSpace >> 6; m_block = ~(m_pSieve[m_iBlock] | ShiftLeft(~0ULL, iBit_SegSpace)); m_x = x; AdvanceInternal(); } void AdvanceInternal() { while (!m_block) { if (m_iBlock == 0) { --m_x; return; } m_block = ~m_pSieve[--m_iBlock]; } m_x = (m_iBlock << 7) + ((CountLeadingZeros(m_block) ^ 63) << 1) - (kUnusedBitsPerSeg << 1) * (m_iBlock / kBlocksPerSeg) + 1; } public: bool operator==(const PrimeSieve::RevIteratorEndSentinel&) { return m_x == 1; } bool operator!=(const PrimeSieve::RevIteratorEndSentinel&) { return m_x != 1; } void operator++() { m_block &= ~ShiftRight(1ULL << 63, CountLeadingZeros(m_block)); AdvanceInternal(); } U64 operator*() const { return m_x; } private: PrimeSieve& m_sieve; const U64* __restrict m_pSieve; U64 m_block; U64 m_iBlock; U64 m_x; }; class RevIteratorFrom { friend class PrimeSieve; RevIteratorFrom(PrimeSieve& sieve, U64 x) : m_sieve(sieve), m_x(x) {} public: RevIterator begin() { return RevIterator(m_sieve, m_x); } RevIteratorEndSentinel end() { return RevIteratorEndSentinel(); } private: PrimeSieve& m_sieve; U64 m_x; }; // private methods private: void GrowToInternal(U64 newNumSegs); void ComputeToInternal(U64 newNumSegs); // member variables private: U64* __restrict m_pSieve = nullptr; U64 m_numSegsAllocated = 0; U64 m_numSegsComputed = 0; U64 m_numThreads; };
26.509186
192
0.534356
e1396e1045acbfb710a52bad3854a581fb6cfd96
6,006
h
C
resourceloaders/shaderloader/src/d3d9reflectionhelper.h
JoJo2nd/Heart
4b50dfa6cbf87d32768f6c01b578bc1b23c18591
[ "BSD-3-Clause" ]
1
2016-05-14T09:22:26.000Z
2016-05-14T09:22:26.000Z
resourceloaders/shaderloader/src/d3d9reflectionhelper.h
JoJo2nd/Heart
4b50dfa6cbf87d32768f6c01b578bc1b23c18591
[ "BSD-3-Clause" ]
null
null
null
resourceloaders/shaderloader/src/d3d9reflectionhelper.h
JoJo2nd/Heart
4b50dfa6cbf87d32768f6c01b578bc1b23c18591
[ "BSD-3-Clause" ]
null
null
null
/******************************************************************** Written by James Moran Please see the file HEART_LICENSE.txt in the source's root directory. Original found at http://www.gamedev.net/topic/648016-replacement-for-id3dxconstanttable/ and based on wine-1.6\dlls\d3dx9_36\shader.c. Saved me reverse engineering it. *********************************************************************/ #include <vector> #include <string> #include <cstdint> #pragma once /* -- https://github.com/wine-compholio/wine-staging/tree/master/patches/d3dx9_36-GetShaderSemantics static const DWORD* skip_instruction(const DWORD *byte_code, UINT shader_model) { TRACE("Shader model %u\n", shader_model); /* Handle all special instructions whose arguments may contain D3DSIO_DCL * if ((*byte_code & D3DSI_OPCODE_MASK) == D3DSIO_COMMENT) { byte_code += 1 + ((*byte_code & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT); } else if (shader_model >= 2) { byte_code += 1 + ((*byte_code & D3DSI_INSTLENGTH_MASK) >> D3DSI_INSTLENGTH_SHIFT); } else if ((*byte_code & D3DSI_OPCODE_MASK) == D3DSIO_DEF) { byte_code += 1 + 5; } else { /* Handle remaining safe instructions * while (*++byte_code & (1 << 31)); } return byte_code; } static UINT get_shader_semantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, DWORD type) { const DWORD *ptr = byte_code; UINT shader_model = (*ptr >> 8) & 0xff; UINT i = 0; TRACE("Shader version: %#x\n", *ptr); ptr++; while (*ptr != D3DSIO_END) { if (*ptr & (1 << 31)) { FIXME("Opcode expected\n"); return 0; } else if ((*ptr & D3DSI_OPCODE_MASK) == D3DSIO_DCL) { DWORD param1 = *++ptr; DWORD param2 = *++ptr; DWORD usage = param1 & 0x1f; DWORD usage_index = (param1 >> 16) & 0xf; DWORD reg_type = (((param2 >> 11) & 0x3) << 3) | ((param2 >> 28) & 0x7); TRACE("D3DSIO_DCL param1: %#x, param2: %#x, usage: %u, usage_index: %u, reg_type: %u\n", param1, param2, usage, usage_index, reg_type); if (reg_type == type) { if (semantics) { semantics[i].Usage = usage; semantics[i].UsageIndex = usage_index; } i++; } ptr++; } else { ptr = skip_instruction(ptr, shader_model); } } return i; } */ enum EREGISTER_SET { RS_BOOL, RS_INT4, RS_FLOAT4, RS_SAMPLER }; struct ConstantDesc { std::string Name; EREGISTER_SET RegisterSet; int RegisterIndex; int RegisterCount; int Rows; int Columns; int Elements; int StructMembers; size_t Bytes; }; class ConstantTable { public: bool Create(const void* data); size_t GetConstantCount() const { return m_constants.size(); } const std::string& GetCreator() const { return m_creator; } const ConstantDesc* GetConstantByIndex(size_t i) const { return &m_constants[i]; } const ConstantDesc* GetConstantByName(const std::string& name) const; private: std::vector<ConstantDesc> m_constants; std::string m_creator; }; // Structs struct CTHeader { uint32_t Size; uint32_t Creator; uint32_t Version; uint32_t Constants; uint32_t ConstantInfo; uint32_t Flags; uint32_t Target; }; struct CTInfo { uint32_t Name; uint16_t RegisterSet; uint16_t RegisterIndex; uint16_t RegisterCount; uint16_t Reserved; uint32_t TypeInfo; uint32_t DefaultValue; }; struct CTType { uint16_t Class; uint16_t Type; uint16_t Rows; uint16_t Columns; uint16_t Elements; uint16_t StructMembers; uint32_t StructMemberInfo; }; // Shader instruction opcodes const uint32_t SIO_COMMENT = 0x0000FFFE; const uint32_t SIO_END = 0x0000FFFF; const uint32_t SI_OPCODE_MASK = 0x0000FFFF; const uint32_t SI_COMMENTSIZE_MASK = 0x7FFF0000; const uint32_t CTAB_CONSTANT = 0x42415443; // Member functions bool ConstantTable::Create(const void* data) { const uint32_t* ptr = static_cast<const uint32_t*>(data); while(*++ptr != SIO_END) { if((*ptr & SI_OPCODE_MASK) == SIO_COMMENT) { // Check for CTAB comment uint32_t comment_size = (*ptr & SI_COMMENTSIZE_MASK) >> 16; if(*(ptr+1) != CTAB_CONSTANT) { ptr += comment_size; continue; } // Read header const char* ctab = reinterpret_cast<const char*>(ptr+2); size_t ctab_size = (comment_size-1)*4; const CTHeader* header = reinterpret_cast<const CTHeader*>(ctab); if(ctab_size < sizeof(*header) || header->Size != sizeof(*header)) return false; m_creator = ctab + header->Creator; // Read constants m_constants.reserve(header->Constants); const CTInfo* info = reinterpret_cast<const CTInfo*>(ctab + header->ConstantInfo); for(uint32_t i = 0; i < header->Constants; ++i) { const CTType* type = reinterpret_cast<const CTType*>(ctab + info[i].TypeInfo); // Fill struct ConstantDesc desc; desc.Name = ctab + info[i].Name; desc.RegisterSet = static_cast<EREGISTER_SET>(info[i].RegisterSet); desc.RegisterIndex = info[i].RegisterIndex; desc.RegisterCount = info[i].RegisterCount; desc.Rows = type->Rows; desc.Columns = type->Columns; desc.Elements = type->Elements; desc.StructMembers = type->StructMembers; desc.Bytes = 4 * desc.Elements * desc.Rows * desc.Columns; m_constants.push_back(desc); } return true; } } return false; } const ConstantDesc* ConstantTable::GetConstantByName(const std::string& name) const { std::vector<ConstantDesc>::const_iterator it; for(it = m_constants.begin(); it != m_constants.end(); ++it) { if(it->Name == name) return &(*it); } return NULL; }
26.227074
100
0.612055
913cd975916253c8b1e304cbadb489f92c7af511
1,846
c
C
pow_accel_soc/software/u-boot-socfpga/post/board/lwmon5/dsp.c
ajblane/iota_fpga
2ec78e89bf263a84905aba92437da5ec091ab621
[ "MIT" ]
13
2018-05-24T07:02:26.000Z
2021-04-13T12:48:24.000Z
pow_accel_soc/software/u-boot-socfpga/post/board/lwmon5/dsp.c
ajblane/iota_fpga
2ec78e89bf263a84905aba92437da5ec091ab621
[ "MIT" ]
null
null
null
pow_accel_soc/software/u-boot-socfpga/post/board/lwmon5/dsp.c
ajblane/iota_fpga
2ec78e89bf263a84905aba92437da5ec091ab621
[ "MIT" ]
14
2018-05-08T23:40:47.000Z
2022-02-12T00:12:06.000Z
/* * (C) Copyright 2008 Dmitry Rakhchev, EmCraft Systems, rda@emcraft.com * * Developed for DENX Software Engineering GmbH * * See file CREDITS for list of people who contributed to this * project. * * 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 */ #include <common.h> #include <post.h> #if CONFIG_POST & CONFIG_SYS_POST_DSP #include <asm/io.h> /* This test verifies DSP status bits in FPGA */ DECLARE_GLOBAL_DATA_PTR; #define DSP_STATUS_REG 0xC4000008 #define FPGA_STATUS_REG 0xC400000C int dsp_post_test(int flags) { uint old_value; uint read_value; int ret; /* momorize fpga status */ old_value = in_be32((void *)FPGA_STATUS_REG); /* enable outputs */ out_be32((void *)FPGA_STATUS_REG, 0x30); /* generate sync signal */ out_be32((void *)DSP_STATUS_REG, 0x300); udelay(5); out_be32((void *)DSP_STATUS_REG, 0); udelay(500); /* read status */ ret = 0; read_value = in_be32((void *)DSP_STATUS_REG) & 0x3; if (read_value != 0x03) { post_log("\nDSP status read %08X\n", read_value); ret = 1; } /* restore fpga status */ out_be32((void *)FPGA_STATUS_REG, old_value); return ret; } #endif /* CONFIG_POST & CONFIG_SYS_POST_DSP */
26
71
0.719935
1ee11a0b8a6ead22891cbdeed015614826d2f422
5,152
c
C
lib/src/ast_comparison.c
xuguruogu/libcypher-parser
6465fdc8788c172df2edb213acb9938eac14fea9
[ "Apache-2.0" ]
121
2016-03-30T16:15:28.000Z
2022-03-07T15:22:52.000Z
lib/src/ast_comparison.c
xuguruogu/libcypher-parser
6465fdc8788c172df2edb213acb9938eac14fea9
[ "Apache-2.0" ]
37
2016-07-10T22:04:41.000Z
2021-12-03T03:03:58.000Z
lib/src/ast_comparison.c
xuguruogu/libcypher-parser
6465fdc8788c172df2edb213acb9938eac14fea9
[ "Apache-2.0" ]
36
2016-07-10T20:55:29.000Z
2022-02-05T06:58:40.000Z
/* vi:set ts=4 sw=4 expandtab: * * Copyright 2016, Chris Leishman (http://github.com/cleishm) * * 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 "../../config.h" #include "astnode.h" #include "operators.h" #include "util.h" #include <assert.h> struct comparison { cypher_astnode_t _astnode; unsigned int length; const cypher_operator_t **ops; const cypher_astnode_t *args[]; }; static cypher_astnode_t *clone(const cypher_astnode_t *self, cypher_astnode_t **children); static ssize_t detailstr(const cypher_astnode_t *self, char *str, size_t size); static void comparison_release(cypher_astnode_t *self); static const struct cypher_astnode_vt *parents[] = { &cypher_expression_astnode_vt }; const struct cypher_astnode_vt cypher_comparison_astnode_vt = { .parents = parents, .nparents = 1, .name = "comparison", .detailstr = detailstr, .release = comparison_release, .clone = clone }; cypher_astnode_t *cypher_ast_comparison(unsigned int length, const cypher_operator_t * const *ops, cypher_astnode_t * const *args, cypher_astnode_t **children, unsigned int nchildren, struct cypher_input_range range) { REQUIRE(length > 0, NULL); REQUIRE(ops != NULL, NULL); REQUIRE_CHILD_ALL(children, nchildren, args, length+1, CYPHER_AST_EXPRESSION, NULL); struct comparison *node = calloc(1, sizeof(struct comparison) + (length + 1) * sizeof(cypher_astnode_t *)); if (node == NULL) { return NULL; } if (cypher_astnode_init(&(node->_astnode), CYPHER_AST_COMPARISON, children, nchildren, range)) { free(node); return NULL; } node->length = length; node->ops = mdup(ops, length * sizeof(cypher_astnode_t *)); if (node->ops == NULL) { goto cleanup; } memcpy(node->args, args, (length+1) * sizeof(cypher_astnode_t *)); return &(node->_astnode); int errsv; cleanup: errsv = errno; free(node->ops); free(node); errno = errsv; return NULL; } void comparison_release(cypher_astnode_t *self) { struct comparison *node = container_of(self, struct comparison, _astnode); free(node->ops); cypher_astnode_release(self); } cypher_astnode_t *clone(const cypher_astnode_t *self, cypher_astnode_t **children) { REQUIRE_TYPE(self, CYPHER_AST_COMPARISON, NULL); struct comparison *node = container_of(self, struct comparison, _astnode); cypher_astnode_t **args = calloc(node->length + 1, sizeof(cypher_astnode_t *)); if (args == NULL) { return NULL; } for (unsigned int i = 0; i < node->length + 1; ++i) { args[i] = children[child_index(self, node->args[i])]; } cypher_astnode_t *clone = cypher_ast_comparison(node->length, node->ops, args, children, self->nchildren, self->range); int errsv = errno; free(args); errno = errsv; return clone; } unsigned int cypher_ast_comparison_get_length(const cypher_astnode_t *astnode) { REQUIRE_TYPE(astnode, CYPHER_AST_COMPARISON, 0); struct comparison *node = container_of(astnode, struct comparison, _astnode); return node->length; } const cypher_operator_t *cypher_ast_comparison_get_operator( const cypher_astnode_t *astnode, unsigned int pos) { REQUIRE_TYPE(astnode, CYPHER_AST_COMPARISON, NULL); struct comparison *node = container_of(astnode, struct comparison, _astnode); if (pos >= node->length) { return NULL; } return node->ops[pos]; } const cypher_astnode_t *cypher_ast_comparison_get_argument( const cypher_astnode_t *astnode, unsigned int pos) { REQUIRE_TYPE(astnode, CYPHER_AST_COMPARISON, NULL); struct comparison *node = container_of(astnode, struct comparison, _astnode); if (pos > node->length) { return NULL; } return node->args[pos]; } ssize_t detailstr(const cypher_astnode_t *self, char *str, size_t size) { REQUIRE_TYPE(self, CYPHER_AST_COMPARISON, -1); struct comparison *node = container_of(self, struct comparison, _astnode); size_t n = 0; for (unsigned int i = 0; i < node->length; ++i) { ssize_t r = snprintf(str + n, (n < size)? size-n : 0, "@%u %s ", node->args[i]->ordinal, node->ops[i]->str); if (r < 0) { return -1; } n += r; } ssize_t r = snprintf(str + n, (n < size)? size-n : 0, "@%u", node->args[node->length]->ordinal); if (r < 0) { return -1; } n += r; return n; }
27.550802
81
0.654115
4844113b36384873d39f757f6c3df18b8675ad7b
870
h
C
src/SelectPoller.h
ichenq/WinsockTut
308711f83334f83e71ddc37d8b8ec862207cf98f
[ "Apache-2.0" ]
20
2015-03-25T04:41:19.000Z
2020-04-03T08:35:21.000Z
src/SelectPoller.h
cheadaq/WinsockTut
308711f83334f83e71ddc37d8b8ec862207cf98f
[ "Apache-2.0" ]
1
2020-01-20T05:34:52.000Z
2020-01-28T03:48:00.000Z
src/SelectPoller.h
cheadaq/WinsockTut
308711f83334f83e71ddc37d8b8ec862207cf98f
[ "Apache-2.0" ]
13
2015-04-21T09:47:34.000Z
2019-12-20T07:24:31.000Z
// Copyright (C) 2012-present ichenq@outlook.com All rights reserved. // Distributed under the terms and conditions of the Apache License. // See accompanying files LICENSE. #pragma once #include "PollerBase.h" #include <vector> class SelectPoller : public PollerBase { public: SelectPoller(); ~SelectPoller(); int AddFd(SOCKET fd, IPollEvent* event); void RemoveFd(SOCKET fd); void SetPollIn(SOCKET fd); void ResetPollIn(SOCKET fd); void SetPollOut(SOCKET fd); void ResetPollOut(SOCKET fd); int Poll(int timeout); private: void MarkRetired(SOCKET fd); void RemoveRetired(); struct FdEntry { SOCKET fd; IPollEvent* sink; }; private: std::vector<FdEntry> fds_; bool has_retired_; fd_set readfds_; fd_set writefds_; fd_set exceptfds_; };
19.772727
69
0.652874
f0eb14c64b359cc783c516971271c9d74ae22e0f
18,750
h
C
Projects/Honey/Honey/Math/MathFunctions.h
dSyncro/Honey
571862e56d2a977d319779be751e5c0ef79de5a1
[ "MIT" ]
null
null
null
Projects/Honey/Honey/Math/MathFunctions.h
dSyncro/Honey
571862e56d2a977d319779be751e5c0ef79de5a1
[ "MIT" ]
null
null
null
Projects/Honey/Honey/Math/MathFunctions.h
dSyncro/Honey
571862e56d2a977d319779be751e5c0ef79de5a1
[ "MIT" ]
null
null
null
#pragma once #include <cmath> #include <limits> #include <Honey/Core.h> namespace Honey { namespace Math::Functions { /** * @brief Famous pi constant. * It express the ratio between a circumference and its diameter. * @return Pi. */ template <typename T = Float> constexpr EnableIfFloatingPoint<T> pi() { return static_cast<T>(3.14159265358979); } /** * @brief Multiply to this constant to convert easily * from degrees to radians. * @return degrees to radians conversion factor. */ template <typename T = Float> constexpr EnableIfFloatingPoint<T> degrees2Radians() { return pi<T>() / static_cast<T>(180.0); } /** * @brief Multiply to this constant to convert easily * from radians to degrees. * @return radians to degrees conversion factor. */ template <typename T = Float> constexpr EnableIfFloatingPoint<T> radians2Degrees() { return static_cast<T>(180.0) / pi<T>(); } /** * @brief The machine epsilon, that is, the difference between * 1.0 and the next value representable by the floating-point type. * @tparam T Floating point type. * @return Epsilon of the related type on this machine. */ template <typename T = Float> constexpr EnableIfFloatingPoint<T> epsilon() { return std::numeric_limits<T>::epsilon(); } /** * @brief The quiet not-a-number value. * @tparam T Floating point type. * @return Quiet NaN of T. */ template <typename T = Float> constexpr EnableIfFloatingPoint<T> NaN() { return std::numeric_limits<T>::quiet_NaN(); } /** * @brief Positive infinity constant. * @tparam T Floating point type. * @return Positive infinity of T. */ template <typename T = Float> constexpr EnableIfFloatingPoint<T> infinity() { return +std::numeric_limits<T>::infinity(); } /** * @brief Negative infinity constant. * @tparam T Floating point type. * @return negative infinity of T. */ template <typename T = Float> constexpr EnableIfFloatingPoint<T> negativeInfinity() { return -infinity(); } /** * @brief Get absolute value of a number. * @param x The number. * @return Absolute value of number. */ template <typename T = Float> static HNY_ALWAYS_INLINE EnableIfArithmetic<T> abs(T x) noexcept { return std::abs(x); } /** * @brief Get sign of a value. * @param x The value. * @return Sign of x. */ template <typename T = Int> static HNY_ALWAYS_INLINE EnableIfSignedInt<T> sign(T x) noexcept { return -(x < 0); } /** * @brief Get sign of a value. * @param x The value. * @return Sign of x. * @overload */ template <typename T = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<T> sign(T x) noexcept { return static_cast<T>(-(x < 0)); } // Powers of 2 /** * @brief Check if value is a power of two. * @param x The value. */ template <typename T = Int> static HNY_ALWAYS_INLINE bool isPowerOfTwo(EnableIfSignedInt<T> x) noexcept { return x & !(x & (x - 1)) && x >= 0; } /** * @brief Check if value is a power of two. * @param x The value. */ template <typename T = UInt> static HNY_ALWAYS_INLINE bool isPowerOfTwo(EnableIfUnsignedInt<T> x) noexcept { return x & !(x & (x - 1)); } /** * @brief Get next power of two. * @param x The value. * @return The nearest power of two bigger than x. */ template <typename T = UInt> static HNY_ALWAYS_INLINE EnableIfUnsignedInt<T> nextPowerOfTwo(T x) noexcept { if (!x) return 0; x--; for (UInt i = 1; i < sizeof(x) * 8; i <<= 1) x |= x >> i; return ++x; } /** * @brief Get previous power of two. * @param x The value. * @return The nearest power of two smaller than x. */ template <typename T = UInt> static HNY_ALWAYS_INLINE EnableIfUnsignedInt<T> previousPowerOfTwo(T x) noexcept { if (!x) return 0; for (UInt i = 1; i < sizeof(x) * 8; i <<= 1) x |= x >> i; return x - (x >> 1); } /** * @brief Get closest power of two. * @param x The value. * @return The power of two nearest to x. */ template <typename T = UInt> static HNY_ALWAYS_INLINE EnableIfUnsignedInt<T> closestPowerOfTwo(T x) noexcept { T nx = nextPowerOfTwo<T>(x); T px = previousPowerOfTwo<T>(x); return (nx - x) > (x - px) ? px : nx; } // Trigonometry /** * @brief Compute cosine of a value * @param x -> The value to compute the cosine of (expressed in radians). * @return The cosine of `x`. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> cos(EnableIfArithmetic<ValueType> x) noexcept { return std::cos(x); } /** * @brief Compute sine of a value * @param x -> The value to compute the sine of (expressed in radians). * @return The sine of `x`. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> sin(EnableIfArithmetic<ValueType> x) noexcept { return std::sin(x); } /** * @brief Compute tangent of a value * @param x -> The value to compute the tangent of (expressed in radians). * @return The tangent of `x`. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> tan(EnableIfArithmetic<ValueType> x) noexcept { return std::tan(x); } /** * @brief Compute arc cosine of a value * @param x -> The value to compute the arc cosine of. Must be in range -1.0f to 1.0f. * @return The arc cosine of `x` expressed in radians. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> acos(EnableIfArithmetic<ValueType> x) noexcept { return std::acos(x); } /** * @brief Compute arc sine of a value * @param x -> The value to compute the arc sine of. Must be in range -1.0f to 1.0f. * @return The arc sine of `x` expressed in radians. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> asin(EnableIfArithmetic<ValueType> x) noexcept { return std::asin(x); } /** * @brief Compute arc tangent of a value * @param x -> The value to compute the arc tangent of. * @return The arc tangent of `x` expressed in radians. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> atan(EnableIfArithmetic<ValueType> x) noexcept { return std::atan(x); } /** * @brief Compute arc tangent of y/x * @param y -> The y component. * @param x -> The x component. * @return The arc tangent of `y/x` expressed in radians. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> atan2(EnableIfArithmetic<ValueType> y, ValueType x) noexcept { return std::atan2(y, x); } // Hyperbolic #if 0 /** * Compute hyperbolic cosine of x * @param x The value to compute the hyperbolic cosine of. * @return The hyperbolic cosine of `x`. */ static HNY_ALWAYS_INLINE float Cosh(float x) { return std::cosh(x); } /** * Compute hyperbolic sine of x * @param x The value to compute the hyperbolic sine of. * @return The hyperbolic sine of `x`. */ static HNY_ALWAYS_INLINE float Sinh(float x) { return std::sinh(x); } /** * Compute hyperbolic tangent of x * @param x The value to compute the hyperbolic tangent of. * @return The hyperbolic tangent of `x`. */ static HNY_ALWAYS_INLINE float Tanh(float x) { return std::tanh(x); } /** * Compute hyperbolic arc cosine of x * @param x The value to compute the hyperbolic arc cosine of. * @return The hyperbolic arc cosine of `x` [0, +Inf]. */ static HNY_ALWAYS_INLINE float Acosh(float x) { return std::acosh(x); } /** * Compute hyperbolic arc sine of x * @param x The value to compute the hyperbolic arc sine of. * @return The hyperbolic arc sine of `x` [0, +Inf]. */ static HNY_ALWAYS_INLINE float Asinh(float x) { return std::asinh(x); } /** * Compute hyperbolic arc tangent of x * @param x The value to compute the hyperbolic arc tangent of. * @return The hyperbolic arc tangent of `x` [0, +Inf]. */ static HNY_ALWAYS_INLINE float Atanh(float x) { return std::atanh(x); } #endif // Exponential and Logarithmic /** * @brief Compute exponential function. * @param x The value of the exponent. * @return The base-e exponential function of x, which is e raised to the power x. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> exp(EnableIfArithmetic<ValueType> x) noexcept { return std::exp(x); } /** * @brief Compute binary exponential function. * @param x The value of the exponent. * @return The base-2 exponential function of x, which is 2 raised to the power x. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> exp2(EnableIfArithmetic<ValueType> x) noexcept { return std::exp2(x); } /** * @brief Compute natural logarithm. * @param x The value whose logarithm is calculated. * @return The natural logarithm of x. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> ln(EnableIfArithmetic<ValueType> x) noexcept { return std::log(x); } /** * @brief Compute base-2 logarithm. * @param x The value whose logarithm is calculated. * @return The base-2 logarithm of x. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> log2(EnableIfArithmetic<ValueType> x) noexcept { return std::log2(x); } /** * @brief Compute base-10 logarithm. * @param x The value whose logarithm is calculated. * @return The base-10 logarithm of x. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> log10(EnableIfArithmetic<ValueType> x) noexcept { return std::log10(x); } /** * @brief Compute logarithm of arbitrary base. * @param base The base. * @param x The value whose logarithm is calculated. * @return The base-n logarithm of x. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> log(EnableIfArithmetic<ValueType> base, ValueType x) noexcept { return log2(x) / log2(base); } // Power /** * @brief Compute the power of x elevated by y. * @param x The base. * @param y The exponent. * @return The power of x elevated by y. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> pow(EnableIfArithmetic<ValueType> x, ValueType y) noexcept { return std::pow(x, y); } /** * @brief Compute the square root of a value. * @param x The value. * @return The square root of x. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> sqrt(EnableIfArithmetic<ValueType> x) noexcept { return std::sqrt(x); } /** * @brief Compute the cube root of a value. * @param x The value. * @return The cube root of x. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> cbrt(EnableIfArithmetic<ValueType> x) noexcept { return std::cbrt(x); } // Rounding and remainder /** * @brief Rounds x upward, returning the smallest integral value that is not less than x. * @param x Value to round up. * @return The smallest integral value that is not less than x (as a floating-point value). */ template <typename T = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<T> ceil(T x) noexcept { return std::ceil(x); } /** * @brief Rounds x upward, returning the smallest integral value that is not less than x. * @param x Value to round up. * @return The smallest integral value that is not less than x (as an integer value). */ template <typename FloatType = Float, typename IntType = Int> static HNY_ALWAYS_INLINE EnableIfIntegral<IntType> ceilToInt(EnableIfFloatingPoint<FloatType> x) noexcept { return static_cast<IntType>(ceil(x)); } /** * @brief Rounds x downward, returning the largest integral value that is not greater than x. * @param x Value to round down. * @return The value of x rounded downward (as a floating-point value). */ template <typename T = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<T> floor(T x) noexcept { return std::floor(x); } /** * @brief Rounds x downward, returning the largest integral value that is not greater than x. * @param x Value to round down. * @return The value of x rounded downward (as an integer value). */ template <typename FloatType = Float, typename IntType = Int> static HNY_ALWAYS_INLINE EnableIfIntegral<IntType> floorToInt(EnableIfFloatingPoint<FloatType> x) noexcept { return static_cast<IntType>(floor(x)); } /** * @brief Rounds x toward zero, returning the nearest integral value that is not larger in magnitude than x. * @param x Value to truncate. * @return The nearest integral value that is not larger in magnitude than x (as a floating-point value). */ template <typename T = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<T> truncate(T x) noexcept { return std::trunc(x); } /** * @brief Rounds x toward zero, returning the nearest integral value that is not larger in magnitude than x. * @param x Value to truncate. * @return The nearest integral value that is not larger in magnitude than x (as an integer value). */ template <typename FloatType = Float, typename IntType = Int> static HNY_ALWAYS_INLINE EnableIfIntegral<IntType> truncateToInt(EnableIfFloatingPoint<FloatType> x) noexcept { return static_cast<IntType>(truncate(x)); } /** * @brief Returns the integral value that is nearest to x, with halfway cases rounded away from zero. * @param x Value to round. * @return The value of x rounded to the nearest integral (as a floating-point value). */ template <typename T = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<T> round(T x) noexcept { return std::round(x); } /** * @brief Returns the integral value that is nearest to x, with halfway cases rounded away from zero. * @param x Value to round. * @return The value of x rounded to the nearest integral (as an integer value). */ template <typename FloatType = Float, typename IntType = Int> static HNY_ALWAYS_INLINE EnableIfIntegral<IntType> roundToInt(EnableIfFloatingPoint<FloatType> x) noexcept { return static_cast<IntType>(round(x)); } /** * @brief Returns the floating-point remainder of numer/denom (rounded towards zero): * fmod = numer - tquot * denom * Where tquot is the truncated (i.e., rounded towards zero) result of: numer/denom. * A similar function, remainder, returns the same but with the quotient rounded to the nearest integer (instead of truncated). * @param x Value of the quotient numerator. * @param y Value of the quotient denominator. * @return The remainder of dividing the arguments. * If denom is zero, the function may either return zero or cause a domain error * (depending on the library implementation). */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> mod(EnableIfArithmetic<ValueType> x, ValueType y) noexcept { return std::fmod(x, y); } /** * @brief Returns the floating-point remainder of numer/denom (rounded to nearest): * remainder = numer - rquot * denom * Where rquot is the result of: numer/denom, rounded toward the nearest integral value (with halfway cases rounded toward the even number). * A similar function, mod, returns the same but with the quotient truncated (rounded towards zero) instead. * @param x Value of the quotient numerator. * @param y Value of the quotient denominator. * @return The remainder of dividing the arguments. */ template <typename ValueType = Float, typename RetType = Float> static HNY_ALWAYS_INLINE EnableIfFloatingPoint<RetType> remainder(EnableIfArithmetic<ValueType> x, ValueType y) noexcept { return std::remainder(x, y); } // Min - max - difference /** * @brief Get the minimum between two numbers. * @param x First number. * @param y Second number. * @return The minimum number. */ template <typename T = Float> static HNY_ALWAYS_INLINE EnableIfArithmetic<T> min(T x, T y) noexcept { return std::min(x, y); } /** * @brief Get the maximum between two numbers. * @param x First number. * @param y Second number. * @return The minimum number. */ template <typename T = Float> static HNY_ALWAYS_INLINE EnableIfArithmetic<T> max(T x, T y) noexcept { return std::max(x, y); } /** * @brief Get the positive difference between two numbers. * @param x First number. * @param y Second number. * @return abs(x - y). */ template <typename T = Float> static HNY_ALWAYS_INLINE EnableIfArithmetic<T> positiveDifference(T x, T y) noexcept { return abs(x - y); } /** * @brief Clamp value in range. * @param x The value. * @param min Minimum bound. * @param max Maximum bound. * @return Clamped value. */ template <typename T = Float> static HNY_ALWAYS_INLINE EnableIfArithmetic<T> clamp(T x, T minimum, T maximum) noexcept { return min(maximum, max(minimum, x)); } /** * @brief Clamp value in range 0 to 1. * @param x The value. * @return Clamped value. */ template <typename T = Float> static HNY_ALWAYS_INLINE EnableIfArithmetic<T> clamp01(T x) noexcept { return clamp<T>(x, 0, 1); } /** * @brief Check if two numbers are approximately equal to each other. * @param x First number. * @param y Second number. */ template <typename T = Float> static HNY_ALWAYS_INLINE bool approximatelyEquals(EnableIfFloatingPoint<T> x, T y) noexcept { return positiveDifference(x, y) < epsilon(); } /** * @brief Check if two numbers are approximately equal to each other provided a max treshold. * @param x First number. * @param y Second number. * @param threshold Max threshold. * @overload */ template <typename T = Float> static HNY_ALWAYS_INLINE bool approximatelyEquals(EnableIfFloatingPoint<T> x, T y, T threshold) noexcept { return positiveDifference(x, y) < threshold; } } //#if !defined(HNY_STRICT_MATH_NAMESPACE) namespace Mathf = Math::Functions; //#endif }
37.128713
157
0.693333
14d1f92939d226ce5c64804b07cc74aa44ab2c16
350
h
C
vs2015/realtime_server/realtime_srv/common/noncopyable.h
no5ix/realtime-server
c786d5329382c2d1f19673ba3025d516b83e1cc4
[ "MIT" ]
465
2018-06-21T02:50:56.000Z
2022-03-27T11:51:46.000Z
vs2015/realtime_server/realtime_srv/common/noncopyable.h
no5ix/RealTimeServer
9e3b690c1d12fe32068bc4637fa1919cd52ce854
[ "MIT" ]
8
2018-08-09T09:25:00.000Z
2022-03-10T14:54:51.000Z
vs2015/realtime_server/realtime_srv/common/noncopyable.h
no5ix/RealTimeServer
9e3b690c1d12fe32068bc4637fa1919cd52ce854
[ "MIT" ]
113
2018-06-25T01:42:20.000Z
2022-03-23T11:27:56.000Z
#ifndef REALTIME_SRV_COMMON_NONCOPYABLE_H #define REALTIME_SRV_COMMON_NONCOPYABLE_H namespace realtime_srv { class noncopyable { protected: noncopyable() = default; ~noncopyable() = default; private: noncopyable( const noncopyable& ) = delete; void operator=( const noncopyable& ) = delete; }; } #endif // REALTIME_SRV_COMMON_NONCOPYABLE_H
16.666667
47
0.777143
4227385b01c4dd7056f4387276466a8c6670ac49
703
h
C
src/entity/Ship.h
DevRaptor/space_ships
4c3196052eeb155e102f81399a4839ad50fad125
[ "MIT" ]
null
null
null
src/entity/Ship.h
DevRaptor/space_ships
4c3196052eeb155e102f81399a4839ad50fad125
[ "MIT" ]
null
null
null
src/entity/Ship.h
DevRaptor/space_ships
4c3196052eeb155e102f81399a4839ad50fad125
[ "MIT" ]
null
null
null
#pragma once #include <chrono> #include <vector> #include "entity/Entity.h" class Ship : public Entity, public std::enable_shared_from_this<Ship> { public: static int points; //reset in constructor Ship(std::shared_ptr<btDiscreteDynamicsWorld> world_ptr, glm::vec3 start_pos, std::vector<std::shared_ptr<Entity>>& bullet_container); void Init() override; void Update() override; protected: float move_speed; float move_speed_max; float move_damping; float stop_damping; float movement_limit; std::chrono::milliseconds shoot_delay; //time to next shoot std::chrono::high_resolution_clock::time_point shoot_timer; std::vector<std::shared_ptr<Entity>>& bullets; void Shoot(); };
19.527778
78
0.758179
b6b6836344bafb85d1ad5193d26f39569fe9cd3d
2,192
h
C
include/log/vqes_pm_debug_flags.h
wmanley/cisco-vqe-client
a01f7c75c3a6f252164b86414288ede248896540
[ "BSD-3-Clause" ]
5
2015-07-21T10:42:38.000Z
2021-05-10T08:41:12.000Z
include/log/vqes_pm_debug_flags.h
youviewtv/cisco-vqe-client
39343596a79439dfdcd050934b02d2a8513168f9
[ "BSD-3-Clause" ]
3
2015-05-05T09:49:48.000Z
2017-01-11T17:10:24.000Z
include/log/vqes_pm_debug_flags.h
youviewtv/cisco-vqe-client
39343596a79439dfdcd050934b02d2a8513168f9
[ "BSD-3-Clause" ]
24
2015-04-16T13:18:24.000Z
2021-09-08T08:17:26.000Z
/******************************************************************** * vqes_pm_debug_flags.h * * Define the debug flags used in VQE-S Process Monitor * * * Copyright (c) 2007 by Cisco Systems, Inc. * All rights reserved. * *********************************************************************/ #include <log/libdebug_macros.h> /* * For each component there are 2 debug levels: * ERR- Unexpected error occured. This may also result in a syslog, * but this debug message will contain more detailed information. * DETL- Debug traces for normal operation. */ ARR_BEGIN(vqes_pm_debug_arr) ARR_ELEM(pm_debug_cfg_err, PM_DEBUG_CFG_ERR, "VQE-S Process Monitor Configuration File Parsing Error Messages", 0) ARR_ELEM(pm_debug_cfg_detl, PM_DEBUG_CFG_DETL, "VQE-S Process Monitor Configuration File Parsing Detail Messages", 0) ARR_ELEM(pm_debug_ctl_err, PM_DEBUG_CTL_ERR, "VQE-S Process Monitor Controller Error Messages", 0) ARR_ELEM(pm_debug_ctl_detl, PM_DEBUG_CTL_DETL, "VQE-S Process Monitor Controller Detail Messages", 0) ARR_ELEM(pm_debug_process_err, PM_DEBUG_PROC_ERR, "VQE-S Process Monitor Process Manager Error Messages", 0) ARR_ELEM(pm_debug_process_detl, PM_DEBUG_PROC_DETL, "VQE-S Process Monitor Process Manager Detail Messages", 0) ARR_ELEM(pm_debug_dep_err, PM_DEBUG_DEP_ERR, "VQE-S Process Monitor Dependency Generator Error Messages", 0) ARR_ELEM(pm_debug_dep_detl, PM_DEBUG_DEP_DETL, "VQE-S Process Monitor Dependency Generator Detail Messages", 0) ARR_ELEM(pm_debug_xmlrpc_err, PM_DEBUG_XMLRPC_ERR, "VQE-S Process Monitor XML-RPC Module Error Messages", 0) ARR_ELEM(pm_debug_xmlrpc_detl, PM_DEBUG_XMLRPC_DETL, "VQE-S Process Monitor XML-RPC Module Detail Messages", 0) ARR_ELEM(pm_debug_main_err, PM_DEBUG_MAIN_ERR, "VQE-S Process Monitor Main Error Messages", 0) ARR_ELEM(pm_debug_main_detl, PM_DEBUG_MAIN_DETL, "VQE-S Process Monitor Main Detail Messages", 0) ARR_ELEM(pm_debug_lock_err, PM_DEBUG_LOCK_ERR, "VQE-S Process Monitor Locking Error Messages", 0) ARR_ELEM(pm_debug_lock_detl, PM_DEBUG_LOCK_DETL, "VQE-S Process Monitor Locking Detail Messages", 0) /* Add other flags here */ ARR_DONE
37.152542
73
0.729927
e519e9e8452fc64061a37ac80b1d84076f9eef6f
801
h
C
System/Library/PrivateFrameworks/TestFlightCore.framework/TFFeedbackSubmissionService.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
1
2020-11-04T15:43:01.000Z
2020-11-04T15:43:01.000Z
System/Library/PrivateFrameworks/TestFlightCore.framework/TFFeedbackSubmissionService.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
System/Library/PrivateFrameworks/TestFlightCore.framework/TFFeedbackSubmissionService.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.0 * on Sunday, September 27, 2020 at 12:26:46 PM Mountain Standard Time * Operating System: Version 14.0 (Build 18A373) * Image Source: /System/Library/PrivateFrameworks/TestFlightCore.framework/TestFlightCore * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ @protocol TFFeedbackSubmissionService <NSObject> @property (nonatomic,readonly) unsigned long long maxNumberOfScreenshotsAllowed; @property (nonatomic,readonly) unsigned long long maxNumberOfCommentSymbolsAllowed; @required -(unsigned long long)maxNumberOfScreenshotsAllowed; -(unsigned long long)maxNumberOfCommentSymbolsAllowed; -(void)submitFeedbackForBundleId:(id)arg1 withContentsOfDataSource:(id)arg2 completionHandler:(/*^block*/id)arg3; @end
40.05
113
0.813983
ab359fec7f464319ad6757c262c4d38888a23ab3
368
h
C
Extras/GrowlTunesPlugin/source/GTPToken.h
Shalaco/shalzers-growl
932dd33a60ffd5b1c6f64448161eb459bf899540
[ "BSD-3-Clause" ]
1
2019-05-22T10:37:30.000Z
2019-05-22T10:37:30.000Z
Extras/GrowlTunesPlugin/source/GTPToken.h
Shalaco/shalzers-growl
932dd33a60ffd5b1c6f64448161eb459bf899540
[ "BSD-3-Clause" ]
null
null
null
Extras/GrowlTunesPlugin/source/GTPToken.h
Shalaco/shalzers-growl
932dd33a60ffd5b1c6f64448161eb459bf899540
[ "BSD-3-Clause" ]
null
null
null
// // GTPToken.h // GrowlTunes // // Created by rudy on 9/16/07. // Copyright 2007 2007 The Growl Project. All rights reserved. // #import <Cocoa/Cocoa.h> @interface GTPToken : NSObject { NSString *displayText; } - (void)encodeWithCoder:(NSCoder *)encoder; - (id)initWithCoder:(NSCoder *)decoder; - (NSString *)code; @property (retain) NSString *text; @end
16
63
0.684783
821920f9f1bfecb216537dd1ddb461cd611c8bd7
442
c
C
src/common/malloc.c
thibautcornolti/MyIRC
05597431090d9ac1d23d296a35734227db623c74
[ "MIT" ]
null
null
null
src/common/malloc.c
thibautcornolti/MyIRC
05597431090d9ac1d23d296a35734227db623c74
[ "MIT" ]
null
null
null
src/common/malloc.c
thibautcornolti/MyIRC
05597431090d9ac1d23d296a35734227db623c74
[ "MIT" ]
null
null
null
/* ** EPITECH PROJECT, 2018 ** myirc ** File description: ** myirc */ #include "common.h" void *safe_malloc(size_t size) { void *ret = malloc(size); if (ret == NULL) { perror("Error when allocating"); exit(EXIT_FAILURE); } memset(ret, 0, size); return (ret); } void *safe_realloc(void *ptr, size_t old_size, size_t size) { void *ret = safe_malloc(size); if (ptr && old_size > 0) memcpy(ret, ptr, old_size); return (ret); }
14.733333
59
0.642534
fbd4576cdccabe821b49c837374b14a495541659
867
h
C
bezierWithCSV/qmlinterface.h
summerpaul/BezierQml
daa841127b55c462c39596eae486606a14ab08f5
[ "MIT" ]
null
null
null
bezierWithCSV/qmlinterface.h
summerpaul/BezierQml
daa841127b55c462c39596eae486606a14ab08f5
[ "MIT" ]
null
null
null
bezierWithCSV/qmlinterface.h
summerpaul/BezierQml
daa841127b55c462c39596eae486606a14ab08f5
[ "MIT" ]
null
null
null
#ifndef QMLINTERFACE_H #define QMLINTERFACE_H #include <QObject> #include <QString> #include <QVector> #include <QQmlListProperty> #include "roadmapreader.h" class QmlInterface : public QObject { Q_PROPERTY(QString nodePath WRITE setNodePath) Q_PROPERTY(QString lanePath WRITE setLanePath) Q_PROPERTY(QQmlListProperty<Point> points READ getPoints ) Q_PROPERTY(QQmlListProperty<Lane> lanes READ getLanes ) Q_OBJECT public: explicit QmlInterface(QObject *parent = nullptr); Q_INVOKABLE void setNodePath(QString nodePath); Q_INVOKABLE void setLanePath(QString lanePath); QQmlListProperty<Point> getPoints(){return m_reader.getPoints();} QQmlListProperty<Lane> getLanes(){return m_reader.getLanes();} signals: private: QString m_nodePath; QString m_lanePath; RoadmapReader m_reader; }; #endif // QMLINTERFACE_H
24.771429
70
0.763552
610afbb2b920f9be82b318dcae615683acda0a10
669
h
C
Demos/Demo-Swift/Demo-Swift/XiaoFuTech.framework/Headers/XFVideoPlayer.h
XiaoFuGenius/CameraDrive-develop
c616d0a4598276b6bb0ee430581f844f983ae585
[ "MIT" ]
null
null
null
Demos/Demo-Swift/Demo-Swift/XiaoFuTech.framework/Headers/XFVideoPlayer.h
XiaoFuGenius/CameraDrive-develop
c616d0a4598276b6bb0ee430581f844f983ae585
[ "MIT" ]
null
null
null
Demos/Demo-Swift/Demo-Swift/XiaoFuTech.framework/Headers/XFVideoPlayer.h
XiaoFuGenius/CameraDrive-develop
c616d0a4598276b6bb0ee430581f844f983ae585
[ "MIT" ]
null
null
null
// // XFVideoPlayer.h // XiaoFuTech // // Created by 胡文峰 on 2018/11/21. // Copyright © 2018 XiaoFu. All rights reserved. // #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN @interface XFVideoPlayer : NSObject /** 控制台输出日志 打开 */ + (void)LogEnabled; /** 设置展示 Window 的显示层级 PlayWithUrl:InView:方法,参数 view 设置为 nil 时会加载一个 window 来展示视频播放视图 @param windowLevel 展示 window 的显示层级 */ + (void)SetWindowLevel:(UIWindowLevel)windowLevel; /** 视频播放. 支持类型 [@".mov", @".mp4", @".mpv", @".3gp"] @param url 视频播放地址 支持 网络 & 本地 @param view 视频播放控制器 上一级控制器的视图 */ + (void)PlayWithUrl:(nullable NSString *)url InView:(nullable UIView *)view; @end NS_ASSUME_NONNULL_END
18.081081
76
0.702541
f914ab502fd2c8ce1401dd96f491c5c85c18abcd
1,302
h
C
src/bigInteger.h
aiyama1467/BigInteger_old
65e128af41c684818ab8328a6dad430ef49986f7
[ "MIT" ]
null
null
null
src/bigInteger.h
aiyama1467/BigInteger_old
65e128af41c684818ab8328a6dad430ef49986f7
[ "MIT" ]
null
null
null
src/bigInteger.h
aiyama1467/BigInteger_old
65e128af41c684818ab8328a6dad430ef49986f7
[ "MIT" ]
null
null
null
#pragma once #ifndef _STDINT // 他のヘッダのインクルード #include<stdint.h> #endif #ifndef BIGINTEGER_H_ #define BIGINTEGER_H_ // 定数定義 #define DIGIT 1500 // 2^15より大きくすると除算がおかしくなる #define BASE 32768 // 32768 = 2^15 // 除算、剰余の指定子 #define DIV 0 #define MOD 1 // マクロ // bint変数初期化 #define INIT(x) for(int i = 0; i < DIGIT; i++) (x).digits[i] = 0 // 構造体 typedef struct natutal_number { int len; uint32_t digits[DIGIT]; } bint; // 関数 // bint->long変換 return:変換後の値 unsigned long bint_to_long(bint n); // long->bint変換 return:変換後の値 bint long_to_bint(long n); // 文字列->bint変換 return:変換後の値 bint str_to_bint(char *str); // bint->文字列変換 return:-1->失敗, 0->成功 int bint_to_str(char *ret, int size, bint a); // bint加算 return:計算結果 bint add_bint(bint a, bint b); // bint減算 return:計算結果 bint sub_bint(bint a, bint b); // bint乗算 return:計算結果 bint mul_bint(bint a, bint b); // bint除算 return:計算結果 bint div_bint(bint a, bint b); // bint剰余 return:計算結果 bint mod_bint(bint a, bint b); // bint左シフト return:計算結果 bint left_shift(bint a, int n); // bint右シフト return:計算結果 bint right_shift(bint a, int n); // baseのexp乗 return:計算結果 bint power_bint(bint base, int exp); // bint比較 return: a>b -> 1, a=b -> 0, a<b -> -1 int comp_bint(bint a, bint b); #endif
21.7
65
0.64977
c33201d1619805edf8f3df0cddc51bae4e010bc8
377
h
C
final-project-goat/assets/projectile.h
enguang2/Project_Demo
d99e77da306848daa8d4cdc913819c7ea2baf65d
[ "MIT" ]
null
null
null
final-project-goat/assets/projectile.h
enguang2/Project_Demo
d99e77da306848daa8d4cdc913819c7ea2baf65d
[ "MIT" ]
null
null
null
final-project-goat/assets/projectile.h
enguang2/Project_Demo
d99e77da306848daa8d4cdc913819c7ea2baf65d
[ "MIT" ]
null
null
null
#ifndef PROJECTILE_H #define PROJECTILE_H #include "physicsObj.h" class projectile : public physicsObj { private: Image* projectileSprite; public: void update(terrain* ter); projectile(GameWindow* gw); ~projectile(); void draw(); void die(); void launch(Vector2 dir); bool dead; void setPos(Vector2 pos); Vector2 getPos(); }; #endif // PPRoJECTILE_H
15.708333
38
0.702918
0f479d47b786affdb4fcf958c516b7426e4bb48d
2,615
h
C
PrivateFrameworks/ScreenReader/SCRWebAreaPromotableElement.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
17
2018-11-13T04:02:58.000Z
2022-01-20T09:27:13.000Z
PrivateFrameworks/ScreenReader/SCRWebAreaPromotableElement.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
3
2018-04-06T02:02:27.000Z
2018-10-02T01:12:10.000Z
PrivateFrameworks/ScreenReader/SCRWebAreaPromotableElement.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
1
2018-09-28T13:54:23.000Z
2018-09-28T13:54:23.000Z
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import <ScreenReader/SCRPromotableElement.h> @class NSArray, SCRElement; __attribute__((visibility("hidden"))) @interface SCRWebAreaPromotableElement : SCRPromotableElement { unsigned long long _childIndex; SCRElement *_readContentsElement; NSArray *_stitchedTextElements; long long _childrenCount; } - (void).cxx_destruct; - (BOOL)isGestureContainerElement; - (BOOL)shouldIncludeInItemChooser; - (BOOL)shouldPromoteForMovingUIElement:(id)arg1; - (BOOL)shouldPromoteUIElement:(id)arg1; - (id)childAtIndex:(unsigned long long)arg1 visibleOnly:(BOOL)arg2; - (unsigned long long)indexOfElement:(id)arg1 visibleOnly:(BOOL)arg2; - (unsigned long long)numberOfChildren:(BOOL)arg1; - (id)children:(BOOL)arg1; - (long long)brailleLineType; - (id)visibleChildrenDescriptionIgnoringChild:(id)arg1; - (BOOL)shouldMapElement:(id)arg1; - (BOOL)allowMappingIfZeroSize; - (BOOL)handleEvent:(id)arg1 request:(id)arg2; - (BOOL)moveFirstWithEvent:(id)arg1 request:(id)arg2 visibleOnly:(BOOL)arg3; - (BOOL)moveLastWithEvent:(id)arg1 request:(id)arg2 visibleOnly:(BOOL)arg3; - (BOOL)interactLeftWithEvent:(id)arg1 request:(id)arg2; - (BOOL)interactRightWithEvent:(id)arg1 request:(id)arg2; - (id)childInAXOrderForward:(BOOL)arg1 horizontal:(BOOL)arg2 visibleOnly:(BOOL)arg3 wrapped:(char *)arg4 didHitBoundary:(char *)arg5 startElement:(id)arg6; - (BOOL)canWrapWhileNavigating; - (BOOL)defersKeyboardHelpCommandsToParent; - (id)childrenInReadContentsOrder; - (id)readContentsElement; - (void)forgetReadContentsElement; - (void)prepareReadContentsElementVisibleOnly:(BOOL)arg1; - (unsigned long long)readContentsElementCount; - (void)_setReadContentsElement:(id)arg1; - (void)beginFocusFromElement:(id)arg1 withEvent:(id)arg2; - (BOOL)_autoDrillShouldAnnounceBorderCross; - (id)focusOntoUIElement:(id)arg1 withScrolling:(BOOL)arg2 withSelection:(BOOL)arg3; - (id)prepareArrayToFocusInto; - (id)lastChildForFocusing; - (id)firstChildForFocusing; - (void)_setChildIndex:(long long)arg1; - (long long)_childIndex; - (BOOL)needToRebuildChildren; - (id)_itemCountOutputAfterFirstChildDescription:(long long)arg1; - (void)_addFirstChildDescription:(id)arg1 itemCount:(long long)arg2 toRequest:(id)arg3; - (void)addItemNameToRequest:(id)arg1; - (BOOL)canFocusOutInto; - (BOOL)focusInto:(id)arg1 event:(id)arg2; - (Class)classForChildUIElement:(id)arg1 parent:(id)arg2; - (BOOL)containsStitchedText; - (id)stitchedTextElements; - (id)initWithUIElement:(id)arg1 parent:(id)arg2; @end
38.455882
155
0.77935
bf79ff42b9b564dce7b6e367b72f741518add895
8,232
c
C
eva/utest/test_vqec_utest_updater.c
wmanley/cisco-vqe-client
a01f7c75c3a6f252164b86414288ede248896540
[ "BSD-3-Clause" ]
5
2015-07-21T10:42:38.000Z
2021-05-10T08:41:12.000Z
eva/utest/test_vqec_utest_updater.c
youviewtv/cisco-vqe-client
39343596a79439dfdcd050934b02d2a8513168f9
[ "BSD-3-Clause" ]
3
2015-05-05T09:49:48.000Z
2017-01-11T17:10:24.000Z
eva/utest/test_vqec_utest_updater.c
youviewtv/cisco-vqe-client
39343596a79439dfdcd050934b02d2a8513168f9
[ "BSD-3-Clause" ]
24
2015-04-16T13:18:24.000Z
2021-09-08T08:17:26.000Z
/* * Copyright (c) 2006-2009 by Cisco Systems, Inc. * All rights reserved. */ #include "test_vqec_utest_main.h" #include "test_vqec_utest_interposers.h" #include "../add-ons/include/CUnit/CUnit.h" #include "../add-ons/include/CUnit/Basic.h" #ifdef _VQEC_UTEST_INTERPOSERS #define UT_STATIC #else #define UT_STATIC static #endif // _VQEC_UTEST_INTERPOSERS #include "vqec_ifclient.h" #include "vqec_ifclient_defs.h" #include "vqec_error.h" #include "vqec_syscfg.h" #include <log/vqe_cfg_syslog_def.h> #include "utils/vmd5.h" #include "vqec_updater.h" #include "vqec_updater_private.h" #include "vqec_debug.h" /* * Unit tests for VQE-C updater */ static vqec_syscfg_t s_cfg; #define MAX_STRLEN 512 static char cmd[MAX_STRLEN]; /* md5 hash of an empty file */ #define VQEC_VERSION_EMPTY_FILE "d41d8cd98f00b204e9800998ecf8427e" void test_vqec_updater_reset_files (void) { /* Restore empty resource files */ snprintf(cmd, MAX_STRLEN, "rm -f %s", s_cfg.network_cfg_pathname); system(cmd); snprintf(cmd, MAX_STRLEN, "rm -f %s", s_cfg.channel_lineup); system(cmd); snprintf(cmd, MAX_STRLEN, "touch %s", s_cfg.network_cfg_pathname); system(cmd); snprintf(cmd, MAX_STRLEN, "touch %s", s_cfg.channel_lineup); system(cmd); } /* * Sets the VQE-C updater to have existent but empty * attribute and channel config files. * * Also, resets the RTSP client interposers. */ void test_vqec_updater_reset_all (void) { /* Restore empty local attribute and channel files */ test_vqec_updater_reset_files(); /* * Make updater records of VQE-C resources match content, * make updater records of VCDS content to match VQE-C. */ (void)vqe_MD5ComputeChecksumStr(vqec_updater.attrcfg.datafile, TRUE, vqec_updater.attrcfg.vqec_version); (void)vqe_MD5ComputeChecksumStr(vqec_updater.chancfg.datafile, TRUE, vqec_updater.chancfg.vqec_version); (void)vqe_MD5ComputeChecksumStr(vqec_updater.attrcfg.datafile, TRUE, vqec_updater.attrcfg.vcds_version); (void)vqe_MD5ComputeChecksumStr(vqec_updater.chancfg.datafile, TRUE, vqec_updater.chancfg.vcds_version); /* Initialize RTSP client interposers to intercept */ test_rtsp_client_set_intercept(TRUE); test_rtsp_client_init_make_fail(RTSP_SUCCESS); test_rtsp_send_request_make_fail(RTSP_SUCCESS); test_rtsp_get_response_code_make_fail(MSG_200_OK); test_rtsp_get_response_body_make_fail(""); test_rtsp_client_close_make_fail(RTSP_SUCCESS); } int test_vqec_updater_init (void) { int loglevel; sleep(2); /* Load the system configuration from supplied file */ (void)vqec_syscfg_init( "data/cfg_test_all_params_valid_with_local_vcds.cfg"); vqec_syscfg_get(&s_cfg); test_vqec_updater_reset_files(); /* Initialize the logging facility */ loglevel = s_cfg.log_level; syslog_facility_open(LOG_VQEC, LOG_CONS); syslog_facility_filter_set(LOG_VQEC, loglevel); sync_lib_facility_filter_with_process(LOG_VQEC, LOG_LIBCFG); sync_lib_facility_filter_with_process(LOG_VQEC, LOG_RTP); return 0; } int test_vqec_updater_clean (void) { snprintf(cmd, MAX_STRLEN, "rm -f %s", s_cfg.network_cfg_pathname); system(cmd); snprintf(cmd, MAX_STRLEN, "rm -f %s", s_cfg.channel_lineup); system(cmd); return 0; } static void test_vqec_updater_tests (void) { vqec_updater_status_t status; boolean in_progress; int32_t seconds_until_next_update; struct timeval attrcfg_last_commit_time; char *attrcfg_version; struct timeval chancfg_last_commit_time; char *chancfg_version; vqec_error_t err; /* Test updater initialization */ vqec_updater_deinit(); err = vqec_updater_init(&s_cfg); CU_ASSERT(err == VQEC_OK); /* Get status prior to any updates: verify no updates performed */ vqec_updater_get_status(&status, &in_progress, &seconds_until_next_update, &attrcfg_last_commit_time, &attrcfg_version, &chancfg_last_commit_time, &chancfg_version); CU_ASSERT(status == VQEC_UPDATER_STATUS_INITIALIZED); CU_ASSERT(in_progress == FALSE); CU_ASSERT(seconds_until_next_update == -1); CU_ASSERT((attrcfg_last_commit_time.tv_sec == 0) && (attrcfg_last_commit_time.tv_usec == 0)); CU_ASSERT(!strcmp(attrcfg_version, VQEC_VERSION_EMPTY_FILE)); CU_ASSERT((chancfg_last_commit_time.tv_sec == 0) && (chancfg_last_commit_time.tv_usec == 0)); CU_ASSERT(!strcmp(chancfg_version, VQEC_VERSION_EMPTY_FILE)); /* * Some tests for parsing index files */ /* * Test 1: NULL body * Make sure both files are deleted */ test_vqec_updater_reset_all(); test_rtsp_get_response_body_make_fail(NULL); vqec_updater_request_update( TRUE, FALSE, FALSE, TIME_ADD_A_R(get_sys_time(), VQEC_UPDATER_TIMEOUT_BACKGROUND)); CU_ASSERT(vqec_updater.last_index_request.result == VQEC_UPDATER_RESULT_ERR_OK); CU_ASSERT(!strcmp(vqec_updater.attrcfg.vcds_version, VQEC_VERSION_FILE_NOT_AVAILABLE)); CU_ASSERT(!strcmp(vqec_updater.chancfg.vcds_version, VQEC_VERSION_FILE_NOT_AVAILABLE)); /* * Test 2: body with only attribute and unrecognized resource * Make sure new updated versions are recorded for VCDS */ test_vqec_updater_reset_all(); test_rtsp_get_response_body_make_fail( "vqec-network-cfg f02d77ad5d121f00b124d4aa5651e2f8\r\n" "unknown-resource <unknown version>"); vqec_updater_request_update( TRUE, FALSE, FALSE, TIME_ADD_A_R(get_sys_time(), VQEC_UPDATER_TIMEOUT_BACKGROUND)); CU_ASSERT(vqec_updater.last_index_request.result == VQEC_UPDATER_RESULT_ERR_OK); CU_ASSERT(!strcmp(vqec_updater.attrcfg.vcds_version, "f02d77ad5d121f00b124d4aa5651e2f8")); CU_ASSERT(!strcmp(vqec_updater.chancfg.vcds_version, VQEC_VERSION_FILE_NOT_AVAILABLE)); /* * Test 3: body with only attribute, unknown, and channel resources * Make sure new updated versions are recorded for VCDS */ test_vqec_updater_reset_all(); test_rtsp_get_response_body_make_fail( "vqe-channels e89ab785efbe3a674655b21e998ab5bd\r\n" "unknown-resource <unknown version>\r\n" "vqec-network-cfg f02d77ad5d121f00b124d4aa5651e2f8\r\n"); vqec_updater_request_update( TRUE, FALSE, FALSE, TIME_ADD_A_R(get_sys_time(), VQEC_UPDATER_TIMEOUT_BACKGROUND)); CU_ASSERT(vqec_updater.last_index_request.result == VQEC_UPDATER_RESULT_ERR_OK); CU_ASSERT(!strcmp(vqec_updater.attrcfg.vcds_version, "f02d77ad5d121f00b124d4aa5651e2f8")); CU_ASSERT(!strcmp(vqec_updater.chancfg.vcds_version, "e89ab785efbe3a674655b21e998ab5bd")); /* * Test 4: VCDS version string with attribute and channel config * Make sure new updated versions are recorded for VCDS */ test_vqec_updater_reset_all(); test_rtsp_get_response_body_make_fail( "vcds 3.2.0(61)-development\r\n" "vqe-channels e89ab785efbe3a674655b21e998ab5bd\r\n" "unknown-resource <unknown version>\r\n" "vqec-network-cfg f02d77ad5d121f00b124d4aa5651e2f8\r\n"); vqec_updater_request_update( TRUE, FALSE, FALSE, TIME_ADD_A_R(get_sys_time(), VQEC_UPDATER_TIMEOUT_BACKGROUND)); CU_ASSERT(vqec_updater.last_index_request.result == VQEC_UPDATER_RESULT_ERR_OK); CU_ASSERT(!strcmp(vqec_updater.attrcfg.vcds_version, "f02d77ad5d121f00b124d4aa5651e2f8")); CU_ASSERT(!strcmp(vqec_updater.chancfg.vcds_version, "e89ab785efbe3a674655b21e998ab5bd")); } CU_TestInfo test_array_updater[] = { {"test_vqec_updater_tests",test_vqec_updater_tests}, CU_TEST_INFO_NULL, };
35.947598
72
0.691812
451b60aa5f1c7e0113b358839bd9cf73710cfd8e
3,170
h
C
code-readpad/kernel-schema/mm_oom_kill.c.h
r4b3rt/kde
b02669373eeae9b836ba83f004ad2f2b642ffac1
[ "MIT" ]
6
2017-07-23T12:53:38.000Z
2017-11-01T11:29:21.000Z
code-readpad/kernel-schema/mm_oom_kill.c.h
r4b3rt/kde
b02669373eeae9b836ba83f004ad2f2b642ffac1
[ "MIT" ]
125
2017-06-16T08:00:28.000Z
2017-11-23T07:08:00.000Z
code-readpad/kernel-schema/mm_oom_kill.c.h
lkml-likexu/kde
8d650a838db6660c5fe01139cb5edb8640abd01a
[ "MIT" ]
null
null
null
EXPORT_SYMBOL_GPL(register_oom_notifier); EXPORT_SYMBOL_GPL(unregister_oom_notifier); \n static bool has_intersects_mems_allowed(struct task_struct *start, const nodemask_t *mask) return ret; } static bool has_intersects_mems_allowed(struct task_struct *tsk, const nodemask_t *mask) struct task_struct *find_lock_task_mm(struct task_struct *p) static inline bool is_sysrq_oom(struct oom_control *oc) static inline bool is_memcg_oom(struct oom_control *oc) static bool oom_unkillable_task(struct task_struct *p, struct mem_cgroup *memcg, const nodemask_t *nodemask) static bool is_dump_unreclaim_slabs(void) unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg, const nodemask_t *nodemask, unsigned long totalpages) static enum oom_constraint constrained_alloc(struct oom_control *oc) static int oom_evaluate_task(struct task_struct *task, void *arg) static void select_bad_process(struct oom_control *oc) static void dump_tasks(struct mem_cgroup *memcg, const nodemask_t *nodemask) static void dump_oom_summary(struct oom_control *oc, struct task_struct *victim) static void dump_header(struct oom_control *oc, struct task_struct *p) bool process_shares_mm(struct task_struct *p, struct mm_struct *mm) bool __oom_reap_task_mm(struct mm_struct *mm) static bool oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm) define MAX_OOM_REAP_RETRIES 10 static void oom_reap_task(struct task_struct *tsk) static int oom_reaper(void *unused) static void wake_oom_reaper(struct task_struct *tsk) static int __init oom_init(void) static int __init oom_init(void) oom_reaper_th = kthread_run(oom_reaper, NULL, "oom_reaper") ;return 0; } subsys_initcall(oom_init) static inline void wake_oom_reaper(struct task_struct *tsk) static void mark_oom_victim(struct task_struct *tsk) void exit_oom_victim(void) void oom_killer_enable(void) bool oom_killer_disable(signed long timeout) static inline bool __task_will_free_mem(struct task_struct *task) static bool task_will_free_mem(struct task_struct *task) static void __oom_kill_process(struct task_struct *victim) static int oom_kill_memcg_member(struct task_struct *task, void *unused) static void oom_kill_process(struct oom_control *oc, const char *message) static void check_panic_on_oom(struct oom_control *oc, enum oom_constraint constraint) int register_oom_notifier(struct notifier_block *nb) int unregister_oom_notifier(struct notifier_block *nb) bool out_of_memory(struct oom_control *oc) void pagefault_out_of_memory(void) \n 9 struct oom_control *oc 6 void 6 struct task_struct *tsk 5 struct task_struct *p 4 struct task_struct *task 3 struct mm_struct *mm 3 struct mem_cgroup *memcg 3 const nodemask_t *nodemask 2 void *unused 2 struct task_struct *victim 2 struct notifier_block *nb 2 const nodemask_t *mask 1 void *arg 1 unsigned long totalpages 1 unregister_oom_notifier 1 struct task_struct *start 1 signed long timeout 1 register_oom_notifier 1 oom_reaper 1 "oom_reaper" 1 oom_init 1 NULL 1 enum oom_constraint constraint 1 const char *message
45.942029
128
0.800315
c9adc99d7239068db4b00d6cecb12bf3d6e8cf30
517
h
C
Shared/Utils-lib/include/database-utils.h
q1e123/Network-resource-monitor
3cabbeeeee628597c4c7a2362eaa3d45995f5355
[ "MIT" ]
null
null
null
Shared/Utils-lib/include/database-utils.h
q1e123/Network-resource-monitor
3cabbeeeee628597c4c7a2362eaa3d45995f5355
[ "MIT" ]
null
null
null
Shared/Utils-lib/include/database-utils.h
q1e123/Network-resource-monitor
3cabbeeeee628597c4c7a2362eaa3d45995f5355
[ "MIT" ]
null
null
null
#include "database-structs.h" #include "build_opts_utils.h" namespace Database_Structs_Utils{ std::string UTILS_IMPEXP serialize(DB_Users user); DB_Users UTILS_IMPEXP deserialize_db_users(std::string serialization); std::string UTILS_IMPEXP serialize(DB_Systems db_system); DB_Systems UTILS_IMPEXP deserialize_db_system(std::string serialization); std::string UTILS_IMPEXP serialize(DB_User_List user_list); DB_User_List UTILS_IMPEXP deserialize_db_user_list(std::string serialization); }
34.466667
82
0.806576
84847c55d4acaab60e33ffbddd58bd2866909d3f
2,569
c
C
Algorithms_1/corewar/assembler/src/detection.c
diVid3/WeThinkCode_Projects
5bf4d715410eb6c974a763016aff65875ccebe5f
[ "MIT" ]
1
2020-04-02T15:54:44.000Z
2020-04-02T15:54:44.000Z
Algorithms_1/corewar/assembler/src/detection.c
diVid3/WeThinkCode_Projects
5bf4d715410eb6c974a763016aff65875ccebe5f
[ "MIT" ]
11
2021-05-07T15:33:47.000Z
2022-03-02T04:25:08.000Z
Algorithms_1/corewar/assembler/src/detection.c
diVid3/WeThinkCode_Projects
5bf4d715410eb6c974a763016aff65875ccebe5f
[ "MIT" ]
1
2018-06-07T07:07:45.000Z
2018-06-07T07:07:45.000Z
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* detection.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: egenis <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/09/18 09:11:03 by egenis #+# #+# */ /* Updated: 2018/09/18 09:11:08 by egenis ### ########.fr */ /* */ /* ************************************************************************** */ #include "../inc/asm.h" void iterate_w_space(char *str, int *cntr) { while (str[*cntr] && (str[*cntr] == ' ' || str[*cntr] == 9 || str[*cntr] == 11 || str[*cntr] == 12 || str[*cntr] == 13)) ++(*cntr); } int is_name_cmd(char *str) { int cntr; cntr = 0; iterate_w_space(str, &cntr); if (ft_strncmp(str + cntr, NAME_CMD_STRING, strclen(NAME_CMD_STRING)) != 0) return (0); cntr += strclen(NAME_CMD_STRING); if (str[cntr] != ' ' && str[cntr] != 9 && str[cntr] != 11 && str[cntr] != 12 && str[cntr] != 13) return (0); iterate_w_space(str, &cntr); if (str[cntr] != '"' || (str[cntr] == '"' && str[cntr + 1] == '"')) return (0); while (str[++cntr] && str[cntr] != '"') ; if (str[cntr] != '"') return (0); ++cntr; iterate_w_space(str, &cntr); if (str[cntr] != '\0' && str[cntr] != COMMENT_CHAR) return (0); return (1); } int is_comment_cmd(char *str) { int cntr; cntr = 0; iterate_w_space(str, &cntr); if (ft_strncmp(str + cntr, COMMENT_CMD_STRING, strclen(COMMENT_CMD_STRING)) != 0) return (0); cntr += strclen(COMMENT_CMD_STRING); if (str[cntr] != ' ' && str[cntr] != 9 && str[cntr] != 11 && str[cntr] != 12 && str[cntr] != 13) return (0); iterate_w_space(str, &cntr); if (str[cntr] != '"' || (str[cntr] == '"' && str[cntr + 1] == '"')) return (0); while (str[++cntr] && str[cntr] != '"') ; if (str[cntr] != '"') return (0); ++cntr; iterate_w_space(str, &cntr); if (str[cntr] != '\0' && str[cntr] != COMMENT_CHAR) return (0); return (1); } int has_ext(char *file) { int cntr; cntr = 0; while (file[cntr]) ++cntr; --cntr; if (file[cntr] == 's' && file[cntr - 1] == '.') return (1); return (0); }
29.193182
80
0.387699
ec2282987e4d56fbd47019998e4cdb25c78d8e12
3,654
c
C
test/lladd-old/jbhtsimple.c
Zhoutall/stasis
65a9ae5ce1468e3d8073e62fbcb15b120ec344f5
[ "TCL" ]
null
null
null
test/lladd-old/jbhtsimple.c
Zhoutall/stasis
65a9ae5ce1468e3d8073e62fbcb15b120ec344f5
[ "TCL" ]
null
null
null
test/lladd-old/jbhtsimple.c
Zhoutall/stasis
65a9ae5ce1468e3d8073e62fbcb15b120ec344f5
[ "TCL" ]
1
2019-11-21T07:21:32.000Z
2019-11-21T07:21:32.000Z
/*--- This software is copyrighted by the Regents of the University of California, and other parties. The following terms apply to all files associated with the software unless explicitly disclaimed in individual files. The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions. No written agreement, license, or royalty fee is required for any of the authorized uses. Modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated on the first page of each file where they apply. IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. GOVERNMENT USE: If you are acquiring this software on behalf of the U.S. government, the Government shall have only "Restricted Rights" in the software and related documentation as defined in the Federal Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you are acquiring the software on behalf of the Department of Defense, the software shall be classified as "Commercial Computer Software" and the Government shall have only "Restricted Rights" as defined in Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the authors grant the U.S. Government and others acting in its behalf permission to use and distribute the software in accordance with the terms specified in this license. ---*/ #include <stdio.h> #include "test.h" #include "../pbl/jbhash.h" typedef struct { int key; char *value; } test_pair_t; /** * Simple test of persistant hash table */ int test() { test_pair_t one = { 1, "one" }; test_pair_t two = { 2, "two" }; test_pair_t three = { 3, "three" }; test_pair_t four = { 4, "four" }; int i; int xid = Tbegin(); jbHashTable_t *ht = jbHtCreate(xid, 79); if( jbHtInsert(xid, ht, &one.key, sizeof(int), one.value, sizeof(char)*4) || jbHtInsert(xid, ht, &two.key, sizeof(int), two.value, sizeof(char)*4) || jbHtInsert(xid, ht, &three.key, sizeof(int), three.value, sizeof(char)*6) || jbHtInsert(xid, ht, &four.key, sizeof(int), four.value, sizeof(char)*5) ) { return -1; } Tcommit(xid); xid = Tbegin(); for( i = 1; i <= 4; i++ ) { char buf[7]; jbHtLookup(xid, ht, &i, sizeof(int), buf); printf("key %u: %s\n", i, buf); } jbHtDelete(xid, ht); Tcommit(xid); return 0; }
40.6
130
0.640668
709bbbded7e7218ad68cedde1a321700fb525037
2,671
h
C
muduo/base/ProcessInfo.h
HZMCIU/muduo
dd863a47746b7d160c461df7d1f169833b152b67
[ "BSD-3-Clause" ]
null
null
null
muduo/base/ProcessInfo.h
HZMCIU/muduo
dd863a47746b7d160c461df7d1f169833b152b67
[ "BSD-3-Clause" ]
null
null
null
muduo/base/ProcessInfo.h
HZMCIU/muduo
dd863a47746b7d160c461df7d1f169833b152b67
[ "BSD-3-Clause" ]
null
null
null
// Use of this source code is governed by a BSD-style license // that can be found in the License file. // Author: Shuo Chen (chenshuo at chenshuo dot com) // // This is a public header file, it must only include public header files. #ifndef MUDUO_BASE_PROCESSINFO_H #define MUDUO_BASE_PROCESSINFO_H #include "muduo/base/StringPiece.h" #include "muduo/base/Types.h" #include "muduo/base/Timestamp.h" #include <vector> #include <sys/types.h> namespace muduo { namespace ProcessInfo { pid_t pid(); string pidString(); uid_t uid(); string username(); uid_t euid(); Timestamp startTime(); int clockTicksPerSecond(); int pageSize(); bool isDebugBuild(); // constexpr string hostname(); string procname(); StringPiece procname(const string& stat); /** * @comment process information file system * @brief * - The proc filesystem is a pseudo-filesystem which provides an interface to kernel data structures. It is commonly mounted at /proc. * Typically, it is mounted automatically by the system, but it can also be mounted manually using a command such as: * mount -t proc proc /proc * Most of the files in the proc filesystem are read-only, but some files are writable, allowing kernel variables to be changed. * - Overview Underneath /proc, there are the following general groups of files and subdirectories: * - /proc/[pid] subdirectories * Each one of these subdirectories contains files and subdirectories exposing information about the process with the corresponding process ID. * - /proc/self * When a process accesses this magic symbolic link, it resolves to the process's own /proc/[pid] directory. * - /proc/[pid]/status * Provides much of the information in /proc/[pid]/stat and /proc/[pid]/statm in a format that's easier for humans to parse. Here's an example: * - /proc/stat * kernel/system statistics. Varies with architecture. Common entries include: * - /proc/[pid]/exe * Under Linux 2.2 and later, this file is a symbolic link containing the actual pathname of the executed command. */ /// read /proc/self/status string procStatus(); /// read /proc/self/stat string procStat(); /// read /proc/self/task/tid/stat string threadStat(); /// readlink /proc/self/exe string exePath(); int openedFiles(); int maxOpenFiles(); struct CpuTime { double userSeconds; double systemSeconds; CpuTime() : userSeconds(0.0), systemSeconds(0.0) { } double total() const { return userSeconds + systemSeconds; } }; CpuTime cpuTime(); int numThreads(); std::vector<pid_t> threads(); } // namespace ProcessInfo } // namespace muduo #endif // MUDUO_BASE_PROCESSINFO_H
30.352273
148
0.722201
5f463ecb45cd86a0124e5799d299f2b2a1910b0d
890
c
C
cs251a-microbench/mm.c
mrunalkp/cs251
894d1c7fa2e33c1af1844b4b3c420cf37d649027
[ "BSD-3-Clause" ]
null
null
null
cs251a-microbench/mm.c
mrunalkp/cs251
894d1c7fa2e33c1af1844b4b3c420cf37d649027
[ "BSD-3-Clause" ]
null
null
null
cs251a-microbench/mm.c
mrunalkp/cs251
894d1c7fa2e33c1af1844b4b3c420cf37d649027
[ "BSD-3-Clause" ]
null
null
null
#include <stdio.h> #define row_size 128 #define N row_size*row_size #define block_size 8 //Matrix multiply: prod = m1 x m2 float m1[N]; float m2[N]; float prod[N]; void mm() { //source machsuite int i, k, j, jj, kk; int i_row, k_row; for (jj = 0; jj < row_size; jj += block_size){ for (kk = 0; kk < row_size; kk += block_size){ for ( i = 0; i < row_size; ++i){ for (k = 0; k < block_size; ++k){ i_row = i * row_size; k_row = (k + kk) * row_size; for (j = 0; j < block_size; ++j){ prod[i_row + j + jj] += m1[i_row + k + kk] * m2[k_row + j + jj]; } } } } } } int main(int argc, char**argv) { mm(); if(argc>=2) { printf("random result:%f, %s\n", prod[argc],argv[0]); } }
21.707317
88
0.44382
e0be9e4b8e7c7ca735a79f445eed796ea85e8ce0
489
c
C
tests/in_flight_memfile_request.c
albertobarri/idk
a250884f79e2a484251fc750bb915ecbc962be58
[ "MIT" ]
9,724
2015-01-01T02:06:30.000Z
2019-01-17T15:13:51.000Z
tests/in_flight_memfile_request.c
albertobarri/idk
a250884f79e2a484251fc750bb915ecbc962be58
[ "MIT" ]
7,584
2019-01-17T22:58:27.000Z
2022-03-31T23:10:22.000Z
tests/in_flight_memfile_request.c
albertobarri/idk
a250884f79e2a484251fc750bb915ecbc962be58
[ "MIT" ]
1,519
2015-01-01T18:11:12.000Z
2019-01-17T14:16:02.000Z
/* * Copyright 2015 The Emscripten Authors. All rights reserved. * Emscripten is available under two separate licenses, the MIT license and the * University of Illinois/NCSA Open Source License. Both these licenses can be * found in the LICENSE file. */ #include <stdio.h> #include <emscripten.h> int main() { int result = EM_ASM_INT({ return !!Module['memoryInitializerRequest']; }); printf("memory init request: %d\n", result); REPORT_RESULT(result); return 0; }
24.45
79
0.711656
4a4f8fd13831bd87f2d9ddd567db4d0cedbe2d4c
393
c
C
latex/src/av5/z4.c
kikojumkd/SP
217cf66bdce28342b211198bac28d4571311265c
[ "MIT" ]
2
2019-05-23T20:41:05.000Z
2019-05-24T13:51:28.000Z
latex/src/av5/z4.c
kikojumkd/SP
217cf66bdce28342b211198bac28d4571311265c
[ "MIT" ]
null
null
null
latex/src/av5/z4.c
kikojumkd/SP
217cf66bdce28342b211198bac28d4571311265c
[ "MIT" ]
null
null
null
#include <stdio.h> int main() { int m, i, n, suma, prva_cifra, cifra; i = 1000; while (i<=9999) { prva_cifra = i/1000; n = i % 1000; suma = 0; while (n > 0) { cifra = n % 10; suma += cifra; n /= 10; } if (suma == prva_cifra) printf("%d\t", i); i++; } return 0; }
19.65
51
0.371501
623367f812a51d1ee6ff7a9eb4f5ab3b0796d426
282
h
C
Sources/UIColor+LUIConvenience.h
aleffert/louis
33eab97e15717c16b9dc722126da113fec173ff3
[ "MIT" ]
9
2016-03-02T10:36:08.000Z
2018-03-28T17:12:43.000Z
Sources/UIColor+LUIConvenience.h
aleffert/louis
33eab97e15717c16b9dc722126da113fec173ff3
[ "MIT" ]
null
null
null
Sources/UIColor+LUIConvenience.h
aleffert/louis
33eab97e15717c16b9dc722126da113fec173ff3
[ "MIT" ]
1
2021-03-21T11:17:30.000Z
2021-03-21T11:17:30.000Z
// // UIColor+LUIConvenience.h // Louis // // Created by Akiva Leffert on 12/24/16. // Copyright © 2016 Akiva Leffert. All rights reserved. // #import <UIKit/UIKit.h> @interface UIColor (LUIConvenience) - (BOOL)lui_isOpaque; - (UIImage*)lui_swatchOfSize:(CGSize)size; @end
15.666667
56
0.698582
00f45d70f28fc1e2e3027f2669b9b98a26d274c5
39,647
c
C
opensoap/src/api/Serializer.c
kbore/pbis-open
a05eb9309269b6402b4d6659bc45961986ea5eab
[ "Apache-2.0" ]
372
2016-10-28T10:50:35.000Z
2022-03-18T19:54:37.000Z
opensoap/src/api/Serializer.c
kbore/pbis-open
a05eb9309269b6402b4d6659bc45961986ea5eab
[ "Apache-2.0" ]
317
2016-11-02T17:41:48.000Z
2021-11-08T20:28:19.000Z
opensoap/src/api/Serializer.c
kenferrara/pbis-open
690c325d947b2bf6fb3032f9d660e41b94aea4be
[ "Apache-2.0" ]
107
2016-11-03T19:25:16.000Z
2022-03-20T21:15:22.000Z
/*----------------------------------------------------------------------------- * $RCSfile: Serializer.c,v $ * * See Copyright for the status of this software. * * The OpenSOAP Project * http://opensoap.jp/ *----------------------------------------------------------------------------- */ #include "Serializer.h" #include <string.h> /* =begin = OpenSOAP Serializer class =end */ /* =begin --- function#OPENSOAP_SERIALIZER_NAME(bool)(*fromValue, to) OpenSOAP Serializer of Boolean Type :Parameters :[in] void * ((|fromValue|)) Serializer Object Assign Pointer :[out] OpenSOAPStringPtr ((|to|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note Boolean-type, handled as INT 0,1,True,False =end */ static const wchar_t * SOAPTrues[] = { L"true", L"1", NULL }; static const wchar_t * SOAPFalses[] = { L"false", L"0", NULL }; int OPENSOAP_SERIALIZER_NAME(boolean)(/* [in] */ void *fromValue, /* [out] */ OpenSOAPStringPtr to) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (fromValue && to) { ret = OpenSOAPStringSetStringWC(to, (*(int *)fromValue) ? SOAPTrues[0] : SOAPFalses[0]); } return ret; } /* =begin --- function#OPENSOAP_DESERIALIZER_NAME(bool)(from, toValue) OpenSOAP Deserializer of Boolean Type :Parameters :[in] OpenSOAPStringPtr ((|from|)) Deserializer Object Assign Pointer :[out] void * ((|toValue|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note Boolean-type, handled as INT 0,1,True,False =end */ int OPENSOAP_DESERIALIZER_NAME(boolean)(/* [in] */ OpenSOAPStringPtr from, /* [out] */ void *toValue) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (from && toValue) { int cmpRslt = 0; const wchar_t **cmpStrs = SOAPTrues; for (; *cmpStrs; ++cmpStrs) { ret = OpenSOAPStringCompareWC(from, *cmpStrs, &cmpRslt); if (OPENSOAP_FAILED(ret) || cmpRslt == 0) { break; } } if (OPENSOAP_SUCCEEDED(ret)) { if (*cmpStrs) { *(int *)toValue = 1; } else { for (cmpStrs = SOAPFalses; *cmpStrs; ++cmpStrs) { ret = OpenSOAPStringCompareWC(from, *cmpStrs, &cmpRslt); if (OPENSOAP_FAILED(ret) || cmpRslt == 0) { break; } } if (OPENSOAP_SUCCEEDED(ret) && *cmpStrs) { *(int *)toValue = 0; } } } } return ret; } /* Base64 encoding/decoding */ #include <string.h> #include <ctype.h> static const unsigned char base64Code[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; static const unsigned char base64PadChar = '='; static unsigned char getBase64Code(unsigned char c) { unsigned char ret = (unsigned char)(-1); const unsigned char *search = strchr(base64Code, c); if (search) { ret = (search - base64Code); } return ret; } /* =begin --- function#OPENSOAP_SERIALIZER_NAME(base64Binary)(fromValue, to) OpenSOAP Serializer of Bibary(Base64Binary) Type :Parameters :[in] void * ((|fromValue|)) Serializer Object Assign Pointer :[out] OpenSOAPStringPtr ((|to|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note Binary-type(Base64Binary)ByteArray =end */ int OPENSOAP_SERIALIZER_NAME(base64Binary)(/* [in] */ void *fromValue, /* [out] */ OpenSOAPStringPtr to) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (fromValue && to) { OpenSOAPByteArrayPtr fromBary = *(OpenSOAPByteArrayPtr *)fromValue; const unsigned char *fromValueBeg = NULL; size_t fromSz = 0; ret = OpenSOAPByteArrayGetBeginSizeConst(fromBary, &fromValueBeg, &fromSz); if (OPENSOAP_SUCCEEDED(ret)) { OpenSOAPByteArrayPtr toStr = NULL; ret = OpenSOAPByteArrayCreate(&toStr); if (OPENSOAP_SUCCEEDED(ret)) { #define B64UNIT_SIZE 3 size_t i = 0; size_t paddingSz = (fromSz + B64UNIT_SIZE - 1) / B64UNIT_SIZE * B64UNIT_SIZE; while (OPENSOAP_SUCCEEDED(ret) && i != paddingSz) { #define B64APPEND_SIZE 4 unsigned char append_buf[B64APPEND_SIZE]; size_t next_i = i + B64UNIT_SIZE; size_t append_fromSz = (next_i == paddingSz) ? (fromSz - i) : B64UNIT_SIZE; const unsigned char *from_i = fromValueBeg + i; unsigned char *a_i = append_buf; *a_i++ = base64Code[(from_i[0] & 0xfc) >> 2]; *a_i++ = base64Code[((from_i[0] & 0x03) << 4) | ((append_fromSz > 1) ? ((from_i[1] & 0xf0) >> 4) : '\0')]; *a_i++ = (append_fromSz > 1) ? base64Code[((from_i[1] & 0x0f) << 2) | ((append_fromSz > 2) ? ((from_i[2] & 0xc0) >> 6) : '\0')] : base64PadChar; *a_i++ = (append_fromSz > 2) ? base64Code[(from_i[2] & 0x3f)] : base64PadChar; ret = OpenSOAPByteArrayAppend(toStr, append_buf, B64APPEND_SIZE); i = next_i; #undef B64APPEND_SIZE } if (OPENSOAP_SUCCEEDED(ret)) { ret = OpenSOAPStringSetCharEncodingString(to, "US-ASCII", toStr); } OpenSOAPByteArrayRelease(toStr); #undef B64UNIT_SIZE } } } return ret; } static int OpenSOAPDeserializerBase64(/* [in] */ OpenSOAPByteArrayPtr from, /* [out] */ OpenSOAPByteArrayPtr to) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (from && to) { ret = OpenSOAPByteArrayClear(to); if (OPENSOAP_SUCCEEDED(ret)) { const unsigned char *fromValue = NULL; size_t fromSz = 0; ret = OpenSOAPByteArrayGetBeginSizeConst(from, &fromValue, &fromSz); if (OPENSOAP_SUCCEEDED(ret)) { #define B64DECUNIT_SIZE 4 unsigned char decunit[B64DECUNIT_SIZE]; unsigned char *dItr = decunit; size_t i = 0; while (i != fromSz && OPENSOAP_SUCCEEDED(ret)) { unsigned char c = fromValue[i++]; if (!isspace(c)) { unsigned char d = getBase64Code(c); if (d != (unsigned char)(-1)) { *dItr++ = d; } else { ret = OPENSOAP_PARAMETER_BADVALUE; break; } } if (dItr == &decunit[B64DECUNIT_SIZE]) { #define B64UNIT_SIZE 3 unsigned char appendData[B64UNIT_SIZE]; size_t appendSize = 0; appendData[appendSize++] = ((decunit[0] & 0x3f) << 2) | ((decunit[1] & 0x30) >> 4); if (decunit[2] < 0x40) { appendData[appendSize++] = ((decunit[1] & 0x0f) << 4) | ((decunit[2] & 0x3c) >> 2); if (decunit[3] < 0x40) { appendData[appendSize++] = ((decunit[2] & 0x03) << 6) | (decunit[3] & 0x3f); } } ret = OpenSOAPByteArrayAppend(to, appendData, appendSize); dItr = decunit; #undef B64UNIT_SIZE } } #undef B64DECUNIT_SIZE } } } return ret; } /* =begin --- function#OPENSOAP_DESERIALIZER_NAME(base64Binary)(from, toValue) OpenSOAP Deserializer of Bibary(Base64Binary) Type :Parameters :[in] void * ((|fromValue|)) Deserializer Object Assign Pointer :[out] OpenSOAPStringPtr ((|to|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note Binary-type(Base64Binary)ByteArray =end */ int OPENSOAP_DESERIALIZER_NAME(base64Binary)(/* [in] */ OpenSOAPStringPtr from, /* [out] */ void *toValue) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (from && toValue) { OpenSOAPByteArrayPtr fromBAry = NULL; ret = OpenSOAPByteArrayCreate(&fromBAry); if (OPENSOAP_SUCCEEDED(ret)) { ret = OpenSOAPStringGetStringUSASCII(from, fromBAry); if (OPENSOAP_SUCCEEDED(ret)) { ret = OpenSOAPDeserializerBase64(fromBAry, *(OpenSOAPByteArrayPtr *) toValue); } OpenSOAPByteArrayRelease(fromBAry); } } return ret; } /* =begin --- function#OPENSOAP_SERIALIZER_NAME(double)(fromValue, to) OpenSOAP Serializer of Double Type :Parameters :[in] void * ((|fromValue|)) Serializer Object Assign Pointer :[out] OpenSOAPStringPtr ((|to|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note 64bit floating =end */ int OPENSOAP_SERIALIZER_NAME(double)(/* [in] */ void *fromValue, /* [out] */ OpenSOAPStringPtr to) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (fromValue && to) { double val = *(double *)fromValue; ret = OpenSOAPStringFormatWC(to, L"%f", val); } return ret; } /* =begin --- function#OPENSOAP_DESERIALIZER_NAME(double)(from, toValue) OpenSOAP Deserializer of Double Type :Parameters :[in] OpenSOAPStringPtr ((|from|)) Deserializer Object Assign Pointer :[out] void * ((|toValue|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note 64bit floating =end */ int OPENSOAP_DESERIALIZER_NAME(double)(/* [in] */ OpenSOAPStringPtr from, /* [out] */ void *toValue) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (from && toValue) { char *buf = NULL; ret = OpenSOAPStringGetStringMBWithAllocator(from, NULL, /* use malloc */ NULL, /* not use length */ &buf); if (OPENSOAP_SUCCEEDED(ret)) { *(double *)toValue = atof(buf); free(buf); } } return ret; } /* =begin --- function#OPENSOAP_SERIALIZER_NAME(int)(fromValue, to) OpenSOAP Serializer of Integer Type :Parameters :[in] void * ((|fromValue|)) Serializer Object Assign Pointer :[out] OpenSOAPStringPtr ((|to|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note 32bit =end */ int OPENSOAP_SERIALIZER_NAME(int)(/* [in] */ void *fromValue, /* [out] */ OpenSOAPStringPtr to) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (fromValue && to) { long val = *(long *)fromValue; ret = OpenSOAPStringFormatWC(to, L"%ld", val); } return ret; } /* =begin --- function#OPENSOAP_DESERIALIZER_NAME(int)(from, toValue) OpenSOAP Deserializer of Integer Type :Parameters :[in] OpenSOAPStringPtr ((|from|)) Serializer Object Assign Pointer :[out] void * ((|toValue|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note 32bit =end */ int OPENSOAP_DESERIALIZER_NAME(int)(/* [in] */ OpenSOAPStringPtr from, /* [out] */ void *toValue) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (from && toValue) { char *buf = NULL; ret = OpenSOAPStringGetStringMBWithAllocator(from, NULL, /* use malloc */ NULL, /* not use length */ &buf); if (OPENSOAP_SUCCEEDED(ret)) { *(long *)toValue = atol(buf); free(buf); } } return ret; } /* =begin --- function#OPENSOAP_SERIALIZER_NAME(short)(fromValue, to) OpenSOAP Serializer of Short Type :Parameters :[in] void * ((|fromValue|)) Serializer Object Assign Pointer :[out] OpenSOAPStringPtr ((|to|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note 16bit =end */ int OPENSOAP_SERIALIZER_NAME(short)(/* [in] */ void *fromValue, /* [out] */ OpenSOAPStringPtr to) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (fromValue && to) { short val = *(short *)fromValue; ret = OpenSOAPStringFormatWC(to, L"%d", val); } return ret; } /* =begin --- function#OPENSOAP_DESERIALIZER_NAME(short)(from, toValue) OpenSOAP Deserializer of Short Type :Parameters :[in] OpenSOAPStringPtr ((|from|)) Deserializer Object Assign Pointer :[out] void * ((|toValue|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note 16bit =end */ int OPENSOAP_DESERIALIZER_NAME(short)(/* [in] */ OpenSOAPStringPtr from, /* [out] */ void *toValue) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (from && toValue) { char *buf = NULL; ret = OpenSOAPStringGetStringMBWithAllocator(from, NULL, /* use malloc */ NULL, /* not use length */ &buf); if (OPENSOAP_SUCCEEDED(ret)) { *(short *)toValue = (short)atoi(buf); free(buf); } } return ret; } /* =begin --- function#OPENSOAP_SERIALIZER_NAME(string)(fromValue, to) OpenSOAP Serializer of String Type :Parameters :[in] void * ((|fromValue|)) Serializer Object Assign Pointer :[out] OpenSOAPStringPtr ((|to|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note String =end */ int OPENSOAP_SERIALIZER_NAME(string)(/* [in] */ void *fromValue, /* [out] */ OpenSOAPStringPtr to) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (fromValue && to) { OpenSOAPStringPtr fromStr = *(OpenSOAPStringPtr *)fromValue; ret = OpenSOAPStringDuplicate(fromStr, &to); } return ret; } /* =begin --- function#OPENSOAP_DESERIALIZER_NAME(string)(from, toValue) OpenSOAP Deserializer of String Type :Parameters :[in] OpenSOAPStringPtr ((|from|)) Deserializer Object Assign Pointer :[out] void * ((|toValue|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note String =end */ int OPENSOAP_DESERIALIZER_NAME(string)(/* [in] */ OpenSOAPStringPtr from, /* [out] */ void *toValue) { int ret = OPENSOAP_PARAMETER_BADVALUE; OpenSOAPStringPtr *toStr = (OpenSOAPStringPtr *)toValue; if (from && toStr #if defined(STRING_DEDESIRALIZER_CHECKED) && *toStr #endif ) { ret = OpenSOAPStringDuplicate(from, toStr); } return ret; } /*-------------------------------*/ /* float serializer/deserializer */ /*-------------------------------*/ /* =begin --- function#OPENSOAP_SERIALIZER_NAME(float)(fromValue, to) OpenSOAP Serializer of float Type :Parameters :[in] void * ((|fromValue|)) Serializer Object Assign Pointer :[out] OpenSOAPStringPtr ((|to|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note 32bit floating point number. =end */ int OPENSOAP_SERIALIZER_NAME(float)(/* [in] */ void *fromValue, /* [out] */ OpenSOAPStringPtr to) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (fromValue && to) { float val = *(float *)fromValue; ret = OpenSOAPStringFormatWC(to, L"%f", val); } return ret; } /* =begin --- function#OPENSOAP_DESERIALIZER_NAME(float)(from, toValue) OpenSOAP Deserializer of float Type :Parameters :[in] OpenSOAPStringPtr ((|from|)) Deserializer Object Assign Pointer :[out] void * ((|toValue|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note 32bit floating point number. =end */ int OPENSOAP_DESERIALIZER_NAME(float)(/* [in] */ OpenSOAPStringPtr from, /* [out] */ void *toValue) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (from && toValue) { char *buf = NULL; ret = OpenSOAPStringGetStringMBWithAllocator(from, NULL, /* use malloc */ NULL, /* not use length */ &buf); if (OPENSOAP_SUCCEEDED(ret)) { *(float *)toValue = (float)atof(buf); free(buf); } } return ret; } /*------------------------------*/ /* byte serializer/deserializer */ /*------------------------------*/ /* =begin --- function#OPENSOAP_SERIALIZER_NAME(byte)(fromValue, to) OpenSOAP Serializer of byte Type :Parameters :[in] void * ((|fromValue|)) Serializer Object Assign Pointer. This type is required signed char *. :[out] OpenSOAPStringPtr ((|to|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note byte is integer type and it's region is [-128, 127]. =end */ int OPENSOAP_SERIALIZER_NAME(byte)(/* [in] */ void *fromValue, /* [out] */ OpenSOAPStringPtr to) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (fromValue && to) { int val = *(signed char *)fromValue; ret = OpenSOAPStringFormatWC(to, L"%d", val); } return ret; } /* =begin --- function#OPENSOAP_DESERIALIZER_NAME(byte)(from, toValue) OpenSOAP Deserializer of byte Type :Parameters :[in] OpenSOAPStringPtr ((|from|)) Deserializer Object Assign Pointer :[out] void * ((|toValue|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode :Note byte is integer and it's region is [-128, 127]. =end */ int OPENSOAP_DESERIALIZER_NAME(byte)(/* [in] */ OpenSOAPStringPtr from, /* [out] */ void *toValue) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (from && toValue) { char *buf = NULL; ret = OpenSOAPStringGetStringMBWithAllocator(from, NULL, /* use malloc */ NULL, /* not use length */ &buf); if (OPENSOAP_SUCCEEDED(ret)) { *(signed char *)toValue = (signed char)atoi(buf); free(buf); } } return ret; } /*----------------------------------*/ /* dateTime serializer/deserializer */ /*----------------------------------*/ #include <time.h> /* =begin --- function#OPENSOAP_SERIALIZER_NAME(dateTime)(fromValue, to) OpenSOAP Serializer of dateTime Type :Parameters :[in] void * ((|fromValue|)) Serializer Object Assign Pointer. This type is required signed char *. :[out] OpenSOAPStringPtr ((|to|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode =end */ int OPENSOAP_SERIALIZER_NAME(dateTime)(/* [in] */ void *fromValue, /* [out] */ OpenSOAPStringPtr to) { static const char XMLdateTimeFormat[] = "%Y-%m-%dT%H:%M:%SZ"; int ret = OPENSOAP_PARAMETER_BADVALUE; if (fromValue && to) { const struct tm *val = (const struct tm *)fromValue; #define BUFDEFSIZE 22 #define BUFGRAWSIZE 4 size_t maxlen = BUFDEFSIZE; char *buf = NULL; char *oldBuf = NULL; for (; buf = realloc(oldBuf, (maxlen + 1)); oldBuf = buf) { size_t len = strftime(buf, maxlen, XMLdateTimeFormat, val); if (len < maxlen && len > 0) { break; } maxlen += BUFGRAWSIZE; } if (!buf) { free(oldBuf); ret = OPENSOAP_MEM_BADALLOC; } else { ret = OpenSOAPStringSetStringMB(to, buf); free(buf); } #undef BUFGRAWSIZE #undef BUFDEFSIZE } return ret; } static int isTermChars(char chr, const char *termChars, size_t termCharsSize) { int ret = 0; if (termChars && termCharsSize) { const char *tc = termChars; const char * const tcEnd = termChars + termCharsSize; for (; tc != tcEnd; ++tc) { if (*tc == chr) { ret = 1; break; } } } return ret; } static int getLongValueWithTermChars(/* [in, out] */ const char **str, /* [in] */ const char *strEnd, /* [in] */ const char *termChars, /* [in] */ size_t termCharsSize, /* [out] */ long *value) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (str && *str && *str < strEnd && termChars && termCharsSize && value) { const char *strI = *str; ret = OPENSOAP_NO_ERROR; *value = 0; for (; strI != strEnd && !isTermChars(*strI, termChars, termCharsSize); ++strI) { if (!isdigit(*strI)) { ret = OPENSOAP_PARAMETER_BADVALUE; break; } *value *= 10; *value += (*strI - '0'); } *str = strI; } return ret; } static int OpenSOAPDeserializerMBStrToDate(/* [in, out] */ const char **str, /* [in] */ const char *strEnd, /* [out] */ struct tm *toValue) { static const char YEAR_MONTH_TERM_CHARS[] = "-"; static size_t YEAR_MONTH_TERM_CHARS_SIZE = sizeof(YEAR_MONTH_TERM_CHARS); static const char DAY_TERM_CHARS[] = "T"; static size_t DAY_TERM_CHARS_SIZE = sizeof(DAY_TERM_CHARS); int ret = OPENSOAP_PARAMETER_BADVALUE; if (str && *str && *str < strEnd && toValue) { long year = 0; ret = getLongValueWithTermChars(str, strEnd, YEAR_MONTH_TERM_CHARS, YEAR_MONTH_TERM_CHARS_SIZE, &year); if (OPENSOAP_SUCCEEDED(ret)) { long month = 0; ++(*str); ret = getLongValueWithTermChars(str, strEnd, YEAR_MONTH_TERM_CHARS, YEAR_MONTH_TERM_CHARS_SIZE, &month); if (OPENSOAP_SUCCEEDED(ret)) { long day = 0; ++(*str); ret = getLongValueWithTermChars(str, strEnd, DAY_TERM_CHARS, DAY_TERM_CHARS_SIZE, &day); if (OPENSOAP_SUCCEEDED(ret)) { if (month <= 0 || month > 12 || day <= 0 || day > 31) { ret = OPENSOAP_PARAMETER_BADVALUE; } else { toValue->tm_year = (year - 1900); toValue->tm_mon = month - 1; toValue->tm_mday = day; } } } } } return ret; } static int OpenSOAPDeserializerMBStrToHourMin(/* [in, out] */ const char **str, /* [in] */ const char *strEnd, /* [out] */ struct tm *toValue) { static const char HOUR_MIN_TERM_CHARS[] = ":"; static size_t HOUR_MIN_TERM_CHARS_SIZE = sizeof(HOUR_MIN_TERM_CHARS); int ret = OPENSOAP_PARAMETER_BADVALUE; if (str && *str && *str < strEnd && toValue) { long hour = 0; ret = getLongValueWithTermChars(str, strEnd, HOUR_MIN_TERM_CHARS, HOUR_MIN_TERM_CHARS_SIZE, &hour); if (OPENSOAP_SUCCEEDED(ret)) { long minutes = 0; ++(*str); ret = getLongValueWithTermChars(str, strEnd, HOUR_MIN_TERM_CHARS, HOUR_MIN_TERM_CHARS_SIZE, &minutes); if (OPENSOAP_SUCCEEDED(ret)) { if (hour < 0 || hour > 23 || minutes < 0 || minutes > 59) { ret = OPENSOAP_PARAMETER_BADVALUE; } else { toValue->tm_hour = hour; toValue->tm_min = minutes; } } } } return ret; } static const char SECOND_TERM_CHARS[] = ".-Z+"; static const size_t SECOND_TERM_CHARS_SIZE = sizeof(SECOND_TERM_CHARS); static const char *PRE_TZ_TERM_CHARS = SECOND_TERM_CHARS + 1; static const size_t PRE_TZ_TERM_CHARS_SIZE = sizeof(SECOND_TERM_CHARS) - 1; static int OpenSOAPDeserializerMBStrToSec(/* [in, out] */ const char **str, /* [in] */ const char *strEnd, /* [in. out] */ struct tm *toValue) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (str && *str && *str < strEnd && toValue) { long sec = 0; ret = getLongValueWithTermChars(str, strEnd, SECOND_TERM_CHARS, SECOND_TERM_CHARS_SIZE, &sec); if (OPENSOAP_SUCCEEDED(ret)) { if (sec <= 0 || sec > 61) { ret = OPENSOAP_PARAMETER_BADVALUE; } else { toValue->tm_sec = sec; if (**str == SECOND_TERM_CHARS[0]) { /* is point */ long dummy = 0; ++(*str); ret = getLongValueWithTermChars(str, strEnd, PRE_TZ_TERM_CHARS, PRE_TZ_TERM_CHARS_SIZE, &dummy); } } } } return ret; } static int OpenSOAPDeserializerMBStrToModifyTZ(/* [in, out] */ const char **str, /* [in] */ const char *strEnd, /* [in. out] */ struct tm *toValue) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (str && *str && *str < strEnd && toValue) { /* const char *strI = *str; */ const char *preTzChar = strchr(PRE_TZ_TERM_CHARS, **str); int sign = preTzChar ? -(preTzChar - PRE_TZ_TERM_CHARS - 1) : 0; ret = OPENSOAP_NO_ERROR; if (sign) { struct tm tz; ++(*str); ret = OpenSOAPDeserializerMBStrToHourMin(str, strEnd, &tz); if (OPENSOAP_SUCCEEDED(ret)) { toValue->tm_hour += sign * tz.tm_hour; toValue->tm_min += sign * tz.tm_min; } } if (OPENSOAP_SUCCEEDED(ret)) { /* adjust tm_wday and tm_yday, etc. */ time_t mktimeRet = (time_t)(-1); mktimeRet = mktime(toValue); if (mktimeRet == (time_t)(-1)) { ret = OPENSOAP_PARAMETER_BADVALUE; } } } return ret; } /* =begin --- function#OPENSOAP_DESERIALIZER_NAME(dateTime)(from, toValue) OpenSOAP Deserializer of dateTime Type :Parameters :[in] OpenSOAPStringPtr ((|from|)) Deserializer Object Assign Pointer :[out] void * ((|toValue|)) Result Value Pointer :Return Value :int Return Code Is ErrorCode =end */ int OPENSOAP_DESERIALIZER_NAME(dateTime)(/* [in] */ OpenSOAPStringPtr from, /* [out] */ void *toValue) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (from && toValue) { char *buf = NULL; size_t len = 0; ret = OpenSOAPStringGetStringMBWithAllocator(from, NULL, /* use malloc */ &len, &buf); if (OPENSOAP_SUCCEEDED(ret)) { const char * const bufEnd = buf + len + 1; const char *bufI = buf; struct tm *value = toValue; ret = OpenSOAPDeserializerMBStrToDate(&bufI, bufEnd, value); if (OPENSOAP_SUCCEEDED(ret)) { ++bufI; ret = OpenSOAPDeserializerMBStrToHourMin(&bufI, bufEnd, value); if (OPENSOAP_SUCCEEDED(ret)) { ++bufI; ret = OpenSOAPDeserializerMBStrToSec(&bufI, bufEnd, value); if (OPENSOAP_SUCCEEDED(ret)) { ret = OpenSOAPDeserializerMBStrToModifyTZ(&bufI, bufEnd, value); } } } free(buf); } } return ret; } /* =begin = Serializer registry code. =end */ #include <OpenSOAP/StringHash.h> typedef struct { OpenSOAPSerializerFunc serializer; OpenSOAPDeserializerFunc deserializer; } StaticOpenSOAPSerializerPair, *StaticOpenSOAPSerializerPairPtr; static OpenSOAPStringHashPtr serializerTable = NULL; /* =begin --- function#createSerializerPair(serializer, deserializer) OpenSOAP create serializer pair :Parameters :OpenSOAPSerializerFunc [in] ((|serializer|)) Serializer Function Program Pointer :OpenSOAPDeserializerFunc [out] ((|deserializer|)) Deserializer Function Program Pointer :Return Value :StaticOpenSOAPSerializerPairPtr :Note This Function Is Static Function =end */ static StaticOpenSOAPSerializerPairPtr createSerializerPair(/* [in] */ OpenSOAPSerializerFunc serializer, /* [in] */ OpenSOAPDeserializerFunc deserializer) { StaticOpenSOAPSerializerPairPtr ret = malloc(sizeof(StaticOpenSOAPSerializerPair)); if (ret) { ret->serializer = serializer; ret->deserializer = deserializer; } return ret; } /* =begin --- function#deleteSerializerPair(obj, opt) Delete OpenSOAP serializer pair. :Parameters :[in] void *((|obj|)) SerializerPair :[in] void *((|opt|)) NULL :Return Value :int return OPENSOAP_NO_ERROR =end */ static int deleteSerializerPair(/* [in] */ void *obj, /* [in] */ void *opt) { int ret = OPENSOAP_NO_ERROR; StaticOpenSOAPSerializerPairPtr p = (StaticOpenSOAPSerializerPairPtr)obj; free(p); return ret; } /* =begin --- function#OpenSOAPSerializerRegisterString(soapTypename, serializer, deserializer) Serializer and deserializer register function. :Parameters :[in] OpenSOAPStringPtr ((|soapTypename|)) typename. :[in] OpenSOAPSerializerFunc ((|serializer|)) serializer :[in] OpenSOAPDeserializerFunc ((|deserializer|)) deserializer :Return Value :int Return Code Is ErrorCode :Note This Function Is Static Function =end */ extern int OPENSOAP_API OpenSOAPSerializerRegisterString(/* [in] */ OpenSOAPStringPtr soapTypename, /* [in] */ OpenSOAPSerializerFunc serializer, /* [in] */ OpenSOAPDeserializerFunc deserializer) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (soapTypename && serializer && deserializer) { if (!serializerTable) { ret = OpenSOAPStringHashCreate(&serializerTable); if (OPENSOAP_FAILED(ret)) { serializerTable = NULL; } } if (serializerTable) { StaticOpenSOAPSerializerPairPtr serializerPair = createSerializerPair(serializer, deserializer); if (!serializerPair) { ret = OPENSOAP_MEM_BADALLOC; } else { ret = OpenSOAPStringHashSetValue(serializerTable, soapTypename, serializerPair); } } } return ret; } /* =begin --- function#OpenSOAPSerializerRegisterMB(soapTypename, serializer, deserializer) Serializer and deserializer register function.(MB) :Parameters :[in] const char *((|soapTypename|)) typename. :[in] OpenSOAPSerializerFunc ((|serializer|)) serializer :[in] OpenSOAPDeserializerFunc ((|deserializer|)) deserializer :Return Value :int Return Code Is ErrorCode =end */ extern int OPENSOAP_API OpenSOAPSerializerRegisterMB(/* [in] */ const char *soapTypename, /* [in] */ OpenSOAPSerializerFunc serializer, /* [in] */ OpenSOAPDeserializerFunc deserializer) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (soapTypename && *soapTypename) { OpenSOAPStringPtr tname = NULL; ret = OpenSOAPStringCreateWithMB(soapTypename, &tname); if (OPENSOAP_SUCCEEDED(ret)) { ret = OpenSOAPSerializerRegisterString(tname, serializer, deserializer); OpenSOAPStringRelease(tname); } } return ret; } /* =begin --- function#OpenSOAPSerializerRegisterWC(soapTypename, serializer, deserializer) Serializer and deserializer register function.(WC) :Parameters : [in] const wchar_t *((|soapTypename|)) typename. :[in] OpenSOAPSerializerFunc ((|serializer|)) serializer :[in] OpenSOAPDeserializerFunc ((|deserializer|)) deserializer :Return Value :int Return Code Is ErrorCode =end */ extern int OPENSOAP_API OpenSOAPSerializerRegisterWC(/* [in] */ const wchar_t *soapTypename, /* [in] */ OpenSOAPSerializerFunc serializer, /* [in] */ OpenSOAPDeserializerFunc deserializer) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (soapTypename && *soapTypename) { OpenSOAPStringPtr tname = NULL; ret = OpenSOAPStringCreateWithWC(soapTypename, &tname); if (OPENSOAP_SUCCEEDED(ret)) { ret = OpenSOAPSerializerRegisterString(tname, serializer, deserializer); OpenSOAPStringRelease(tname); } } return ret; } /* =begin --- function#OpenSOAPGetSerializerPair(soapTypename, serializerPair) Get registered serializer. :Parameters :[in] OpenSOAPStringPtr ((|soapTypename|)) typename. :[out] StaticOpenSOAPSerializerPairPtr * ((|serializerPair|)) serializer :Return Value :int Return Code Is ErrorCode :Note This Function Is Static Function =end */ static /* extern */ int /* OPENSOAP_API */ OpenSOAPGetSerializerPair(/* [in] */ OpenSOAPStringPtr soapTypename, /* [out] */ StaticOpenSOAPSerializerPairPtr *serializerPair) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (soapTypename && serializerPair) { ret = OpenSOAPStringHashGetValue(serializerTable, soapTypename, (void **)serializerPair); } return ret; } /* =begin --- function#OpenSOAPGetSerializer(soapTypename, serializer) Get registered serializer.(MB) :Parameters :[in] OpenSOAPStringPtr ((|soapTypename|)) typename. :[out] OpenSOAPSerializerFunc * ((|serializer|)) serializer :Return Value :int Return Code Is ErrorCode =end */ extern int OPENSOAP_API OpenSOAPGetSerializer(/* [in] */ OpenSOAPStringPtr soapTypename, /* [out] */ OpenSOAPSerializerFunc *serializer) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (soapTypename && serializer) { StaticOpenSOAPSerializerPairPtr serializerPair = NULL; ret = OpenSOAPGetSerializerPair(soapTypename, &serializerPair); if (OPENSOAP_SUCCEEDED(ret)) { *serializer = serializerPair->serializer; } } return ret; } /* =begin --- function#OpenSOAPGetSerializerMB(soapTypename, serializer) Get registered serializer.(MB) :Parameters :[in] const char * ((|soapTypename|)) typename. :[out] OpenSOAPSerializerFunc * ((|serializer|)) serializer :Return Value :int Return Code Is ErrorCode =end */ extern int OPENSOAP_API OpenSOAPGetSerializerMB(/* [in] */ const char *soapTypename, /* [out] */ OpenSOAPSerializerFunc *serializer) { OpenSOAPStringPtr tname = NULL; int ret = OpenSOAPStringCreateWithMB(soapTypename, &tname); if (OPENSOAP_SUCCEEDED(ret)) { ret = OpenSOAPGetSerializer(tname, serializer); OpenSOAPStringRelease(tname); } return ret; } /* =begin --- function#OpenSOAPGetSerializerWC(soapTypename, serializer) Get registered serializer.(WC) :Parameters :[in] const wchar_t * ((|soapTypename|)) typename. :[out] OpenSOAPSerializerFunc * ((|serializer|)) serializer :Return Value :int Return Code Is ErrorCode =end */ extern int OPENSOAP_API OpenSOAPGetSerializerWC(/* [in] */ const wchar_t *soapTypename, /* [out] */ OpenSOAPSerializerFunc *serializer) { OpenSOAPStringPtr tname = NULL; int ret = OpenSOAPStringCreateWithWC(soapTypename, &tname); if (OPENSOAP_SUCCEEDED(ret)) { ret = OpenSOAPGetSerializer(tname, serializer); OpenSOAPStringRelease(tname); } return ret; } /* =begin --- function#OpenSOAPGetDeserializer(soapTypename, deserializer) Get registered serializer.(OpenSOAPString) :Parameters :[in] OpenSOAPStringPtr ((|soapTypename|)) typename. :[out] OpenSOAPDeserializerFunc * ((|deserializer|)) deserializer :Return Value :int Return Code Is ErrorCode =end */ extern int OPENSOAP_API OpenSOAPGetDeserializer(/* [in] */ OpenSOAPStringPtr soapTypename, /* [out] */ OpenSOAPDeserializerFunc *deserializer) { int ret = OPENSOAP_PARAMETER_BADVALUE; if (soapTypename && deserializer) { StaticOpenSOAPSerializerPairPtr serializerPair = NULL; ret = OpenSOAPGetSerializerPair(soapTypename, &serializerPair); if (OPENSOAP_SUCCEEDED(ret)) { *deserializer = serializerPair->deserializer; } } return ret; } /* =begin --- function#OpenSOAPGetDeserializerMB(soapTypename, deserializer) Get registered serializer.(MB) :Parameters :[in] const char * ((|soapTypename|)) typename. :[out] OpenSOAPDeserializerFunc * ((|deserializer|)) deserializer :Return Value :int Return Code Is ErrorCode =end */ extern int OPENSOAP_API OpenSOAPGetDeserializerMB(/* [in] */ const char *soapTypename, /* [out] */ OpenSOAPDeserializerFunc *deserializer) { OpenSOAPStringPtr tname = NULL; int ret = OpenSOAPStringCreateWithMB(soapTypename, &tname); if (OPENSOAP_SUCCEEDED(ret)) { ret = OpenSOAPGetDeserializer(tname, deserializer); OpenSOAPStringRelease(tname); } return ret; } /* =begin --- function#OpenSOAPGetSerializerWC(soapTypename, deserializer) Get registered serializer.(WC) :Parameters :[in] const wchar_t * ((|soapTypename|)) typename. :[out] OpenSOAPDeserializerFunc * ((|deserializer|)) deserializer :Return Value :int Return Code Is ErrorCode =end */ extern int OPENSOAP_API OpenSOAPGetDeserializerWC(/* [in] */ const wchar_t *soapTypename, /* [out] */ OpenSOAPDeserializerFunc *deserializer) { OpenSOAPStringPtr tname = NULL; int ret = OpenSOAPStringCreateWithWC(soapTypename, &tname); if (OPENSOAP_SUCCEEDED(ret)) { ret = OpenSOAPGetDeserializer(tname, deserializer); OpenSOAPStringRelease(tname); } return ret; } typedef struct { const wchar_t *soapTypename; OpenSOAPSerializerFunc serializer; OpenSOAPDeserializerFunc deserializer; } OpenSOAPSerializerRegistInfo; typedef OpenSOAPSerializerRegistInfo *OpenSOAPSerializerRegistInfoPtr; static OpenSOAPSerializerRegistInfo SerializerRegisterInfos[] = { { L"boolean", OPENSOAP_SERIALIZER_PAIR(boolean)}, { L"base64Binary", OPENSOAP_SERIALIZER_PAIR(base64Binary)}, { L"double", OPENSOAP_SERIALIZER_PAIR(double)}, { L"int", OPENSOAP_SERIALIZER_PAIR(int)}, { L"short", OPENSOAP_SERIALIZER_PAIR(short)}, { L"string", OPENSOAP_SERIALIZER_PAIR(string)}, { L"float", OPENSOAP_SERIALIZER_PAIR(float)}, { L"byte", OPENSOAP_SERIALIZER_PAIR(byte)}, { L"dateTime", OPENSOAP_SERIALIZER_PAIR(dateTime)}, { NULL, NULL, NULL} }; /* =begin --- function#OpenSOAPSerializerRegistDefaults() OpenSOAP default serializers/deserializers regist. :Parameters nothing. :Return Value :int error code. =end */ extern int OPENSOAP_API OpenSOAPSerializerRegistDefaults(void) { int ret = OPENSOAP_NO_ERROR; OpenSOAPSerializerRegistInfoPtr i = SerializerRegisterInfos; for (;OPENSOAP_SUCCEEDED(ret) && i->soapTypename; ++i) { ret = OpenSOAPSerializerRegisterWC(i->soapTypename, i->serializer, i->deserializer); } return ret; } /* --- function#OpenSOAPSerializerRegisterUltimate() OpenSOAP serializerTable release function. :Parameters nothing. :Return Value :int error code. */ extern int /* OPENSOAP_API */ OpenSOAPSerializerRegisterUltimate(void) { int ret = OpenSOAPStringHashApplyToValues(serializerTable, deleteSerializerPair, NULL); if (OPENSOAP_SUCCEEDED(ret)) { ret = OpenSOAPStringHashRelease(serializerTable); if (OPENSOAP_SUCCEEDED(ret)) { serializerTable = NULL; } } return ret; }
24.93522
88
0.592781
2f46dd7f1023aa9ce100dc54653e322794165dce
2,606
c
C
rxc/src/logic.c
fabianishere/sas
84c15d77988fac5a173f766d866d90666b529bc1
[ "MIT" ]
3
2020-05-02T20:53:57.000Z
2020-11-11T11:32:23.000Z
rxc/src/logic.c
fabianishere/sas
84c15d77988fac5a173f766d866d90666b529bc1
[ "MIT" ]
null
null
null
rxc/src/logic.c
fabianishere/sas
84c15d77988fac5a173f766d866d90666b529bc1
[ "MIT" ]
null
null
null
#include <stdlib.h> #include <limits.h> #include <rxc/rxc.h> #include <rxc/logic.h> /* Inlet */ void rxc_inlet_pull(struct rxc_inlet *in, long n) { in->pull(in, n); } void rxc_inlet_cancel(struct rxc_inlet *in) { in->cancel(in); } /* Connection */ static void rxc_connection_inlet_pull(struct rxc_inlet *self, long n) { struct rxc_connection *conn = (void *) self; /* Check whether the connection is still open */ if (conn->requested == LONG_MIN) { return; } conn->requested += n; /* Cap the requested amount at the maximum size of a long */ if (conn->requested < 0) { conn->requested = LONG_MAX; } conn->source_logic->on_pull(conn->source_logic, n); } static void rxc_connection_inlet_cancel(struct rxc_inlet *self) { struct rxc_connection *conn = (void *) self; /* Check if it is already closed */ if (conn->requested == LONG_MIN) { return; } conn->requested = LONG_MIN; conn->source_logic->on_downstream_finish(conn->source_logic); return; } void rxc_connection_create(struct rxc_source_logic *source, struct rxc_sink_logic *sink) { struct rxc_connection *conn = malloc(sizeof(struct rxc_connection)); conn->in.pull = rxc_connection_inlet_pull; conn->in.cancel = rxc_connection_inlet_cancel; conn->requested = 0; conn->source_logic = source; conn->sink_logic = sink; source->out = (void *) conn; sink->in = (void *) conn; } int rxc_outlet_available(struct rxc_outlet *out) { return out->conn.requested > 0; } int rxc_outlet_emit(struct rxc_outlet *out, void *element) { struct rxc_connection *conn = &out->conn; /* Check whether the connection is still open */ if (conn->requested <= 0) { return -1; } /* LONG_MAX means unbounded */ if (conn->requested != LONG_MAX) { conn->requested--; } conn->sink_logic->on_push(conn->sink_logic, element); return RXC_EOK; } void rxc_outlet_fail(struct rxc_outlet *out, void *failure) { struct rxc_connection *conn = &out->conn; /* Check if it is already closed */ if (conn->requested == LONG_MIN) { return; } conn->requested = LONG_MIN; conn->sink_logic->on_upstream_failure(conn->sink_logic, failure); } void rxc_outlet_complete(struct rxc_outlet *out) { struct rxc_connection *conn = &out->conn; /* Check if it is already closed */ if (conn->requested == LONG_MIN) { return; } conn->requested = LONG_MIN; conn->sink_logic->on_upstream_finish(conn->sink_logic); }
22.465517
72
0.64812
92375a91d708db2f8e557c6223de8659d7cc4ffe
1,159
c
C
util/hash.c
enriquesomolinos/REDR
bb0712748a658d00b0bb9672d78a61f367e53fde
[ "CC0-1.0", "CC-BY-4.0" ]
69
2016-11-28T21:54:32.000Z
2022-03-24T00:09:16.000Z
util/hash.c
enriquesomolinos/REDR
bb0712748a658d00b0bb9672d78a61f367e53fde
[ "CC0-1.0", "CC-BY-4.0" ]
25
2016-11-17T15:48:24.000Z
2021-12-11T12:17:19.000Z
util/hash.c
enriquesomolinos/REDR
bb0712748a658d00b0bb9672d78a61f367e53fde
[ "CC0-1.0", "CC-BY-4.0" ]
9
2019-07-15T17:15:20.000Z
2020-11-21T15:57:17.000Z
#include <stdio.h> #include <stdlib.h> #include "hash.h" #include <malloc.h> #include <string.h> hash_t *hash_new (int size) { hash_t *h = malloc(sizeof (hash_t)); // h->keys = malloc(size* sizeof (void *)); // h->values = malloc(size* sizeof (void *)); if (h != NULL) { h->size = size; h->filled = 0; } return h; } int hash_index (hash_t *h, char *key) { int i;// = (int) hash(key) % h->size; char *orig =""; char * dest=""; dest =malloc(strlen(key)); if (dest != NULL) { strcpy(dest, key); } for(i=0;i<h->filled;i++){ orig = malloc(strlen(h->keys[i])); if (orig != NULL) { strcpy(orig, h->keys[i]); } if(strcmp(_strupr(orig),_strupr(dest))==0){ return i; } } /* while (h->keys[i] && h->keys[i] != key) i = (i + 1) % h->size;*/ return -1; } void hash_insert (hash_t *h, char *key, void *value) { //int i = hash_index(h, key); h->keys[h->filled] = key; h->values[h->filled] = value; h->filled = h->filled +1; } void *hash_lookup (hash_t *h, char *key) { signed int i = hash_index(h, key); if(i==-1) return NULL; h->filled = h->filled +1; return h->values[i]; }
20.333333
54
0.548749
f3d4e4fca9ef7f16c2560866239248688c19c5df
1,495
h
C
src/ppl/common/lock_utils.h
jimurk/ppl.common
2e75bfd76165449216004f3ceb34fad99d764dcd
[ "Apache-2.0" ]
20
2021-06-30T13:41:04.000Z
2022-02-16T13:19:28.000Z
src/ppl/common/lock_utils.h
jimurk/ppl.common
2e75bfd76165449216004f3ceb34fad99d764dcd
[ "Apache-2.0" ]
1
2021-07-11T05:00:10.000Z
2021-07-21T09:06:30.000Z
src/ppl/common/lock_utils.h
jimurk/ppl.common
2e75bfd76165449216004f3ceb34fad99d764dcd
[ "Apache-2.0" ]
14
2021-06-30T14:24:31.000Z
2022-03-16T07:58:43.000Z
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you 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. #ifndef _ST_HPC_PPL_COMMON_LOCK_UTILS_H_ #define _ST_HPC_PPL_COMMON_LOCK_UTILS_H_ namespace ppl { namespace common { class DummyLock final { public: void ReadLock() {} void WriteLock() {} void Unlock() {} }; template <typename T> class ReadLockGuard final { public: ReadLockGuard(T* lock) : lock_(lock) { lock->ReadLock(); } ~ReadLockGuard() { lock_->Unlock(); } private: T* lock_; }; template <typename T> class WriteLockGuard final { public: WriteLockGuard(T* lock) : lock_(lock) { lock->WriteLock(); } ~WriteLockGuard() { lock_->Unlock(); } private: T* lock_; }; }} // namespace ppl::common #endif
24.508197
63
0.696321
f3e666d01e8aca38c1fbbf327303d622d37c3c74
2,746
h
C
ios/Framework/Libs/WBCloudReflectionFaceVerify.framework/Versions/Current/Headers/WBFaceVerifySDKConfig.h
Ucoon/wb_cloud_face
1922f4451d5a73517a59b922f1c45f409cded113
[ "Apache-2.0" ]
2
2022-01-29T10:27:52.000Z
2022-02-08T07:54:41.000Z
ios/Framework/Libs/WBCloudReflectionFaceVerify.framework/Versions/Current/Headers/WBFaceVerifySDKConfig.h
Ucoon/wb_cloud_face
1922f4451d5a73517a59b922f1c45f409cded113
[ "Apache-2.0" ]
null
null
null
ios/Framework/Libs/WBCloudReflectionFaceVerify.framework/Versions/Current/Headers/WBFaceVerifySDKConfig.h
Ucoon/wb_cloud_face
1922f4451d5a73517a59b922f1c45f409cded113
[ "Apache-2.0" ]
1
2021-12-26T06:11:18.000Z
2021-12-26T06:11:18.000Z
// // WBFaceVerifySDKConfig.h // Pods // // Created by pp on 2017/8/2. // // #import <Foundation/Foundation.h> #import "WBFaceVerifyConst.h" NS_ASSUME_NONNULL_BEGIN /** 人脸识别SDK 基础配置类 */ @interface WBFaceVerifySDKConfig : NSObject /* 是否使用非标模式(具体含义请咨询技术支持) !!!使用原WBCloudFaceVerifySimpleSDK切过来的,务必打开此项 默认为NO */ @property (nonatomic, assign) BOOL useSimpleMode; #pragma mark - common /** sdk中拉起人脸活体识别界面中使用UIWindow时的windowLevel配置,默认配置是1 + UIWindowLevelNormal 如果接入放app中有其他自定义UIWindow, 为了防止界面覆盖,可以酌情设置该参数 */ @property (nonatomic, assign) NSUInteger windowLevel; /** 人脸识别服务结果页是否展示配置项 - 是否展示人脸对比成功界面 -> 建议关闭 default: NO */ @property (nonatomic, assign) BOOL showSuccessPage; /** 人脸识别服务结果页是否展示配置项 - 是否展示人脸对比失败界面 -> 建议关闭 default: NO */ @property (nonatomic, assign) BOOL showFailurePage; /** 人脸识别服务是否进行通过录像, 从而进行视频存证 default: NO */ @property (nonatomic, assign) BOOL recordVideo; /** 是否由SDK内部处理sdk网络请求的cookie 默认值: YES */ @property (nonatomic, assign) BOOL manualCookie; /** 人脸识别页面中的主题风格, 需要配合不同资源包使用: WBFaceVerifyThemeDarkness - 暗灰主题 WBFaceVerifyThemeLightness - 明亮主题 */ @property (nonatomic, assign) WBFaceVerifyTheme theme; /** 是否静音 默认值:YES */ @property (nonatomic, assign) BOOL mute; /** 刷脸服务走iPv6协议栈 默认:YES */ @property (nonatomic, assign) BOOL isIpv6; /* 送入自定义提示文案的位置 默认:WBFaceCustomTipsLoc_Bottom */ @property (nonatomic, assign) WBFaceCustomTipsLoc tipsLoc; /* 检测过程中展示的文案 默认为空 */ @property (nonatomic, copy) NSString *customTipsInDetect; /* 上传过程中展示的文案 默认为空 */ @property (nonatomic, copy) NSString *customTipsInUpload; /* 底部提示文案,长度不超过70字 */ @property (nonatomic, copy) NSString *bottomCustomTips; /* 退出二次确认UI配置 */ @property (nonatomic, copy) NSString *exitAlertTitle; //标题 @property (nonatomic, copy) NSString *exitAlertMessage; //内容 @property (nonatomic, copy) NSString *exitAlertRight; //右边按钮 @property (nonatomic, copy) NSString *exitAlertLeft; //左边按钮 /* 如果有使用苹果分屏模式(UIWindowScene),打开此开关 Xcode11新建工程有使用Scene,可以参考资料自行调整 默认为NO */ @property (nonatomic, assign) BOOL useWindowSecene; /** 资源路径,不包含bundle本身(仅当需要自己下发资源时配置,本地资源无需配置) !!!重要:此目录下必须包含face-tracker-v001.bundle和WBCloudReflectionFaceVerify.bundle两个文件,否则无法拉起SDK */ @property (nonatomic, copy) NSString *bundlePath; /** 是否采用增强比对服务,仅增强接口生效,仅活体服务设置为NO 默认为 NO */ @property (nonatomic, assign) BOOL useAdvanceCompare; #pragma mark - simple //非标特有字段,标准模式无需设置 /** 是否返回录制的视频 default: NO */ @property (nonatomic, assign) BOOL returnVideo; /** 返回视频加密的公钥,如果不配置则不加密 需要recordVideo returnVideo同时为YES,才返回加密的视频内容 */ @property (nonatomic, copy) NSString *publicKey; /** AES加密需要用到的IV */ @property (nonatomic, copy) NSString *aesIV; #pragma mark - /** 默认sdk配置 */ +(instancetype)sdkConfig; @end NS_ASSUME_NONNULL_END
17.379747
88
0.745812
fad40ea990e01a233b92b612756f469b2d5fb946
275
h
C
thirdparty/simpleuv/simpleuv/parametrize.h
MelvinG24/dust3d
c4936fd900a9a48220ebb811dfeaea0effbae3ee
[ "MIT" ]
2,392
2016-12-17T14:14:12.000Z
2022-03-30T19:40:40.000Z
thirdparty/simpleuv/simpleuv/parametrize.h
MelvinG24/dust3d
c4936fd900a9a48220ebb811dfeaea0effbae3ee
[ "MIT" ]
106
2018-04-19T17:47:31.000Z
2022-03-01T19:44:11.000Z
thirdparty/simpleuv/simpleuv/parametrize.h
MelvinG24/dust3d
c4936fd900a9a48220ebb811dfeaea0effbae3ee
[ "MIT" ]
184
2017-11-15T09:55:37.000Z
2022-02-21T16:30:46.000Z
#ifndef SIMPLEUV_PARAMETRIZE_H #define SIMPLEUV_PARAMETRIZE_H #include <simpleuv/meshdatatype.h> namespace simpleuv { bool parametrize(const std::vector<Vertex> &verticies, const std::vector<Face> &faces, std::vector<TextureCoord> &vertexUvs); } #endif
18.333333
55
0.738182
063f1694fceda036617340311cb06f41c2203bdb
5,042
h
C
Sources/TensorFlowAPI/include/TensorFlowAPI.h
PerfectlySoft/Perfect-TensorFlow
dbbbedcfc541fd7dbda63c3350941ad1d2ba728c
[ "Apache-2.0" ]
172
2017-06-08T21:17:05.000Z
2022-01-07T01:18:52.000Z
Sources/TensorFlowAPI/include/TensorFlowAPI.h
PerfectlySoft/Perfect-TensorFlow
dbbbedcfc541fd7dbda63c3350941ad1d2ba728c
[ "Apache-2.0" ]
3
2017-10-15T12:12:43.000Z
2021-12-19T20:18:57.000Z
Sources/TensorFlowAPI/include/TensorFlowAPI.h
PerfectlySoft/Perfect-TensorFlow
dbbbedcfc541fd7dbda63c3350941ad1d2ba728c
[ "Apache-2.0" ]
17
2017-06-13T16:10:01.000Z
2020-01-08T06:25:12.000Z
// // TensorFlowAPI.h // Perfect-TensorFlow // // Created by Rockford Wei on 2017-05-18. // Copyright © 2017 PerfectlySoft. All rights reserved. // //===----------------------------------------------------------------------===// // // This source file is part of the Perfect.org open source project // // Copyright (c) 2017 - 2018 PerfectlySoft Inc. and the Perfect project authors // Licensed under Apache License v2.0 // // See http://perfect.org/licensing.html for license information // //===----------------------------------------------------------------------===// // #ifndef __TENSOR_FLOW_STRUCT__ #define __TENSOR_FLOW_STRUCT__ #include <stddef.h> #include <stdint.h> // -------------------------------------------------------------------------- // TF_Buffer holds a pointer to a block of data and its associated length. // Typically, the data consists of a serialized protocol buffer, but other data // may also be held in a buffer. // // By default, TF_Buffer itself does not do any memory management of the // pointed-to block. If need be, users of this struct should specify how to // deallocate the block by setting the `data_deallocator` function pointer. typedef struct TF_Buffer { const void* data; size_t length; void (*data_deallocator)(void* data, size_t length); } TF_Buffer; // -------------------------------------------------------------------------- // The new graph construction API, still under development. // Represents a computation graph. Graphs may be shared between sessions. // Graphs are thread-safe when used as directed below. typedef struct TF_Graph TF_Graph; // Operation being built. The underlying graph must outlive this. typedef struct TF_OperationDescription TF_OperationDescription; // Operation that has been added to the graph. Valid until the graph is // deleted -- in particular adding a new operation to the graph does not // invalidate old TF_Operation* pointers. typedef struct TF_Operation TF_Operation; // Represents a specific input of an operation. typedef struct TF_Input { TF_Operation* oper; int index; // The index of the input within oper. } TF_Input; // Represents a specific output of an operation. typedef struct TF_Output { TF_Operation* oper; int index; // The index of the output within oper. } TF_Output; // TF_AttrMetadata describes the value of an attribute on an operation. typedef struct TF_AttrMetadata { // A boolean: 1 if the attribute value is a list, 0 otherwise. unsigned char is_list; // Length of the list if is_list is true. Undefined otherwise. int64_t list_size; // Type of elements of the list if is_list != 0. // Type of the single value stored in the attribute if is_list == 0. int type; // Total size the attribute value. // The units of total_size depend on is_list and type. // (1) If type == TF_ATTR_STRING and is_list == 0 // then total_size is the byte size of the string // valued attribute. // (2) If type == TF_ATTR_STRING and is_list == 1 // then total_size is the cumulative byte size // of all the strings in the list. // (3) If type == TF_ATTR_SHAPE and is_list == 0 // then total_size is the number of dimensions // of the shape valued attribute, or -1 // if its rank is unknown. // (4) If type == TF_ATTR_SHAPE and is_list == 1 // then total_size is the cumulative number // of dimensions of all shapes in the list. // (5) Otherwise, total_size is undefined. int64_t total_size; } TF_AttrMetadata; // TF_ImportGraphDefOptions holds options that can be passed to // TF_GraphImportGraphDef. typedef struct TF_ImportGraphDefOptions TF_ImportGraphDefOptions; typedef struct TF_WhileParams { // The number of inputs to the while loop, i.e. the number of loop variables. // This is the size of cond_inputs, body_inputs, and body_outputs. const int ninputs; // The while condition graph. The inputs are the current values of the loop // variables. The output should be a scalar boolean. TF_Graph* const cond_graph; const TF_Output* const cond_inputs; TF_Output cond_output; // The loop body graph. The inputs are the current values of the loop // variables. The outputs are the updated values of the loop variables. TF_Graph* const body_graph; const TF_Output* const body_inputs; TF_Output* const body_outputs; // Unique null-terminated name for this while loop. This is used as a prefix // for created operations. const char* name; } TF_WhileParams; // -------------------------------------------------------------------------- // API for driving Graph execution. typedef struct TF_Session TF_Session; typedef struct TF_DeviceList TF_DeviceList; // Load plugins containing custom ops and kernels // TF_Library holds information about dynamically loaded TensorFlow plugins. typedef struct TF_Library TF_Library; extern TF_Operation * TF_NextGraphOperation(TF_Graph * graph, size_t * pos); extern int TF_LoadPatchLibrary(const char * path); extern void TF_ClosePatchLibrary(void); #endif
36.273381
80
0.686037
945961f59aaae45b49de034134a845fb469b05cb
24,316
c
C
dovecot-2.2.33.2/src/pop3/pop3-commands.c
NicoleRobin/dovecot
f971413537673e781c00808bc039fde5749fcc95
[ "MIT" ]
null
null
null
dovecot-2.2.33.2/src/pop3/pop3-commands.c
NicoleRobin/dovecot
f971413537673e781c00808bc039fde5749fcc95
[ "MIT" ]
null
null
null
dovecot-2.2.33.2/src/pop3/pop3-commands.c
NicoleRobin/dovecot
f971413537673e781c00808bc039fde5749fcc95
[ "MIT" ]
null
null
null
/* Copyright (c) 2002-2017 Dovecot authors, see the included COPYING file */ #include "pop3-common.h" #include "array.h" #include "istream.h" #include "ostream.h" #include "hash.h" #include "str.h" #include "var-expand.h" #include "message-size.h" #include "mail-storage.h" #include "mail-storage-settings.h" #include "mail-search-build.h" #include "pop3-capability.h" #include "pop3-commands.h" static enum mail_sort_type pop3_sort_program[] = { MAIL_SORT_POP3_ORDER, MAIL_SORT_END }; static uint32_t msgnum_to_seq(struct client *client, uint32_t msgnum) { return msgnum < client->msgnum_to_seq_map_count ? client->msgnum_to_seq_map[msgnum] : msgnum+1; } static const char *get_msgnum(struct client *client, const char *args, unsigned int *msgnum, bool thenspace) { unsigned int num; if (*args < '0' || *args > '9') { client_send_line(client, "-ERR Invalid message number: %s", args); return NULL; } if (str_parse_uint(args, &num, &args) < 0) { client_send_line(client, "-ERR Message number too large: %s", args); return NULL; } if (*args != (thenspace ? ' ' : '\0')) { client_send_line(client, "-ERR Noise after message number: %s", args); return NULL; } if (num == 0 || num > client->messages_count) { client_send_line(client, "-ERR There's no message %u.", num); return NULL; } num--; if (client->deleted) { if (client->deleted_bitmask[num / CHAR_BIT] & (1 << (num % CHAR_BIT))) { client_send_line(client, "-ERR Message is deleted."); return NULL; } } while (*args == ' ') args++; *msgnum = num; return args; } static const char *get_size(struct client *client, const char *args, uoff_t *size, bool thenspace) { uoff_t num; if (*args < '0' || *args > '9') { client_send_line(client, "-ERR Invalid size: %s", args); return NULL; } if (str_parse_uoff(args, &num, &args) < 0) { client_send_line(client, "-ERR Size too large: %s", args); return NULL; } if (*args != (thenspace ? ' ' : '\0')) { client_send_line(client, "-ERR Noise after size: %s", args); return NULL; } while (*args == ' ') args++; *size = num; return args; } static int cmd_capa(struct client *client, const char *args ATTR_UNUSED) { client_send_line(client, "+OK\r\n"POP3_CAPABILITY_REPLY"."); return 1; } static int cmd_dele(struct client *client, const char *args) { unsigned int msgnum; if (get_msgnum(client, args, &msgnum, FALSE) == NULL) return -1; if (!client->deleted) { client->deleted_bitmask = i_malloc(MSGS_BITMASK_SIZE(client)); client->deleted = TRUE; } client->deleted_bitmask[msgnum / CHAR_BIT] |= 1 << (msgnum % CHAR_BIT); client->deleted_count++; client->deleted_size += client->message_sizes[msgnum]; client_send_line(client, "+OK Marked to be deleted."); return 1; } struct cmd_list_context { unsigned int msgnum; }; static void cmd_list_callback(struct client *client) { struct cmd_list_context *ctx = client->cmd_context; for (; ctx->msgnum != client->messages_count; ctx->msgnum++) { if (client->output->closed) break; if (POP3_CLIENT_OUTPUT_FULL(client)) { /* buffer full */ return; } if (client->deleted) { if (client->deleted_bitmask[ctx->msgnum / CHAR_BIT] & (1 << (ctx->msgnum % CHAR_BIT))) continue; } client_send_line(client, "%u %"PRIuUOFF_T, ctx->msgnum+1, client->message_sizes[ctx->msgnum]); } client_send_line(client, "."); i_free(ctx); client->cmd = NULL; } static int cmd_list(struct client *client, const char *args) { struct cmd_list_context *ctx; if (*args == '\0') { ctx = i_new(struct cmd_list_context, 1); client_send_line(client, "+OK %u messages:", client->messages_count - client->deleted_count); client->cmd = cmd_list_callback; client->cmd_context = ctx; cmd_list_callback(client); } else { unsigned int msgnum; if (get_msgnum(client, args, &msgnum, FALSE) == NULL) return -1; client_send_line(client, "+OK %u %"PRIuUOFF_T, msgnum+1, client->message_sizes[msgnum]); } return 1; } static int cmd_last(struct client *client, const char *args ATTR_UNUSED) { client_send_line(client, "+OK %u", client->last_seen_pop3_msn); return 1; } static int cmd_noop(struct client *client, const char *args ATTR_UNUSED) { client_send_line(client, "+OK"); return 1; } static struct mail_search_args * pop3_search_build(struct client *client, uint32_t seq) { struct mail_search_args *search_args; struct mail_search_arg *sarg; search_args = mail_search_build_init(); if (seq == 0) { sarg = mail_search_build_add(search_args, SEARCH_SEQSET); sarg->value.seqset = client->all_seqs; } else { mail_search_build_add_seqset(search_args, seq, seq); } return search_args; } static int client_verify_ordering(struct client *client, struct mail *mail, uint32_t msgnum) { uint32_t seq; seq = msgnum_to_seq(client, msgnum); if (seq != mail->seq) { i_error("Message ordering changed unexpectedly " "(msg #%u: storage seq %u -> %u)", msgnum+1, seq, mail->seq); return -1; } return 0; } static void client_expunge(struct client *client, struct mail *mail) { switch (client->set->parsed_delete_type) { case POP3_DELETE_TYPE_EXPUNGE: mail_expunge(mail); break; case POP3_DELETE_TYPE_FLAG: i_assert(client->deleted_kw != NULL); mail_update_keywords(mail, MODIFY_ADD, client->deleted_kw); break; } } bool client_update_mails(struct client *client) { struct mail_search_args *search_args; struct mail_search_context *ctx; struct mail *mail; ARRAY_TYPE(seq_range) deleted_msgs, seen_msgs; uint32_t msgnum, bit; bool ret = TRUE; if (mailbox_is_readonly(client->mailbox)) { /* silently ignore */ return TRUE; } /* translate msgnums to sequences (in case POP3 ordering is different) */ t_array_init(&deleted_msgs, 8); if (client->deleted_bitmask != NULL) { for (msgnum = 0; msgnum < client->messages_count; msgnum++) { bit = 1 << (msgnum % CHAR_BIT); if ((client->deleted_bitmask[msgnum / CHAR_BIT] & bit) != 0) seq_range_array_add(&deleted_msgs, msgnum_to_seq(client, msgnum)); } } t_array_init(&seen_msgs, 8); if (client->seen_bitmask != NULL) { for (msgnum = 0; msgnum < client->messages_count; msgnum++) { bit = 1 << (msgnum % CHAR_BIT); if ((client->seen_bitmask[msgnum / CHAR_BIT] & bit) != 0) seq_range_array_add(&seen_msgs, msgnum_to_seq(client, msgnum)); } } search_args = pop3_search_build(client, 0); ctx = mailbox_search_init(client->trans, search_args, NULL, 0, NULL); mail_search_args_unref(&search_args); while (mailbox_search_next(ctx, &mail)) { if (seq_range_exists(&deleted_msgs, mail->seq)) client_expunge(client, mail); else if (seq_range_exists(&seen_msgs, mail->seq)) mail_update_flags(mail, MODIFY_ADD, MAIL_SEEN); } client->seen_change_count = 0; if (mailbox_search_deinit(&ctx) < 0) ret = FALSE; return ret; } static int cmd_quit(struct client *client, const char *args ATTR_UNUSED) { if (client->deleted || client->seen_bitmask != NULL) { if (!client_update_mails(client)) { client_send_storage_error(client); client_disconnect(client, "Storage error during logout."); return 1; } } if (mailbox_transaction_commit(&client->trans) < 0 || mailbox_sync(client->mailbox, MAILBOX_SYNC_FLAG_FULL_WRITE) < 0) { client_send_storage_error(client); client_disconnect(client, "Storage error during logout."); return 1; } else { client->delete_success = TRUE; } if (!client->deleted) client_send_line(client, "+OK Logging out."); else client_send_line(client, "+OK Logging out, messages deleted."); client_disconnect(client, "Logged out"); return 1; } struct fetch_context { struct mail *mail; struct istream *stream; uoff_t body_lines; uoff_t *byte_counter; uoff_t byte_counter_offset; unsigned char last; bool cr_skipped, in_body; }; static void fetch_deinit(struct fetch_context *ctx) { mail_free(&ctx->mail); i_free(ctx); } static void fetch_callback(struct client *client) { struct fetch_context *ctx = client->cmd_context; const unsigned char *data; unsigned char add; size_t i, size; int ret; while ((ctx->body_lines > 0 || !ctx->in_body) && i_stream_read_data(ctx->stream, &data, &size, 0) > 0) { if (size > 4096) size = 4096; add = '\0'; for (i = 0; i < size; i++) { if ((data[i] == '\r' || data[i] == '\n') && !ctx->in_body) { if (i == 0 && (ctx->last == '\0' || ctx->last == '\n')) ctx->in_body = TRUE; else if (i > 0 && data[i-1] == '\n') ctx->in_body = TRUE; } if (data[i] == '\n') { if ((i == 0 && ctx->last != '\r') || (i > 0 && data[i-1] != '\r')) { /* missing CR */ add = '\r'; break; } if (ctx->in_body) { if (--ctx->body_lines == 0) { i++; break; } } } else if (data[i] == '.' && ((i == 0 && ctx->last == '\n') || (i > 0 && data[i-1] == '\n'))) { /* escape the dot */ add = '.'; break; } else if (data[i] == '\0' && (client->set->parsed_workarounds & WORKAROUND_OUTLOOK_NO_NULS) != 0) { add = 0x80; break; } } if (i > 0) { if (o_stream_send(client->output, data, i) < 0) break; ctx->last = data[i-1]; i_stream_skip(ctx->stream, i); } if (o_stream_get_buffer_used_size(client->output) >= 4096) { if ((ret = o_stream_flush(client->output)) < 0) break; if (ret == 0) { /* continue later */ return; } } if (add != '\0') { if (o_stream_send(client->output, &add, 1) < 0) break; ctx->last = add; if (add == 0x80) i_stream_skip(ctx->stream, 1); } } if (ctx->last != '\n') { /* didn't end with CRLF */ o_stream_nsend(client->output, "\r\n", 2); } if (!ctx->in_body && (client->set->parsed_workarounds & WORKAROUND_OE_NS_EOH) != 0) { /* Add the missing end of headers line. */ o_stream_nsend(client->output, "\r\n", 2); } *ctx->byte_counter += client->output->offset - ctx->byte_counter_offset; client_send_line(client, "."); fetch_deinit(ctx); client->cmd = NULL; } static int client_reply_msg_expunged(struct client *client, unsigned int msgnum) { client_send_line(client, "-ERR Message %u expunged.", msgnum + 1); if (msgnum <= client->highest_expunged_fetch_msgnum) { /* client tried to fetch an expunged message again. treat this as error so we'll eventually disconnect the client instead of letting it loop forever. */ return -1; } client->highest_expunged_fetch_msgnum = msgnum; return 1; } static int fetch(struct client *client, unsigned int msgnum, uoff_t body_lines, const char *reason, uoff_t *byte_counter) { struct fetch_context *ctx; int ret; ctx = i_new(struct fetch_context, 1); ctx->byte_counter = byte_counter; ctx->byte_counter_offset = client->output->offset; ctx->mail = mail_alloc(client->trans, MAIL_FETCH_STREAM_HEADER | MAIL_FETCH_STREAM_BODY, NULL); mail_set_seq(ctx->mail, msgnum_to_seq(client, msgnum)); if (mail_get_stream_because(ctx->mail, NULL, NULL, reason, &ctx->stream) < 0) { ret = client_reply_msg_expunged(client, msgnum); fetch_deinit(ctx); return ret; } if (body_lines == (uoff_t)-1 && client->seen_bitmask != NULL) { if ((mail_get_flags(ctx->mail) & MAIL_SEEN) == 0) { /* mark the message seen with RETR command */ client->seen_bitmask[msgnum / CHAR_BIT] |= 1 << (msgnum % CHAR_BIT); client->seen_change_count++; } } ctx->body_lines = body_lines; if (body_lines == (uoff_t)-1) { client_send_line(client, "+OK %"PRIuUOFF_T" octets", client->message_sizes[msgnum]); } else { client_send_line(client, "+OK"); ctx->body_lines++; /* internally we count the empty line too */ } client->cmd = fetch_callback; client->cmd_context = ctx; fetch_callback(client); return 1; } static int cmd_retr(struct client *client, const char *args) { unsigned int msgnum; if (get_msgnum(client, args, &msgnum, FALSE) == NULL) return -1; if (client->lowest_retr_pop3_msn > msgnum+1 || client->lowest_retr_pop3_msn == 0) client->lowest_retr_pop3_msn = msgnum+1; if (client->last_seen_pop3_msn < msgnum+1) client->last_seen_pop3_msn = msgnum+1; client->retr_count++; return fetch(client, msgnum, (uoff_t)-1, "RETR", &client->retr_bytes); } static int cmd_rset(struct client *client, const char *args ATTR_UNUSED) { struct mail_search_context *search_ctx; struct mail *mail; struct mail_search_args *search_args; client->last_seen_pop3_msn = 0; if (client->deleted) { client->deleted = FALSE; memset(client->deleted_bitmask, 0, MSGS_BITMASK_SIZE(client)); client->deleted_count = 0; client->deleted_size = 0; } if (client->seen_change_count > 0) { memset(client->seen_bitmask, 0, MSGS_BITMASK_SIZE(client)); client->seen_change_count = 0; } if (client->set->pop3_enable_last) { /* remove all \Seen flags (as specified by RFC 1460) */ search_args = pop3_search_build(client, 0); search_ctx = mailbox_search_init(client->trans, search_args, NULL, 0, NULL); mail_search_args_unref(&search_args); while (mailbox_search_next(search_ctx, &mail)) mail_update_flags(mail, MODIFY_REMOVE, MAIL_SEEN); (void)mailbox_search_deinit(&search_ctx); (void)mailbox_transaction_commit(&client->trans); client->trans = mailbox_transaction_begin(client->mailbox, 0); } client_send_line(client, "+OK"); return 1; } static int cmd_stat(struct client *client, const char *args ATTR_UNUSED) { client_send_line(client, "+OK %u %"PRIuUOFF_T, client->messages_count - client->deleted_count, client->total_size - client->deleted_size); return 1; } static int cmd_top(struct client *client, const char *args) { unsigned int msgnum; uoff_t max_lines; args = get_msgnum(client, args, &msgnum, TRUE); if (args == NULL) return -1; if (get_size(client, args, &max_lines, FALSE) == NULL) return -1; client->top_count++; return fetch(client, msgnum, max_lines, "TOP", &client->top_bytes); } struct cmd_uidl_context { struct mail_search_context *search_ctx; struct mail *mail; uint32_t msgnum; bool list_all; }; static int pop3_get_uid(struct client *client, struct mail *mail, string_t *str, bool *permanent_uidl_r) { static struct var_expand_table static_tab[] = { { 'v', NULL, "uidvalidity" }, { 'u', NULL, "uid" }, { 'm', NULL, "md5" }, { 'f', NULL, "filename" }, { 'g', NULL, "guid" }, { '\0', NULL, NULL } }; struct var_expand_table *tab; char uid_str[MAX_INT_STRLEN]; const char *uidl; if (mail_get_special(mail, MAIL_FETCH_UIDL_BACKEND, &uidl) == 0 && *uidl != '\0') { str_append(str, uidl); /* UIDL is already permanent */ *permanent_uidl_r = TRUE; return 0; } *permanent_uidl_r = FALSE; if (client->set->pop3_reuse_xuidl && mail_get_first_header(mail, "X-UIDL", &uidl) > 0) { str_append(str, uidl); return 0; } tab = t_malloc(sizeof(static_tab)); memcpy(tab, static_tab, sizeof(static_tab)); tab[0].value = t_strdup_printf("%u", client->uid_validity); if ((client->uidl_keymask & UIDL_UID) != 0) { if (i_snprintf(uid_str, sizeof(uid_str), "%u", mail->uid) < 0) i_unreached(); tab[1].value = uid_str; } if ((client->uidl_keymask & UIDL_MD5) != 0) { if (mail_get_special(mail, MAIL_FETCH_HEADER_MD5, &tab[2].value) < 0) { i_error("UIDL: Header MD5 lookup failed: %s", mailbox_get_last_internal_error(mail->box, NULL)); return -1; } else if (*tab[2].value == '\0') { i_error("UIDL: Header MD5 not found " "(pop3_uidl_format=%%m not supported by storage?)"); return -1; } } if ((client->uidl_keymask & UIDL_FILE_NAME) != 0) { if (mail_get_special(mail, MAIL_FETCH_STORAGE_ID, &tab[3].value) < 0) { i_error("UIDL: File name lookup failed: %s", mailbox_get_last_internal_error(mail->box, NULL)); return -1; } else if (*tab[3].value == '\0') { i_error("UIDL: File name not found " "(pop3_uidl_format=%%f not supported by storage?)"); return -1; } } if ((client->uidl_keymask & UIDL_GUID) != 0) { if (mail_get_special(mail, MAIL_FETCH_GUID, &tab[4].value) < 0) { i_error("UIDL: Message GUID lookup failed: %s", mailbox_get_last_internal_error(mail->box, NULL)); return -1; } else if (*tab[4].value == '\0') { i_error("UIDL: Message GUID not found " "(pop3_uidl_format=%%g not supported by storage?)"); return -1; } } var_expand(str, client->mail_set->pop3_uidl_format, tab); return 0; } static bool list_uidls_saved_iter(struct client *client, struct cmd_uidl_context *ctx) { bool found = FALSE; while (ctx->msgnum < client->messages_count) { uint32_t msgnum = ctx->msgnum++; if (client->deleted) { if (client->deleted_bitmask[msgnum / CHAR_BIT] & (1 << (msgnum % CHAR_BIT))) continue; } found = TRUE; client_send_line(client, ctx->list_all ? "%u %s" : "+OK %u %s", msgnum+1, client->message_uidls[msgnum]); if (client->output->closed || !ctx->list_all) break; if (POP3_CLIENT_OUTPUT_FULL(client)) { /* output is being buffered, continue when there's more space */ return FALSE; } } /* finished */ client->cmd = NULL; if (ctx->list_all) client_send_line(client, "."); i_free(ctx); return found; } static bool list_uids_iter(struct client *client, struct cmd_uidl_context *ctx) { string_t *str; bool permanent_uidl, found = FALSE; bool failed = FALSE; if (client->message_uidls != NULL) return list_uidls_saved_iter(client, ctx); str = t_str_new(128); while (mailbox_search_next(ctx->search_ctx, &ctx->mail)) { uint32_t msgnum = ctx->msgnum++; if (client_verify_ordering(client, ctx->mail, msgnum) < 0) { failed = TRUE; break; } if (client->deleted) { if (client->deleted_bitmask[msgnum / CHAR_BIT] & (1 << (msgnum % CHAR_BIT))) continue; } found = TRUE; str_truncate(str, 0); if (pop3_get_uid(client, ctx->mail, str, &permanent_uidl) < 0) { failed = TRUE; break; } if (client->set->pop3_save_uidl && !permanent_uidl) mail_update_pop3_uidl(ctx->mail, str_c(str)); client_send_line(client, ctx->list_all ? "%u %s" : "+OK %u %s", msgnum+1, str_c(str)); if (client->output->closed) break; if (POP3_CLIENT_OUTPUT_FULL(client) && ctx->list_all) { /* output is being buffered, continue when there's more space */ return FALSE; } } /* finished */ (void)mailbox_search_deinit(&ctx->search_ctx); client->cmd = NULL; if (ctx->list_all && !failed) client_send_line(client, "."); i_free(ctx); if (failed) client_disconnect(client, "POP3 UIDLs couldn't be listed"); return found || failed; } static void cmd_uidl_callback(struct client *client) { struct cmd_uidl_context *ctx = client->cmd_context; (void)list_uids_iter(client, ctx); } HASH_TABLE_DEFINE_TYPE(uidl_counter, char *, void *); static void uidl_rename_duplicate(string_t *uidl, HASH_TABLE_TYPE(uidl_counter) prev_uidls) { char *key; void *value; unsigned int counter; while (hash_table_lookup_full(prev_uidls, str_c(uidl), &key, &value)) { /* duplicate. the value contains the number of duplicates. */ counter = POINTER_CAST_TO(value, unsigned int) + 1; hash_table_update(prev_uidls, key, POINTER_CAST(counter)); str_printfa(uidl, "-%u", counter); /* the second lookup really should return NULL, but just in case of some weird UIDLs do this as many times as needed */ } } static void client_uidls_save(struct client *client) { struct mail_search_context *search_ctx; struct mail_search_args *search_args; struct mail *mail; HASH_TABLE_TYPE(uidl_counter) prev_uidls; const char **seq_uidls; string_t *str; char *uidl; enum mail_fetch_field wanted_fields; uint32_t msgnum; bool permanent_uidl, uidl_duplicates_rename, failed = FALSE; i_assert(client->message_uidls == NULL); search_args = pop3_search_build(client, 0); wanted_fields = 0; if ((client->uidl_keymask & UIDL_MD5) != 0) wanted_fields |= MAIL_FETCH_HEADER_MD5; search_ctx = mailbox_search_init(client->trans, search_args, NULL, wanted_fields, NULL); mail_search_args_unref(&search_args); uidl_duplicates_rename = strcmp(client->set->pop3_uidl_duplicates, "rename") == 0; if (uidl_duplicates_rename) hash_table_create(&prev_uidls, default_pool, 0, str_hash, strcmp); client->uidl_pool = pool_alloconly_create("message uidls", 1024); /* first read all the UIDLs into a temporary [seq] array */ seq_uidls = i_new(const char *, client->highest_seq); str = t_str_new(128); while (mailbox_search_next(search_ctx, &mail)) { str_truncate(str, 0); if (pop3_get_uid(client, mail, str, &permanent_uidl) < 0) { failed = TRUE; break; } if (uidl_duplicates_rename) uidl_rename_duplicate(str, prev_uidls); uidl = p_strdup(client->uidl_pool, str_c(str)); if (client->set->pop3_save_uidl && !permanent_uidl) mail_update_pop3_uidl(mail, uidl); i_assert(mail->seq <= client->highest_seq); seq_uidls[mail->seq-1] = uidl; if (uidl_duplicates_rename) hash_table_insert(prev_uidls, uidl, POINTER_CAST(1)); } (void)mailbox_search_deinit(&search_ctx); if (uidl_duplicates_rename) hash_table_destroy(&prev_uidls); if (failed) { pool_unref(&client->uidl_pool); i_free(seq_uidls); return; } /* map UIDLs to msgnums (in case POP3 sort ordering is different) */ client->message_uidls = p_new(client->uidl_pool, const char *, MALLOC_ADD(client->messages_count, 1)); for (msgnum = 0; msgnum < client->messages_count; msgnum++) { client->message_uidls[msgnum] = seq_uidls[msgnum_to_seq(client, msgnum) - 1]; } i_free(seq_uidls); } static struct cmd_uidl_context * cmd_uidl_init(struct client *client, uint32_t seq) { struct cmd_uidl_context *ctx; struct mail_search_args *search_args; enum mail_fetch_field wanted_fields; if (client->message_uidls_save && client->message_uidls == NULL && client->messages_count > 0) client_uidls_save(client); ctx = i_new(struct cmd_uidl_context, 1); ctx->list_all = seq == 0; if (client->message_uidls == NULL) { wanted_fields = 0; if ((client->uidl_keymask & UIDL_MD5) != 0) wanted_fields |= MAIL_FETCH_HEADER_MD5; search_args = pop3_search_build(client, seq); ctx->search_ctx = mailbox_search_init(client->trans, search_args, pop3_sort_program, wanted_fields, NULL); mail_search_args_unref(&search_args); } if (seq == 0) { client->cmd = cmd_uidl_callback; client->cmd_context = ctx; } return ctx; } static int cmd_uidl(struct client *client, const char *args) { struct cmd_uidl_context *ctx; uint32_t seq; if (*args == '\0') { client_send_line(client, "+OK"); ctx = cmd_uidl_init(client, 0); (void)list_uids_iter(client, ctx); } else { unsigned int msgnum; if (get_msgnum(client, args, &msgnum, FALSE) == NULL) return -1; seq = msgnum_to_seq(client, msgnum); ctx = cmd_uidl_init(client, seq); ctx->msgnum = msgnum; if (!list_uids_iter(client, ctx)) return client_reply_msg_expunged(client, msgnum); } return 1; } int client_command_execute(struct client *client, const char *name, const char *args) { /* keep the command uppercased */ name = t_str_ucase(name); while (*args == ' ') args++; switch (*name) { case 'C': if (strcmp(name, "CAPA") == 0) return cmd_capa(client, args); break; case 'D': if (strcmp(name, "DELE") == 0) return cmd_dele(client, args); break; case 'L': if (strcmp(name, "LIST") == 0) return cmd_list(client, args); if (strcmp(name, "LAST") == 0 && client->set->pop3_enable_last) return cmd_last(client, args); break; case 'N': if (strcmp(name, "NOOP") == 0) return cmd_noop(client, args); break; case 'Q': if (strcmp(name, "QUIT") == 0) return cmd_quit(client, args); break; case 'R': if (strcmp(name, "RETR") == 0) return cmd_retr(client, args); if (strcmp(name, "RSET") == 0) return cmd_rset(client, args); break; case 'S': if (strcmp(name, "STAT") == 0) return cmd_stat(client, args); break; case 'T': if (strcmp(name, "TOP") == 0) return cmd_top(client, args); break; case 'U': if (strcmp(name, "UIDL") == 0) return cmd_uidl(client, args); break; } client_send_line(client, "-ERR Unknown command: %s", name); return -1; }
25.595789
80
0.671245
9e8edafd4ba97dd8cac3002c525deaa081be889a
1,476
h
C
include/cloudstorageapi/auth/credentials.h
awkv/cloudstorageapi
3c1e47f0a3bf8ceaed66f272c17ef949bac4e424
[ "Apache-2.0" ]
null
null
null
include/cloudstorageapi/auth/credentials.h
awkv/cloudstorageapi
3c1e47f0a3bf8ceaed66f272c17ef949bac4e424
[ "Apache-2.0" ]
null
null
null
include/cloudstorageapi/auth/credentials.h
awkv/cloudstorageapi
3c1e47f0a3bf8ceaed66f272c17ef949bac4e424
[ "Apache-2.0" ]
null
null
null
// Copyright 2019 Andrew Karasyov // // Copyright 2018 Google LLC // // 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. #pragma once #include "cloudstorageapi/status.h" #include "cloudstorageapi/status_or_val.h" namespace csa { namespace auth { /** * Common interface for OAuth 2.0 and password-based credentials used to access cloud services. */ class Credentials { public: virtual ~Credentials() = default; /** * Attempts to obtain a value for the Authorization HTTP header. * * If unable to obtain a value for the Authorization header, which could * happen for `Credentials` that need to be periodically refreshed, the * underyling `Status` will indicate failure details from the refresh HTTP * request. Otherwise, the returned value will contain the Authorization * header to be used in HTTP requests. */ virtual StatusOrVal<std::string> AuthorizationHeader() = 0; }; } // namespace auth } // namespace csa
32.086957
95
0.726287
9a7da8356ff0095f66ad90c49b3544e6fec7c4bb
5,458
c
C
feed_device.c
fboucher9/feed
baa6add5f901a02dd0754c1cbc984089a20a8007
[ "MIT" ]
null
null
null
feed_device.c
fboucher9/feed
baa6add5f901a02dd0754c1cbc984089a20a8007
[ "MIT" ]
null
null
null
feed_device.c
fboucher9/feed
baa6add5f901a02dd0754c1cbc984089a20a8007
[ "MIT" ]
null
null
null
/* See LICENSE for license details */ /* Module: feed_device.c Description: Dispatch of feed_device_intf to selected implementation. Default implementation is feed_device_std or else user may decide to hook the implementation via application callbacks. The feed_device_null module is used for when feed_device is destroyed. */ #include "feed_os.h" #include "feed_cfg.h" #include "feed_device.h" #include "feed.h" /* Function: feed_device_null_enter Description: Stub for feed_device_enter. */ static int feed_device_null_enter( void * const p_context) { (void)( p_context); return -1; } /* feed_device_null_enter() */ /* Function: feed_device_null_leave Description: Stub for feed_device_leave. */ static int feed_device_null_leave( void * const p_context) { (void)( p_context); return -1; } /* feed_device_null_leave() */ /* Function: feed_device_null_query Description: Stub for feed_device_query. */ static int feed_device_null_query( void * const p_context, unsigned short int * const p_columns, unsigned short int * const p_rows) { (void)( p_context); (void)( p_columns); (void)( p_rows); return -1; } /* feed_device_null_query() */ /* Function: feed_device_null_read Description: Stub for feed_device_read. */ static signed long int feed_device_null_read( void * const p_context, unsigned char * const p_buf, unsigned long int const i_buf_len) { (void)( p_context); (void)( p_buf); (void)( i_buf_len); return -1; } /* feed_device_null_read() */ /* Function: feed_device_null_write Description: Stub for feed_device_write. */ static signed long int feed_device_null_write( void * const p_context, unsigned char const * const p_buf, unsigned long int const i_buf_len) { (void)( p_context); (void)( p_buf); (void)( i_buf_len); return -1; } /* feed_device_null_write() */ /* Interface of feed_device_null module */ static struct feed_device_intf const g_feed_device_null_intf = { &( feed_device_null_enter), &( feed_device_null_leave), &( feed_device_null_query), &( feed_device_null_read), &( feed_device_null_write) }; /* Context of feed_device_null module */ static unsigned char g_feed_device_null_context[1u] = { (unsigned char)( 0u) }; /* Function: feed_device_init Description: Initialize feed_device module to reference the selected feed_device_intf callbacks and callback context. */ char feed_device_init( struct feed_device * const p_device, struct feed_device_intf const * const p_device_intf, void * const p_context) { char b_result; p_device->p_device_intf = p_device_intf; p_device->p_context = p_context; b_result = 1; return b_result; } /* feed_device_init() */ /* Function: feed_device_cleanup Description: Undo initialization of feed_device_init() function. */ void feed_device_cleanup( struct feed_device * const p_device) { p_device->p_device_intf = &( g_feed_device_null_intf); p_device->p_context = (void *)( g_feed_device_null_context); } /* feed_device_cleanup() */ /* Function: feed_device_enter Description: Dispatch to selected implementation. */ int feed_device_enter( struct feed_device * const p_device) { return (*(p_device->p_device_intf->p_enter))( p_device->p_context); } /* feed_device_enter() */ /* Function: feed_device_leave Description: Dispatch to selected implementation. */ int feed_device_leave( struct feed_device * const p_device) { return (*(p_device->p_device_intf->p_leave))( p_device->p_context); } /* feed_device_leave() */ /* Function: feed_device_query Description: Dispatch to selected implementation. */ int feed_device_query( struct feed_device * const p_device, unsigned short int * const p_columns, unsigned short int * const p_rows) { return (*(p_device->p_device_intf->p_query))( p_device->p_context, p_columns, p_rows); } /* feed_device_query() */ /* Function: feed_device_read Description: Dispatch to selected implementation. */ signed long int feed_device_read( struct feed_device * const p_device, unsigned char * const p_buf, unsigned long int const i_buf_len) { return (*(p_device->p_device_intf->p_read))( p_device->p_context, p_buf, i_buf_len); } /* feed_device_read() */ /* Function: feed_device_write Description: Dispatch to selected implementation. */ signed long int feed_device_write( struct feed_device * const p_device, unsigned char const * const p_buf, unsigned long int const i_buf_len) { return (*(p_device->p_device_intf->p_write))( p_device->p_context, p_buf, i_buf_len); } /* feed_device_write() */ /* end-of-file: feed_device.c */
14.831522
76
0.626053
d2f71eef9698e72c3d29f415607a6739dae5e32e
1,978
c
C
ADC/scheduler/task.c
afatom/core-program
7886acf67f6b81bd06edef41f6ddab83cc993927
[ "MIT" ]
null
null
null
ADC/scheduler/task.c
afatom/core-program
7886acf67f6b81bd06edef41f6ddab83cc993927
[ "MIT" ]
null
null
null
ADC/scheduler/task.c
afatom/core-program
7886acf67f6b81bd06edef41f6ddab83cc993927
[ "MIT" ]
null
null
null
#include "task.h" #include <stdlib.h> /*malloc*/ /******************************************************************************/ struct Task { size_t m_periodTime; size_t m_dueTime; TaskFunction m_userFunction; void* m_functionContext; }; /******************************************************************************/ #define FALSE 0 #define TRUE 1 /* int DueTimeCompare(const Task *_firstTask, const Task *_secondTask); */ /******************************************************************************/ Task* TaskCreate(size_t _period,TaskFunction _userFunction, void* _context) { Task* task = NULL; task=(Task*)malloc(sizeof(Task)); if(NULL == task) { return NULL; } task->m_periodTime=_period; task->m_dueTime = _period; task->m_userFunction = _userFunction; task->m_functionContext = _context; return task; } /******************************************************************************/ void TaskDestroy(void* _task) { if(NULL == _task) { return; } free(_task); return; } /******************************************************************************/ TaskTerminator GetTaskTerminatorPointer(void) { return TaskDestroy; } /******************************************************************************/ /*task execution cpu end time - when misiion finish its job*/ void TaskUpdateDueTime(Task* _task, size_t _newDueTime) { _task->m_dueTime = _newDueTime; return; } /******************************************************************************/ size_t TaskGetDueTime(Task* _task) { return _task->m_dueTime; } /******************************************************************************/ size_t TaskGetPeriodTime(Task* _task) { return _task->m_periodTime; } /******************************************************************************/ int TaskExecution(Task* _task) { return _task->m_userFunction(_task->m_functionContext); } /******************************************************************************/
23
80
0.429221
307e938c80f49ec08ba345dc477828fe27c80217
1,954
h
C
x86_driver/TalkUSB/StdAfx.h
goodspeed24e/Programming
ae73fad022396ea03105aad83293facaeea561ae
[ "MIT" ]
1
2021-03-12T19:29:33.000Z
2021-03-12T19:29:33.000Z
x86_driver/TalkUSB/StdAfx.h
goodspeed24e/Programming
ae73fad022396ea03105aad83293facaeea561ae
[ "MIT" ]
1
2019-03-13T01:36:12.000Z
2019-03-13T01:36:12.000Z
x86_driver/TalkUSB/StdAfx.h
goodspeed24e/Programming
ae73fad022396ea03105aad83293facaeea561ae
[ "MIT" ]
null
null
null
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #if !defined(AFX_STDAFX_H__E53D928B_04C4_4749_A724_19A94710D6CE__INCLUDED_) #define AFX_STDAFX_H__E53D928B_04C4_4749_A724_19A94710D6CE__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. #define WINVER 0x0501 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. #endif #ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. #define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. #endif //#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. //#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. //#endif #ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. #define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. #endif #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit #include <afxwin.h> // MFC core and standard components #include <afxext.h> // MFC extensions #include <afxdisp.h> // MFC Automation classes #include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls #ifndef _AFX_NO_AFXCMN_SUPPORT #include <afxcmn.h> // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT #include <afxsock.h> // MFC socket extensions //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_STDAFX_H__E53D928B_04C4_4749_A724_19A94710D6CE__INCLUDED_)
41.574468
116
0.772774
308b9ab093b22851849d704f3c82defcf5b52dd2
13,466
h
C
aws-cpp-sdk-iot/include/aws/iot/model/StartDetectMitigationActionsTaskRequest.h
Eliyahu-Machluf/aws-sdk-cpp
97b8d6cdc16df298b80941b94327a5026efa7f8c
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-iot/include/aws/iot/model/StartDetectMitigationActionsTaskRequest.h
Eliyahu-Machluf/aws-sdk-cpp
97b8d6cdc16df298b80941b94327a5026efa7f8c
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-iot/include/aws/iot/model/StartDetectMitigationActionsTaskRequest.h
Eliyahu-Machluf/aws-sdk-cpp
97b8d6cdc16df298b80941b94327a5026efa7f8c
[ "Apache-2.0" ]
1
2022-03-23T15:17:18.000Z
2022-03-23T15:17:18.000Z
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/iot/IoT_EXPORTS.h> #include <aws/iot/IoTRequest.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/iot/model/DetectMitigationActionsTaskTarget.h> #include <aws/core/utils/memory/stl/AWSVector.h> #include <aws/iot/model/ViolationEventOccurrenceRange.h> #include <utility> #include <aws/core/utils/UUID.h> namespace Aws { namespace IoT { namespace Model { /** */ class AWS_IOT_API StartDetectMitigationActionsTaskRequest : public IoTRequest { public: StartDetectMitigationActionsTaskRequest(); // Service request name is the Operation name which will send this request out, // each operation should has unique request name, so that we can get operation's name from this request. // Note: this is not true for response, multiple operations may have the same response name, // so we can not get operation's name from response. inline virtual const char* GetServiceRequestName() const override { return "StartDetectMitigationActionsTask"; } Aws::String SerializePayload() const override; /** * <p> The unique identifier of the task. </p> */ inline const Aws::String& GetTaskId() const{ return m_taskId; } /** * <p> The unique identifier of the task. </p> */ inline bool TaskIdHasBeenSet() const { return m_taskIdHasBeenSet; } /** * <p> The unique identifier of the task. </p> */ inline void SetTaskId(const Aws::String& value) { m_taskIdHasBeenSet = true; m_taskId = value; } /** * <p> The unique identifier of the task. </p> */ inline void SetTaskId(Aws::String&& value) { m_taskIdHasBeenSet = true; m_taskId = std::move(value); } /** * <p> The unique identifier of the task. </p> */ inline void SetTaskId(const char* value) { m_taskIdHasBeenSet = true; m_taskId.assign(value); } /** * <p> The unique identifier of the task. </p> */ inline StartDetectMitigationActionsTaskRequest& WithTaskId(const Aws::String& value) { SetTaskId(value); return *this;} /** * <p> The unique identifier of the task. </p> */ inline StartDetectMitigationActionsTaskRequest& WithTaskId(Aws::String&& value) { SetTaskId(std::move(value)); return *this;} /** * <p> The unique identifier of the task. </p> */ inline StartDetectMitigationActionsTaskRequest& WithTaskId(const char* value) { SetTaskId(value); return *this;} /** * <p> Specifies the ML Detect findings to which the mitigation actions are * applied. </p> */ inline const DetectMitigationActionsTaskTarget& GetTarget() const{ return m_target; } /** * <p> Specifies the ML Detect findings to which the mitigation actions are * applied. </p> */ inline bool TargetHasBeenSet() const { return m_targetHasBeenSet; } /** * <p> Specifies the ML Detect findings to which the mitigation actions are * applied. </p> */ inline void SetTarget(const DetectMitigationActionsTaskTarget& value) { m_targetHasBeenSet = true; m_target = value; } /** * <p> Specifies the ML Detect findings to which the mitigation actions are * applied. </p> */ inline void SetTarget(DetectMitigationActionsTaskTarget&& value) { m_targetHasBeenSet = true; m_target = std::move(value); } /** * <p> Specifies the ML Detect findings to which the mitigation actions are * applied. </p> */ inline StartDetectMitigationActionsTaskRequest& WithTarget(const DetectMitigationActionsTaskTarget& value) { SetTarget(value); return *this;} /** * <p> Specifies the ML Detect findings to which the mitigation actions are * applied. </p> */ inline StartDetectMitigationActionsTaskRequest& WithTarget(DetectMitigationActionsTaskTarget&& value) { SetTarget(std::move(value)); return *this;} /** * <p> The actions to be performed when a device has unexpected behavior. </p> */ inline const Aws::Vector<Aws::String>& GetActions() const{ return m_actions; } /** * <p> The actions to be performed when a device has unexpected behavior. </p> */ inline bool ActionsHasBeenSet() const { return m_actionsHasBeenSet; } /** * <p> The actions to be performed when a device has unexpected behavior. </p> */ inline void SetActions(const Aws::Vector<Aws::String>& value) { m_actionsHasBeenSet = true; m_actions = value; } /** * <p> The actions to be performed when a device has unexpected behavior. </p> */ inline void SetActions(Aws::Vector<Aws::String>&& value) { m_actionsHasBeenSet = true; m_actions = std::move(value); } /** * <p> The actions to be performed when a device has unexpected behavior. </p> */ inline StartDetectMitigationActionsTaskRequest& WithActions(const Aws::Vector<Aws::String>& value) { SetActions(value); return *this;} /** * <p> The actions to be performed when a device has unexpected behavior. </p> */ inline StartDetectMitigationActionsTaskRequest& WithActions(Aws::Vector<Aws::String>&& value) { SetActions(std::move(value)); return *this;} /** * <p> The actions to be performed when a device has unexpected behavior. </p> */ inline StartDetectMitigationActionsTaskRequest& AddActions(const Aws::String& value) { m_actionsHasBeenSet = true; m_actions.push_back(value); return *this; } /** * <p> The actions to be performed when a device has unexpected behavior. </p> */ inline StartDetectMitigationActionsTaskRequest& AddActions(Aws::String&& value) { m_actionsHasBeenSet = true; m_actions.push_back(std::move(value)); return *this; } /** * <p> The actions to be performed when a device has unexpected behavior. </p> */ inline StartDetectMitigationActionsTaskRequest& AddActions(const char* value) { m_actionsHasBeenSet = true; m_actions.push_back(value); return *this; } /** * <p> Specifies the time period of which violation events occurred between. </p> */ inline const ViolationEventOccurrenceRange& GetViolationEventOccurrenceRange() const{ return m_violationEventOccurrenceRange; } /** * <p> Specifies the time period of which violation events occurred between. </p> */ inline bool ViolationEventOccurrenceRangeHasBeenSet() const { return m_violationEventOccurrenceRangeHasBeenSet; } /** * <p> Specifies the time period of which violation events occurred between. </p> */ inline void SetViolationEventOccurrenceRange(const ViolationEventOccurrenceRange& value) { m_violationEventOccurrenceRangeHasBeenSet = true; m_violationEventOccurrenceRange = value; } /** * <p> Specifies the time period of which violation events occurred between. </p> */ inline void SetViolationEventOccurrenceRange(ViolationEventOccurrenceRange&& value) { m_violationEventOccurrenceRangeHasBeenSet = true; m_violationEventOccurrenceRange = std::move(value); } /** * <p> Specifies the time period of which violation events occurred between. </p> */ inline StartDetectMitigationActionsTaskRequest& WithViolationEventOccurrenceRange(const ViolationEventOccurrenceRange& value) { SetViolationEventOccurrenceRange(value); return *this;} /** * <p> Specifies the time period of which violation events occurred between. </p> */ inline StartDetectMitigationActionsTaskRequest& WithViolationEventOccurrenceRange(ViolationEventOccurrenceRange&& value) { SetViolationEventOccurrenceRange(std::move(value)); return *this;} /** * <p> Specifies to list only active violations. </p> */ inline bool GetIncludeOnlyActiveViolations() const{ return m_includeOnlyActiveViolations; } /** * <p> Specifies to list only active violations. </p> */ inline bool IncludeOnlyActiveViolationsHasBeenSet() const { return m_includeOnlyActiveViolationsHasBeenSet; } /** * <p> Specifies to list only active violations. </p> */ inline void SetIncludeOnlyActiveViolations(bool value) { m_includeOnlyActiveViolationsHasBeenSet = true; m_includeOnlyActiveViolations = value; } /** * <p> Specifies to list only active violations. </p> */ inline StartDetectMitigationActionsTaskRequest& WithIncludeOnlyActiveViolations(bool value) { SetIncludeOnlyActiveViolations(value); return *this;} /** * <p> Specifies to include suppressed alerts. </p> */ inline bool GetIncludeSuppressedAlerts() const{ return m_includeSuppressedAlerts; } /** * <p> Specifies to include suppressed alerts. </p> */ inline bool IncludeSuppressedAlertsHasBeenSet() const { return m_includeSuppressedAlertsHasBeenSet; } /** * <p> Specifies to include suppressed alerts. </p> */ inline void SetIncludeSuppressedAlerts(bool value) { m_includeSuppressedAlertsHasBeenSet = true; m_includeSuppressedAlerts = value; } /** * <p> Specifies to include suppressed alerts. </p> */ inline StartDetectMitigationActionsTaskRequest& WithIncludeSuppressedAlerts(bool value) { SetIncludeSuppressedAlerts(value); return *this;} /** * <p> Each mitigation action task must have a unique client request token. If you * try to create a new task with the same token as a task that already exists, an * exception occurs. If you omit this value, AWS SDKs will automatically generate a * unique client request. </p> */ inline const Aws::String& GetClientRequestToken() const{ return m_clientRequestToken; } /** * <p> Each mitigation action task must have a unique client request token. If you * try to create a new task with the same token as a task that already exists, an * exception occurs. If you omit this value, AWS SDKs will automatically generate a * unique client request. </p> */ inline bool ClientRequestTokenHasBeenSet() const { return m_clientRequestTokenHasBeenSet; } /** * <p> Each mitigation action task must have a unique client request token. If you * try to create a new task with the same token as a task that already exists, an * exception occurs. If you omit this value, AWS SDKs will automatically generate a * unique client request. </p> */ inline void SetClientRequestToken(const Aws::String& value) { m_clientRequestTokenHasBeenSet = true; m_clientRequestToken = value; } /** * <p> Each mitigation action task must have a unique client request token. If you * try to create a new task with the same token as a task that already exists, an * exception occurs. If you omit this value, AWS SDKs will automatically generate a * unique client request. </p> */ inline void SetClientRequestToken(Aws::String&& value) { m_clientRequestTokenHasBeenSet = true; m_clientRequestToken = std::move(value); } /** * <p> Each mitigation action task must have a unique client request token. If you * try to create a new task with the same token as a task that already exists, an * exception occurs. If you omit this value, AWS SDKs will automatically generate a * unique client request. </p> */ inline void SetClientRequestToken(const char* value) { m_clientRequestTokenHasBeenSet = true; m_clientRequestToken.assign(value); } /** * <p> Each mitigation action task must have a unique client request token. If you * try to create a new task with the same token as a task that already exists, an * exception occurs. If you omit this value, AWS SDKs will automatically generate a * unique client request. </p> */ inline StartDetectMitigationActionsTaskRequest& WithClientRequestToken(const Aws::String& value) { SetClientRequestToken(value); return *this;} /** * <p> Each mitigation action task must have a unique client request token. If you * try to create a new task with the same token as a task that already exists, an * exception occurs. If you omit this value, AWS SDKs will automatically generate a * unique client request. </p> */ inline StartDetectMitigationActionsTaskRequest& WithClientRequestToken(Aws::String&& value) { SetClientRequestToken(std::move(value)); return *this;} /** * <p> Each mitigation action task must have a unique client request token. If you * try to create a new task with the same token as a task that already exists, an * exception occurs. If you omit this value, AWS SDKs will automatically generate a * unique client request. </p> */ inline StartDetectMitigationActionsTaskRequest& WithClientRequestToken(const char* value) { SetClientRequestToken(value); return *this;} private: Aws::String m_taskId; bool m_taskIdHasBeenSet; DetectMitigationActionsTaskTarget m_target; bool m_targetHasBeenSet; Aws::Vector<Aws::String> m_actions; bool m_actionsHasBeenSet; ViolationEventOccurrenceRange m_violationEventOccurrenceRange; bool m_violationEventOccurrenceRangeHasBeenSet; bool m_includeOnlyActiveViolations; bool m_includeOnlyActiveViolationsHasBeenSet; bool m_includeSuppressedAlerts; bool m_includeSuppressedAlertsHasBeenSet; Aws::String m_clientRequestToken; bool m_clientRequestTokenHasBeenSet; }; } // namespace Model } // namespace IoT } // namespace Aws
41.180428
193
0.707263
d054b4bf5a8966fe730d7bf310ff5bf31279f9c2
9,024
h
C
arch/arm/src/lpc2378/lpc23xx_i2c.h
kazz12211/NuttX
0349b6821779276fb82aa234b43b8e6d44fa3020
[ "MIT" ]
null
null
null
arch/arm/src/lpc2378/lpc23xx_i2c.h
kazz12211/NuttX
0349b6821779276fb82aa234b43b8e6d44fa3020
[ "MIT" ]
null
null
null
arch/arm/src/lpc2378/lpc23xx_i2c.h
kazz12211/NuttX
0349b6821779276fb82aa234b43b8e6d44fa3020
[ "MIT" ]
null
null
null
/************************************************************************************ * arch/arm/src/lpc2378/lpc23xx_i2c.h * * Copyright (C) 2013 Li Zhuoyi. All rights reserved. * Author: Li Zhuoyi <lzyy.cn@gmail.com> * * Derived arch/arm/src/lpc17xx_40xx/lpc17_40_i2c.h * * Copyright (C) 2010, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * 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 NuttX 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 OWNER 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 __ARCH_ARM_SRC_LPC2378_LPC23XX_I2C_H #define __ARCH_ARM_SRC_LPC2378_LPC23XX_I2C_H /************************************************************************************ * Included Files ************************************************************************************/ #include <nuttx/config.h> #include <nuttx/i2c/i2c_master.h> #include "chip.h" /************************************************************************************ * Pre-processor Definitions ************************************************************************************/ /* I2C Pin Configuration ************************************************************/ #define I2C0_PCLKSEL_MASK (0x03 << 14) #define I2C1_PCLKSEL_MASK (0x03 << 6) #define I2C2_PCLKSEL_MASK (0x03 << 20) #define I2C0_PCLKSEL (0x01 << 14) #define I2C1_PCLKSEL (0x01 << 6) #define I2C2_PCLKSEL (0x01 << 20) #define I2C0_PINSEL_MASK (0x0f << 22) /* P0.27 P0.28 PINSEL1 */ #define I2C1_PINSEL_MASK (0x0f) /* P0.0 P0.1 PINSEL0 */ #define I2C2_PINSEL_MASK (0x0f << 22) /* P0.10 P0.11 PINSEL0 */ #define I2C0_PINSEL (0x05 << 22) #define I2C1_PINSEL (0x0f) #define I2C2_PINSEL (0x0a << 22) /* I2C Register addresses ***********************************************************/ #define I2C0_CONSET (I2C0_BASE_ADDR+I2C_CONSET_OFFSET) #define I2C0_STAT (I2C0_BASE_ADDR+I2C_STAT_OFFSET) #define I2C0_DAT (I2C0_BASE_ADDR+I2C_DAT_OFFSET) #define I2C0_ADR0 (I2C0_BASE_ADDR+I2C_ADR0_OFFSET) #define I2C0_SCLH (I2C0_BASE_ADDR+I2C_SCLH_OFFSET) #define I2C0_SCLL (I2C0_BASE_ADDR+I2C_SCLL_OFFSET) #define I2C0_CONCLR (I2C0_BASE_ADDR+I2C_CONCLR_OFFSET) #define I2C1_CONSET (I2C1_BASE_ADDR+I2C_CONSET_OFFSET) #define I2C1_STAT (I2C1_BASE_ADDR+I2C_STAT_OFFSET) #define I2C1_DAT (I2C1_BASE_ADDR+I2C_DAT_OFFSET) #define I2C1_ADR0 (I2C1_BASE_ADDR+I2C_ADR0_OFFSET) #define I2C1_SCLH (I2C1_BASE_ADDR+I2C_SCLH_OFFSET) #define I2C1_SCLL (I2C1_BASE_ADDR+I2C_SCLL_OFFSET) #define I2C1_CONCLR (I2C1_BASE_ADDR+I2C_CONCLR_OFFSET) #define I2C2_CONSET (I2C2_BASE_ADDR+I2C_CONSET_OFFSET) #define I2C2_STAT (I2C2_BASE_ADDR+I2C_STAT_OFFSET) #define I2C2_DAT (I2C2_BASE_ADDR+I2C_DAT_OFFSET) #define I2C2_ADR0 (I2C2_BASE_ADDR+I2C_ADR0_OFFSET) #define I2C2_SCLH (I2C2_BASE_ADDR+I2C_SCLH_OFFSET) #define I2C2_SCLL (I2C2_BASE_ADDR+I2C_SCLL_OFFSET) #define I2C2_CONCLR (I2C2_BASE_ADDR+I2C_CONCLR_OFFSET) /* I2C Register bit definitions *****************************************************/ /* I2C Control Set Register */ /* Bits 0-1: Reserved */ #define I2C_CONSET_AA (1 << 2) /* Bit 2: Assert acknowledge flag */ #define I2C_CONSET_SI (1 << 3) /* Bit 3: I2C interrupt flag */ #define I2C_CONSET_STO (1 << 4) /* Bit 4: STOP flag */ #define I2C_CONSET_STA (1 << 5) /* Bit 5: START flag */ #define I2C_CONSET_I2EN (1 << 6) /* Bit 6: I2C interface enable */ /* Bits 7-31: Reserved */ /* I2C Control Clear Register */ /* Bits 0-1: Reserved */ #define I2C_CONCLR_AAC (1 << 2) /* Bit 2: Assert acknowledge Clear bit */ #define I2C_CONCLR_SIC (1 << 3) /* Bit 3: I2C interrupt Clear bit */ /* Bit 4: Reserved */ #define I2C_CONCLR_STAC (1 << 5) /* Bit 5: START flag Clear bit */ #define I2C_CONCLRT_I2ENC (1 << 6) /* Bit 6: I2C interface Disable bit */ /* Bits 7-31: Reserved */ /* I2C Status Register * * See tables 399-402 in the "LPC17xx User Manual" (UM10360), Rev. 01, 4 January * 2010, NXP for definitions of status codes. */ #define I2C_STAT_MASK (0xff) /* Bits 0-7: I2C interface status * Bits 0-1 always zero */ /* Bits 8-31: Reserved */ /* I2C Data Register */ #define I2C_DAT_MASK (0xff) /* Bits 0-7: I2C data */ /* Bits 8-31: Reserved */ #define I2C_ADR_GC (1 << 0) /* Bit 0: GC General Call enable bit */ #define I2C_ADR_ADDR_SHIFT (1) /* Bits 1-7: I2C slave address */ #define I2C_ADR_ADDR_MASK (0x7f << I2C_ADR_ADDR_SHIFT) /* Bits 8-31: Reserved */ /* I2C Slave address mask registers: * * I2C Slave address mask register 0 * I2C Slave address mask register 1 * I2C Slave address mask register 2 * I2C Slave address mask register 3 */ /* Bit 0: Reserved */ #define I2C_MASK_SHIFT (1) /* Bits 1-7: I2C mask bits */ #define I2C_MASK_MASK (0x7f << I2C_ADR_ADDR_SHIFT) /* Bits 8-31: Reserved */ /* SCH Duty Cycle Register High Half Word */ #define I2C_SCLH_MASK (0xffff) /* Bit 0-15: Count for SCL HIGH time period selection */ /* Bits 16-31: Reserved */ /* SCL Duty Cycle Register Low Half Word */ #define I2C_SCLL_MASK (0xffff) /* Bit 0-15: Count for SCL LOW time period selection */ /* Bits 16-31: Reserved */ /************************************************************************************ * Public Function Prototypes ************************************************************************************/ /************************************************************************************ * Name: lpc2378_i2cbus_initialize * * Description: * Initialize the selected I2C port. And return a unique instance of struct * struct i2c_master_s. This function may be called to obtain multiple * instances of the interface, each of which may be set up with a * different frequency and slave address. * * Input Parameters: * Port number (for hardware that has multiple I2C interfaces) * * Returned Value: * Valid I2C device structure reference on succcess; a NULL on failure * ************************************************************************************/ FAR struct i2c_master_s *lpc2378_i2cbus_initialize(int port); /************************************************************************************ * Name: lpc2378_i2cbus_uninitialize * * Description: * De-initialize the selected I2C port, and power down the device. * * Input Parameters: * Device structure as returned by the lpc2378_i2cbus_initialize() * * Returned Value: * OK on success, ERROR when internal reference count mismatch or dev * points to invalid hardware device. * ************************************************************************************/ int lpc2378_i2cbus_uninitialize(FAR struct i2c_master_s *dev); #endif /* __ARCH_ARM_SRC_LPC2378_LPC23XX_I2C_H */
46.515464
95
0.563165
a976c5fac72245277617681d64ee636c97c375e4
8,689
c
C
kernel/base/mem/common/memrecord/los_binarytree.c
github0null/LiteOSv5.0_CMake
4253ec53521be01016079c7d0e57d5dbf80c1903
[ "BSD-3-Clause" ]
4,335
2018-05-08T16:55:45.000Z
2022-03-31T03:52:42.000Z
kernel/base/mem/common/memrecord/los_binarytree.c
github0null/LiteOSv5.0_CMake
4253ec53521be01016079c7d0e57d5dbf80c1903
[ "BSD-3-Clause" ]
106
2018-05-16T11:30:54.000Z
2021-12-27T01:50:33.000Z
kernel/base/mem/common/memrecord/los_binarytree.c
github0null/LiteOSv5.0_CMake
4253ec53521be01016079c7d0e57d5dbf80c1903
[ "BSD-3-Clause" ]
1,387
2018-05-08T11:06:50.000Z
2022-03-26T16:03:05.000Z
/* ---------------------------------------------------------------------------- * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved. * Description: LiteOS BinTree Implementation * Author: Huawei LiteOS Team * Create: 2013-01-01 * 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. * --------------------------------------------------------------------------- */ #include "los_config.h" #ifdef LOSCFG_MEM_RECORDINFO #include "los_binarytree_pri.h" #include "los_typedef.h" #include "los_memory.h" #ifdef __cplusplus #if __cplusplus extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ UINT32 OsBinTreeInsert(const VOID *node, UINT32 nodeLen, BinNode **leaf, BinNode *(*GetMyBinNode)(UINT32 *nodeId), INT32 (*CompareNode)(const VOID *node1, const VOID *node2)) { UINT32 nodeId; INT32 result; BinNode **currentNode = leaf; if (leaf == NULL) { return OS_INVALID; } do { if (*currentNode != NULL) { result = CompareNode(node, (const VOID *)(*currentNode)); if (result == 0) { return (*currentNode)->nodeId; } else if (result < 0) { currentNode = (BinNode **)(&((*currentNode)->left)); } else { currentNode = (BinNode **)(&((*currentNode)->right)); } } else { (*currentNode) = GetMyBinNode(&nodeId); if (*currentNode == NULL) { return OS_INVALID; } (VOID)memcpy_s((*currentNode)->keyValue, (nodeLen - sizeof(BinNode)), ((BinNode *)node)->keyValue, (nodeLen - sizeof(BinNode))); (*currentNode)->nodeId = nodeId; /* initialize the children to NULL */ (*currentNode)->left = NULL; (*currentNode)->right = NULL; return (*currentNode)->nodeId; } } while (1); } /* LRNODE */ LinkRegNode g_linkRegNode[LR_COUNT]; UINT32 g_linkRegNodeIndex = 0; LinkRegNode *g_linkRegRoot = NULL; INT32 OsCompareLRNode(const VOID *node1, const VOID *node2) { LinkRegNode *linkRegNode1 = (LinkRegNode *)node1; LinkRegNode *linkRegNode2 = (LinkRegNode *)node2; if (linkRegNode1->linkReg1 < linkRegNode2->linkReg1) { return -1; } else if ((linkRegNode1->linkReg1 == linkRegNode2->linkReg1) && (linkRegNode1->linkReg2 < linkRegNode2->linkReg2)) { return -1; } else if ((linkRegNode1->linkReg1 == linkRegNode2->linkReg1) && (linkRegNode1->linkReg2 == linkRegNode2->linkReg2) && (linkRegNode1->linkReg3 < linkRegNode2->linkReg3)) { return -1; } else if ((linkRegNode1->linkReg1 == linkRegNode2->linkReg1) && (linkRegNode1->linkReg2 == linkRegNode2->linkReg2) && (linkRegNode1->linkReg3 == linkRegNode2->linkReg3)) { return 0; } else { return 1; } } BinNode *OsGetLRBinNode(UINT32 *nodeId) { if (g_linkRegNodeIndex < LR_COUNT) { *nodeId = g_linkRegNodeIndex; return (BinNode *)(&g_linkRegNode[g_linkRegNodeIndex++]); } else { *nodeId = (UINT32)-1; return NULL; } } /* ADDRNODE */ AddrNode g_addrNode[ADDR_COUNT]; UINT32 g_addrNodeIndex = 0; AddrNode *g_addrRoot = NULL; INT32 OsCompareAddrNode(const VOID *node1, const VOID *node2) { AddrNode *addrNode1 = (AddrNode *)node1; AddrNode *addrNode2 = (AddrNode *)node2; if (addrNode1->addr < addrNode2->addr) { return -1; } else if (addrNode1->addr == addrNode2->addr) { return 0; } else { return 1; } } BinNode *OsGetAddrBinNode(UINT32 *nodeId) { if (g_addrNodeIndex < ADDR_COUNT) { *nodeId = g_addrNodeIndex; return (BinNode *)(&g_addrNode[g_addrNodeIndex++]); } else { *nodeId = (UINT32)-1; return NULL; } } /* REQSIZENODE */ ReqSizeNode g_reqSizeNode[REQ_SIZE_COUNT]; UINT32 g_reqSizeNodeIndex = 0; ReqSizeNode *g_reqSizeRoot = NULL; INT32 OsCompareReqSizeNode(const VOID *node1, const VOID *node2) { ReqSizeNode *reqSizeNode1 = (ReqSizeNode *)node1; ReqSizeNode *reqSizeNode2 = (ReqSizeNode *)node2; if (reqSizeNode1->reqSize < reqSizeNode2->reqSize) { return -1; } else if (reqSizeNode1->reqSize == reqSizeNode2->reqSize) { return 0; } else { return 1; } } BinNode *OsGetReqSizeBinNode(UINT32 *nodeId) { if (g_reqSizeNodeIndex < REQ_SIZE_COUNT) { *nodeId = g_reqSizeNodeIndex; return (BinNode *)(&g_reqSizeNode[g_reqSizeNodeIndex++]); } else { *nodeId = (UINT32)-1; return NULL; } } /* TASKIDNODE */ STATIC TaskIDNode g_taskIdNode[TASK_ID_COUNT]; STATIC UINT32 g_taskIdNodeIndex = 0; STATIC TaskIDNode *g_taskIdRoot = NULL; INT32 OsCompareTaskIDNode(const VOID *node1, const VOID *node2) { TaskIDNode *taskIdNode1 = (TaskIDNode *)node1; TaskIDNode *taskIdNode2 = (TaskIDNode *)node2; if (taskIdNode1->taskId < taskIdNode2->taskId) { return -1; } else if (taskIdNode1->taskId == taskIdNode2->taskId) { return 0; } else { return 1; } } BinNode *OsGetTaskIDBinNode(UINT32 *nodeId) { if (g_taskIdNodeIndex < TASK_ID_COUNT) { *nodeId = g_taskIdNodeIndex; return (BinNode *)(&g_taskIdNode[g_taskIdNodeIndex++]); } else { *nodeId = (UINT32)-1; return NULL; } } #define BINARYTREE_TASKID_COUNT 11 #define BINARYTREE_REQSIZE_COUNT 4 STATIC const UINT32 g_binaryTreeTaskID[BINARYTREE_TASKID_COUNT] = { 33, 10, 20, 9, 42, 34, 45, 47, 46, 50, 49 }; STATIC const UINT32 g_binaryTreeReqSize[BINARYTREE_REQSIZE_COUNT] = { 616, 136, 1708, 1580 }; VOID OsBinaryTreeInit(VOID) { INT32 index; LinkRegNode linkRegNode; AddrNode node; TaskIDNode taskNode; ReqSizeNode reqNode; /* equal to the middle address of __text_start and __text_end */ linkRegNode.linkReg1 = (UINTPTR)(((&__text_end - &__text_start) / 2) + &__text_start); linkRegNode.linkReg2 = linkRegNode.linkReg1; linkRegNode.linkReg3 = linkRegNode.linkReg1; (VOID)OsBinTreeInsert(&linkRegNode, sizeof(LinkRegNode), (BinNode **)&g_linkRegRoot, OsGetLRBinNode, OsCompareLRNode); /* equal to the middle address of __bss_end and g_sys_mem_addr_end */ node.addr = ((g_sys_mem_addr_end - (UINTPTR)(&__bss_end)) / 2) + (UINTPTR)(&__bss_end); (VOID)OsBinTreeInsert(&node, sizeof(AddrNode), (BinNode **)&g_addrRoot, OsGetAddrBinNode, OsCompareAddrNode); for (index = 0; index < BINARYTREE_TASKID_COUNT; index++) { taskNode.taskId = g_binaryTreeTaskID[index]; (VOID)OsBinTreeInsert(&taskNode, sizeof(TaskIDNode), (BinNode **)&g_taskIdRoot, OsGetTaskIDBinNode, OsCompareTaskIDNode); } for (index = 0; index < BINARYTREE_REQSIZE_COUNT; index++) { reqNode.reqSize = g_binaryTreeReqSize[index]; (VOID)OsBinTreeInsert(&reqNode, sizeof(ReqSizeNode), (BinNode **)&g_reqSizeRoot, OsGetReqSizeBinNode, OsCompareReqSizeNode); } } #ifdef __cplusplus #if __cplusplus } #endif /* __cplusplus */ #endif /* __cplusplus */ #endif
35.178138
112
0.642652
b741b158aeec3b87ee1ac4ed00cfb59b31291533
265
c
C
programs/template/template_main.c
iTNTPiston/asis-plus
18c7621c09f9d3c5623e9aebf0513852bdd7e588
[ "MIT" ]
null
null
null
programs/template/template_main.c
iTNTPiston/asis-plus
18c7621c09f9d3c5623e9aebf0513852bdd7e588
[ "MIT" ]
null
null
null
programs/template/template_main.c
iTNTPiston/asis-plus
18c7621c09f9d3c5623e9aebf0513852bdd7e588
[ "MIT" ]
null
null
null
//Change to your header file #include <template_main.h> #include <asis+.h> #include <asis_display_adapter.h> //Change function name here to match header void template_main(uint32_t arg){ //Code here asis_click(BTN_A); da_print_u32l(0,0,arg); asis_delay_s(1); }
22.083333
43
0.754717
a2862ae98bfd49bcf6ce8da7c424ca5704d55ff3
684
h
C
raygame/Graph.h
jeremyjflowers/AIClassExample
36aeb0f05b3db3c81b65cb727e659ae8eaa202d2
[ "MIT" ]
null
null
null
raygame/Graph.h
jeremyjflowers/AIClassExample
36aeb0f05b3db3c81b65cb727e659ae8eaa202d2
[ "MIT" ]
null
null
null
raygame/Graph.h
jeremyjflowers/AIClassExample
36aeb0f05b3db3c81b65cb727e659ae8eaa202d2
[ "MIT" ]
null
null
null
#pragma once #include "Actor.h" #include <vector> #include <deque> class Node; class Graph : public Actor { public: Graph(int width, int height, int nodeSize, int nodeSpacing); void draw()override; void update(float deltaTime) override; Node* checkList(std::deque<Node*> list, Node* lookingFor); void BFS(int startX, int startY, int goalX, int goalY); void DSP(int startX, int startY, int goalX, int goalY); void aStar(int startX, int startY, int goalX, int goalY); void bubbleSort(std::deque<Node*> node); Node* getNode(int xPos, int yPos); private: void createGraph(int nodeSize, int nodeSpacing); private: int m_height; int m_width; std::vector<Node*> m_nodes; };
23.586207
61
0.726608
c82dd0078d03df66fdec6561a9a42f71d2e3d85f
5,356
c
C
Drivers/BSP/Components/spirit1/SPIRIT1_Library/Src/SPIRIT_DirectRF.c
SensiEDGE/SensiSUB
1d885b57b65704d116de8317beb86c479b9419e4
[ "Unlicense" ]
null
null
null
Drivers/BSP/Components/spirit1/SPIRIT1_Library/Src/SPIRIT_DirectRF.c
SensiEDGE/SensiSUB
1d885b57b65704d116de8317beb86c479b9419e4
[ "Unlicense" ]
null
null
null
Drivers/BSP/Components/spirit1/SPIRIT1_Library/Src/SPIRIT_DirectRF.c
SensiEDGE/SensiSUB
1d885b57b65704d116de8317beb86c479b9419e4
[ "Unlicense" ]
null
null
null
/** ****************************************************************************** * @file SPIRIT_DirectRF.c * @author VMA division - AMS * @version 3.2.3 * @date 21-October-2015 * @brief Configuration and management of SPIRIT direct transmission / receive modes. * @details * @attention * * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2> * * 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 STMicroelectronics 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. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "SPIRIT_DirectRF.h" #include "MCU_Interface.h" /** * @addtogroup SPIRIT_Libraries * @{ */ /** * @addtogroup SPIRIT_DirectRf * @{ */ /** * @defgroup DirectRf_Private_TypesDefinitions Direct RF Private Types Definitions * @{ */ /** *@} */ /** * @defgroup DirectRf_Private_Defines Direct RF Private Defines * @{ */ /** *@} */ /** * @defgroup DirectRf_Private_Macros Direct RF Private Macros * @{ */ /** *@} */ /** * @defgroup DirectRf_Private_Variables Direct RF Private Variables * @{ */ /** *@} */ /** * @defgroup DirectRf_Private_FunctionPrototypes Direct RF Private Function Prototypes * @{ */ /** *@} */ /** * @defgroup DirectRf_Private_Functions Direct RF Private Functions * @{ */ /** * @brief Sets the DirectRF RX mode of SPIRIT. * @param xDirectRx code of the desired mode. * This parameter can be any value of @ref DirectRx. * @retval None. */ void SpiritDirectRfSetRxMode(DirectRx xDirectRx) { uint8_t tempRegValue; /* Check the parameters */ s_assert_param(IS_DIRECT_RX(xDirectRx)); /* Reads the register value */ SpiritSpiReadRegisters(PCKTCTRL3_BASE, 1, &tempRegValue); /* Build the value to be stored */ tempRegValue &= ~PCKTCTRL3_RX_MODE_MASK; tempRegValue |= (uint8_t)xDirectRx; /* Writes value on register */ g_xStatus = SpiritSpiWriteRegisters(PCKTCTRL3_BASE, 1, &tempRegValue); } /** * @brief Returns the DirectRF RX mode of SPIRIT. * @param None. * @retval DirectRx Direct Rx mode. */ DirectRx SpiritDirectRfGetRxMode(void) { uint8_t tempRegValue; /* Reads the register value and mask the RX_Mode field */ g_xStatus = SpiritSpiReadRegisters(PCKTCTRL3_BASE, 1, &tempRegValue); /* Rebuild and return value */ return (DirectRx)(tempRegValue & 0x30); } /** * @brief Sets the TX mode of SPIRIT. * @param xDirectTx code of the desired source. * This parameter can be any value of @ref DirectTx. * @retval None. */ void SpiritDirectRfSetTxMode(DirectTx xDirectTx) { uint8_t tempRegValue; /* Check the parameters */ s_assert_param(IS_DIRECT_TX(xDirectTx)); /* Reads the register value */ SpiritSpiReadRegisters(PCKTCTRL1_BASE, 1, &tempRegValue); /* Build the value to be stored */ tempRegValue &= ~PCKTCTRL1_TX_SOURCE_MASK; tempRegValue |= (uint8_t)xDirectTx; /* Writes value on register */ g_xStatus = SpiritSpiWriteRegisters(PCKTCTRL1_BASE, 1, &tempRegValue); } /** * @brief Returns the DirectRF TX mode of SPIRIT. * @param None. * @retval DirectTx Direct Tx mode. */ DirectTx SpiritDirectRfGetTxMode(void) { uint8_t tempRegValue; /* Reads the register value and mask the RX_Mode field */ g_xStatus = SpiritSpiReadRegisters(PCKTCTRL1_BASE, 1, &tempRegValue); /* Returns value */ return (DirectTx)(tempRegValue & 0x0C); } /** *@} */ /** *@} */ /** *@} */ /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/
24.796296
94
0.628641
bde8b8b8720c797b7441bfbd12363c01fe7902d4
674
h
C
pyramid/pyramid.h
alirezaahmadi/Accelerated-Up-Down-Pyramid-Library
e91bfeb727c3b1a7e7e13e861b3975fa4088f286
[ "MIT" ]
1
2020-04-21T20:32:32.000Z
2020-04-21T20:32:32.000Z
pyramid/pyramid.h
alirezaahmadi/Accelerated-Up-Down-Pyramid-Library
e91bfeb727c3b1a7e7e13e861b3975fa4088f286
[ "MIT" ]
null
null
null
pyramid/pyramid.h
alirezaahmadi/Accelerated-Up-Down-Pyramid-Library
e91bfeb727c3b1a7e7e13e861b3975fa4088f286
[ "MIT" ]
null
null
null
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % by: Alireza Ahmadi % % University of Bonn- MSc Robotics & Geodetic Engineering% % Alireza.Ahmadi@uni-bonn.de % % AlirezaAhmadi.xyz % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ #pragma once #include <cuda.h> #include <cuda_runtime.h> #include "conv2D/conv2D.h" #include "utils.h" namespace DynaMap{ class pyramid : public conv2D , public virtual rgbdImage { public: ~pyramid(); void downPyramid(float *src, int scale); float* dstBlur; }; } // namespace DynaMap
24.962963
60
0.456973
0800bb8cd87f3b7ac5ece8ca9b6e15274f6c8150
8,195
h
C
src/MAX30105.h
opensensinglab/max30105
f62a95763ee3e7ef07828c1f7e841d0826113547
[ "Unlicense" ]
2
2020-05-21T03:45:08.000Z
2021-07-20T07:06:48.000Z
src/MAX30105.h
opensensinglab/max30105
f62a95763ee3e7ef07828c1f7e841d0826113547
[ "Unlicense" ]
1
2017-10-23T06:58:49.000Z
2021-07-21T02:24:48.000Z
src/MAX30105.h
opensensinglab/max30105
f62a95763ee3e7ef07828c1f7e841d0826113547
[ "Unlicense" ]
3
2016-09-23T03:49:25.000Z
2020-01-26T04:22:09.000Z
/*************************************************** This is a library written for the Maxim MAX30105 Optical Smoke Detector It should also work with the MAX30102. However, the MAX30102 does not have a Green LED. These sensors use I2C to communicate, as well as a single (optional) interrupt line that is not currently supported in this driver. Written by Peter Janen and Nathan Seidle (SparkFun) BSD license, all text above must be included in any redistribution. *****************************************************/ #if (ARDUINO >= 100) #include "Arduino.h" #else #include "WProgram.h" #endif #include <Wire.h> // // MAX30105 I2C Address (7-bit) // #define MAX30105_ADDRESS 0x57 //Note that MAX30102 has the same I2C address and Part ID #define I2C_SPEED_STANDARD 100000 #define I2C_SPEED_FAST 400000 // // MAX30105 I2C Register Addresses // // Status Registers #define MAX30105_INTSTAT1 0x00 #define MAX30105_INTSTAT2 0x01 #define MAX30105_INTENABLE1 0x02 #define MAX30105_INTENABLE2 0x03 // FIFO Registers #define MAX30105_FIFOWRITEPTR 0x04 #define MAX30105_FIFOOVERFLOW 0x05 #define MAX30105_FIFOREADPTR 0x06 #define MAX30105_FIFODATA 0x07 // Configuration Registers #define MAX30105_FIFOCONFIG 0x08 #define MAX30105_MODECONFIG 0x09 #define MAX30105_PARTICLECONFIG 0x0A // Note, sometimes listed as "SPO2" config in datasheet (pg. 11) #define MAX30105_LED1_PULSEAMP 0x0C #define MAX30105_LED2_PULSEAMP 0x0D #define MAX30105_LED3_PULSEAMP 0x0E #define MAX30105_LED_PROX_AMP 0x10 #define MAX30105_MULTILEDCONFIG1 0x11 #define MAX30105_MULTILEDCONFIG2 0x12 // Die Temperature Registers #define MAX30105_DIETEMPINT 0x1F #define MAX30105_DIETEMPFRAC 0x20 #define MAX30105_DIETEMPCONFIG 0x21 // Proximity Function Registers #define MAX30105_PROXINTTHRESH 0x30 // Part ID Registers #define MAX30105_REVISIONID 0xFE #define MAX30105_PARTID 0xFF // Should always be 0x15. Identical to MAX30102. // // MAX30105 Commands // // Interrupt configuration (pg 13, 14) #define MAX30105_INT_A_FULL_MASK (byte)~0b10000000 #define MAX30105_INT_A_FULL_ENABLE 0x80 #define MAX30105_INT_A_FULL_DISABLE 0x00 #define MAX30105_INT_DATA_RDY_MASK (byte)~0b01000000 #define MAX30105_INT_DATA_RDY_ENABLE 0x40 #define MAX30105_INT_DATA_RDY_DISABLE 0x00 #define MAX30105_INT_ALC_OVF_MASK (byte)~0b00100000 #define MAX30105_INT_ALC_OVF_ENABLE 0x20 #define MAX30105_INT_ALC_OVF_DISABLE 0x00 #define MAX30105_INT_PROX_INT_MASK (byte)~0b00010000 #define MAX30105_INT_PROX_INT_ENABLE 0x10 #define MAX30105_INT_PROX_INT_DISABLE 0x00 #define MAX30105_INT_DIE_TEMP_RDY_MASK (byte)~0b00000010 #define MAX30105_INT_DIE_TEMP_RDY_ENABLE 0x02 #define MAX30105_INT_DIE_TEMP_RDY_DISABLE 0x00 // FIFO configuration commands (pg 18) #define MAX30105_SAMPLEAVG_MASK (byte)~0b11100000 #define MAX30105_SAMPLEAVG_1 0x00 #define MAX30105_SAMPLEAVG_2 0x20 #define MAX30105_SAMPLEAVG_4 0x40 #define MAX30105_SAMPLEAVG_8 0x60 #define MAX30105_SAMPLEAVG_16 0x80 #define MAX30105_SAMPLEAVG_32 0xA0 #define MAX30105_ROLLOVER_MASK 0xEF #define MAX30105_ROLLOVER_ENABLE 0x10 #define MAX30105_ROLLOVER_DISABLE 0x00 #define MAX30105_A_FULL_MASK 0xF0 // Mode configuration commands (page 19) #define MAX30105_SHUTDOWN_MASK 0x7F #define MAX30105_SHUTDOWN 0x80 #define MAX30105_WAKEUP 0x00 #define MAX30105_RESET_MASK 0xBF #define MAX30105_RESET 0x40 #define MAX30105_MODE_MASK 0xF8 #define MAX30105_MODE_REDONLY 0x02 #define MAX30105_MODE_REDIRONLY 0x03 #define MAX30105_MODE_MULTILED 0x07 // Particle sensing configuration commands (pgs 19-20) #define MAX30105_ADCRANGE_MASK 0x9F #define MAX30105_ADCRANGE_2048 0x00 #define MAX30105_ADCRANGE_4096 0x20 #define MAX30105_ADCRANGE_8192 0x40 #define MAX30105_ADCRANGE_16384 0x60 #define MAX30105_SAMPLERATE_MASK 0xE3 #define MAX30105_SAMPLERATE_50 0x00 #define MAX30105_SAMPLERATE_100 0x04 #define MAX30105_SAMPLERATE_200 0x08 #define MAX30105_SAMPLERATE_400 0x0C #define MAX30105_SAMPLERATE_800 0x10 #define MAX30105_SAMPLERATE_1000 0x14 #define MAX30105_SAMPLERATE_1600 0x18 #define MAX30105_SAMPLERATE_3200 0x1C #define MAX30105_PULSEWIDTH_MASK 0xFC #define MAX30105_PULSEWIDTH_69 0x00 #define MAX30105_PULSEWIDTH_118 0x01 #define MAX30105_PULSEWIDTH_215 0x02 #define MAX30105_PULSEWIDTH_411 0x03 //Multi-LED Mode configuration (pg 22) #define MAX30105_SLOT1_MASK 0xF8 #define MAX30105_SLOT2_MASK 0x8F #define MAX30105_SLOT3_MASK 0xF8 #define MAX30105_SLOT4_MASK 0x8F #define SLOT_NONE 0x00 #define SLOT_RED_LED 0x01 #define SLOT_IR_LED 0x02 #define SLOT_GREEN_LED 0x03 #define SLOT_NONE_PILOT 0x04 #define SLOT_RED_PILOT 0x05 #define SLOT_IR_PILOT 0x06 #define SLOT_GREEN_PILOT 0x07 // // MAX30105 Other Defines // #define MAX_30105_EXPECTEDPARTID 0x15 // // Driver Class Definition // class MAX30105 { public: MAX30105(void); boolean begin(TwoWire &wirePort = Wire, uint32_t i2cSpeed = I2C_SPEED_STANDARD, uint8_t i2caddr = MAX30105_ADDRESS); // Configuration void softReset(); void shutDown(); void wakeUp(); void setLEDMode(uint8_t mode); void setADCRange(uint8_t adcRange); void setSampleRate(uint8_t sampleRate); void setPulseWidth(uint8_t pulseWidth); void setPulseAmplitudeRed(uint8_t value); void setPulseAmplitudeIR(uint8_t value); void setPulseAmplitudeGreen(uint8_t value); void setPulseAmplitudeProximity(uint8_t value); void setProximityThreshold(uint8_t threshMSB); //Multi-led configuration mode (page 22) void enableSlot(uint8_t slotNumber, uint8_t device); //Given slot number, assign a device to slot void disableSlots(void); // Data Collection //Interrupts (page 13, 14) uint8_t getINT1(void); //Returns the main interrupt group uint8_t getINT2(void); //Returns the temp ready interrupt void enableAFULL(void); //Enable/disable individual interrupts void disableAFULL(void); void enableDATARDY(void); void disableDATARDY(void); void enableALCOVF(void); void disableALCOVF(void); void enablePROXINT(void); void disablePROXINT(void); void enableDIETEMPRDY(void); void disableDIETEMPRDY(void); //FIFO Configuration (page 18) void setFIFOAverage(uint8_t samples); void enableFIFORollover(); void disableFIFORollover(); void setFIFOAlmostFull(uint8_t samples); //FIFO Reading uint16_t check(void); uint8_t getWritePointer(void); uint8_t getReadPointer(void); void clearFIFO(void); //Sets the read/write pointers to zero uint16_t available(void); //Tells caller how many new samples are available uint32_t getRed(void); //Returns the oldest red value. uint32_t getIR(void); //Returns the oldest IR value. uint32_t getGreen(void); //Returns the oldest green value. void nextSample(void); //Advances the tail of the sense array //Proximity Mode Interrupt Threshold void setPROXINTTHRESH(uint8_t val); // Die Temperature float readTemperature(); float readTemperatureF(); // Detecting ID/Revision uint8_t getRevisionID(); uint8_t readPartID(); // Setup the IC with user selectable settings void setup(byte powerLevel = 0x1F, byte sampleAverage = 4, byte ledMode = 3, int sampleRate = 100, int pulseWidth = 411); // Low-level I2C communication uint8_t readRegister8(uint8_t address, uint8_t reg); void writeRegister8(uint8_t address, uint8_t reg, uint8_t value); private: TwoWire *_i2cPort; //The generic connection to user's chosen I2C hardware uint8_t _i2caddr; //activeLEDs is the number of channels turned on, and can be 1 to 3. 2 is common for Red+IR. byte activeLEDs; //Gets set during setup. Allows check() to calculate how many bytes to read from FIFO uint8_t revisionID; void readRevisionID(); void bitMask(uint8_t reg, uint8_t mask, uint8_t thing); };
31.159696
123
0.743258
ecd2b570d1b484adfbe751a00af37dca8772690e
6,432
c
C
external/asf4-drivers/hal/src/hal_mci_sync.c
thisconnect/bitbox02-firmware
e081ac18dc28c2bdffdc58a94afa36a1bb5bade2
[ "Apache-2.0" ]
119
2019-06-06T11:18:14.000Z
2022-03-21T00:03:45.000Z
external/asf4-drivers/hal/src/hal_mci_sync.c
thisconnect/bitbox02-firmware
e081ac18dc28c2bdffdc58a94afa36a1bb5bade2
[ "Apache-2.0" ]
530
2019-06-12T14:16:54.000Z
2022-03-21T18:16:46.000Z
external/asf4-drivers/hal/src/hal_mci_sync.c
thisconnect/bitbox02-firmware
e081ac18dc28c2bdffdc58a94afa36a1bb5bade2
[ "Apache-2.0" ]
54
2019-06-07T04:16:56.000Z
2022-01-18T08:32:06.000Z
/** * \file * * \brief Multimedia Card/ Memory Card Interface HAL. * * Copyright (C) 2016 Atmel Corporation. All rights reserved. * * \asf_license_start * * \page License * * 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. The name of Atmel may not be used to endorse or promote products derived * from this software without specific prior written permission. * * 4. This software may only be redistributed and used in connection with an * Atmel microcontroller product. * * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL 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. * * \asf_license_stop * */ #include "hal_mci_sync.h" #include <utils_assert.h> #ifdef __cplusplus extern "C" { #endif /** MCI HAL driver version. */ #define DRIVER_VERSION 0x00000001u /** * \brief Initialize MCI low level driver. */ int32_t mci_sync_init(struct mci_sync_desc *mci, void *hw) { ASSERT(mci && hw); return _mci_sync_init(&mci->device, hw); } /** * \brief Deinitialize MCI low level driver. */ int32_t mci_sync_deinit(struct mci_sync_desc *mci) { ASSERT(mci); return _mci_sync_deinit(&mci->device); } /** * \brief Select a device and initialize it */ int32_t mci_sync_select_device(struct mci_sync_desc *mci, uint8_t slot, uint32_t clock, uint8_t bus_width, bool high_speed) { ASSERT(mci); return _mci_sync_select_device(&mci->device, slot, clock, bus_width, high_speed); } /** * \brief Get the maximum bus width of a device by a selected slot */ uint8_t mci_sync_get_bus_width(struct mci_sync_desc *mci, uint8_t slot) { ASSERT(mci); return _mci_sync_get_bus_width(&mci->device, slot); } /** * \brief Get the high speed capability of the device. * */ bool mci_sync_is_high_speed_capable(struct mci_sync_desc *mci) { ASSERT(mci); return _mci_sync_is_high_speed_capable(&mci->device); } /** * \brief Send 74 clock cycles on the line. */ void mci_sync_send_clock(struct mci_sync_desc *mci) { ASSERT(mci); _mci_sync_send_clock(&mci->device); } /** * \brief Disable the bus clock. */ void mci_sync_pause_clock(struct mci_sync_desc *mci) { ASSERT(mci); _mci_sync_pause_clock(&mci->device); } /** * \brief Resume the bus clock. */ void mci_sync_resume_clock(struct mci_sync_desc *mci) { ASSERT(mci); _mci_sync_resume_clock(&mci->device); } /** * \brief Send a command on the selected slot */ bool mci_sync_send_cmd(struct mci_sync_desc *mci, uint32_t cmd, uint32_t arg) { ASSERT(mci); return _mci_sync_send_cmd(&mci->device, cmd, arg); } /** * \brief Get 32 bits response of the last command. */ uint32_t mci_sync_get_response(struct mci_sync_desc *mci) { ASSERT(mci); return _mci_sync_get_response(&mci->device); } /** * \brief Get 128 bits response of the last command. */ void mci_sync_get_response_128(struct mci_sync_desc *mci, uint8_t *response) { ASSERT(mci && response); _mci_sync_get_response_128(&mci->device, response); } /** * \brief Send an ADTC command on the selected slot * An ADTC (Addressed Data Transfer Commands) * command is used for read/write access. */ bool mci_sync_adtc_start(struct mci_sync_desc *mci, uint32_t cmd, uint32_t arg, uint16_t block_size, uint16_t nb_block, bool access_block) { ASSERT(mci); return _mci_sync_adtc_start(&mci->device, cmd, arg, block_size, nb_block, access_block); } /** * \brief Send a command to stop an ADTC command on the selected slot. */ bool mci_sync_adtc_stop(struct mci_sync_desc *mci, uint32_t cmd, uint32_t arg) { ASSERT(mci); return _mci_sync_adtc_stop(&mci->device, cmd, arg); } /** * \brief Read a word on the line. */ bool mci_sync_read_word(struct mci_sync_desc *mci, uint32_t *value) { ASSERT(mci && value); return _mci_sync_read_word(&mci->device, value); } /** * \brief Write a word on the line */ bool mci_sync_write_word(struct mci_sync_desc *mci, uint32_t value) { ASSERT(mci); return _mci_sync_write_word(&mci->device, value); } /** * \brief Start a read blocks transfer on the line * Note: The driver will use the DMA available to speed up the transfer. */ bool mci_sync_start_read_blocks(struct mci_sync_desc *mci, void *dst, uint16_t nb_block) { ASSERT(mci && dst); return _mci_sync_start_read_blocks(&mci->device, dst, nb_block); } /** * \brief Start a write blocks transfer on the line */ bool mci_sync_start_write_blocks(struct mci_sync_desc *mci, const void *src, uint16_t nb_block) { ASSERT(mci && src); return _mci_sync_start_write_blocks(&mci->device, src, nb_block); } /** * \brief Wait the end of transfer initiated by mci_start_read_blocks() */ bool mci_sync_wait_end_of_read_blocks(struct mci_sync_desc *mci) { ASSERT(mci); return _mci_sync_wait_end_of_read_blocks(&mci->device); } /** * \brief Wait the end of transfer initiated by mci_start_write_blocks() */ bool mci_sync_wait_end_of_write_blocks(struct mci_sync_desc *mci) { ASSERT(mci); return _mci_sync_wait_end_of_write_blocks(&mci->device); } /** * \brief Retrieve the current driver version * \return Current driver version */ uint32_t mci_sync_get_version(void) { return DRIVER_VERSION; } #ifdef __cplusplus } #endif
26.469136
119
0.719838
08e2f0f1bf6508e349e42f93e1a9d1dabd7cd294
5,119
h
C
src/game/shared/tf/tf_weapon_shotgun.h
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
6
2022-01-23T09:40:33.000Z
2022-03-20T20:53:25.000Z
src/game/shared/tf/tf_weapon_shotgun.h
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
null
null
null
src/game/shared/tf/tf_weapon_shotgun.h
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
1
2022-02-06T21:05:23.000Z
2022-02-06T21:05:23.000Z
//========= Copyright Valve Corporation, All rights reserved. ============// // // Purpose: // //============================================================================= #ifndef TF_WEAPON_SHOTGUN_H #define TF_WEAPON_SHOTGUN_H #ifdef _WIN32 #pragma once #endif #include "tf_weaponbase_gun.h" #if defined( CLIENT_DLL ) #define CTFShotgun C_TFShotgun #define CTFShotgun_Soldier C_TFShotgun_Soldier #define CTFShotgun_HWG C_TFShotgun_HWG #define CTFShotgun_Pyro C_TFShotgun_Pyro #define CTFScatterGun C_TFScatterGun #define CTFShotgun_Revenge C_TFShotgun_Revenge #define CTFSodaPopper C_TFSodaPopper #define CTFPEPBrawlerBlaster C_TFPEPBrawlerBlaster #define CTFShotgunBuildingRescue C_TFShotgunBuildingRescue #define CTFLeech C_TFLeech #endif // Reload Modes enum { TF_WEAPON_SHOTGUN_RELOAD_START = 0, TF_WEAPON_SHOTGUN_RELOAD_SHELL, TF_WEAPON_SHOTGUN_RELOAD_CONTINUE, TF_WEAPON_SHOTGUN_RELOAD_FINISH }; //============================================================================= // // Shotgun class. // class CTFShotgun : public CTFWeaponBaseGun { public: DECLARE_CLASS( CTFShotgun, CTFWeaponBaseGun ); DECLARE_NETWORKCLASS(); DECLARE_PREDICTABLE(); CTFShotgun(); virtual int GetWeaponID( void ) const { return TF_WEAPON_SHOTGUN_PRIMARY; } virtual void PrimaryAttack(); virtual void PlayWeaponShootSound( void ); #ifdef GAME_DLL virtual CDmgAccumulator *GetDmgAccumulator( void ) { return &m_Accumulator; } #endif // GAME_DLL protected: void Fire( CTFPlayer *pPlayer ); void UpdatePunchAngles( CTFPlayer *pPlayer ); private: CTFShotgun( const CTFShotgun & ) {} #ifdef GAME_DLL CDmgAccumulator m_Accumulator; #endif // GAME_DLL }; // Engineer's revenge shotgun. class CTFShotgun_Revenge : public CTFShotgun { public: DECLARE_CLASS( CTFShotgun_Revenge, CTFShotgun ); DECLARE_NETWORKCLASS(); DECLARE_PREDICTABLE(); CTFShotgun_Revenge(); virtual int GetWeaponID( void ) const { return TF_WEAPON_SENTRY_REVENGE; } void Precache(); virtual void PrimaryAttack(); virtual void SentryKilled( int iKills ); virtual bool Holster( CBaseCombatWeapon *pSwitchingTo = NULL ); virtual bool Deploy( void ); virtual int GetCustomDamageType() const; int GetCount( void ); float GetProgress( void ) { return 0.f; } const char* GetEffectLabelText( void ) { return "#TF_REVENGE"; } #ifdef CLIENT_DLL virtual void SetWeaponVisible( bool visible ); virtual int GetWorldModelIndex( void ); #else virtual void Detach(); #endif }; // Scout version. Different models, possibly different behaviour later on class CTFScatterGun : public CTFShotgun { public: DECLARE_CLASS( CTFScatterGun, CTFShotgun ); DECLARE_NETWORKCLASS(); DECLARE_PREDICTABLE(); virtual int GetWeaponID( void ) const { return TF_WEAPON_SCATTERGUN; } virtual bool Reload( void ); virtual void FireBullet( CTFPlayer *pPlayer ); virtual void ApplyPostHitEffects( const CTakeDamageInfo &inputInfo, CTFPlayer *pPlayer ); virtual void FinishReload( void ); virtual bool HasKnockback( void ); virtual bool SendWeaponAnim( int iActivity ); #ifdef GAME_DLL virtual void Equip( CBaseCombatCharacter *pOwner ); #endif // GAME_DLL }; class CTFShotgun_Soldier : public CTFShotgun { public: DECLARE_CLASS( CTFShotgun_Soldier, CTFShotgun ); DECLARE_NETWORKCLASS(); DECLARE_PREDICTABLE(); virtual int GetWeaponID( void ) const { return TF_WEAPON_SHOTGUN_SOLDIER; } }; // Secondary version. Different weapon slot, different ammo class CTFShotgun_HWG : public CTFShotgun { public: DECLARE_CLASS( CTFShotgun_HWG, CTFShotgun ); DECLARE_NETWORKCLASS(); DECLARE_PREDICTABLE(); virtual int GetWeaponID( void ) const { return TF_WEAPON_SHOTGUN_HWG; } }; class CTFShotgun_Pyro : public CTFShotgun { public: DECLARE_CLASS( CTFShotgun_Pyro, CTFShotgun ); DECLARE_NETWORKCLASS(); DECLARE_PREDICTABLE(); virtual int GetWeaponID( void ) const { return TF_WEAPON_SHOTGUN_PYRO; } }; class CTFSodaPopper : public CTFScatterGun { public: DECLARE_CLASS( CTFSodaPopper, CTFScatterGun ); DECLARE_NETWORKCLASS(); DECLARE_PREDICTABLE(); virtual int GetWeaponID( void ) const { return TF_WEAPON_SODA_POPPER; } virtual void ItemBusyFrame( void ); virtual void SecondaryAttack( void ); const char* GetEffectLabelText( void ) { return "#TF_HYPE"; } float GetProgress( void ); }; class CTFPEPBrawlerBlaster : public CTFScatterGun { public: DECLARE_CLASS( CTFPEPBrawlerBlaster, CTFScatterGun ); DECLARE_NETWORKCLASS(); DECLARE_PREDICTABLE(); virtual int GetWeaponID( void ) const { return TF_WEAPON_PEP_BRAWLER_BLASTER; } const char* GetEffectLabelText( void ) { return "#TF_Boost"; } float GetProgress( void ); }; class CTFShotgunBuildingRescue : public CTFShotgun { public: DECLARE_CLASS( CTFShotgunBuildingRescue, CTFShotgun ); DECLARE_NETWORKCLASS(); DECLARE_PREDICTABLE(); virtual int GetWeaponID( void ) const { return TF_WEAPON_SHOTGUN_BUILDING_RESCUE; } virtual float GetProjectileSpeed( void ); virtual float GetProjectileGravity( void ); virtual bool IsViewModelFlipped( void ); }; #endif // TF_WEAPON_SHOTGUN_H
25.853535
90
0.743114
4d0f1ef6e725a5558fd07fc46161d693a0df4717
2,539
h
C
src/analysis/network/qgsnetworkstrategy.h
dyna-mis/Hilabeling
cb7d5d4be29624a20c8a367162dbc6fd779b2b52
[ "MIT" ]
null
null
null
src/analysis/network/qgsnetworkstrategy.h
dyna-mis/Hilabeling
cb7d5d4be29624a20c8a367162dbc6fd779b2b52
[ "MIT" ]
null
null
null
src/analysis/network/qgsnetworkstrategy.h
dyna-mis/Hilabeling
cb7d5d4be29624a20c8a367162dbc6fd779b2b52
[ "MIT" ]
1
2021-12-25T08:40:30.000Z
2021-12-25T08:40:30.000Z
/*************************************************************************** qgsnetworkstrategy.h -------------------------------------- Date : 2011-04-01 Copyright : (C) 2010 by Yakushev Sergey Email : YakushevS <at> list.ru **************************************************************************** * * * 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. * * * ***************************************************************************/ #ifndef QGSNETWORKSTRATERGY_H #define QGSNETWORKSTRATERGY_H #include <QVariant> #include "qgsfeature.h" #include "qgsfeaturerequest.h" #include "qgis_analysis.h" #ifdef SIP_RUN % ModuleHeaderCode #include <qgsnetworkspeedstrategy.h> #include <qgsnetworkdistancestrategy.h> % End #endif /** * \ingroup analysis * \class QgsNetworkStrategy * \brief QgsNetworkStrategy defines strategy used for calculation of the edge cost. For example it can * take into account travel distance, amount of time or money. Currently there are two strategies * implemented in the analysis library: QgsNetworkDistanceStrategy and QgsNetworkSpeedStrategy. * QgsNetworkStrategy implemented using "strategy" design pattern. * \since QGIS 3.0 */ class ANALYSIS_EXPORT QgsNetworkStrategy { #ifdef SIP_RUN SIP_CONVERT_TO_SUBCLASS_CODE if ( dynamic_cast< QgsNetworkDistanceStrategy * >( sipCpp ) != NULL ) sipType = sipType_QgsNetworkDistanceStrategy; else if ( dynamic_cast< QgsNetworkSpeedStrategy * >( sipCpp ) != NULL ) sipType = sipType_QgsNetworkSpeedStrategy; else sipType = NULL; SIP_END #endif public: /** * Default constructor */ QgsNetworkStrategy() = default; virtual ~QgsNetworkStrategy() = default; /** * Returns a list of the source layer attributes needed for cost calculation. * This is method called by QgsGraphDirector. */ virtual QSet< int > requiredAttributes() const { return QSet< int >(); } /** * Returns edge cost */ virtual QVariant cost( double distance, const QgsFeature &f ) const = 0; }; #endif // QGSNETWORKSTRATERGY_H
32.551282
103
0.57818
231e1ede71fff1b92788525e88fa513ffd6a9fd3
258
h
C
env/Library/include/qt/QtWebEngineWidgets/qtwebenginewidgetsversion.h
h4vlik/TF2_OD_BRE
54643b6e8e9d76847329b1dbda69efa1c7ae3e72
[ "BSD-3-Clause" ]
1
2020-12-26T15:52:19.000Z
2020-12-26T15:52:19.000Z
env/Library/include/qt/QtWebEngineWidgets/qtwebenginewidgetsversion.h
h4vlik/TF2_OD_BRE
54643b6e8e9d76847329b1dbda69efa1c7ae3e72
[ "BSD-3-Clause" ]
null
null
null
env/Library/include/qt/QtWebEngineWidgets/qtwebenginewidgetsversion.h
h4vlik/TF2_OD_BRE
54643b6e8e9d76847329b1dbda69efa1c7ae3e72
[ "BSD-3-Clause" ]
1
2021-01-05T13:08:03.000Z
2021-01-05T13:08:03.000Z
/* This file was generated by syncqt. */ #ifndef QT_QTWEBENGINEWIDGETS_VERSION_H #define QT_QTWEBENGINEWIDGETS_VERSION_H #define QTWEBENGINEWIDGETS_VERSION_STR "5.12.9" #define QTWEBENGINEWIDGETS_VERSION 0x050C09 #endif // QT_QTWEBENGINEWIDGETS_VERSION_H
25.8
47
0.844961
9ce1144c9893ba1ee08d31896e5d5027bf8d1bfa
727
h
C
shibari/shibari.h
jnastarot/shibari
5b0bc7b7b886fe0c9b19f5e4d97c7e969edacb56
[ "BSD-3-Clause" ]
32
2018-10-17T09:33:59.000Z
2022-01-30T18:22:51.000Z
shibari/shibari.h
jnastarot/shibari
5b0bc7b7b886fe0c9b19f5e4d97c7e969edacb56
[ "BSD-3-Clause" ]
2
2019-02-24T05:28:50.000Z
2019-03-15T19:16:04.000Z
shibari/shibari.h
jnastarot/shibari
5b0bc7b7b886fe0c9b19f5e4d97c7e969edacb56
[ "BSD-3-Clause" ]
17
2018-05-22T23:37:24.000Z
2021-11-09T07:24:00.000Z
#pragma once class shibari_module; class shibari_linker; #include "shibari_module.h" #include "shibari_linker.h" #include "shibari_builder.h" class shibari { std::vector<shibari_module*> extended_modules; shibari_module* main_module; public: shibari(); ~shibari(); shibari_linker_errors exec_shibari(uint32_t enma_build_flags, std::vector<uint8_t>& out_image); public: void set_main_module(shibari_module* module); void add_extended_module(shibari_module* module); public: std::vector<shibari_module*>& get_extended_modules(); const std::vector<shibari_module*>& get_extended_modules() const; shibari_module* get_main_module(); const shibari_module* get_main_module() const; };
25.964286
99
0.757909
8c1fe0e632b399e5ec1b9990c31f5b5024235d1d
68
h
C
PWGLF/ThermalFits/PWGLFthermalfitsLinkDef.h
maroozm/AliPhysics
22ec256928cfdf8f800e05bfc1a6e124d90b6eaf
[ "BSD-3-Clause" ]
114
2017-03-03T09:12:23.000Z
2022-03-03T20:29:42.000Z
PWGLF/ThermalFits/PWGLFthermalfitsLinkDef.h
maroozm/AliPhysics
22ec256928cfdf8f800e05bfc1a6e124d90b6eaf
[ "BSD-3-Clause" ]
19,637
2017-01-16T12:34:41.000Z
2022-03-31T22:02:40.000Z
PWGLF/ThermalFits/PWGLFthermalfitsLinkDef.h
maroozm/AliPhysics
22ec256928cfdf8f800e05bfc1a6e124d90b6eaf
[ "BSD-3-Clause" ]
1,021
2016-07-14T22:41:16.000Z
2022-03-31T05:15:51.000Z
#ifdef __CINT__ #pragma link C++ class AliParticleYield+; #endif
9.714286
41
0.735294
88f730e95cf2cd3a3decc0707eeb8fa0062a8b36
741
h
C
src/lldb/Bindings/SBHostOSBinding.h
danielzfranklin/lldb-sys.rs
47c1673d131d4911b3cfdc8e6b2c7a300707314e
[ "Apache-2.0", "MIT" ]
null
null
null
src/lldb/Bindings/SBHostOSBinding.h
danielzfranklin/lldb-sys.rs
47c1673d131d4911b3cfdc8e6b2c7a300707314e
[ "Apache-2.0", "MIT" ]
null
null
null
src/lldb/Bindings/SBHostOSBinding.h
danielzfranklin/lldb-sys.rs
47c1673d131d4911b3cfdc8e6b2c7a300707314e
[ "Apache-2.0", "MIT" ]
null
null
null
//===-- SBHostOSBinding.h ---------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef LLDB_SBHostOSBinding_h_ #define LLDB_SBHostOSBinding_h_ #include "lldb/Bindings/SBBindingDefines.h" #ifdef __cplusplus extern "C" { #endif LLDB_API SBFileSpecRef SBHostOSGetProgramFileSpec(void); LLDB_API SBFileSpecRef SBHostOSGetLLDBPythonPath(void); LLDB_API SBFileSpecRef SBHostOSGetLLDBPath(ENUM(PathType) path_type); #ifdef __cplusplus } #endif #endif // LLDB_SBHostOSBinding_h_
24.7
80
0.631579
15b177341ff060e29c9063bb2fbaf8831f3c7e77
5,394
h
C
include/perfetto/ext/base/small_vector.h
ztlevi/perfetto
a0de991bf39c5744ab4eef00eae823c378eb99a9
[ "Apache-2.0" ]
3
2022-01-27T23:05:58.000Z
2022-01-28T07:53:34.000Z
include/perfetto/ext/base/small_vector.h
ztlevi/perfetto
a0de991bf39c5744ab4eef00eae823c378eb99a9
[ "Apache-2.0" ]
null
null
null
include/perfetto/ext/base/small_vector.h
ztlevi/perfetto
a0de991bf39c5744ab4eef00eae823c378eb99a9
[ "Apache-2.0" ]
2
2022-03-29T02:58:16.000Z
2022-03-29T13:19:34.000Z
/* * Copyright (C) 2021 The Android Open Source Project * * 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. */ #ifndef INCLUDE_PERFETTO_EXT_BASE_SMALL_VECTOR_H_ #define INCLUDE_PERFETTO_EXT_BASE_SMALL_VECTOR_H_ #include <algorithm> #include <type_traits> #include <utility> #include "perfetto/base/compiler.h" #include "perfetto/base/logging.h" #include "perfetto/ext/base/utils.h" namespace perfetto { namespace base { // Uses inline storage first, switches to dynamic storage when it overflows. template <typename T, size_t kSize> class SmallVector { public: static constexpr size_t kInlineSize = kSize; explicit SmallVector() = default; ~SmallVector() { clear(); if (PERFETTO_UNLIKELY(is_using_heap())) AlignedFree(begin_); begin_ = end_ = end_of_storage_ = nullptr; } // Move operators. SmallVector(SmallVector&& other) noexcept( std::is_nothrow_move_constructible<T>::value) { if (other.is_using_heap()) { // Move the heap content, no need to move the individual objects as their // location won't change. begin_ = other.begin_; end_ = other.end_; end_of_storage_ = other.end_of_storage_; } else { const size_t other_size = other.size(); PERFETTO_DCHECK(other_size <= capacity()); for (size_t i = 0; i < other_size; i++) { // Move the entries and destroy the ones in the moved-from object. new (&begin_[i]) T(std::move(other.begin_[i])); other.begin_[i].~T(); } end_ = begin_ + other_size; } auto* const other_inline_storage = other.inline_storage_begin(); other.end_ = other.begin_ = other_inline_storage; other.end_of_storage_ = other_inline_storage + kInlineSize; } SmallVector& operator=(SmallVector&& other) noexcept( std::is_nothrow_move_constructible<T>::value) { this->~SmallVector(); new (this) SmallVector<T, kSize>(std::move(other)); return *this; } // Copy operators. SmallVector(const SmallVector& other) { const size_t other_size = other.size(); if (other_size > capacity()) Grow(other_size); // Copy-construct the elements. for (size_t i = 0; i < other_size; ++i) new (&begin_[i]) T(other.begin_[i]); end_ = begin_ + other_size; } SmallVector& operator=(const SmallVector& other) { if (PERFETTO_UNLIKELY(this == &other)) return *this; this->~SmallVector(); new (this) SmallVector<T, kSize>(other); return *this; } T* data() { return begin_; } const T* data() const { return begin_; } T* begin() { return begin_; } const T* begin() const { return begin_; } T* end() { return end_; } const T* end() const { return end_; } size_t size() const { return static_cast<size_t>(end_ - begin_); } bool empty() const { return end_ == begin_; } size_t capacity() const { return static_cast<size_t>(end_of_storage_ - begin_); } T& back() { PERFETTO_DCHECK(!empty()); return end_[-1]; } const T& back() const { PERFETTO_DCHECK(!empty()); return end_[-1]; } T& operator[](size_t index) { PERFETTO_DCHECK(index < size()); return begin_[index]; } const T& operator[](size_t index) const { PERFETTO_DCHECK(index < size()); return begin_[index]; } template <typename... Args> void emplace_back(Args&&... args) { T* end = end_; if (PERFETTO_UNLIKELY(end == end_of_storage_)) end = Grow(); new (end) T(std::forward<Args>(args)...); end_ = end + 1; } void pop_back() { PERFETTO_DCHECK(!empty()); back().~T(); --end_; } // Clear without reverting back to inline storage. void clear() { while (!empty()) pop_back(); } private: PERFETTO_NO_INLINE T* Grow(size_t desired_capacity = 0) { size_t cur_size = size(); size_t new_capacity = desired_capacity; if (desired_capacity <= cur_size) new_capacity = std::max(capacity() * 2, size_t(128)); T* new_storage = static_cast<T*>(AlignedAlloc(alignof(T), new_capacity * sizeof(T))); for (size_t i = 0; i < cur_size; ++i) { // Move the elements into the new heap buffer and destroy the old ones. new (&new_storage[i]) T(std::move(begin_[i])); begin_[i].~T(); } if (is_using_heap()) AlignedFree(begin_); begin_ = new_storage; end_ = new_storage + cur_size; end_of_storage_ = new_storage + new_capacity; return end_; } T* inline_storage_begin() { return reinterpret_cast<T*>(&inline_storage_); } bool is_using_heap() { return begin_ != inline_storage_begin(); } T* begin_ = inline_storage_begin(); T* end_ = begin_; T* end_of_storage_ = begin_ + kInlineSize; typename std::aligned_storage<sizeof(T) * kInlineSize, alignof(T)>::type inline_storage_; }; } // namespace base } // namespace perfetto #endif // INCLUDE_PERFETTO_EXT_BASE_SMALL_VECTOR_H_
28.539683
79
0.660178
12141d2b300fef9c267001a02a25e62039d7d08c
717
h
C
app/out_html5/out/haxe/xml/_Access/HasNodeAccess_Impl_.h
Lerg/hashlink-emscripten
8f5c28a879c78f275fcbc482e1c5f86c08dbe72e
[ "MIT" ]
1
2021-10-03T16:34:38.000Z
2021-10-03T16:34:38.000Z
app/out_html5/out/haxe/xml/_Access/HasNodeAccess_Impl_.h
Lerg/hashlink-emscripten
8f5c28a879c78f275fcbc482e1c5f86c08dbe72e
[ "MIT" ]
null
null
null
app/out_html5/out/haxe/xml/_Access/HasNodeAccess_Impl_.h
Lerg/hashlink-emscripten
8f5c28a879c78f275fcbc482e1c5f86c08dbe72e
[ "MIT" ]
null
null
null
// Generated by HLC 4.2.1 (HL v4) #ifndef INC_haxe__xml___Access__HasNodeAccess_Impl_ #define INC_haxe__xml___Access__HasNodeAccess_Impl_ typedef struct _haxe__xml___Access__$HasNodeAccess_Impl_ *haxe__xml___Access__$HasNodeAccess_Impl_; typedef struct _haxe__xml___Access__HasNodeAccess_Impl_ *haxe__xml___Access__HasNodeAccess_Impl_; #include <hl/Class.h> #include <hl/BaseType.h> #include <_std/String.h> #include <_std/Xml.h> struct _haxe__xml___Access__$HasNodeAccess_Impl_ { hl_type *$type; hl_type* __type__; vdynamic* __meta__; varray* __implementedBy__; String __name__; vdynamic* __constructor__; vclosure* resolve; }; struct _haxe__xml___Access__HasNodeAccess_Impl_ { hl_type *$type; }; #endif
27.576923
99
0.828452
18c4b798f002a7112c08d1528a6c4c6c752ca9de
30
h
C
2019/express/node_modules/unit-http/version.h
dejonghe/nginx_unit_examples
6e3643950ce65d5f3fefc32e04d681d9d5445094
[ "Apache-2.0" ]
3
2020-11-17T09:46:40.000Z
2021-03-11T14:55:58.000Z
2019/express/node_modules/unit-http/version.h
dejonghe/nginx_unit_examples
6e3643950ce65d5f3fefc32e04d681d9d5445094
[ "Apache-2.0" ]
null
null
null
2019/express/node_modules/unit-http/version.h
dejonghe/nginx_unit_examples
6e3643950ce65d5f3fefc32e04d681d9d5445094
[ "Apache-2.0" ]
1
2021-09-20T03:07:25.000Z
2021-09-20T03:07:25.000Z
#define NXT_NODE_VERNUM 10800
15
29
0.866667
49dbd138063fc4c9ddcff06807753e8ae8a75c89
3,691
h
C
Source/vtkboneApplyTorsionTest.h
Numerics88/vtkbone
5a6ab2870679e9e7ea51926c34911607b9d85235
[ "MIT" ]
3
2017-04-04T04:59:22.000Z
2022-03-13T11:22:40.000Z
Source/vtkboneApplyTorsionTest.h
Numerics88/vtkbone
5a6ab2870679e9e7ea51926c34911607b9d85235
[ "MIT" ]
5
2017-04-06T19:46:39.000Z
2019-12-11T23:41:41.000Z
Source/vtkboneApplyTorsionTest.h
Numerics88/vtkbone
5a6ab2870679e9e7ea51926c34911607b9d85235
[ "MIT" ]
2
2017-04-29T20:54:57.000Z
2017-04-29T22:28:10.000Z
/*========================================================================= Copyright 2010-2016, Numerics88 Solutions Ltd. http://www.numerics88.com/ Copyright (c) Eric Nodwell and Steven K. Boyd See Copyright.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // .NAME vtkboneApplyTorsionTest - Generates a finite element mesh that // corresponds to a torsion test. // // .SECTION Description // vtkboneApplyTorsionTest is an object that generates a finite element mesh // corresponding to a torsion test. In a torsion test, the Bottom // surface is fixed (all directions), while the Top surface is rotated. // // Refer to vtkboneApplyTestBase for details regarding the orientation of the // test. // // This object requires two inputs. Input 0 must be a vtkUnstructuredGrid (or an // existing vtkboneFiniteElementModel) giving the segmented geometry of the // model, while input 2 must be the vtkboneMaterialTable object that will be // associated with the model. // // Very often, you will want to use the center of mass as the torsion axis // origin. For this purpose, you can use either vtkboneTensorOfInertia or // vtkMassProperties to obtain the center of mass. // // The following Constraints are generated: // // - "bottom_fixed" : All fixed nodes constraints from node set "face_z0". // - "top_fixed" : All fixed nodes constraints from node set "face_z1". // - "top_displacement" : All displacement node constraints from node set "face_z1". // // The object information ROTATION_CENTER is set to the TwistAxis, // converted to the Data Frame. As there is no z value of the TwistAxis, // the equivalent sense of the ROTATION_CENTER is set to the mid-point of // the bounds along that axis. // // .SECTION See Also // vtkboneFiniteElementModel vtkboneConstraint // vtkboneSolverParameters vtkboneMaterialTable #ifndef __vtkboneApplyTorsionTest_h #define __vtkboneApplyTorsionTest_h #include "vtkboneApplyTestBase.h" #include "vtkboneWin32Header.h" class VTKBONE_EXPORT vtkboneApplyTorsionTest : public vtkboneApplyTestBase { public: static vtkboneApplyTorsionTest *New(); vtkTypeMacro(vtkboneApplyTorsionTest, vtkboneApplyTestBase); void PrintSelf(ostream& os, vtkIndent indent) override; void PrintParameters(ostream& os, vtkIndent indent); // Description: // Specifies the x,y coordinates of the Twist Axis origin. // Default is 0,0 . vtkSetVector2Macro(TwistAxisOrigin, double); vtkGetVector2Macro(TwistAxisOrigin, double); // Description: // Specifies the rotation angle of the Top surface. Units are radians. // Default is 0.01745, corresponding to 1º. vtkSetMacro(TwistAngle, double); vtkGetMacro(TwistAngle, double); protected: vtkboneApplyTorsionTest(); ~vtkboneApplyTorsionTest(); double TwistAxisOrigin[2]; double TwistAngle; virtual int RequestData(vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector) override; virtual int AddTopAndBottomConstraints(vtkboneFiniteElementModel* model); virtual int AddConvergenceSet(vtkboneFiniteElementModel* model); virtual int AddPostProcessingSets(vtkboneFiniteElementModel* model); virtual int AddInformation(vtkboneFiniteElementModel* model); private: vtkboneApplyTorsionTest(const vtkboneApplyTorsionTest&); // Not implemented void operator=(const vtkboneApplyTorsionTest&); // Not implemented }; #endif
37.282828
84
0.736115
5b974bd9d9676c3063c5d181a10c5ea6274bbb98
2,007
h
C
src/manager/network-link.h
ntsbtz/network-config-manager
5e0199c6fc9168a5b4ab47f930e0a43155c8070b
[ "Apache-2.0" ]
15
2020-07-10T08:39:41.000Z
2022-03-12T19:18:17.000Z
src/manager/network-link.h
ntsbtz/network-config-manager
5e0199c6fc9168a5b4ab47f930e0a43155c8070b
[ "Apache-2.0" ]
7
2019-12-18T06:37:12.000Z
2022-02-15T14:15:44.000Z
src/manager/network-link.h
ntsbtz/network-config-manager
5e0199c6fc9168a5b4ab47f930e0a43155c8070b
[ "Apache-2.0" ]
10
2019-12-11T21:27:29.000Z
2022-03-06T04:37:41.000Z
/* Copyright 2021 VMware, Inc. * SPDX-License-Identifier: Apache-2.0 */ #pragma once #include "alloc-util.h" #include "network-util.h" typedef enum LinkState { LINK_STATE_DOWN, LINK_STATE_UP, _LINK_STATE_MAX, _LINK_STATE_INVALID, } LinkState; typedef struct Link { struct ether_addr mac_address; unsigned short iftype; char name[IFNAMSIZ+1]; char *qdisc; int ifindex; uint8_t operstate; uint32_t mtu; uint32_t master; uint32_t min_mtu; uint32_t max_mtu; uint32_t n_tx_queues; uint32_t n_rx_queues; uint32_t gso_max_size; uint32_t gso_max_segments; uint32_t flags; union { struct rtnl_link_stats64 stats64; struct rtnl_link_stats stats; }; GPtrArray *alt_names; bool contains_mac_address:1; bool contains_mtu:1; bool contains_stats:1; bool contains_stats64:1; } Link; typedef struct Links { GList *links; } Links; void link_unref(Link *l); void links_unref(Links *l); DEFINE_CLEANUP(Link*, link_unref); DEFINE_CLEANUP(Links*, links_unref); int link_get_links(Links **ret); int link_get_one_link(const char *ifname, Link **ret); int link_read_sysfs_attribute(const char *ifname, const char *attribute, char **ret); int link_set_mac_address(const IfNameIndex *ifnameidx, const char *mac_address); int manager_link_get_link_mac_addr(const char *ifname, char **pmac); int link_get_mtu(const char *ifname, uint32_t *mtu); int link_update_mtu(const IfNameIndex *ifnameidx, uint32_t mtu); int link_get_mac_address(const char *ifname, char **mac); int link_set_state(const IfNameIndex *ifnameidx, LinkState state); int link_get_operstate(const char *ifname, char **operstate); int link_remove(const IfNameIndex *ifnameidx); const char *link_operstates_to_name(int id); const char *link_state_to_name(int id); int link_name_to_state(char *name);
25.0875
85
0.692576
a52ee63d0058320b39c4a1490d2c385f3a3aba08
825
h
C
ios/Pods/TuyaSmartBLEKit/ios/TuyaSmartBLEKit.framework/Versions/A/Headers/TuyaSmartBLEManager+Channel.h
Hugo-tuya/tuya-home-sdk-react-native
5041af2e41465df7b5c5a8d329ae102d2672c0c0
[ "MIT" ]
21
2019-03-04T01:21:13.000Z
2021-12-03T20:37:26.000Z
ios/Pods/TuyaSmartBLEKit/ios/TuyaSmartBLEKit.framework/Versions/A/Headers/TuyaSmartBLEManager+Channel.h
ammarkhan967/tuyasmart-home-sdk-react-native
7a754fd4c78b6bf39e18ec4a422cd488553fa945
[ "MIT" ]
39
2019-01-24T02:47:59.000Z
2021-07-07T09:23:14.000Z
ios/Pods/TuyaSmartBLEKit/ios/TuyaSmartBLEKit.framework/Versions/A/Headers/TuyaSmartBLEManager+Channel.h
ammarkhan967/tuyasmart-home-sdk-react-native
7a754fd4c78b6bf39e18ec4a422cd488553fa945
[ "MIT" ]
32
2018-12-28T03:02:55.000Z
2022-02-17T06:00:29.000Z
// // TuyaSmartBLEManager+Channel.h // TuyaSmartBLEKit // // Created by 黄凯 on 2019/2/22. // #import <Foundation/Foundation.h> #import "TuyaSmartBLEManager.h" NS_ASSUME_NONNULL_BEGIN /** ble 大数据通道,针对手环等需要短时间传输大量数据时使用 */ typedef void (^TPBleResultBlock)(NSString *result); @interface TuyaSmartBLEManager (Channel) /** 判断设备是否已连接 check the device is connected. @param uuid 设备id @return connected */ - (BOOL)isBLEChannelDeviceConnect:(NSString *)uuid; /** 判断设备是否已连接 check the device is connected. @param block 回调 @param uuid 设备id */ - (void)setCompletionBlock:(TPBleResultBlock)block uuid:(NSString *)uuid; /** APP 申请启动大数据通道 @param uuid 设备id */ - (void)appApplyLaunch:(NSString *)uuid; /** APP 强制传输终止 @param uuid 设备id */ - (BOOL)appMandatoryTrans:(NSString *)uuid; @end NS_ASSUME_NONNULL_END
15
73
0.722424
a586a7bfc48bac7127b68dc7b935f356fee01ff8
2,494
h
C
devices-framework/riot-app/riot/cpu/stm32l0/include/periph_cpu.h
bench-os/bench-os
38ade08e097ca215f7465047dfa70503af11d612
[ "MIT" ]
1
2020-02-21T09:16:17.000Z
2020-02-21T09:16:17.000Z
extension-framework/riot-app/riot/cpu/stm32l0/include/periph_cpu.h
bench-os/bench-os
38ade08e097ca215f7465047dfa70503af11d612
[ "MIT" ]
null
null
null
extension-framework/riot-app/riot/cpu/stm32l0/include/periph_cpu.h
bench-os/bench-os
38ade08e097ca215f7465047dfa70503af11d612
[ "MIT" ]
1
2020-02-21T09:21:45.000Z
2020-02-21T09:21:45.000Z
/* * Copyright (C) 2015-2017 Freie Universität Berlin * 2017 Inria * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level * directory for more details. */ /** * @ingroup cpu_stm32l0 * @{ * * @file * @brief CPU specific definitions for internal peripheral handling * * @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Alexandre Abadie <alexandre.abadie@inria.fr> * */ #ifndef PERIPH_CPU_H #define PERIPH_CPU_H #include "periph_cpu_common.h" #ifdef __cplusplus extern "C" { #endif /** * @brief Starting address of the CPU ID */ #define CPUID_ADDR (0x1ff80050) /** * @brief Available ports on the STM32L0 family */ enum { PORT_A = 0, /**< port A */ PORT_B = 1, /**< port B */ PORT_C = 2, /**< port C */ PORT_D = 3, /**< port D */ PORT_E = 4, /**< port E */ PORT_H = 7, /**< port H */ }; #ifndef DOXYGEN /** * @brief Override ADC resolution values * @{ */ #define HAVE_ADC_RES_T typedef enum { ADC_RES_6BIT = (0x3 << 3), /**< ADC resolution: 6 bit */ ADC_RES_8BIT = (0x2 << 3), /**< ADC resolution: 8 bit */ ADC_RES_10BIT = (0x1 << 3), /**< ADC resolution: 10 bit */ ADC_RES_12BIT = (0x0 << 3), /**< ADC resolution: 12 bit */ ADC_RES_14BIT = (0xfe), /**< not applicable */ ADC_RES_16BIT = (0xff) /**< not applicable */ } adc_res_t; /** @} */ #endif /* ndef DOXYGEN */ /** * @brief ADC line configuration values */ typedef struct { gpio_t pin; /**< pin to use */ uint8_t chan; /**< internal channel the pin is connected to */ } adc_conf_t; /** * @brief Override the default initial PM blocker * @todo we block all modes per default, until PM is cleanly implemented */ #define PM_BLOCKER_INITIAL { .val_u32 = 0x01010101 } /** * @name EEPROM configuration * @{ */ #define EEPROM_START_ADDR (0x08080000) #if defined(CPU_MODEL_STM32L073RZ) || defined(CPU_MODEL_STM32L072CZ) #define EEPROM_SIZE (6144U) /* 6kB */ #elif defined(CPU_MODEL_STM32L053R8) #define EEPROM_SIZE (2048U) /* 2kB */ #elif defined(CPU_MODEL_STM32L031K6) #define EEPROM_SIZE (1024U) /* 1kB */ #endif /** @} */ #ifdef __cplusplus } #endif #endif /* PERIPH_CPU_H */ /** @} */
25.191919
77
0.579391
a5bcf4a6c28a35582e5ede75a8ce20b49572367b
1,232
h
C
AirCoolControll/AirCoolControll/ModbusDriver.h
TECOLTD/AirCoolControl_Desktop
548f2ad93ec81a3ae058272e6a7d686b9360238c
[ "Unlicense" ]
null
null
null
AirCoolControll/AirCoolControll/ModbusDriver.h
TECOLTD/AirCoolControl_Desktop
548f2ad93ec81a3ae058272e6a7d686b9360238c
[ "Unlicense" ]
null
null
null
AirCoolControll/AirCoolControll/ModbusDriver.h
TECOLTD/AirCoolControl_Desktop
548f2ad93ec81a3ae058272e6a7d686b9360238c
[ "Unlicense" ]
2
2016-04-24T10:24:20.000Z
2016-11-07T17:39:19.000Z
#ifndef MODBUSDRIVER_H #define MODBUSDRIVER_H #include <QObject> #include <map> #include <memory> #include <functional> #include "VersionStorage.h" #include "ModbusPuller.h" #include "DeviceInfo.h" class ModbusDriver : public QObject { Q_OBJECT public: typedef std::function<void(DeviceInfoShared)> detectionCallback; ModbusDriver(const QString& name,QObject *parent = NULL); ~ModbusDriver(); void addPullerReadTask(PullerTaskShared a_task); void requestDeviceAproval(quint16 id, int speed); void writeRegister(quint16 id, int speed, quint16 regNumber, quint16 value); void setCoil(quint16 id, int speed, quint16 regNumber, bool state); bool readyToWork() const; void removeTaskWithID(int id); void onDeviceDetected(DeviceInfoShared a_info); const QString& getName(void) const { return m_currentPortName; } signals: void deviceDetected(DeviceInfoShared); void connectionFail(); private slots: void UARTfail(void); private: ModbusPuller m_puller; QString m_currentPortName; }; typedef std::shared_ptr<ModbusDriver> ModbusDriverShared; #include "DeviceInfo.h" #endif // MODBUSDRIVER_H
25.666667
81
0.707792
77e1466ac09d1c258e14e0fcf3f7894183055ae3
1,792
h
C
classdump_Safari/TabDialogConfiguration.h
inket/smartPins
2f9a68dccf8b605f863a680488ed4c6c428f4a52
[ "MIT" ]
2
2016-09-29T09:50:04.000Z
2016-09-29T19:39:11.000Z
classdump_Safari/TabDialogConfiguration.h
inket/smartPins
2f9a68dccf8b605f863a680488ed4c6c428f4a52
[ "MIT" ]
null
null
null
classdump_Safari/TabDialogConfiguration.h
inket/smartPins
2f9a68dccf8b605f863a680488ed4c6c428f4a52
[ "MIT" ]
null
null
null
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import <objc/NSObject.h> #import <Safari/NSCopying-Protocol.h> @class NSArray, NSString; __attribute__((visibility("hidden"))) @interface TabDialogConfiguration : NSObject <NSCopying> { BOOL _hasCancelButton; BOOL _hasPromptField; NSString *_message; NSArray *_buttonLabels; NSString *_originStringForAccessibility; NSString *_promptFieldDefaultResponse; } + (id)javaScriptPromptDialogConfigurationWithMessage:(id)arg1 defaultResponse:(id)arg2 originStringForAccessibility:(id)arg3; + (id)javaScriptConfirmDialogConfigurationWithMessage:(id)arg1 originStringForAccessibility:(id)arg2; + (id)javaScriptAlertDialogConfigurationWithMessage:(id)arg1 originStringForAccessibility:(id)arg2; @property(readonly, copy, nonatomic) NSString *promptFieldDefaultResponse; // @synthesize promptFieldDefaultResponse=_promptFieldDefaultResponse; @property(readonly, nonatomic) BOOL hasPromptField; // @synthesize hasPromptField=_hasPromptField; @property(readonly, copy, nonatomic) NSString *originStringForAccessibility; // @synthesize originStringForAccessibility=_originStringForAccessibility; @property(readonly, nonatomic) NSArray *buttonLabels; // @synthesize buttonLabels=_buttonLabels; @property(readonly, nonatomic) BOOL hasCancelButton; // @synthesize hasCancelButton=_hasCancelButton; @property(readonly, copy, nonatomic) NSString *message; // @synthesize message=_message; - (void).cxx_destruct; - (id)copyWithZone:(struct _NSZone *)arg1; - (id)initWithMessage:(id)arg1 hasCancelButton:(BOOL)arg2 buttonLabels:(id)arg3 originStringForAccessibility:(id)arg4 hasPromptField:(BOOL)arg5 promptFieldDefaultResponse:(id)arg6; @end
45.948718
180
0.802455
e338202244a44f792c2526046f064d40d4878b8b
318
c
C
2708.c
edufcarvalho/URI
99491ef0aed3bd25024873eac24256e7327a31ca
[ "MIT" ]
2
2020-09-17T01:31:20.000Z
2020-10-19T21:24:18.000Z
2708.c
edufcarvalho/URI
99491ef0aed3bd25024873eac24256e7327a31ca
[ "MIT" ]
1
2020-09-17T22:00:05.000Z
2020-09-30T07:21:47.000Z
2708.c
edufcarvalho/URI
99491ef0aed3bd25024873eac24256e7327a31ca
[ "MIT" ]
null
null
null
#include <stdio.h> int main(void) { char input[7]; int jeeps = 0, people = 0; while (scanf("%s", input), input[0] != 'A') { int tmp; scanf("%d", &tmp); if (input[0] == 'S') people += tmp, jeeps++; else people -= tmp, jeeps--; } printf("%d\n%d\n", people, jeeps); }
22.714286
52
0.471698
64c52d8a59820f832112f15cf7f0b06248a557f6
2,028
h
C
opts.h
neilgonzalez/diff
562236408c8e93150e96e8e628bf13bd7baf4d8b
[ "MIT" ]
null
null
null
opts.h
neilgonzalez/diff
562236408c8e93150e96e8e628bf13bd7baf4d8b
[ "MIT" ]
null
null
null
opts.h
neilgonzalez/diff
562236408c8e93150e96e8e628bf13bd7baf4d8b
[ "MIT" ]
null
null
null
#ifndef OPTS_H_ #define OPTS_H_ #define AUTHOR "Neil Gonzalez" #define LICENSE "GPL v2" #define VERSION "1.0.0" void print_version() { printf("%s\n", VERSION);} void print_author() { printf("%s\n", AUTHOR);} void print_license() { printf("%s\n", LICENSE);} int compare(const char* argv, char* argv2) { return (strcmp(argv, argv2) == 0) ? 1 : 0;} int target_flags(int argc, const char* argv[], FILE* ptr1, FILE* ptr2) { for(int i = 0; i < argc; i++) { //-v version if (compare(argv[i], "-v")) { print_version(); print_author(); print_license(); return 1; } //-q difference else if(compare(argv[i], "-q")) { if (different(ptr1, ptr2)) { printf("files are different...\n"); return 2; } } //-s identical else if (compare(argv[i], "-s")) { if(same(ptr1, ptr2)) { printf("files are similar...\n"); return 3; } } else if (compare(argv[i], "-s") && compare(argv[i], "-q")) { if (same(ptr1, ptr2)) { printf("files are the same...\n"); return 4; }else { printf("files are different\n"); return 4; } } //-y side by side unless --suppress-common-lines is set //then it shows onyl arrow paras //'\' for lines different in common paras else if (compare(argv[i], "-y")){ if (compare(argv[i], "--suppress-common-lines")) { return 6; } else if (compare(argv[i], "--side-by-side")) { return 5; } else if(compare(argv[i], "--left-column")) { return 7; } } else if (compare(argv[i], "-h")) { usageBanner(); } } return 0; } #endif
24.731707
88
0.441815
b9fabb1e79884ac3be0760eb11841db3cd9263b7
991
h
C
Objective-C++/LinkList/LinkList.h
wsv587/Data-Structure-and-Algorithms
c9eeccf3e5271cb053d74dcf5e552611ed19f632
[ "MIT" ]
null
null
null
Objective-C++/LinkList/LinkList.h
wsv587/Data-Structure-and-Algorithms
c9eeccf3e5271cb053d74dcf5e552611ed19f632
[ "MIT" ]
null
null
null
Objective-C++/LinkList/LinkList.h
wsv587/Data-Structure-and-Algorithms
c9eeccf3e5271cb053d74dcf5e552611ed19f632
[ "MIT" ]
null
null
null
// // LinkList.h // LinkList // // Created by sw on 2019/4/19. // Copyright © 2019 WS. All rights reserved. // #import <Foundation/Foundation.h> #import "Node.h" @interface LinkList : NSObject @property(nonatomic) Node *first; // 链表的头结点,此处设置为k读写是为了在category中可访问 @property(nonatomic, readonly) NSUInteger size; // 链表的长度 // 初始化操作 + (instancetype)linklist; // 基本的增删改查操作 // 添加元素 - (void)add:(NSObject *)obj; // 移除末尾元素 - (void)pop; // 移除指定元素 - (void)removeObject:(NSObject *)obj; // 移除某个索引下的元素,然后返回移除的元素 - (NSObject *)removeObjectAtIndex:(NSInteger)idx; // 插入元素 - (void)insert:(NSObject *)obj atIndex:(NSInteger)idx; // 获取某个索引下的元素 - (NSObject *)objectAtIndex:(NSInteger)idx; // 获取元素的索引 - (NSInteger)indexOfObject:(NSObject *)obj; // 更新某个索引下的元素 - (NSObject *)setObject:(NSObject *)obj atIndex:(NSInteger)idx; // 是否包含某个元素 - (BOOL)contains:(NSObject *)obj; // 清空ArrayList - (void)clear; // 判断ArrayList是否为空 - (BOOL)isEmpty; // 获取ArrayList的大小 - (NSUInteger)size; @end
20.645833
86
0.690212
6b7ed03107da07168104b54673f5f32164fcc3da
758
h
C
src/shader/CoordinateSystemOverlay.h
tody411/SimpleMeshViewer
25aa62371bf815316244387cb1a69a27b47f80c0
[ "MIT" ]
null
null
null
src/shader/CoordinateSystemOverlay.h
tody411/SimpleMeshViewer
25aa62371bf815316244387cb1a69a27b47f80c0
[ "MIT" ]
null
null
null
src/shader/CoordinateSystemOverlay.h
tody411/SimpleMeshViewer
25aa62371bf815316244387cb1a69a27b47f80c0
[ "MIT" ]
null
null
null
/*! \file CoordinateSystemOverlay.h \author Tody CoordinateSystemOverlay definition. \date 2015/12/17 */ #ifndef COORDINATESYSTEMOVERLAY_H #define COORDINATESYSTEMOVERLAY_H #include "BaseOverlay.h" #include "ModelView.h" #include "CameraTool.h" //! CoordinateSystemOverlay implementation. class CoordinateSystemOverlay : public BaseOverlay { public : //! Constructor. CoordinateSystemOverlay ( Scene* scene, CameraTool* cameraTool, ModelView* view ) : BaseOverlay ( "CoordinateSystem", scene ), _cameraTool ( cameraTool ), _view ( view ) {} //! Destructor. virtual ~CoordinateSystemOverlay() {} void renderViewOverlayImp(); private: CameraTool* _cameraTool; ModelView* _view; }; #endif
18.487805
95
0.708443
753b6f6b822396860ae599d68722fb50034c16d3
228
h
C
Aplus-SaaS/ZYClass/HomeController/Controller/ZYHomeController.h
CentaFrameWork/Aplus-SaaS
18a29aa32cc31996b85168c6871df41c32d1e977
[ "MIT" ]
null
null
null
Aplus-SaaS/ZYClass/HomeController/Controller/ZYHomeController.h
CentaFrameWork/Aplus-SaaS
18a29aa32cc31996b85168c6871df41c32d1e977
[ "MIT" ]
null
null
null
Aplus-SaaS/ZYClass/HomeController/Controller/ZYHomeController.h
CentaFrameWork/Aplus-SaaS
18a29aa32cc31996b85168c6871df41c32d1e977
[ "MIT" ]
null
null
null
// // ZYHomeController.h // Aplus-SaaS // // Created by Admin on 2018/8/22. // Copyright © 2018年 CentaLine. All rights reserved. // #import "ZYBaseViewController.h" @interface ZYHomeController : ZYBaseViewController @end
16.285714
53
0.719298
1d2f3d466cd8bf64193be68efe7119bf84ce3e0a
798
h
C
src/rl_dumper/libs/include/bakkesmod/wrappers/GameObject/RumbleComponent/DemolishPickup.h
thoo0224/rl_dumper
b8ccc4eeda87428c2d85db4f48588e5eb1d8f8ba
[ "MIT" ]
5
2020-05-20T00:24:28.000Z
2021-05-01T23:22:53.000Z
src/rl_dumper/libs/include/bakkesmod/wrappers/GameObject/RumbleComponent/DemolishPickup.h
thoo0224/rl_dumper
b8ccc4eeda87428c2d85db4f48588e5eb1d8f8ba
[ "MIT" ]
6
2020-02-02T06:58:07.000Z
2021-11-12T16:29:39.000Z
src/rl_dumper/libs/include/bakkesmod/wrappers/GameObject/RumbleComponent/DemolishPickup.h
thoo0224/rl_dumper
b8ccc4eeda87428c2d85db4f48588e5eb1d8f8ba
[ "MIT" ]
2
2020-05-20T15:13:39.000Z
2020-08-09T15:23:59.000Z
#pragma once template<class T> class ArrayWrapper; template<typename T> class StructArrayWrapper; #include "../../WrapperStructs.h" #include "../.././GameObject/RumbleComponent/RumblePickupComponentWrapper.h" class BAKKESMOD_PLUGIN_IMPORT DemolishPickup : public RumblePickupComponentWrapper { public: CONSTRUCTORS(DemolishPickup) //AUTO-GENERATED FROM FIELDS unsigned char GetDemolishTarget(); void SetDemolishTarget(unsigned char newDemolishTarget); unsigned char GetDemolishSpeed(); void SetDemolishSpeed(unsigned char newDemolishSpeed); unsigned char GetOldTarget(); void SetOldTarget(unsigned char newOldTarget); unsigned char GetOldSpeed(); void SetOldSpeed(unsigned char newOldSpeed); //AUTO-GENERATED FUNCTION PROXIES void PickupEnd(); void PickupStart(); private: PIMPL };
30.692308
84
0.805764
d4f50bc475d52afb88d4977bdc4f74a80176a7e6
1,940
h
C
ZF/ZFCore/zfsrc/ZFCore/ZFObjectDef/ZFCoreType_IODef.h
ZFFrameworkDist/ZFFramework
6b498e7b95ee6d6aaa28d8369eef8c2ff94daaf7
[ "MIT" ]
57
2016-06-12T11:05:55.000Z
2021-05-22T13:12:17.000Z
ZF/ZFCore/zfsrc/ZFCore/ZFObjectDef/ZFCoreType_IODef.h
ZFFrameworkDist/ZFFramework
6b498e7b95ee6d6aaa28d8369eef8c2ff94daaf7
[ "MIT" ]
null
null
null
ZF/ZFCore/zfsrc/ZFCore/ZFObjectDef/ZFCoreType_IODef.h
ZFFrameworkDist/ZFFramework
6b498e7b95ee6d6aaa28d8369eef8c2ff94daaf7
[ "MIT" ]
20
2016-05-26T04:47:37.000Z
2020-12-13T01:39:39.000Z
/** * @file ZFCoreType_IODef.h * @brief type io with io callbacks */ #ifndef _ZFI_ZFCoreType_IODef_h_ #define _ZFI_ZFCoreType_IODef_h_ #include "ZFIOCallback.h" #include "ZFSerializable.h" #include "ZFFilterForZFClass.h" #include "ZFFilterForZFMethod.h" #include "ZFFilterForZFProperty.h" ZF_NAMESPACE_GLOBAL_BEGIN // ============================================================ // util #define _ZFP_ZFCoreType_IODef_outputObjectPointer() \ {if(v) {output << v->objectInfo();} else {output.execute(ZFTOKEN_zfnull);}} // ============================================================ // common output for core types ZFOUTPUT_TYPE_TEMPLATE(ZFM_EXPAND(typename T_Public, typename T_Internal), ZFM_EXPAND(ZFFilterBase<T_Public, T_Internal>), {output << v.objectInfo();}) ZFOUTPUT_TYPE_TEMPLATE(typename T_Element, ZFCoreArray<T_Element>, {output << v.objectInfo();}) ZFOUTPUT_TYPE_TEMPLATE(typename T_Element, ZFCoreQueuePOD<T_Element>, {output << v.objectInfo();}) ZFOUTPUT_TYPE(ZFCoreMap, {output << v.objectInfo();}) ZFOUTPUT_TYPE(ZFCorePointerBase, {output << v.objectInfo();}) // ============================================================ // common output for ZFObject types ZFOUTPUT_TYPE(ZFFilterForZFClass, {output << v.objectInfo();}) ZFOUTPUT_TYPE(ZFObject *, _ZFP_ZFCoreType_IODef_outputObjectPointer()) ZFOUTPUT_TYPE(const ZFClass *, _ZFP_ZFCoreType_IODef_outputObjectPointer()) ZFOUTPUT_TYPE(const ZFMethod *, _ZFP_ZFCoreType_IODef_outputObjectPointer()) ZFOUTPUT_TYPE(const ZFProperty *, _ZFP_ZFCoreType_IODef_outputObjectPointer()) ZFOUTPUT_TYPE(ZFObserverHolder, {output << v.objectInfo();}) ZFOUTPUT_TYPE(ZFListenerData, {output << v.objectInfo();}) ZFOUTPUT_TYPE(ZFAny, {output << v.toObject();}) ZF_NAMESPACE_GLOBAL_END #endif // #ifndef _ZFI_ZFCoreType_IODef_h_
32.333333
79
0.653093
0e995a95813aeaea50bce695bfbe0a85b1bf435f
8,080
h
C
src/mason/Dictionary.h
paulhoux/mason
5c505e14fa4b4e043818d2ddbd75149cf10f50ab
[ "BSD-2-Clause" ]
null
null
null
src/mason/Dictionary.h
paulhoux/mason
5c505e14fa4b4e043818d2ddbd75149cf10f50ab
[ "BSD-2-Clause" ]
null
null
null
src/mason/Dictionary.h
paulhoux/mason
5c505e14fa4b4e043818d2ddbd75149cf10f50ab
[ "BSD-2-Clause" ]
null
null
null
/* Copyright (c) 2014, Richard Eakin - 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 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. */ #pragma once #include "cinder/Filesystem.h" #include "cinder/DataSource.h" #include "cinder/Exception.h" #include "cinder/System.h" #include "cinder/Vector.h" #include "cinder/Color.h" #include "cinder/Rect.h" #include <memory> #include <map> #include <boost/any.hpp> #include "mason/Mason.h" namespace mason { typedef std::shared_ptr<class Dictionary> DictionaryRef; //! Object for storing dynamic data in a hierarchical form, key = string, value = any. class MA_API Dictionary { public: //! Constructs an empty Dictionary on the stack Dictionary(); //! Creates an empty Dictionary and returns it in a shared_ptr static DictionaryRef create() { return std::make_shared<Dictionary>(); } template<typename DataT> static Dictionary convert( const DataT &data ); template<typename DataT> static Dictionary convert( const ci::DataSourceRef &dataSource ); template<typename DataT> static Dictionary convert( const ci::fs::path &filePath ); // TODO: possible to reuse above converts but store in shared_ptr? // template<typename DataT, typename... Args> // static DictionaryRef convertShared( Args... ) template<typename T> void set( const std::string &key, const T &value ); //! Returns a copy of the value associated with T. Some type conversions are allowed (like double -> float), hency why a copy is necessary. //! A DictionaryExc is thrown if the key doesn't exist or it can't be converted to type T. template<typename T> T get( const std::string &key ) const; //! Same as above but will return \a defaultValue if the key doesn't exist. //! A DictionaryExc is thrown if the key exists but can't be converted to type T. template<typename T> T get( const std::string &key, const T &defaultValue ) const; //! Returns a reference to the value associated with T. The typeid must match exactly. template<typename T> const T& getStrict( const std::string &key ) const; //! Returns a reference to the value associated with T. The typeid must match exactly. Returns \a defaultValue if the key doesn't exist. template<typename T> const T& getStrict( const std::string &key, const T &defaultValue ) const; const std::type_info& getType( const std::string &key ) const; bool contains( const std::string &key ) const; // TODO: need to sort out what is happening with return versus const-ref before these are useful // - could use getStrict() but more likely to throw // template<typename T> // T& operator[]( const std::string &key ) { return get<T>( key ); } // template<typename T> // const T& operator[]( const std::string &key ) const { return get<T>( key ); } size_t getSize() const { return mData.size(); } std::vector<std::string> getAllKeys() const; bool isEmpty() const { return mData.empty(); } // TODO: implement //std::string toString() const; private: std::map<std::string, boost::any> mData; }; class MA_API DictionaryExc : public ci::Exception { public: DictionaryExc( const std::string &description ) : Exception( description ) { } }; class MA_API DictionaryBadTypeExc : public DictionaryExc { public: DictionaryBadTypeExc( const std::string &key, const boost::any &value, const std::type_info &typeInfo ) : DictionaryExc( "" ) { std::string descr = "Failed to convert value for key '" + key + "', from native type '"; descr += ci::System::demangleTypeName( value.type().name() ) + "' to requested type '"; descr += ci::System::demangleTypeName( typeInfo.name() ) + "'."; setDescription( descr ); } }; // ---------------------------------------------------------------------------------------------------- // Implementation // ---------------------------------------------------------------------------------------------------- namespace detail { // TODO: move getValue() to private Dictionary::getValue() for clarity template<typename T> bool getValue( const boost::any &value, T *result ) { if( value.type() != typeid( T ) ) { return false; } *result = boost::any_cast<T>( value ); return true; } template<typename T> bool getValue( const boost::any &value, std::vector<T> *result ) { const auto castedVector = boost::any_cast<std::vector<boost::any>> ( &value ); if( ! castedVector ) return false; result->resize( castedVector->size() ); for( size_t i = 0; i < result->size(); i++ ) { getValue( (*castedVector)[i], &( (*result)[i] ) ); } return true; } bool MA_API getValue( const boost::any &value, float *result ); bool MA_API getValue( const boost::any &value, double *result ); bool MA_API getValue( const boost::any &value, size_t *result ); bool MA_API getValue( const boost::any &value, ci::vec2 *result ); bool MA_API getValue( const boost::any &value, ci::vec3 *result ); bool MA_API getValue( const boost::any &value, ci::vec4 *result ); bool MA_API getValue( const boost::any &value, ci::Rectf *result ); bool MA_API getValue( const boost::any &value, ci::Color *result ); bool MA_API getValue( const boost::any &value, ci::ColorA *result ); bool MA_API getValue( const boost::any &value, ci::fs::path *result ); bool MA_API getValue( const boost::any &value, std::vector<boost::any> *result ); } // namespace mason::detail template<typename T> void Dictionary::set( const std::string &key, const T &value ) { mData[key] = value; } template<typename T> T Dictionary::get( const std::string &key ) const { auto it = mData.find( key ); if( it == mData.end() ) { throw DictionaryExc( "no key named '" + key + "'" ); } T result; const auto &value = it->second; if( ! detail::getValue( value, &result ) ) { throw DictionaryBadTypeExc( key, value, typeid( T ) ); } return result; } template<typename T> T Dictionary::get( const std::string &key, const T &defaultValue ) const { auto it = mData.find( key ); if( it == mData.end() ) { return defaultValue; } T result; const auto &value = it->second; if( ! detail::getValue( value, &result ) ) { throw DictionaryBadTypeExc( key, value, typeid( T ) ); } return result; } template<typename T> const T& Dictionary::getStrict( const std::string &key ) const { auto it = mData.find( key ); if( it == mData.end() ) { throw DictionaryExc( "no key named '" + key + "'" ); } const auto &value = it->second; if( value.type() != typeid( T ) ) { throw DictionaryBadTypeExc( key, value, typeid( T ) ); } return boost::any_cast<const T&>( value ); } template<typename T> const T& Dictionary::getStrict( const std::string &key, const T &defaultValue ) const { auto it = mData.find( key ); if( it == mData.end() ) { return defaultValue; } const auto &value = it->second; if( value.type() != typeid( T ) ) { throw DictionaryBadTypeExc( key, value, typeid( T ) ); } return boost::any_cast<const T&>( value ); } } // namespace mason
32.32
140
0.687871
3dc7b391d79868eea80790f96e9421db22cdf768
540
h
C
Source/Scanning/Formatter/TokenizerFormatter.h
GoPlan/cldeparser
430bd983fa2c448680f3b7452c40ebb4c1ca3048
[ "MIT" ]
null
null
null
Source/Scanning/Formatter/TokenizerFormatter.h
GoPlan/cldeparser
430bd983fa2c448680f3b7452c40ebb4c1ca3048
[ "MIT" ]
null
null
null
Source/Scanning/Formatter/TokenizerFormatter.h
GoPlan/cldeparser
430bd983fa2c448680f3b7452c40ebb4c1ca3048
[ "MIT" ]
null
null
null
// // Created by LE, Duc Anh on 8/23/15. // #ifndef CLDEPARSER_SCANNING_FORMATTER_TOKENIZERFORMATTER_H #define CLDEPARSER_SCANNING_FORMATTER_TOKENIZERFORMATTER_H #include "../../Common/IPrintFormatter.h" namespace CLDEParser { namespace Scanning { namespace Formatter { struct TokenizerFormatter : public Common::IPrintFormatter { virtual std::string Print(const Common::IPrintable &printable) const; }; } } } #endif //CLDEPARSER_SCANNING_FORMATTER_TOKENIZERFORMATTER_H
23.478261
85
0.705556
cedf00063fc9040ecf6da5345eb74868a7184c85
2,623
h
C
archive/editor/window.h
brettonw/Two
5cd121c94388f4465157c770bde7ec369f1f5f97
[ "MIT" ]
null
null
null
archive/editor/window.h
brettonw/Two
5cd121c94388f4465157c770bde7ec369f1f5f97
[ "MIT" ]
null
null
null
archive/editor/window.h
brettonw/Two
5cd121c94388f4465157c770bde7ec369f1f5f97
[ "MIT" ]
null
null
null
//------------------------------------------------------------------------------ // Copyright (C) 1997-2000 Bretton Wade // All Rights Reserved //------------------------------------------------------------------------------ #ifndef _BW_WINDOW_H_ #define _BW_WINDOW_H_ //------------------------------------------------------------------------------ // includes //------------------------------------------------------------------------------ #ifndef _BW_TEXT_H_ #include "text.h" #endif // _BW_TEXT_H_ //------------------------------------------------------------------------------ // class definitions //------------------------------------------------------------------------------ class Window { public: Window (const Text& className, const Text& windowName, DWORD windowStyle, DWORD extendedWindowStyle = 0, sInt x = CW_USEDEFAULT, sInt y = 0, sInt width = CW_USEDEFAULT, sInt height = 0, Window* parent = 0, uInt id = 0); virtual ~Window (void); virtual bool OnCloseWindow (void); virtual void Pulse (void); bool OnPaintWindow (void); virtual bool OnPaintWindow (PAINTSTRUCT& paint) = 0; virtual bool OnEraseWindow (HDC dc); bool OnKeyDown (LPMSG message); virtual bool OnKeyDown (sInt virtualKeyCode, uInt data); virtual bool OnCharDown (uInt keyChar, sInt data); virtual bool OnCommand (sInt command); virtual bool OnMouseDown (uInt which, const POINTS& point, uInt flags); virtual bool OnMouseMove (const POINTS& point, uInt flags); virtual bool OnMouseUp (uInt which, const POINTS& point, uInt flags); virtual bool OnActivate (void); virtual bool OnDeactivate (void); virtual bool OnSizingWindow (sInt code, RECT* rect); virtual void SizeWindow (sInt width, sInt height); void SizeToChildren (RECT* rect); virtual void SetCursor (void); void ShowWindow (bool show = true); void SetName (const Text& windowName); virtual Text GetWindowClassName (void) = 0; virtual HACCEL GetWindowAccelerators (void) = 0; static void RegisterWindowClass (DWORD classStyle, WNDPROC windowProc, const Text& className, uInt menuID = 0); static LRESULT CALLBACK WindowProc (HWND window, UINT message, WPARAM wParam, LPARAM lParam); public: const enum { LEFT_BUTTON = 1, RIGHT_BUTTON = 2, MIDDLE_BUTTON = 4 }; protected: Window (const Window& window); protected: HWND myWindow; sInt myWidthDelta; sInt myHeightDelta; uInt myMouseIsDown; POINTS myMouseDownPoint; }; //------------------------------------------------------------------------------ #endif // _BW_WINDOW_H_
38.573529
221
0.556996
e1a763c2c69b8ebe508aa48bc06bb4a435518a57
5,340
c
C
test/m88k/loader.c
ismaell/libcpu
3a82a1ab0b99e439e6fbcafca71e9d3d7fe06b12
[ "BSD-2-Clause" ]
277
2015-01-04T23:33:37.000Z
2022-03-24T20:38:51.000Z
test/m88k/loader.c
farmdve/libcpu
d624f5863f49b059726bce83e4da944ed4b4764c
[ "BSD-2-Clause" ]
7
2015-02-18T12:41:18.000Z
2021-08-21T14:07:53.000Z
test/m88k/loader.c
farmdve/libcpu
d624f5863f49b059726bce83e4da944ed4b4764c
[ "BSD-2-Clause" ]
44
2015-02-03T09:08:14.000Z
2022-03-14T16:35:31.000Z
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "xec-debug.h" #include "xec-mmap.h" #include "xec-byte-order.h" #include "m88k-context.h" #include "loader.h" static void *g_ldr_log = NULL; struct coff_aouthdr g_ahdr; aout_header_t g_exec; static int mapin(xec_mem_if_t *mem_if, xec_mmap_t *mm, aout_header_t const *ah) { void const *bytes; void *text; void *data; xec_mem_flg_t mf; g_ahdr.tstart = N_TXTADDR(*ah); g_ahdr.dstart = N_DATADDR(*ah); g_ahdr.tsize = ah->a_text; g_ahdr.dsize = ah->a_data; g_ahdr.bsize = ah->a_bss; bytes = xec_mmap_get_bytes(mm); mf = 0; text = (void *)xec_mem_gtoh(mem_if, g_ahdr.tstart, &mf); if (mf != 0) return LOADER_INVALID_ADDRESS; memcpy(text, (void *)(uintptr_t)bytes, ah->a_text); data = (void *)xec_mem_gtoh(mem_if, g_ahdr.dstart, &mf); if (mf != 0) return LOADER_INVALID_ADDRESS; memcpy(data, (void *)((uintptr_t)bytes + ah->a_text), ah->a_data); return LOADER_SUCCESS; } static void aout_dump_sections(aout_header_t const *ah) { unsigned long entry; XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, " .text start = %08lx size = %08lx offset = %08lx", (unsigned long)N_TXTADDR(*ah), (unsigned long)ah->a_text, (unsigned long)N_TXTOFF(*ah)); XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, " .data start = %08lx size = %08lx offset = %08lx", (unsigned long)N_DATADDR(*ah), (unsigned long)ah->a_data, (unsigned long)N_DATOFF(*ah)); XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, " .bss start = %08lx size = %08lx", (unsigned long)N_BSSADDR(*ah), (unsigned long)ah->a_bss); entry = (unsigned long)ah->a_entry; XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, " entry point = %08lx", entry); g_ahdr.entry = entry; } static void aout_swap(aout_header_t const *in, aout_header_t *out) { out->a_midmag = xec_byte_swap_big_to_host32(in->a_midmag); out->a_text = xec_byte_swap_big_to_host32(in->a_text); out->a_data = xec_byte_swap_big_to_host32(in->a_data); out->a_bss = xec_byte_swap_big_to_host32(in->a_bss); out->a_syms = xec_byte_swap_big_to_host32(in->a_syms); out->a_entry = xec_byte_swap_big_to_host32(in->a_entry); out->a_trsize = xec_byte_swap_big_to_host32(in->a_trsize); out->a_drsize = xec_byte_swap_big_to_host32(in->a_drsize); } static int aout_process(xec_mem_if_t *mem_if, xec_mmap_t *mm, aout_header_t const *ah) { int rc; m88k_uintptr_t pc; aout_header_t sah; XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, "Found 88K a.out executable signature.", 0); XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, "Sections = %u", 3); aout_swap(ah, &sah); aout_dump_sections(&sah); pc = sah.a_entry; rc = mapin(mem_if, mm, &sah); if (rc == 0) memcpy(&g_exec, &sah, sizeof (sah)); return rc; } static int coff_process(xec_mem_if_t *mem_if, xec_mmap_t *mm, struct coff_filehdr const *fh) { struct coff_aouthdr const *ah; struct coff_secthdr const *sh; uint8_t const *data; m88k_uintptr_t pc; size_t n; size_t toff = 0; ah = (struct coff_aouthdr const *)(fh + 1); sh = (struct coff_secthdr const *)(ah + 1); XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, "Found 88open BCS COFF executable signature.", 0); XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, "Sections = %u", xec_byte_swap_big_to_host16(fh->f_nscns)); aout_dump_sections((aout_header_t const *)ah); for (n = 0; n < xec_byte_swap_big_to_host16(fh->f_nscns); n++) { XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, "section #%u: %s", n, sh[n].s_name); XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, " paddr = %08lx", xec_byte_swap_big_to_host32(sh[n].s_paddr)); XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, " vaddr = %08lx", xec_byte_swap_big_to_host32(sh[n].s_vaddr)); XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, " filoff = %08lx", xec_byte_swap_big_to_host32(sh[n].s_scnptr)); if (strcmp(sh[n].s_name, ".text") == 0) toff = xec_byte_swap_big_to_host32(sh[n].s_scnptr); } XEC_ASSERT(NULL, toff != 0); pc = xec_byte_swap_big_to_host32(ah->tstart); data = ((uint8_t const *)fh) + toff; return aout_process(mem_if, mm, (aout_header_t const *)ah); } void loader_init(void) { if (g_ldr_log == NULL) g_ldr_log = xec_log_register("loader"); } int loader_load(xec_mem_if_t *mem_if, char const *path) { int rc; xec_mmap_t *mm; struct coff_filehdr const *fh; mm = xec_mmap_create_with_file(path, 0, XEC_MMAP_WHOLE, XEC_MMAP_READ); if (mm == NULL) { XEC_LOG (g_ldr_log, XEC_LOG_FATAL, XEC_LOG_DONTEXIT, "Failed opening `%s' or cannot map it.", path); return LOADER_MAP_FAIL; } XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, "Opened file `%s'", path); XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, " Base Pointer = %p", xec_mmap_get_bytes(mm)); XEC_LOG(g_ldr_log, XEC_LOG_INFO, 0, " Size = %lu", (unsigned long)xec_mmap_get_size(mm)); fh = (struct coff_filehdr const *)xec_mmap_get_bytes(mm); switch(xec_byte_swap_big_to_host16(fh->f_magic)) { case COFF_MAGIC_M88K: rc = coff_process(mem_if, mm, fh); break; case 0231: /* OpenBSD/m88k a.out magic */ rc = aout_process(mem_if, mm, (aout_header_t const *)fh); break; default: XEC_LOG(g_ldr_log, XEC_LOG_FATAL, XEC_LOG_DONTEXIT, "File `%s' is not an 88open BCS COFF nor 88k a.out executable.", path); rc = LOADER_UNSUPPORTED; } xec_mmap_free(mm); return rc; }
26.7
126
0.685206
6daba41fc90f0f6a3c7b1c0b9819f0bfdea92de1
2,325
c
C
auto-gen/oop/inheritance/grandgirl.c
enterxor/Design-Patterns-in-C
5c1fd3d8b6a337a60d57b597560e4757ceecfde7
[ "MIT" ]
null
null
null
auto-gen/oop/inheritance/grandgirl.c
enterxor/Design-Patterns-in-C
5c1fd3d8b6a337a60d57b597560e4757ceecfde7
[ "MIT" ]
null
null
null
auto-gen/oop/inheritance/grandgirl.c
enterxor/Design-Patterns-in-C
5c1fd3d8b6a337a60d57b597560e4757ceecfde7
[ "MIT" ]
null
null
null
/** * grandgirl.c 2014-05-03 15:06:28 * anonymouse(anonymouse@email) * * Copyright (C) 2000-2014 All Right Reserved * * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A * PARTICULAR PURPOSE. * * Auto generate for Design Patterns in C */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <mycommon.h> #include <myobj.h> #include "grandgirl.h" /** called by free(): put resources, forward to super. */ static void grandgirl_ops__destructor(struct parent *parent) { printf("grandgirl::_destructor()\n"); CLASS_SUPER(parent, _destructor); } /** free memory after call destructor(). */ static void grandgirl_ops_free(struct parent *parent) { struct grandgirl *a_grandgirl = container_of(parent, typeof(*a_grandgirl), child.parent); parent__destructor(parent); printf("grandgirl::free()\n"); free(a_grandgirl); } static void grandgirl_ops_pub_v_func1(struct parent *parent) { /*struct grandgirl *a_grandgirl = container_of(parent, typeof(*a_grandgirl), child.parent); */ printf("grandgirl::pub_v_func1()\n"); } static void grandgirl_ops_pub_v_func2(struct parent *parent) { /*struct grandgirl *a_grandgirl = container_of(parent, typeof(*a_grandgirl), child.parent); */ printf("grandgirl::pub_v_func2()\n"); } static void grandgirl_ops_pri_v_func3(struct parent *parent) { /*struct grandgirl *a_grandgirl = container_of(parent, typeof(*a_grandgirl), child.parent); */ printf("grandgirl::pri_v_func3()\n"); } static void grandgirl_ops_pri_v_func4(struct parent *parent) { /*struct grandgirl *a_grandgirl = container_of(parent, typeof(*a_grandgirl), child.parent); */ printf("grandgirl::pri_v_func4()\n"); } static struct parent_ops parent_ops = { ._destructor = grandgirl_ops__destructor, .free = grandgirl_ops_free, .pub_v_func1 = grandgirl_ops_pub_v_func1, .pub_v_func2 = grandgirl_ops_pub_v_func2, .pri_v_func3 = grandgirl_ops_pri_v_func3, .pri_v_func4 = grandgirl_ops_pri_v_func4, }; void grandgirl_init(struct grandgirl *grandgirl) { memset(grandgirl, 0, sizeof(*grandgirl)); child_init(&grandgirl->child); CLASS_OPS_INIT_SUPER_WITH_FIRST_STATIC(grandgirl->child.parent.ops, parent_ops, static_pub_data3); }
29.0625
99
0.756559
336c05d9bc6c6aaa9ce77e2999d588605daca65e
559
h
C
src/protection.h
ElliotAlderson51/Kernel-Rootkit-32Bit
44ebc2afc8e0e2ea23b89df32a3ddf614ee683bb
[ "MIT" ]
1
2022-02-02T21:27:34.000Z
2022-02-02T21:27:34.000Z
src/protection.h
ElliotAlderson51/Kernel-Rootkit-32Bit
44ebc2afc8e0e2ea23b89df32a3ddf614ee683bb
[ "MIT" ]
null
null
null
src/protection.h
ElliotAlderson51/Kernel-Rootkit-32Bit
44ebc2afc8e0e2ea23b89df32a3ddf614ee683bb
[ "MIT" ]
null
null
null
#include <ntddk.h> void deprotect() { __asm { cli push eax // Save EAX mov eax, CR0 // Put CR0 contents into EAX and eax, 0FFFEFFFFh // Turn off write protection mov CR0, eax // Put back the value after the modifications pop eax // Load former EAX value } } void protect() { __asm { push eax // Save EAX mov eax, CR0 // Put CR0 contents into EAX or eax, NOT 0FFFEFFFFh // Turn on write protection mov CR0, eax // Put back the value after the modifications pop eax // Load former EAX value sti } }
19.964286
63
0.636852
3385815ee18622132af91263bb2cbe8637ddcb50
694
h
C
src/rx/core/hints/unlikely.h
BuckeyeSoftware/rex
a0380e2e3ce26e610b4c9fcbe0ece19ecc8c3531
[ "MIT" ]
37
2019-02-17T06:31:22.000Z
2022-01-13T12:08:13.000Z
src/rx/core/hints/unlikely.h
BuckeyeSoftware/rex
a0380e2e3ce26e610b4c9fcbe0ece19ecc8c3531
[ "MIT" ]
47
2019-10-28T07:23:41.000Z
2020-07-25T22:36:16.000Z
src/rx/core/hints/unlikely.h
BuckeyeSoftware/rex
a0380e2e3ce26e610b4c9fcbe0ece19ecc8c3531
[ "MIT" ]
7
2019-03-03T12:08:52.000Z
2020-11-21T22:01:51.000Z
#ifndef RX_CORE_HINTS_UNLIKELY_H #define RX_CORE_HINTS_UNLIKELY_H #include "rx/core/config.h" // RX_COMPILER_{GCC,CLANG} /// \file unlikely.h /// \brief Hint unlikeliness of condition. #if defined(RX_DOCUMENT) /// \brief Indicate a conditional is unlikely. /// /// Hint to indicate that the given conditional is unlikely to evaluate true, /// enabling better code generation of branches. /// /// \param _x The conditional. #else #if defined(RX_COMPILER_GCC) || defined(RX_COMPILER_CLANG) #define RX_HINT_UNLIKELY(_x) __builtin_expect(!!(_x), 0) #else #define RX_HINT_UNLIKELY(_x) (_x) #endif // defined(RX_COMPILER_GCC) || defined(RX_COMPILER_CLANG) #endif #endif // RX_CORE_HINTS_UNLIKELY_H
30.173913
77
0.763689
a654f9c987583a8e82f42052f9ae65ecb916733a
1,119
h
C
ios/chrome/browser/ui/settings/google_services/google_services_settings_command_handler.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
ios/chrome/browser/ui/settings/google_services/google_services_settings_command_handler.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
ios/chrome/browser/ui/settings/google_services/google_services_settings_command_handler.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
// Copyright 2018 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. #ifndef IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_GOOGLE_SERVICES_SETTINGS_COMMAND_HANDLER_H_ #define IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_GOOGLE_SERVICES_SETTINGS_COMMAND_HANDLER_H_ // Protocol to communicate user actions from the mediator to its coordinator. @protocol GoogleServicesSettingsCommandHandler <NSObject> // Restarts the authentication flow. - (void)restartAuthenticationFlow; // Opens the reauth sync dialog. - (void)openReauthDialogAsSyncIsInAuthError; // Opens the passphrase dialog. - (void)openPassphraseDialog; // Presents the sign-in dialog to the user. - (void)showSignIn; // Opens the account setting view. - (void)openAccountSettings; // Opens the manage sync settings view. - (void)openManageSyncSettings; // Open the "Manage Your Google Account" web page - (void)openManageGoogleAccountWebPage; @end #endif // IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_GOOGLE_SERVICES_SETTINGS_COMMAND_HANDLER_H_
31.971429
101
0.823056
11b63b603f82bce3e4fc41cb6bd3cc7d1a991e58
1,661
h
C
mod/inc/hal/wachdog_mod.h
JamesLinus/UniSP-firmware
9be7e3a9c309e9c1a2440da228e2819e820e1af6
[ "MIT" ]
null
null
null
mod/inc/hal/wachdog_mod.h
JamesLinus/UniSP-firmware
9be7e3a9c309e9c1a2440da228e2819e820e1af6
[ "MIT" ]
null
null
null
mod/inc/hal/wachdog_mod.h
JamesLinus/UniSP-firmware
9be7e3a9c309e9c1a2440da228e2819e820e1af6
[ "MIT" ]
3
2018-06-26T02:58:30.000Z
2020-07-28T06:25:44.000Z
/** * @file wachdog_mod.h * @brief Header for wachdog_mod.c * @author raiden00 * @date 2015-09-28 **/ /****************************************************************************** * project: UniSP * chip: STM32F334x8 * compiler: arm-none-eabi-gcc * ******************************************************************************/ #ifdef OUT_MODULE_WDOG_ #ifndef WDOG_MOD_H_ #define WDOG_MOD_H_ /* +=============================================================================+ | includes +=============================================================================+ */ /* +=============================================================================+ | global definitions +=============================================================================+ */ /* +=============================================================================+ | strange variables +=============================================================================+ */ /* +=============================================================================+ | global variables +=============================================================================+ */ /* +=============================================================================+ | global functions' declarations +=============================================================================+ */ /****************************************************************************** * END OF FILE ******************************************************************************/ #endif /* WDOG_MOD_H_ */ #endif /* OUT_MODULE_WDOG_ */
30.759259
82
0.181216
693082109658a6f28e6604e39ca1bdda5af80317
309
c
C
736-2_has-2-2.c
7362has/timp-736-2_hass
37b4b0b713d3e23184c1156ebac7b0afc7db7e8e
[ "BSD-3-Clause" ]
null
null
null
736-2_has-2-2.c
7362has/timp-736-2_hass
37b4b0b713d3e23184c1156ebac7b0afc7db7e8e
[ "BSD-3-Clause" ]
null
null
null
736-2_has-2-2.c
7362has/timp-736-2_hass
37b4b0b713d3e23184c1156ebac7b0afc7db7e8e
[ "BSD-3-Clause" ]
null
null
null
#include <stdio.h> int main() { int n,i,x,a; a=0; printf ("Vvedite kolvo chisel n\n"); scanf ( "%d", &n); printf("vvedite x\n"); for (i=1;i<=n;i++) { scanf("%d",&x); a=a+(x-i); } printf("summa posledovarelnosti chisel="); printf("%d\n", a); return 0; }
16.263158
45
0.472492
5967bae04cf3f2438e74e40ae2aaa419201a0bab
2,427
h
C
lsass/server/auth-providers/ad-open-provider/adldap_p.h
kbore/pbis-open
a05eb9309269b6402b4d6659bc45961986ea5eab
[ "Apache-2.0" ]
372
2016-10-28T10:50:35.000Z
2022-03-18T19:54:37.000Z
lsass/server/auth-providers/ad-open-provider/adldap_p.h
kbore/pbis-open
a05eb9309269b6402b4d6659bc45961986ea5eab
[ "Apache-2.0" ]
317
2016-11-02T17:41:48.000Z
2021-11-08T20:28:19.000Z
lsass/server/auth-providers/ad-open-provider/adldap_p.h
kenferrara/pbis-open
690c325d947b2bf6fb3032f9d660e41b94aea4be
[ "Apache-2.0" ]
107
2016-11-03T19:25:16.000Z
2022-03-20T21:15:22.000Z
/* Editor Settings: expandtabs and use 4 spaces for indentation * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: * * -*- mode: c, c-basic-offset: 4 -*- */ /* * Copyright © BeyondTrust Software 2004 - 2019 * All rights reserved. * * 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. * * BEYONDTRUST MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING TERMS AS * WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT WITH * BEYONDTRUST, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE TERMS OF THAT * SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE APACHE LICENSE, * NOTWITHSTANDING THE ABOVE NOTICE. IF YOU HAVE QUESTIONS, OR WISH TO REQUEST * A COPY OF THE ALTERNATE LICENSING TERMS OFFERED BY BEYONDTRUST, PLEASE CONTACT * BEYONDTRUST AT beyondtrust.com/contact */ /* * Copyright (C) BeyondTrust Software. All rights reserved. * * Module Name: * * adldap_p.h * * Abstract: * * BeyondTrust Security and Authentication Subsystem (LSASS) * * AD LDAP helper functions (private header) * * Authors: Krishna Ganugapati (krishnag@likewisesoftware.com) * Sriram Nambakam (snambakam@likewisesoftware.com) * Wei Fu (wfu@likewisesoftware.com) */ #ifndef __ADLDAP_P_H__ #define __ADLDAP_P_H__ typedef struct _LSA_AD_QUERY_LISTS_ENTRY { DWORD dwQueryCount; PSTR* ppszQueryValues; } LSA_AD_QUERY_LISTS_ENTRY, *PLSA_AD_QUERY_LISTS_ENTRY; DWORD UnprovisionedModeMakeLocalSID( PCSTR pszDomainSID, DWORD dwID, PSTR* ppszLocalSID ); DWORD ADLdap_GetAttributeValuesList( IN PLSA_DM_LDAP_CONNECTION pConn, IN PCSTR pszDN, IN PCSTR pszAttributeName, IN BOOLEAN bDoExtDnSearch, IN BOOLEAN bDoSidParsing, OUT PDWORD pdwTotalCount, OUT PSTR** pppszValues ); DWORD ADLdap_MoveHashKeysToArray( IN OUT PLW_HASH_TABLE pHash, OUT PDWORD pCount, OUT PVOID** pppValues ); #endif
29.597561
81
0.730532
597199c144c9d36f4b3ec376578136b2306f4024
11,629
h
C
src/Benchmarks/SpMV/ReferenceFormats/Legacy/CSR.h
grinisrit/tnl-dev
4403b2dca895e2c32636395d6f1c1210c7afcefd
[ "MIT" ]
null
null
null
src/Benchmarks/SpMV/ReferenceFormats/Legacy/CSR.h
grinisrit/tnl-dev
4403b2dca895e2c32636395d6f1c1210c7afcefd
[ "MIT" ]
null
null
null
src/Benchmarks/SpMV/ReferenceFormats/Legacy/CSR.h
grinisrit/tnl-dev
4403b2dca895e2c32636395d6f1c1210c7afcefd
[ "MIT" ]
null
null
null
#pragma once #include <Benchmarks/SpMV/ReferenceFormats/Legacy/Sparse.h> #include <TNL/Containers/Vector.h> #include <TNL/Devices/Cuda.h> #include <TNL/Exceptions/CudaBadAlloc.h> namespace TNL { namespace Benchmarks { namespace SpMV { namespace ReferenceFormats { namespace Legacy { enum class Type { /* LONG = 0!!! Non zero value rewrites index[1] */ LONG = 0, STREAM = 1, VECTOR = 2 }; template<typename Index> union Block { Block(Index row, Type type = Type::VECTOR, Index index = 0) noexcept { this->index[0] = row; this->index[1] = index; this->byte[sizeof(Index) == 4 ? 7 : 15] = (uint8_t)type; } Block(Index row, Type type, Index nextRow, Index maxID, Index minID) noexcept { this->index[0] = row; this->index[1] = 0; this->twobytes[sizeof(Index) == 4 ? 2 : 4] = maxID - minID; if (type == Type::STREAM) this->twobytes[sizeof(Index) == 4 ? 3 : 5] = nextRow - row; if (type == Type::STREAM) this->byte[sizeof(Index) == 4 ? 7 : 15] |= 0b1000000; else if (type == Type::VECTOR) this->byte[sizeof(Index) == 4 ? 7 : 15] |= 0b10000000; } Block() = default; template< typename Index2 > Block& operator=( const Block< Index2 >& source ) { index[ 0 ] = source.index[ 0 ]; index[ 1 ] = source.index[ 1 ]; for( int i = 0; i < ( sizeof(Index) == 4 ? 8 : 16); i ++ ) byte[ i ] = source.byte[ i ]; for( int i = 0; i < (sizeof(Index) == 4 ? 4 : 8); i++ ) twobytes[ i ] = source.twobytes[ i ]; return *this; } Index index[2]; // index[0] is row pointer, index[1] is index in warp uint8_t byte[sizeof(Index) == 4 ? 8 : 16]; // byte[7/15] is type specificator uint16_t twobytes[sizeof(Index) == 4 ? 4 : 8]; //twobytes[2/4] is maxID - minID //twobytes[3/5] is nextRow - row }; #ifdef HAVE_UMFPACK template< typename Matrix, typename Preconditioner > class UmfpackWrapper; #endif template< typename Real > class CusparseCSR; template< typename Device > class CSRDeviceDependentCode; enum CSRKernel { CSRScalar, CSRVector, CSRHybrid, // Hybrid is not implemented CSRLight, CSRLight2, CSRLight3, CSRLight4, CSRLight5, CSRLight6, CSRAdaptive, CSRMultiVector, CSRLightWithoutAtomic }; template< typename Real, typename Device = Devices::Host, typename Index = int, CSRKernel KernelType = CSRScalar > class CSR : public Sparse< Real, Device, Index > { private: // convenient template alias for controlling the selection of copy-assignment operator template< typename Device2 > using Enabler = std::enable_if< ! std::is_same< Device2, Device >::value >; // friend class will be needed for templated assignment operators template< typename Real2, typename Device2, typename Index2, CSRKernel KernelType2 > friend class CSR; public: using RealType = Real; using DeviceType = Device; using IndexType = Index; using RowsCapacitiesType = typename Sparse< RealType, DeviceType, IndexType >::RowsCapacitiesType; using RowsCapacitiesTypeView = typename Sparse< RealType, DeviceType, IndexType >::RowsCapacitiesView; using ConstRowsCapacitiesTypeView = typename Sparse< RealType, DeviceType, IndexType >::ConstRowsCapacitiesView; using BaseType = Sparse< Real, Device, Index >; using MatrixRow = typename BaseType::MatrixRow; using ConstMatrixRow = typename BaseType::ConstMatrixRow; template< typename _Real = Real, typename _Device = Device, typename _Index = Index > using Self = CSR< _Real, _Device, _Index >; constexpr CSRKernel getSpMVKernelType() { return KernelType; }; static constexpr bool isSymmetric() { return false; }; Containers::Vector< Block<Index>, Device, Index > blocks; /* Configuration of CSR SpMV kernels ----------------------------------------- */ /* Block sizes */ static constexpr Index THREADS_ADAPTIVE = sizeof(Index) == 8 ? 128 : 256; static constexpr Index THREADS_SCALAR = 128; static constexpr Index THREADS_VECTOR = 128; static constexpr Index THREADS_LIGHT = 128; /* Max length of row to process one warp for CSR Light, MultiVector */ static constexpr Index MAX_ELEMENTS_PER_WARP = 384; /* Max length of row to process one warp for CSR Adaptive */ static constexpr Index MAX_ELEMENTS_PER_WARP_ADAPT = 512; /* How many shared memory use per block in CSR Adaptive kernel */ static constexpr Index SHARED_PER_BLOCK = 24576; /* Number of elements in shared memory */ static constexpr Index SHARED = SHARED_PER_BLOCK/sizeof(Real); /* Number of warps in block for CSR Adaptive */ static constexpr Index WARPS = THREADS_ADAPTIVE / 32; /* Number of elements in shared memory per one warp */ static constexpr Index SHARED_PER_WARP = SHARED / WARPS; /* -------------------------------------------------------------------------- */ using Sparse< Real, Device, Index >::getAllocatedElementsCount; CSR(); static std::string getSerializationType(); std::string getSerializationTypeVirtual() const override; void setDimensions( const IndexType rows, const IndexType columns ) override; void setCompressedRowLengths( ConstRowsCapacitiesTypeView rowLengths ); void setRowCapacities( ConstRowsCapacitiesTypeView rowLengths ); void getCompressedRowLengths( RowsCapacitiesTypeView rowLengths ) const; IndexType getRowLength( const IndexType row ) const; __cuda_callable__ IndexType getRowLengthFast( const IndexType row ) const; IndexType getNonZeroRowLength( const IndexType row ) const; __cuda_callable__ IndexType getNonZeroRowLengthFast( const IndexType row ) const; template< typename Real2, typename Device2, typename Index2, CSRKernel KernelType2 > void setLike( const CSR< Real2, Device2, Index2, KernelType2 >& matrix ); void reset(); __cuda_callable__ bool setElementFast( const IndexType row, const IndexType column, const RealType& value ); bool setElement( const IndexType row, const IndexType column, const RealType& value ); __cuda_callable__ bool addElementFast( const IndexType row, const IndexType column, const RealType& value, const RealType& thisElementMultiplicator = 1.0 ); bool addElement( const IndexType row, const IndexType column, const RealType& value, const RealType& thisElementMultiplicator = 1.0 ); __cuda_callable__ bool setRowFast( const IndexType row, const IndexType* columnIndexes, const RealType* values, const IndexType elements ); bool setRow( const IndexType row, const IndexType* columnIndexes, const RealType* values, const IndexType elements ); __cuda_callable__ bool addRowFast( const IndexType row, const IndexType* columns, const RealType* values, const IndexType numberOfElements, const RealType& thisElementMultiplicator = 1.0 ); bool addRow( const IndexType row, const IndexType* columns, const RealType* values, const IndexType numberOfElements, const RealType& thisElementMultiplicator = 1.0 ); __cuda_callable__ RealType getElementFast( const IndexType row, const IndexType column ) const; RealType getElement( const IndexType row, const IndexType column ) const; __cuda_callable__ void getRowFast( const IndexType row, IndexType* columns, RealType* values ) const; __cuda_callable__ MatrixRow getRow( const IndexType rowIndex ); __cuda_callable__ ConstMatrixRow getRow( const IndexType rowIndex ) const; template< typename Vector > __cuda_callable__ typename Vector::RealType rowVectorProduct( const IndexType row, const Vector& vector ) const; template< typename InVector, typename OutVector > void vectorProduct( const InVector& inVector, OutVector& outVector ) const; // TODO: add const RealType& multiplicator = 1.0 ) template< typename Real2, typename Index2, CSRKernel KernelType2 > void addMatrix( const CSR< Real2, Device, Index2, KernelType2 >& matrix, const RealType& matrixMultiplicator = 1.0, const RealType& thisMatrixMultiplicator = 1.0 ); template< typename Real2, typename Index2, CSRKernel KernelType2 > void getTransposition( const CSR< Real2, Device, Index2, KernelType2 >& matrix, const RealType& matrixMultiplicator = 1.0 ); template< typename Vector1, typename Vector2 > bool performSORIteration( const Vector1& b, const IndexType row, Vector2& x, const RealType& omega = 1.0 ) const; // copy assignment CSR& operator=( const CSR& matrix ); template< typename IndexType2, CSRKernel KernelType2 > CSR& operator=( const CSR< RealType, DeviceType, IndexType2, KernelType2 >& matrix ); // cross-device copy assignment template< typename Real2, typename Device2, typename Index2, CSRKernel KernelType2, typename = typename Enabler< Device2 >::type > CSR& operator=( const CSR< Real2, Device2, Index2, KernelType2 >& matrix ); void save( File& file ) const override; void load( File& file ) override; void save( const String& fileName ) const; void load( const String& fileName ); void print( std::ostream& str ) const override; //void setCudaKernelType( const SPMVCudaKernel kernel ); //__cuda_callable__ //SPMVCudaKernel getCudaKernelType() const; void setCudaWarpSize( const int warpSize ); int getCudaWarpSize() const; void setHybridModeSplit( const IndexType hybridModeSplit ); __cuda_callable__ IndexType getHybridModeSplit() const; /* Analyze rowPointers, columnIndecies and values to create block for CSR Adaptive */ void setBlocks(); // The following getters allow us to interface TNL with external C-like // libraries such as UMFPACK or SuperLU, which need the raw data. const Containers::Vector< Index, Device, Index >& getRowPointers() const { return this->rowPointers; } Containers::Vector< Index, Device, Index >& getRowPointers() { return this->rowPointers; } const Containers::Vector< Index, Device, Index >& getColumnIndexes() const { return this->columnIndexes; } Containers::Vector< Index, Device, Index >& getColumnIndexes() { return this->columnIndexes; } protected: Containers::Vector< Index, Device, Index > rowPointers; //SPMVCudaKernel spmvCudaKernel; int cudaWarpSize, hybridModeSplit; typedef CSRDeviceDependentCode< DeviceType > DeviceDependentCode; friend class CSRDeviceDependentCode< DeviceType >; friend class CusparseCSR< RealType >; }; } //namespace Legacy } //namespace ReferenceFormats } //namespace SpMV } //namespace Benchmarks } // namespace TNL #include <Benchmarks/SpMV/ReferenceFormats/Legacy/CSR_impl.h>
33.416667
115
0.647949
dd6e5dc0dd9c8fa9bcead4fb9e5ebf7ad15f9edc
21,865
h
C
macros.h
LuaDist/luaglut
4d4746c3e884de63e15b9dbc78062db235172ca2
[ "MIT" ]
11
2015-01-29T08:15:41.000Z
2019-07-05T15:34:29.000Z
macros.h
LuaDist/luaglut
4d4746c3e884de63e15b9dbc78062db235172ca2
[ "MIT" ]
null
null
null
macros.h
LuaDist/luaglut
4d4746c3e884de63e15b9dbc78062db235172ca2
[ "MIT" ]
6
2015-01-30T13:24:27.000Z
2022-01-13T12:00:19.000Z
/* vim: set ts=3 et: */ /* This file is automatically generated by menus.lua */ inline const char * check_string(lua_State *L, int n) { if (lua_type(L,n) != LUA_TSTRING) luaL_typerror(L, n, lua_typename(L, LUA_TSTRING)); return (const char *) lua_tostring(L, n); } inline const void * check_lightuserdata(lua_State *L, int n) { if (lua_type(L,n) != LUA_TLIGHTUSERDATA) luaL_typerror(L, n, "lightuserdata"); return (const void *) lua_touserdata(L, n); } #define CONSTANT(name)\ lua_pushstring(L, #name);\ lua_pushnumber(L, name);\ lua_settable(L, LUA_GLOBALSINDEX); #define POINTER(name)\ lua_pushstring(L, #name);\ lua_pushlightuserdata(L, name);\ lua_settable(L, LUA_GLOBALSINDEX); #define FUN_SPEC(name) #define FUN(name)\ lua_register(L, #name, L ## name); inline GLboolean check_GLboolean(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(GLboolean)"); return (GLboolean) lua_tonumber(L, n); } inline GLbyte check_GLbyte(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(GLbyte)"); return (GLbyte) lua_tonumber(L, n); } inline GLubyte check_GLubyte(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(GLubyte)"); return (GLubyte) lua_tonumber(L, n); } inline GLshort check_GLshort(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(GLshort)"); return (GLshort) lua_tonumber(L, n); } inline GLushort check_GLushort(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(GLushort)"); return (GLushort) lua_tonumber(L, n); } inline GLint check_GLint(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(GLint)"); return (GLint) lua_tonumber(L, n); } inline GLuint check_GLuint(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(GLuint)"); return (GLuint) lua_tonumber(L, n); } inline GLsizei check_GLsizei(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(GLsizei)"); return (GLsizei) lua_tonumber(L, n); } inline GLenum check_GLenum(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(GLenum)"); return (GLenum) lua_tonumber(L, n); } inline GLbitfield check_GLbitfield(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(GLbitfield)"); return (GLbitfield) lua_tonumber(L, n); } inline GLfloat check_GLfloat(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(GLfloat)"); return (GLfloat) lua_tonumber(L, n); } inline GLdouble check_GLdouble(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(GLdouble)"); return (GLdouble) lua_tonumber(L, n); } inline int check_int(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(int)"); return (int) lua_tonumber(L, n); } inline unsigned int check_uint(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(unsigned int)"); return (unsigned int) lua_tonumber(L, n); } inline float check_float(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(float)"); return (float) lua_tonumber(L, n); } inline double check_double(lua_State *L, int n) { if (lua_type(L,n) != LUA_TNUMBER) luaL_typerror(L, n, "number(double)"); return (double) lua_tonumber(L, n); } #define FUN_BE(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ lua_pushnumber(L, (GLboolean) name(a1));\ return 1;\ } #define FUN_BuI(name)\ LUA_API int L ## name (lua_State *L) {\ GLuint a1 = (GLuint) check_GLuint(L, 1);\ lua_pushnumber(L, (GLboolean) name(a1));\ return 1;\ } #define FUN_E(name)\ LUA_API int L ## name (lua_State *L) {\ lua_pushnumber(L, (GLenum) name());\ return 1;\ } #define FUN_IE(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ lua_pushnumber(L, (GLint) name(a1));\ return 1;\ } #define FUN_sE(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ lua_pushstring(L, (const char *) name(a1));\ return 1;\ } #define FUN_uIZ(name)\ LUA_API int L ## name (lua_State *L) {\ GLsizei a1 = (GLsizei) check_GLsizei(L, 1);\ lua_pushnumber(L, (GLuint) name(a1));\ return 1;\ } #define FUN_v(name)\ LUA_API int L ## name (lua_State *L) {\ (void) L; /* unused */ \ name();\ return 0;\ } #define FUN_vB(name)\ LUA_API int L ## name (lua_State *L) {\ GLboolean a1 = (GLboolean) check_GLboolean(L, 1);\ name(a1);\ return 0;\ } #define FUN_vB4(name)\ LUA_API int L ## name (lua_State *L) {\ GLboolean a1 = (GLboolean) check_GLboolean(L, 1);\ GLboolean a2 = (GLboolean) check_GLboolean(L, 2);\ GLboolean a3 = (GLboolean) check_GLboolean(L, 3);\ GLboolean a4 = (GLboolean) check_GLboolean(L, 4);\ name(a1, a2, a3, a4);\ return 0;\ } #define FUN_vD(name)\ LUA_API int L ## name (lua_State *L) {\ GLdouble a1 = (GLdouble) check_GLdouble(L, 1);\ name(a1);\ return 0;\ } #define FUN_vD2(name)\ LUA_API int L ## name (lua_State *L) {\ GLdouble a1 = (GLdouble) check_GLdouble(L, 1);\ GLdouble a2 = (GLdouble) check_GLdouble(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_vD3(name)\ LUA_API int L ## name (lua_State *L) {\ GLdouble a1 = (GLdouble) check_GLdouble(L, 1);\ GLdouble a2 = (GLdouble) check_GLdouble(L, 2);\ GLdouble a3 = (GLdouble) check_GLdouble(L, 3);\ name(a1, a2, a3);\ return 0;\ } #define FUN_vD4(name)\ LUA_API int L ## name (lua_State *L) {\ GLdouble a1 = (GLdouble) check_GLdouble(L, 1);\ GLdouble a2 = (GLdouble) check_GLdouble(L, 2);\ GLdouble a3 = (GLdouble) check_GLdouble(L, 3);\ GLdouble a4 = (GLdouble) check_GLdouble(L, 4);\ name(a1, a2, a3, a4);\ return 0;\ } #define FUN_vD6(name)\ LUA_API int L ## name (lua_State *L) {\ GLdouble a1 = (GLdouble) check_GLdouble(L, 1);\ GLdouble a2 = (GLdouble) check_GLdouble(L, 2);\ GLdouble a3 = (GLdouble) check_GLdouble(L, 3);\ GLdouble a4 = (GLdouble) check_GLdouble(L, 4);\ GLdouble a5 = (GLdouble) check_GLdouble(L, 5);\ GLdouble a6 = (GLdouble) check_GLdouble(L, 6);\ name(a1, a2, a3, a4, a5, a6);\ return 0;\ } #define FUN_vE(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ name(a1);\ return 0;\ } #define FUN_vE2(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLenum a2 = (GLenum) check_GLenum(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_vE2D(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLenum a2 = (GLenum) check_GLenum(L, 2);\ GLdouble a3 = (GLdouble) check_GLdouble(L, 3);\ name(a1, a2, a3);\ return 0;\ } #define FUN_vE2F(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLenum a2 = (GLenum) check_GLenum(L, 2);\ GLfloat a3 = (GLfloat) check_GLfloat(L, 3);\ name(a1, a2, a3);\ return 0;\ } #define FUN_vE2p(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLenum a2 = (GLenum) check_GLenum(L, 2);\ void * a3 = (void *) check_lightuserdata(L, 3);\ name(a1, a2, a3);\ return 0;\ } #define FUN_vE3(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLenum a2 = (GLenum) check_GLenum(L, 2);\ GLenum a3 = (GLenum) check_GLenum(L, 3);\ name(a1, a2, a3);\ return 0;\ } #define FUN_vEF(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLfloat a2 = (GLfloat) check_GLfloat(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_vEI(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLint a2 = (GLint) check_GLint(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_vEI2Z2IE2p(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLint a2 = (GLint) check_GLint(L, 2);\ GLint a3 = (GLint) check_GLint(L, 3);\ GLsizei a4 = (GLsizei) check_GLsizei(L, 4);\ GLsizei a5 = (GLsizei) check_GLsizei(L, 5);\ GLint a6 = (GLint) check_GLint(L, 6);\ GLenum a7 = (GLenum) check_GLenum(L, 7);\ GLenum a8 = (GLenum) check_GLenum(L, 8);\ void * a9 = (void *) check_lightuserdata(L, 9);\ name(a1, a2, a3, a4, a5, a6, a7, a8, a9);\ return 0;\ } #define FUN_vEI2ZIE2p(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLint a2 = (GLint) check_GLint(L, 2);\ GLint a3 = (GLint) check_GLint(L, 3);\ GLsizei a4 = (GLsizei) check_GLsizei(L, 4);\ GLint a5 = (GLint) check_GLint(L, 5);\ GLenum a6 = (GLenum) check_GLenum(L, 6);\ GLenum a7 = (GLenum) check_GLenum(L, 7);\ void * a8 = (void *) check_lightuserdata(L, 8);\ name(a1, a2, a3, a4, a5, a6, a7, a8);\ return 0;\ } #define FUN_vEIE2p(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLint a2 = (GLint) check_GLint(L, 2);\ GLenum a3 = (GLenum) check_GLenum(L, 3);\ GLenum a4 = (GLenum) check_GLenum(L, 4);\ void * a5 = (void *) check_lightuserdata(L, 5);\ name(a1, a2, a3, a4, a5);\ return 0;\ } #define FUN_vEIEp(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLint a2 = (GLint) check_GLint(L, 2);\ GLenum a3 = (GLenum) check_GLenum(L, 3);\ void * a4 = (void *) check_lightuserdata(L, 4);\ name(a1, a2, a3, a4);\ return 0;\ } #define FUN_vEIp(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLint a2 = (GLint) check_GLint(L, 2);\ void * a3 = (void *) check_lightuserdata(L, 3);\ name(a1, a2, a3);\ return 0;\ } #define FUN_vEIuI(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLint a2 = (GLint) check_GLint(L, 2);\ GLuint a3 = (GLuint) check_GLuint(L, 3);\ name(a1, a2, a3);\ return 0;\ } #define FUN_vEp(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ void * a2 = (void *) check_lightuserdata(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_vEuI(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLuint a2 = (GLuint) check_GLuint(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_vF(name)\ LUA_API int L ## name (lua_State *L) {\ GLfloat a1 = (GLfloat) check_GLfloat(L, 1);\ name(a1);\ return 0;\ } #define FUN_vF2(name)\ LUA_API int L ## name (lua_State *L) {\ GLfloat a1 = (GLfloat) check_GLfloat(L, 1);\ GLfloat a2 = (GLfloat) check_GLfloat(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_vF4(name)\ LUA_API int L ## name (lua_State *L) {\ GLfloat a1 = (GLfloat) check_GLfloat(L, 1);\ GLfloat a2 = (GLfloat) check_GLfloat(L, 2);\ GLfloat a3 = (GLfloat) check_GLfloat(L, 3);\ GLfloat a4 = (GLfloat) check_GLfloat(L, 4);\ name(a1, a2, a3, a4);\ return 0;\ } #define FUN_vI(name)\ LUA_API int L ## name (lua_State *L) {\ GLint a1 = (GLint) check_GLint(L, 1);\ name(a1);\ return 0;\ } #define FUN_vI2Z2(name)\ LUA_API int L ## name (lua_State *L) {\ GLint a1 = (GLint) check_GLint(L, 1);\ GLint a2 = (GLint) check_GLint(L, 2);\ GLsizei a3 = (GLsizei) check_GLsizei(L, 3);\ GLsizei a4 = (GLsizei) check_GLsizei(L, 4);\ name(a1, a2, a3, a4);\ return 0;\ } #define FUN_vI2Z2E(name)\ LUA_API int L ## name (lua_State *L) {\ GLint a1 = (GLint) check_GLint(L, 1);\ GLint a2 = (GLint) check_GLint(L, 2);\ GLsizei a3 = (GLsizei) check_GLsizei(L, 3);\ GLsizei a4 = (GLsizei) check_GLsizei(L, 4);\ GLenum a5 = (GLenum) check_GLenum(L, 5);\ name(a1, a2, a3, a4, a5);\ return 0;\ } #define FUN_vI2Z2E2p(name)\ LUA_API int L ## name (lua_State *L) {\ GLint a1 = (GLint) check_GLint(L, 1);\ GLint a2 = (GLint) check_GLint(L, 2);\ GLsizei a3 = (GLsizei) check_GLsizei(L, 3);\ GLsizei a4 = (GLsizei) check_GLsizei(L, 4);\ GLenum a5 = (GLenum) check_GLenum(L, 5);\ GLenum a6 = (GLenum) check_GLenum(L, 6);\ void * a7 = (void *) check_lightuserdata(L, 7);\ name(a1, a2, a3, a4, a5, a6, a7);\ return 0;\ } #define FUN_vIuH(name)\ LUA_API int L ## name (lua_State *L) {\ GLint a1 = (GLint) check_GLint(L, 1);\ GLushort a2 = (GLushort) check_GLushort(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_vp(name)\ LUA_API int L ## name (lua_State *L) {\ void * a1 = (void *) check_lightuserdata(L, 1);\ name(a1);\ return 0;\ } #define FUN_vT(name)\ LUA_API int L ## name (lua_State *L) {\ GLbitfield a1 = (GLbitfield) check_GLbitfield(L, 1);\ name(a1);\ return 0;\ } #define FUN_vuI(name)\ LUA_API int L ## name (lua_State *L) {\ GLuint a1 = (GLuint) check_GLuint(L, 1);\ name(a1);\ return 0;\ } #define FUN_vuIE(name)\ LUA_API int L ## name (lua_State *L) {\ GLuint a1 = (GLuint) check_GLuint(L, 1);\ GLenum a2 = (GLenum) check_GLenum(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_vuIZ(name)\ LUA_API int L ## name (lua_State *L) {\ GLuint a1 = (GLuint) check_GLuint(L, 1);\ GLsizei a2 = (GLsizei) check_GLsizei(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_vZ2E2p(name)\ LUA_API int L ## name (lua_State *L) {\ GLsizei a1 = (GLsizei) check_GLsizei(L, 1);\ GLsizei a2 = (GLsizei) check_GLsizei(L, 2);\ GLenum a3 = (GLenum) check_GLenum(L, 3);\ GLenum a4 = (GLenum) check_GLenum(L, 4);\ void * a5 = (void *) check_lightuserdata(L, 5);\ name(a1, a2, a3, a4, a5);\ return 0;\ } #define FUN_vZ2F4p(name)\ LUA_API int L ## name (lua_State *L) {\ GLsizei a1 = (GLsizei) check_GLsizei(L, 1);\ GLsizei a2 = (GLsizei) check_GLsizei(L, 2);\ GLfloat a3 = (GLfloat) check_GLfloat(L, 3);\ GLfloat a4 = (GLfloat) check_GLfloat(L, 4);\ GLfloat a5 = (GLfloat) check_GLfloat(L, 5);\ GLfloat a6 = (GLfloat) check_GLfloat(L, 6);\ void * a7 = (void *) check_lightuserdata(L, 7);\ name(a1, a2, a3, a4, a5, a6, a7);\ return 0;\ } #define FUN_vZEp(name)\ LUA_API int L ## name (lua_State *L) {\ GLsizei a1 = (GLsizei) check_GLsizei(L, 1);\ GLenum a2 = (GLenum) check_GLenum(L, 2);\ void * a3 = (void *) check_lightuserdata(L, 3);\ name(a1, a2, a3);\ return 0;\ } #define FUN_vZp(name)\ LUA_API int L ## name (lua_State *L) {\ GLsizei a1 = (GLsizei) check_GLsizei(L, 1);\ void * a2 = (void *) check_lightuserdata(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_Fi2(name)\ LUA_API int L ## name (lua_State *L) {\ int a1 = (int) check_int(L, 1);\ int a2 = (int) check_int(L, 2);\ lua_pushnumber(L, (GLfloat) name(a1, a2));\ return 1;\ } #define FUN_i(name)\ LUA_API int L ## name (lua_State *L) {\ lua_pushnumber(L, (int) name());\ return 1;\ } #define FUN_iD3p6(name)\ LUA_API int L ## name (lua_State *L) {\ GLdouble a1 = (GLdouble) check_GLdouble(L, 1);\ GLdouble a2 = (GLdouble) check_GLdouble(L, 2);\ GLdouble a3 = (GLdouble) check_GLdouble(L, 3);\ void * a4 = (void *) check_lightuserdata(L, 4);\ void * a5 = (void *) check_lightuserdata(L, 5);\ void * a6 = (void *) check_lightuserdata(L, 6);\ void * a7 = (void *) check_lightuserdata(L, 7);\ void * a8 = (void *) check_lightuserdata(L, 8);\ void * a9 = (void *) check_lightuserdata(L, 9);\ lua_pushnumber(L, (int) name(a1, a2, a3, a4, a5, a6, a7, a8, a9));\ return 1;\ } #define FUN_iE(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ lua_pushnumber(L, (int) name(a1));\ return 1;\ } #define FUN_IEIZ2E2p(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLint a2 = (GLint) check_GLint(L, 2);\ GLsizei a3 = (GLsizei) check_GLsizei(L, 3);\ GLsizei a4 = (GLsizei) check_GLsizei(L, 4);\ GLenum a5 = (GLenum) check_GLenum(L, 5);\ GLenum a6 = (GLenum) check_GLenum(L, 6);\ void * a7 = (void *) check_lightuserdata(L, 7);\ lua_pushnumber(L, (GLint) name(a1, a2, a3, a4, a5, a6, a7));\ return 1;\ } #define FUN_IEIZE2p(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ GLint a2 = (GLint) check_GLint(L, 2);\ GLsizei a3 = (GLsizei) check_GLsizei(L, 3);\ GLenum a4 = (GLenum) check_GLenum(L, 4);\ GLenum a5 = (GLenum) check_GLenum(L, 5);\ void * a6 = (void *) check_lightuserdata(L, 6);\ lua_pushnumber(L, (GLint) name(a1, a2, a3, a4, a5, a6));\ return 1;\ } #define FUN_ip(name)\ LUA_API int L ## name (lua_State *L) {\ void * a1 = (void *) check_lightuserdata(L, 1);\ lua_pushnumber(L, (int) name(a1));\ return 1;\ } #define FUN_ipi(name)\ LUA_API int L ## name (lua_State *L) {\ void * a1 = (void *) check_lightuserdata(L, 1);\ int a2 = (int) check_int(L, 2);\ lua_pushnumber(L, (int) name(a1, a2));\ return 1;\ } #define FUN_is(name)\ LUA_API int L ## name (lua_State *L) {\ const char * a1 = (const char *) check_string(L, 1);\ lua_pushnumber(L, (int) name(a1));\ return 1;\ } #define FUN_p(name)\ LUA_API int L ## name (lua_State *L) {\ lua_pushlightuserdata(L, (void *) name());\ return 1;\ } #define FUN_ps(name)\ LUA_API int L ## name (lua_State *L) {\ const char * a1 = (const char *) check_string(L, 1);\ lua_pushlightuserdata(L, (void *) name(a1));\ return 1;\ } #define FUN_v(name)\ LUA_API int L ## name (lua_State *L) {\ (void) L; /* unused */ \ name();\ return 0;\ } #define FUN_vD(name)\ LUA_API int L ## name (lua_State *L) {\ GLdouble a1 = (GLdouble) check_GLdouble(L, 1);\ name(a1);\ return 0;\ } #define FUN_vD2I2(name)\ LUA_API int L ## name (lua_State *L) {\ GLdouble a1 = (GLdouble) check_GLdouble(L, 1);\ GLdouble a2 = (GLdouble) check_GLdouble(L, 2);\ GLint a3 = (GLint) check_GLint(L, 3);\ GLint a4 = (GLint) check_GLint(L, 4);\ name(a1, a2, a3, a4);\ return 0;\ } #define FUN_vD4(name)\ LUA_API int L ## name (lua_State *L) {\ GLdouble a1 = (GLdouble) check_GLdouble(L, 1);\ GLdouble a2 = (GLdouble) check_GLdouble(L, 2);\ GLdouble a3 = (GLdouble) check_GLdouble(L, 3);\ GLdouble a4 = (GLdouble) check_GLdouble(L, 4);\ name(a1, a2, a3, a4);\ return 0;\ } #define FUN_vD4p(name)\ LUA_API int L ## name (lua_State *L) {\ GLdouble a1 = (GLdouble) check_GLdouble(L, 1);\ GLdouble a2 = (GLdouble) check_GLdouble(L, 2);\ GLdouble a3 = (GLdouble) check_GLdouble(L, 3);\ GLdouble a4 = (GLdouble) check_GLdouble(L, 4);\ void * a5 = (void *) check_lightuserdata(L, 5);\ name(a1, a2, a3, a4, a5);\ return 0;\ } #define FUN_vD9(name)\ LUA_API int L ## name (lua_State *L) {\ GLdouble a1 = (GLdouble) check_GLdouble(L, 1);\ GLdouble a2 = (GLdouble) check_GLdouble(L, 2);\ GLdouble a3 = (GLdouble) check_GLdouble(L, 3);\ GLdouble a4 = (GLdouble) check_GLdouble(L, 4);\ GLdouble a5 = (GLdouble) check_GLdouble(L, 5);\ GLdouble a6 = (GLdouble) check_GLdouble(L, 6);\ GLdouble a7 = (GLdouble) check_GLdouble(L, 7);\ GLdouble a8 = (GLdouble) check_GLdouble(L, 8);\ GLdouble a9 = (GLdouble) check_GLdouble(L, 9);\ name(a1, a2, a3, a4, a5, a6, a7, a8, a9);\ return 0;\ } #define FUN_vDI2(name)\ LUA_API int L ## name (lua_State *L) {\ GLdouble a1 = (GLdouble) check_GLdouble(L, 1);\ GLint a2 = (GLint) check_GLint(L, 2);\ GLint a3 = (GLint) check_GLint(L, 3);\ name(a1, a2, a3);\ return 0;\ } #define FUN_vE(name)\ LUA_API int L ## name (lua_State *L) {\ GLenum a1 = (GLenum) check_GLenum(L, 1);\ name(a1);\ return 0;\ } #define FUN_vi(name)\ LUA_API int L ## name (lua_State *L) {\ int a1 = (int) check_int(L, 1);\ name(a1);\ return 0;\ } #define FUN_vI(name)\ LUA_API int L ## name (lua_State *L) {\ GLint a1 = (GLint) check_GLint(L, 1);\ name(a1);\ return 0;\ } #define FUN_vi2(name)\ LUA_API int L ## name (lua_State *L) {\ int a1 = (int) check_int(L, 1);\ int a2 = (int) check_int(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_viF3(name)\ LUA_API int L ## name (lua_State *L) {\ int a1 = (int) check_int(L, 1);\ GLfloat a2 = (GLfloat) check_GLfloat(L, 2);\ GLfloat a3 = (GLfloat) check_GLfloat(L, 3);\ GLfloat a4 = (GLfloat) check_GLfloat(L, 4);\ name(a1, a2, a3, a4);\ return 0;\ } #define FUN_visi(name)\ LUA_API int L ## name (lua_State *L) {\ int a1 = (int) check_int(L, 1);\ const char * a2 = (const char *) check_string(L, 2);\ int a3 = (int) check_int(L, 3);\ name(a1, a2, a3);\ return 0;\ } #define FUN_vp(name)\ LUA_API int L ## name (lua_State *L) {\ void * a1 = (void *) check_lightuserdata(L, 1);\ name(a1);\ return 0;\ } #define FUN_vpi(name)\ LUA_API int L ## name (lua_State *L) {\ void * a1 = (void *) check_lightuserdata(L, 1);\ int a2 = (int) check_int(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_vps(name)\ LUA_API int L ## name (lua_State *L) {\ void * a1 = (void *) check_lightuserdata(L, 1);\ const char * a2 = (const char *) check_string(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_vs(name)\ LUA_API int L ## name (lua_State *L) {\ const char * a1 = (const char *) check_string(L, 1);\ name(a1);\ return 0;\ } #define FUN_vsi(name)\ LUA_API int L ## name (lua_State *L) {\ const char * a1 = (const char *) check_string(L, 1);\ int a2 = (int) check_int(L, 2);\ name(a1, a2);\ return 0;\ } #define FUN_vui(name)\ LUA_API int L ## name (lua_State *L) {\ unsigned int a1 = (unsigned int) check_uint(L, 1);\ name(a1);\ return 0;\ }
26.762546
70
0.618523
20e2004d97d9a083417f5e7263f8c0957e6d554c
919
h
C
iso14229_config.h
fuluwwa/iso14229
60a3bc8f84b9eafad89330d42face197957673f4
[ "MIT" ]
1
2022-02-11T06:36:55.000Z
2022-02-11T06:36:55.000Z
iso14229_config.h
fuluwwa/iso14229
60a3bc8f84b9eafad89330d42face197957673f4
[ "MIT" ]
null
null
null
iso14229_config.h
fuluwwa/iso14229
60a3bc8f84b9eafad89330d42face197957673f4
[ "MIT" ]
null
null
null
/** * @brief maximum allowable number of user defined 0x31 RoutineControl routines * The number of routines in theory ranges from [0-0xFFFF] */ #ifndef ISO14229_USER_DEFINED_MAX_ROUTINES #define ISO14229_USER_DEFINED_MAX_ROUTINES 10 #endif /** * @brief maximum allowable number of download handlers * */ #ifndef ISO14229_USER_DEFINED_MAX_DOWNLOAD_HANDLERS #define ISO14229_USER_DEFINED_MAX_DOWNLOAD_HANDLERS 1 #endif /* The iso14229 server must delay sending an outgoing response for up to p2 milliseconds. Outgoing responses go in a buffer of this size until p2 elapses. This extraneous buffer can be removed by using the one in the ISO-TP layer but I didn't see an obvious way of doing that. */ #define ISO14229_TPORT_SEND_BUFSIZE 255 /* provide a debug function with -DISO14229USERDEBUG=printf when compiling this library */ #ifndef ISO14229USERDEBUG #define ISO14229USERDEBUG(fmt, ...) ((void)fmt) #endif
27.848485
79
0.799782
de6eb3660562d0a2540544e76f9ab3ad3f2752ce
343
h
C
tic-tac-toe/unit.h
dingjun/tic_tac_toe
708dbbe8e21c39a9f60b540a494f767ff5c41c2e
[ "MIT" ]
1
2017-03-29T17:38:17.000Z
2017-03-29T17:38:17.000Z
tic-tac-toe/unit.h
dingjun/tic-tac-toe
708dbbe8e21c39a9f60b540a494f767ff5c41c2e
[ "MIT" ]
null
null
null
tic-tac-toe/unit.h
dingjun/tic-tac-toe
708dbbe8e21c39a9f60b540a494f767ff5c41c2e
[ "MIT" ]
null
null
null
#ifndef UNIT_H_ #define UNIT_H_ #include <SDL.h> #include "application.h" class Application; class Unit { public: Unit(SDL_Texture* texture, const SDL_Point& point); Unit(SDL_Texture* texture, const SDL_Rect& rect); void Render(SDL_Renderer* renderer); private: SDL_Texture* texture_; SDL_Rect rect_; }; #endif // UNIT_H_
15.590909
53
0.723032
50dbfc85e756fddb9dcf39094434a1c84f85588a
11,542
c
C
kernel/tegra/drivers/mfd/tlv320aic3256-core.c
alexunder/CellMatrix
bd21813ad8ab4ccd320bcac9aad7c61eb7f35df2
[ "MIT" ]
null
null
null
kernel/tegra/drivers/mfd/tlv320aic3256-core.c
alexunder/CellMatrix
bd21813ad8ab4ccd320bcac9aad7c61eb7f35df2
[ "MIT" ]
null
null
null
kernel/tegra/drivers/mfd/tlv320aic3256-core.c
alexunder/CellMatrix
bd21813ad8ab4ccd320bcac9aad7c61eb7f35df2
[ "MIT" ]
null
null
null
/* * tlv320aic325x-core.c -- driver for TLV320AIC3XXX * * Author: Mukund Navada <navada@ti.com> * Mehar Bajwa <mehar.bajwa@ti.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * 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., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/i2c.h> #include <linux/err.h> #include <linux/delay.h> #include <linux/regmap.h> #include <linux/mfd/core.h> #include <linux/pm_runtime.h> #include <linux/regulator/consumer.h> #include <linux/regulator/machine.h> #include <linux/gpio.h> #include <linux/mfd/tlv320aic325x-core.h> #include <linux/mfd/tlv320aic325x-registers.h> #include <linux/mfd/tlv320aic3256-registers.h> /** * set_aic325x_book: change book which we have to write/read to. * * @aic325x: Device to write/read to. * @book: Book to write/read to. */ int set_aic325x_book(struct aic325x *aic325x, int book) { int ret = 0; u8 page_buf[] = { 0x0, 0x0 }; u8 book_buf[] = { 0x7f, 0x0 }; ret = regmap_write(aic325x->regmap, page_buf[0], page_buf[1]); if (ret < 0) return ret; book_buf[1] = book; ret = regmap_write(aic325x->regmap, book_buf[0], book_buf[1]); if (ret < 0) return ret; aic325x->book_no = book; aic325x->page_no = 0; return ret; } /** * set_aic325x_page: change page which we have to write/read to. * * @aic325x: Device to write/read to. * @page: Book to write/read to. */ int set_aic325x_page(struct aic325x *aic325x, int page) { int ret = 0; u8 page_buf[] = { 0x0, 0x0 }; page_buf[1] = page; ret = regmap_write(aic325x->regmap, page_buf[0], page_buf[1]); if (ret < 0) return ret; aic325x->page_no = page; return ret; } /** * aic325x_reg_read: Read a single TLV320AIC3xxx register. * * @aic325x: Device to read from. * @reg: Register to read. */ int aic325x_reg_read(struct aic325x *aic325x, unsigned int reg) { unsigned int val; int ret; union aic325x_reg_union *aic_reg = (union aic325x_reg_union *) &reg; u8 book, page, offset; page = aic_reg->aic325x_register.page; book = aic_reg->aic325x_register.book; offset = aic_reg->aic325x_register.offset; mutex_lock(&aic325x->io_lock); if (aic325x->book_no != book) { ret = set_aic325x_book(aic325x, book); if (ret < 0) { mutex_unlock(&aic325x->io_lock); return ret; } } if (aic325x->page_no != page) { ret = set_aic325x_page(aic325x, page); if (ret < 0) { mutex_unlock(&aic325x->io_lock); return ret; } } ret = regmap_read(aic325x->regmap, offset, &val); mutex_unlock(&aic325x->io_lock); if (ret < 0) return ret; else return val; } EXPORT_SYMBOL_GPL(aic325x_reg_read); /** * aic325x_bulk_read: Read multiple TLV320AIC3XXX registers * * @aic325x: Device to read from * @reg: First register * @count: Number of registers * @buf: Buffer to fill. The data will be returned big endian. */ int aic325x_bulk_read(struct aic325x *aic325x, unsigned int reg, int count, u8 *buf) { int ret; union aic325x_reg_union *aic_reg = (union aic325x_reg_union *) &reg; u8 book, page, offset; page = aic_reg->aic325x_register.page; book = aic_reg->aic325x_register.book; offset = aic_reg->aic325x_register.offset; mutex_lock(&aic325x->io_lock); if (aic325x->book_no != book) { ret = set_aic325x_book(aic325x, book); if (ret < 0) { mutex_unlock(&aic325x->io_lock); return ret; } } if (aic325x->page_no != page) { ret = set_aic325x_page(aic325x, page); if (ret < 0) { mutex_unlock(&aic325x->io_lock); return ret; } } ret = regmap_bulk_read(aic325x->regmap, offset, buf, count); mutex_unlock(&aic325x->io_lock); return ret; } EXPORT_SYMBOL_GPL(aic325x_bulk_read); /** * aic325x_reg_write: Write a single TLV320AIC3XXX register. * * @aic325x: Device to write to. * @reg: Register to write to. * @val: Value to write. */ int aic325x_reg_write(struct aic325x *aic325x, unsigned int reg, unsigned char val) { union aic325x_reg_union *aic_reg = (union aic325x_reg_union *) &reg; int ret = 0; u8 page, book, offset; page = aic_reg->aic325x_register.page; book = aic_reg->aic325x_register.book; offset = aic_reg->aic325x_register.offset; mutex_lock(&aic325x->io_lock); if (book != aic325x->book_no) { ret = set_aic325x_book(aic325x, book); if (ret < 0) { mutex_unlock(&aic325x->io_lock); return ret; } } if (page != aic325x->page_no) { ret = set_aic325x_page(aic325x, page); if (ret < 0) { mutex_unlock(&aic325x->io_lock); return ret; } } ret = regmap_write(aic325x->regmap, offset, val); mutex_unlock(&aic325x->io_lock); return ret; } EXPORT_SYMBOL_GPL(aic325x_reg_write); /** * aic325x_bulk_write: Write multiple TLV320AIC3XXX registers * * @aic325x: Device to write to * @reg: First register * @count: Number of registers * @buf: Buffer to write from. Data must be big-endian formatted. */ int aic325x_bulk_write(struct aic325x *aic325x, unsigned int reg, int count, const u8 *buf) { union aic325x_reg_union *aic_reg = (union aic325x_reg_union *) &reg; int ret = 0; u8 page, book, offset; page = aic_reg->aic325x_register.page; book = aic_reg->aic325x_register.book; offset = aic_reg->aic325x_register.offset; mutex_lock(&aic325x->io_lock); if (book != aic325x->book_no) { ret = set_aic325x_book(aic325x, book); if (ret < 0) { mutex_unlock(&aic325x->io_lock); return ret; } } if (page != aic325x->page_no) { ret = set_aic325x_page(aic325x, page); if (ret < 0) { mutex_unlock(&aic325x->io_lock); return ret; } } ret = regmap_raw_write(aic325x->regmap, offset, buf, count); mutex_unlock(&aic325x->io_lock); return ret; } EXPORT_SYMBOL_GPL(aic325x_bulk_write); /** * aic325x_set_bits: Set the value of a bitfield in a TLV320AIC3XXX register * * @aic325x: Device to write to. * @reg: Register to write to. * @mask: Mask of bits to set. * @val: Value to set (unshifted) */ int aic325x_set_bits(struct aic325x *aic325x, unsigned int reg, unsigned char mask, unsigned char val) { union aic325x_reg_union *aic_reg = (union aic325x_reg_union *) &reg; int ret = 0; u8 page, book, offset; page = aic_reg->aic325x_register.page; book = aic_reg->aic325x_register.book; offset = aic_reg->aic325x_register.offset; mutex_lock(&aic325x->io_lock); if (book != aic325x->book_no) { ret = set_aic325x_book(aic325x, book); if (ret < 0) { mutex_unlock(&aic325x->io_lock); return ret; } } if (page != aic325x->page_no) { ret = set_aic325x_page(aic325x, page); if (ret < 0) { mutex_unlock(&aic325x->io_lock); return ret; } } ret = regmap_update_bits(aic325x->regmap, offset, mask, val); mutex_unlock(&aic325x->io_lock); return ret; } EXPORT_SYMBOL_GPL(aic325x_set_bits); /** * aic325x_wait_bits: wait for a value of a bitfield in a TLV320AIC3XXX register * * @aic325x: Device to write to. * @reg: Register to write to. * @mask: Mask of bits to set. * @val: Value to set (unshifted) * @sleep: delay value in each iteration in micro seconds * @count: iteration count for timeout */ int aic325x_wait_bits(struct aic325x *aic325x, unsigned int reg, unsigned char mask, unsigned char val, int sleep, int counter) { int status; int timeout = sleep * counter; status = aic325x_reg_read(aic325x, reg); while (((status & mask) != val) && counter) { usleep_range(sleep, sleep + 500); status = aic325x_reg_read(aic325x, reg); counter--; }; if (!counter) dev_err(aic325x->dev, "wait_bits timedout (%d millisecs). lastval 0x%x\n", timeout, status); return counter; } EXPORT_SYMBOL_GPL(aic325x_wait_bits); static struct mfd_cell aic3262_devs[] = { { .name = "tlv320aic3262-codec", }, { .name = "tlv320aic3262-gpio", }, }; static struct mfd_cell aic3256_devs[] = { { .name = "tlv320aic325x-codec", }, { .name = "tlv320aic3256-gpio", }, }; /** * Instantiate the generic non-control parts of the device. */ int aic325x_device_init(struct aic325x *aic325x) { const char *devname; int ret, i; u8 reset = 1; dev_info(aic325x->dev, "aic325x_device_init beginning\n"); mutex_init(&aic325x->io_lock); dev_set_drvdata(aic325x->dev, aic325x); if (dev_get_platdata(aic325x->dev)) memcpy(&aic325x->pdata, dev_get_platdata(aic325x->dev), sizeof(aic325x->pdata)); /* GPIO reset for TLV320AIC3xxx codec */ if (aic325x->pdata.gpio_reset) { ret = gpio_request_one(aic325x->pdata.gpio_reset, GPIOF_DIR_OUT | GPIOF_INIT_LOW, "aic325x-reset-pin"); if (ret != 0) { dev_err(aic325x->dev, "not able to acquire gpio\n"); goto err_return; } } /* run the codec through software reset */ ret = aic325x_reg_write(aic325x, AIC3XXX_RESET, reset); if (ret < 0) { dev_err(aic325x->dev, "Could not write to AIC3XXX register\n"); goto err_return; } usleep_range(10000, 10500); ret = aic325x_reg_read(aic325x, AIC3XXX_DEVICE_ID); if (ret < 0) { dev_err(aic325x->dev, "Failed to read ID register\n"); goto err_return; } devname = "TLV320AIC3256"; aic325x->type = TLV320AIC3256; /*If naudint is gpio convert it to irq number */ if (aic325x->pdata.gpio_irq == 1) { aic325x->irq = gpio_to_irq(aic325x->pdata.naudint_irq); gpio_request(aic325x->pdata.naudint_irq, "aic325x-gpio-irq"); gpio_direction_input(aic325x->pdata.naudint_irq); } else { aic325x->irq = aic325x->pdata.naudint_irq; } for (i = 0; i < aic325x->pdata.num_gpios; i++) { aic325x_reg_write(aic325x, aic325x->pdata.gpio_defaults[i].reg, aic325x->pdata.gpio_defaults[i].value); } if (aic325x->irq) { ret = aic325x_irq_init(aic325x); if (ret < 0) goto err_irq; } dev_info(aic325x->dev, "%s revision %c\n", devname, 'D' + ret); switch (aic325x->type) { case TLV320AIC3266: case TLV320AIC3262: ret = mfd_add_devices(aic325x->dev, -1, aic3262_devs, ARRAY_SIZE(aic3262_devs), NULL, 0, NULL); break; case TLV320AIC3256: ret = mfd_add_devices(aic325x->dev, -1, aic3256_devs, ARRAY_SIZE(aic3256_devs), NULL, 0, NULL); break; default: dev_err(aic325x->dev, "unable to recognize codec\n"); break; } if (ret != 0) { dev_err(aic325x->dev, "Failed to add children: %d\n", ret); goto err_mfd; } dev_info(aic325x->dev, "aic325x_device_init added mfd devices\n"); return 0; err_mfd: aic325x_irq_exit(aic325x); err_irq: if (aic325x->pdata.gpio_irq) gpio_free(aic325x->pdata.naudint_irq); err_return: if (aic325x->pdata.gpio_reset) gpio_free(aic325x->pdata.gpio_reset); return ret; } EXPORT_SYMBOL_GPL(aic325x_device_init); void aic325x_device_exit(struct aic325x *aic325x) { mfd_remove_devices(aic325x->dev); aic325x_irq_exit(aic325x); if (aic325x->pdata.gpio_irq) gpio_free(aic325x->pdata.naudint_irq); if (aic325x->pdata.gpio_reset) gpio_free(aic325x->pdata.gpio_reset); } EXPORT_SYMBOL_GPL(aic325x_device_exit); MODULE_AUTHOR("Mukund Navada <navada@ti.comm>"); MODULE_AUTHOR("Mehar Bajwa <mehar.bajwa@ti.com>"); MODULE_DESCRIPTION("Core support for the TLV320AIC3XXX audio CODEC"); MODULE_LICENSE("GPL");
24.928726
80
0.697193
f7a17e77784c7aac1dca65d8239a92989cfce435
2,139
h
C
RobotSwarm/RobotSwarmDLL/CameraConfig.h
saccharios/MasterThesis
6c1a72d0cdd3c08db1993d4527ebe2f660d1244d
[ "MIT" ]
null
null
null
RobotSwarm/RobotSwarmDLL/CameraConfig.h
saccharios/MasterThesis
6c1a72d0cdd3c08db1993d4527ebe2f660d1244d
[ "MIT" ]
null
null
null
RobotSwarm/RobotSwarmDLL/CameraConfig.h
saccharios/MasterThesis
6c1a72d0cdd3c08db1993d4527ebe2f660d1244d
[ "MIT" ]
null
null
null
#ifndef _CAMERACONFIG_H_ #define _CAMERACONFIG_H_ // Author: Stefan Frei, 2013 //const int WIDTH_PIX = 1920; //in pixel = 265 cm //const int HEIGHT_PIX = 1080; //in pixel = 195 cm // //const float WIDTH_WORLD = 330; //in cm - dependant on resolution and your camera - this is what the camera sees (given constant mapping from pix to cm) //const float HEIGHT_WORLD = 200; //in cm - dependant on resolution and your camera - this is what the camera sees //260 , 200 // //// Define available region on the table. //const float OFFSET_X = 185; // in cm //const float OFFSET_Y = 15; //in cm ////35, 15 // //const float WIDTH_TABLE = 90;// in cm - effective available space on table, depends on resolution //const float HEIGHT_TABLE = 175; //in cm - effective available space on table, depends on resolution ////260, 175 //// make sure that OFFSET_X + WIDTH_TABLE <= WIDTH_WORLD and OFFSET_Y + HEIGHT_TABLE <= HEIGHT_WORLD // //const float SAMPLING_TIME_CAMERA = 0.2f; const int WIDTH_PIX = 640; //in pixel = 265 cm const int HEIGHT_PIX = 480; //in pixel = 195 cm const float WIDTH_WORLD = 260; //in cm - dependant on resolution and your camera - this is what the camera sees (given constant mapping from pix to cm) const float HEIGHT_WORLD = 195; //in cm - dependant on resolution and your camera - this is what the camera sees //260 , 195 // Define available region on the table. const float OFFSET_X = 10; // in cm, 10 const float OFFSET_Y = 10; //in cm, 10 const float WIDTH_TABLE = 225;// in cm - effective available space on table, depends on resolution const float HEIGHT_TABLE = 175; //in cm - effective available space on table, depends on resolution //240, 175 // make sure that OFFSET_X + WIDTH_TABLE <= WIDTH_WORLD and OFFSET_Y + HEIGHT_TABLE <= HEIGHT_WORLD const float SAMPLING_TIME_CAMERA = 0.048f; // Define Size of output windows (only display) const int SHOW_XPIX = 640; const int SHOW_YPIX = 480; // Add userspecific configuration for outputs // 1 = Alex // 2 = Stefan const int USER_NAME = 2; // Choose extenden kalman filter type // 1, inputs estimated // 2, give inputs const int EKFtype = 2; #endif
35.65
153
0.721833
ee2144ecc9f8265ff79c2321648929f92d38c2fe
8,860
c
C
util/iseltime.c
MichaelTien8901/ipmiutil
5cc58de93101c939535bdd2aa146d21a66b5c389
[ "OpenSSL", "BSD-3-Clause" ]
13
2020-03-24T03:13:04.000Z
2021-09-06T17:09:21.000Z
util/iseltime.c
MichaelTien8901/ipmiutil
5cc58de93101c939535bdd2aa146d21a66b5c389
[ "OpenSSL", "BSD-3-Clause" ]
3
2020-07-12T01:31:23.000Z
2022-02-22T19:49:23.000Z
util/iseltime.c
MichaelTien8901/ipmiutil
5cc58de93101c939535bdd2aa146d21a66b5c389
[ "OpenSSL", "BSD-3-Clause" ]
4
2020-06-21T19:21:04.000Z
2021-09-23T00:20:58.000Z
/* * iseltime.c * * Author: Andy Cress arcress at users.sourceforge.net * * 05/11/09 Andy Cress v1.0 - created * 07/23/10 Andy Cress v1.1 - always show System time also * 08/20/10 Andy Cress v1.2 - show/set RTC time also if Linux * 03/16/17 Andy Cress 3.03 - show/set UTC offset also */ /*M* Copyright (c) 2013, Andy Cress All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: a.. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. b.. 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 OWNER 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. *M*/ #ifdef WIN32 #include <windows.h> #include <stdio.h> #include "getopt.h" #elif defined(EFI) // EFI: defined (EFI32) || defined (EFI64) || defined(EFIX64) #ifndef NULL #define NULL 0 #endif #include <types.h> #include <libdbg.h> #include <unistd.h> #include <errno.h> #elif defined(DOS) #include <dos.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "getopt.h" #else /* Linux, Solaris, BSD */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #if defined(HPUX) /* getopt is defined in stdio.h */ #elif defined(MACOS) /* getopt is defined in unistd.h */ #include <unistd.h> #else #include <getopt.h> #endif #endif #include <time.h> #include <string.h> #include "ipmicmd.h" #define GET_SELTIME 0x48 #define SET_SELTIME 0x49 #define GET_SELUTC 0x5C #define SET_SELUTC 0x5D /* * Global variables */ #ifdef METACOMMAND extern char * progver; /*from ipmiutil.c*/ static char * progname = "ipmiutil seltime"; #else static char * progver = "3.08"; static char * progname = "iseltime"; #endif static char fdebug = 0; static char fset = 0; static uchar ipmi_maj = 0; static uchar ipmi_min = 0; static int get_sel_utc(uchar *rdata, int rlen) { uchar idata[4]; uchar ccode; int ret; ret = ipmi_cmdraw(GET_SELUTC, NETFN_STOR, BMC_SA, PUBLIC_BUS, BMC_LUN, idata, 0, rdata, &rlen, &ccode, fdebug); if (ret == 0 && ccode != 0) ret = ccode; return(ret); } /*end get_sel_utc()*/ static int set_sel_utc(short offset) { uchar idata[4]; uchar rdata[16]; int rlen = 8; int ret; uchar ccode; idata[0] = (uchar)(offset & 0x00ff); idata[1] = (uchar)((offset >> 8) & 0x00ff); ret = ipmi_cmdraw(SET_SELUTC, NETFN_STOR, BMC_SA, PUBLIC_BUS, BMC_LUN, idata, 2, rdata, &rlen, &ccode, fdebug); if (ret == 0 && ccode != 0) ret = ccode; return(ret); } /*end set_sel_utc()*/ static int get_sel_time(uchar *rdata, int rlen) { uchar idata[4]; uchar ccode; int ret; ret = ipmi_cmdraw(GET_SELTIME, NETFN_STOR, BMC_SA, PUBLIC_BUS, BMC_LUN, idata, 0, rdata, &rlen, &ccode, fdebug); if (ret == 0 && ccode != 0) ret = ccode; return(ret); } /*end get_sel_time()*/ static int set_sel_time(time_t newtime) { uchar idata[4]; uchar rdata[16]; int rlen = 8; int ret; uchar ccode; idata[0] = (uchar)(newtime & 0x00ff); idata[1] = (uchar)((newtime >> 8) & 0x00ff); idata[2] = (uchar)((newtime >> 16) & 0x00ff); idata[3] = (uchar)((newtime >> 24) & 0x00ff); ret = ipmi_cmdraw(SET_SELTIME, NETFN_STOR, BMC_SA, PUBLIC_BUS, BMC_LUN, idata, 4, rdata, &rlen, &ccode, fdebug); if (ret == 0 && ccode != 0) ret = ccode; return(ret); } /*end set_sel_time()*/ time_t utc2local(time_t t) { struct tm * tm_tmp; int gt_year,gt_yday,gt_hour,lt_year,lt_yday,lt_hour; int delta_hour; time_t lt; //modify UTC time to local time expressed in number of seconds from 1/1/70 0:0:0 1970 GMT // check for dst? tm_tmp=gmtime(&t); gt_year=tm_tmp->tm_year; gt_yday=tm_tmp->tm_yday; gt_hour=tm_tmp->tm_hour; tm_tmp=localtime(&t); lt_year=tm_tmp->tm_year; lt_yday=tm_tmp->tm_yday; lt_hour=tm_tmp->tm_hour; delta_hour=lt_hour - gt_hour; if ( (lt_year > gt_year) || ((lt_year == gt_year) && (lt_yday > gt_yday)) ) delta_hour += 24; if ( (lt_year < gt_year) || ((lt_year == gt_year) && (lt_yday < gt_yday)) ) delta_hour -= 24; if (fdebug) printf("utc2local: delta_hour = %d\n",delta_hour); lt = t + (delta_hour * 60 * 60); return(lt); } #define TIMESTR_SZ 30 void show_time(time_t etime, int doutc) { char buf[TIMESTR_SZ]; int bufsz = TIMESTR_SZ; time_t t; strcpy(buf,"00/00/00 00:00:00"); if (doutc) t = utc2local(etime); else t = etime; strftime(buf,bufsz, "%x %H:%M:%S", gmtime(&t)); /*or "%x %T"*/ printf("%s\n",buf); return; } #ifdef METACOMMAND int i_iseltime(int argc, char **argv) #else #ifdef WIN32 int __cdecl #else int #endif main(int argc, char **argv) #endif { int rv = 0; uchar devrec[20]; uchar timebuf[4]; time_t ltime1, ltime2, ltime3; short offset; int c; #if defined (EFI) InitializeLib(_LIBC_EFIImageHandle, _LIBC_EFISystemTable); #else printf("%s ver %s\n", progname,progver); #endif while ( (c = getopt( argc, argv,"sT:V:J:EYF:P:N:R:U:x?")) != EOF ) switch(c) { case 's': fset = 1; break; /* read only */ case 'x': fdebug = 1; break; /* debug messages */ case 'N': /* nodename */ case 'U': /* remote username */ case 'P': /* remote password */ case 'R': /* remote password */ case 'E': /* get password from IPMI_PASSWORD environment var */ case 'F': /* force driver type */ case 'T': /* auth type */ case 'J': /* cipher suite */ case 'V': /* priv level */ case 'Y': /* prompt for remote password */ parse_lan_options(c,optarg,fdebug); break; default: printf("Usage: %s [-sx -NUPRETVF]\n", progname); printf(" where -s Set SEL time (usually once a day)\n"); printf(" -x show eXtra debug messages\n"); print_lan_opt_usage(0); exit(1); } rv = ipmi_getdeviceid(devrec,16,fdebug); if (rv != 0) { show_outcome(progname,rv); ipmi_close_(); exit(rv); } else { ipmi_maj = devrec[4] & 0x0f; ipmi_min = devrec[4] >> 4; #ifndef EFI printf("-- BMC version %x.%x, IPMI version %d.%d \n", devrec[2], devrec[3], ipmi_maj, ipmi_min); #endif } offset = 0; rv = get_sel_utc((uchar *)&offset,2); if (fdebug) printf("get_sel_utc: ret=%x offset=%d\n",rv,offset); if (rv == 0) { /* TODO: get system UTC offset */ rv = set_sel_utc(offset); printf("set_sel_utc(%d): ret=%x\n",offset,rv); } rv = get_sel_time(&timebuf[0],4); if (rv != 0) { printf("get_sel_time error: ret = %x\n",rv); ipmi_close_(); exit(1); } time(&ltime2); printf("Current System time: "); show_time(ltime2,1); ltime1 = timebuf[0] + (timebuf[1] << 8) + (timebuf[2] << 16) + (timebuf[3] << 24); printf("Current SEL time: "); show_time(ltime1,0); // if (fdebug) ltime3 = utc2local(ltime1); if (fset == 1) { /* get current time */ time(&ltime2); rv = set_sel_time(ltime2); printf("Setting SEL time to System Time: ret = %x\n",rv); if (rv != 0) printf("set_sel_time error: ret = %x\n",rv); else { /*successful*/ rv = get_sel_time(timebuf,8); if (rv != 0) printf("get_sel_time error: ret = %x\n",rv); else { ltime3 = timebuf[0] + (timebuf[1] << 8) + (timebuf[2] << 16) + (timebuf[3] << 24); printf("New SEL time: "); show_time(ltime3,0); } } } #ifdef LINUX if (is_remote() == 0) { c = system("echo \"Current RTC time: `hwclock`\""); if (fset == 1) { c = system("hwclock --systohc"); printf("Copying System Time to RTC: ret = %d\n",c); } } #endif ipmi_close_(); show_outcome(progname,rv); exit (rv); } /* end main()*/ /* end iseltime.c */
28.954248
92
0.622912
919117331767b0f7f969af6bf4e389ed7ecf3dc9
2,715
h
C
usermonitor/server/poller/groups_p.h
kbore/pbis-open
a05eb9309269b6402b4d6659bc45961986ea5eab
[ "Apache-2.0" ]
372
2016-10-28T10:50:35.000Z
2022-03-18T19:54:37.000Z
usermonitor/server/poller/groups_p.h
kbore/pbis-open
a05eb9309269b6402b4d6659bc45961986ea5eab
[ "Apache-2.0" ]
317
2016-11-02T17:41:48.000Z
2021-11-08T20:28:19.000Z
usermonitor/server/poller/groups_p.h
kenferrara/pbis-open
690c325d947b2bf6fb3032f9d660e41b94aea4be
[ "Apache-2.0" ]
107
2016-11-03T19:25:16.000Z
2022-03-20T21:15:22.000Z
/* Editor Settings: expandtabs and use 4 spaces for indentation * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: * * -*- mode: c, c-basic-offset: 4 -*- */ /* * Copyright © BeyondTrust Software 2004 - 2019 * All rights reserved. * * 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. * * BEYONDTRUST MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING TERMS AS * WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT WITH * BEYONDTRUST, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE TERMS OF THAT * SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE APACHE LICENSE, * NOTWITHSTANDING THE ABOVE NOTICE. IF YOU HAVE QUESTIONS, OR WISH TO REQUEST * A COPY OF THE ALTERNATE LICENSING TERMS OFFERED BY BEYONDTRUST, PLEASE CONTACT * BEYONDTRUST AT beyondtrust.com/contact */ /* * Copyright (C) BeyondTrust Software. All rights reserved. * * Module Name: * * groups_p.h * * Abstract: * * User monitor service for local users and groups * * Functions internal to this package for enumerating and tracking * users. * * Authors: Kyle Stemen <kstemen@beyondtrust.com> * */ #ifndef __GROUPS_P_H__ #define __GROUPS_P_H__ VOID UmnSrvFreeGroupContents( PUSER_MONITOR_GROUP pGroup ); DWORD UmnSrvReadGroup( PCSTR pParentKey, PSTR pName, PUSER_MONITOR_GROUP pResult ); DWORD UmnSrvFindDeletedGroups( PLW_EVENTLOG_CONNECTION pEventlog, HANDLE hReg, PCSTR pGroupKeyName, HKEY hGroups, long long Now ); DWORD UmnSrvUpdateGroups( HANDLE hLsass, PLW_EVENTLOG_CONNECTION pEventlog, HANDLE hReg, HKEY hParameters, long long PreviousRun, long long Now ); DWORD UmnSrvWriteGroupMemberEvent( PLW_EVENTLOG_CONNECTION pEventlog, long long Now, PCSTR pGroupKeyName, long long PreviousRun, BOOLEAN AddMember, BOOLEAN OnlyGidChange, PCSTR pUserName, DWORD Gid, PCSTR pGroupName ); DWORD UmnSrvFindDeletedGroupMembers( PLW_EVENTLOG_CONNECTION pEventlog, HANDLE hReg, PCSTR pGroupKeyName, HKEY hMembers, long long Now, BOOLEAN GidOnlyChange, DWORD Gid, PCSTR pGroupName ); #endif /* __GROUPS_P_H__ */
25.373832
81
0.718232
dc26978c6bd4eebaa3b5b9f5bc56a9577f052d92
415
h
C
mwc/romana/relic/a/usr/man/COHERENT/v7sgtty.h
gspu/Coherent
299bea1bb52a4dcc42a06eabd5b476fce77013ef
[ "BSD-3-Clause" ]
20
2019-10-10T14:14:56.000Z
2022-02-24T02:54:38.000Z
mwc/romana/relic/a/usr/man/COHERENT/v7sgtty.h
gspu/Coherent
299bea1bb52a4dcc42a06eabd5b476fce77013ef
[ "BSD-3-Clause" ]
null
null
null
mwc/romana/relic/a/usr/man/COHERENT/v7sgtty.h
gspu/Coherent
299bea1bb52a4dcc42a06eabd5b476fce77013ef
[ "BSD-3-Clause" ]
1
2022-03-25T18:38:37.000Z
2022-03-25T18:38:37.000Z
v7sgtty.h Header File v7sgtty.h UNIX Version 7-style terminal I/O #include <v7sgtty.h> v7sgtty.h defines structures and constants used by routines that perform terminal I/O in the manner of UNIX version 7. ***** See Also ***** header files, sgtty.h, tty.h COHERENT Lexicon Page 1
6.19403
65
0.513253
40866b2c3a029efbb5ce5906eb1aa8df8a24587d
601
h
C
src/ApplicationConfig/SdkModel/IApplicationConfigurationVersionProvider.h
eegeo/cardboard-vr-integration
3f0c3d0f1b7ddaa6b2ef980e46ead71c8a85a260
[ "BSD-2-Clause" ]
8
2017-07-02T01:14:29.000Z
2021-06-19T07:14:38.000Z
src/ApplicationConfig/SdkModel/IApplicationConfigurationVersionProvider.h
eegeo/cardboard-vr-demo
3f0c3d0f1b7ddaa6b2ef980e46ead71c8a85a260
[ "BSD-2-Clause" ]
null
null
null
src/ApplicationConfig/SdkModel/IApplicationConfigurationVersionProvider.h
eegeo/cardboard-vr-demo
3f0c3d0f1b7ddaa6b2ef980e46ead71c8a85a260
[ "BSD-2-Clause" ]
5
2018-02-07T07:43:51.000Z
2020-01-24T12:29:25.000Z
// Copyright eeGeo Ltd (2012-2015), All Rights Reserved #pragma once #include "ApplicationConfiguration.h" #include <string> namespace Examples { namespace ApplicationConfig { namespace SdkModel { class IApplicationConfigurationVersionProvider { public: virtual ~IApplicationConfigurationVersionProvider() { } virtual std::string GetProductVersionString() const = 0; virtual std::string GetBuildNumberString() const = 0; }; } } }
21.464286
72
0.569052