Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

snapprune.C

Go to the documentation of this file.
00001 
00009 
00010 //   version 1:  Nov 1994   Piet Hut
00011 
00012 #include "node.h"
00013 
00014 /*-----------------------------------------------------------------------------
00015  *  main  --
00016  *-----------------------------------------------------------------------------
00017  */
00018 main(int argc, char ** argv)
00019 {
00020     int  k = 2;    // default: pass half of all snapshots
00021     int  s = 0;    // default: do not skip any snapshpt
00022     int  x = -1;   // default: exit after end of file
00023     bool  c_flag = FALSE;
00024     char  *comment;
00025     
00026     check_help();
00027 
00028     extern char *poptarg;
00029     int c;
00030     char* param_string = "c:k:s:x:";
00031 
00032     while ((c = pgetopt(argc, argv, param_string)) != -1)
00033     switch(c)
00034     {
00035         case 'c': c_flag = TRUE;
00036                   comment = poptarg;
00037                   break;
00038         case 'k': k = atoi(poptarg);
00039                   break;
00040         case 's': s = atoi(poptarg);
00041                   break;
00042         case 'x': x = atoi(poptarg);
00043                   break;
00044         case '?': params_to_usage(cerr, argv[0], param_string);
00045                   get_help();
00046                   exit(1);
00047               }            
00048 
00049     node *b;
00050     for (int i = 0; i < s; i++){
00051         cerr << " skipping snapshot " << i << endl;
00052         if (! forget_node(cin)) exit(1);
00053     }
00054     
00055     
00056     int node_read = 0;
00057     while (b = get_node(cin))
00058     {
00059         node_read++;
00060         if (c_flag == TRUE)
00061         b->log_comment(comment);
00062         b->log_history(argc, argv);
00063         put_node(cout,*b);
00064         rmtree(b);
00065         
00066         for (int i = 1; i < k; i++)
00067           if (! forget_node(cin)) {
00068             exit(1);
00069           }
00070 
00071         if (x>0 && node_read>=x)
00072           exit(1);
00073     }
00074 }
00075 
00076 /* endof: snapprune.c */

Generated at Sun Feb 24 09:57:16 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001