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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
/*
event2html - Convert an event file to html
Note that this is ALPHA software, developed piecemeal while I
was testing various ideas.
Released under the GNU Copyright.
Author: John Lines <john@paladin.demon.co.uk>
Things to do
Does not handle header tags (They should be displayed differently at the
start of the html output - we probably dont want version tags etc)
Should allow arguments to select tags which will not be displayed,
and much more
*/
#include <stdio.h>
#include <stdlib.h>
#include "tagtypes.h"
void parseargs(int argc,char *argv[]);
void puthtmlrec(FILE *f, struct tagrecord *rec);
int main(int argc, char *argv[]) {
int recbufsize=10000; /* Size of a record buffer */
struct tagrecord *record;
struct tagrecord *header;
char *fieldbuffer;
char EventsDir[40];
parseargs(argc,argv);
opentagdefaults();
gettagdefval("Events-dir",EventsDir);
closetagdefaults();
fieldbuffer=malloc(recbufsize);
header=gettagrec(stdin, fieldbuffer);
freetagrec(header); /* we dont use it at all at the moment */
fprintf(stdout,"<dl>\n");
while (!feof(stdin)) {
record=gettagrec(stdin,fieldbuffer);
puthtmlrec(stdout,record);
freetagrec(record);
}
fprintf(stdout,"</dl>\n");
return 0;
}
void parseargs(int argc,char *argv[])
{
}
void puthtmlrec(FILE *f, struct tagrecord *rec)
{
struct tagrecord *current;
current=rec;
if (current==0) return;
/*
here we could write out a title taken from the command line, and maybe
other bits of info
If we get really flash then we could read the input twice (save to /tmp
if it was being read from stdin) and then generate an index.
- alternatively we could read the whole file into memory before we start
to generate output - it is probably best to leave all such fiddles as
options
*/
while (current!=0) {
if (strcmp(current->tagname,"Date")==0) {
fprintf(f,"<dt>%s<dd>",current->value);
}
if (strcmp(current->tagname,"Title") ==0) {
fprintf(f,"%s\n", current->value);
}
current=current->next;
}
}
|