int get_string(char* argv[]){ char szDirectory[MAX_PATH]; int nIdx = 2; memset(szDirectory, 0, sizeof(szDirectory)); while ( argv[nIdx] != NULL ){ if ( strncmp(argv[nIdx], "-s=", 3) == 0 ){ strcpy(szDirectory, &argv[nIdx][3]); szDirectory[MAX_PATH-1] = '\0'; } else{ printf("Error: invalid option '%s'\n", argv[nIdx]); return 0; } nIdx ++; } infGetString(szDirectory); /* if ( szDirectory[0] == '\0' ){ write_log(LT_BOTH,"Error: Please specify the source root path after '-s'\n"); return 0; } get_path_or_filename(szDirectory); if ( is_a_valid_directory(szDirectory) == 0 ) return 0; // init log file system which is used to record some error for get string if ( str_operate_init(szDirectory, NULL) == 0){ write_log(LT_BOTH,"Error: Can't init 'get string' module!\n"); return 0; } if ( db_init(0) == 0 ){ write_log(LT_BOTH,"Error: Can't init 'database operation' module!\n"); return 0; } write_log(LT_BOTH,"Current task:\n"); write_log(LT_BOTH,"--------------------------------------------------------\n"); write_log(LT_BOTH,"Get all chinese string from directory:\n\t'%s'\n", szDirectory); write_log(LT_BOTH,"The string will be inserted into translate database!\n"); write_log(LT_BOTH,"--------------------------------------------------------\n\n"); return start_work();*/ }
static void key_assignments (void) { int i, j, k, errcnt=0, nkt=sizeof(kt)/sizeof(struct _kt); char sect_keys[]="keys", *p, *p1, *p2, *p3; for (j=0; j<nkt; j++) { if (infGetString (sect_keys, kt[j].n, &p) < 0) continue; p1 = p; for (i=1; i<=64; i++) { p2 = strchr (p1, ','); if (p2 != NULL) *p2 = '\0'; p3 = strdup (p1); str_strip2 (p3, " "); if (p3[0] != '\0') { k = fly_keyvalue (p3); free (p3); if (k == -1) { fly_ask_ok (0, M("wrong key name: [%s]\n"), p1); errcnt++; } else { options.keytable[k] = kt[j].v; } } if (p2 == NULL) break; p1 = p2 + 1; } free (p); } if (errcnt && fl_opt.has_console) { fprintf (stderr, M("%d errors while processing key definitions\nPress ENTER..."), errcnt); fgetc (stdin); } }
void GetProfileOptions (char *ini_name) { char *p, buf[16]; int i; if (infLoad (ini_name) < 0) { fly_error (M("Error loading %s; terminating"), ini_name); } // put defaults in place for (i=0; i<sizeof(boptions)/sizeof(boptions[0]); i++) *(boptions[i].value) = boptions[i].def; for (i=0; i<sizeof(ioptions)/sizeof(ioptions[0]); i++) *(ioptions[i].value) = ioptions[i].def; for (i=0; i<sizeof(soptions)/sizeof(soptions[0]); i++) *(soptions[i].value) = soptions[i].def; for (i=0; i<sizeof(xoptions)/sizeof(xoptions[0]); i++) if (xoptions[i].def != 255) *(xoptions[i].value) = xoptions[i].def; if (fl_opt.is_unix || fl_opt.platform == PLATFORM_OS2_X || fl_opt.platform == PLATFORM_OS2_X11) options.pseudographics = 2; // some defaults options.psw_file = str_strdup1 (paths.user_libpath, 9); str_cats (options.psw_file, "nftp.psw"); options.history_file = str_strdup1 (paths.user_libpath, 9); str_cats (options.history_file, "nftp.hst"); // retrieve options for (i=0; i<sizeof(boptions)/sizeof(boptions[0]); i++) infGetBoolean (boptions[i].sect, boptions[i].name, boptions[i].value); for (i=0; i<sizeof(ioptions)/sizeof(ioptions[0]); i++) infGetInteger (ioptions[i].sect, ioptions[i].name, ioptions[i].value); for (i=0; i<sizeof(soptions)/sizeof(soptions[0]); i++) infGetString (soptions[i].sect, soptions[i].name, soptions[i].value); for (i=0; i<sizeof(xoptions)/sizeof(xoptions[0]); i++) infGetHexbyte (xoptions[i].sect, xoptions[i].name, (char *)xoptions[i].value); if (infGetInteger (sect_psw, "encryption-type", &options.psw_enctype) < 0) { if (fl_opt.platform != PLATFORM_UNIX_TERM && fl_opt.platform != PLATFORM_UNIX_X11) options.psw_enctype = 2; } if (infGetBoolean (sect_options, "query-bfs-attributes-support", &options.query_bfsattrs) < 0) { if (fl_opt.platform == PLATFORM_BEOS_TERM) options.query_bfsattrs = TRUE; else options.query_bfsattrs = FALSE; } if (options.user_agent == NULL) { strcpy (buf, NFTP_VERSION); str_strip2 (buf, " "); options.user_agent = str_join ("NFTP-", buf); } // post-config if (fl_opt.has_osmenu) fl_opt.menu_onscreen = FALSE; // INI file editor if (fl_opt.platform == PLATFORM_OS2_VIO) { options.texteditor = "tedit.exe"; infGetString (sect_options, "text-editor-os2vio", &options.texteditor); } if (fl_opt.platform == PLATFORM_OS2_PM) { options.texteditor = "e.exe"; infGetString (sect_options, "text-editor-os2pm", &options.texteditor); } if (fl_opt.platform == PLATFORM_OS2_X || fl_opt.platform == PLATFORM_OS2_X11) { options.texteditor = "xedit.exe"; infGetString (sect_options, "text-editor-os2x", &options.texteditor); } if (fl_opt.platform == PLATFORM_WIN32_CONS) { options.texteditor = "Notepad.exe"; infGetString (sect_options, "text-editor-win32cons", &options.texteditor); } if (fl_opt.platform == PLATFORM_WIN32_GUI) { options.texteditor = "Notepad.exe"; infGetString (sect_options, "text-editor-win32gui", &options.texteditor); } if (fl_opt.platform == PLATFORM_BEOS_TERM) { options.texteditor = "vi"; infGetString (sect_options, "text-editor-beosterm", &options.texteditor); } if (fl_opt.platform == PLATFORM_UNIX_TERM) { options.texteditor = "vi"; infGetString (sect_options, "text-editor-unixterm", &options.texteditor); } if (fl_opt.platform == PLATFORM_UNIX_X11) { options.texteditor = "xedit"; infGetString (sect_options, "text-editor-unix_x11", &options.texteditor); } // others if (options.log_trans) { if (infGetString (sect_options, "log-transfers-name", &p) == 0) { strcpy (options.log_trans_name, p); free (p); } else { strcpy (options.log_trans_name, paths.user_libpath); str_cats (options.log_trans_name, "nftp.fls"); } } if (infGetString (sect_options, "bookmarks-file", &p) == 0) { strcpy (options.bmk_name, p); free (p); } else { strcpy (options.bmk_name, paths.user_libpath); str_cats (options.bmk_name, "nftp.bmk"); } // registration information if ((cfg_get_string (CONFIG_NFTP, NULL, "registration-name"))[0] == '\0') { if (infGetString (sect_registration, "name", &p) == 0) { cfg_set_string (CONFIG_NFTP, NULL, "registration-name", p); free (p); } if (infGetString (sect_registration, "code", &p) == 0) { cfg_set_string (CONFIG_NFTP, NULL, "registration-code", p); free (p); } } // clear key definition table for (i=0; i<sizeof(options.keytable)/sizeof(int); i++) { options.keytable[i] = KEY_NOTHING; options.keytable2[i] = KEY_NOTHING; } def_key_assignments (); key_assignments (); // retrieve colours if ((options.monochrome && !cmdline.colour) || cmdline.monochrome) { options.attr_pointer_marked_dir = VID_REVERSE; options.attr_pointer_marked = VID_REVERSE; options.attr_pointer_dir = VID_REVERSE; options.attr_pointer = VID_REVERSE; options.attr_pointer_desc = VID_REVERSE; options.attr_marked_dir = VID_BRIGHT; options.attr_marked = VID_BRIGHT; options.attr_dir = VID_NORMAL; options.attr_description = VID_NORMAL; options.attr_ = VID_NORMAL; options.attr_background = VID_NORMAL; options.attr_status = VID_NORMAL; options.attr_status2 = VID_REVERSE; options.attr_statmarked = VID_REVERSE; options.attr_tr_info = VID_NORMAL; options.attr_help = VID_REVERSE; options.attr_status_local = VID_NORMAL; options.attr_tp_file = VID_NORMAL; options.attr_tp_dir = VID_NORMAL; options.attr_tp_file_m = VID_NORMAL; options.attr_tp_dir__m = VID_NORMAL; options.attr_tp_file_p = VID_REVERSE; options.attr_tp_dir__p = VID_REVERSE; options.attr_tp_file_mp = VID_REVERSE; options.attr_tp_dir__mp = VID_REVERSE; options.attr_cntr_header = VID_REVERSE; options.attr_cntr_resp = VID_NORMAL; options.attr_cntr_cmd = VID_BRIGHT; options.attr_cntr_comment = VID_BRIGHT; options.attr_bmrk_back = VID_REVERSE; options.attr_bmrk_pointer = VID_NORMAL; options.attr_bmrk_hostpath = VID_REVERSE; options.attr_bmrk_hostpath_pointer = VID_BRIGHT; } infFree (); }