-
Notifications
You must be signed in to change notification settings - Fork 1
/
history.c
41 lines (39 loc) · 835 Bytes
/
history.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <time.h>
#include "db.h"
#include "object.h"
#include "history.h"
void
history(int n)
{
dr_t h;
int i = 0;
struct release rel;
h = db_readhead(&rel, NULL);
if (h->size == 0) {
printf("Empty db\n");
} else {
for (;;) {
struct tm *t;
char datetime[200];
t = localtime(&rel.time);
strftime(datetime, sizeof(datetime),
"%a %b %d %H:%M:%S %Z", t);
printf("release:%s\n", h->buf);
printf("finger:%s\n", rel.finger->buf);
printf("Version:%s\n", rel.ver->buf);
printf("Date:%s\n", datetime);
printf("\n\t%s\n\n", rel.note->buf);
if (rel.prev->size <= 0 || (n > 0 && ++i >= n))
break;
dr_unref(h);
h = dr_ref(rel.prev);
release_destroy(&rel);
memset(&rel, 0, sizeof(rel));
db_readrel(&rel, h);
}
}
dr_unref(h);
release_destroy(&rel);
return ;
}