#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../src/cmime_message.h"
void usage() {
printf("\n");
printf("libcmime - simple api demonstration\n");
printf("-----------------------------------\n");
printf("demonstrates: save CMimePart_T part of CMimeMessage_T object with cmime_part_to_file() to a file\n");
printf("required parameter: -i /path/to/in_file\n");
printf("optional parameter: -o /path/to/out_file\n");
}
int main(int argc, char *argv[]) {
int option;
int retval = 0;
char *in_file = NULL;
char *out_file = NULL;
int i=0;
while((option = getopt(argc,argv,"hi:o:")) != EOF) {
switch(option) {
case 'i':
asprintf(&in_file, "%s", optarg);
break;
case 'o':
asprintf(&out_file, "%s", optarg);
break;
case 'h':
usage();
break;
default:
usage();
}
}
if(in_file != NULL && out_file != NULL) {
if(i == 0) {
} else {
printf("failed opening file [%s]\n", in_file);
retval = -1;
}
} else {
printf("you have to specify an input file with -i and an output file with -o\n");
retval = -1;
}
if(in_file != NULL)
free(in_file);
if(out_file != NULL)
free(out_file);
return retval;
}