00001
00011
00012 #include "dyn.h"
00013
00014 #ifdef TOOLBOX
00015
00016 main(int argc, char ** argv)
00017 {
00018 char *comment;
00019 bool c_flag = FALSE;
00020
00021 real t_extract;
00022 bool t_flag = FALSE;
00023
00024 bool v_flag = FALSE;
00025
00026 int n = 1;
00027 bool n_flag = false;
00028
00029 check_help();
00030
00031 extern char *poptarg;
00032 int c;
00033 char* param_string = "c:n:t:v";
00034
00035 while ((c = pgetopt(argc, argv, param_string)) != -1)
00036 switch(c) {
00037 case 'c': c_flag = TRUE;
00038 comment = poptarg;
00039 break;
00040 case 't': t_flag = TRUE;
00041 t_extract = atof(poptarg);
00042 break;
00043 case 'n': n_flag = TRUE;
00044 n = atoi(poptarg);
00045 break;
00046 case 'v': v_flag = TRUE;
00047 break;
00048 case '?': params_to_usage(cerr, argv[0], param_string);
00049 get_help();
00050 exit(1);
00051 }
00052
00053 if (n < 0) err_exit("n < 0 specified.");
00054 if (n > 1 && !t_flag) {
00055 warning("n > 1 but no time specified -- 0 assumed.");
00056 t_extract = 0;
00057 t_flag = true;
00058 }
00059
00060 dyn *b = NULL, *bp = NULL;
00061 int i = 0;
00062
00063 while (b = get_dyn(cin)) {
00064
00065 real time = b->get_system_time();
00066 i++;
00067
00068 if (v_flag) cerr << "Snap time #" << i << " = " << time << endl;
00069
00070 if (t_flag && time >= t_extract) {
00071
00072 if (n > 0) {
00073
00074 if (c_flag == TRUE)
00075 b->log_comment(comment);
00076
00077 b->log_history(argc, argv);
00078 put_dyn(cout, *b);
00079 }
00080
00081 if (--n <= 0) exit(0);
00082 }
00083
00084 if (bp != NULL)
00085 rmtree(bp);
00086
00087 bp = b;
00088 }
00089
00090 if (n > 0 && !t_flag) {
00091 bp->log_history(argc, argv);
00092 put_dyn(cout, *bp);
00093 }
00094
00095 }
00096
00097 #endif