static git_repository *repo;
+static const char *baseurl = ""; /* base URL to make absolute RSS/Atom URI */
static const char *relpath = "";
static const char *repodir;
xmlencodeline(FILE *fp, const char *s, size_t len)
{
size_t i;
-
- for (i = 0; *s && i < len; s++, i++) {
- switch(*s) {
- case '<': fputs("<", fp); break;
- case '>': fputs(">", fp); break;
- case '\'': fputs("'", fp); break;
- case '&': fputs("&", fp); break;
- case '"': fputs(""", fp); break;
- case '\r': break; /* ignore CR */
- case '\n': break; /* ignore LF */
- default: putc(*s, fp);
- }
- }
-}
-
-/* Escape characters below as HTML 2.0 / XML 1.0, ignore printing '\n', '\r' */
-void
-xmlencodeline(FILE *fp, const char *s, size_t len)
-{
- size_t i;
-
for (i = 0; *s && i < len; s++, i++) {
switch(*s) {
case '<': fputs("<", fp); break;
xmlencode(fp, ci->author->email, strlen(ci->author->email));
fputs("</a>>\n<b>Date:</b> ", fp);
printtime(fp, &(ci->author->when));
- fputc('\n', fp);
+ putc('\n', fp);
}
if (ci->msg) {
- fputc('\n', fp);
+ putc('\n', fp);
xmlencode(fp, ci->msg, strlen(ci->msg));
- fputc('\n', fp);
+ putc('\n', fp);
}
}
xmlencode(fp, ci->summary, strlen(ci->summary));
fputs("</title>\n", fp);
}
- fprintf(fp, "<link rel=\"alternate\" type=\"text/html\" href=\"commit/%s.html\" />\n",
- ci->oid);
+ fprintf(fp, "<link rel=\"alternate\" type=\"text/html\" href=\"%scommit/%s.html\" />\n",
+ baseurl, ci->oid);
if (ci->author) {
fputs("<author>\n<name>", fp);
xmlencode(fp, ci->author->email, strlen(ci->author->email));
fputs(">\nDate: ", fp);
printtime(fp, &(ci->author->when));
- fputc('\n', fp);
+ putc('\n', fp);
}
if (ci->msg) {
- fputc('\n', fp);
+ putc('\n', fp);
xmlencode(fp, ci->msg, strlen(ci->msg));
}
fputs("\n</content>\n</entry>\n", fp);
void
usage(char *argv0)
{
- fprintf(stderr, "%s [-c cachefile | -l commits] repodir\n", argv0);
+ fprintf(stderr, "%s [-c cachefile | -l commits] "
+ "[-u baseurl] repodir\n", argv0);
exit(1);
}
if (argv[i][0] == '\0' || *p != '\0' ||
nlogcommits <= 0 || errno)
usage(argv[0]);
+ } else if (argv[i][1] == 'u') {
+ if (i + 1 >= argc)
+ usage(argv[0]);
+ baseurl = argv[++i];
}
}
if (!repodir)