int inputInit() { int i=0; printf("INFO: reading input config\n"); inputReadConfig(); #ifndef RETRO if((SDL_InitSubSystem( SDL_INIT_JOYSTICK )) < 0 ) { printf("ERROR: can't init joystick subsystem\n"); return 0; } printf("INFO: input found %d joysticks\n",inputEnum()); if(inputEnum()==0){ usekb=1; } for(i=0;i<inputEnum();i++) { joystick[i]=inputOpen(i); } return SDL_InitSubSystem(SDL_INIT_JOYSTICK); #endif }
int streamFilePrimitive(char *filename, int sanitize UNUSED, struct osmdata_t *osmdata) { struct Input *i; char buffer[65536]; int bufsz = 0; int offset = 0; char *nl; i = inputOpen(filename); if (i != NULL) { while(1) { bufsz = bufsz + readFile(i, buffer + bufsz, sizeof(buffer) - bufsz - 1); buffer[bufsz] = 0; nl = strchr(buffer, '\n'); if (nl == 0) break; *nl=0; while (nl && nl < buffer + bufsz) { *nl = 0; process(buffer + offset, osmdata); offset = nl - buffer + 1; nl = strchr(buffer + offset, '\n'); } memcpy(buffer, buffer + offset, bufsz - offset); bufsz = bufsz - offset; offset = 0; } } else { fprintf(stderr, "Unable to open %s\n", filename); return 1; } inputClose(i); return 0; }
int streamFilePrimitive(char *filename, int sanitize UNUSED, struct osmdata_t *osmdata) { struct Input *i; char buffer[65536]; int bufsz = 0; int offset = 0; i = inputOpen(filename); if (i != NULL) { while(1) { bufsz = bufsz + readFile(i, buffer + bufsz, sizeof(buffer) - bufsz); char *nl = index(buffer, '\n'); if (nl == 0) break; *nl=0; while (nl && nl < buffer + bufsz) { *nl = 0; process(buffer + offset, osmdata); offset = nl - buffer + 1; //printf("\nsearch line at %d, buffer sz is %d = ",offset, bufsz); nl = index(buffer + offset, '\n'); //printf("%d\n", nl ? nl-buffer : -1); } memcpy(buffer, buffer + offset, bufsz - offset); bufsz = bufsz - offset; offset = 0; } } else { fprintf(stderr, "Unable to open %s\n", filename); return 1; } return 0; }
xmlTextReaderPtr inputUTF8(const char *name) { void *ctx = inputOpen(name); if (!ctx) { fprintf(stderr, "Input reader create failed for: %s\n", name); return NULL; } return xmlReaderForIO(readFileXML, inputCloseXML, (void *)ctx, NULL, NULL, 0); }
//------------------------------------------------------------------------------------------ ASIOBool AsioSample::init (void* sysRef) { sysRef = sysRef; if (active) return true; strcpy (errorMessage, "ASIO Driver open Failure!"); if (inputOpen ()) { if (outputOpen ()) { active = true; return true; } } timerOff (); // de-activate 'hardware' outputClose (); inputClose (); return false; }
xmlTextReaderPtr sanitizerOpen(const char *name) { struct Context *ctx = (struct Context *)malloc(sizeof(*ctx)); if (!ctx) return NULL; memset(ctx, 0, sizeof(*ctx)); ctx->verbose = 0; ctx->state = 1; ctx->pend = 0; ctx->file = inputOpen(name); if (!ctx->file) { fprintf(stderr, "Input reader create failed\n"); free(ctx); return NULL; } return xmlReaderForIO(sanitizerProcess, sanitizerClose, (void *)ctx, NULL, NULL, 0); }