/* *************************************************************************** * Read statistics from a system activity data file. * * IN: * @from_file Input file name. *************************************************************************** */ void read_stats_from_file(char from_file[]) { struct file_magic file_magic; struct file_activity *file_actlst = NULL; int curr = 1, i, p; int ifd, rtype; int rows, eosaf = TRUE, reset = FALSE; long cnt = 1; off_t fpos; /* Get window size */ rows = get_win_height(); /* Read file headers and activity list */ check_file_actlst(&ifd, from_file, act, &file_magic, &file_hdr, &file_actlst, id_seq, FALSE); /* Perform required allocations */ allocate_structures(act); /* Print report header */ print_report_hdr(flags, &rectime, &file_hdr, act[get_activity_position(act, A_CPU)]->nr); /* Read system statistics from file */ do { /* * If this record is a special (RESTART or COMMENT) one, print it and * (try to) get another one. */ do { if (sa_fread(ifd, &record_hdr[0], RECORD_HEADER_SIZE, SOFT_SIZE)) /* End of sa data file */ return; rtype = record_hdr[0].record_type; if ((rtype == R_RESTART) || (rtype == R_COMMENT)) { sar_print_special(0, tm_start.use, tm_end.use, rtype, ifd, from_file, &file_magic); } else { /* * OK: Previous record was not a special one. * So read now the extra fields. */ read_file_stat_bunch(act, 0, ifd, file_hdr.sa_act_nr, file_actlst); if (sar_get_record_timestamp_struct(0)) /* * An error was detected. * The timestamp hasn't been updated. */ continue; } } while ((rtype == R_RESTART) || (rtype == R_COMMENT) || (tm_start.use && (datecmp(&rectime, &tm_start) < 0)) || (tm_end.use && (datecmp(&rectime, &tm_end) >=0))); /* Save the first stats collected. Will be used to compute the average */ copy_structures(act, id_seq, record_hdr, 2, 0); reset = TRUE; /* Set flag to reset last_uptime variable */ /* Save current file position */ if ((fpos = lseek(ifd, 0, SEEK_CUR)) < 0) { perror("lseek"); exit(2); } /* * Read and write stats located between two possible Linux restarts. * Activities that should be displayed are saved in id_seq[] array. */ for (i = 0; i < NR_ACT; i++) { if (!id_seq[i]) continue; if ((p = get_activity_position(act, id_seq[i])) < 0) { /* Should never happen */ PANIC(1); } if (!IS_SELECTED(act[p]->options)) continue; if (!HAS_MULTIPLE_OUTPUTS(act[p]->options)) { handle_curr_act_stats(ifd, fpos, &curr, &cnt, &eosaf, rows, act[p]->id, &reset, file_actlst, from_file, &file_magic); } else { unsigned int optf, msk; optf = act[p]->opt_flags; for (msk = 1; msk < 0x10; msk <<= 1) { if (act[p]->opt_flags & msk) { act[p]->opt_flags &= msk; handle_curr_act_stats(ifd, fpos, &curr, &cnt, &eosaf, rows, act[p]->id, &reset, file_actlst, from_file, &file_magic); act[p]->opt_flags = optf; } } } } if (!cnt) { /* Go to next Linux restart, if possible */ do { eosaf = sa_fread(ifd, &record_hdr[curr], RECORD_HEADER_SIZE, SOFT_SIZE); rtype = record_hdr[curr].record_type; if (!eosaf && (rtype != R_RESTART) && (rtype != R_COMMENT)) { read_file_stat_bunch(act, curr, ifd, file_hdr.sa_act_nr, file_actlst); } else if (!eosaf && (rtype == R_COMMENT)) { /* This was a COMMENT record: print it */ sar_print_special(curr, tm_start.use, tm_end.use, R_COMMENT, ifd, from_file, &file_magic); } } while (!eosaf && (rtype != R_RESTART)); } /* The last record we read was a RESTART one: Print it */ if (!eosaf && (record_hdr[curr].record_type == R_RESTART)) { sar_print_special(curr, tm_start.use, tm_end.use, R_RESTART, ifd, from_file, &file_magic); } } while (!eosaf); close(ifd); free(file_actlst); }
void HPanEntry(Evas *e, Evas_Object *obj,const char *startval) { hpanentrybox=init_entrybox(e,"Hor. Panning Inc.",startval,3,hpan_entryhandler,obj); int x,y,w,h; evas_object_geometry_get(hpanentrybox,&x,&y,&w,&h); evas_object_move(hpanentrybox,(int)(((double)get_win_width()-w)/2.0),(int)(((double)get_win_height()-h)/2.0)); }
/* *************************************************************************** * Read statistics sent by sadc, the data collector. *************************************************************************** */ void read_stats(void) { int curr = 1; unsigned long lines; unsigned int rows = 23; int dis_hdr = 0; /* Don't buffer data if redirected to a pipe... */ setbuf(stdout, NULL); /* Read stats header */ read_header_data(); if (!get_activity_nr(act, AO_SELECTED, COUNT_ACTIVITIES)) { fprintf(stderr, _("Requested activities not available\n")); exit(1); } /* Determine if a stat line header has to be displayed */ dis_hdr = check_line_hdr(); lines = rows = get_win_height(); /* Perform required allocations */ allocate_structures(act); /* Print report header */ print_report_hdr(flags, &rectime, &file_hdr, act[get_activity_position(act, A_CPU)]->nr); /* Read system statistics sent by the data collector */ read_sadc_stat_bunch(0); if (!interval) { /* Display stats since boot time and exit */ write_stats_startup(0); } /* Save the first stats collected. Will be used to compute the average */ copy_structures(act, id_seq, record_hdr, 2, 0); /* Set a handler for SIGINT */ memset(&int_act, 0, sizeof(int_act)); int_act.sa_handler = (void *) int_handler; int_act.sa_flags = SA_RESTART; sigaction(SIGINT, &int_act, NULL); /* Main loop */ do { /* Get stats */ read_sadc_stat_bunch(curr); /* Print results */ if (!dis_hdr) { dis = lines / rows; if (dis) { lines %= rows; } lines++; } write_stats(curr, USE_SADC, &count, NO_TM_START, tm_end.use, NO_RESET, ALL_ACTIVITIES); if (record_hdr[curr].record_type == R_LAST_STATS) { /* File rotation is happening: Re-read header data sent by sadc */ read_header_data(); allocate_structures(act); } if (count > 0) { count--; } if (count) { if (sigint_caught) { /* SIGINT signal caught => Display average stats */ count = 0; } else { curr ^= 1; } } } while (count); /* Print statistics average */ dis = dis_hdr; write_stats_avg(curr, USE_SADC, ALL_ACTIVITIES); }
void TOCDialog(Evas *e, Evas_Object *obj,Ecore_List *list) { int numchoices=ecore_list_count(list); char **initchoices; //char **values; initchoices=(char **)malloc(sizeof(char*)*numchoices); //values=(char **)malloc(sizeof(char*)*numchoices); ecore_list_first_goto(list); int i; for(i=0;i<numchoices;i++) { asprintf(&(initchoices[i]),"%d. %s",(i%8+1),epdf_index_item_title_get((Epdf_Index_Item *)ecore_list_next(list))); } Evas_Object *tocchoicebox=init_choicebox(e,(const char**)initchoices,NULL, numchoices, toc_choicehandler, "Table of Contents",obj,(void *)list, true); for(i=0;i<numchoices;i++) { free(initchoices[i]); } //free(values); free(initchoices); int x,y,w,h; evas_object_geometry_get(tocchoicebox,&x,&y,&w,&h); evas_object_move(tocchoicebox,(int)(((double)get_win_width()-w)/2.0),(int)(((double)get_win_height()-h)/2.0)); }
void GotoPageEntry(Evas *e, Evas_Object *obj) { char *tempstr; asprintf(&tempstr,"Page? (%d/%d)",get_cur_page()+1,get_num_pages()); gotopageentrybox=init_entrybox(e,tempstr,"",4,goto_page_entryhandler,obj); free(tempstr); int x,y,w,h; evas_object_geometry_get(gotopageentrybox,&x,&y,&w,&h); evas_object_move(gotopageentrybox,(int)(((double)get_win_width()-w)/2.0),(int)(((double)get_win_height()-h)/2.0)); }
void PreferencesDialog(Evas *e, Evas_Object *obj) { const char *initchoices[] = { "1. Hor. Panning", "2. Ver. Panning", "3. Trimming", "4. Zoom Increment", "5. Fit Mode", "6. Antialias", "7. Reader Mode", }; char *zoom; asprintf(&zoom,"%d%%",(int)(get_zoom_inc()*100)); char *hpan; asprintf(&hpan,"%d%%",(int)(get_hpan_inc()*100)); char *vpan; asprintf(&vpan,"%d%%",(int)(get_vpan_inc()*100)); const char *values[] = { hpan, vpan, "", zoom, FIT_STRINGS[get_fit_mode()], OFF_ON_STRINGS[get_antialias_mode()], OFF_ON_STRINGS[get_reader_mode()], }; preferenceschoicebox=init_choicebox(e,initchoices, values, 7, preferences_choicehandler, "LoCoPDF Settings",obj, NULL,true); int x,y,w,h; evas_object_geometry_get(preferenceschoicebox,&x,&y,&w,&h); evas_object_move(preferenceschoicebox,(int)(((double)get_win_width()-w)/2.0),(int)(((double)get_win_height()-h)/2.0)); free(zoom); free(hpan); free(vpan); }
void TrimmingDialog(Evas *e, Evas_Object *obj) { const char *initchoices[] = { "1. Left Trimming", "2. Right Trimming", "3. Top Trimming", "4. Bottom Trimming", }; char *lefttrim,*righttrim,*toptrim,*bottomtrim; asprintf(&lefttrim,"%dpx",get_lefttrim()); asprintf(&righttrim,"%dpx",get_righttrim()); asprintf(&toptrim,"%dpx",get_toptrim()); asprintf(&bottomtrim,"%dpx",get_bottomtrim()); const char *values[] = { lefttrim, righttrim, toptrim, bottomtrim, }; trimmingchoicebox=init_choicebox(e,initchoices, values, 4, trimming_choicehandler, "Trimming Settings",obj, NULL,true); int x,y,w,h; evas_object_geometry_get(trimmingchoicebox,&x,&y,&w,&h); evas_object_move(trimmingchoicebox,(int)(((double)get_win_width()-w)/2.0),(int)(((double)get_win_height()-h)/2.0)); free(lefttrim); free(righttrim); free(toptrim); free(bottomtrim); }
void FitModeDialog(Evas *e, Evas_Object *obj) { const char *initchoices[] = { "1. Fit Width", "2. Fit Height", "3. Best Fit", "4. Stretch Fit", "5. No Fit", }; const char *values[] = { "", "", "", "", "", }; fitmodechoicebox=init_choicebox(e,initchoices, values, 5, fitmode_choicehandler, "Fit Mode Settings",obj,NULL, true); int x,y,w,h; evas_object_geometry_get(fitmodechoicebox,&x,&y,&w,&h); evas_object_move(fitmodechoicebox,(int)(((double)get_win_width()-w)/2.0),(int)(((double)get_win_height()-h)/2.0)); }
void BottomTrimEntry(Evas *e, Evas_Object *obj,const char *startval) { bottomtrimentrybox=init_entrybox(e,"Bottom Trimming.",startval,3,bottomtrim_entryhandler,obj); int x,y,w,h; evas_object_geometry_get(bottomtrimentrybox,&x,&y,&w,&h); evas_object_move(bottomtrimentrybox,(int)(((double)get_win_width()-w)/2.0),(int)(((double)get_win_height()-h)/2.0)); }
void ZoomEntry(Evas *e, Evas_Object *obj,const char *startval) { zoomentrybox=init_entrybox(e,"Zoom Inc.",startval,3,zoom_entryhandler,obj); int x,y,w,h; evas_object_geometry_get(zoomentrybox,&x,&y,&w,&h); evas_object_move(zoomentrybox,(int)(((double)get_win_width()-w)/2.0),(int)(((double)get_win_height()-h)/2.0)); }