From f0262739e1c7bd152ad5eaad36a99513706177c7 Mon Sep 17 00:00:00 2001 From: nobody Date: Thu, 12 Jul 2001 20:44:02 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'GAL_0_9'. svn path=/tags/GAL_0_9/; revision=11062 --- libical/src/test/testmime.c | 340 -------------------------------------------- 1 file changed, 340 deletions(-) delete mode 100644 libical/src/test/testmime.c (limited to 'libical/src/test/testmime.c') diff --git a/libical/src/test/testmime.c b/libical/src/test/testmime.c deleted file mode 100644 index 5dfc3b7d31..0000000000 --- a/libical/src/test/testmime.c +++ /dev/null @@ -1,340 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: - CREATOR: eric 25 June 2000 - - $Id$ - $Locker$ - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Initial Developer of the Original Code is Eric Busboom - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - ======================================================================*/ - -#include "ical.h" -#include "sspm.h" -#include "icalmime.h" -#include /* For rand */ -#include /* for strrchr, strdup*/ -#include /* for getopt */ - -/*int sspm_parse_mime(struct sspm_part *parts, - size_t max_parts, - struct sspm_action_map *actions, - char* (*get_string)(char *s, size_t size, void* data), - void *get_string_data, - struct sspm_header *first_header - ); -*/ - - - -char* major_type_string[] = { - "TEXT", - "IMAGE", - "AUDIO", - "VIDEO", - "APPLICATION", - "MULTIPART", - "MESSAGE", - "UNKNOWN", - "NO" -}; - -char* minor_type_string[] = { - "ANY", - "PLAIN", - "RFC822", - "DIGEST", - "CALENDAR", - "MIXED", - "RELATED", - "ALTERNATIVE", - "PARALLEL", - "UNKNOWN", - "NO" -}; - - -char* read_stream(char *s, size_t size, void *d) -{ - char *c = fgets(s,size, (FILE*)d); - - return c; - -} - - -int main(int argc, char* argv[]) { - - FILE *f; - int c; - extern char *optarg; - extern int optind, optopt; - int errflg=0; - char* program_name; - - struct options{ - int normal; - int stress; - int base64; - int qp; - int sleep; - int count; - char* input_file; - } opt; - - memset(&opt,0,sizeof(opt)); - - program_name = (char*)strrchr((char*)argv[0],'/'); - program_name++; - - while ((c = getopt(argc, argv, "nsbqi:S:c:")) != -1) { - switch (c) { - case 'i': { /* Input comes from named file */ - opt.input_file = strdup(optarg); - break; - } - case 'n':{ /* Normal */ - - if(opt.stress+opt.base64+opt.qp != 0){ - fprintf(stderr, - "%s: Use only one of n,s,b and q\n", - program_name); - } - opt.normal = 1; - break; - } - case 's':{ /* Stress-test*/ - if(opt.base64+opt.normal+opt.qp != 0){ - fprintf(stderr, - "%s: Use only one of n,s,b and q\n", - program_name); - } - opt.stress = 1; - break; - } - case 'b':{ /* test base64 decoding*/ - if(opt.stress+opt.normal+opt.qp != 0){ - fprintf(stderr, - "%s: Use only one of n,s,b and q\n", - program_name); - } - opt.base64 = 1; - break; - } - case 'q':{ /* test quoted-printable decoding*/ - if(opt.stress+opt.base64+opt.normal != 0){ - fprintf(stderr, - "%s: Use only one of n,s,b and q\n", - program_name); - } - opt.qp = 1; - break; - } - case 'S':{ /* sleep at end of run */ - opt.sleep = atoi(optarg); - break; - } - - case 'c':{ /* number of iterations of stress test */ - opt.count = atoi(optarg); - break; - } - - case ':': {/* Option given without an operand */ - fprintf(stderr, - "%s: Option -%c requires an operand\n", - program_name,optopt); - errflg++; - break; - } - case '?': { - errflg++; - } - } - } - - if (errflg >0){ - fprintf(stderr,"Usage: %s [-n|-s|-b|-q] [-i input_file]\n", - program_name); - exit(1); - } - - if(opt.stress+opt.base64+opt.normal+opt.qp == 0){ - fprintf(stderr, - "%s: Must have one of n,s,b or q\n", - program_name); - } - - if(opt.input_file){ - f = fopen(opt.input_file,"r"); - if (f == 0){ - fprintf(stderr,"Could not open input file \"%s\"\n", - opt.input_file); - exit(1); - } - } else { - f = stdin; - } - - - - if(opt.normal == 1){ - icalcomponent *c; - - c = icalmime_parse(read_stream,f); - - printf("%s\n",icalcomponent_as_ical_string(c)); - - icalcomponent_free(c); - - } else if (opt.stress==1 ){ - /* Read file in by lines, then randomize the lines into a - string buffer */ - - char *array[1024]; - char temp[1024]; - char *buf; - int i,last; - int size; - int non_rand; - int rand_lines; - int r; - int j; - icalcomponent *c; - struct slg_data { - char* pos; - char* str; - } d; - - for(i=0; !feof(f); i++){ - fgets(temp,1024,f); - array[i] = strdup(temp); - size += strlen(temp); - } - last = i; - - buf = malloc(size*2); - assert(buf != 0); - - - for(j=0; j