blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
250
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
58
license_type
stringclasses
2 values
repo_name
stringlengths
5
107
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
185 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
15.7k
664M
โŒ€
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
68 values
src_encoding
stringclasses
27 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
6
9.36M
extension
stringclasses
31 values
content
stringlengths
4
9.36M
authors
sequencelengths
1
1
author
stringlengths
0
73
6e142e946a8eea810bceb15f7ada544ab9931cb0
6ef6213d2fa39d1d0ab7e2373d882b9d263e8c6d
/ti_components/algorithms/vlib_c66x_3_3_2_0/packages/ti/vlib/src/VLIB_ORB_computeOrientation/VLIB_ORB_computeOrientation_cn.h
b894dbc58a0b2a4caf5af6d8c2a4c550a38628ff
[]
no_license
Zhangh2018/PROCESSOR_SDK_VISION_03_06_00_00
9c380d3167b156a11a8f21814e94ac5550cddc87
05c72de5d031006c7565d4234abd53670a926acd
refs/heads/master
2021-10-16T13:43:05.313000
2019-02-11T09:10:44
2019-02-11T09:10:44
null
0
0
null
null
null
null
UTF-8
C
false
false
3,069
h
/******************************************************************************* **+--------------------------------------------------------------------------+** **| **** |** **| **** |** **| ******o*** |** **| ********_///_**** |** **| ***** /_//_/ **** |** **| ** ** (__/ **** |** **| ********* |** **| **** |** **| *** |** **| |** **| Copyright (c) 2007-2012 Texas Instruments Incorporated |** **| ALL RIGHTS RESERVED |** **| |** **| Permission to use, copy, modify, or distribute this software, |** **| whether in part or in whole, for any purpose is forbidden without |** **| a signed licensing agreement and NDA from Texas Instruments |** **| Incorporated (TI). |** **| |** **| TI makes no representation or warranties with respect to the |** **| performance of this computer program, and specifically disclaims |** **| any responsibility for any damages, special or consequential, |** **| connected with the use of this program. |** **| |** **+--------------------------------------------------------------------------+** *******************************************************************************/ #ifndef VLIB_ORB_COMPUTEORIENTATION_CN_H_ #define VLIB_ORB_COMPUTEORIENTATION_CN_H_ 1 #include "../common/VLIB_types.h" #include "../common/VLIB_orb.h" CORBResult VLIB_ORB_computeOrientation_cn(uint8_t *inImg, uint16_t imgWidth, uint16_t imgHeight, uint16_t imgPitch, uint32_t *featuresLoc, uint16_t numFeatures, int16_t *outAngle, uint8_t *momentPattern, uint8_t *scratch); #endif /* ======================================================================== */ /* End of file: VLIB_ORB_computeOrientation_cn.h */ /* ======================================================================== */
[ "yukichen@otobrite.com" ]
yukichen@otobrite.com
87b393e0e37d196a9779122a7240425d0269f0da
3c406f63a82affe48a40c6e4312ad071aebcf62e
/static/test.c
d6839978199fc1bb3d5e211d972bd5e850265b0f
[]
no_license
vivek703/OWN_EXP
d1a2c78ea69a7114088783e373660d2d39ed317e
fe0f7359693d8822b52121e07d808495f1c93e5e
refs/heads/master
2022-05-29T13:37:09.261000
2020-05-04T18:23:16
2020-05-04T18:23:16
257,104,389
0
0
null
null
null
null
UTF-8
C
false
false
125
c
#include "test.h" #include <stdio.h> static int static_1(void) { printf("HI\n"); } void test(void) { static_1(); }
[ "vivekp9922@gmail.com" ]
vivekp9922@gmail.com
cf438c03fe427b18d5ef0c3ee6b083cbcaf7fb89
2837f8a4e1c618f00ad7ba5cf4c248232ea1743b
/1012.c
13ca81f31503b51ffd86f58d4a77bd3cf3a1fc50
[]
no_license
jorgeduartejr/URI-online-judge---C
c56a2e887db097725694bef25ac390e9edb38b26
d913288c68870f1058bd7fb0ce754ebc3a015ef8
refs/heads/main
2023-07-17T19:04:10.937000
2021-08-24T22:33:49
2021-08-24T22:33:49
399,618,839
0
0
null
null
null
null
UTF-8
C
false
false
610
c
#include <stdio.h> int main() { double A,B,C; double areaTriangulo, areaCirculo, areaTrapezio, areaQuadrado, areaRetangulo; double pi = 3.14159; scanf("%lf""%lf""%lf", &A,&B,&C); areaTriangulo = (A * C)/2; areaCirculo = C * C * pi; areaTrapezio = ((A + B) * C)/2; areaQuadrado = B * B; areaRetangulo = A * B; printf("TRIANGULO: %.3lf\n", areaTriangulo); printf("CIRCULO: %.3lf\n",areaCirculo); printf("TRAPEZIO: %.3lf\n",areaTrapezio); printf("QUADRADO: %.3lf\n", areaQuadrado); printf("RETANGULO: %.3lf\n", areaRetangulo); return 0; }
[ "migueljunior1000@gmail.com" ]
migueljunior1000@gmail.com
6e4b62fc82e9d7f43ce043d45c270328142a1c71
dec6419e67295954f5c526d9631685d9d8499342
/src/xoip_messages.c
7d8d11f458027296451ce911469b4db64fdc59bf
[]
no_license
vassilux/xoip2
23029e19221f98fbb24368259ba0770541cdb8e2
4893d31a9dbad1fc585b515c3a371ce59f752180
refs/heads/master
2021-01-01T05:49:33.621000
2014-08-21T14:12:06
2014-08-21T14:12:06
null
0
0
null
null
null
null
UTF-8
C
false
false
10,909
c
/* * XoIP -- telephony toolkit. * * Copyright (C) <2014>, <vassilux> * * <Vassili Gontcharov> <v.gontcharov@gmail.com> * */ /*! \file * * \brief Xoipeton application * * \author\verbatim <Vassili Gontcharov> <vassili.gontcharov@esifrance.net> \endverbatim * * This is a Xoip for development of an Asterisk application * \ingroup applications */ /*** MODULEINFO <defaultenabled>no</defaultenabled> <support_level>core</support_level> ***/ #include <stdio.h> #include <stdlib.h> #include "asterisk.h" #include "asterisk/logger.h" //#include "asterisk/astmm.h" #include "xoip_messages.h" int do_process_message (const char *buf, int size, struct f1_messages_handlers *handlers); static void do_process_message_fa(int track, int callref, char *code, struct f1_messages_handlers *handlers) { if(code == NULL){ return; } if(code[0] == 'M'){ handlers->mute_micro_operator(track, callref, true); }else if(code[0] == 'N'){ handlers->mute_micro_operator(track, callref, false); } } /*! * \brief Intiaialize the emmessions configuration for the given communication. * * \param track The track number. * \param callref The call reference. * \param messages The string array of parameters. * \param handlers The pointer to the wrapper of the app_xoip functions. */ static void do_process_message_fc(int track, int callref, char messages[10][255], struct f1_messages_handlers *handlers) { char *emmission_type = messages[3]; int dtmf_duration = 0; int silence_duration = 0; int loudness = 0; if(emmission_type != NULL &&(strcmp(emmission_type, "DTMF") == 0)){ if(messages[4] != NULL){ /* * pay an attention cause the F1 send packege without , between DTMF * and duration */ dtmf_duration = atoi(messages[4] + 4); // move 4 to skip DTMF string } if(messages[5] != NULL){ silence_duration = atoi(messages[5]); } if(messages[6] != NULL){ loudness = atoi(messages[6]); } } } /*! * \brief Send the frequencies to th] channel identified by the given track and callref */ static void do_process_message_ff(int track, int callref, char messages[10][255], struct f1_messages_handlers *handlers) { int freq; int duration; int level; char *mode = NULL; char *break_record; if(messages[3] != NULL){ freq = atoi(messages[3]); } if(messages[4] != NULL){ duration = atoi(messages[4]); } if(messages[5] != NULL){ level = atoi(messages[5]); } mode = messages[6]; break_record = messages[6]; handlers->send_freq(track, callref, freq, duration, level, mode, break_record); } /*! * \brief Process FL message. Send data to the channel identificated by the given track and callref */ static void do_process_message_fl(int track, int callref, char messages[10][255], struct f1_messages_handlers *handlers) { int mode_transfer; char *data; char *mode_operator = NULL; char *break_record; if(messages[3] != NULL){ mode_transfer = atoi(messages[3]); } data = messages[4]; mode_operator = messages[5]; break_record = messages[6]; handlers->send_data(track, callref, mode_transfer, data, mode_operator, break_record); } /*! * */ int do_process_message (const char *buf, int size, struct f1_messages_handlers *handlers) { int res = 0; char *buffer = strdup (buf); const char *sep = ","; char messages[10][255] = { '\0' }; int count = 0; ast_verb(5, "Get packet from f1 endpoint : [%s\n]", buffer); char *token = NULL; for (token = strtok (buffer, sep); token; token = strtok (NULL, sep)) { if (token != NULL) { strcpy (messages[count], token); count++; } } char type = messages[0][2]; /* this is special case for ithe polling and mode request messages */ if(messages[0][0] == 'R' && type == 'S'){ handlers->request_reboot(); goto goout; }else if(type == 'N'){ /* skip this one */ handlers->request_mode_normal(); goto goout; }else if(messages[0][0]== 'V' && type == 'R'){ goto goout; }else if(type == 'P'){ ast_verb(5, "Get polling [%s].\n", messages[3]); handlers->polling(messages[3]); goto goout; } int track = atoi (messages[1]); long callref = 0; sscanf(messages[2], "%04X", &callref); /* so far sor good */ switch (type) { case 'A': do_process_message_fa(track, callref, messages[3], handlers); break; case 'C': do_process_message_fc(track, callref, messages, handlers); break; case 'F': do_process_message_ff(track, callref, messages, handlers); break; case 'G': { char proto = messages[3][0]; int level = 0; if (messages[4] != NULL) { level = atoi (messages[4]); } handlers->answer (track, callref, proto, level); } break; case 'H': { char *callee = messages[3]; char *caller = messages[4]; char *volum = messages[5]; handlers->commut (track, callref, callee, caller, volum); } break; case 'I': { char proto = messages[3][0]; int loudness = 0; if(messages[4] != NULL){ loudness = atoi(messages[4]); } handlers->switch_protocol(track, callref, proto, loudness); } break; case 'K': handlers->ack_alarm(track, callref); break; case 'L': do_process_message_fl(track, callref, messages, handlers); break; case 'M': { int record_track = 0; if(messages[3] != NULL){ record_track = atoi(messages[4]); } handlers->record_request(track, callref, record_track); } break; case 'r': case 'R': //ast_log(AST_LOG_VERBOSE, " Processing R.\n"); handlers->hangup (track, callref); break; case 'V': { int volume; if(messages[3] != NULL){ volume = atoi(messages[3]); } handlers->volume_adjust(track, callref, volume); } break; case 'W': handlers->queuing_call(track, callref, messages[3]); break; case 'U': break; default: ast_log (AST_LOG_VERBOSE, " Processing but type not found : [%c]..\n", buf); break; } goto goout; goout: res = size; free (buffer); return res; } /*! * */ int xoip_build_XC_msg (int voie, int callref, const char *did, const char *caller, const char *transfered, char *dest, int size) { snprintf (dest, size - 1, "X C,%02d,%04X,%s,%s,T%s\r", voie, callref, did, caller, transfered); if(strlen(dest) == 0){ return -1; } return 0; } /*! * */ int xoip_build_Xg_msg (int voie, int callref, int state, int res, char *dest, int size) { if(res != 0){ snprintf (dest, size - 1, "X g,%02d,%04X,1,%01d\r", voie, callref, res); }else{ snprintf (dest, size - 1, "X g,%02d,%04X,%d\r", voie, callref,state); } if(strlen(dest) == 0){ return -1; } return 0; } /*! * */ int xoip_build_XL_msg (int voie, int callref, int res, char *dest, int size) { if(res != 0){ snprintf (dest, size - 1, "X L,%02d,%04X,1,%01d\r", voie, callref, res); }else{ snprintf (dest, size - 1, "X L,%02d,%04d\r", voie, callref); } if(strlen(dest) == 0){ return -1; } return 0; } /*! * */ int xoip_build_Xm_msg(int voie, int callref, int state, int res, char *dest, int size) { if(res != 0){ snprintf (dest, size - 1, "X m,%02d,%04X,1,%01d\r", voie, callref, res); }else{ snprintf (dest, size - 1, "X m,%02d,%04d\r", voie, callref); } if(strlen(dest) == 0){ return -1; } return 0; } /*! * */ int xoip_build_XE_msg(int status, char *dest, int size) { snprintf (dest, size - 1, "X E,%01d,%s\r", status, "XoIP Alarms-V0.2.0.80,Dem V0000,Mod V0000"); if(strlen(dest) == 0){ return -1; } return 0; } /*! * */ int xoip_build_Xr_msg (int voie, int callref, char *dest, int size) { snprintf (dest, size, "X r,%02d,%04d\r", voie, callref); return 0; } /*! * */ int xoip_build_Xh_msg (int voie, int callref, int state, const char *callee, char *dest, int size) { snprintf (dest, size, "X h,%02d,%04X,%01d,%s\r", voie, callref, state, callee); return 0; } /*! * */ int xoip_build_Xi_msg(int voie, int callref, int state, int res, char *dest, int size) { snprintf (dest, size - 1, "X i,%02d,%04X,%01d,%01d\r", voie, callref, state, res); if(strlen(dest) == 0){ return -1; } return 0; } /*! * */ int xoip_build_Xk_msg(int voie, int callref, int state, int res, char *dest, int size) { snprintf (dest, size - 1, "X k,%02d,%04X,%01d,%01d\r", voie, callref, state, res); if(strlen(dest) == 0){ return -1; } return 0; } /*! * */ int xoip_build_Xf_msg (int voie, int callref, int state, int res, char *dest, int size) { snprintf (dest, size - 1, "X f,%02d,%04X,%01d,%01d\r", voie, callref, state, res); if(strlen(dest) == 0){ return -1; } return 0; } /*! * */ int xoip_build_XA_msg (int voie, int callref, const char *data, char *dest, int size) { snprintf (dest, size, "X A,%02d,%04X,%s\r", voie, callref, data); return 0; } /*! * \brief Build X w message. * The response for f1 F W request : qeueuing a call */ int xoip_build_Xw_msg(int voie, int callref, int res, char *dest, int size) { snprintf (dest, size - 1, "X w,%02d,%04X,%01d\r", voie, callref, res); if(strlen(dest) == 0){ return -1; } return 0; } /*! * \brief Parsing message from the given buffer. * Buffer can content few messges * * \param buf messages buffer * \param size the length of the buffer * \params handlers the structur of callback for each type of message * * \retval -1 on error * \retval > 0 the lenth of processing messages */ int process_message (const char *buf, int size, struct f1_messages_handlers *handlers) { int res = 0; int i = 0; int count = 0; char *buffer = strdup (buf); const char *sep = "\r"; char *token = NULL; /* must be changed */ char messages[10][255] = { '\0' }; for (token = strtok (buffer, sep); token; token = strtok (NULL, sep)) { strcpy (messages[count], token); count++; } res = 0; for (i = 0; i < count; i++) { /* increment by the token length */ res += do_process_message (messages[i], strlen (messages[i]), handlers); } /* add to the result the number of tokens. May be addt length(sep) can be good idea */ res += count; free (buffer); return res; }
[ "v.gontcharov@gmail.com" ]
v.gontcharov@gmail.com
37c89afb473fb1f0e71c3f743b0cc646712c4985
5c255f911786e984286b1f7a4e6091a68419d049
/vulnerable_code/0f76e37c-5ba9-431e-acb0-97747e28c6bb.c
d70ff0058833ce6c0df966372d79fbd154c48354
[]
no_license
nmharmon8/Deep-Buffer-Overflow-Detection
70fe02c8dc75d12e91f5bc4468cf260e490af1a4
e0c86210c86afb07c8d4abcc957c7f1b252b4eb2
refs/heads/master
2021-09-11T19:09:59.944000
2018-04-06T16:26:34
2018-04-06T16:26:34
125,521,331
0
0
null
null
null
null
UTF-8
C
false
false
558
c
#include <string.h> #include <stdio.h> int main() { int i=4; int j=13; int k; int l; k = 53; l = 64; k = i/j; l = i/j; l = j/j; l = l/j; l = l%j; l = l-j; k = k-k*i; //variables /* START VULNERABILITY */ int a; int b[28]; int c[67]; a = 0; while (a > -1) { //random /* START BUFFER SET */ *((int *)c + a) = *((int *)b + a); /* END BUFFER SET */ a--; } /* END VULNERABILITY */ printf("%d%d\n",k,l); return 0; }
[ "nharmon8@gmail.com" ]
nharmon8@gmail.com
435d938de995c245d164b32e935ec8b55a8bc340
bb762a49e4f5324de253d6287438899a4c645632
/Lista9/Questao1/tadArvoreBB3.c
9f8071a9ac77eb7d89a79a9acd91267be9385138
[]
no_license
RaquelBelmiro/estruturas-de-dados-c
7de2defe4ffaf1849eb5408c533658c0637a1366
f38f6e6758a897a24e8091e773b6651f02e09a45
refs/heads/master
2023-08-01T07:46:45.736000
2021-09-21T21:42:25
2021-09-21T21:42:25
408,981,056
0
0
null
null
null
null
UTF-8
C
false
false
3,945
c
#include<stdio.h> #include<stdlib.h> struct reg_no_arvore { struct reg_no_arvore *ptrEsquerda; int chave; struct reg_no_arvore *ptrDireita; }; typedef struct reg_no_arvore **tipo_no_arvore; tipo_no_arvore inicializar_arvore(tipo_no_arvore sub_raiz) { sub_raiz = (struct reg_no_arvore**)malloc(sizeof(struct reg_no_arvore*)); *sub_raiz = NULL; } void incluir_no_arvore(tipo_no_arvore sub_raiz, int chave) { if (*sub_raiz == NULL) { *sub_raiz = malloc(sizeof(struct reg_no_arvore)); (*sub_raiz)->chave = chave; (*sub_raiz)->ptrEsquerda = NULL; (*sub_raiz)->ptrDireita = NULL; } else { if (chave < (*sub_raiz)->chave) { incluir_no_arvore(&((*sub_raiz)->ptrEsquerda), chave); } else { if (chave > (*sub_raiz)->chave) { incluir_no_arvore(&((*sub_raiz)->ptrDireita), chave); } } } } void percurso_em_ordem(tipo_no_arvore sub_raiz) { if (*sub_raiz != NULL) { percurso_em_ordem(&((*sub_raiz)->ptrEsquerda)); printf("%d ", (*sub_raiz)->chave); percurso_em_ordem(&((*sub_raiz)->ptrDireita)); } } void percurso_em_pre_ordem(tipo_no_arvore sub_raiz) { if (*sub_raiz != NULL) { printf("%d ", (*sub_raiz)->chave); percurso_em_pre_ordem(&((*sub_raiz)->ptrEsquerda)); percurso_em_pre_ordem(&((*sub_raiz)->ptrDireita)); } } void percurso_em_pos_ordem(tipo_no_arvore sub_raiz) { if (*sub_raiz != NULL) { percurso_em_pos_ordem(&((*sub_raiz)->ptrEsquerda)); percurso_em_pos_ordem(&((*sub_raiz)->ptrDireita)); printf("%d ", (*sub_raiz)->chave); } } int encontrar_elemento(tipo_no_arvore sub_raiz, int chave) { if ((*sub_raiz) == NULL) { return 0; } else { if (chave == (*sub_raiz)->chave) { return 1; } else { if (chave < (*sub_raiz)->chave) { return encontrar_elemento(&((*sub_raiz)->ptrEsquerda), chave); } else { if (chave > (*sub_raiz)->chave) { return encontrar_elemento(&((*sub_raiz)->ptrDireita), chave); } } } } } int numero_nos(tipo_no_arvore sub_raiz){ if (*sub_raiz != NULL) { return 1+numero_nos(&((*sub_raiz)->ptrEsquerda))+numero_nos(&((*sub_raiz)->ptrDireita)); } return 0; } int qtdFolha(tipo_no_arvore sub_raiz){ if (*sub_raiz !=NULL) { if(((*sub_raiz)->ptrEsquerda==NULL) && ((*sub_raiz)->ptrDireita==NULL)) return 1+qtdFolha(&(*sub_raiz)->ptrEsquerda) + qtdFolha(&(*sub_raiz)->ptrDireita); else return qtdFolha(&(*sub_raiz)->ptrDireita) + qtdFolha(&(*sub_raiz)->ptrEsquerda); } else return 0; } int qtdNull(tipo_no_arvore sub_raiz){ if (*sub_raiz !=NULL) { return qtdNull(&(*sub_raiz)->ptrEsquerda)+qtdNull(&(*sub_raiz)->ptrDireita); } else return 1; } int altura(tipo_no_arvore sub_raiz){ if (*sub_raiz !=NULL) { if( altura(&((*sub_raiz)->ptrEsquerda)) > altura(&((*sub_raiz)->ptrDireita))) return 1+altura(&(*sub_raiz)->ptrEsquerda); else return 1+altura(&(*sub_raiz)->ptrDireita); } return 0; } void copiarArvore(tipo_no_arvore sub_raiz_original, tipo_no_arvore sub_raiz_copia){ if(*sub_raiz_original!=NULL){ incluir_no_arvore(sub_raiz_copia,(*sub_raiz_original)->chave); copiarArvore(&((*sub_raiz_original)->ptrDireita),sub_raiz_copia); copiarArvore(&((*sub_raiz_original)->ptrEsquerda),sub_raiz_copia); } }
[ "raquelsilvabelmiro@gmail.com" ]
raquelsilvabelmiro@gmail.com
9b15002d5bd412d9ae808f94e24062e867912908
79b2d3126476fe7c997ebc5b8f0a1298b34630fd
/PROG/Sem1/Lab4/logo.h
f18a8f5846e8655b25d16b0468fe9ed466ff3075
[]
no_license
DenisVasenin/Labs
13ba28d4c29cbe8899cd20ac9cc1f1dbdd825659
4b96ea12987d2a0046f58fe8b6d36e775769233b
refs/heads/master
2020-03-18T20:20:16.447000
2018-05-28T15:57:45
2018-05-28T15:57:45
null
0
0
null
null
null
null
UTF-8
C
false
false
646
h
int logo() { puts(""); puts(" ============================"); puts(" "); puts(" XX XX YY YY NN NN "); puts(" XXXX YYYY NNNN NN "); puts(" XX YY NN NN NN "); puts(" XXXX YY NN NNNN "); puts(" XX XX YY NN NN "); puts(" "); puts(" "); puts(" ะŸะตะฝะบะธะฝ ะกั‚ะฐะฝะธัะปะฐะฒ ะณั€ ะ˜ะ’ะข-11 "); puts(" "); puts(" ============================"); puts(""); return(0); }
[ "ps.smartbox@gmail.com" ]
ps.smartbox@gmail.com
a2ee19d7d87b6949e20292b2a52ca26dc7dd75dd
0b98befdd49f707ed1923703bcdac9740bb4d699
/priv/codegolf/Draw the Sawtooth Alphabet.c
de85b8d2d1997998ac9bef46d8908dbbd40b99cb
[]
no_license
jbebe/all-my-projects
a957f2ae70d3ca09d49e1efc52c3cd9f6f786094
32a8b12b17d48c0138005eb54cb1ed9745baa737
refs/heads/master
2021-01-10T08:55:55.291000
2015-05-29T20:16:05
2015-05-29T20:16:05
35,968,468
0
0
null
null
null
null
UTF-8
C
false
false
884
c
/* A simple one today. Write the shortest program that draws a "sawtooth alphabet" given a positive integer for the height. You must write the name of your programming language when you come to the letter it starts with. For example, if your language is Python and the input is 1 the output should be: ABCDEFGHIJKLMNOPythonQRSTUVWXYZ If the input is 2 the output should be: B D F H J L N Python R T V X Z A C E G I K M O Q S U W Y If the input is 4 the output should be: D J Python V C E I K O Q U W B F H L N R T X Z A G M S Y */ /* if n holds the height: */ // C + escape codes: 81 x;main(y){for(y=n--;x<26;x++)printf("\033[%d;%dH%c",n?x/n&1?y++:y--:y,x+1,x+65);} // C 110 x;char a[702]={[0 ...701]=32};main(y){for(y=--n;x<26;a[x*27-1]=10)a[27*(n?x/n&1?y++:y--:y)+x]=x+++65;puts(a);}
[ "juhasz.balint.bebe@gmail.com" ]
juhasz.balint.bebe@gmail.com
a6268cf05d542102a4e024b55ddb4478cd60d8ce
e250176d7fc2d1d1ac604aa843543afe91e8843e
/chapter1/fold.c
0e37e96d78aa3e77a5172cc49be766743550f4ba
[]
no_license
alicewriteswrongs/programminginc
3ea2ebd1a4622856eecb1b49e8011d5fb2cc4ed8
69f17bfede6ccfea70677eb06c6dd76305429ca8
refs/heads/master
2021-08-27T15:31:10.765000
2015-07-14T19:53:23
2015-07-14T19:53:23
null
0
0
null
null
null
null
UTF-8
C
false
false
1,419
c
#include <stdio.h> /* this is program to 'fold' long lines onto two lines, and I think we're going to do 80 * characters/line * */ #define MAXLINE 1000 // not going to bother with lines longer than 1000 #define OUTPUTMAXLINE 1020 // longer incase input is actually 1000 characters #define SPLIT 79 // number of characters per output line (indexed from 0, so 79 == 80 characters per line int mygetline(char line[], int maxline); void foldit(char old[], char new[], int length); main() { int lim = MAXLINE; int len; char before[MAXLINE]; char after[OUTPUTMAXLINE]; while ((len = mygetline(before, lim)) > 0) { foldit(before,after,len); printf("%s", after); } } int mygetline(char before[], int maxline) { int c, i; for (i = 0; i < maxline && (c = getchar()) != EOF && c != '\n'; i++) before[i] = c; if (c == '\n') { before[i] = c; i++; } before[i] = '\0'; return i; } void foldit(char old[], char new[], int length) { int i, offset, count; offset = count = 0; for (i = 0; i <= length; i++) { if (count != SPLIT) { new[i+offset] = old[i]; count += 1; } else if (count == SPLIT) { new[i+offset] = old[i]; offset += 1; new[i+offset] = '\n'; count = 0; } } } // I think it works! hahahaha!
[ "alice.writes.wrongs@gmail.com" ]
alice.writes.wrongs@gmail.com
ad6c47c43213451cd6735ee31d3b8c2cb5b854d4
fd0137df01992ad3153ba9658e71e6c763760b7f
/Emu48/DDESERV.C
6478426a222253dd6a1def7b7c0fb139a99e39fc
[]
no_license
tolkien/Emu48
b22a61dc952d70f9fd93e32a9a8a95c103f96e4b
777d5a9c399f4b2d800e8376bf2e62431bda71a0
refs/heads/master
2021-06-20T01:36:10.050000
2017-05-12T18:11:34
2017-05-12T18:11:34
null
0
0
null
null
null
null
ISO-8859-1
C
false
false
4,855
c
/* * DdeServ.c * * This file is part of Emu48 * * Copyright (C) 1998 Christoph GieรŸelink * */ #include "pch.h" #include "Emu48.h" #include "io.h" HDDEDATA CALLBACK DdeCallback(UINT iType,UINT iFmt,HCONV hConv, HSZ hsz1,HSZ hsz2,HDDEDATA hData, DWORD dwData1,DWORD dwData2) { TCHAR *psz,szBuffer[32]; HDDEDATA hReturn; LPBYTE lpData,lpHeader; DWORD dwAddress,dwSize,dwLoop,dwIndex; UINT nStkLvl; BOOL bSuccess; // disable stack loading items on HP38G, HP39/40G BOOL bStackEnable = cCurrentRomType!='6' && cCurrentRomType!='A' && cCurrentRomType!='E'; switch (iType) { case XTYP_CONNECT: // get service name DdeQueryString(idDdeInst,hsz2,szBuffer,ARRAYSIZEOF(szBuffer),0); if (0 != lstrcmp(szBuffer,szAppName)) return (HDDEDATA) FALSE; // get topic name DdeQueryString(idDdeInst,hsz1,szBuffer,ARRAYSIZEOF(szBuffer),0); return (HDDEDATA) (INT_PTR) (0 == lstrcmp(szBuffer,szTopic)); case XTYP_POKE: // quit on models without stack or illegal data format or not in running state if (!bStackEnable || iFmt != uCF_HpObj || nState != SM_RUN) return (HDDEDATA) DDE_FNOTPROCESSED; // get item name DdeQueryString(idDdeInst,hsz2,szBuffer,ARRAYSIZEOF(szBuffer),0); nStkLvl = _tcstoul(szBuffer,&psz,10); if (*psz != 0 || nStkLvl < 1) // invalid number format return (HDDEDATA) DDE_FNOTPROCESSED; SuspendDebugger(); // suspend debugger bDbgAutoStateCtrl = FALSE; // disable automatic debugger state control if (!(Chipset.IORam[BITOFFSET]&DON)) // HP off { // turn on HP KeyboardEvent(TRUE,0,0x8000); Sleep(dwWakeupDelay); KeyboardEvent(FALSE,0,0x8000); } if (WaitForSleepState()) // wait for cpu SHUTDN then sleep state { hReturn = DDE_FNOTPROCESSED; goto cancel; } while (nState!=nNextState) Sleep(0); _ASSERT(nState==SM_SLEEP); bSuccess = FALSE; // get data and size lpData = DdeAccessData(hData,&dwSize); // has object length header if (lpData && dwSize >= sizeof(DWORD)) { dwIndex = *(LPDWORD) lpData; // object length if (dwIndex <= dwSize - sizeof(DWORD)) { // reserve unpacked object length memory LPBYTE pbyMem = (LPBYTE) malloc(dwIndex * 2); if (pbyMem != NULL) { // copy data and write to stack CopyMemory(pbyMem+dwIndex,lpData+sizeof(DWORD),dwIndex); bSuccess = (WriteStack(nStkLvl,pbyMem,dwIndex) == S_ERR_NO); free(pbyMem); // free memory } } } DdeUnaccessData(hData); SwitchToState(SM_RUN); // run state while (nState!=nNextState) Sleep(0); _ASSERT(nState==SM_RUN); if (bSuccess == FALSE) { hReturn = DDE_FNOTPROCESSED; goto cancel; } KeyboardEvent(TRUE,0,0x8000); Sleep(dwWakeupDelay); KeyboardEvent(FALSE,0,0x8000); // wait for sleep mode while (Chipset.Shutdn == FALSE) Sleep(0); hReturn = (HDDEDATA) DDE_FACK; cancel: bDbgAutoStateCtrl = TRUE; // enable automatic debugger state control ResumeDebugger(); return hReturn; case XTYP_REQUEST: // quit on models without stack or illegal data format or not in running state if (!bStackEnable || iFmt != uCF_HpObj || nState != SM_RUN) return NULL; // get item name DdeQueryString(idDdeInst,hsz2,szBuffer,ARRAYSIZEOF(szBuffer),0); nStkLvl = _tcstoul(szBuffer,&psz,10); if (*psz != 0 || nStkLvl < 1) // invalid number format return NULL; if (WaitForSleepState()) // wait for cpu SHUTDN then sleep state return NULL; while (nState!=nNextState) Sleep(0); _ASSERT(nState==SM_SLEEP); dwAddress = RPL_Pick(nStkLvl); // pick address of stack level "item" object if (dwAddress == 0) { SwitchToState(SM_RUN); // run state return NULL; } dwLoop = dwSize = (RPL_SkipOb(dwAddress) - dwAddress + 1) / 2; lpHeader = (Chipset.type != 'X') ? (LPBYTE) BINARYHEADER48 : (LPBYTE) BINARYHEADER49; // length of binary header dwIndex = (DWORD) strlen((LPCSTR) lpHeader); // size of objectsize + header + object dwSize += dwIndex + sizeof(DWORD); // reserve memory if ((lpData = (LPBYTE) malloc(dwSize)) == NULL) { SwitchToState(SM_RUN); // run state return NULL; } // save data length *(DWORD *)lpData = dwLoop + dwIndex; // copy header memcpy(lpData + sizeof(DWORD),lpHeader,dwIndex); // copy data for (dwIndex += sizeof(DWORD);dwLoop--;++dwIndex,dwAddress += 2) lpData[dwIndex] = Read2(dwAddress); // write data hReturn = DdeCreateDataHandle(idDdeInst,lpData,dwSize,0,hsz2,iFmt,0); free(lpData); SwitchToState(SM_RUN); // run state while (nState!=nNextState) Sleep(0); _ASSERT(nState==SM_RUN); return hReturn; } return NULL; UNREFERENCED_PARAMETER(hConv); UNREFERENCED_PARAMETER(dwData1); UNREFERENCED_PARAMETER(dwData2); }
[ "ryanbee@microsoft.com" ]
ryanbee@microsoft.com
e4ca123d176646b4ad4c5e6601e1ec61881ef2b6
eb127d545b1aa5d4f6dfe7b900613678a061ed8e
/clip/libclipmain/_util/clip_CLIP_HOSTCS.c
68fd4dedfca7aaaf9947cfc9d259df1827c1ab7f
[]
no_license
amery/clip-angelo
a41fccb525b2fb311b2e179508b8ec50457ee7ae
556fb1d40645d4c8fc33cda4014ab31a5b6500ea
refs/heads/master
2020-05-05T04:12:01.911000
2010-12-25T10:42:00
2011-01-01T13:08:14
null
0
0
null
null
null
null
UTF-8
C
false
false
119
c
int clip_CLIP_HOSTCS(ClipMachine * ClipMachineMemory) { _clip_retc(ClipMachineMemory, _clip_hostcs); return 0; }
[ "amery@geeks.cl" ]
amery@geeks.cl
f3aba8ef613f6ee571dcd7583931e508a0734276
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/lm3s8962/Libraries/driverlib/lpc.h
15023178da16496a198e68242b6002c3aa35a2e2
[ "Apache-2.0", "LicenseRef-scancode-proprietary-license", "Zlib", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295000
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
26,535
h
//***************************************************************************** // // lpc.h - Prototypes for the Low Pin Count (LPC) driver. // // Copyright (c) 2010-2011 Texas Instruments Incorporated. All rights reserved. // Software License Agreement // // Texas Instruments (TI) is supplying this software for use solely and // exclusively on TI's microcontroller products. The software is owned by // TI and/or its suppliers, and is protected under applicable copyright // laws. You may not combine this software with "viral" open-source // software in order to form a larger program. // // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL // DAMAGES, FOR ANY REASON WHATSOEVER. // // This is part of revision 8264 of the Stellaris Peripheral Driver Library. // //***************************************************************************** #ifndef __LPC_H__ #define __LPC_H__ //***************************************************************************** // // If building with a C++ compiler, make all of the definitions in this header // have a C binding. // //***************************************************************************** #ifdef __cplusplus extern "C" { #endif //***************************************************************************** // // Values that can be passed to LPCConfigSet as the ulConfig value, and // returned from LPCConfigGet. // //***************************************************************************** #define LPC_CFG_WAKE 0x00000100 // Restart the LPC Bus //***************************************************************************** // // Values that can be returned from LPCStatus. // //***************************************************************************** #define LPC_STATUS_RST 0x00000400 // LPC is in Reset #define LPC_STATUS_BUSY 0x00000200 // LPC is Busy #define LPC_STATUS_SLEEP 0x00000100 // LPC is in Sleep Mode #define LPC_STATUS_CA7 0x00000080 // Channel 7 Active #define LPC_STATUS_CA6 0x00000040 // Channel 6 Active #define LPC_STATUS_CA5 0x00000020 // Channel 5 Active #define LPC_STATUS_CA4 0x00000010 // Channel 4 Active #define LPC_STATUS_CA3 0x00000008 // Channel 3 Active #define LPC_STATUS_CA2 0x00000004 // Channel 2 Active #define LPC_STATUS_CA1 0x00000002 // Channel 1 Active #define LPC_STATUS_CA0 0x00000001 // Channel 0 Active //***************************************************************************** // // Values that can be passed to LPCIRQSet and LPCIRQClear in the ulIRQ // parameter and returned from LPCIRQGet. // //***************************************************************************** #define LPC_IRQ15 0x80000000 // Serial IRQ15 #define LPC_IRQ14 0x40000000 // Serial IRQ14 #define LPC_IRQ13 0x20000000 // Serial IRQ13 #define LPC_IRQ12 0x10000000 // Serial IRQ12 #define LPC_IRQ11 0x08000000 // Serial IRQ11 #define LPC_IRQ10 0x04000000 // Serial IRQ10 #define LPC_IRQ9 0x02000000 // Serial IRQ9 #define LPC_IRQ8 0x01000000 // Serial IRQ8 #define LPC_IRQ7 0x00800000 // Serial IRQ7 #define LPC_IRQ6 0x00400000 // Serial IRQ6 #define LPC_IRQ5 0x00200000 // Serial IRQ5 #define LPC_IRQ4 0x00100000 // Serial IRQ4 #define LPC_IRQ3 0x00080000 // Serial IRQ3 #define LPC_IRQ2 0x00040000 // Serial IRQ2 #define LPC_IRQ1 0x00020000 // Serial IRQ1 #define LPC_IRQ0 0x00010000 // Serial IRQ0 //***************************************************************************** // // Addition values that can be returned from LPCIRQGet. // //***************************************************************************** #define LPC_IRQ_BUSY 0x00000004 // SERIRQ frame in progress #define LPC_IRQ_CONT 0x00000001 // SERIRQ in Continuous Mode //***************************************************************************** // // Values that can be passed as the ulChannel parameter in LPCChannel... // API calls. // //***************************************************************************** #define LPC_CHAN_CH0 0 // LPC Channel 0 #define LPC_CHAN_CH1 1 // LPC Channel 1 #define LPC_CHAN_CH2 2 // LPC Channel 2 #define LPC_CHAN_CH3 3 // LPC Channel 3 #define LPC_CHAN_CH4 4 // LPC Channel 4 #define LPC_CHAN_CH5 5 // LPC Channel 5 #define LPC_CHAN_CH6 6 // LPC Channel 6 #define LPC_CHAN_CH7 7 // LPC Channel 7 (COMx) #define LPC_CHAN_COMx 7 // LPC Channel 7 (COMx) //***************************************************************************** // // Values that can be passed as part of the ulConfig parameter in the // LPCChannelConfig... functions. // //***************************************************************************** #define LPC_CHAN_IRQSEL2_NONE 0x00000000 // LPC Channel IRQSEL2 Disabled #define LPC_CHAN_IRQSEL2_IRQ0 0x00080000 // LPC Channel IRQSEL2 IRQ0 #define LPC_CHAN_IRQSEL2_IRQ1 0x10080000 // LPC Channel IRQSEL2 IRQ1 #define LPC_CHAN_IRQSEL2_IRQ2 0x20080000 // LPC Channel IRQSEL2 IRQ2 #define LPC_CHAN_IRQSEL2_IRQ3 0x30080000 // LPC Channel IRQSEL2 IRQ3 #define LPC_CHAN_IRQSEL2_IRQ4 0x40080000 // LPC Channel IRQSEL2 IRQ4 #define LPC_CHAN_IRQSEL2_IRQ5 0x50080000 // LPC Channel IRQSEL2 IRQ5 #define LPC_CHAN_IRQSEL2_IRQ6 0x60080000 // LPC Channel IRQSEL2 IRQ6 #define LPC_CHAN_IRQSEL2_IRQ7 0x70080000 // LPC Channel IRQSEL2 IRQ7 #define LPC_CHAN_IRQSEL2_IRQ8 0x80080000 // LPC Channel IRQSEL2 IRQ8 #define LPC_CHAN_IRQSEL2_IRQ9 0x90080000 // LPC Channel IRQSEL2 IRQ9 #define LPC_CHAN_IRQSEL2_IRQ10 0xA0080000 // LPC Channel IRQSEL2 IRQ10 #define LPC_CHAN_IRQSEL2_IRQ11 0xB0080000 // LPC Channel IRQSEL2 IRQ11 #define LPC_CHAN_IRQSEL2_IRQ12 0xC0080000 // LPC Channel IRQSEL2 IRQ12 #define LPC_CHAN_IRQSEL2_IRQ13 0xD0080000 // LPC Channel IRQSEL2 IRQ13 #define LPC_CHAN_IRQSEL2_IRQ14 0xE0080000 // LPC Channel IRQSEL2 IRQ14 #define LPC_CHAN_IRQSEL2_IRQ15 0xF0080000 // LPC Channel IRQSEL2 IRQ15 #define LPC_CHAN_COMxIRQ_DISABLE \ 0x00000000 // LCP Channel COMx IRQ Disabled #define LPC_CHAN_COMxIRQ_ENABLE 0x00080000 // LCP Channel COMx IRQ Enabled #define LPC_CHAN_IRQSEL1_NONE 0x00000000 // LPC Channel IRQSEL1 Disabled #define LPC_CHAN_IRQSEL1_IRQ0 0x00040000 // LPC Channel IRQSEL1 IRQ0 #define LPC_CHAN_IRQSEL1_IRQ1 0x01040000 // LPC Channel IRQSEL1 IRQ1 #define LPC_CHAN_IRQSEL1_IRQ2 0x02040000 // LPC Channel IRQSEL1 IRQ2 #define LPC_CHAN_IRQSEL1_IRQ3 0x03040000 // LPC Channel IRQSEL1 IRQ3 #define LPC_CHAN_IRQSEL1_IRQ4 0x04040000 // LPC Channel IRQSEL1 IRQ4 #define LPC_CHAN_IRQSEL1_IRQ5 0x05040000 // LPC Channel IRQSEL1 IRQ5 #define LPC_CHAN_IRQSEL1_IRQ6 0x06040000 // LPC Channel IRQSEL1 IRQ6 #define LPC_CHAN_IRQSEL1_IRQ7 0x07040000 // LPC Channel IRQSEL1 IRQ7 #define LPC_CHAN_IRQSEL1_IRQ8 0x08040000 // LPC Channel IRQSEL1 IRQ8 #define LPC_CHAN_IRQSEL1_IRQ9 0x09040000 // LPC Channel IRQSEL1 IRQ9 #define LPC_CHAN_IRQSEL1_IRQ10 0x0A040000 // LPC Channel IRQSEL1 IRQ10 #define LPC_CHAN_IRQSEL1_IRQ11 0x0B040000 // LPC Channel IRQSEL1 IRQ11 #define LPC_CHAN_IRQSEL1_IRQ12 0x0C040000 // LPC Channel IRQSEL1 IRQ12 #define LPC_CHAN_IRQSEL1_IRQ13 0x0D040000 // LPC Channel IRQSEL1 IRQ13 #define LPC_CHAN_IRQSEL1_IRQ14 0x0E040000 // LPC Channel IRQSEL1 IRQ14 #define LPC_CHAN_IRQSEL1_IRQ15 0x0F040000 // LPC Channel IRQSEL1 IRQ15 #define LPC_CHAN_IRQSEL0_NONE 0x00000000 // LPC Channel IRQSEL0 Disabled #define LPC_CHAN_IRQSEL0_IRQ0 0x00000000 // LPC Channel IRQSEL0 IRQ0 #define LPC_CHAN_IRQSEL0_IRQ1 0x00100000 // LPC Channel IRQSEL0 IRQ1 #define LPC_CHAN_IRQSEL0_IRQ2 0x00200000 // LPC Channel IRQSEL0 IRQ2 #define LPC_CHAN_IRQSEL0_IRQ3 0x00300000 // LPC Channel IRQSEL0 IRQ3 #define LPC_CHAN_IRQSEL0_IRQ4 0x00400000 // LPC Channel IRQSEL0 IRQ4 #define LPC_CHAN_IRQSEL0_IRQ5 0x00500000 // LPC Channel IRQSEL0 IRQ5 #define LPC_CHAN_IRQSEL0_IRQ6 0x00600000 // LPC Channel IRQSEL0 IRQ6 #define LPC_CHAN_IRQSEL0_IRQ7 0x00700000 // LPC Channel IRQSEL0 IRQ7 #define LPC_CHAN_IRQSEL0_IRQ8 0x00800000 // LPC Channel IRQSEL0 IRQ8 #define LPC_CHAN_IRQSEL0_IRQ9 0x00900000 // LPC Channel IRQSEL0 IRQ9 #define LPC_CHAN_IRQSEL0_IRQ10 0x00A00000 // LPC Channel IRQSEL0 IRQ10 #define LPC_CHAN_IRQSEL0_IRQ11 0x00B00000 // LPC Channel IRQSEL0 IRQ11 #define LPC_CHAN_IRQSEL0_IRQ12 0x00C00000 // LPC Channel IRQSEL0 IRQ12 #define LPC_CHAN_IRQSEL0_IRQ13 0x00D00000 // LPC Channel IRQSEL0 IRQ13 #define LPC_CHAN_IRQSEL0_IRQ14 0x00E00000 // LPC Channel IRQSEL0 IRQ14 #define LPC_CHAN_IRQSEL0_IRQ15 0x00F00000 // LPC Channel IRQSEL0 IRQ15 #define LPC_CHAN_IRQEN0_OFF 0x00000000 // LPC Channel IRQEN0 Disabled #define LPC_CHAN_IRQEN0_TRG1 0x00010000 // LPC Channel IRQEN0 Trigger 1 #define LPC_CHAN_IRQEN0_TRG2 0x00020000 // LPC Channel IRQEN0 Trigger 2 #define LPC_CHAN_IRQEN0_TRG3 0x00030000 // LPC Channel IRQEN0 Trigger 3 #define LPC_CHAN_MBARB_ENABLED 0x00000000 // LPC Channel Mailbox Arbritration // enabled. #define LPC_CHAN_MBARB_DISABLED 0x00008000 // LPC Channel Mailbox Arbritration // disabled. #define LPC_CHAN_SIZE_4 0x00000000 // Mailbox IO/Memory Window size // is 4 Bytes. #define LPC_CHAN_SIZE_8 0x00000004 // Mailbox IO/Memory Window size // is 4 Bytes. #define LPC_CHAN_SIZE_16 0x00000008 // Mailbox IO/Memory Window size // is 4 Bytes. #define LPC_CHAN_SIZE_32 0x0000000C // Mailbox IO/Memory Window size // is 4 Bytes. #define LPC_CHAN_SIZE_64 0x00000010 // Mailbox IO/Memory Window size // is 4 Bytes. #define LPC_CHAN_SIZE_128 0x00000014 // Mailbox IO/Memory Window size // is 4 Bytes. #define LPC_CHAN_SIZE_256 0x00000018 // Mailbox IO/Memory Window size // is 4 Bytes. #define LPC_CHAN_SIZE_512 0x0000001C // Mailbox IO/Memory Window size // is 4 Bytes. //***************************************************************************** // // Values that can be passed to LCPChannelConfigCOMxSet as the ulCOMxMode // parameter or returned from LPCChannelConfigGet in the pulCOMxMode // parameter. // //***************************************************************************** #define LPC_COMx_MODE_FRMHNML 0x00000000 // Normal From Host model. #define LPC_COMx_MODE_FRMHIGN 0x00020000 // Ignore From Host data. #define LPC_COMx_MODE_FRMHDMA 0x00040000 // COMx DMA on From Host data to // memory #define LPC_COMx_MODE_UARTDMA 0x00060000 // COMx DMA on From Host data to // UART1 //***************************************************************************** // // Additinal values that can be returned from LPCChannelConfigGet in the // pulCOMxMode parameter. // //***************************************************************************** #define LPC_COMx_ENABLED 0x00010000 // COMx mode enabled. //***************************************************************************** // // Values that can be passed to LPCIntEnable, LPCIntDisable, and LPCIntClear // as the ulIntFlags parameter and returned by LPCIntStatus. // //***************************************************************************** #define LPC_INT_RST 0x80000000 // LPC Bus Enters or Exits // Reset State. #define LPC_INT_SLEEP 0x40000000 // LPC Bus Enters or Exits // Sleep State. #define LPC_INT_COMx 0x20000000 // COMx has read/written // data. #define LPC_INT_SIRQ 0x10000000 // SERIRQ frame has completed #define LPC_INT_CH6_EP_TO_HOST (1 << 24) // To-Host has been read. #define LPC_INT_CH6_EP_FROM_DATA \ (2 << 24) // From-Host has been written as // data. #define LPC_INT_CH6_EP_FROM_CMD (4 << 24) // From-Host has been written as // command. #define LPC_INT_CH6_MB_HOST_WON (1 << 24) // Host Won (HW1ST) #define LPC_INT_CH6_MB_HOST_WRITE \ (2 << 24) // Host Wrote Last Byte. #define LPC_INT_CH6_MB_HOST_READ \ (4 << 24) // Host Read Last Byte #define LPC_INT_CH6_MB_MCU_LOST (8 << 24) // MCU Lost (when host had HW1ST). #define LPC_INT_CH5_EP_TO_HOST (1 << 20) // To-Host has been read. #define LPC_INT_CH5_EP_FROM_DATA \ (2 << 20) // From-Host has been written as // data. #define LPC_INT_CH5_EP_FROM_CMD (4 << 20) // From-Host has been written as // command. #define LPC_INT_CH5_MB_HOST_WON (1 << 20) // Host Won (HW1ST) #define LPC_INT_CH5_MB_HOST_WRITE \ (2 << 20) // Host Wrote Last Byte. #define LPC_INT_CH5_MB_HOST_READ \ (4 << 20) // Host Read Last Byte #define LPC_INT_CH5_MB_MCU_LOST (8 << 20) // MCU Lost (when host had HW1ST). #define LPC_INT_CH4_EP_TO_HOST (1 << 16) // To-Host has been read. #define LPC_INT_CH4_EP_FROM_DATA \ (2 << 16) // From-Host has been written as // data. #define LPC_INT_CH4_EP_FROM_CMD (4 << 16) // From-Host has been written as // command. #define LPC_INT_CH4_MB_HOST_WON (1 << 16) // Host Won (HW1ST) #define LPC_INT_CH4_MB_HOST_WRITE \ (2 << 16) // Host Wrote Last Byte. #define LPC_INT_CH4_MB_HOST_READ \ (4 << 16) // Host Read Last Byte #define LPC_INT_CH4_MB_MCU_LOST (8 << 16) // MCU Lost (when host had HW1ST). #define LPC_INT_CH3_EP_TO_HOST (1 << 12) // To-Host has been read. #define LPC_INT_CH3_EP_FROM_DATA \ (2 << 12) // From-Host has been written as // data. #define LPC_INT_CH3_EP_FROM_CMD (4 << 12) // From-Host has been written as // command. #define LPC_INT_CH3_MB_HOST_WON (1 << 12) // Host Won (HW1ST) #define LPC_INT_CH3_MB_HOST_WRITE \ (2 << 12) // Host Wrote Last Byte. #define LPC_INT_CH3_MB_HOST_READ \ (4 << 12) // Host Read Last Byte #define LPC_INT_CH3_MB_MCU_LOST (8 << 12) // MCU Lost (when host had HW1ST). #define LPC_INT_CH2_EP_TO_HOST (1 << 8) // To-Host has been read. #define LPC_INT_CH2_EP_FROM_DATA \ (2 << 8) // From-Host has been written as // data. #define LPC_INT_CH2_EP_FROM_CMD (4 << 8) // From-Host has been written as // command. #define LPC_INT_CH2_MB_HOST_WON (1 << 8) // Host Won (HW1ST) #define LPC_INT_CH2_MB_HOST_WRITE \ (2 << 8) // Host Wrote Last Byte. #define LPC_INT_CH2_MB_HOST_READ \ (4 << 8) // Host Read Last Byte #define LPC_INT_CH2_MB_MCU_LOST (8 << 8) // MCU Lost (when host had HW1ST). #define LPC_INT_CH1_EP_TO_HOST (1 << 4) // To-Host has been read. #define LPC_INT_CH1_EP_FROM_DATA \ (2 << 4) // From-Host has been written as // data. #define LPC_INT_CH1_EP_FROM_CMD (4 << 4) // From-Host has been written as // command. #define LPC_INT_CH1_MB_HOST_WON (1 << 4) // Host Won (HW1ST) #define LPC_INT_CH1_MB_HOST_WRITE \ (2 << 4) // Host Wrote Last Byte. #define LPC_INT_CH1_MB_HOST_READ \ (4 << 4) // Host Read Last Byte #define LPC_INT_CH1_MB_MCU_LOST (8 << 4) // MCU Lost (when host had HW1ST). #define LPC_INT_CH0_EP_TO_HOST (1 << 0) // To-Host has been read. #define LPC_INT_CH0_EP_FROM_DATA \ (2 << 0) // From-Host has been written as // data. #define LPC_INT_CH0_EP_FROM_CMD (4 << 0) // From-Host has been written as // command. #define LPC_INT_CH0_MB_HOST_WON (1 << 0) // Host Won (HW1ST) #define LPC_INT_CH0_MB_HOST_WRITE \ (2 << 0) // Host Wrote Last Byte. #define LPC_INT_CH0_MB_HOST_READ \ (4 << 0) // Host Read Last Byte #define LPC_INT_CH0_MB_MCU_LOST (8 << 0) // MCU Lost (when host had HW1ST). //***************************************************************************** // // Values that can be passed to LPCCOMxInt... functions as the ulIntFlags // parameter and returned by LPCIntStatus. // //***************************************************************************** #define LPC_COMx_INT_CX 0x02000000 // Raw Event State for COMx #define LPC_COMx_INT_CXTX 0x01000000 // Raw Event State for COMx TX #define LPC_COMx_INT_CXRX 0x00800000 // Raw Event State for COMx RX #define LPC_COMx_MASK_CX 0x00200000 // Event Mask for COMx #define LPC_COMx_MASK_CXTX 0x00100000 // Event Mask for COMx TX #define LPC_COMx_MASK_CXRX 0x00080000 // Event Mask for COMx RX //***************************************************************************** // // Values that can be passed to the LPCChannelDMAConfigSet function as part // of the ulConfig or ulMask parameter, or can be returned from the // LPCChannelConfigGet function. // //***************************************************************************** #define LPC_DMA_CH3_WEN 0x00000080 // Trigger DMA for "To Host" data // buffer is empty. #define LPC_DMA_CH3_REN 0x00000040 // Trigger DMA when "From Host" // data buffer is full. #define LPC_DMA_CH2_WEN 0x00000020 // Trigger DMA for "To Host" data // buffer is empty. #define LPC_DMA_CH2_REN 0x00000010 // Trigger DMA when "From Host" // data buffer is full. #define LPC_DMA_CH1_WEN 0x00000008 // Trigger DMA for "To Host" data // buffer is empty. #define LPC_DMA_CH1_REN 0x00000004 // Trigger DMA when "From Host" // data buffer is full. #define LPC_DMA_CH0_WEN 0x00000002 // Trigger DMA for "To Host" data // buffer is empty. #define LPC_DMA_CH0_REN 0x00000001 // Trigger DMA when "From Host" // data buffer is full. //***************************************************************************** // // Values that can be passed to the LPCChannelStatusSet and // LPCChannelStatusClear function, and returned by the LPCChannelStatusGet // function. // //***************************************************************************** #define LPC_CH_ST_USER0 0x00000100 // User Status Bit 0 #define LPC_CH_ST_USER1 0x00000200 // User Status Bit 1 #define LPC_CH_ST_USER2 0x00000400 // User Status Bit 2 #define LPC_CH_ST_USER3 0x00000800 // User Status Bit 3 #define LPC_CH_ST_USER4 0x00001000 // User Status Bit 4 //***************************************************************************** // // Additinoal values that can be returned by the LPCChannelStatusGet function. // //***************************************************************************** #define LPC_CH_ST_LASTHW 0x00000080 // Last Host Write #define LPC_CH_ST_HW1ST 0x00000040 // First Host Write #define LPC_CH_ST_LASTSW 0x00000020 // Last Slave Write #define LPC_CH_ST_SW1ST 0x00000010 // First Slave Write #define LPC_CH_ST_CMD 0x00000008 // Command or Data #define LPC_CH_ST_FRMH 0x00000002 // From-Host Transaction #define LPC_CH_ST_TOH 0x00000001 // To-Host Transaction //***************************************************************************** // // Prototypes for the APIs. // //***************************************************************************** extern void LPCConfigSet(unsigned long ulBase, unsigned long ulConfig); extern unsigned long LPCConfigGet(unsigned long ulBase); extern unsigned long LPCStatusGet(unsigned long ulBase, unsigned long *pulCount, unsigned long *pulPoolSize); extern void LPCStatusBlockAddressSet(unsigned long ulBase, unsigned long ulAddress, tBoolean bEnabled); extern unsigned LPCStatusBlockAddressGet(unsigned long ulBase); extern void LPCSCIAssert(unsigned long ulBase, unsigned long ulCount); extern void LPCIRQConfig(unsigned long ulBase, tBoolean bIRQPulse, tBoolean bIRQOnChange); extern void LPCIRQSet(unsigned long ulBase, unsigned long ulIRQ); extern void LPCIRQClear(unsigned long ulBase, unsigned long ulIRQ); extern unsigned long LPCIRQGet(unsigned long ulBase); extern void LPCIRQSend(unsigned long ulBase); extern void LPCIntRegister(unsigned long ulBase, void (*pfnHandler)(void)); extern void LPCIntUnregister(unsigned long ulBase); extern void LPCIntEnable(unsigned long ulBase, unsigned long ulIntFlags); extern void LPCIntDisable(unsigned long ulBase, unsigned long ulIntFlags); extern unsigned long LPCIntStatus(unsigned long ulBase, tBoolean bMasked); extern void LPCIntClear(unsigned long ulBase, unsigned long ulIntFlags); extern void LPCChannelEnable(unsigned long ulBase, unsigned long ulChannel); extern void LPCChannelDisable(unsigned long ulBase, unsigned long ulChannel); extern void LPCChannelConfigEPSet(unsigned long ulBase, unsigned long ulChannel, unsigned long ulConfig, unsigned long ulAddress, unsigned long ulOffset); extern void LPCChannelConfigMBSet(unsigned long ulBase, unsigned long ulChannel, unsigned long ulConfig, unsigned long ulAddress, unsigned long ulOffset); extern void LPCChannelConfigCOMxSet(unsigned long ulBase, unsigned long ulChannel, unsigned long ulConfig, unsigned long ulAddress, unsigned long ulOffset, unsigned long ulCOMxMode); extern unsigned long LPCChannelConfigGet(unsigned long ulBase, unsigned long ulChannel, unsigned long *pulAddress, unsigned long *pulOffset, unsigned long *pulCOMxMode); extern unsigned long LPCChannelPoolAddressGet(unsigned long ulBase, unsigned long ulChannel); extern unsigned long LPCChannelStatusGet(unsigned long ulBase, unsigned long ulChannel); extern void LPCChannelStatusSet(unsigned long ulBase, unsigned long ulChannel, unsigned long ulStatus); extern void LPCChannelStatusClear(unsigned long ulBase, unsigned long ulChannel, unsigned long ulStatus); extern void LPCChannelDMAConfigSet(unsigned long ulBase, unsigned long ulConfig, unsigned long ulMask); extern unsigned long LPCChannelDMAConfigGet(unsigned long ulBase); extern unsigned char LPCByteRead(unsigned long ulBase, unsigned long ulOffset); extern void LPCByteWrite(unsigned long ulBase, unsigned long ulOffset, unsigned char ucData); extern unsigned short LPCHalfWordRead(unsigned long ulBase, unsigned long ulOffset); extern void LPCHalfWordWrite(unsigned long ulBase, unsigned long ulOffset, unsigned short usData); extern unsigned long LPCWordRead(unsigned long ulBase, unsigned long ulOffset); extern void LPCWordWrite(unsigned long ulBase, unsigned long ulOffset, unsigned long ulData); extern void LPCCOMxIntEnable(unsigned long ulBase, unsigned long ulIntFlags); extern void LPCCOMxIntDisable(unsigned long ulBase, unsigned long ulIntFlags); extern unsigned long LPCCOMxIntStatus(unsigned long ulBase, tBoolean bMasked); extern void LPCCOMxIntClear(unsigned long ulBase, unsigned long ulIntFlags); //***************************************************************************** // // Mark the end of the C bindings section for C++ compilers. // //***************************************************************************** #ifdef __cplusplus } #endif #endif // __LPC_H__
[ "mbbill@gmail.com" ]
mbbill@gmail.com
ba1e8d10b4304a881878387964db1a02e670c5d3
166fba38e48ca1968348f5a6fd8c435392d619db
/jzz.c
d1576d8fbf128a1060ae1ca5dd4b9ce9d27aea4e
[]
no_license
Yuvpriya/jazz
0925c109f2f2652ed886f4cce0c0c362ff96ba5b
0e81454801892f6fc762f74cb15b363d8640c301
refs/heads/master
2021-01-01T16:53:35.835000
2017-07-21T12:33:36
2017-07-21T12:33:36
97,944,469
0
0
null
null
null
null
UTF-8
C
false
false
295
c
#include<stdio.h> #include<string.h> int main() { char p[20],q[20],r[20],i; scanf("%s",p); scanf("%s",r); scanf("%s",q); for(i=0;i<19;i++) { if((p[i]==q[i])&&(q[i]==r[i])) { printf("%c",p[i]); } else break; } return 0; }
[ "noreply@github.com" ]
noreply@github.com
872d8f0e8f79d8d3cc847d279d797bd59b047c8a
bfb77baec8635ec547dcab598fa537785a03d3fb
/MDK-ARM/Lora.c
f4632170ad1e6ae45ecaa5aa22ab3d9fc338799b
[]
no_license
huynd98/SENSOR1_DATN
6fd4dc6eaae9665b738c86c31dd83b432823d140
6faedbe233ec30f4f1c79f0368cafcbe2a9ff678
refs/heads/main
2023-02-13T04:16:59.856000
2021-01-11T15:20:07
2021-01-11T15:20:07
318,145,813
0
0
null
null
null
null
UTF-8
C
false
false
8,661
c
#include "Lora.h" uint8_t readRegLora_8Bit(uint8_t address){ uint8_t result=0; HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_RESET); HAL_Delay(1); while ( HAL_SPI_Transmit(&hspi2,&address,1,100) != HAL_OK ); while ( HAL_SPI_Receive(&hspi2,&result,1,100) != HAL_OK ); HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_SET); return result; } /*****************************************************************/ void readRegLora(uint8_t address, uint8_t *receiveData, uint8_t length){ HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_RESET); HAL_Delay(1); while ( HAL_SPI_Transmit(&hspi2,&address,1,100) != HAL_OK ); while ( HAL_SPI_Receive(&hspi2,receiveData,length,100) != HAL_OK ); HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_SET); } /*****************************************************************/ void writeRegLora(uint8_t address, uint8_t data){ uint8_t add; add = address | 0x80; HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_RESET); HAL_Delay(1); while ( HAL_SPI_Transmit(&hspi2,&add,1,100) != HAL_OK ); while ( HAL_SPI_Transmit(&hspi2,&data,1,100) != HAL_OK ); HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_SET); } /*****************************************************************/ void writeToFIFO(uint8_t *data, uint8_t length){ uint8_t add= REG_FIFO | 0x80; HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_RESET); HAL_Delay(1); while ( HAL_SPI_Transmit(&hspi2,&add,1,100) != HAL_OK ); while ( HAL_SPI_Transmit(&hspi2,data,length,100) != HAL_OK ); HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_SET); } /*****************************************************************/ void LoraSetFreq(uint32_t frequency){ uint64_t frf = ((uint64_t)frequency << 19) / 32000000; writeRegLora(REG_FRF_MSB, (uint8_t)(frf >> 16)); writeRegLora(REG_FRF_MID, (uint8_t)(frf >> 8)); writeRegLora(REG_FRF_LSB, (uint8_t)(frf >> 0)); } /*****************************************************************/ void LoraSleep(void){ writeRegLora(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_SLEEP); } /*****************************************************************/ void LoraIdle(void){ writeRegLora(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_STDBY); } //********************************************************** uint16_t LoraBegin(void){ //Blink Reset Pin HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8,GPIO_PIN_SET); HAL_Delay(10); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8,GPIO_PIN_RESET); HAL_Delay(10); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8,GPIO_PIN_SET); HAL_Delay(10); //Blink Slave Selection HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_RESET); HAL_Delay(10); HAL_GPIO_WritePin(GPIOA, LORA_NSS_Pin, GPIO_PIN_SET); HAL_Delay(10); //Check Version uint8_t version = readRegLora_8Bit(REG_VERSION); if (version != 0x12) return 0; //put in sleep mode LoraSleep(); //Set Frequency LoraSetFreq(FREQUENCY); //Set base address FIFO writeRegLora(REG_FIFO_TX_BASE_ADDR, 0); writeRegLora(REG_FIFO_RX_BASE_ADDR, 0); //set explicitheader mode //writeRegLora(REG_MODEM_CONFIG_1, readRegLora_8Bit(REG_MODEM_CONFIG_1) & 0xfe); LoraExplicitHeaderMode(); // set LNA boost writeRegLora(REG_LNA, readRegLora_8Bit(REG_LNA) | 0x03); // set auto AGC writeRegLora(REG_MODEM_CONFIG_3, 0x04); //ocpTrim writeRegLora(REG_OCP, 0x20 | (0x1F & 0x0B)); //TX power writeRegLora(REG_PA_CONFIG, PA_BOOST | (17 - 2)); //put in standby Mode LoraIdle(); return 1; } //***************************************************** void LoraEnd(void){ LoraSleep(); } //**************************************************** void LoraSetLdoFlag(void){ // Section 4.1.1.5 long symbolDuration = 1000 / ( LoraGetSignalBW() / (1L << LoraGetSpreadingFactor()) ) ; uint8_t config3 = readRegLora_8Bit(REG_MODEM_CONFIG_3); // Section 4.1.1.6 if(symbolDuration > 16) config3 = config3 | 0x08; else config3 = config3 & 0xF7; // bitWrite(config3, 3, ldoOn); writeRegLora(REG_MODEM_CONFIG_3, config3); } //**************************************************** //set Spreading Factor void LoraSetSpreadingFactor(uint8_t sf){ if (sf < 6) { sf = 6; } else if (sf > 12) { sf = 12; } if (sf == 6) { writeRegLora(REG_DETECTION_OPTIMIZE, 0xc5); writeRegLora(REG_DETECTION_THRESHOLD, 0x0c); } else { writeRegLora(REG_DETECTION_OPTIMIZE, 0xc3); writeRegLora(REG_DETECTION_THRESHOLD, 0x0a); } writeRegLora(REG_MODEM_CONFIG_2, (readRegLora_8Bit(REG_MODEM_CONFIG_2) & 0x0f) | ((sf << 4) & 0xf0)); LoraSetLdoFlag(); } //****************************************************** uint16_t LoraGetSpreadingFactor(void){ return readRegLora_8Bit(REG_MODEM_CONFIG_2) >> 4; } //*************************************************** //get Signal Band Width uint32_t LoraGetSignalBW(void){ uint8_t bw = (readRegLora_8Bit(REG_MODEM_CONFIG_1) >> 4); switch (bw) { case 0: return 7800; case 1: return 10400; case 2: return 15600; case 3: return 20800; case 4: return 31250; case 5: return 41700; case 6: return 62500; case 7: return 125000; case 8: return 250000; case 9: return 500000; } return 0; } //***************************************************** //set Signal BandWidth void LoraSetSignalBW(uint32_t bandwidth){ int bw; if (bandwidth <= 7.8E3) { bw = 0; } else if (bandwidth <= 10400) { bw = 1; } else if (bandwidth <= 15600) { bw = 2; } else if (bandwidth <= 20800) { bw = 3; } else if (bandwidth <= 31250) { bw = 4; } else if (bandwidth <= 41700) { bw = 5; } else if (bandwidth <= 62500) { bw = 6; } else if (bandwidth <= 125000) { bw = 7; } else if (bandwidth <= 250000) { bw = 8; } else /*if (bandwidth <= 250E3)*/ { bw = 9; } writeRegLora(REG_MODEM_CONFIG_1, (readRegLora_8Bit(REG_MODEM_CONFIG_1) & 0x0f) | (bw << 4)); LoraSetLdoFlag(); } //******************************************************** //set Coding Rate void LoraSetCodingRate(int denominator){ if (denominator < 5) { denominator = 5; } else if (denominator > 8) { denominator = 8; } int cr = denominator - 4; writeRegLora(REG_MODEM_CONFIG_1, (readRegLora_8Bit(REG_MODEM_CONFIG_1) & 0xf1) | (cr << 1)); } //*********************************************************** //Lora is Transmitting uint8_t LoraIsTransmitting(void){ if ((readRegLora_8Bit(REG_OP_MODE) & MODE_TX) == MODE_TX) { return 1; } if (readRegLora_8Bit(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) { // clear IRQ's writeRegLora(REG_IRQ_FLAGS, IRQ_TX_DONE_MASK); } return 0; } //*********************************************************** //Set imlicit Header Mode void LoraImplicitHeaderMode(void){ writeRegLora(REG_MODEM_CONFIG_1, readRegLora_8Bit(REG_MODEM_CONFIG_1) | 0x01); } //*********************************************************** //Set explicit Header Mode void LoraExplicitHeaderMode(void){ writeRegLora(REG_MODEM_CONFIG_1, readRegLora_8Bit(REG_MODEM_CONFIG_1) & 0xFE); } /********************************************************/ // set Lora into Rx mode : Continous or Single void LoraRxMode(uint8_t RxMode){ writeRegLora(REG_OP_MODE, MODE_LONG_RANGE_MODE | RxMode); } /********************************************************/ // set Lora into Rx mode : Continous or Single void LoraTxMode(){ writeRegLora(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_TX); } /**************************************************************/ void LoraRead(uint8_t *arrayReadData){ uint8_t packetLength = 0; uint8_t i; uint8_t irqFlag = readRegLora_8Bit(REG_IRQ_FLAGS); writeRegLora(REG_IRQ_FLAGS, irqFlag); if((irqFlag & 0x40) != 0){ packetLength = readRegLora_8Bit(REG_RX_NB_BYTES); writeRegLora(REG_FIFO_ADDR_PTR, readRegLora_8Bit(REG_FIFO_RX_CURRENT_ADDR)); for(i = 0; i <packetLength; i++){ arrayReadData[i]=readRegLora_8Bit(REG_FIFO); } //powerReadInt = ( arrayReadData[0]-48)*10 + (arrayReadData[1] -48); //neu doc dc HAL_GPIO_WritePin(GPIOB,GPIO_PIN_8,GPIO_PIN_RESET); HAL_Delay(200); HAL_GPIO_WritePin(GPIOB,GPIO_PIN_8,GPIO_PIN_SET); HAL_Delay(200); } } /**************************************************************/ //Transfer Data have first address = buffer, and length = uint8_t Size //return Size transfered uint8_t LoraTransfer(uint8_t *buffer, uint8_t size){ // reset FIFO address and paload length writeRegLora(REG_FIFO_ADDR_PTR, 0); writeRegLora(REG_PAYLOAD_LENGTH, 0); writeToFIFO(buffer,size); writeRegLora(REG_PAYLOAD_LENGTH, size); // put in TX mode LoraTxMode(); // wait for TX done while ((readRegLora_8Bit(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) == 0) {} // clear IRQ's writeRegLora(REG_IRQ_FLAGS, IRQ_TX_DONE_MASK); return 1; } //convert read data to int
[ "nguyendanghuy247@gmail.com" ]
nguyendanghuy247@gmail.com
74155732b9c958f7e75602f9329f9c20146aa7a9
54acb0bc5cfe18341533cf9b451757374e98f9d0
/ProiectRetele/functions.h
95e415efb92f5c944b170864006c8e9debcc06be
[]
no_license
balandan/Proiect-Retele
2a13b6bb3ca917188fa2f41bab159ea47be9ccf2
430503bfc24a963c5577a50a18a3254c3142f217
refs/heads/master
2020-03-12T15:45:09.726000
2018-04-23T13:17:14
2018-04-23T13:17:14
130,698,324
0
0
null
null
null
null
UTF-8
C
false
false
8,566
h
#include <stdio.h> #include "listOfItems.h" int typeOfUser; int searchInServer(int descriptor,char fileName[30]) { DIR *dir; struct dirent *file; dir = opendir ("."); if(dir==NULL) { printf("Fail to open this directory"); exit(1); } while( (file=readdir(dir))!=NULL ) { if( strcmp(file->d_name,fileName)==0) { closedir(dir); return 1; } } closedir(dir); return 0; } int download(char nameOfFile[30],int descriptor) { int ptr_myfile; int counter=0; char buffer[1024]; char mesaj[100]; bzero(mesaj,100); char messageFromClient[50]; ptr_myfile=open(nameOfFile,O_RDONLY); if (ptr_myfile < 0) { strcat(mesaj,"Unable to open file!"); //printf("%s",mesaj); //write(descriptor,"Unable to open file!",30); } else strcat(mesaj,"The file was found!"); //printf("%d\n",bytes); //printf("%d",counter); printf("[server]%s\n",mesaj); write(descriptor,mesaj,35); bzero(messageFromClient,50); read(descriptor,messageFromClient,50); if(strcmp(messageFromClient,"done")==0 && strcmp(mesaj,"The file was found!")==0) { int bytes; while ((bytes=read(ptr_myfile,buffer,1024))>0) { counter+=bytes; //printf("%d\n",bytes); } int n = counter; write(descriptor, &n, sizeof(n)); close(ptr_myfile); write(descriptor,nameOfFile,100); ptr_myfile=open(nameOfFile,O_RDONLY); while (n>0) { bytes=read(ptr_myfile,buffer,1024); n=n-bytes; printf("[server]We sent %d%s%d%s\n",bytes," there are still ", n ," bytes to send"); sleep(0.1); write(descriptor,buffer,bytes); //printf("[server]We sent %d%s"," bytes"); } } bzero(messageFromClient,50); close(ptr_myfile); } void primireComenzi(int descriptor) { char message[100]; char *firstWord; char *secondWord; char path[100]; read(descriptor,message,100); printf("[server]The message recived:%s",message); //primim comanda //printf("%s",firstWord); if(strcmp(message,"ls\n")==0 && (typeOfUser==0 || typeOfUser==1)) //comanda pentru ls { write(descriptor,"start",6); listOfItems(descriptor); primireComenzi(descriptor); } else if (strcmp(message,"exit\n")==0 && (typeOfUser==0 || typeOfUser==1)) { char answer[5]; write(descriptor,"Are you sure?",15); printf ("[server]Message sent:%s\n","Are you sure?\n"); read(descriptor,answer,5); if(strcmp(answer,"yes")==0) { printf("[server]A client has disconnected\n"); close(descriptor); exit(0); } else primireComenzi(descriptor); } firstWord=strtok(message," "); secondWord=strtok(NULL,"\n"); if(strcmp(firstWord,"download")==0 && (typeOfUser==0 || typeOfUser==1)) { printf("[server]The file that the client ask for:%s\n",secondWord); //read(descriptor,path,100); //printf("%s",path); download(secondWord,descriptor); primireComenzi(descriptor); } else if (strcmp(firstWord,"delete")==0 && typeOfUser==1) { //printf("[server]Message recived:delete %s",secondWord); if(remove(secondWord)==0) write(descriptor,"The file was deleted!",30); else write(descriptor,"The file can't be deleted or do not exist",50); primireComenzi(descriptor); } else if (strcmp(firstWord,"delete")==0 && typeOfUser==0) { primireComenzi(descriptor); } else if (strcmp(firstWord,"copy")==0 && typeOfUser==1) { int x=searchInServer(descriptor,secondWord); if (x==1) { char nameForTheNewFile[30]; char buffer[1024]; char file[30];//numele final al fisierului pe care il deschidem char theFileWeOpen[30]; char *extension;//folosim pentru a afla extensia noului fisier char *nume;//folosim pentru a afla denumirea noului fisier int openFile; write(descriptor,"File found!",15); printf("%s\n","[server]File found!"); read(descriptor,nameForTheNewFile,30); bzero(theFileWeOpen,30); strcat(theFileWeOpen,secondWord); extension=strtok(secondWord,"."); extension=strtok(NULL,"\n"); nume=strtok(nameForTheNewFile,"\n"); bzero(file,30); strcat(file,nume); strcat(file,"."); strcat(file,extension); openFile=open(theFileWeOpen,O_RDONLY); if (openFile < 0) { printf("%s\n","[server]Unable to open file!"); } int x; x=open(file,O_WRONLY|O_CREAT); int bytes=0; while ((bytes=read(openFile,buffer,1024))>0) { write(x,buffer,bytes); } close(x); close(openFile); printf("[server]The file was copied!\n"); write(descriptor,"Done",5); primireComenzi(descriptor); } else { write(descriptor,"File not found!",15); printf("%s\n","[server]File not found!"); primireComenzi(descriptor); } } else if (strcmp(firstWord,"copy")==0 && typeOfUser==0) { primireComenzi(descriptor); } else primireComenzi(descriptor); //primireComenzi(descriptor); } int searchInFile(char user[20],char pass[20]) { int nr_linie=0; int nr_linie2=0; char buffer[20]; FILE *a; a=fopen("user.txt","r"); if (a!=NULL) { while(!feof(a)) { fgets(buffer,20,a); nr_linie+=1; if (strcmp(buffer,user)==0) { break; } bzero(buffer,20); } fclose(a); if(nr_linie %2==1) { a=fopen("user.txt","r"); while(!feof(a)) { fgets(buffer,20,a); nr_linie2+=1; if(nr_linie2==nr_linie+1 && strcmp(buffer,pass)==0) return 1; bzero(buffer,20); } } } return 0; } int typeUser (char username[30]) { char buffer[30]; FILE *b; b=fopen("whitelist.txt","r"); if(b!=NULL) { while(!feof(b)) { fgets(buffer,30,b); if(strcmp(buffer,username)==0) return 1; } } fclose(b); b=fopen("blacklist.txt","r"); if(b!=NULL) { while(!feof(b)) { fgets(buffer,30,b); if(strcmp(buffer,username)==0) return 0; } } fclose(b); } void login (int descriptor) { char *username; char *password; char buffer[100]; char msg[100]; //mesajul primit de la client int i=0; int y; char c; char newPassword[50]; int bytes; bytes = read (descriptor, msg, sizeof (buffer)); //Citim datele de autentificare if (bytes < 0) { perror ("Eroare la read() de la client.\n"); close(descriptor); exit(0); } printf ("[server]Message recived:%s\n", msg); username = strtok(msg,"\n"); //Le prelucram password = strtok(NULL,"\n"); while(password[i]!='\0') { y=(int)password[i]; y--; c=y; newPassword[i]=c; i++; } newPassword[i]='\0'; //Am decriptat parola char spatiu[3]="\n"; char nume[20]; bzero(nume,20); strcat(nume,username); strcat(nume,spatiu); int x=searchInFile(nume,newPassword); //cautam in fisierul de logare daca datele primite sunt valide if(x){ bzero(msg,100); strcat(msg,"Connected"); printf ("[server]Message sent:%s\n",msg); typeOfUser=typeUser(nume); //daca sunt valide determinam din ce fisier face parte userul conectat //printf("%d",typeOfUser); } else { bzero(msg,100); strcat(msg,"Try again"); printf ("[server]Message sent:%s\n",msg); } if (bytes && write (descriptor, msg, bytes) < 0) //trimitem mesaj de raspuns { perror ("[server] Eroare la write() catre client.\n"); //return 0; } if (strcmp(msg,"Connected")==0) //daca mesajul trimis este connected apelam functia unde putem primi comenzi { write(descriptor, &typeOfUser, sizeof(typeOfUser));//scriem clientului tipul de user ce tocmai s-a logat //printf("%d",typeOfUser); primireComenzi(descriptor); } else if(strcmp(msg,"Try again")==0) //daca datele sunt gresite se ofera posibilitatea de a incerca de nou { login(descriptor); } close(descriptor); exit(0); }
[ "noreply@github.com" ]
noreply@github.com
0a8e0289152e8c5ddde56fb7659d8c479c4582cf
e4a1f59a825748852406246ad4a0a7e58c0c756b
/code/functs.h
be49b077ece743129c59d76e88d82e6b23007194
[]
no_license
MVour/diseaseAggregator
19d46631f1982a407cc243431392c9f1bdc13094
acb9b05c4d6fe73ccbc063f0d4e9132352c9e97d
refs/heads/master
2023-02-11T03:08:55.542000
2021-01-15T20:48:48
2021-01-15T20:48:48
330,018,961
0
0
null
null
null
null
UTF-8
C
false
false
975
h
// #include "myList.h" #include "myHash.h" #include "heap.h" #include "filesStats.h" ////// FUNCTS void printMenu(); char* act(int, hashTable*, hashTable*, infoNode*, StatsList*, char* buf); // void act_1(hashTable*, char*, char*); char* act_2(hashTable*, char*, char*, char*, char*); char* act_3(StatsList* myStats, int, char*, char*, char*, char*); char* act_4(infoNode*, char*); char* act_5(StatsList*, char*, char*, char*, char*); char* act_6(hashTable* , char*, char*, char*, char*); // void act_3_4(hashTable*, char*, char*, char*, int, int); // void act_5(hashTable*, hashTable*, infoNode*, myPatient*); // void act_6(infoNode*, char*, char*); // void act_7(hashTable*, char*); // void act_8(hashTable* cHash, hashTable* dHash, infoNode* pList); int isDate(char*); void treeToHeap(RBT*, maxHeap*, RBnode*, char*, char*, char*); int statsToHeap(StatsList*, maxHeap*, char* country, char* disease, char*, char*); // int count_keys(RBnode* n, char* date1, char* date2);
[ "m.vourtzoumis@gmail.com" ]
m.vourtzoumis@gmail.com
25021c56cbd311feb2474cce81be4758cf5ee5d8
394c1965d2300d06df1a72868670397d4ac262c5
/Libft/srcs/ft_putchar_fd.c
df6248e83b11873e2ab6dcb3898dc37e6be95fa4
[]
no_license
lterrail/minishell
f0584386ca9f9184ab21f32ad900610ddb75f090
a2221f74445c526eec356b672efee4640fd7aefb
refs/heads/master
2021-07-25T16:39:30.554000
2020-04-30T15:55:05
2020-04-30T15:55:05
158,931,545
0
0
null
null
null
null
UTF-8
C
false
false
970
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_putchar_fd.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lterrail <lterrail@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/04/03 16:24:20 by lterrail #+# #+# */ /* Updated: 2018/04/11 17:00:53 by lterrail ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" void ft_putchar_fd(char c, int fd) { write(fd, &c, 1); }
[ "lterrail@e1r10p17.42.fr" ]
lterrail@e1r10p17.42.fr
26f23f68c2d65c91dbf7731ee589f62a41d27d8a
7da6ed1e31f4dd92d923cc867f21b33a74e0ebc1
/src/createregion.c
4743ff3cf0a3b2c59883d6f6f024f8bc1946adb9
[]
no_license
freudshow/practice
2f672a460ea9d61135b6ac26919fdd3d9fab5224
6801ea586c5db2f30a268040f3390e303cf0fb89
refs/heads/master
2021-07-05T00:47:14.143000
2021-06-09T06:03:17
2021-06-09T06:03:17
90,633,429
0
2
null
null
null
null
UTF-8
C
false
false
159
c
#include "shm.h" int rand(void); int rand_r(unsigned int *seedp); void srand(unsigned int seed); int main() { init_sem_set(); init_region(); exit(0); }
[ "s_baoshan@163.com" ]
s_baoshan@163.com
c8bd691314e2dda543aebd10b67df1d55639c9da
598883867c454c3706ef844d5c0505c00142ba61
/LCD/LCD.h
8a928231dcc96aff1080d4fd704910a849aef356
[]
no_license
ahmedelgazwy/Password-Based-Lock
996b245047e1602b175aad5a7b1c04eb3d0e2ff7
337ebc6e545d25e134d972cb5ef637ad986fa650
refs/heads/master
2021-03-02T20:24:19.206000
2020-03-08T19:40:14
2020-03-08T19:40:14
245,902,521
0
0
null
2020-03-08T23:06:35
2020-03-08T23:06:35
null
UTF-8
C
false
false
568
h
#ifndef __LCD__H__ #define __LCD__H__ #include "std_types.h" #include "IO_ports.h" #define LCD_DATA GPIO_PORTC_DATA_R #define LCD_DATA_DIR GPIO_PORTC_DIR_R #define LCD_DATA_DEN GPIO_PORTC_DEN_R #define LCD_DATA_AFSEL GPIO_PORTC_AFSEL_R #define LCD_DATA_AMSEL GPIO_PORTC_AMSEL_R #define LCD_DATA_PCTL GPIO_PORTC_PCTL_R #define LCD_CTRL GPIO_PORTD_DATA_R #define LCD_CTRL_DIR GPIO_PORTD_DIR_R #define LCD_CTRL_DEN GPIO_PORTD_DEN_R #define LCD_CTRL_AFSEL GPIO_PORTD_AFSEL_R #define LCD_CTRL_AMSEL GPIO_PORTD_AMSEL_R #define LCD_CTRL_PCTL GPIO_PORTD_PCTL_R #endif
[ "noreply@github.com" ]
noreply@github.com
04fea91c01ee1587f19ad32ee856fa3859d09f22
ade70089afe2f9bd496985fe67d46c5372042ab0
/nvm/versions/node/v16.14.0/include/node/openssl/opensslv.h
afe0161c9ca2dc78a4eac5c0a5319f30e43aba74
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "CC0-1.0", "LicenseRef-scancode-openssl", "LicenseRef-scancode-unicode", "Artistic-2.0", "BSD-3-Clause", "Zlib", "NAIST-2003", "ISC", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "NTP", "LicenseRef-scancode-public-domain-disclaimer", "ICU" ]
permissive
gn0rt0n/dotfiles
96e37a87cec555cbfd222795466c140eb502c892
35f01242e7ac73a8b21b5e62398f1185102b7ee9
refs/heads/master
2023-02-23T03:02:35.212000
2023-02-19T02:53:00
2023-02-19T02:53:00
299,629,236
0
1
null
2022-10-16T02:07:11
2020-09-29T13:40:38
C
UTF-8
C
false
false
4,110
h
/* * Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ #ifndef HEADER_OPENSSLV_H # define HEADER_OPENSSLV_H #ifdef __cplusplus extern "C" { #endif /*- * Numeric release version identifier: * MNNFFPPS: major minor fix patch status * The status nibble has one of the values 0 for development, 1 to e for betas * 1 to 14, and f for release. The patch level is exactly that. * For example: * 0.9.3-dev 0x00903000 * 0.9.3-beta1 0x00903001 * 0.9.3-beta2-dev 0x00903002 * 0.9.3-beta2 0x00903002 (same as ...beta2-dev) * 0.9.3 0x0090300f * 0.9.3a 0x0090301f * 0.9.4 0x0090400f * 1.2.3z 0x102031af * * For continuity reasons (because 0.9.5 is already out, and is coded * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level * part is slightly different, by setting the highest bit. This means * that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start * with 0x0090600S... * * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for * major minor fix final patch/beta) */ # define OPENSSL_VERSION_NUMBER 0x101010dfL # define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1m+quic 14 Dec 2021" /*- * The macros below are to be used for shared library (.so, .dll, ...) * versioning. That kind of versioning works a bit differently between * operating systems. The most usual scheme is to set a major and a minor * number, and have the runtime loader check that the major number is equal * to what it was at application link time, while the minor number has to * be greater or equal to what it was at application link time. With this * scheme, the version number is usually part of the file name, like this: * * libcrypto.so.0.9 * * Some unixen also make a softlink with the major version number only: * * libcrypto.so.0 * * On Tru64 and IRIX 6.x it works a little bit differently. There, the * shared library version is stored in the file, and is actually a series * of versions, separated by colons. The rightmost version present in the * library when linking an application is stored in the application to be * matched at run time. When the application is run, a check is done to * see if the library version stored in the application matches any of the * versions in the version string of the library itself. * This version string can be constructed in any way, depending on what * kind of matching is desired. However, to implement the same scheme as * the one used in the other unixen, all compatible versions, from lowest * to highest, should be part of the string. Consecutive builds would * give the following versions strings: * * 3.0 * 3.0:3.1 * 3.0:3.1:3.2 * 4.0 * 4.0:4.1 * * Notice how version 4 is completely incompatible with version, and * therefore give the breach you can see. * * There may be other schemes as well that I haven't yet discovered. * * So, here's the way it works here: first of all, the library version * number doesn't need at all to match the overall OpenSSL version. * However, it's nice and more understandable if it actually does. * The current library version is stored in the macro SHLIB_VERSION_NUMBER, * which is just a piece of text in the format "M.m.e" (Major, minor, edit). * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways, * we need to keep a history of version numbers, which is done in the * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and * should only keep the versions that are binary compatible with the current. */ # define SHLIB_VERSION_HISTORY "" # define SHLIB_VERSION_NUMBER "81.1.1" #ifdef __cplusplus } #endif #endif /* HEADER_OPENSSLV_H */
[ "gary@odindev.com" ]
gary@odindev.com
ae6588ae9020907de235f7dc4c83350dbf925003
60cddbbb30ef7614070f6e1691ab9a3f0ce407e4
/robo2-xsdk/libs/phymod/chip/falcon16/falcon16_diagnostics_dispatch.c
12ba0238027635ff729ee0e14f43ab82c3db76e5
[]
no_license
David-Croose/Broadcom-Compute-Connectivity-Software-robo2-xsdk
f2a1fe9a704e1a1873eac2fba02125ba7cb1570f
25b15c851d6e8a5a70715603e4f8d8a9af8f66fe
refs/heads/master
2022-11-27T00:00:23.553000
2020-08-03T07:36:34
2020-08-03T07:36:34
null
0
0
null
null
null
null
UTF-8
C
false
false
1,555
c
/* * * $Id: phymod.xml,v 1.1.2.5 Broadcom SDK $ * * * This license is set out in https://github.com/Broadcom/Broadcom-Compute-Connectivity-Software-robo2-xsdk/master/Legal/LICENSE file. * * $Copyright: (c) 2020 Broadcom Inc. * Broadcom Proprietary and Confidential. All rights reserved.$ * * * DO NOT EDIT THIS FILE! * */ #include <phymod/phymod.h> #include <phymod/phymod_diagnostics.h> #include <phymod/phymod_diagnostics_dispatch.h> #ifdef PHYMOD_FALCON16_SUPPORT #include <phymod/chip/falcon16_diagnostics.h> __phymod_diagnostics__dispatch__t__ phymod_diagnostics_falcon16_diagnostics_driver = { falcon16_phy_rx_slicer_position_set, falcon16_phy_rx_slicer_position_get, falcon16_phy_rx_slicer_position_max_get, falcon16_phy_prbs_config_set, falcon16_phy_prbs_config_get, falcon16_phy_prbs_enable_set, falcon16_phy_prbs_enable_get, falcon16_phy_prbs_status_get, falcon16_phy_pattern_config_set, falcon16_phy_pattern_config_get, falcon16_phy_pattern_enable_set, falcon16_phy_pattern_enable_get, falcon16_core_diagnostics_get, falcon16_phy_diagnostics_get, falcon16_phy_pmd_info_dump, NULL, /* phymod_phy_pcs_info_dump */ falcon16_phy_eyescan_run, NULL, /* phymod_phy_link_mon_enable_set */ NULL, /* phymod_phy_link_mon_enable_get */ NULL, /* phymod_phy_link_mon_status_get */ NULL, /* phymod_phy_fec_correctable_counter_get */ NULL, /* phymod_phy_fec_uncorrectable_counter_get */ }; #endif /* PHYMOD_FALCON16_SUPPORT */
[ "murali.policharla@broadcom.com" ]
murali.policharla@broadcom.com
4e6ed1901fc0f9319647713b68b5b6b327930a06
3f309b1dd9774ca1eef2c7bb7626447e6c3dbe70
/apps/evsys/evsys_trigger/firmware/src/config/sam_l10_xpro/peripheral/clock/plib_clock.c
e3a6e5298e13415f391dd1c25b0e3d7d7fe6eb46
[ "LicenseRef-scancode-unknown-license-reference", "ISC", "LicenseRef-scancode-public-domain" ]
permissive
Unitek-KL/csp
30892ddf1375f5191173cafdfba5f098245a0ff7
2ac7ba59465f23959e51d2f16a5712b57b79ef5f
refs/heads/master
2020-12-10T13:42:26.878000
2019-10-14T17:55:22
2019-10-14T17:56:20
233,609,402
0
0
NOASSERTION
2020-01-13T14:04:51
2020-01-13T14:04:51
null
UTF-8
C
false
false
4,781
c
/******************************************************************************* CLOCK PLIB Company: Microchip Technology Inc. File Name: plib_clock.c Summary: CLOCK PLIB Implementation File. Description: None *******************************************************************************/ /******************************************************************************* * Copyright (C) 2018 Microchip Technology Inc. and its subsidiaries. * * Subject to your compliance with these terms, you may use Microchip software * and any derivatives exclusively with Microchip products. It is your * responsibility to comply with third party license terms applicable to your * use of third party software (including open source software) that may * accompany Microchip software. * * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A * PARTICULAR PURPOSE. * * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. *******************************************************************************/ #include "plib_clock.h" #include "device.h" static void OSCCTRL_Initialize(void) { /**************** OSC16M IniTialization *************/ OSCCTRL_REGS->OSCCTRL_OSC16MCTRL = OSCCTRL_OSC16MCTRL_FSEL(0x0) | OSCCTRL_OSC16MCTRL_ENABLE_Msk; } static void OSC32KCTRL_Initialize(void) { OSC32KCTRL_REGS->OSC32KCTRL_RTCCTRL = OSC32KCTRL_RTCCTRL_RTCSEL(0); } static void FDPLL_Initialize(void) { GCLK_REGS->GCLK_PCHCTRL[0] = GCLK_PCHCTRL_GEN(0x1) | GCLK_PCHCTRL_CHEN_Msk; while ((GCLK_REGS->GCLK_PCHCTRL[0] & GCLK_PCHCTRL_CHEN_Msk) != GCLK_PCHCTRL_CHEN_Msk) { /* Wait for synchronization */ } /****************** DPLL Initialization *********************************/ /* Configure DPLL */ OSCCTRL_REGS->OSCCTRL_DPLLCTRLB = OSCCTRL_DPLLCTRLB_FILTER(0) | OSCCTRL_DPLLCTRLB_LTIME(0)| OSCCTRL_DPLLCTRLB_REFCLK(2) ; OSCCTRL_REGS->OSCCTRL_DPLLRATIO = OSCCTRL_DPLLRATIO_LDRFRAC(0) | OSCCTRL_DPLLRATIO_LDR(63); while((OSCCTRL_REGS->OSCCTRL_DPLLSYNCBUSY & OSCCTRL_DPLLSYNCBUSY_DPLLRATIO_Msk) == OSCCTRL_DPLLSYNCBUSY_DPLLRATIO_Msk) { /* Waiting for the synchronization */ } /* Selection of the DPLL Enable */ OSCCTRL_REGS->OSCCTRL_DPLLCTRLA = OSCCTRL_DPLLCTRLA_ENABLE_Msk ; while((OSCCTRL_REGS->OSCCTRL_DPLLSYNCBUSY & OSCCTRL_DPLLSYNCBUSY_ENABLE_Msk) == OSCCTRL_DPLLSYNCBUSY_ENABLE_Msk ) { /* Waiting for the DPLL enable synchronization */ } while((OSCCTRL_REGS->OSCCTRL_DPLLSTATUS & (OSCCTRL_DPLLSTATUS_LOCK_Msk | OSCCTRL_DPLLSTATUS_CLKRDY_Msk)) != (OSCCTRL_DPLLSTATUS_LOCK_Msk | OSCCTRL_DPLLSTATUS_CLKRDY_Msk)) { /* Waiting for the Ready state */ } } static void GCLK0_Initialize(void) { GCLK_REGS->GCLK_GENCTRL[0] = GCLK_GENCTRL_DIV(2) | GCLK_GENCTRL_SRC(7) | GCLK_GENCTRL_GENEN_Msk; while((GCLK_REGS->GCLK_SYNCBUSY & GCLK_SYNCBUSY_GENCTRL0_Msk) == GCLK_SYNCBUSY_GENCTRL0_Msk) { /* wait for the Generator 0 synchronization */ } } static void GCLK1_Initialize(void) { GCLK_REGS->GCLK_GENCTRL[1] = GCLK_GENCTRL_DIV(4) | GCLK_GENCTRL_SRC(5) | GCLK_GENCTRL_GENEN_Msk; while((GCLK_REGS->GCLK_SYNCBUSY & GCLK_SYNCBUSY_GENCTRL1_Msk) == GCLK_SYNCBUSY_GENCTRL1_Msk) { /* wait for the Generator 1 synchronization */ } } void CLOCK_Initialize (void) { /* Function to Initialize the Oscillators */ OSCCTRL_Initialize(); /* Function to Initialize the 32KHz Oscillators */ OSC32KCTRL_Initialize(); GCLK1_Initialize(); FDPLL_Initialize(); GCLK0_Initialize(); /* Selection of the Generator and write Lock for EIC */ GCLK_REGS->GCLK_PCHCTRL[3] = GCLK_PCHCTRL_GEN(0x0) | GCLK_PCHCTRL_CHEN_Msk; while ((GCLK_REGS->GCLK_PCHCTRL[3] & GCLK_PCHCTRL_CHEN_Msk) != GCLK_PCHCTRL_CHEN_Msk) { /* Wait for synchronization */ } /* Selection of the Generator and write Lock for EVSYS_0 */ GCLK_REGS->GCLK_PCHCTRL[6] = GCLK_PCHCTRL_GEN(0x0) | GCLK_PCHCTRL_CHEN_Msk; while ((GCLK_REGS->GCLK_PCHCTRL[6] & GCLK_PCHCTRL_CHEN_Msk) != GCLK_PCHCTRL_CHEN_Msk) { /* Wait for synchronization */ } }
[ "http://support.microchip.com" ]
http://support.microchip.com
140d8434c9645707bed4716235e4ff9dc4315eca
c9eccf85f19371a3843911c1480e761de4773722
/src/lvgl/src/lv_misc/lv_bidi.h
f3f758b43ab14b9f6180db943b44a41d1f39df7d
[ "MIT" ]
permissive
mibus/TTGO_TWatch_Library
7d3c04ca2358b181264ea744a1bcd8338f508d91
bd77e6edba3baf9c5c68de4683a01b81f6b3a8b3
refs/heads/master
2022-11-25T03:04:40.292000
2020-07-25T03:15:55
2020-07-25T03:15:55
275,497,118
0
0
MIT
2020-06-28T03:13:55
2020-06-28T03:13:54
null
UTF-8
C
false
false
4,064
h
/** * @file lv_bifi.h * */ #ifndef LV_BIDI_H #define LV_BIDI_H #ifdef __cplusplus extern "C" { #endif /********************* * INCLUDES *********************/ #include "../lv_conf_internal.h" #include <stdbool.h> #include <stdint.h> /********************* * DEFINES *********************/ /* Special non printable strong characters. * They can be inserted to texts to affect the run's direction*/ #define LV_BIDI_LRO "\xE2\x80\xAD" /*U+202D*/ #define LV_BIDI_RLO "\xE2\x80\xAE" /*U+202E*/ /********************** * TYPEDEFS **********************/ enum { /*The first 4 values are stored in `lv_obj_t` on 2 bits*/ LV_BIDI_DIR_LTR = 0x00, LV_BIDI_DIR_RTL = 0x01, LV_BIDI_DIR_AUTO = 0x02, LV_BIDI_DIR_INHERIT = 0x03, LV_BIDI_DIR_NEUTRAL = 0x20, LV_BIDI_DIR_WEAK = 0x21, }; typedef uint8_t lv_bidi_dir_t; /********************** * GLOBAL PROTOTYPES **********************/ #if LV_USE_BIDI /** * Convert a text to get the characters in the correct visual order according to * Unicode Bidirectional Algorithm * @param str_in the text to process * @param str_out store the result here. Has the be `strlen(str_in)` length * @param base_dir `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` */ void _lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_dir); /** * Auto-detect the direction of a text based on the first strong character * @param txt the text to process * @return `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` */ lv_bidi_dir_t _lv_bidi_detect_base_dir(const char * txt); /** * Get the logical position of a character in a line * @param str_in the input string. Can be only one line. * @param bidi_txt internally the text is bidi processed which buffer can be get here. * If not required anymore has to freed with `lv_mem_free()` * Can be `NULL` is unused * @param len length of the line in character count * @param base_dir base direction of the text: `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` * @param vicual_pos the visual character position which logical position should be get * @param is_rtl tell the the char at `viasual_pos` is RTL or LTR context * @return the logical character position */ uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos, bool * is_rtl); /** * Get the visual position of a character in a line * @param str_in the input string. Can be only one line. * @param bidi_txt internally the text is bidi processed which buffer can be get here. * If not required anymore has to freed with `lv_mem_free()` * Can be `NULL` is unused * @param len length of the line in character count * @param base_dir base direction of the text: `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` * @param logical_pos the logical character position which visual position should be get * @param is_rtl tell the the char at `logical_pos` is RTL or LTR context * @return the visual character position */ uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, uint32_t logical_pos, bool * is_rtl); /** * Bidi process a paragraph of text * @param str_in the string to process * @param str_out store the result here * @param len length of teh text * @param base_dir base dir of the text * @param pos_conv_out an `uint16_t` array to store the related logical position of the character. * Can be `NULL` is unused * @param pos_conv_len length of `pos_conv_out` in element count */ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir, uint16_t * pos_conv_out, uint16_t pos_conv_len); /********************** * MACROS **********************/ #endif /*LV_USE_BIDI*/ #ifdef __cplusplus } /* extern "C" */ #endif #endif /*LV_BIDI_H*/
[ "lewisxhe@outlook.com" ]
lewisxhe@outlook.com
0ddad1251dcd4016b4c526efeafe716af3f5026e
ef9a2839953f3586e66c1cf824c9de199f52d088
/mcc_generated_files/X2CCode/Library/Math/Controller/inc/Sqrt_FiP16.h
b83fa9c934f92a6452ef0773f0ae3be8fd299024
[]
no_license
MCHP-X2Cdemos/mc_foc_sl_fip_dsPIC33ck_mclv2.x
72f1e06eb18738796d59938474c6d533bd07bb1e
d77e18983439d895b83b6d63fdaad4c8fdb028e7
refs/heads/master
2023-03-20T10:54:54.157000
2021-03-11T22:01:12
2021-03-11T22:01:12
288,478,027
2
0
null
null
null
null
UTF-8
C
false
false
3,510
h
/* * Copyright (c) 2013, Linz Center of Mechatronics GmbH (LCM) http://www.lcm.at/ * All rights reserved. */ /* * This file is licensed according to the BSD 3-clause license as follows: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the "Linz Center of Mechatronics GmbH" and "LCM" 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 "Linz Center of Mechatronics GmbH" 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. */ /* * This file is part of X2C. http://x2c.lcm.at/ * $LastChangedRevision: 1603 $ */ /* USERCODE-BEGIN:Description */ /** Description: Square Root Computation **/ /** Calculation: **/ /** y = sqrt((abs(u)) **/ /** **/ /* USERCODE-END:Description */ #ifndef SQRT_FIP16_H #define SQRT_FIP16_H #ifdef __cplusplus extern "C" { #endif #include "CommonFcts.h" #if !defined(SQRT_FIP16_ISLINKED) #define SQRT_FIP16_ID ((uint16)4817) typedef struct { uint16 ID; int16 *In; int16 Out; } SQRT_FIP16; #define SQRT_FIP16_FUNCTIONS { \ SQRT_FIP16_ID, \ (void (*)(void*))Sqrt_FiP16_Update, \ (void (*)(void*))Sqrt_FiP16_Init, \ (tLoadImplementationParameter)Common_Load, \ (tSaveImplementationParameter)Common_Save, \ (void* (*)(const void*, uint16))Sqrt_FiP16_GetAddress } /**********************************************************************************************************************/ /** Public prototypes **/ /**********************************************************************************************************************/ void Sqrt_FiP16_Update(SQRT_FIP16 *pTSqrt_FiP16); void Sqrt_FiP16_Init(SQRT_FIP16 *pTSqrt_FiP16); void* Sqrt_FiP16_GetAddress(const SQRT_FIP16 *block, uint16 elementId); #endif #ifdef __cplusplus } #endif #endif
[ "christoph.baumgartner@microchipcom" ]
christoph.baumgartner@microchipcom
00b89f8c82ebde7fba9cca6124b9592cc534c8af
a0d6b2c2dd8bcbe03e5c6fb35f766bd2af9a1d5c
/dynix.3.2.0/src/ucb/tftp/main.c
a7f804e9f48afbb7a6089aad2297032b45976d5f
[]
no_license
legacy-codedigger/Dynix.3.2.Source
593485f234eee4de75c0e23fe689f247471c83f8
2789373c94bc57e4c4a915bcba354f2243e12ca4
refs/heads/master
2022-04-25T22:49:00.493000
2020-04-25T00:49:59
2020-04-25T00:49:59
258,656,640
0
0
null
null
null
null
UTF-8
C
false
false
13,184
c
/* $Copyright: $ * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 * Sequent Computer Systems, Inc. All rights reserved. * * This software is furnished under a license and may be used * only in accordance with the terms of that license and with the * inclusion of the above copyright notice. This software may not * be provided or otherwise made available to, or used by, any * other person. No title to or ownership of the software is * hereby transferred. */ #ifndef lint static char rcsid[] = "$Header: main.c 2.3 90/04/05 $"; #endif /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint char copyright[] = "@(#) Copyright (c) 1983 Regents of the University of California.\n\ All rights reserved.\n"; #endif /* not lint */ #ifndef lint static char sccsid[] = "@(#)main.c 5.7 (Berkeley) 6/29/88"; #endif /* not lint */ /* Many bug fixes are from Jim Guyton <guyton@rand-unix> */ /* * TFTP User Program -- Command Interface. */ #include <sys/types.h> #include <sys/socket.h> #include <sys/file.h> #include <netinet/in.h> #include <signal.h> #include <stdio.h> #include <errno.h> #include <setjmp.h> #include <ctype.h> #include <netdb.h> #define TIMEOUT 5 /* secs between rexmt's */ struct sockaddr_in sin; int f; short port; int trace; int verbose; int connected; char mode[32]; char line[200]; int margc; char *margv[20]; char *prompt = "tftp"; jmp_buf toplevel; int intr(); struct servent *sp; int quit(), help(), setverbose(), settrace(), status(); int get(), put(), setpeer(), modecmd(), setrexmt(), settimeout(); int setbinary(), setascii(); #define HELPINDENT (sizeof("connect")) struct cmd { char *name; char *help; int (*handler)(); }; char vhelp[] = "toggle verbose mode"; char thelp[] = "toggle packet tracing"; char chelp[] = "connect to remote tftp"; char qhelp[] = "exit tftp"; char hhelp[] = "print help information"; char shelp[] = "send file"; char rhelp[] = "receive file"; char mhelp[] = "set file transfer mode"; char sthelp[] = "show current status"; char xhelp[] = "set per-packet retransmission timeout"; char ihelp[] = "set total retransmission timeout"; char ashelp[] = "set mode to netascii"; char bnhelp[] = "set mode to octet"; struct cmd cmdtab[] = { { "connect", chelp, setpeer }, { "mode", mhelp, modecmd }, { "put", shelp, put }, { "get", rhelp, get }, { "quit", qhelp, quit }, { "verbose", vhelp, setverbose }, { "trace", thelp, settrace }, { "status", sthelp, status }, { "binary", bnhelp, setbinary }, { "ascii", ashelp, setascii }, { "rexmt", xhelp, setrexmt }, { "timeout", ihelp, settimeout }, { "?", hhelp, help }, 0 }; struct cmd *getcmd(); char *tail(); char *index(); char *rindex(); main(argc, argv) char *argv[]; { struct sockaddr_in sin; int top; sp = getservbyname("tftp", "udp"); if (sp == 0) { fprintf(stderr, "tftp: udp/tftp: unknown service\n"); exit(1); } f = socket(AF_INET, SOCK_DGRAM, 0); if (f < 0) { perror("tftp: socket"); exit(3); } bzero((char *)&sin, sizeof (sin)); sin.sin_family = AF_INET; if (bind(f, &sin, sizeof (sin)) < 0) { perror("tftp: bind"); exit(1); } strcpy(mode, "netascii"); signal(SIGINT, intr); if (argc > 1) { if (setjmp(toplevel) != 0) exit(0); setpeer(argc, argv); } top = setjmp(toplevel) == 0; for (;;) command(top); } char hostname[100]; setpeer(argc, argv) int argc; char *argv[]; { struct hostent *host; if (argc < 2) { strcpy(line, "Connect "); printf("(to) "); gets(&line[strlen(line)]); makeargv(); argc = margc; argv = margv; } if (argc > 3) { printf("usage: %s host-name [port]\n", argv[0]); return; } host = gethostbyname(argv[1]); if (host) { sin.sin_family = host->h_addrtype; bcopy(host->h_addr, &sin.sin_addr, host->h_length); strcpy(hostname, host->h_name); } else { sin.sin_family = AF_INET; sin.sin_addr.s_addr = inet_addr(argv[1]); if (sin.sin_addr.s_addr == -1) { connected = 0; printf("%s: unknown host\n", argv[1]); return; } strcpy(hostname, argv[1]); } port = sp->s_port; if (argc == 3) { port = atoi(argv[2]); if (port < 0) { printf("%s: bad port number\n", argv[2]); connected = 0; return; } port = htons(port); } connected = 1; } struct modes { char *m_name; char *m_mode; } modes[] = { { "ascii", "netascii" }, { "netascii", "netascii" }, { "binary", "octet" }, { "image", "octet" }, { "octet", "octet" }, /* { "mail", "mail" }, */ { 0, 0 } }; modecmd(argc, argv) char *argv[]; { register struct modes *p; char *sep; if (argc < 2) { printf("Using %s mode to transfer files.\n", mode); return; } if (argc == 2) { for (p = modes; p->m_name; p++) if (strcmp(argv[1], p->m_name) == 0) break; if (p->m_name) { setmode(p->m_mode); return; } printf("%s: unknown mode\n", argv[1]); /* drop through and print usage message */ } printf("usage: %s [", argv[0]); sep = " "; for (p = modes; p->m_name; p++) { printf("%s%s", sep, p->m_name); if (*sep == ' ') sep = " | "; } printf(" ]\n"); return; } setbinary(argc, argv) char *argv[]; { setmode("octet"); } setascii(argc, argv) char *argv[]; { setmode("netascii"); } setmode(newmode) char *newmode; { strcpy(mode, newmode); if (verbose) printf("mode set to %s\n", mode); } /* * Send file(s). */ put(argc, argv) char *argv[]; { int fd; register int n; register char *cp, *targ; if (argc < 2) { strcpy(line, "send "); printf("(file) "); gets(&line[strlen(line)]); makeargv(); argc = margc; argv = margv; } if (argc < 2) { putusage(argv[0]); return; } targ = argv[argc - 1]; if (index(argv[argc - 1], ':')) { char *cp; struct hostent *hp; for (n = 1; n < argc - 1; n++) if (index(argv[n], ':')) { putusage(argv[0]); return; } cp = argv[argc - 1]; targ = index(cp, ':'); *targ++ = 0; hp = gethostbyname(cp); if (hp == 0) { printf("%s: Unknown host.\n", cp); return; } bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length); sin.sin_family = hp->h_addrtype; connected = 1; strcpy(hostname, hp->h_name); port = sp->s_port; } if (!connected) { printf("No target machine specified.\n"); return; } if (argc < 4) { cp = argc == 2 ? tail(targ) : argv[1]; fd = open(cp, O_RDONLY); if (fd < 0) { fprintf(stderr, "tftp: "); perror(cp); return; } if (verbose) printf("putting %s to %s:%s [%s]\n", cp, hostname, targ, mode); sin.sin_port = port; sendfile(fd, targ, mode); return; } /* this assumes the target is a directory */ /* on a remote unix system. hmmmm. */ cp = index(targ, '\0'); *cp++ = '/'; for (n = 1; n < argc - 1; n++) { strcpy(cp, tail(argv[n])); fd = open(argv[n], O_RDONLY); if (fd < 0) { fprintf(stderr, "tftp: "); perror(argv[n]); continue; } if (verbose) printf("putting %s to %s:%s [%s]\n", argv[n], hostname, targ, mode); sin.sin_port = port; sendfile(fd, targ, mode); } } putusage(s) char *s; { printf("usage: %s file ... host:target, or\n", s); printf(" %s file ... target (when already connected)\n", s); } /* * Receive file(s). */ get(argc, argv) char *argv[]; { int fd; register int n; register char *cp; char *src; if (argc < 2) { strcpy(line, "get "); printf("(files) "); gets(&line[strlen(line)]); makeargv(); argc = margc; argv = margv; } if (argc < 2) { getusage(argv[0]); return; } if (!connected) { for (n = 1; n < (argc - 1); n++) if (index(argv[n], ':') == 0) { getusage(argv[0]); return; } } for (n = 1; n < argc ; n++) { src = index(argv[n], ':'); if (src == NULL) src = argv[n]; else { struct hostent *hp; *src++ = 0; hp = gethostbyname(argv[n]); if (hp == 0) { printf("%s: Unknown host.\n", argv[n]); continue; } bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length); sin.sin_family = hp->h_addrtype; connected = 1; strcpy(hostname, hp->h_name); port = sp->s_port; } if (argc < 4) { cp = argc == 3 ? argv[2] : tail(src); fd = creat(cp, 0644); if (fd < 0) { fprintf(stderr, "tftp: "); perror(cp); return; } if (verbose) printf("getting from %s:%s to %s [%s]\n", hostname, src, cp, mode); sin.sin_port = port; recvfile(fd, src, mode); break; } cp = tail(src); /* new .. jdg */ fd = creat(cp, 0644); if (fd < 0) { fprintf(stderr, "tftp: "); perror(cp); continue; } if (verbose) printf("getting from %s:%s to %s [%s]\n", hostname, src, cp, mode); sin.sin_port = port; recvfile(fd, src, mode); } } getusage(s) char * s; { printf("usage: %s host:file host:file ... file, or\n", s); printf(" %s file file ... file if connected\n", s); } int rexmtval = TIMEOUT; setrexmt(argc, argv) char *argv[]; { int t; if (argc < 2) { strcpy(line, "Rexmt-timeout "); printf("(value) "); gets(&line[strlen(line)]); makeargv(); argc = margc; argv = margv; } if (argc != 2) { printf("usage: %s value\n", argv[0]); return; } t = atoi(argv[1]); if (t < 0) printf("%s: bad value\n", t); else rexmtval = t; } int maxtimeout = 5 * TIMEOUT; settimeout(argc, argv) char *argv[]; { int t; if (argc < 2) { strcpy(line, "Maximum-timeout "); printf("(value) "); gets(&line[strlen(line)]); makeargv(); argc = margc; argv = margv; } if (argc != 2) { printf("usage: %s value\n", argv[0]); return; } t = atoi(argv[1]); if (t < 0) printf("%s: bad value\n", t); else maxtimeout = t; } status(argc, argv) char *argv[]; { if (connected) printf("Connected to %s.\n", hostname); else printf("Not connected.\n"); printf("Mode: %s Verbose: %s Tracing: %s\n", mode, verbose ? "on" : "off", trace ? "on" : "off"); printf("Rexmt-interval: %d seconds, Max-timeout: %d seconds\n", rexmtval, maxtimeout); } intr() { signal(SIGALRM, SIG_IGN); alarm(0); longjmp(toplevel, -1); } char * tail(filename) char *filename; { register char *s; while (*filename) { s = rindex(filename, '/'); if (s == NULL) break; if (s[1]) return (s + 1); *s = '\0'; } return (filename); } /* * Command parser. */ command(top) int top; { register struct cmd *c; if (!top) putchar('\n'); for (;;) { printf("%s> ", prompt); if (gets(line) == 0) { if (feof(stdin)) { quit(); } else { continue; } } if (line[0] == 0) continue; makeargv(); c = getcmd(margv[0]); if (c == (struct cmd *)-1) { printf("?Ambiguous command\n"); continue; } if (c == 0) { printf("?Invalid command\n"); continue; } (*c->handler)(margc, margv); } } struct cmd * getcmd(name) register char *name; { register char *p, *q; register struct cmd *c, *found; register int nmatches, longest; longest = 0; nmatches = 0; found = 0; for (c = cmdtab; p = c->name; c++) { for (q = name; *q == *p++; q++) if (*q == 0) /* exact match? */ return (c); if (!*q) { /* the name was a prefix */ if (q - name > longest) { longest = q - name; nmatches = 1; found = c; } else if (q - name == longest) nmatches++; } } if (nmatches > 1) return ((struct cmd *)-1); return (found); } /* * Slice a string up into argc/argv. */ makeargv() { register char *cp; register char **argp = margv; margc = 0; for (cp = line; *cp;) { while (isspace(*cp)) cp++; if (*cp == '\0') break; *argp++ = cp; margc += 1; while (*cp != '\0' && !isspace(*cp)) cp++; if (*cp == '\0') break; *cp++ = '\0'; } *argp++ = 0; } /*VARARGS*/ quit() { exit(0); } /* * Help command. */ help(argc, argv) int argc; char *argv[]; { register struct cmd *c; if (argc == 1) { printf("Commands may be abbreviated. Commands are:\n\n"); for (c = cmdtab; c->name; c++) printf("%-*s\t%s\n", HELPINDENT, c->name, c->help); return; } while (--argc > 0) { register char *arg; arg = *++argv; c = getcmd(arg); if (c == (struct cmd *)-1) printf("?Ambiguous help command %s\n", arg); else if (c == (struct cmd *)0) printf("?Invalid help command %s\n", arg); else printf("%s\n", c->help); } } /*VARARGS*/ settrace() { trace = !trace; printf("Packet tracing %s.\n", trace ? "on" : "off"); } /*VARARGS*/ setverbose() { verbose = !verbose; printf("Verbose mode %s.\n", verbose ? "on" : "off"); }
[ "zahir.meddour@protonmail.com" ]
zahir.meddour@protonmail.com
32004cd6aee41c08905cd5b705ab6f8ff0bb6507
cdf75036c20eed12b54f9110c95588652899fa4c
/Others/atoi_2.c
1845ab7cbe713cde67484b57a0fe4dd8bbf74bd5
[]
no_license
M1c17/C_Programming_Language
6ca585297ab6014a8a5a86ec1e4be8fb58f01e39
15c3074a7876dea9615a3d4a5dd0bb8120abf180
refs/heads/main
2023-03-06T05:41:51.665000
2021-02-07T04:41:49
2021-02-07T04:41:49
323,505,241
0
0
null
null
null
null
UTF-8
C
false
false
862
c
#include <stdio.h> #include <ctype.h> #include <string.h> /* atoi: convert s to integer; version 2 */ int atoi(char line[]); int main(){ int val; char str[10]; strcpy(str, "-93284927"); val = atoi(str); printf("String value = %s, Int value = %d\n", str, val); strcpy(str, "hello"); val = atoi(str); printf("String value = %s, Int value = %d\n", str, val); return 0; } int atoi(char line[]){ //Initialize variables int i, n, sign; //skip white space, if any for (i = 0; isspace(line[i]); ++i){ ; } //get sign, if any sign = (line[i] == '-') ? -1 : 1; //skip sign, if any if (line[i] == '+' || line[i] == '-'){ ++i; } //get integer part and convert it for (n = 0; isdigit(line[i]); ++i){ n = 10 * n + (line[i] - '0'); } return sign * n; }
[ "pictor117@gmail.com" ]
pictor117@gmail.com
f8a07ef6a3923daba641e7ac3c0fd7ad2ecbfc87
1fabbdfd1ca9ea1b6808893e12bd907eb74de414
/xcode/Classes/Native/AssemblyU2DCSharp_SPacket_SocketInstance_GC_SYNC_REACHEDSCENMethodDeclarations.h
cc71e70250fd75fada95620a65e6af4003c60645
[]
no_license
Klanly/TutorialPackageClient
6f889e96c40ab13c97d107708ae8f3c71a484301
b9d61ba2f287c491c9565b432f852980ec3fee28
refs/heads/master
2020-12-03T01:42:35.256000
2016-11-01T02:40:21
2016-11-01T02:40:21
null
0
0
null
null
null
null
UTF-8
C
false
false
743
h
๏ปฟ#pragma once #include <stdint.h> #include <assert.h> #include <exception> #include "codegen/il2cpp-codegen.h" // SPacket.SocketInstance.GC_SYNC_REACHEDSCENEHandler struct GC_SYNC_REACHEDSCENEHandler_t2847; // PacketDistributed struct PacketDistributed_t2209; // System.Void SPacket.SocketInstance.GC_SYNC_REACHEDSCENEHandler::.ctor() void GC_SYNC_REACHEDSCENEHandler__ctor_m16033 (GC_SYNC_REACHEDSCENEHandler_t2847 * __this, MethodInfo* method) IL2CPP_METHOD_ATTR; // System.UInt32 SPacket.SocketInstance.GC_SYNC_REACHEDSCENEHandler::Execute(PacketDistributed) uint32_t GC_SYNC_REACHEDSCENEHandler_Execute_m16034 (GC_SYNC_REACHEDSCENEHandler_t2847 * __this, PacketDistributed_t2209 * ___ipacket, MethodInfo* method) IL2CPP_METHOD_ATTR;
[ "bu213200@gmail.com" ]
bu213200@gmail.com
7474d91708e166196a92071abed55e4358790a6c
33a6448e047d43eeeebe36f11cec5863c4d237c9
/FileReadWriteCharacter/main.c
f73b56c824db77ca9043f16bbc2c6f2800163b97
[]
no_license
Qianfinland/C
fca683f4e503a63435f43d1c82d1b5704b954bcf
00f6530d1282149b5d218e4ab4069562c145fd8e
refs/heads/master
2021-01-10T16:08:32.115000
2015-08-16T19:52:21
2015-08-16T19:52:21
36,993,923
0
0
null
null
null
null
UTF-8
C
false
false
1,026
c
#include <stdio.h> int main() { FILE *file = fopen("/home/qxzhou/NetBeansProjects/daydaylearning/FileReadWriteCharacter/read.txt", "r"); if(file == NULL) { printf("Error on open the file !"); return 1; } while(1) { int ch = fgetc(file); if(ch == EOF) break; printf("%c", ch); } FILE *file2 = fopen("/home/qxzhou/NetBeansProjects/daydaylearning/FileReadWriteCharacter/write.txt", "w"); if(file2 == NULL) { printf("Error on open the file !"); return 1; } /*char c[1000]; printf("Enter a sentence to the file!\n"); fgets(c, sizeof(c), stdin); //gets(c);//dangerous to use fprintf(file2, "%s", c);*/ printf("Enter multiple lines of strings and end by ctrl+D\n"); while(1) { char ch; ch = getchar(); //putchar(ch);// if(ch == EOF) break; putc(ch, file2); } fclose(file); fclose(file2); return 0; }
[ "qianfinland@gmail.com" ]
qianfinland@gmail.com
726a722b8c6dcb1d128fb29aeec5b4130d327071
999d0cc68f04af3168b1eb5f766756b5661170f4
/robot/็ฌฌๅ››็ป„/่ˆตๆœบ-STM32/USER/main.c
555d4c36330cc649455c80a1336c946a2637e724
[]
no_license
aestheticisma/2019
e89e24b6fdf5e56d76af3211b97194ea01bab0e1
4286782e714cdcda86f8c477be2fc5a9297f49aa
refs/heads/master
2020-06-19T19:05:32.242000
2019-07-14T13:34:13
2019-07-14T13:34:13
196,836,522
1
0
null
2019-07-14T12:55:50
2019-07-14T12:55:49
null
GB18030
C
false
false
1,104
c
#include "stm32f10x.h" #include "car.h" #include "delay.h" #include "control.h" #include "echo.h" #include "infrared.h" int main(void) { float a=0.0; char len; control_init(); SysTick_Init();//ๅปถๆ—ถๅˆๅง‹ๅŒ– echo_init(); infrared_init(); //Usart1_Init(); while(1) { len='0'; a=(((float)Get_Adc(ADC_Channel_1))/4096)*3.3; if(a>=0.95){ len = '1'; } USART_SendData(USART1,len); while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET); static_pole(); Delay_ms(2000); } } //ๆฏๆฌกtimerไน‹ๅŽ void TIM3_IRQHandler(void) { if(TIM_GetITStatus(TIM3,TIM_IT_Update) != RESET) { TIM_ClearITPendingBit(TIM3, TIM_IT_Update); } } void USART1_IRQHandler(void) { int order= 0 ; if(USART_GetITStatus(USART1,USART_IT_RXNE)==SET) { order = USART_ReceiveData(USART1); USART_ClearITPendingBit(USART1,USART_IT_RXNE); USART_ClearFlag(USART1,USART_IT_RXNE); switch(order) { case 0x00000031://ๅ‰่ฟ› up(); break; case 0x00000032://ๅ€’่ฝฆ down(); break; } } }
[ "noreply@github.com" ]
noreply@github.com
e68b09ef487cfbc95b0472becf08661d8f918a67
93f2b5dc75142b5d6f5cb31e1e02f1c5aac130a0
/srcs_lem/get_next_line1.c
9a771719bb18a1137c4edc964beaab2d64290170
[]
no_license
Enshertid/lem-in_school21
d869541fb45c6c6f9d8f96bb047d489aed895b26
3b326ec0c41cefe4af28eb46d76817ad89612a33
refs/heads/master
2022-05-07T23:49:00.736000
2020-03-15T16:34:49
2020-03-15T16:34:49
null
0
0
null
null
null
null
UTF-8
C
false
false
3,150
c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_next_line1.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ymanilow <ymanilow@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/02 14:42:04 by dbendu #+# #+# */ /* Updated: 2020/02/13 21:25:11 by ymanilow ### ########.fr */ /* */ /* ************************************************************************** */ #include "lem_in.h" #define GNL_BUFF 1024 void ft_lstappend(t_list **list, t_list *new) { if (!list || !new) return ; if (!*list) { *list = new; new->end = new; } else { (*list)->end->next = new; (*list)->end = new; } } static void add_in_bufs(t_list **bufs, const char *src, size_t strlen, int fd) { char *str; str = ft_strnew(strlen); ft_memcpy(str, src, strlen); ft_lstappend(bufs, ft_lstnew(str, strlen + 1)); (*bufs)->end->content_size = fd; free(str); } static int check_bufs(t_list **bufs, t_list **buf, int fd) { t_list *iter; char *npos; char *temp; iter = *bufs; while (iter && (int)iter->content_size != fd) iter = iter->next; if (!iter) return (0); npos = (char*)ft_memchr(iter->content, '\n', ft_strlen(iter->content)); ft_lstappend(buf, ft_lstnew(iter->content, npos ? (size_t)(npos - (char*)iter->content) : (size_t)ft_strlen(iter->content))); if (!npos || (npos && !npos[1])) ft_lstdelete(bufs, &iter); else if (npos[1]) { temp = ft_strdup(npos + 1); free(iter->content); iter->content = temp; } return (npos ? 1 : 0); } static char *lst_to_str(const t_list *list) { char *str; char *striter; const t_list *lstiter; size_t len; len = 0; lstiter = list; while (lstiter) { len += lstiter->content_size; lstiter = lstiter->next; } str = ft_strnew(len); if (!str) return (NULL); striter = str; while (list) { ft_memcpy(striter, list->content, list->content_size); striter += list->content_size; list = list->next; } return (str); } int get_next_line(const int fd, char **line) { static t_list *bufs = NULL; t_list *buf; ssize_t ret; char *npos; char str[GNL_BUFF]; if (fd < 0 || !GNL_BUFF || read(fd, str, 0) < 0 || (buf = NULL)) return (-1); if (!check_bufs(&bufs, &buf, fd)) { while ((ret = read(fd, str, GNL_BUFF))) { npos = (char*)ft_memchr(str, '\n', ret); ft_lstappend(&buf, ft_lstnew(str, npos ? npos - str : ret)); if (npos) break ; } if (!ret && !buf) return (0); if (ret && npos && npos - str != ret - 1) add_in_bufs(&bufs, npos + 1, ret - 1 - (npos - str), fd); } *line = lst_to_str(buf); ft_lstpurge(&buf); return (*line ? 1 : -1); }
[ "enshertid@icloud.com" ]
enshertid@icloud.com
26393171c0093670884c0ea4829ff4beaea2848e
fda015cc078e877754e4cd5a48e970f0a1159ada
/src/sources/shared/system_support/os_specifics.h
aee560f47e775860f7a101ac20eaaa04456aeddf
[]
no_license
cran/liquidSVM
886e0487104a434d3854120a774ebe120e1ddeae
35b8af219f5d52df5513789793c1e5cf07d310b8
refs/heads/master
2020-04-06T04:12:26.063000
2019-09-14T17:20:02
2019-09-14T17:20:02
83,014,436
2
0
null
null
null
null
UTF-8
C
false
false
4,395
h
// Copyright 2015, 2016, 2017 Ingo Steinwart // // This file is part of liquidSVM. // // liquidSVM is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // liquidSVM 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 Affero General Public License for more details. // You should have received a copy of the GNU Affero General Public License // along with liquidSVM. If not, see <http://www.gnu.org/licenses/>. #if !defined (OS_SPECIFICS_H) #define OS_SPECIFICS_H #include "sources/shared/system_support/compiler_specifics.h" //********************************************************************************************************************************** // Linux and Mac //********************************************************************************************************************************** #if defined __linux__ || defined __MACH__ #define POSIX_OS__ #define THREADING_IMPLEMENTED #ifdef __SSE2__ #define SSE2__ #endif #ifdef __AVX__ #define AVX__ #endif #ifdef __AVX2__ #define AVX2__ #endif #define sync_add_and_fetch __sync_add_and_fetch #define Tmutex pthread_mutex_t #define Tthread_handle pthread_t #define atomic_unsigned unsigned #define thread__ __thread #define restrict__ __restrict__ #endif //********************************************************************************************************************************** // Windows //********************************************************************************************************************************** #if defined _WIN32 #if !defined (NOMINMAX) #define NOMINMAX #endif #include <malloc.h> // Has to come before windows.h #include <windows.h> // Has to come before emmintrin.h/immintrin.h in simd_basics.h ! #include <iso646.h> #define THREADING_IMPLEMENTED #undef COMPILE_WITH_CUDA__ // The next line repeats the default of MS Visual Studio 2012++ // Basically, it assumes that Windows is not running on a CPU built before 2004 or so. #define SSE2__ #ifdef __AVX__ #define AVX__ #endif #ifdef __AVX2__ #define AVX2__ #endif #define Tmutex HANDLE #define Tthread_handle HANDLE #ifdef __MINGW32__ #define sync_add_and_fetch __sync_add_and_fetch #define atomic_unsigned unsigned #define thread__ __thread #else #define sync_add_and_fetch atomic_fetch_add #if defined(MSVISUAL_LEGACY) #define atomic_unsigned unsigned #else #define atomic_unsigned atomic_uint #endif #define thread__ __declspec(thread) #endif #define restrict__ __restrict #endif //********************************************************************************************************************************** // Other Operating Systems //********************************************************************************************************************************** #if !defined(POSIX_OS__) && !defined(_WIN32) #define UNKNOWN_OS__ #undef THREADING_IMPLEMENTED // The following definitions are meant as safeguards. Depending on the // situtation they may or may not be necessary. #undef SSE2__ #undef AVX__ #undef AVX2__ #undef COMPILE_WITH_CUDA__ #define Tmutex unsigned #define Tthread_handle void* #define atomic_unsigned unsigned #define thread__ #define restrict__ #endif //********************************************************************************************************************************** // More safeguards //********************************************************************************************************************************** // Make sure that simd instructions are only used on systems on which we can // safely alloc aligned memory. Currently, this is true for MS Windows and // systems supporting POSIX with optional posix_memalign commands. #if defined _WIN32 #define SIMD_ACTIVATED #else #include <unistd.h> #if defined(_POSIX_ADVISORY_INFO) && _POSIX_ADVISORY_INFO > 0 #define SIMD_ACTIVATED #else #undef SIMD_ACTIVATED #undef AVX2__ #undef AVX__ #undef SSE2__ #endif #endif #endif
[ "csardi.gabor+cran@gmail.com" ]
csardi.gabor+cran@gmail.com
85535a4d92f8f2666b9a5170975b7e8728e2f10d
bd1fea86d862456a2ec9f56d57f8948456d55ee6
/000/246/087/CWE78_OS_Command_Injection__char_listen_socket_w32_execv_13.c
820a233fd4b7e26bdeed91be32983bf04da283ab
[]
no_license
CU-0xff/juliet-cpp
d62b8485104d8a9160f29213368324c946f38274
d8586a217bc94cbcfeeec5d39b12d02e9c6045a2
refs/heads/master
2021-03-07T15:44:19.446000
2020-03-10T12:45:40
2020-03-10T12:45:40
246,275,244
0
1
null
null
null
null
UTF-8
C
false
false
6,999
c
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE78_OS_Command_Injection__char_listen_socket_w32_execv_13.c Label Definition File: CWE78_OS_Command_Injection.strings.label.xml Template File: sources-sink-13.tmpl.c */ /* * @description * CWE: 78 OS Command Injection * BadSource: listen_socket Read data using a listen socket (server side) * GoodSource: Fixed string * Sink: w32_execv * BadSink : execute command with execv * Flow Variant: 13 Control flow: if(GLOBAL_CONST_FIVE==5) and if(GLOBAL_CONST_FIVE!=5) * * */ #include "std_testcase.h" #include <wchar.h> #ifdef _WIN32 #define COMMAND_INT_PATH "%WINDIR%\\system32\\cmd.exe" #define COMMAND_INT "cmd.exe" #define COMMAND_ARG1 "/c" #define COMMAND_ARG2 "dir " #define COMMAND_ARG3 data #else /* NOT _WIN32 */ #include <unistd.h> #define COMMAND_INT_PATH "/bin/sh" #define COMMAND_INT "sh" #define COMMAND_ARG1 "-c" #define COMMAND_ARG2 "ls " #define COMMAND_ARG3 data #endif #ifdef _WIN32 #include <winsock2.h> #include <windows.h> #include <direct.h> #pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */ #define CLOSE_SOCKET closesocket #else #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #define CLOSE_SOCKET close #define SOCKET int #endif #define TCP_PORT 27015 #define LISTEN_BACKLOG 5 #include <process.h> #define EXECV _execv #ifndef OMITBAD void CWE78_OS_Command_Injection__char_listen_socket_w32_execv_13_bad() { char * data; char dataBuffer[100] = COMMAND_ARG2; data = dataBuffer; if(GLOBAL_CONST_FIVE==5) { { #ifdef _WIN32 WSADATA wsaData; int wsaDataInit = 0; #endif int recvResult; struct sockaddr_in service; char *replace; SOCKET listenSocket = INVALID_SOCKET; SOCKET acceptSocket = INVALID_SOCKET; size_t dataLen = strlen(data); do { #ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) { break; } wsaDataInit = 1; #endif /* POTENTIAL FLAW: Read data using a listen socket */ listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (listenSocket == INVALID_SOCKET) { break; } memset(&service, 0, sizeof(service)); service.sin_family = AF_INET; service.sin_addr.s_addr = INADDR_ANY; service.sin_port = htons(TCP_PORT); if (bind(listenSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR) { break; } if (listen(listenSocket, LISTEN_BACKLOG) == SOCKET_ERROR) { break; } acceptSocket = accept(listenSocket, NULL, NULL); if (acceptSocket == SOCKET_ERROR) { break; } /* Abort on error or the connection was closed */ recvResult = recv(acceptSocket, (char *)(data + dataLen), sizeof(char) * (100 - dataLen - 1), 0); if (recvResult == SOCKET_ERROR || recvResult == 0) { break; } /* Append null terminator */ data[dataLen + recvResult / sizeof(char)] = '\0'; /* Eliminate CRLF */ replace = strchr(data, '\r'); if (replace) { *replace = '\0'; } replace = strchr(data, '\n'); if (replace) { *replace = '\0'; } } while (0); if (listenSocket != INVALID_SOCKET) { CLOSE_SOCKET(listenSocket); } if (acceptSocket != INVALID_SOCKET) { CLOSE_SOCKET(acceptSocket); } #ifdef _WIN32 if (wsaDataInit) { WSACleanup(); } #endif } } { char *args[] = {COMMAND_INT_PATH, COMMAND_ARG1, COMMAND_ARG3, NULL}; /* execv - specify the path where the command is located */ /* POTENTIAL FLAW: Execute command without validating input possibly leading to command injection */ EXECV(COMMAND_INT_PATH, args); } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B1() - use goodsource and badsink by changing the GLOBAL_CONST_FIVE==5 to GLOBAL_CONST_FIVE!=5 */ static void goodG2B1() { char * data; char dataBuffer[100] = COMMAND_ARG2; data = dataBuffer; if(GLOBAL_CONST_FIVE!=5) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } else { /* FIX: Append a fixed string to data (not user / external input) */ strcat(data, "*.*"); } { char *args[] = {COMMAND_INT_PATH, COMMAND_ARG1, COMMAND_ARG3, NULL}; /* execv - specify the path where the command is located */ /* POTENTIAL FLAW: Execute command without validating input possibly leading to command injection */ EXECV(COMMAND_INT_PATH, args); } } /* goodG2B2() - use goodsource and badsink by reversing the blocks in the if statement */ static void goodG2B2() { char * data; char dataBuffer[100] = COMMAND_ARG2; data = dataBuffer; if(GLOBAL_CONST_FIVE==5) { /* FIX: Append a fixed string to data (not user / external input) */ strcat(data, "*.*"); } { char *args[] = {COMMAND_INT_PATH, COMMAND_ARG1, COMMAND_ARG3, NULL}; /* execv - specify the path where the command is located */ /* POTENTIAL FLAW: Execute command without validating input possibly leading to command injection */ EXECV(COMMAND_INT_PATH, args); } } void CWE78_OS_Command_Injection__char_listen_socket_w32_execv_13_good() { goodG2B1(); goodG2B2(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on * its own for testing or for building a binary to use in testing binary * analysis tools. It is not used when compiling all the testcases as one * application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE78_OS_Command_Injection__char_listen_socket_w32_execv_13_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE78_OS_Command_Injection__char_listen_socket_w32_execv_13_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
[ "frank@fischer.com.mt" ]
frank@fischer.com.mt
8b39fe097d9a0ad75f4e8e176acbcd3e9e6ce47c
5c255f911786e984286b1f7a4e6091a68419d049
/code/24fbc88b-b066-449c-ae5b-a5acd378d8ab.c
6c6cfa7dc48bd7868bbeecf6b19c39cd6bf27ae4
[]
no_license
nmharmon8/Deep-Buffer-Overflow-Detection
70fe02c8dc75d12e91f5bc4468cf260e490af1a4
e0c86210c86afb07c8d4abcc957c7f1b252b4eb2
refs/heads/master
2021-09-11T19:09:59.944000
2018-04-06T16:26:34
2018-04-06T16:26:34
125,521,331
0
0
null
null
null
null
UTF-8
C
false
false
217
c
#include <stdio.h> int main() { int i=0; int j=14; int k; int l; k = 53; l = 64; k = i/j; l = i/j; l = l/j; l = k-j*i; printf("vulnerability"); printf("%d%d\n",l,l); return 0; }
[ "nharmon8@gmail.com" ]
nharmon8@gmail.com
ff3959dcfefc32276c08841c6534ca13f08bec63
d24750e5c892c961ebc316484e27de11774db135
/Src/VL53l1X.c
9130b1f3476a4024ec8ee467dd98e7873227adac
[]
no_license
MarcusCorbin1/Number12
3bc4f46a59bfd1f29a3ac61c214409eb43e2cdae
0069173892eb944d12c0b6c9ee8a8dd2b52c481b
refs/heads/master
2022-03-03T14:58:26.731000
2019-06-17T16:33:27
2019-06-17T16:33:27
192,381,912
0
0
null
null
null
null
UTF-8
C
false
false
950
c
#include "stm32l4xx_hal.h" #include "VL53l1X.h" //Start the Data Initializer void VL53L1_DataInit(I2C_HandleTypeDef i2cHandle) { uint8_t buffer[12]; buffer[0] = 0x88; buffer[1] = 0x00; HAL_I2C_Master_Transmit(&i2cHandle, 0x52, buffer, 2, 100); HAL_Delay(20); } //Start the Static Initializer void VL53L1_StaticInit(I2C_HandleTypeDef i2cHandle) { uint8_t buffer[12]; buffer[0] = 0xFF; buffer[1] = 0x01; HAL_I2C_Master_Transmit(&i2cHandle, 0x52, buffer, 2, 100); uint16_t tempword = 0; buffer[0] = 0xFF; buffer[1] = tempword; HAL_I2C_Master_Receive(&i2cHandle, 0x53, buffer, 2, 100); buffer[0] = 0xFF; buffer[1] = 0x00; HAL_I2C_Master_Transmit(&i2cHandle, 0x52, buffer, 2, 100); } // This function will get the measurement ready void VL53L1_StartMeasurement(I2C_HandleTypeDef i2cHandle) { uint8_t buffer[64]; buffer[0] = 0x000; buffer[1] = 0x01; HAL_I2C_Master_Transmit(&i2cHandle, 0x52, buffer, 2, 100); }
[ "marcus.corbin@itron.com" ]
marcus.corbin@itron.com
681714c9a7576083efca3998c82af18ed07b3562
99166976f3e170ad5d9fb2840b1c0ade2182a2c3
/libs/rh4n_ldaparser/src/rh4n_lda_array.c
18cc3aecdc99a46678399d32d905ecce91675310
[]
no_license
audacity363/natAWSWrapper
18acda09518788ae22c78b797e65ec3e3cd0531a
e99ed02d465ba9e6a3234ac30563b00d612d4d46
refs/heads/master
2020-06-15T08:49:09.333000
2019-08-25T17:35:27
2019-08-25T17:35:27
195,252,545
1
0
null
null
null
null
UTF-8
C
false
false
1,119
c
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include "rh4n.h" #include "rh4n_ldaparser.h" int rh4nldaGetArrayType(char *line, int *dimensions, int length[3], RH4nProperties *props, char *errorstr) { *dimensions= 0; char *end_var_params = NULL, *comma = NULL, *double_collon = NULL; if((end_var_params = strchr(line, ')')) == NULL) { sprintf(errorstr, "Can not find array parms end"); rh4n_log_error(props->logging, "%s", errorstr); return(RH4N_RET_LDA_PARSE_ERR); } *end_var_params = 0x00; comma = rh4nldastrtok(line, ','); while(comma) { (*dimensions)++; //Check if a lower bound is specified if((double_collon = strchr(comma, ':')) != NULL) { *double_collon = 0x00; double_collon++; length[(*dimensions)-1] = atoi(double_collon); } else { length[(*dimensions)-1] = atoi(comma); } comma = rh4nldastrtok(NULL, ','); } return(RH4N_RET_OK); }
[ "tom@engemann.me" ]
tom@engemann.me
51fbad2bfeb09528ca3cb36ba6098eb1c9816eff
25ba673dae94a65d02989d8b72aa4ebda00b0652
/์˜ˆ์ œ9-6.c
c28ba2aeede8768fa8a3d745203496296575bb28
[]
no_license
mykid7/C
3c72d2414ba4a9ae889d57702468ccbfea19796a
23d1de46d313521a53cb957014f492e3165cff17
refs/heads/master
2020-07-21T16:58:10.378000
2019-11-10T15:20:47
2019-11-10T15:20:47
206,925,648
0
0
null
null
null
null
UHC
C
false
false
380
c
#include <stdio.h> int main(void) { int a = 10; // ๋ณ€์ˆ˜ ์„ ์–ธ๊ณผ ์ดˆ๊ธฐํ™” int *p = &a; // ํฌ์ธํ„ฐ ์„ ์–ธ๊ณผ ๋™์‹œ์— a๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋„๋ก ์ดˆ๊ธฐํ™” double *pd; // doubleํ˜• ๋ณ€์ˆ˜๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ํฌ์ธํ„ฐ pd = p; // ํฌ์ธํ„ฐ p ๊ฐ’์„ ํฌ์ธํ„ฐ pd์— ๋Œ€์ž… printf("%lf\n", *pd); // pd๊ฐ€ ๊ฐ€๋ฆฌํ‚ค๋Š” ๋ณ€์ˆ˜์˜ ๊ฐ’ ์ถœ๋ ฅ return 0; }
[ "noreply@github.com" ]
noreply@github.com
README.md exists but content is empty.
Downloads last month
18