00001 #include "../csm/csm_all.h" 00002 #include <options/options.h> 00003 00004 int main(int argc, const char * argv[]) { 00005 sm_set_program_name(argv[0]); 00006 00007 int n; 00008 00009 struct option* ops = options_allocate(3); 00010 options_int(ops, "n", &n, 1, "Number of copies"); 00011 if(!options_parse_args(ops, argc, argv)) { 00012 sm_info("%s : reads a JSON stream and copies it multiplied by n." 00013 "\n\nOptions:\n", (char*)argv[0]); 00014 options_print_help(ops, stderr); 00015 return -1; 00016 } 00017 00018 00019 while(1) { 00020 JO jo = json_read_stream(stdin); 00021 if(!jo) { 00022 if(feof(stdin)) break; 00023 sm_error("Malformed JSON\n"); 00024 return -1; 00025 } 00026 00027 const char * s = json_object_to_json_string(jo); 00028 int i; for(i=0;i<n;i++) { 00029 puts(s); puts("\n"); 00030 } 00031 jo_free(jo); 00032 } 00033 00034 return 0; 00035 }