// The main function int main(int argc, char **argv) { char *msg = NULL; char buffer[256]; int i; int ret; // init library tifiles_library_init(); // test tifiles.c printf("Library version : <%s>\n", tifiles_version_get()); printf("--\n"); // test error.c tifiles_error_get(515, &msg); printf("Error message: <%s>\n", msg); #ifndef __WIN32__ free(msg); #endif printf("--\n"); // test type2str.c printf("tifiles_string_to_model: <%i> <%i>\n", CALC_TI92, tifiles_string_to_model(tifiles_model_to_string(CALC_TI92))); printf("tifiles_string_to_attribute: <%i> <%i>\n", ATTRB_LOCKED, tifiles_string_to_attribute(tifiles_attribute_to_string(ATTRB_LOCKED))); printf("tifiles_string_to_class: <%i> <%i>\n", TIFILE_SINGLE, tifiles_string_to_class(tifiles_class_to_string(TIFILE_SINGLE))); printf("--\n"); // test filetypes.c for(i = CALC_TI73; i <= CALC_V200; i++) { printf("%s (%i) ", tifiles_fext_of_group(i), i); } printf("\n"); for(i = CALC_TI73; i <= CALC_V200; i++) { printf("%s ", tifiles_fext_of_backup(i)); } printf("\n"); for(i = CALC_TI73; i <= CALC_V200; i++) { printf("%s ", tifiles_fext_of_flash_os(i)); } printf("\n"); for(i = CALC_TI73; i <= CALC_V200; i++) { printf("%s ", tifiles_fext_of_flash_app(i)); } printf("\n"); printf("--\n"); printf("<%s> <%s>\n", "foo.bar", tifiles_fext_get("foo.bar")); ret = tifiles_file_is_ti(PATH("misc/str.92s")); printf("tifiles_file_is_ti: %i\n", ret); ret = tifiles_file_is_single(PATH("misc/str.92s")); printf("tifiles_file_is_single: %i\n", ret); ret = tifiles_file_is_group(PATH("misc/group.92g")); printf("tifiles_file_is_group: %i\n", ret); ret = tifiles_file_is_regular(PATH("misc/str.92s")); printf("tifiles_file_is_regular: %i\n", ret); ret = tifiles_file_is_regular(PATH("misc/group.92g")); printf("tifiles_file_is_regular: %i\n", ret); ret = tifiles_file_is_backup(PATH("misc/backup.83b")); printf("tifiles_file_is_backup: %i\n", ret); ret = tifiles_file_is_flash(PATH("misc/ticabfra.89k")); printf("tifiles_file_is_flash: %i\n", ret); ret = tifiles_file_is_flash(PATH("misc/TI73_OS160.73U")); printf("tifiles_file_is_flash: %i\n", ret); ret = tifiles_file_is_tib(PATH("misc/ams100.tib")); printf("tifiles_file_is_tib: %i\n", ret); ret = tifiles_file_is_tigroup(PATH("misc/test.tig")); printf("tifiles_file_is_tigroup: %i\n", ret); printf("--\n"); // test typesxx.c printf("tifiles_file_get_model: %s\n", tifiles_model_to_string(tifiles_file_get_model(PATH("misc/str.92s")))); printf("tifiles_file_get_class: %s\n", tifiles_class_to_string(tifiles_file_get_class(PATH("misc/group.92g")))); printf("tifiles_file_get_type: %s\n", tifiles_file_get_type(PATH("misc/TI73_OS160.73U"))); printf("tifiles_file_get_icon: %s\n", tifiles_file_get_icon(PATH("misc/str.92s"))); printf("--\n"); // test misc.c printf("tifiles_calc_is_ti8x: %i\n", tifiles_calc_is_ti8x(CALC_TI83)); printf("tifiles_calc_is_ti9x: %i\n", tifiles_calc_is_ti9x(CALC_TI89)); printf("tifiles_has_folder: %i\n", tifiles_has_folder(CALC_TI92)); printf("tifiles_is_flash: %i\n", tifiles_is_flash(CALC_TI73)); printf("tifiles_get_varname: <%s>\n", tifiles_get_varname("fld\\var")); printf("tifiles_get_fldname: <%s>\n", tifiles_get_fldname("fld\\var")); tifiles_build_fullname(CALC_TI89, buffer, "fld", "var"); printf("tifiles_build_fullname: <%s>\n", buffer); printf("--\n"); // test filesxx.c & grouped.c do { // TI73 support change_dir(PATH("ti73")); ret = test_ti73_backup_support(); if (ret) break; ret = test_ti73_regular_support(); if (ret) break; ret = test_ti73_group_support(); if (ret) break; ret = test_ti73_ungroup_support(); if (ret) break; // TI82 support change_dir(PATH("ti82")); ret = test_ti82_backup_support(); if (ret) break; ret = test_ti82_regular_support(); if (ret) break; ret = test_ti82_group_support(); if (ret) break; ret = test_ti82_ungroup_support(); if (ret) break; // TI83 support change_dir(PATH("ti83")); ret = test_ti83_backup_support(); if (ret) break; ret = test_ti83_regular_support(); if (ret) break; ret = test_ti83_group_support(); if (ret) break; ret = test_ti83_ungroup_support(); if (ret) break; // TI84+ support change_dir(PATH("ti84p")); ret = test_ti84p_regular_support(); if (ret) break; ret = test_ti84p_group_support(); if (ret) break; ret = test_ti84p_ungroup_support(); if (ret) break; ret = test_ti84p_flash_support(); if (ret) break; // TI85 support change_dir(PATH("ti85")); ret = test_ti85_regular_support(); if (ret) break; // TI86 support change_dir(PATH("ti86")); ret = test_ti86_backup_support(); if (ret) break; ret = test_ti86_regular_support(); if (ret) break; ret = test_ti86_group_support(); if (ret) break; ret = test_ti86_ungroup_support(); if (ret) break; // TI89 support change_dir(PATH("ti89")); ret = test_ti89_regular_support(); if (ret) break; ret = test_ti89_flash_support(); if (ret) break; ret = test_v200_regular_support(); if (ret) break; // TI92 support change_dir(PATH("ti92")); ret = test_ti92_backup_support(); if (ret) break; ret = test_ti92_regular_support(); if (ret) break; ret = test_ti92_group_support(); if (ret) break; ret = test_ti92_ungroup_support(); if (ret) break; // TIXX certificates change_dir(PATH("certs")); ret = test_ti8x_cert_support(); if (ret) break; ret = test_ti9x_cert_support(); if (ret) break; // Add/Del files change_dir(PATH("misc")); ret = test_ti8x_group_merge(); if (ret) break; change_dir(PATH("tig")); ret = test_tigroup(); } while(0); // end of test tifiles_library_exit(); return ret; }
gint display_about_dbox(void) { GtkWidget* widget; GtkAboutDialog* dlg; GdkPixbuf *pix; struct stat stbuf; FILE *fd; gchar *filename; int len = 0; gchar buffer[32768]; gchar *version; #ifdef _MSC_VER /* MSVC builds. MinGW builds use Linux file structures. */ filename = g_strconcat(inst_paths.base_dir, "License.txt", NULL); #else /* */ filename = g_strconcat(inst_paths.base_dir, "COPYING", NULL); #endif /* */ if (access(filename, F_OK) == 0) { if (stat(filename, &stbuf) != -1) { len = stbuf.st_size; len -= 2; } if ((fd = fopen(filename, "r")) != NULL) { memset(buffer, 0, sizeof(buffer)); len = fread(buffer, 1, len, fd); fclose(fd); } } version = g_strdup_printf(_("Framework version (cables=%s, files=%s, calcs=%s, conv=%s)"), ticables_version_get(), tifiles_version_get(), ticalcs_version_get(), ticonv_version_get()); //--- widget = gtk_about_dialog_new(); dlg = GTK_ABOUT_DIALOG(widget); pix = create_pixbuf("logo.png"); gtk_about_dialog_set_program_name(dlg, "TiLP2 - Tilp Is a Linking Program - "); gtk_about_dialog_set_version(dlg, TILP_VERSION); gtk_about_dialog_set_comments(dlg, version); gtk_about_dialog_set_copyright(dlg, "Copyright (c) 2001-2010 The TiLP Team"); gtk_about_dialog_set_license(dlg, buffer); gtk_about_dialog_set_website(dlg, "http://www.tilp.info"); gtk_about_dialog_set_authors(dlg, authors); gtk_about_dialog_set_documenters(dlg, documenters); gtk_about_dialog_set_artists(dlg, artists); gtk_about_dialog_set_logo(dlg, pix); g_signal_connect_swapped(dlg, "response", G_CALLBACK(gtk_widget_destroy), dlg); //gtk_show_about_dialog(NULL, ""); gtk_widget_show_all(widget); return 0; }
/* This function must be the first function to call in your function 'main'. It initializes the TiLP core engine. */ int tilp_init(int *argc, char ***argv) { /* Display program version */ tilp_cmdline_version(); /* Initialize platform independant paths */ tilp_paths_init(); /* Init i18n support */ #ifdef ENABLE_NLS tilp_info("setlocale: %s", setlocale(LC_ALL, "")); tilp_info("bindtextdomain: %s", bindtextdomain(PACKAGE, inst_paths.locale_dir)); bind_textdomain_codeset(PACKAGE, "UTF-8"/*"ISO-8859-15"*/); tilp_info("textdomain: %s", textdomain(PACKAGE)); #endif /* Initialize callbacks with default functions */ tilp_gif_set_default(); /* Initialize/reload config */ tilp_config_default(); tilp_config_read(); /* Scan and modify command line and change to working folder*/ tilp_cmdline_scan(argc, argv); tilp_file_chdir(options.working_dir); /* Catch 'Ctrl-C' */ signal(SIGINT, signal_handler); /* Check the version of libraries and init framework */ if (strcmp(ticonv_version_get(), TILP_REQUIRES_LIBCONV_VERSION) < 0) tilp_error(_("libticonv library version is %s but %s mini required.\n"), ticonv_version_get(), TILP_REQUIRES_LIBCONV_VERSION); if (strcmp(tifiles_version_get(), TILP_REQUIRES_LIBFILES_VERSION) < 0) tilp_error(_("libtifiles library version is %s but %s mini required.\n"), tifiles_version_get(), TILP_REQUIRES_LIBFILES_VERSION); if (strcmp(ticables_version_get(), TILP_REQUIRES_LIBCABLES_VERSION) < 0) tilp_error(_("libticables library version is %s but %s mini required.\n"), ticables_version_get(), TILP_REQUIRES_LIBCABLES_VERSION); if (strcmp(ticalcs_version_get(), TILP_REQUIRES_LIBCALCS_VERSION) < 0) tilp_error(_("libticalcs library version is %s but %s mini required.\n"), ticalcs_version_get(), TILP_REQUIRES_LIBCALCS_VERSION); ticables_library_init(); tifiles_library_init(); ticalcs_library_init(); /* Check for USB support */ options.usb_avail = ticables_is_usb_enabled(); /* Set cable & calc */ if(options.auto_detect && options.usb_avail) { int ret; CableModel cable; CalcModel calc; CablePort port; ret = tilp_device_probe_usb(&cable, &port, &calc); if(!ret) { options.cable_model = cable; options.cable_port = port; options.calc_model = calc; } } tilp_device_open(); /* If we are in command line mode, does the required operation and exit else fallback on a graphic interface. */ if((working_mode & MODE_CMD) && !(working_mode & MODE_GUI)) { int ret; ret = tilp_cmdline_send(); exit(ret); } else if(working_mode == MODE_INI) exit(0); return 0; }