Lines 319-331
show_sync_history(const char *logfile)
Link Here
|
319 |
|
319 |
|
320 |
buf = NULL; |
320 |
buf = NULL; |
321 |
while (getline(&buf, &buflen, fp) != -1) { |
321 |
while (getline(&buf, &buflen, fp) != -1) { |
322 |
if (strlen(buf) < 35) |
322 |
/* Possibilities: |
|
|
323 |
* 1417415175: === Sync completed with rsync://... |
324 |
* 1417299771: >>> Git pull successful: /usr/portage |
325 |
* 1417438324: >>> Git clone successful |
326 |
* ^ ^ ^ |
327 |
* 123456789012345678901234567890123456 |
328 |
*/ |
329 |
if (strlen(buf) < 36) |
323 |
continue; |
330 |
continue; |
324 |
if (strncmp(buf+12, "=== Sync completed with", 23) != 0) |
331 |
if (strncmp(buf+12, "=== Sync completed with", 23) != 0 |
|
|
332 |
&& strncmp(buf+12, ">>> Git pull successful:", 24) != 0 |
333 |
&& strncmp(buf+12, ">>> Git clone successful", 24) != 0) |
325 |
continue; |
334 |
continue; |
326 |
|
335 |
|
327 |
if ((p = strchr(buf, '\n')) != NULL) |
336 |
if ((p = strchr(buf, '\n')) != NULL) |
328 |
*p = 0; |
337 |
*p = 0; |
|
|
338 |
/* timestamp */ |
329 |
if ((p = strchr(buf, ':')) == NULL) |
339 |
if ((p = strchr(buf, ':')) == NULL) |
330 |
continue; |
340 |
continue; |
331 |
*p = 0; |
341 |
*p = 0; |
Lines 333-343
show_sync_history(const char *logfile)
Link Here
|
333 |
|
343 |
|
334 |
t = (time_t)atol(buf); |
344 |
t = (time_t)atol(buf); |
335 |
|
345 |
|
336 |
if ((p = strstr(q, "with")) == NULL) |
346 |
if ((p = strstr(q, "with")) != NULL) |
337 |
continue; |
347 |
{ |
338 |
q = p + 5; |
348 |
/* 'Sync completed with' variant */ |
339 |
|
349 |
q = p + 5; |
340 |
printf("%s >>> %s%s%s\n", chop_ctime(t), GREEN, q, NORM); |
350 |
printf("%s >>> %s%s%s\n", chop_ctime(t), GREEN, q, NORM); |
|
|
351 |
} |
352 |
else if ((p = strchr(q, ':')) != NULL) |
353 |
{ |
354 |
/* 'Git pull successful:' variant */ |
355 |
q = p + 2; |
356 |
printf("%s >>> %s%s%s\n", chop_ctime(t), GREEN, q, NORM); |
357 |
} |
358 |
else |
359 |
{ |
360 |
/* '>>> Git clone successful' variant */ |
361 |
printf("%s >>> %s[initial clone]%s\n", chop_ctime(t), GREEN, NORM); |
362 |
} |
341 |
} |
363 |
} |
342 |
|
364 |
|
343 |
free(buf); |
365 |
free(buf); |
344 |
- |
|
|