void roadmap_log (int level, const char *source, int line, const char *format, ...) { va_list ap; char saved = ' '; struct roadmap_message_descriptor *category; char *debug; if (level < roadmap_verbosity()) return; #if(defined DEBUG && defined SKIP_DEBUG_LOGS) return; #endif // SKIP_DEBUG_LOGS debug = roadmap_debug(); if ((debug[0] != 0) && (strcmp (debug, source) != 0)) return; for (category = RoadMapMessageHead; category->level != 0; ++category) { if (category->level == level) break; } va_start(ap, format); if (category->save_to_file) { static int open_file_attemped = 0; if ((sgLogFile == NULL) && (!open_file_attemped)) { open_file_attemped = 1; sgLogFile = roadmap_file_fopen (roadmap_log_path(), roadmap_log_filename(), roadmap_log_access_mode()); if (sgLogFile) fprintf (sgLogFile, "*** Starting log file %d ***", (int)time(NULL)); } if (sgLogFile != NULL) { roadmap_log_one (category, sgLogFile, ' ', source, line, format, ap); fflush (sgLogFile); //fclose (file); va_end(ap); va_start(ap, format); saved = 's'; } } #ifdef __SYMBIAN32__ //roadmap_log_one (category, __stderr(), saved, source, line, format, ap); #else #if(defined WIN32PC && defined _DEBUG) show_logs_in_debugger( category, format, ap); #endif // WIN32PC Debug roadmap_log_one (category, stderr, saved, source, line, format, ap); #endif va_end(ap); if( category->do_exit) #ifdef FREEZE_ON_FATAL_ERROR { int beep_times = 20; int sleep_time = 1000; do { Sleep( sleep_time); if( beep_times) { fprintf( sgLogFile, ">>> FATAL ERROR - WAITING FOR PROCESS TO BE ATTACHED BY A DEBUGGER...\r\n"); MessageBeep(MB_OK); beep_times--; if(!beep_times) sleep_time = 5000; } } while(1); } #else exit(1); #endif // FREEZE_ON_FATAL_ERROR }
/////////////////////////////////////////////////////// // Compress files and prepare for upload int prepare_for_upload () { int res; char out_filename[256]; char **files; char **cursor; const char* directory; int count; int total; time_t now; struct tm *tms; char year[5], month[5], day[5]; #ifdef RIMAPI timeStruct time_s; #endif sprintf (warning_message,"%s",roadmap_lang_get("Preparing files for upload...")); ssd_progress_msg_dialog_show(warning_message); roadmap_main_flush(); //Count files for upload directory = roadmap_path_gps(); files = roadmap_path_list (directory, ".csv"); count = 1; //Counting also the postmortem for (cursor = files; *cursor != NULL; ++cursor) { count++; } total = count; count = 0; //Prepare log count++; sprintf (warning_message,"%s\n%d/%d",roadmap_lang_get("Preparing files for upload..."),count, total); ssd_progress_msg_dialog_show(warning_message); roadmap_main_flush(); // Building the filename time( &now ); tms = localtime( &now ); #ifdef RIMAPI roadmap_time_get_time(&time_s); tms->tm_hour = time_s.hours; tms->tm_min = time_s.minutes; #endif GET_2_DIGIT_STRING( tms->tm_mday, day ); GET_2_DIGIT_STRING( tms->tm_mon+1, month ); // Zero based from January GET_2_DIGIT_STRING( tms->tm_year-100, year ); // Year from 1900 snprintf(out_filename,256, "%s%s%s__%d_%d__%s_%d_%s__%s.gz", day, month, year, tms->tm_hour, tms->tm_min, RealTime_GetUserName(), RT_DEVICE_ID, roadmap_start_version(), roadmap_log_filename()); #ifndef RIMAPI res = roadmap_zlib_compress(roadmap_log_path(), roadmap_log_filename(), roadmap_path_debug(), out_filename, COMPRESSION_LEVEL,TRUE); #else // 0 = Z_OK = SUCCESS. 1 = failure. res = NOPH_ZLib_compress(roadmap_log_path(), roadmap_log_filename(), roadmap_path_debug(),out_filename,COMPRESSION_LEVEL); strcpy(zipped_log_name,out_filename); // emporary until path_list is implemented #endif if (res != Z_OK) { ssd_progress_msg_dialog_hide(); return 0; } //Prepare CSV files for (cursor = files; *cursor != NULL; ++cursor) { count++; sprintf (warning_message,"%s\n%d/%d",roadmap_lang_get("Preparing files for upload..."),count, total); ssd_progress_msg_dialog_show(warning_message); roadmap_main_flush(); sprintf(out_filename, "%s%s.gz", *cursor, RealTime_GetUserName()); #ifndef J2ME res = roadmap_zlib_compress(directory, *cursor, roadmap_path_debug(), out_filename, COMPRESSION_LEVEL,FALSE); #else // 0 = Z_OK = SUCCESS. 1 = failure. res = NOPH_ZLib_compress(directory, *cursor, roadmap_path_debug(),out_filename,COMPRESSION_LEVEL); #endif if (res != Z_OK) { ssd_progress_msg_dialog_hide(); return 0; } else { roadmap_file_remove(directory, *cursor); } } roadmap_path_list_free (files); ssd_progress_msg_dialog_hide(); return 1; }