#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../src/cmime_message.h"
#include "../src/cmime_address.h"
#include "../src/cmime_list.h"
#include "../src/cmime_string.h"
void usage() {
printf("\n");
printf("libcmime - simple api demonstration\n");
printf("-----------------------------------\n");
printf("demonstrates: parsing an email message \n");
printf("output: output is written to stdout if no output file is specified\n");
printf("required parameter: -i /path/to/input_file\n");
}
int main(int argc, char *argv[])
{
int option;
int retval = 0;
char *in_file = NULL;
int i=0;
char *s = NULL;
char *s2 = NULL;
char *msg_string = NULL;
while((option = getopt(argc,argv,"hi:")) != EOF) {
switch(option) {
case 'i':
asprintf(&in_file, "%s", optarg);
break;
case 'h':
usage();
break;
default:
usage();
}
}
if(in_file != NULL) {
if(i == 0) {
printf("Message summary:\n=========================================\n");
printf("Sender: [%s]\n",s);
free(s);
while(elem != NULL) {
printf("- [%s]\n",s2);
free(s);
}
printf(
"Number of message headers: [%d]\n",message->
headers->
size);
printf("=========================================\n\n");
printf("%s\n",msg_string);
free(msg_string);
} else {
printf("failed opening file [%s]\n", in_file);
retval = -1;
}
} else {
printf("you have to specify an input file with -i\n");
retval = -1;
}
if(in_file != NULL)
free(in_file);
return retval;
}