rohrpost

A commandline mail client to change the world as we see it.
git clone git://r-36.net/rohrpost
Log | Files | Refs | README | LICENSE

parsetest.c (1095B)


      1 /*
      2  * Copy me if you can.
      3  * by 20h
      4  *
      5  * % make parsetest
      6  * % cat ../proto/parsetest.example | socat - tcp-l:5600,reuseaddr
      7  * % ./parsetest 'tcp!localhost!5600'
      8  *
      9  * Beware, that parsetest.example should be in DOS format (\r\n)! The parser
     10  * will tolerate the UNIX format, but that will not be sent over the line in
     11  * the actual protocol.
     12  */
     13 
     14 #include <unistd.h>
     15 #include <stdio.h>
     16 #include <stdlib.h>
     17 #include <string.h>
     18 
     19 #include "ind.h"
     20 #include "imap.h"
     21 #include "llist.h"
     22 #include "parser.h"
     23 
     24 int
     25 main(int argc, char *argv[])
     26 {
     27 	net_t *net;
     28 	llistelem_t *stru;
     29 	parser_t *parser;
     30 
     31 	if (argc < 2)
     32 		die("usage: %s tcp!localhost!port\n", argv[0]);
     33 
     34 	net = net_new(argv[1]);
     35 	parser = parser_new("net", net);
     36 
     37 	printf("net_connect %s\n", argv[1]);
     38 	if (net_connect(net))
     39 		edie("net_connect");
     40 
     41 	printf("net_parsestruct\n");
     42 	stru = parser_parseimapstruct(parser);
     43 	if (stru == NULL)
     44 		edie("parser_parseimapstruct");
     45 
     46 	printf("net_close\n");
     47 	net_close(net);
     48 
     49 	printf("result:\n");
     50 	llistelem_eprint(stru);
     51 
     52 	llistelem_efree(stru);
     53 	parser_free(parser);
     54 	net_free(net);
     55 
     56 	return 0;
     57 }
     58