static FT_Error ft_lzw_file_fill_output( FT_LZWFile zip ) { s_zstate_t* zstream = &zip->zstream; FT_Error error = 0; zip->cursor = zip->buffer; zstream->next_out = zip->cursor; zstream->avail_out = FT_LZW_BUFFER_SIZE; while ( zstream->avail_out > 0 ) { int num_read = 0; if ( zstream->avail_in == 0 ) { error = ft_lzw_file_fill_input( zip ); if ( error ) break; } num_read = zread( zstream ); if ( num_read == -1 && zstream->zs_in_count == 0 ) { zip->limit = zstream->next_out; if ( zip->limit == zip->cursor ) error = LZW_Err_Invalid_Stream_Operation; break; } else if ( num_read == -1 ) break; else zstream->avail_out -= num_read; } return error; }
int main(void) { char answer[256]; long t; verylong zn = 0; do { do { printf("enter the security parameter ( >= 1): "); scanf("%d", &t); } while (t < 1); printf("enter the number to be tested below:\n"); zread(&zn); if (Miller_Rabin(t, zn)) printf("number is probably prime\n"); else printf("number is composite\n"); printf("another number (n or y)? "); scanf("%s", answer); } while (tolower(answer[0]) == 'y'); zfree(&zn); return 0; }
int file_read(void *buf, size_t length) { if (rom_fd != -1) return zread(rom_fd, buf, length); return -1; }
static void ezread (lua_State* L, ZIO* Z, void* b, int n) { int r=zread(Z,b,n); if (r!=0) unexpectedEOZ(L,Z); }
int main(int ac, char **av) { for(av++ ; *av ; av++) zread(*av, 0); return 0; }
int neogeo_check_game(void) { FILE *fp; char fname[16], path[MAX_PATH], linebuf[128]; int i, fd, found = 0, NGH_number; neogeo_ngh = 0; hack_irq = 0; if (neogeo_boot_bios) { strcpy(game_name, games[99].name); game_index = 99; } else { strcpy(game_name, default_name); game_index = 0; sprintf(path, "%sIPL.TMP", launchDir); zip_open(game_dir); i = zlength("IPL.TXT"); if ((fd = zopen("IPL.TXT")) == -1) { zip_close(); return 0; } zread(fd, memory_region_cpu1, i); zclose(fd); zip_close(); if ((fp = fopen(path, "w")) == NULL) { return 0; } fwrite(memory_region_cpu1, 1, i, fp); fclose(fp); if ((fp = fopen(path, "r")) == NULL) { sceIoRemove(path); return 0; } while (fgets(linebuf, 127, fp)) { char *strfname = strtok(linebuf, ",\r\n"); char *strbank = strtok(NULL, ",\r\n"); char *stroffs = strtok(NULL, ",\r\n"); char *ext; int bank, offs; if (strfname == NULL || strbank == NULL || stroffs == NULL) break; sscanf(strbank, "%d", &bank); sscanf(stroffs, "%x", &offs); ext = strrchr(strfname, '.'); if (stricmp(ext, ".PRG") == 0 || stricmp(ext, ".ARG") == 0) { if (!bank && !offs) { strcpy(fname, strfname); found = 1; break; } } } fclose(fp); sceIoRemove(path); if (!found) return 0; zip_open(game_dir); if ((fd = zopen(fname)) == -1) { zip_close(); return 0; } zread(fd, memory_region_cpu1, 0x110); zclose(fd); zip_close(); swab(memory_region_cpu1, memory_region_cpu1, 0x110); memcpy(neogeo_game_vectors, memory_region_cpu1, 0x100); NGH_number = m68000_read_memory_16(0x108); for (i = 0; games[i].ngh_number; i++) { if (games[i].ngh_number == NGH_number) { game_index = i + 1; neogeo_ngh = NGH_number; strcpy(game_name, games[i].name); if (NGH_NUMBER(0x0243)) // lastbld2 hack_irq = 1; break; } } } neogeo_reset_driver_type(); return 1; }