type
stringclasses
5 values
content
stringlengths
9
163k
functions
int dirTraversal(const char *path, int recursive,file_callback xCallback,void * usr) { int len; char tmp[256]; len = strlen(path); strcpy(tmp, path); if(tmp[len - 1] == '/') tmp[len -1] = '\0'; if(isDir(tmp)) { doTraversal(tmp, recursive,xCallback,usr); }
functions
int dirTraversal(const char *path, int recursive,file_callback xCallback,void * usr) { int len = strlen(path)+3; long handle; char mypath[1024]; char searchpath[1024]; char tmppath[1024]; char nxtpath[1024]; char sp = '/'; int i; struct _finddata_t fileinfo; sprintf(mypath,"%s",path); switch(mypa...
defines
#define MAX_WALL_COUNT 20
defines
#define FRAME_MEM ((volatile uint16*)MEM_VRAM)
functions
fixed DotProduct(Vec2 a, Vec2 b){ return fixMult(a.x, b.x) + fixMult(a.y, b.y); }
functions
Vec2 VecSub(Vec2 a, Vec2 b){ Vec2 retVal = {a.x - b.x, a.y - b.y}
functions
Vec2 VecAdd(Vec2 a, Vec2 b){ Vec2 retVal = {a.x + b.x, a.y + b.y}
functions
Vec2 VecScale(Vec2 v, fixed s){ Vec2 retVal = {fixMult(v.x, s), fixMult(v.y, s)}
functions
Vec2 AngleToVec(fixed angle){ Vec2 forward = {mySin(angle), myCos(angle)}
functions
void AddWall(Wall wall){ walls[wallCount] = wall; wallCount++; }
functions
fixed mySqrt(fixed in){ int reduce = (in >= makeFixed(4)); if(reduce){ in /= 4; }
functions
uint16 for(int i = 0; i < wallCount; i++){ Vec2 playerToWallStart = VecSub(walls[i].start, playerPos); Vec2 playerToWallEnd = VecSub(walls[i].end, playerPos); fixed forwardDotToStart = DotProduct(playerToWallStart, playerForward); fixed forwardDotToEnd = DotProduct(playerToWallEnd, playerF...
main
int main(void) { INT_VECTOR = InterruptMain; BNS_REG_IME = 0; REG_DISPSTAT |= LCDC_VBL; BNS_REG_IE |= IRQ_VBLANK; BNS_REG_IME = 1; REG_DISPLAY = 0x0403; for(int i = 0; i < SCREEN_WIDTH*SCREEN_HEIGHT; i++){ FRAME_MEM[i] = 0; }
functions
void sdramInit(uint32_t coreClockFrequency) { uint32_t n; //Enable PIO peripheral clocks PMC->PMC_PCER0 = (1 << ID_PIOC) | (1 << ID_PIOD); //Enable SMC peripheral clock PMC->PMC_PCER0 = (1 << ID_SMC); //Assign SDRAM pins to Peripheral A function PIOC->PIO_ABSR &= ~SDRAM_PIOC_MASK; //Disable th...
functions
error_t sdramTest(void) { uint_t i; //Point to the beginning of the memory space uint32_t *address = (uint32_t *) SDRAM_BASE; //Initialize test pattern generation uint32_t value = 0x12345678; //Write SDRAM memory contents for(i = 0; i < (SDRAM_SIZE / 4); i++) { //Write current location ...
structs
struct au_header { uint32_t magic; uint32_t data_offset; uint32_t data_size; uint32_t encoding; uint32_t sample_rate; uint32_t channels; };
functions
int au_isfile(const uint8_t *data, size_t input_len, size_t *lengthptr) { if (input_len < AU_HEADER_SIZE || MAGIC(data) != AU_MAGIC) return 0; const struct au_header *header = (const struct au_header *)data; size_t data_offset = be32toh(header->data_offset); size_t data_size = be32toh(header->data_size); ...
includes
#include <stdlib.h>
includes
#include <signal.h>
includes
#include <unistd.h>
includes
#include <gtk/gtk.h>
includes
#include <time.h>
includes
#include <stdio.h>
includes
#include <sys/types.h>
includes
#include <sys/ipc.h>
includes
#include <sys/msg.h>
includes
#include <string.h>
includes
#include <plugin.h>
includes
#include <amixer-plugin.h>
defines
#define _GNU_SOURCE
functions
void clean_exit (int sig) { exit (EXIT_SUCCESS); }
functions
void vol_increase (KTPreferences *preferences) { is_muted = FALSE; change_volume ( CHANGE_VOL_CMD(VOL_DEFAULT_INCR) ); }
functions
void vol_decrease (KTPreferences *preferences) { is_muted &= !get_current_volume(); change_volume ( CHANGE_VOL_CMD(VOL_DEFAULT_DECR) ); }
functions
void vol_increase_10 (KTPreferences *preferences) { is_muted = FALSE; change_volume ( CHANGE_VOL_CMD(VOL_10PERCENT_INCR) ); }
functions
void vol_decrease_10 (KTPreferences *preferences) { is_muted &= !get_current_volume(); change_volume ( CHANGE_VOL_CMD(VOL_10PERCENT_DECR) ); }
functions
void mute (KTPreferences *preferences) { static int prev_volume = -1; int current_volume; char *command = NULL; current_volume = get_current_volume(); is_muted &= !current_volume; if (is_muted) { /* Tell amixer to set the volume to prev_volume */ if (asprintf(&command, "amixer sset Master %d%% > /dev/nul...
functions
else if (current_volume) { /* Tell amixer to set the volume to 0 */ command = strdup("amixer sset Master 0% > /dev/null"); if (command == NULL) { perror ("keytouch amixer plugin"); }
includes
#include <math.h>
functions
int num_plus(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { strm_value x, y; strm_get_args(strm, argc, args, "NN", &x, &y); if (strm_int_p(x) && strm_int_p(y)) { *ret = strm_int_value(strm_value_int(x)+strm_value_int(y)); return STRM_OK; }
functions
int num_minus(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { if (argc == 1) { if (strm_int_p(args[0])) { *ret = strm_int_value(-strm_value_int(args[0])); return STRM_OK; }
functions
int num_mult(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { strm_value x, y; strm_get_args(strm, argc, args, "NN", &x, &y); if (strm_int_p(x) && strm_int_p(y)) { *ret = strm_int_value(strm_value_int(x)*strm_value_int(y)); return STRM_OK; }
functions
int num_div(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { double x, y; strm_get_args(strm, argc, args, "ff", &x, &y); *ret = strm_float_value(x/y); return STRM_OK; }
functions
int num_bar(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { strm_value x, y; strm_get_args(strm, argc, args, "ii", &x, &y); *ret = strm_int_value(strm_value_int(x)|strm_value_int(y)); return STRM_OK; }
functions
int num_mod(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { strm_value x; strm_int y; strm_get_args(strm, argc, args, "Ni", &x, &y); if (strm_int_p(x)) { *ret = strm_int_value(strm_value_int(x)%y); return STRM_OK; }
functions
int num_gt(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { double x, y; strm_get_args(strm, argc, args, "ff", &x, &y); *ret = strm_bool_value(x>y); return STRM_OK; }
functions
int num_ge(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { double x, y; strm_get_args(strm, argc, args, "ff", &x, &y); *ret = strm_bool_value(x>=y); return STRM_OK; }
functions
int num_lt(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { double x, y; strm_get_args(strm, argc, args, "ff", &x, &y); *ret = strm_bool_value(x<y); return STRM_OK; }
functions
int num_le(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { double x, y; strm_get_args(strm, argc, args, "ff", &x, &y); *ret = strm_bool_value(x<=y); return STRM_OK; }
functions
int num_number(strm_stream* strm, int argc, strm_value* args, strm_value* ret) { strm_get_args(strm, argc, args, "N", ret); return STRM_OK; }
functions
void strm_number_init(strm_state* state) { strm_ns_number = strm_ns_new(NULL, "number"); strm_var_def(strm_ns_number, "+", strm_cfunc_value(num_plus)); strm_var_def(strm_ns_number, "-", strm_cfunc_value(num_minus)); strm_var_def(strm_ns_number, "*", strm_cfunc_value(num_mult)); strm_var_def(strm_ns_number, "/...
includes
#include <wchar.h>
includes
#include <unistd.h>
includes
#include <winsock2.h>
includes
#include <windows.h>
includes
#include <direct.h>
includes
#include <sys/types.h>
includes
#include <sys/socket.h>
includes
#include <netinet/in.h>
includes
#include <arpa/inet.h>
includes
#include <process.h>
defines
#define COMMAND_INT_PATH L"%WINDIR%\\system32\\cmd.exe"
defines
#define COMMAND_INT L"cmd.exe"
defines
#define COMMAND_ARG1 L"/c"
defines
#define COMMAND_ARG2 L"dir"
defines
#define COMMAND_ARG3 data
defines
#define COMMAND_INT_PATH L"/bin/sh"
defines
#define COMMAND_INT L"sh"
defines
#define COMMAND_ARG1 L"ls"
defines
#define COMMAND_ARG2 L"-la"
defines
#define COMMAND_ARG3 data
defines
#define CLOSE_SOCKET closesocket
defines
#define INVALID_SOCKET -1
defines
#define SOCKET_ERROR -1
defines
#define CLOSE_SOCKET close
defines
#define SOCKET int
defines
#define TCP_PORT 27015
defines
#define IP_ADDRESS "127.0.0.1"
functions
void CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_18_bad() { wchar_t * data; wchar_t dataBuffer[100] = L""; data = dataBuffer; goto source; source: { #ifdef _WIN32 WSADATA wsaData; int wsaDataInit = 0; #endif int recvResult; struct sockadd...
functions
_WIN32 if (wsaDataInit) { WSACleanup(); }
functions
void goodG2B() { wchar_t * data; wchar_t dataBuffer[100] = L""; data = dataBuffer; goto source; source: /* FIX: Append a fixed string to data (not user / external input) */ wcscat(data, L"*.*"); /* wspawnl - specify the path where the command is located */ /* POTENTIAL FLAW: Ex...
functions
void CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_18_good() { goodG2B(); }
main
int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE78_OS_Command_Injection__wchar_t_connect_socket_w32spawnl_18_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLin...
includes
#include <stdio.h>
includes
#include <string.h>
defines
#define SEPARATOR "\n"
functions
void extract_text(TET *tet, int doc, FILE *outfp) { int n_pages; volatile int pageno = 0; /* get number of pages in the document */ n_pages = (int) TET_pcos_get_number(tet, doc, "length:pages"); /* loop over all pages */ for (pageno = 1; pageno <= n_pages; ++pageno) { const char *text; i...
functions
int process_document(FILE *outfp, const char *filename, const char *realname, const unsigned char *data, int length) { TET *tet; if ((tet = TET_new()) == (TET *) 0) { fprintf(stderr, "extractor: out of memory\n"); return(4); }
main
int main(int argc, char **argv) { FILE *outfp; int ret = 0; if (argc != 3) { fprintf(stderr, "usage: %s <infilename> <outfilename>\n", argv[0]); return(2); }
functions
void reset_speaker_enable_pin(void) { #ifdef SPEAKER_ENABLE_PIN speaker_enable_in_use = false; nrf_gpio_cfg(SPEAKER_ENABLE_PIN->number, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_H0H1, ...
functions
void reset_all_pins(void) { for (size_t i = 0; i < GPIO_COUNT; i++) { claimed_pins[i] = never_reset_pins[i]; }
functions
void reset_pin_number(uint8_t pin_number) { if (pin_number == NO_PIN) { return; }
functions
MICROPY_HW_NEOPIXEL if (pin_number == MICROPY_HW_NEOPIXEL->number) { neopixel_in_use = false; rgb_led_status_init(); return; }
functions
MICROPY_HW_APA102_MOSI if (pin_number == MICROPY_HW_APA102_MOSI->number || pin_number == MICROPY_HW_APA102_SCK->number) { apa102_mosi_in_use = apa102_mosi_in_use && pin_number != MICROPY_HW_APA102_MOSI->number; apa102_sck_in_use = apa102_sck_in_use && pin_number != MICROPY_HW_APA102_SCK->num...
functions
SPEAKER_ENABLE_PIN if (pin_number == SPEAKER_ENABLE_PIN->number) { reset_speaker_enable_pin(); }
functions
void never_reset_pin_number(uint8_t pin_number) { never_reset_pins[nrf_pin_port(pin_number)] |= 1 << nrf_relative_pin_number(pin_number); }
functions
void common_hal_never_reset_pin(const mcu_pin_obj_t* pin) { never_reset_pin_number(pin->number); }
functions
void common_hal_reset_pin(const mcu_pin_obj_t* pin) { reset_pin_number(pin->number); }
functions
void claim_pin(const mcu_pin_obj_t* pin) { // Set bit in claimed_pins bitmask. claimed_pins[nrf_pin_port(pin->number)] |= 1 << nrf_relative_pin_number(pin->number); #ifdef MICROPY_HW_NEOPIXEL if (pin == MICROPY_HW_NEOPIXEL) { neopixel_in_use = true; }
functions
MICROPY_HW_APA102_MOSI if (pin == MICROPY_HW_APA102_MOSI) { apa102_mosi_in_use = true; }
functions
SPEAKER_ENABLE_PIN if (pin == SPEAKER_ENABLE_PIN) { speaker_enable_in_use = true; }