// Print current compression statistics static void print_stats (Results &r) { #ifndef FREEARC_NO_TIMING FILESIZE insize = r.progress_insize; bool not_enough_input = (insize - r.last_insize < PROGRESS_CHUNK_SIZE); FILESIZE outsize = r.progress_outsize; bool not_enough_output = (outsize - r.last_outsize < PROGRESS_CHUNK_SIZE); if (r.quiet_progress || insize==0 || outsize==0 || not_enough_input && not_enough_output) return; // Prints stats no more often than once per 64 kb r.last_insize = insize; r.last_outsize = outsize; double curtime = GetSomeTime(); // Update progress indicator every 0.2 seconds if (curtime > r.lasttime+0.2) { double time = curtime - r.start_time; // Time used so far char percents0[100] = "", remains0[100] = "", percents[1000] = "", remains[100] = "", insize_str[100], outsize_str[100]; if (r.filesize) { // If progress by 1% takes more than 1-2 seconds - display xx.x%, otherwise xx% // (we don't want to switch it too frequently, therefore "?1:2") r.show_exact_percent = double(r.filesize)/insize*time > (r.show_exact_percent?1:2)*100; if (r.show_exact_percent) sprintf (percents0, "%.1lf%%", double(int(double(insize)*100/r.filesize*10))/10); else sprintf (percents0, "%d%%", int(double(insize)*100/r.filesize)); sprintf (percents, "%s: ", percents0); int remain = int(double(r.filesize-insize)/insize*time)+1; if (remain>=3600) sprintf (remains0, "%02d:%02d:%02d", remain / 3600, (remain % 3600) / 60, remain % 60); else sprintf (remains0, "%02d:%02d", remain / 60, remain % 60); sprintf (remains, ". Remains %s", remains0); } double origsize = (r.mode==_COMPRESS? insize : outsize); // Size of original (uncompressed) data double compsize = (r.mode==_COMPRESS? outsize : insize); // Size of compressed data double ratio = (compsize/origsize)*100; double speed = (origsize/mb) / mymax(time,0.001); // Speed of processing, in MiB/s if (!r.quiet_result && !strequ (r.outname, "-")) fprintf (stderr, "\r%s%s%s -> %s: %.2lf%%, speed %.3lf mb/sec%s ", r.method_name, percents, show3(insize,insize_str), show3(outsize,outsize_str), ratio, speed, remains); if (!r.quiet_title && r.filesize && curtime > r.lasttime2+0.5) // Update window title every 0.5 seconds { const char *op = (r.mode==_COMPRESS? "Compressing": r.mode==_DECOMPRESS? "Extracting": "Benchmarking"); sprintf (percents, "%s %s | %s %s", percents0, remains0, op, strequ(r.filename,"-")? PROGRAM_NAME : r.filename); EnvSetConsoleTitleA (percents); Taskbar_SetProgressValue (insize, r.filesize); r.lasttime2 = curtime; } r.lasttime = curtime; } #endif }
void showNumber(uint8_t number) { if(number == 0) { show0(); } else if(number == 1) { show1(); } else if(number == 2) { show2(); } else if(number == 3) { show3(); } else if(number == 4) { show4(); } else if(number == 5) { show5(); } else if(number == 6) { show6(); } else if(number == 7) { show7(); } else if(number == 8) { show8(); } else if(number == 9) { show9(); } }
/* function to show the things player can quaff only */ static void showquaff(void) { int i, j, sigsav, count; sigsav = nosignal; nosignal = 1; /* don't allow ^c etc */ srcount = 0; for (count = 2, j = 0; j <= 26; j++) switch (iven[j]) { case OPOTION: count++; }; t_setup(count); for (i = 22; i < 84; i++) for (j = 0; j <= 26; j++) if (i == iven[j]) switch (i) { case OPOTION: show3(j); }; more(); nosignal = sigsav; t_endup(count); }
/* * Subroutine to print out the non-winners scoreboard * * Enter with 0 to list the scores, enter with 1 to list inventories too * Returns the number of players on scoreboard that were shown */ static int shou (int x) { int i, j, n, k; int count; for (count = j = i = 0; i < SCORESIZE; i++) /* is the scoreboard empty? */ if (sco[i].score != 0) { j++; break; } if (j) { lprcat ("\n Score Difficulty Larn Visitor Log\n"); for (i = 0; i < SCORESIZE; i++) /* be sure to print them out in order */ for (j = 0; j < SCORESIZE; j++) if (sco[j].order == i) { if (sco[j].score) { count++; lprintf ("%10ld %2d %s ", sco[j].score, sco[j].hardlev, sco[j].who); if (sco[j].what < 256) lprintf ("killed by a %s", monster[sco[j].what].name); else lprintf ("%s", whydead[sco[j].what - 256]); if (x != 263) lprintf (" on %s", levelname[sco[j].level]); if (x) { for (n = 0; n < 26; n++) { iven[n] = sco[j].sciv[n][0]; ivenarg[n] = sco[j].sciv[n][1]; } for (k = 1; k < 99; k++) { for (n = 0; n < 26; n++) { if (k == iven[n]) show3 (n); } } lprcat ("\n\n"); } else lprc ('\n'); } j = SCORESIZE; } } return (count); /* return the number of players just shown */ }
/* function to show the things player can wield only */ static void showwield(void) { int i, j, sigsav, count; sigsav = nosignal; nosignal = 1; /* don't allow ^c etc */ srcount = 0; for (count = 2, j = 0; j <= 26; j++) /* count how many items */ if ((i = iven[j]) != 0) switch (i) { case ODIAMOND: case ORUBY: case OEMERALD: case OSAPPHIRE: case OBOOK: case OCHEST: case OLARNEYE: case ONOTHEFT: case OSPIRITSCARAB: case OCUBEofUNDEAD: case OPOTION: case OSCROLL: break; default: count++; }; t_setup(count); for (i = 22; i < 84; i++) for (j = 0; j <= 26; j++) if (i == iven[j]) switch (i) { case ODIAMOND: case ORUBY: case OEMERALD: case OSAPPHIRE: case OBOOK: case OCHEST: case OLARNEYE: case ONOTHEFT: case OSPIRITSCARAB: case OCUBEofUNDEAD: case OPOTION: case OSCROLL: break; default: show3(j); }; more(); nosignal = sigsav; t_endup(count); }
// Print final compression statistics static void print_final_stats (Results &r) { if (!r.quiet_result && r.insize && r.outsize) { double origsize = (r.mode==_COMPRESS? r.insize : r.outsize); // Size of original (uncompressed) data double compsize = (r.mode==_COMPRESS? r.outsize : r.insize); // Size of compressed data double ratio = (compsize/origsize)*100; char insize_str[100], outsize_str[100]; fprintf (stderr, "\r%s%s %s -> %s: %.2lf%%", r.method_name, r.mode==_COMPRESS? "compressed":"Unpacked", show3(r.insize,insize_str), show3(r.outsize,outsize_str), ratio); #ifndef FREEARC_NO_TIMING double time = GetSomeTime() - r.start_time; // Time spent for (de)compression if (time > 0.001) { double speed = (origsize/mb) / time; // Speed of processing, in MiB/s fprintf (stderr, ", time %.3lf secs, speed %.3lf mb/sec", time, speed); } #endif fprintf (stderr, "\n"); } if (!r.quiet_title && r.filesize) clear_window_title(); }
void Segment::display(int number) { this->offAll(); switch(number) { case 0: show0(); // delay(500); break; case 1: show1(); // delay(500); break; case 2: show2(); // delay(500); break; case 3: show3(); // delay(500); break; case 4: show4(); // delay(500); break; case 5: show5(); // delay(500); break; case 6: show6(); // delay(500); break; case 7: show7(); // delay(500); break; case 8: show8(); // delay(500); break; case 9: show9(); // delay(500); break; default: showE(); // delay(500); break; } }
/* function to show the things player is wearing only */ static void showwear(void) { int i, j, sigsav, count; sigsav = nosignal; nosignal = 1; /* don't allow ^c etc */ srcount = 0; for (count = 2, j = 0; j <= 26; j++) /* count number of items we * will display */ if ((i = iven[j]) != 0) switch (i) { case OLEATHER: case OPLATE: case OCHAIN: case ORING: case OSTUDLEATHER: case OSPLINT: case OPLATEARMOR: case OSSPLATE: case OSHIELD: count++; }; t_setup(count); for (i = 22; i < 84; i++) for (j = 0; j <= 26; j++) if (i == iven[j]) switch (i) { case OLEATHER: case OPLATE: case OCHAIN: case ORING: case OSTUDLEATHER: case OSPLINT: case OPLATEARMOR: case OSSPLATE: case OSHIELD: show3(j); }; more(); nosignal = sigsav; t_endup(count); }
void qshowstr(void) { int i, j, k, sigsav; srcount = 0; sigsav = nosignal; nosignal = 1; /* don't allow ^c etc */ if (c[GOLD]) { lprintf(".) %ld gold pieces", (long) c[GOLD]); srcount++; } for (k = 26; k >= 0; k--) if (iven[k]) { for (i = 22; i < 84; i++) for (j = 0; j <= k; j++) if (i == iven[j]) show3(j); k = 0; } lprintf("\nElapsed time is %ld. You have %ld mobuls left", (long) ((gltime + 99) / 100 + 1), (long) ((TIMELIMIT - gltime) / 100)); more(); nosignal = sigsav; }
int main() { printf("Example of calling fftw++ convolutions from C:\n"); unsigned int nthreads=2; unsigned int M=2; /* dimension of dot product */ double overM=1.0/(double) M; double complex *pf[M]; double complex *pg[M]; int returnflag=0; set_fftwpp_maxthreads(nthreads); { printf("Complex, non-centered 1D example:\n"); unsigned int nx = 8; /* ImplicitConvolution *cconv=fftwpp_create_conv1d(m); */ ImplicitConvolution *cconv = fftwpp_create_conv1d(nx); double complex *f = create_complexAlign(nx); double complex *g = create_complexAlign(nx); init(f, g, nx); /* set the input data */ printf("Input f:\n"); show(f, nx); printf("Input g:\n"); show(g, nx); fftwpp_conv1d_convolve(cconv, f, g); //fftwpp_conv1d_correlate(cconv, f, g); printf("Output f:\n"); show(f, nx); delete_complexAlign(g); delete_complexAlign(f); fftwpp_conv1d_delete(cconv); printf("\n"); } { printf("Complex, Hermitian-symmetric, centered 1D example:\n"); unsigned int nx = 8; ImplicitHConvolution *hconv = fftwpp_create_hconv1d(nx); double complex *f = create_complexAlign(nx); double complex *g = create_complexAlign(nx); init(f, g, nx); /* set the input data */ printf("Input f:\n"); show(f, nx); printf("Input g:\n"); show(g, nx); fftwpp_hconv1d_convolve(hconv, f, g); printf("Output f:\n"); show(f, nx); delete_complexAlign(g); delete_complexAlign(f); fftwpp_hconv1d_delete(hconv); printf("\n"); } { printf("Complex, non-centered 2D example:\n"); unsigned int nx = 4; unsigned int ny = 4; ImplicitConvolution2 *cconv2 = fftwpp_create_conv2d(nx, ny ); double complex *f = create_complexAlign(nx * ny); double complex *g = create_complexAlign(nx * ny); init2(f, g, nx, ny); /* set the input data */ printf("Input f:\n"); show2(f, nx, ny); printf("Input g:\n"); show2(g, nx, ny); fftwpp_conv2d_convolve(cconv2, f, g); printf("Output f:\n"); show2(f, nx, ny); delete_complexAlign(g); delete_complexAlign(f); fftwpp_conv2d_delete(cconv2); printf("\n"); } { printf("Complex, Hermitian-symmertic, centered 2D example:\n"); unsigned int nx = 4; unsigned int ny = 4; ImplicitHConvolution2 *hconv2 = fftwpp_create_hconv2d(nx, ny ); unsigned int nxp = 2 * nx - 1; double complex *f = create_complexAlign(nxp * ny); double complex *g = create_complexAlign(nxp * ny); init2(f, g, nxp, ny); /* set the input data */ printf("Input f:\n"); show2(f, nxp, ny); printf("Input g:\n"); show2(g, nxp, ny); fftwpp_hconv2d_convolve(hconv2, f, g); printf("Output f:\n"); show2(f, nxp, ny); delete_complexAlign(g); delete_complexAlign(f); fftwpp_hconv2d_delete(hconv2); printf("\n"); } { printf("Complex, non-centered 3D example:\n"); unsigned int nx = 4; unsigned int ny = 4; unsigned int nz = 4; ImplicitConvolution3 *cconv3 = fftwpp_create_conv3d(nx, ny, nz); double complex *f = create_complexAlign(nx * ny * nz); double complex *g = create_complexAlign(nx * ny * nz); init3(f, g, nx, ny, nz); /* set the input data */ printf("Input f:\n"); show3(f, nx, ny, nz); printf("Input g:\n"); show3(g, nx, ny, nz); fftwpp_conv3d_convolve(cconv3, f, g); printf("Output f:\n"); show3(f, nx, ny, nz); delete_complexAlign(g); delete_complexAlign(f); fftwpp_conv3d_delete(cconv3); printf("\n"); } { printf("Complex, non-centered 3D example:\n"); unsigned int nx = 4; unsigned int ny = 4; unsigned int nz = 4; ImplicitConvolution3 *cconv3 = fftwpp_create_conv3d(nx, ny, nz); double complex *f = create_complexAlign(nx * ny * nz); double complex *g = create_complexAlign(nx * ny * nz); init3(f, g, nx, ny, nz); /* set the input data */ printf("Input f:\n"); show3(f, nx, ny, nz); printf("Input g:\n"); show3(g, nx, ny, nz); fftwpp_conv3d_convolve(cconv3, f, g); printf("Output f:\n"); show3(f, nx, ny, nz); delete_complexAlign(g); delete_complexAlign(f); fftwpp_conv3d_delete(cconv3); printf("\n"); } { printf("Complex, Hermitian-symmetric, centered 3D example:\n"); unsigned int nx = 4; unsigned int ny = 4; unsigned int nz = 4; ImplicitHConvolution3 *hconv3 = fftwpp_create_hconv3d(nx, ny, nz); unsigned int nxp = 2 * nx - 1; unsigned int nyp = 2 * ny - 1; double complex *f = create_complexAlign(nxp * nyp * nz); double complex *g = create_complexAlign(nxp * nyp * nz); init3(f, g, nxp, nyp, nz); /* set the input data */ printf("Input f:\n"); show3(f, nxp, nyp, nz); printf("Input g:\n"); show3(g, nxp, nyp, nz); fftwpp_hconv3d_convolve(hconv3, f, g); printf("Output f:\n"); show3(f, nxp, nyp, nz); delete_complexAlign(g); delete_complexAlign(f); fftwpp_hconv3d_delete(hconv3); printf("\n"); } }
int main (int argc, char **argv) { // Optimize allocation for Tornado (2GB hash allocated after 1GB dictionary) AllocTopDown = FALSE; // Operation mode OPMODE global_mode=AUTO; // Record that stores all the info required for ReadWriteCallback static Results r; r.use_cpu_time = r.quiet_title = r.quiet_header = r.quiet_progress = r.quiet_result = FALSE; // Default compression parameters are equivalent to option -5 r.method = std_Tornado_method [default_Tornado_method]; // Delete successfully (de)compressed input files bool delete_input_files = FALSE; // Count of files to process int fcount=0; // Output path/filename const char *output_filename = NULL; // Process options until "--" // 1. First, process -1..-16 option if any for (char **argv_ptr = argv; *++argv_ptr!=NULL; ) { char *param = *argv_ptr; if (*param == '-') { param++; if (strcasecmp(param,"-")==0) break; // "--" is a "stop processing" option else if (isdigit(*param)) r.method = std_Tornado_method[check_parse_int (param, 1, elements(std_Tornado_method)-1, param-1)]; } } // 2. Second, process rest of options for (char **argv_ptr = argv; *++argv_ptr!=NULL; ) { char *param = *argv_ptr; if (param[0] != '-' || param[1]=='\0') { fcount++; } else { param++; int error=0; if (strcasecmp(param,"-")==0) break; else if (strcasecmp(param,"") ==0) continue; else if (strcasecmp(param,"z")==0) global_mode=_COMPRESS; else if (strcasecmp(param,"d")==0) global_mode=_DECOMPRESS; else if (strcasecmp(param,"delete")==0) delete_input_files=TRUE; else if (strcasecmp(param,"t")==0) output_filename=""; else if (strcasecmp(param,"q")==0) r.quiet_title = r.quiet_header = r.quiet_progress = r.quiet_result = TRUE; #ifndef FREEARC_NO_TIMING else if (strcasecmp(param,"cpu")==0) r.use_cpu_time=TRUE; #endif else if (strcasecmp(param,"h")==0) global_mode=HELP; else if (strcasecmp(param,"b")==0) r.method.buffer = MAX_BUFFER_SIZE; // set buffer size to the maximum supported by LZ coders else if (strcasecmp(param,"x")==0) r.method.caching_finder = CACHING_MF4; else if (strcasecmp(param,"xx")==0) r.method.caching_finder = CYCLED_MF4; else if (strcasecmp(param,"x+")==0) r.method.caching_finder = CACHING_MF4; else if (strcasecmp(param,"x-")==0) r.method.caching_finder = NON_CACHING_MF; else if (strcasecmp(param,"t+")==0) r.method.find_tables = TRUE; else if (strcasecmp(param,"t-")==0) r.method.find_tables = FALSE; else if (strcasecmp(param,"t1")==0) r.method.find_tables = TRUE; else if (strcasecmp(param,"t0")==0) r.method.find_tables = FALSE; else if (strcasecmp(param,"s")==0) r.method.hash3 = 1; else if (strcasecmp(param,"ss")==0) r.method.hash3 = 2; else if (strcasecmp(param,"s+")==0) r.method.hash3 = 1; else if (strcasecmp(param,"s-")==0) r.method.hash3 = 0; else if (start_with(param,"fb")) r.method.fast_bytes = check_parse_int (param+2, MIN_FAST_BYTES, MAX_FAST_BYTES, *argv_ptr); #ifdef FREEARC_WIN else if (strcasecmp(param,"slp-")==0) DefaultLargePageMode = DISABLE; else if (strcasecmp(param,"slp" )==0) DefaultLargePageMode = TRY; else if (strcasecmp(param,"slp+")==0) DefaultLargePageMode = FORCE; #endif else if (start_with(param,"rem")) /* ignore option */; else if (isdigit(*param)) ; // -1..-16 option is already processed :) else switch( tolower(*param++) ) { case 'b': r.method.buffer = check_parse_mem (param, MIN_BUFFER_SIZE, MAX_BUFFER_SIZE, *argv_ptr); break; case 'h': r.method.hashsize = check_parse_mem (param, MIN_HASH_SIZE, MAX_HASH_SIZE, *argv_ptr); break; case 'l': r.method.hash_row_width = check_parse_int (param, 1, MAX_HASH_ROW_WIDTH, *argv_ptr); break; case 'u': r.method.update_step = check_parse_int (param, 1, MAX_UPDATE_STEP, *argv_ptr); break; case 'c': r.method.encoding_method = check_parse_int (param, BYTECODER, ARICODER, *argv_ptr); break; case 's': r.method.hash3 = check_parse_int (param, 0, 2, *argv_ptr); break; case 'p': r.method.match_parser = parseInt (param, &error); break; case 'x': r.method.caching_finder = parseInt (param, &error); break; case 'o': output_filename = param; break; case 'q': #ifndef FREEARC_NO_TIMING r.quiet_title = strchr (param, 't'); r.quiet_progress = strchr (param, 'p'); #endif r.quiet_header = strchr (param, 'h'); r.quiet_result = strchr (param, 'r'); break; case 'a': switch( tolower(*param++) ) { case 'h': r.method.auxhash_size = check_parse_mem (param, MIN_HASH_SIZE, MAX_HASH_SIZE, *argv_ptr); goto check_for_errors; case 'l': r.method.auxhash_row_width = check_parse_int (param, 1, MAX_HASH_ROW_WIDTH, *argv_ptr); goto check_for_errors; } // 'a' should be the last case! default : fprintf (stderr, "ERROR: unknown option '%s'\n", *argv_ptr); exit(FREEARC_EXIT_ERROR); } check_for_errors: if (error) { fprintf (stderr, "ERROR: bad option format: '%s'\n", *argv_ptr); exit(FREEARC_EXIT_ERROR); } if (!(r.method.match_parser==GREEDY || r.method.match_parser==LAZY || r.method.match_parser==OPTIMAL)) { fprintf (stderr, "ERROR: bad option value: '%s'\n", *argv_ptr); exit(FREEARC_EXIT_ERROR); } int mf = r.method.caching_finder; r.method.caching_finder = mf = (mf==CACHING_MF4_DUB? CACHING_MF4 : (mf==CYCLED_MF4_DUB? CYCLED_MF4 : mf)); if (!(mf==NON_CACHING_MF || (CYCLED_MF4<=mf && mf<=CYCLED_MF7) || (CACHING_MF4<=mf && mf<=CACHING_MF7) || (BT_MF4<=mf && mf<=BT_MF7))) { fprintf (stderr, "ERROR: non-existing match finder: '%s'\n", *argv_ptr); exit(FREEARC_EXIT_ERROR); } } } // No files to compress: read from stdin and write to stdout if (global_mode!=HELP && fcount==0 && (global_mode!=AUTO || !isatty(0) && !isatty(1)) ) { static char *_argv[] = {argv[0], (char*)"-", NULL}; argv = _argv; fcount = 1; } else if (global_mode==HELP || fcount==0) { char h[100], ah[100], b[100], MinHashSizeStr[100], MaxHashSizeStr[100], MinBufSizeStr[100], MaxBufSizeStr[100]; showMem64 (r.method.hashsize, h); showMem64 (r.method.auxhash_size, ah); showMem64 (r.method.buffer, b); showMem64 (MIN_HASH_SIZE, MinHashSizeStr); showMem64 (MAX_HASH_SIZE+1, MaxHashSizeStr); showMem64 (MIN_BUFFER_SIZE, MinBufSizeStr); showMem64 (MAX_BUFFER_SIZE, MaxBufSizeStr); printf( "Tornado compressor v0.6 (c) [email protected] http://freearc.org 2014-03-08\n" "\n" " Usage: tor [options and files in any order]\n" " -# -- compression level (1..%d), default %d\n", int(elements(std_Tornado_method))-1, default_Tornado_method); printf( " -z -- force compression\n" " -d -- force decompression\n" " -oNAME -- output filename/directory (default %s/%s)\n", COMPRESS_EXT, DECOMPRESS_EXT); printf( " -t -- test (de)compression (redirect output to nul)\n" " -delete -- delete successfully (de)compressed input files\n" #ifdef FREEARC_NO_TIMING " -q -- be quiet; -q[hr]* disables header/results individually\n" #else " -q -- be quiet; -q[thpr]* disables title/header/progress/results individually\n" " -cpu -- compute raw CPU time (for benchmarking)\n" #endif #ifdef FREEARC_WIN " -slp[+/-/] -- force/disable/try(default) large pages support (2mb/4mb)\n" #endif " -rem... -- command-line remark\n" " -h -- display this help\n" " -- -- stop flags processing\n" " \"-\" used as filename means stdin/stdout\n" "\n" " Advanced compression parameters:\n" " -b# -- buffer size (%s..%s), default %s\n", MinBufSizeStr, MaxBufSizeStr, b); printf( " -h# -- hash size (%s..%s-1), default %s\n", MinHashSizeStr, MaxHashSizeStr, h); printf( " -l# -- length of hash row (1..%d), default %d\n", int(MAX_HASH_ROW_WIDTH), r.method.hash_row_width); printf( " -ah# -- auxiliary hash size (%s..%s-1), default %s\n", MinHashSizeStr, MaxHashSizeStr, ah); printf( " -al# -- auxiliary hash row length (1..%d), default %d\n", int(MAX_HASH_ROW_WIDTH), r.method.auxhash_row_width); printf( " -u# -- update step (1..%d), default %d\n", int(MAX_UPDATE_STEP), r.method.update_step); printf( " -c# -- coder (1-bytes, 2-bits, 3-huf, 4-arith), default %d\n", r.method.encoding_method); printf( " -p# -- parser (1-greedy, 2-lazy, 4-optimal), default %d\n", r.method.match_parser); printf( " -x# -- match finder (0: non-caching ht4, 4-7: cycling cached ht4..ht7,\n" " 14-17: shifting cached ht4..ht7, 24-27: bt4..bt7), default %d\n", r.method.caching_finder); printf( " -s# -- 2/3-byte hash (0-disabled, 1-fast, 2-max), default %d\n", r.method.hash3); printf( " -t# -- table diffing (0-disabled, 1-enabled), default %d\n", r.method.find_tables); printf( " -fb# -- fast bytes in the optimal parser (%d..%d), default %d\n", int(MIN_FAST_BYTES), int(MAX_FAST_BYTES), r.method.fast_bytes); printf( "\n" " Predefined methods:\n"); for (int i=1; i<elements(std_Tornado_method); i++) { printf(" %-8d-- %s\n", -i, name(std_Tornado_method[i])); } exit(EXIT_SUCCESS); } // (De)compress all files given on cmdline bool parse_options=TRUE; // options will be parsed until "--" Install_signal_handler(signal_handler); for (char **parameters = argv; *++parameters!=NULL; ) { // If options are still parsed and this argument starts with "-" - it's an option if (parse_options && parameters[0][0]=='-' && parameters[0][1]) { if (strequ(*parameters,"--")) parse_options=FALSE; continue; } // Save input filename r.filename = *parameters; // Select operation mode if it was not specified on cmdline r.mode = global_mode != AUTO? global_mode : end_with (r.filename, COMPRESS_EXT)? _DECOMPRESS : _COMPRESS; // Extension that should be added to output filenames const char *MODE_EXT = r.mode==_COMPRESS? COMPRESS_EXT : DECOMPRESS_EXT; // Construct output filename if (r.mode==BENCHMARK || output_filename && strequ (output_filename, "")) { // Redirect output to nul strcpy (r.outname, ""); } else if (output_filename) { if (strequ(output_filename,"-")) strcpy (r.outname, output_filename); else if (is_path_char (last_char (output_filename))) {sprintf(r.outname, "%s%s", output_filename, drop_dirname(r.filename)); goto add_remove_ext;} else if (dir_exists (output_filename)) {sprintf(r.outname, "%s%c%s", output_filename, PATH_DELIMITER, drop_dirname(r.filename)); goto add_remove_ext;} else strcpy (r.outname, output_filename); } else if (strequ(r.filename,"-")) { strcpy (r.outname, r.filename); } else { // No output filename was given on cmdline: // on compression - add COMPRESS_EXT // on decompression - remove COMPRESS_EXT (and add DECOMPRESS_EXT if file already exists) strcpy (r.outname, r.filename); add_remove_ext: // Remove COMPRESS_EXT on the end of name or add DECOMPRESS_EXT (unless we are in _COMPRESS mode) if (r.mode!=_COMPRESS && end_with (r.outname, COMPRESS_EXT)) { r.outname [strlen(r.outname) - strlen(COMPRESS_EXT)] = '\0'; if (file_exists (r.outname)) strcat(r.outname, MODE_EXT); } else { strcat(r.outname, MODE_EXT); } } // Open input file r.fin = strequ (r.filename, "-")? stdin : file_open_read_binary(r.filename); if (r.fin == NULL) { fprintf (stderr, "\n Can't open %s for read\n", r.filename); exit(FREEARC_EXIT_ERROR); } set_binary_mode (r.fin); // Open output file if (*r.outname) { r.fout = strequ (r.outname, "-")? stdout : file_open_write_binary(r.outname); if (r.fout == NULL) { fprintf (stderr, "\n Can't open %s for write\n", r.outname); exit(FREEARC_EXIT_ERROR); } set_binary_mode (r.fout); } else { r.fout = NULL; } // Prepare to (de)compression int result; char filesize_str[100]; start_print_stats(r); // Perform actual (de)compression switch (r.mode) { case _COMPRESS: { if (!r.quiet_header && r.filesize >= 0) fprintf (stderr, "Compressing %s bytes with %s\n", show3(r.filesize,filesize_str), name(r.method)); PackMethod m = r.method; if (r.filesize >= 0) m.buffer = mymin (m.buffer, r.filesize+LOOKAHEAD*2); result = tor_compress (m, ReadWriteCallback, &r, NULL, -1); break; } case _DECOMPRESS: { //if (!r.quiet_header && !strequ (r.outname, "-")) fprintf (stderr, "Unpacking %.3lf mb\n", double(r.filesize)/1000/1000); result = tor_decompress (ReadWriteCallback, &r, NULL, -1); break; } } // Finish (de)compression print_final_stats(r); fclose (r.fin); if (r.fout) fclose (r.fout); if (result == FREEARC_OK) { if (delete_input_files && !strequ(r.filename,"-")) delete_file(r.filename); } else { if (!strequ(r.outname,"-") && !strequ(r.outname,"")) delete_file(r.outname); switch (result) { case FREEARC_ERRCODE_INVALID_COMPRESSOR: fprintf (stderr, "\nThis compression mode isn't supported by small Tornado version, use full version instead!"); break; case FREEARC_ERRCODE_NOT_ENOUGH_MEMORY: fprintf (stderr, "\nNot enough memory for (de)compression!"); break; case FREEARC_ERRCODE_READ: fprintf (stderr, "\nRead error! Bad media?"); break; case FREEARC_ERRCODE_WRITE: fprintf (stderr, "\nWrite error! Disk full?"); break; case FREEARC_ERRCODE_BAD_COMPRESSED_DATA: fprintf (stderr, "\nData can't be decompressed!"); break; default: fprintf (stderr, "\n(De)compression failed with error code %d!", result); break; } exit(FREEARC_EXIT_ERROR); } // going to next file... } return EXIT_SUCCESS; }
void StatTask() { int i, j, prn; unsigned start = timer_ms(); while (!ready) TaskSleep(1000000); while (1) { UMS lat(StatLat), lon(StatLon); UMS hms(StatSec/60/60); TaskSleep(1000000); if (print_stats == 2) { static int fixes; if (gps.fixes > fixes) { fixes = gps.fixes; if (StatLat) printf("wikimapia.org/#lang=en&lat=%9.6f&lon=%9.6f&z=18&m=b\n", (StatNS=='S')? -StatLat:StatLat, (StatEW=='W')? -StatLon:StatLon); } continue; } printf("\n\n\n\n\n\n"); #if DECIM_CMP printf(" CH PRN SNR CA ERR RSSI GAIN BITS WDOG SUB"); #else // 12345 * 1234 123456 123456 123456 123456 123456 Up12345 123456 ######### printf(" CH PRN SNR RSSI GAIN BITS WDOG SUB NOVFL"); #endif //printf(" LS CS LO SLO DLO CA SCA DCA"); printf("\n"); for (i=0; i<gps_chans; i++) { stats_t *s = &stats[i]; char c1, c2; double snew; printf("%5d %c ", i+1, (stats_fft == i)? '*':' '); show4(prn, prn); show6(snr, snr); #if DECIM_CMP show6(snr, ca_dop); printf(" "); #endif show6(rssi, rssi); show6(rssi, gain); show6(hold, hold); show6(rssi, wdog); printf("%c", s->ca_unlocked? 'U':' '); printf("%c", (s->sub & (1<<(PARITY-1)))? 'p':' '); s->sub &= ~(1<<(PARITY-1)); // clear parity for (j=4; j>=0; j--) { printf("%c", (s->sub & (1<<j))? '1'+j:' '); if (s->sub_next & (1<<j)) { s->sub |= 1<<j; s->sub_next &= ~(1<<j); } } show7(novfl, novfl); printf(" "); #if 0 if (s->rssi) printf("%6d:E %6d:P %6d:L ", s->pe/1000, s->pp/1000, s->pl/1000); #endif #if 0 show3(rssi, lo_dop); show5(rssi, ca_dop); if (s->dir == ' ') s->f_lo=s->lo, s->f_ca=s->ca; snew = fabs(s->f_lo-s->lo); if (snew > s->s_lo) s->s_lo = snew; snew = fabs(s->f_ca-s->ca); if (snew > s->s_ca) s->s_ca = snew; showf7_1(lo, lo); showf7_1(s_lo, s_lo); showf7_1(d_lo, d_lo); showf7_4(ca, ca); showf7_4(s_ca, s_ca); showf7_4(d_ca, d_ca); c1 = c2 = '_'; if (s->rssi) { s->to++; if (s->lo < s->l_lo) { s->l_lo=s->lo; s->dir='v'; s->to=0; c1='v'; } else if (s->lo > s->h_lo) { s->h_lo=s->lo; s->dir='^'; s->to=0; c1='^'; }; if (s->ca < s->l_ca) { s->l_ca=s->ca; s->to=0; c2='v'; } else if (s->ca > s->h_ca) { s->h_ca=s->ca; s->to=0; c2='^'; }; } printf("%c%c ", c1, c2); if (s->rssi) printf("%3d%c ", s->to, s->dir); else printf(" "); #endif //if (s->dbug) printf("%9.6f %9.6f %6d %6d %6d ", // s->dbug_d1, s->dbug_d2, s->dbug_i1, s->dbug_i2, s->dbug_i3); printf(" "); for (j=0; j < s->rssi*50/3000; j++) printf("#"); printf ("\n"); #if DECIM_CMP printf(" "); show6(snr2, snr2); show6(snr2, ca_dop2); show6(snr2, ca_dop-s->ca_dop2); printf ("\n"); #endif } printf("\n"); NextTask("stat1"); printf(" SATS "); if (gps.tracking) printf("tracking %d", gps.tracking); if (gps.good) printf(", good %d", gps.good); printf("\n"); printf(" LAT "); if (StatLat) printf("%9.5fd %c %3dd %2dm %6.3fs %c ", StatLat, StatNS, lat.u, lat.m, lat.s, StatNS); if (StatLat) printf("%3dd %6.3fm %c", lat.u, lat.fm, StatNS); printf("\n"); printf(" LON "); if (StatLat) printf("%9.5fd %c %3dd %2dm %6.3fs %c ", StatLon, StatEW, lon.u, lon.m, lon.s, StatEW); if (StatLat) printf("%3dd %6.3fm %c", lon.u, lon.fm, StatEW); printf("\n"); printf(" ALT "); if (StatLat) printf("%1.0f m", StatAlt); printf("\n"); printf(" TIME "); if (StatDay != -1) printf("%s %02d:%02d:%02.0f GPST", Week[StatDay], hms.u, hms.m, hms.s); printf("\n"); printf("FIXES "); if (gps.fixes) printf("%d", gps.fixes); printf("\n"); printf(" TTFF "); if (stats_ttff) printf("%d:%02d", stats_ttff / 60, stats_ttff % 60); printf("\n"); printf(" RUN "); unsigned r = (timer_ms() - start)/1000; if (r >= 3600) printf("%02d:", r / 3600); printf("%02d:%02d", (r / 60) % 60, r % 60); printf("\n"); printf(" MAP "); if (StatLat) printf("wikimapia.org/#lang=en&lat=%9.6f&lon=%9.6f&z=18&m=b", (StatNS=='S')? -StatLat:StatLat, (StatEW=='W')? -StatLon:StatLon); printf("\n"); printf(" ECPU "); printf("%4.1f%% cmds %d/%d", ecpu_use(), ecpu_cmds, ecpu_tcmds); ecpu_cmds = ecpu_tcmds = 0; printf("\n"); int offset = (int)(adc_clock - adc_clock_nom); printf(" DECIM: %d FFT: %d -> %d CCF: %5.3fs MIN_SIG: %d ADC_CLK: %.6f %s%d (%d) ACQ: %d", decim, FFT_LEN, FFT_LEN/decim, fft_msec, min_sig, adc_clock/1000000.0, (offset >= 0)? "+":"", offset, gps.adc_clk_corr, gps.acquiring); printf("\n"); printf("\n"); NextTask("stat2"); TaskDump(); } }