void do_adsllog_cgi(char *path, FILE *stream) { dump_file(stream, "/tmp/adsl/adsllog.log-1"); dump_file(stream, "/tmp/adsl/adsllog.log"); fputs("\r\n", stream); /* terminator */ fputs("\r\n", stream); /* terminator */ }
int main() { dump_file( CALLER_FILE, "/// this file was generated by a tiny program.\n" ); DUMP_CALLER( 1 ); DUMP_CALLER( 2 ); DUMP_CALLER( 3 ); DUMP_CALLER( 4 ); DUMP_CALLER( 5 ); DUMP_CALLER( 6 ); DUMP_CALLER( 7 ); DUMP_CALLER( 8 ); DUMP_CALLER( 9 ); DUMP_CALLER( 10 ); DUMP_CALLER( 11 ); DUMP_CALLER( 12 ); DUMP_CALLER( 13 ); DUMP_CALLER( 14 ); DUMP_CALLER( 15 ); dump_file( BINDER_FILE, "/// this file was generated by a tiny program.\n" ); DUMP_BINDER( 1 ); DUMP_BINDER( 2 ); DUMP_BINDER( 3 ); DUMP_BINDER( 4 ); DUMP_BINDER( 5 ); DUMP_BINDER( 6 ); DUMP_BINDER( 7 ); DUMP_BINDER( 8 ); DUMP_BINDER( 9 ); DUMP_BINDER( 10 ); DUMP_BINDER( 11 ); DUMP_BINDER( 12 ); DUMP_BINDER( 13 ); DUMP_BINDER( 14 ); DUMP_BINDER( 15 ); dump_file( BIND_CALLER_FILE, "/// this file was generated by a tiny program.\n" ); DUMP_BIND_CALLER( 1 ); DUMP_BIND_CALLER( 2 ); DUMP_BIND_CALLER( 3 ); DUMP_BIND_CALLER( 4 ); DUMP_BIND_CALLER( 5 ); DUMP_BIND_CALLER( 6 ); DUMP_BIND_CALLER( 7 ); DUMP_BIND_CALLER( 8 ); DUMP_BIND_CALLER( 9 ); DUMP_BIND_CALLER( 10 ); DUMP_BIND_CALLER( 11 ); DUMP_BIND_CALLER( 12 ); DUMP_BIND_CALLER( 13 ); DUMP_BIND_CALLER( 14 ); DUMP_BIND_CALLER( 15 ); return 0; }
int main(int argc, char *argv[]) { int fd; const char *simple_path = "/dev/simple"; off_t pos; size_t fsize; const char *wdata = "Something else to write"; size_t wlen = strlen(wdata) + 1; ssize_t cnt; int rc; fd = open(simple_path, O_RDWR); if (fd < 0) { printf("open(%s) failed: %s\n", simple_path, strerror(errno)); return -1; } pos = lseek(fd, 0, SEEK_END); if (pos < 0) { printf("lseek(0, SEEK_END) failed: %s\n", strerror(errno)); } fsize = pos; printf("File size of %s is %d\n", simple_path, fsize); printf("Initial file content:\n"); dump_file(fd, fsize); lseek(fd, 0, SEEK_SET); cnt = write(fd, wdata, wlen); if (cnt < 0) { printf("write(%d bytes) failed: %s\n", wlen, strerror(errno)); close(fd); return -1; } printf("After writing \"%s\" over the existing data:\n", wdata); dump_file(fd, fsize); printf("Press ENTER to exit\n"); fgetc(stdin); if (close(fd)) { printf("close(%d) failed: %s\n", fd, strerror(errno)); return -1; } return 0; }
static void dump_limits_any_type( FILE *fp, uint type, char *dir, uint lower, uint upper) { fs_path_t *mount; uint id; if ((mount = fs_table_lookup(dir, FS_MOUNT_POINT)) == NULL) { exitcode = 1; fprintf(stderr, "%s: cannot find mount point %s\n", progname, dir); return; } if (upper) { for (id = lower; id <= upper; id++) dump_file(fp, id, type, mount->fs_name); return; } switch (type) { case XFS_GROUP_QUOTA: { struct group *g; setgrent(); while ((g = getgrent()) != NULL) dump_file(fp, g->gr_gid, type, mount->fs_name); endgrent(); break; } case XFS_PROJ_QUOTA: { struct fs_project *p; setprent(); while ((p = getprent()) != NULL) dump_file(fp, p->pr_prid, type, mount->fs_name); endprent(); break; } case XFS_USER_QUOTA: { struct passwd *u; setpwent(); while ((u = getpwent()) != NULL) dump_file(fp, u->pw_uid, type, mount->fs_name); endpwent(); break; } } }
void dump_node(struct f2fs_sb_info *sbi, nid_t nid) { struct node_info ni; struct f2fs_node *node_blk; get_node_info(sbi, nid, &ni); node_blk = calloc(BLOCK_SZ, 1); dev_read_block(node_blk, ni.blk_addr); DBG(1, "Node ID [0x%x]\n", nid); DBG(1, "nat_entry.block_addr [0x%x]\n", ni.blk_addr); DBG(1, "nat_entry.version [0x%x]\n", ni.version); DBG(1, "nat_entry.ino [0x%x]\n", ni.ino); if (ni.blk_addr == 0x0) MSG(0, "Invalid nat entry\n\n"); DBG(1, "node_blk.footer.ino [0x%x]\n", le32_to_cpu(node_blk->footer.ino)); DBG(1, "node_blk.footer.nid [0x%x]\n", le32_to_cpu(node_blk->footer.nid)); if (le32_to_cpu(node_blk->footer.ino) == ni.ino && le32_to_cpu(node_blk->footer.nid) == ni.nid) { print_node_info(node_blk); dump_file(sbi, &ni, node_blk); } else { MSG(0, "Invalid node block\n\n"); } free(node_blk); }
int main(int argc, char **argv) { int in_fd, out_fd; char *in_fname, *out_fname; if (argc != 3) { printf("Usage: sr_collect <input file> <output file>\n"); return 0; } in_fname = argv[1]; in_fd = open(in_fname, O_RDONLY | O_NONBLOCK); if (!in_fd) { printf("Error opening input file: %s\n", in_fname); return 0; } out_fname = argv[2]; out_fd = open(out_fname, O_CREAT | O_RDWR | O_TRUNC); if (!out_fd) { printf("Error opening output file: %s\n", out_fname); close(in_fd); return 0; } dump_file(in_fd, out_fd); close(in_fd); close(out_fd); return 0; }
static void dump_label(struct label_header *lbl_hdr) { dump_file(&lbl_hdr->fil_hdr); printf("label:\n"); dump_label_data_offset(&lbl_hdr->label); printf("country:\n"); dump_label_data(&lbl_hdr->country); printf("region:\n"); dump_label_data(&lbl_hdr->region); printf("city:\n"); dump_label_data(&lbl_hdr->city); printf("poi_index:\n"); dump_label_data(&lbl_hdr->poi_index); printf("poi_properties:\n"); dump_label_data_offset(&lbl_hdr->poi_properties); printf("poi_types:\n"); dump_label_data(&lbl_hdr->poi_types); printf("zip:\n"); dump_label_data(&lbl_hdr->zip); printf("hway:\n"); dump_label_data(&lbl_hdr->hway); printf("exit:\n"); dump_label_data(&lbl_hdr->exit); printf("hway_data:\n"); dump_label_data(&lbl_hdr->hway_data); printf("lbl13:\n"); dump_label_data(&lbl_hdr->lbl13); printf("lbl14:\n"); dump_label_data(&lbl_hdr->lbl14); printf("len: 0x%x(%d)\n", sizeof(*lbl_hdr), sizeof(*lbl_hdr)); }
int main(int argc, char** argv) { char *input_filename = NULL; char *catalog_filename = NULL; char *output_filename = NULL; rs_module_t *modules = NULL; long modules_count = 2; long module_index = 0; #if HAVE_XLSXWRITER modules_count++; #endif modules = calloc(modules_count, sizeof(rs_module_t)); modules[module_index++] = rs_mod_readstat; modules[module_index++] = rs_mod_csv; #if HAVE_XLSXWRITER modules[module_index++] = rs_mod_xlsx; #endif if (argc == 2 && (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0)) { print_version(); return 0; } else if (argc == 2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)) { print_usage(argv[0]); return 0; } else if (argc == 2) { if (!can_read(argv[1])) { print_usage(argv[0]); return 1; } input_filename = argv[1]; } else if (argc == 3) { if (!can_read(argv[1]) || !can_write(modules, modules_count, argv[2])) { print_usage(argv[0]); return 1; } input_filename = argv[1]; output_filename = argv[2]; } else if (argc == 4) { if (!can_read(argv[1]) || !is_catalog(argv[2]) || !can_write(modules, modules_count, argv[3])) { print_usage(argv[0]); return 1; } input_filename = argv[1]; catalog_filename = argv[2]; output_filename = argv[3]; } else { print_usage(argv[0]); return 1; } if (output_filename) return convert_file(input_filename, catalog_filename, output_filename, modules, modules_count); return dump_file(input_filename); }
int DumpPacketCommand::Execute() { if (remaining().empty()) { cout << GetUsage() << GetHelp() << endl; return 2; } const string filename(remaining().front()); return dump_file(filename); }
int main(int argc,char * argv []) { if (mysql_library_init(argc, argv, NULL)) return 0; dump_file(); mysql_library_end(); return 0; }
void ut_FileReaderSimple::do_test(const char * full_path, string descr) { ut_out << "\n========================================================\n"; ut_out << "\n" << descr << "\n"; ut_out << "\n========================================================\n"; ut_out << "\n/////////////////INPUT FILE DUMP/////////////////////////////\n"; dump_file(full_path); ut_out << "\n/////////////////RUN/////////////////////////////\n"; this->readFile(full_path); ut_out << "\n/////////////////UPDATED FILE DUMP/////////////////////////////\n"; dump_file(full_path); return; }
/** * Print out file table for debug purposes. */ void dump_files() { fs_dprintf("FILE_TABLE:\n"); for (int i = 0; i < NUM_FILES; i++) { if(gft[i].f_desc >= 0) dump_file(&gft[i]); } }
static bool load_content_data(resource_content* content, int offset_block, void* data, int blocks) { if (!StorageReadLba(get_ptn_offset() + content->content_offset + offset_block, data, blocks)) { return false; } dump_file(content->path, data, blocks * BLOCK_SIZE); return true; }
bool Http_handler::parse_body(){ if(!body_len){ return false; } decoded_body_buffer=dezip(); dump_file(decoded_body_buffer,file_extention); decoded_body_buffer=decode(); //clear(); let tcp helper to clear. return true; }
int main(int argc, char *argv[]) { int i; for (i = 1; i < argc; ++i) dump_file(argv[i]); return error_count == 0 ? EXIT_SUCCESS : EXIT_FAILURE; }
int main( int argc, char *argv[] ) { init( argc, argv ); if ( opt_reverse ) reverse_dump_file(); else if ( opt_c_fmt != 0 ) dump_file_c(); else dump_file(); assert( false ); // none of the above functions returns }
static void run_tests() { encode_null(); encode_twice(); circular_references(); encode_other_than_array_or_object(); escape_slashes(); encode_nul_byte(); dump_file(); }
void config_sync (void) { GList *list; struct config_file *file; for (list = files; list; list = list->next) { file = (struct config_file *) list->data; dump_file (file); } /* config_drop_all (); */ }
int editor_save_file (char *filename) { int i, l, l1; char *p, *p1, *backup = NULL; unsigned long rc; // count memory needed l = 0; for (i=0; i<nl; i++) l += strlen(lines[i]) + 1; // allocate buffer p = malloc (l+1); if (p == NULL) goto failure; // copy everything into the buffer p1 = p; for (i=0; i<nl; i++) { l1 = strlen (lines[i]); memcpy (p1, lines[i], l1); p1 += l1; *p1 = '\n'; p1++; } *p1 = '\0'; // rename original file backup = malloc (strlen (filename)+6); snprintf1 (backup, strlen (filename)+6, "%s.bak", filename); rc = rename (filename, backup); if (rc < 0) goto failure; // dump buffer into the file and free buffer rc = dump_file (filename, p, l); // check for save error if (rc != l) { remove (filename); rename (backup, filename); goto failure; } remove (backup); free (backup); free (p); return 0; failure: if (backup != NULL) free (backup); if (p != NULL) free (p); fly_ask_ok (ASK_WARN, " Save failed! "); return -1; }
void create_archive() { register char *p; char *name_from_list(); open_archive(0); /* Open for writing */ if(f_gnudump) { char buf[MAXNAMLEN],*q,*bufp; collect_and_sort_names(); while(p=name_from_list()) dump_file(p,-1); /* if(!f_dironly) { */ blank_name_list(); while(p=name_from_list()) { strcpy(buf,p); if(p[strlen(p)-1]!='/') strcat(buf,"/"); bufp=buf+strlen(buf); for(q=gnu_list_name->dir_contents;*q;q+=strlen(q)+1) { if(*q=='Y') { strcpy(bufp,q+1); dump_file(buf,-1); } } } /* } */ } else { while (p = name_next(1)) { dump_file(p, -1); } } write_eot(); close_archive(); name_close(); }
static void rdump_inode(ext2_ino_t ino, struct ext2_inode *inode, const char *name, const char *dumproot) { char *fullname; /* There are more efficient ways to do this, but this method * requires only minimal debugging. */ fullname = malloc(strlen(dumproot) + strlen(name) + 2); if (!fullname) { com_err("rdump", errno, "while allocating memory"); return; } sprintf(fullname, "%s/%s", dumproot, name); if (LINUX_S_ISLNK(inode->i_mode)) rdump_symlink(ino, inode, fullname); else if (LINUX_S_ISREG(inode->i_mode)) { int fd; fd = open(fullname, O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE, S_IRWXU); if (fd == -1) { com_err("rdump", errno, "while opening %s", fullname); goto errout; } dump_file("rdump", ino, fd, 1, fullname); if (close(fd) != 0) { com_err("rdump", errno, "while closing %s", fullname); goto errout; } } else if (LINUX_S_ISDIR(inode->i_mode) && strcmp(name, ".") && strcmp(name, "..")) { errcode_t retval; /* Create the directory with 0700 permissions, because we * expect to have to create entries it. Then fix its perms * once we've done the traversal. */ if (name[0] && mkdir(fullname, S_IRWXU) == -1) { com_err("rdump", errno, "while making directory %s", fullname); goto errout; } retval = ext2fs_dir_iterate(current_fs, ino, 0, 0, rdump_dirent, (void *) fullname); if (retval) com_err("rdump", retval, "while dumping %s", fullname); fix_perms("rdump", inode, -1, fullname); } /* else do nothing (don't dump device files, sockets, fifos, etc.) */ errout: free(fullname); }
int main( int argc, char **argv ) { int i; for (i=1 ; i<argc ; i++) { if ( dump_file( argv[i] ) ) return -1; } return 0; }
static void dump_tree_header(struct tree_header *tre_hdr) { printf("tree_header:\n"); dump_file(&tre_hdr->fil_hdr); printf("level: "); dump_offset_len(&tre_hdr->level); printf("subdivision: "); dump_offset_len(&tre_hdr->subdivision); printf("copyright: "); dump_label_data(&tre_hdr->copyright); printf("polyline: "); dump_label_data(&tre_hdr->polyline); printf("polygon: "); dump_label_data(&tre_hdr->polygon); printf("point: "); dump_label_data(&tre_hdr->point); printf("len: 0x%x(%d)\n", sizeof(*tre_hdr), sizeof(*tre_hdr)); }
void do_dump(int argc, char **argv) { ext2_ino_t inode; int fd; int c; int preserve = 0; char *in_fn, *out_fn; reset_getopt(); while ((c = getopt (argc, argv, "p")) != EOF) { switch (c) { case 'p': preserve++; break; default: print_usage: com_err(argv[0], 0, "Usage: dump_inode [-p] " "<file> <output_file>"); return; } } if (optind != argc-2) goto print_usage; if (check_fs_open(argv[0])) return; in_fn = argv[optind]; out_fn = argv[optind+1]; inode = string_to_inode(in_fn); if (!inode) return; fd = open(out_fn, O_CREAT | O_WRONLY | O_TRUNC | O_LARGEFILE, 0666); if (fd < 0) { com_err(argv[0], errno, "while opening %s for dump_inode", out_fn); return; } dump_file(argv[0], inode, fd, preserve, out_fn); if (close(fd) != 0) { com_err(argv[0], errno, "while closing %s for dump_inode", out_fn); return; } return; }
int bt4b_encode(char *infile, char *outfile, int qfl) { byte *cbuf, *ibuf; char *ext; int xs, ys, sz, clrs; ext=bt4b_getext(infile); if(!strcmp(ext, ".tga") || !strcmp(ext, ".TGA")) { ibuf=BTIC1H_Img_LoadTGA(infile, &xs, &ys); clrs=BTIC4B_CLRS_RGBA; if(BTIC4B_Img_CheckRGBeP(ibuf, xs, ys)) clrs=BTIC4B_CLRS_RGB8E8; }else if(!strcmp(ext, ".hdr") || !strcmp(ext, ".HDR")) { ibuf=BTIC4B_Img_LoadHDR_R11F(infile, &xs, &ys); clrs=BTIC4B_CLRS_RGB11F; }else { ibuf=NULL; } // ibuf=BTIC1H_Img_LoadTGA(infile, &xs, &ys); if(!ibuf) { printf("Failed Load TGA %s\n", infile); return(-1); } cbuf=malloc(1<<24); sz=BTIC4B_EncodeImgBmpBuffer(cbuf, 1<<24, ibuf, xs, ys, qfl, clrs); if(sz<0) { printf("Encode Failed %d\n", sz); free(cbuf); free(ibuf); return(sz); } dump_file(outfile, cbuf, sz); free(cbuf); free(ibuf); return(sz); }
void create_archive() { register char *p; open_archive(0); /* Open for writing */ while (p = name_next()) { dump_file(p, -1); } write_eot(); close_archive(); name_close(); }
int main(int argc, char **argv) { eightchan_parser p; auto html = dump_file(argv[1]); auto t = p.parse_threads("test", html); for (const auto &tt: t) { for (const auto &ttt : tt) { ttt.print(); } std::cout << "########################################" << std::endl; } std::cout << p.final_page(html) << std::endl; }
int main(int argc, char *argv[]) { char *arg = NULL; if (argc == 1) dump_file(stdin); else { char *first = *++argv; if (strcmp(first, "--help") == 0) { usage(); return 0; } if (strcmp(first, "-n") == 0) { if (--argc > 1) { char *num = *++argv; if (!isdigit(*num)) printf("-n option needs a numeric argument\n"); else { int b = atoi(num); if (b < 1) b = 1; if (b > 16) b = 16; BytesBetweenSpace = b; if (--argc > 1) arg = *++argv; else printf("no file specified\n"); } } else printf("-n option needs a numeric argument\n"); } else arg = first; if (arg) do_hd(arg); } putchar('\n'); return 0; }
int main( int argc, char **argv ) { int escape = ESC_FULL; int file_format = FMT_NVRAM; // Check our arguments for options, and for at least one filename after // the options. int opt; while ( ( opt = getopt( argc, argv, "hd" ) ) != -1 ) { switch ( (char) opt ) { case 'h': escape = ESC_HUMAN; break; case 'd': file_format = FMT_DEFAULTS; break; default: fprintf( stderr, "Usage: %s [-h] [-d] <filename>...\n", argv[0] ); return 1; } } if ( optind >= argc ) { fprintf( stderr, "Expected at least one file\n" ); fprintf( stderr, "Usage: %s [-h] [-d] <filename>...\n", argv[0] ); return 1; } // Dump out each filename given. If any file fails, we fail. int sts, i; int ret = 0; for ( i = optind; i < argc; i++ ) { if ( argv[i] ) { sts = dump_file( escape, file_format, argv[i] ); // Remember our first failure, but keep on going with the rest of the // files so we catch all errors in one pass. if ( sts && !ret ) ret = sts; } } return ret; }
static bool load_content(resource_content* content) { if (content->load_addr) return true; int blocks = fix_blocks(content->content_size); content->load_addr = malloc(blocks * BLOCK_SIZE); if (!content->load_addr) return false; if (!StorageReadLba(get_ptn_offset() + content->content_offset, content->load_addr, blocks)) { free_content(content); return false; } dump_file(content->path, content->load_addr, content->content_size); return true; }