X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Famindex.c;h=e71fc013d1d3eb490b4e1aafae5e1f5011512133;hb=refs%2Ftags%2Fupstream%2F3.3.1;hp=7c52bd380564043709666ffa4f51a23dbc93f03c;hpb=cd0b924f27312d57bd42f6c4fae2b795139e2d0b;p=debian%2Famanda diff --git a/server-src/amindex.c b/server-src/amindex.c index 7c52bd3..e71fc01 100644 --- a/server-src/amindex.c +++ b/server-src/amindex.c @@ -91,6 +91,63 @@ getindexfname( return buf; } +char * +getheaderfname( + char * host, + char * disk, + char * date, + int level) +{ + char *conf_indexdir; + char *buf; + char level_str[NUM_STR_SIZE]; + char datebuf[14 + 1]; + char *dc = NULL; + char *pc; + int ch; + + if (date != NULL) { + dc = date; + pc = datebuf; + while (pc < datebuf + sizeof(datebuf)) { + ch = *dc++; + *pc++ = (char)ch; + if (ch == '\0') { + break; + } else if (! isdigit (ch)) { + pc--; + } + } + datebuf[sizeof(datebuf)-1] = '\0'; + dc = datebuf; + + g_snprintf(level_str, sizeof(level_str), "%d", level); + } + + host = sanitise_filename(host); + if (disk != NULL) { + disk = sanitise_filename(disk); + } + + conf_indexdir = config_dir_relative(getconf_str(CNF_INDEXDIR)); + /* + * Note: g_strjoin(NULL, ) will stop at the first NULL, which might be + * "disk" or "dc" (datebuf) rather than the full file name. + */ + buf = g_strjoin(NULL, conf_indexdir, "/", + host, "/", + disk, "/", + dc, "_", + level_str, ".header", + NULL); + + amfree(conf_indexdir); + amfree(host); + amfree(disk); + + return buf; +} + char * getoldindexfname( char * host,