dav/sync.c

changeset 784
592ff4ca2aaa
parent 783
36a7f2ea7d12
child 788
9b9420041d8e
equal deleted inserted replaced
783:36a7f2ea7d12 784:592ff4ca2aaa
70 70
71 static int sync_shutdown = 0; 71 static int sync_shutdown = 0;
72 72
73 static FILE *synclog; 73 static FILE *synclog;
74 74
75 static int orig_argc;
76 static char **orig_argv;
77
75 static void xmlerrorfnc(void * c, const char * msg, ... ) { 78 static void xmlerrorfnc(void * c, const char * msg, ... ) {
76 va_list ap; 79 va_list ap;
77 va_start(ap, msg); 80 va_start(ap, msg);
78 vfprintf(stderr, msg, ap); 81 vfprintf(stderr, msg, ap);
79 va_end(ap); 82 va_end(ap);
139 142
140 synclog = fopen(lf_path, "a"); 143 synclog = fopen(lf_path, "a");
141 if(!synclog) { 144 if(!synclog) {
142 fprintf(stderr, "Cannot open logfile %s: %s\n", lf_path, strerror(errno)); 145 fprintf(stderr, "Cannot open logfile %s: %s\n", lf_path, strerror(errno));
143 ret = 1; 146 ret = 1;
147 } else {
148 time_t t = time(NULL);
149 char *now = ctime(&t);
150 size_t len = strlen(now);
151 if(now[len-1] == '\n') {
152 len--;
153 }
154
155 fprintf(synclog, "[%.*s] ", (int)len, now);
156 for(int i=0;i<orig_argc;i++) {
157 fprintf(synclog, "%s ", orig_argv[i]);
158 }
159 fprintf(synclog, "\n");
144 } 160 }
145 if(lf_path_fr) { 161 if(lf_path_fr) {
146 free(lf_path_fr); 162 free(lf_path_fr);
147 } 163 }
148 } 164 }
244 return dav_sync_main(argc, argv); 260 return dav_sync_main(argc, argv);
245 } 261 }
246 #endif 262 #endif
247 263
248 int dav_sync_main(int argc, char **argv) { 264 int dav_sync_main(int argc, char **argv) {
265 orig_argc = argc;
266 orig_argv = argv;
267
249 if(argc < 2) { 268 if(argc < 2) {
250 fprintf(stderr, "Missing command\n"); 269 fprintf(stderr, "Missing command\n");
251 print_usage(argv[0]); 270 print_usage(argv[0]);
252 return -1; 271 return -1;
253 } 272 }

mercurial