summaryrefslogtreecommitdiffabout
path: root/cgit.h
authorLars Hjemli <hjemli@gmail.com>2007-05-22 21:08:46 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-05-22 21:12:41 (UTC)
commit5db39170b6c979655a0238dcd627e206febed88b (patch) (unidiff)
tree2c79691bde31f9db2861dc76010691e9dbdde1cb /cgit.h
parent3b86b44fc761cfa8b97c44bbbdd63c9fbf1127ed (diff)
downloadcgit-5db39170b6c979655a0238dcd627e206febed88b.zip
cgit-5db39170b6c979655a0238dcd627e206febed88b.tar.gz
cgit-5db39170b6c979655a0238dcd627e206febed88b.tar.bz2
Add cgit_print_age() function
This function can be used to print relative dates, just as in gitweb. Next step will be to actually use the new function. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'cgit.h') (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/cgit.h b/cgit.h
index 8927236..4da2d3d 100644
--- a/cgit.h
+++ b/cgit.h
@@ -20,24 +20,43 @@
20 20
21/* 21/*
22 * The valid cgit repo-commands 22 * The valid cgit repo-commands
23 */ 23 */
24#define CMD_LOG 1 24#define CMD_LOG 1
25#define CMD_COMMIT 2 25#define CMD_COMMIT 2
26#define CMD_DIFF 3 26#define CMD_DIFF 3
27#define CMD_TREE 4 27#define CMD_TREE 4
28#define CMD_VIEW 5 28#define CMD_VIEW 5
29#define CMD_BLOB 6 29#define CMD_BLOB 6
30#define CMD_SNAPSHOT 7 30#define CMD_SNAPSHOT 7
31 31
32
33/*
34 * Dateformats used on misc. pages
35 */
36#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S"
37#define FMT_SHORTDATE "%Y-%m-%d"
38
39
40/*
41 * Limits used for relative dates
42 */
43#define TM_MIN 60
44#define TM_HOUR (TM_MIN * 60)
45#define TM_DAY (TM_HOUR * 24)
46#define TM_WEEK (TM_DAY * 7)
47#define TM_YEAR (TM_DAY * 365)
48#define TM_MONTH (TM_YEAR / 12.0)
49
50
32typedef void (*configfn)(const char *name, const char *value); 51typedef void (*configfn)(const char *name, const char *value);
33typedef void (*filepair_fn)(struct diff_filepair *pair); 52typedef void (*filepair_fn)(struct diff_filepair *pair);
34typedef void (*linediff_fn)(char *line, int len); 53typedef void (*linediff_fn)(char *line, int len);
35 54
36struct cacheitem { 55struct cacheitem {
37 char *name; 56 char *name;
38 struct stat st; 57 struct stat st;
39 int ttl; 58 int ttl;
40 int fd; 59 int fd;
41}; 60};
42 61
43struct repoinfo { 62struct repoinfo {
@@ -172,25 +191,26 @@ extern void cgit_parse_url(const char *url);
172extern char *cache_safe_filename(const char *unsafe); 191extern char *cache_safe_filename(const char *unsafe);
173extern int cache_lock(struct cacheitem *item); 192extern int cache_lock(struct cacheitem *item);
174extern int cache_unlock(struct cacheitem *item); 193extern int cache_unlock(struct cacheitem *item);
175extern int cache_cancel_lock(struct cacheitem *item); 194extern int cache_cancel_lock(struct cacheitem *item);
176extern int cache_exist(struct cacheitem *item); 195extern int cache_exist(struct cacheitem *item);
177extern int cache_expired(struct cacheitem *item); 196extern int cache_expired(struct cacheitem *item);
178 197
179extern char *cgit_repourl(const char *reponame); 198extern char *cgit_repourl(const char *reponame);
180extern char *cgit_pageurl(const char *reponame, const char *pagename, 199extern char *cgit_pageurl(const char *reponame, const char *pagename,
181 const char *query); 200 const char *query);
182 201
183extern void cgit_print_error(char *msg); 202extern void cgit_print_error(char *msg);
184extern void cgit_print_date(unsigned long secs); 203extern void cgit_print_date(time_t secs, char *format);
204extern void cgit_print_age(time_t t, time_t max_relative, char *format);
185extern void cgit_print_docstart(char *title, struct cacheitem *item); 205extern void cgit_print_docstart(char *title, struct cacheitem *item);
186extern void cgit_print_docend(); 206extern void cgit_print_docend();
187extern void cgit_print_pageheader(char *title, int show_search); 207extern void cgit_print_pageheader(char *title, int show_search);
188extern void cgit_print_snapshot_start(const char *mimetype, 208extern void cgit_print_snapshot_start(const char *mimetype,
189 const char *filename, 209 const char *filename,
190 struct cacheitem *item); 210 struct cacheitem *item);
191 211
192extern void cgit_print_repolist(struct cacheitem *item); 212extern void cgit_print_repolist(struct cacheitem *item);
193extern void cgit_print_summary(); 213extern void cgit_print_summary();
194extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path); 214extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path);
195extern void cgit_print_view(const char *hex, char *path); 215extern void cgit_print_view(const char *hex, char *path);
196extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); 216extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path);