ref: e23fd2fce14cd0ea17a924503c334f9d63b8470a
dir: /pim.c/
#include <u.h> #include <libc.h> #include <bio.h> #include <String.h> #include "libvcard/vcard.h" extern void _vc_t_fold(char*); void printparams(Vparam *p) { for (; p; p = p->next) { fprint(2, " param: %s → %s\n", p->name, p->value); } } void main(int argc, char **argv) { String *s; Biobuf *b; Vcard *vc, *card; Vline *vl; ARGBEGIN{ case 'h': break; }ARGEND; if (argc < 1) sysfatal("usage"); b = Bopen(argv[0], OREAD); if (!b) sysfatal("%r"); s = s_new(); while (s_read(b, s, 256) > 0) continue; Bterm(b); _vc_t_fold(s_to_c(s)); fprint(2, "%s\n\n", s_to_c(s)); vc = vcparse(s_to_c(s)); if (!vc) sysfatal("err: %r"); fprint(2, "printing results:\n\n"); for (card = vc; card; card = card->next) { fprint(2, "NEW CARD\n"); for (vl = card->content; vl; vl = vl->next) { fprint(2, "%s → %s\n", vl->name, vl->value); if (vl->params) printparams(vl->params); } } exits(nil); }