void writeold( QTextStream &str, const Item &i2 ) { nOld++; writecomment( str, i2.usercomments ); writecomment( str, i2.systemcomments ); writecomment( str, i2.msgid ); writecomment( str, i2.msgstr ); str << "\n"; }
void writejunk( QTextStream &str, const Item &it ) { nJunk++; if ( !it.usercomments.isEmpty() ) str << it.usercomments; writecomment( str, it.systemcomments ); writecomment( str, it.msgid ); writecomment( str, it.msgstr ); str << "\n"; }
int main(int argc, char* argv[]) { const char *comment = "Created with Bin2Var v1.10"; FILE *fp; char *buf, str[256], *c; int i, n, ext, n2; unsigned short chk; printf("Bin2Var v1.20 by David Phillips <*****@*****.**>\n\n"); if (argc != 3) die(0); buf = strrchr(argv[2], '.'); if (!buf) die("Output file must have an extension!\n"); if (!stricmp(buf, ".82p")) ext = E_82P; else if (!stricmp(buf, ".83p")) ext = E_83P; else if (!stricmp(buf, ".8xp")) ext = E_8XP; else if (!stricmp(buf, ".85s")) ext = E_85S; else if (!stricmp(buf, ".86p")) ext = E_86P; else if (!stricmp(buf, ".86s")) ext = E_86S; else die("Extension \'%s\' is not supported!\n", buf); genname(argv[2], str); fp = fopen(argv[1], "rb"); if (!fp) die("Failed to open input file: %s\n", argv[1]); n = fsize(fp); buf = (char *)malloc(n); fread(buf, n, 1, fp); if (ferror(fp)) die("Error reading input file: %s\n", argv[1]); fclose(fp); fp = fopen(argv[2], "wb"); if (!fp) die("Failed to open output file: %s\n", argv[2]); chk = 0; if (ext == E_82P) fwrite("**TI82**\x1a\x0a\x00", 11, 1, fp); else if (ext == E_83P) fwrite("**TI83**\x1a\x0a\x00", 11, 1, fp); else if (ext == E_8XP) fwrite("**TI83F*\x1a\x0a\x00", 11, 1, fp); else if (ext == E_85S) fwrite("**TI85**\x1a\x0c\x00", 11, 1, fp); else if ((ext == E_86P) || (ext == E_86S)) fwrite("**TI86**\x1a\x0a\x00", 11, 1, fp); writecomment(fp, comment); if ((ext == E_82P) ) i = n + 17; else if (ext == E_83P) i = (n * 2) + 26; else if (ext == E_8XP) i = (n * 2) + 20; else if (ext == E_85S) i = n + 10 + strlen(str); else i = n + 18; fwrite(&i, 2, 1, fp); if ((ext == E_82P) || (ext == E_83P) || (ext == E_8XP)) cfwrite("\x0b\0x00", 2, fp, &chk); else if (ext == E_85S) { i = 4 + strlen(str); cfwrite(&i, 1, fp, &chk); cfwrite("\0x00", 1, fp, &chk); } else cfwrite("\x0c\0x00", 2, fp, &chk); if(ext == E_8XP) i = (n * 2) + 5; else if(ext == E_83P) i = (n * 2) + 11; else i = n + 2; cfwrite(&i, 2, fp, &chk); if ((ext == E_82P) || (ext == E_83P) || (ext == E_8XP)) cfwrite("\x06", 1, fp, &chk); else if (ext == E_86P) cfwrite("\x12", 1, fp, &chk); else if ((ext == E_85S) || (ext == E_86S)) cfwrite("\x0c", 1, fp, &chk); i = strlen(str); if ((ext == E_85S) || (ext == E_86P) || (ext == E_86S)) cfwrite(&i, 1, fp, &chk); cfwrite(str, i, fp, &chk); memset(str, 0, 8); if (ext != E_85S) cfwrite(str, 8 - i, fp, &chk); if (ext == E_8XP) { i = (n * 2) + 5; n2 = (n * 2) + 3; } else if (ext == E_83P) { i = (n * 2) + 11; n2 = (n * 2) + 9; } else { i = n + 2; n2 = n; } cfwrite(&i, 2, fp, &chk); cfwrite(&n2, 2, fp, &chk); if(ext == E_8XP) { cfwrite("\xBB", 1, fp, &chk); cfwrite("\x6C", 1, fp, &chk); cfwrite("\x3F", 1, fp, &chk); } if((ext == E_83P) || (ext == E_8XP)) datawrite(buf, n, fp, &chk); else cfwrite(buf, n, fp, &chk); if(ext == E_83P) { cfwrite("\x3F", 1, fp, &chk); cfwrite("\xD4", 1, fp, &chk); cfwrite("\x3F", 1, fp, &chk); cfwrite("0000", 4, fp, &chk); cfwrite("\x3F", 1, fp, &chk); cfwrite("\xD4", 1, fp, &chk); } fwrite(&chk, 2, 1, fp); if (ferror(fp)) die("Failed writing output file: %s\n", argv[2]); fclose(fp); free(buf); printf("'%s' successfully converted to '%s'\n", argv[1], argv[2]); return 0; }