/* Note: when launched from command line we do not reach this method * since we manually handle the command line parameters in order to * parse +LINE:COL, stdin, etc. * However this method is called when open() is called via dbus, for * instance when double clicking on a file in nautilus */ static void gedit_app_open (GApplication *application, GFile **files, gint n_files, const gchar *hint) { gint i; GSList *file_list = NULL; for (i = 0; i < n_files; i++) { file_list = g_slist_prepend (file_list, files[i]); } file_list = g_slist_reverse (file_list); open_files (application, FALSE, FALSE, NULL, 0, 0, NULL, NULL, file_list, NULL); g_slist_free (file_list); }
main_window(const std::vector<std::string>& file_paths = {}){ setCentralWidget(tabs); tabs->setTabsClosable(true); open_files(file_paths); set_menu_bar(); }
/* Given a filenme, surround the original contents with <html> and </html>. */ static int hack_root_tags(const char *path_in) { FILE *fin, *fout; if (open_files(&fin, &fout, path_in, "tmp")) return 1; fputs("<html>", fout); char buf[201]; while (fgets(buf, 200, fin)) fputs(buf, fout); fclose(fin); fputs("</html>", fout); fclose(fout); puts("Done..."); if (rename("tmp", path_in)) { printf("Could not move <%s> to <%s>\n%s\n", path_in, "tmp", strerror(errno)); return 1; } return 0; }
int main(int argc, char **argv) { int fd_rd = -1, fd_wr = -1; test_init(argc, argv); snprintf(filename_rd, sizeof(filename_rd), "%s.0", filename); snprintf(filename_wr, sizeof(filename_wr), "%s.1", filename); if (open_files(&fd_rd, &fd_wr)) { pr_err("Can't open files\n"); return -1; } if (fcntl(fd_rd, F_SETLEASE, F_RDLCK) < 0 || fcntl(fd_wr, F_SETLEASE, F_WRLCK) < 0) { pr_perror("Can't set leases\n"); close_files(fd_rd, fd_wr); return -1; } test_daemon(); test_waitsig(); if (check_lease_type(fd_rd, F_RDLCK)) fail("Read lease check failed\n"); else if (check_lease_type(fd_wr, F_WRLCK)) fail("Write lease check failed\n"); else pass(); close_files(fd_rd, fd_wr); return 0; }
int main( int argc, char * const *argv ) /**************************************/ { int found_file; WSize = 0; Write_buff[WSize] = '\0'; if( parse_options( argc, argv ) ) { return( 1 ); } if( !(Options_dmp & QUIET) ) { wbanner(); } if( Name == NULL || *Name == '\0' ) { usage(); return( 1 ); } found_file = find_file( Name ); if( found_file ) { return( open_files() ); } Wdputs( "Could not open '" ); Wdputs( Name ); Wdputs( "': " ); Wdputslc( strerror( errno ) ); Wdputslc( "\n" ); return( 1 ); }
static void do_init_stuff( char **cmdline ) /*****************************************/ { char *env; char buff[80]; if( !MsgInit() ) exit(1); AsmInit( -1, -1, -1, -1 ); // initialize hash table strcpy( buff, "__WASM__=" BANSTR( _BANVER ) ); add_constant( buff ); ForceInclude = getenv( "FORCE" ); do_envvar_cmdline( "WASM" ); parse_cmdline( cmdline ); set_build_target(); get_os_include(); env = getenv( "INCLUDE" ); if( env != NULL ) AddStringToIncludePath( env ); if( !Options.quiet && !Options.banner_printed ) { Options.banner_printed = TRUE; trademark(); } open_files(); PushLineQueue(); AsmLookup( "$" ); // create "$" symbol for current segment counter }
char* vilistextum(char* text, int extractText) { if(text == NULL) return NULL; length = strlen(text); error = 0; set_options(); if(init_multibyte()) { open_files(text); html(extractText); quit(); } if(!error) { CHAR* output = getOutput(); size_t buffersize = 2*sizeof(char)*length; buffer = malloc(buffersize); int ret = wcstombs ( buffer, output, buffersize ); if (ret==buffersize) buffer[buffersize-1]='\0'; if (ret) return buffer; else return NULL; } else return NULL; }
bool runReachability(double* start, double simTime, double wallTimeMs, double startMs) { LiftingSettings set; for (int d = 0; d < NUM_DIMS; ++d) { set.init.dims[d].min = start[d]; set.init.dims[d].max = start[d]; } set.reachTime = simTime; set.maxRuntimeMilliseconds = wallTimeMs; set.initialStepSize = set.reachTime / 10; set.maxRectWidthBeforeError = 100; set.reachedAtFinalTime = finalState; set.reachedAtIntermediateTime = intermediateState; set.restartedComputation = restartedComputation; open_files(true); hyperrectangle_to_file(f_initial, &set.init, 0); bool safe = face_lifting_iterative_improvement(startMs, &set); close_files(true); return safe; }
main(int argc,char *argv[]) { if (argc<2) { puts("\nPouziti: MGFSOUND film.mgf zvuk.wav [i]"); puts("\nnebo: MGFSOUND script.scr"); puts("\nKde _i_ je komprimacni krivka (viz SNDPACK) (default:4)"); exit(0); } if (argc>3) { sscanf(argv[3],"%d",&difftype); } Create_table_16(); if (argc==2) call_script(argv[1]); else { open_wav(argv[2]); open_files(argv[1]); ozvuceni(); } close_files(); }
int spell_check(struct sc_config const *config) { int i = 0; int ret = -1; char ch; char buf[MAX_WORD_LENGTH]; FILE *files[FILE_COUNT]; if (open_files(config, files)) goto ERROR; while ((ch = getc(files[FILE_DOC])) != EOF) { if (isspace(ch)) { buf[i] = '\0'; if (i != 0) { if (handle_word(buf, files, config)) goto ERROR; i = 0; } fprintf(files[FILE_OUT], "%c", ch); } else { buf[i++] = ch; } } ret = 0; ERROR: close_files(files); return ret; }
/* Runs the two-pass assembler. Most of the actual work is done in pass_one() and pass_two(). */ int assemble(const char* in_name, const char* tmp_name, const char* out_name) { FILE *src, *dst; int err = 0; SymbolTable* symtbl = create_table(SYMTBL_UNIQUE_NAME); SymbolTable* reltbl = create_table(SYMTBL_NON_UNIQUE); if (in_name) { printf("Running pass one: %s -> %s\n", in_name, tmp_name); if (open_files(&src, &dst, in_name, tmp_name) != 0) { free_table(symtbl); free_table(reltbl); exit(1); } if (pass_one(src, dst, symtbl) != 0) { err = 1; } close_files(src, dst); } if (out_name) { printf("Running pass two: %s -> %s\n", tmp_name, out_name); if (open_files(&src, &dst, tmp_name, out_name) != 0) { free_table(symtbl); free_table(reltbl); exit(1); } fprintf(dst, ".text\n"); if (pass_two(src, dst, symtbl, reltbl) != 0) { err = 1; } fprintf(dst, "\n.symbol\n"); write_table(symtbl, dst); fprintf(dst, "\n.relocation\n"); write_table(reltbl, dst); close_files(src, dst); } free_table(symtbl); free_table(reltbl); return err; }
void regenerate_fds(void) { if (no_files == TRUE) return; close_files(); open_files(); }
/* * grpck - verify group file integrity */ int main (int argc, char **argv) { int errors = 0; bool changed = false; /* * Get my name so that I can use it to report errors. */ Prog = Basename (argv[0]); (void) setlocale (LC_ALL, ""); (void) bindtextdomain (PACKAGE, LOCALEDIR); (void) textdomain (PACKAGE); process_root_flag ("-R", argc, argv); OPENLOG ("grpck"); /* Parse the command line arguments */ process_flags (argc, argv); open_files (); if (sort_mode) { gr_sort (); #ifdef SHADOWGRP if (is_shadow) { sgr_sort (); } changed = true; #endif } else { check_grp_file (&errors, &changed); #ifdef SHADOWGRP if (is_shadow) { check_sgr_file (&errors, &changed); } #endif } /* Commit the change in the database if needed */ close_files (changed); nscd_flush_cache ("group"); /* * Tell the user what we did and exit. */ if (0 != errors) { if (changed) { printf (_("%s: the files have been updated\n"), Prog); } else { printf (_("%s: no changes\n"), Prog); } } return ((0 != errors) ? E_BAD_ENTRY : E_OKAY); }
int main(int argc, char *argv[]) { FILE *in_fp = NULL; FILE *out_fp = NULL; FILE *err_fp = NULL; char *in_file = "/dev/stdin"; char *out_file = NULL; char *err_file = NULL; int byte_no = 0; int record_no = 0; int rc = 0; int time_travel = DEFAULT_TIME_TRAVEL; struct futmpx record, last_valid_record; debug("Record length: %i\n\n", RECORD_LENGTH); (void)memset(&last_valid_record, 0, RECORD_LENGTH); (void)memset(&record, 0, RECORD_LENGTH); /* Functions parse_args() and open_files() exit on error: */ parse_args(argc, argv, &out_file, &err_file, &time_travel); open_files(in_file, &in_fp, out_file, &out_fp, err_file, &err_fp); /* Loop over input file records */ byte_no = 0; record_no = 0; while(1 == fread(&record, RECORD_LENGTH, 1, in_fp)) { byte_no += RECORD_LENGTH; record_no++; if(g_DEBUG) { print_record(stderr, record_no, byte_no, record); } if(is_record_valid(last_valid_record, record, time_travel)) { if(out_fp) { write_record(out_fp, record); } (void)memcpy(&last_valid_record, &record, RECORD_LENGTH); } else { rc = 1; debug("Invalid record encountered at byte %i, seeking\n", byte_no); seek_valid_record(in_fp, &byte_no, time_travel, last_valid_record, &record, err_fp); } } if(ferror(in_fp)) { error("a read error occurred at or around byte %i\n", byte_no); rc = 1; } /* Tidy up and exit */ rc |= flush_and_close_files(in_file, in_fp, out_file, out_fp, err_file, err_fp); rc |= check_out_file_size(out_file); return rc; }
/* * main - groupadd command */ int main (int argc, char **argv) { /* * Get my name so that I can use it to report errors. */ Prog = Basename (argv[0]); (void) setlocale (LC_ALL, ""); (void) bindtextdomain (PACKAGE, LOCALEDIR); (void) textdomain (PACKAGE); process_root_flag ("-R", argc, argv); prefix = process_prefix_flag ("-P", argc, argv); OPENLOG ("groupadd"); #ifdef WITH_AUDIT audit_help_open (); #endif if (atexit (do_cleanups) != 0) { fprintf (stderr, _("%s: Cannot setup cleanup service.\n"), Prog); exit (1); } /* * Parse the command line options. */ process_flags (argc, argv); check_perms (); #ifdef SHADOWGRP is_shadow_grp = sgr_file_present (); #endif /* * Do the hard stuff - open the files, create the group entries, * then close and update the files. */ open_files (); if (!gflg) { if (find_new_gid (rflg, &group_id, NULL) < 0) { exit (E_GID_IN_USE); } } grp_update (); close_files (); nscd_flush_cache ("group"); return E_SUCCESS; }
int main(int argc, char **argv){ if(argc!=3){ print_help(); exit(EXIT_FAILURE); } size_t f_s_s,f_b_s; FILE *f_smaller; FILE *f_bigger; open_files(argv[1],argv[2], &f_smaller,&f_bigger, &f_s_s,&f_b_s); size_t fl=f_s_s<CHUNK; size_t len=fl?f_s_s:CHUNK; size_t i,j; unsigned char *b_s=malloc(len*sizeof(unsigned char)); unsigned char *b_b=malloc(len*sizeof(unsigned char)); unsigned char *r=malloc(len*sizeof(unsigned char)); size_t s_d=0,b_d=0; size_t l_len=len; int s,b; FILE *f=fopen("x.zip","wb"); // TODO: add flexible size of buffer, smaller file. while(b_d<f_b_s){ fseek(f_bigger, b_d, SEEK_SET); fseek(f_smaller, b_d, SEEK_SET); fread(b_s,sizeof(unsigned char),l_len,f_smaller); fread(b_b,sizeof(unsigned char),l_len,f_bigger); for(i=0;i<l_len;i++){ s=b_s[i]; b=b_b[i]; r[i]=s^b; } //fseek(f_smaller, 0, SEEK_SET); if(b_d+l_len>f_b_s){ l_len=f_b_s-b_d; } fwrite(r,sizeof(char),l_len,f); b_d+=len; s_d+=len; } return(0); }
WORD rvrt_files(VOID) { if (!open_files(TRUE)) return(FALSE); else if (!read_files()) return(FALSE); else { redo_trees(); return(TRUE); } }
int main(int argc, char *argv[]) { get_exec_name(argv[0]); get_options(argc, argv); /* may exit */ open_files(); /* may exit */ read_input_file(); /* may exit */ validate_input_file(); /* may exit */ generate_interrupt_vector_bitmap(); /* may exit */ generate_idt(); /* may exit */ close_files(); return 0; }
// Main program int main(int argc, const char **argv) { FILE *in, *out; ToJunit converter; open_files(argc, argv, &in, &out); converter.parse(in); converter.print(out); fclose(in); fclose(out); }
void do_conversion(m00data_t* data) { debug_print("Beginning file conversion.\n"); open_files(data); fputs(file_head, data->out_file); convert_files(data); fputs(file_end, data->out_file); close_files(data); }
int main(int argc, char **argv) { set_signals(); getargs(argc, argv); open_files(); reader(); lr0(); lalr(); make_parser(); verbose(); output(); done(0); return 0; }
void parse_rmc(char *buffer){ char local_buffer[100]; strcpy(local_buffer, buffer); char *array[50]; char sep[] = "*,"; str_split(array, local_buffer+3, sep, 50); log_array[TIME_1] = atof(array[1]); log_array[DATE] = atof(array[9]); log_array[LATITUDE] = convert(atof(array[3]),array[4][0]); log_array[LONGITUDE] = convert(atof(array[5]),array[6][0]); log_array[COG] = atof(array[8]); log_array[SOG] = atof(array[7]); if (files_open == 0) open_files(array[1],array[9]); write_log_1_row(); }
static void regenerate() { if (!shm->regenerate) { output("[%d] Regenerating random pages, fd's etc.\n", getpid()); close_files(); open_files(); destroy_maps(); setup_maps(); shm->regenerate = REGENERATION_POINT - 1; regenerate_random_page(); } }
int main(int argc, char *argv[]) { int fd_in, fd_out; unsigned long n; if (argc != 4) { fprintf(stderr, "Usage: %s <file input> <file output> <block size>\n", argv[0]); exit(EXIT_FAILURE); } open_files(argv[1], argv[2], &fd_in, &fd_out); n = read_block_size(argv[3]); copy_invert(fd_in, fd_out, n); exit(EXIT_SUCCESS); }
int main (int argc, char *argv[]) { set_signals(); getargs(argc, argv); open_files(); reader(); lr0(); lalr(); make_parser(); verbose(); output(); done(0); /*NOTREACHED*/ }
int unit_init(unsigned play_rate, unsigned play_channels, unsigned rec_rate, unsigned rec_channels, unsigned flags) { int ret = open_files(flags); if(ret != 0) { return -1; } ret = set_params(play_rate, play_channels, rec_rate, rec_channels, flags); if(ret != 0) { return -1; } LOGI("Init success\n"); return 1; }
int main(int argc, char **argv) { atexit(cleanup); set_signals(); getargs(argc, argv); open_files(); reader(); lr0(); lalr(); make_parser(); verbose(); output(); exit(0); /*NOTREACHED*/ }
int main(int argc, char *argv[]) { set_signals(); byacc_getargs(argc, argv); open_files(); reader(); lr0(); lalr(); make_parser(); verbose(); output(); done(EXIT_SUCCESS); /*NOTREACHED*/ exit(EXIT_SUCCESS); }
VOID merge_rsc(VOID) { BYTE sv_rfile[80], sv_dfile[80]; strcpy(&sv_rfile[0], rcs_rfile); strcpy(&sv_dfile[0], rcs_dfile); mouse_form(HGLASS); if (open_files(FALSE)) if (merge_files()) redo_trees(); if (rcs_state == FILE_STATE) { strcpy(rcs_rfile, &sv_rfile[0]); strcpy(rcs_dfile, &sv_dfile[0]); } mouse_form(ARROW); }
int main(void) { if (open_files() != ERROR_SUCCESS) return lasterror; if (close_files() != ERROR_SUCCESS) return lasterror; return ERROR_SUCCESS; }