2 #include "../csm/csm_all.h" 4 int main(
int argc,
const char * argv[]) {
8 const char*input_filename;
9 const char*output_filename;
12 options_int(ops,
"period", &period, 1,
"Period of objects to extract.");
13 options_int(ops,
"phase", &phase, 0,
"Phase (=0 starts with the first object)");
14 options_string(ops,
"in", &input_filename,
"stdin",
"input file (JSON)");
15 options_string(ops,
"out", &output_filename,
"stdout",
"output file (JSON)");
18 fprintf(stderr,
"%s : decimates a JSON stream." 19 "\n\nOptions:\n", argv[0]);
32 if(!input_stream || !output_stream)
return -1;
39 if(feof(input_stream))
break;
44 if( (count - phase) % period == 0) {
46 fputs(s,output_stream); fputs(
"\n",output_stream);
void sm_set_program_name(const char *name)
FILE * open_file_for_writing(const char *filename)
struct option * options_allocate(int n)
const char * json_object_to_json_string(struct json_object *this)
void options_int(struct option *, const char *name, int *p, int def_value, const char *desc)
FILE * open_file_for_reading(const char *filename)
void options_print_help(struct option *options, FILE *f)
void options_string(struct option *, const char *name, const char **p, const char *def_balue, const char *desc)
JO json_read_stream(FILE *f)
void sm_error(const char *msg,...)
int options_parse_args(struct option *ops, int argc, const char *argv[])
int main(int argc, const char *argv[])