/* The main function */ int main(int argc, char **argv) { int i, j; unsigned int n = 0; int is_utf8 = ticonv_environment_is_utf8(); charsets[0] = ti73_charset; charsets[1] = ti82_charset; charsets[2] = ti83_charset; charsets[3] = ti83p_charset; charsets[4] = ti85_charset; charsets[5] = ti86_charset; charsets[6] = ti9x_charset; // test ticonv.c printf("Library version : <%s>\n", ticonv_version_get()); printf("--\n"); printf("Choose your charset: "); if (!scanf("%u", &n)) { n = 0; } if (n >= 7) { n = 6; } printf(" 0 1 2 3 4 5 6 7 8 9 A B C D E F\n"); for(i = 0; i < 16; i++) { printf("%x ", i); for(j = 0; j < 16; j++) { unsigned long wc = charsets[n][16*i+j]; gchar *str = NULL; if (wc && wc != '\n') { gunichar2 buf[4] = { 0 }; buf[0] = (gunichar2)wc; str = ticonv_utf16_to_utf8(buf); if (!is_utf8 && str) { gchar *tmp = g_locale_from_utf8(str, -1, NULL, NULL, NULL); ticonv_utf8_free(str); str = tmp; } } else { str = NULL; } if (str) { printf("%s ", str); } ticonv_utf8_free(str); } printf("\n"); } { char ti82_varname[9] = { 0 }; char ti92_varname[9] = { 0 }; char ti84p_varname[36] = { 0 }; char *utf8; char *filename; char *varname; ti82_varname[0] = 0x5d; // L1 ti82_varname[1] = 0x01; ti82_varname[2] = 0; ti92_varname[0] = (char)132; // delta ti92_varname[1] = (char)0xE9; // e acute. ti92_varname[2] = 0; ti84p_varname[0] = 'L'; // L1 in TI-UTF-8 ti84p_varname[1] = (char)0xE2; ti84p_varname[2] = (char)0x82; ti84p_varname[3] = (char)0x81; // TI -> UTF-8 utf8 = ticonv_varname_to_utf8(CALC_TI82, ti82_varname, -1); printf("UTF-8 varname: <%s> (%i)\n", ti82_varname, (int)strlen(ti82_varname)); ticonv_utf8_free(utf8); utf8 = ticonv_varname_to_utf8(CALC_TI92, ti92_varname, -1); printf("UTF-8 varname: <%s> (%i)\n", ti92_varname, (int)strlen(ti92_varname)); ticonv_utf8_free(utf8); utf8 = ticonv_varname_to_utf8(CALC_TI84P_USB, ti84p_varname, -1); printf("UTF-8 varname: <%s> (%i)\n", ti84p_varname, (int)strlen(ti84p_varname)); ticonv_utf8_free(utf8); // TI -> filename printf("raw varname: <%s> (%i)\n", ti92_varname, (int)strlen(ti92_varname)); filename = ticonv_varname_to_filename(CALC_TI92, ti92_varname, -1); printf("filename: <%s>\n", filename); ticonv_gfe_free(filename); printf("raw varname: <%s> (%i)\n", ti82_varname, (int)strlen(ti82_varname)); filename = ticonv_varname_to_filename(CALC_TI82, ti82_varname, -1); printf("filename: <%s>\n", filename); ticonv_gfe_free(filename); printf("raw varname: <%s> (%i)\n", ti84p_varname, (int)strlen(ti84p_varname)); filename = ticonv_varname_to_filename(CALC_TI84P_USB, ti84p_varname, -1); printf("filename: <%s>\n", filename); ticonv_gfe_free(filename); // varname -> varname printf("raw varname: <%s> (%i)\n", ti84p_varname, (int)strlen(ti84p_varname)); varname = ticonv_varname_to_tifile(CALC_TI84P_USB, ti84p_varname, -1); printf("varname: <%s>\n", varname); ticonv_gfe_free(varname); } #ifdef __WIN32__ while(!_kbhit()); #endif return 0; }
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; }