Beispiel #1
0
static void 
parse_content_disposition (unsigned char **in, unsigned char *inend, disposition_t *disposition, GError **err)
{
	unsigned char *inptr = *in;

	/* a) NIL 
	 * b) ("INLINE" NIL) 
	 * c) ("ATTACHMENT" ("FILENAME", "myfile.ext")) 
	 * d) "ALTERNATIVE" ("BOUNDARY", "---")  */

	while (inptr < inend && *inptr == ' ')
		inptr++;

	if (*inptr == '(') {
		inptr++; /* My '(' */

		/* cases c & b */
		disposition->type = decode_qstring (&inptr, inend, err);
		debug_printf ("disposition.type: %s\n", PRINT_NULL (disposition->type));
		disposition->params = decode_params (&inptr, inend, err);
		print_params (disposition->params);

		while (inptr < inend && *inptr == ' ')
			inptr++;

		if (*inptr != ')') {
			g_free (disposition->type);
			disposition->type = NULL;
			if (disposition->params)
				mimeparam_destroy (disposition->params);
			*in = inptr;
			set_error (err, in);
			return;
		}

		inptr++; /* My ')' */
	} else {
		if (strncmp ((const char *) inptr, "NIL", 3) != 0) {
			/* case d */
			disposition->type = decode_qstring (&inptr, inend, err);
			debug_printf ("disposition.type: %s\n", PRINT_NULL (disposition->type));
			disposition->params = decode_params (&inptr, inend, err);
			print_params (disposition->params);
		} else /* case a */
			inptr += 3;
	}

	*in = inptr;

	return;
}
Beispiel #2
0
	int
main (

int		argc,
char **		argv
)
{
int			fpsave;
bitmap_t *		vert_mask;
bitmap_t *		edge_mask;
struct cinfo		cinfo;

	fpsave = set_floating_point_double_precision ();

	setbuf (stdout, NULL);

	decode_params (argc, argv);

	init_tables ();

	read_phase_1_data (&cinfo);
	if (description NE NULL) {
		free ((char *) cinfo.description);
		cinfo.description = gst_strdup (description);
	}

	if ((cinfo.metric NE RECTILINEAR) AND (cinfo.metric NE EUCLIDEAN)) {
		fprintf (stderr, "This only be done for geometric (Euclidean or rectilinear) FSTs\n");
		exit (1);
	}

	vert_mask	= cinfo.initial_vert_mask;
	edge_mask	= cinfo.initial_edge_mask;

	if ((cinfo.metric EQ RECTILINEAR) AND (NOT Print_Unscaled)) {
		/* Force printing of integer data. */
		cinfo.scale.min_precision = 0;
		if (cinfo.scale.scale > 0) {
			cinfo.scale.scale = 0;
		}
	}

	if ((cinfo.metric EQ EUCLIDEAN) OR (!Print_Grid_Graph)) {
		compute_edge_graph (vert_mask, edge_mask, &cinfo);
	}
	else {
		compute_grid_graph (vert_mask, edge_mask, &cinfo);
	}

	free_phase_1_data (&cinfo);

	restore_floating_point_precision (fpsave);

	exit (0);
}
Beispiel #3
0
/*
* PKCS#5 v2.0 PBE Constructor
*/
PBE_PKCS5v20::PBE_PKCS5v20(DataSource& params) : direction(DECRYPTION)
   {
   hash_function = 0;
   block_cipher = 0;
   decode_params(params);
   }
Beispiel #4
0
void *process_connection(void* client_id)
{
    // Convert the passed in client id to an int
    int id = *((int*) client_id);

    // Local variables
    char* params = malloc(STRINGSIZE * sizeof(char));
    char* file = malloc(FILESIZE * sizeof(char));
    char* buffer = malloc(BUFFERSIZE * sizeof(char));
    char* params_pointer = params;
    char method[STRINGSIZE];
    char endpoint[STRINGSIZE];
    char response[STRINGSIZE];
    char JSON[STRINGSIZE];
    char header[STRINGSIZE];
    int size = 0, message_length = 0, error = 0, is_file = 0;
    FILE *f;

    // Read entire message from client
    message_length = read(id, buffer, BUFFERSIZE);

    // Extract endpoint and its paramaters from message
    extract_endpoint_params(buffer, method, endpoint, params);

    // Decode tax info     
    size = decode_params(params, JSON);

    // Set standard header
    strcpy(header, "HTTP/1.0 200 OK\r\nContent-type:application/json\r\n\r\n");
    
    // Select Resource
    if(strcmp(endpoint, "taxestimator/taxes") == 0)
    {
        if(strcmp(method, "GET") == 0)
        {
            // Process taxes
            error = !process_taxes(JSON, response);
            if(error)
            {
                // 500 Internal Server Error
                memset(response, '\0', STRINGSIZE); // Erase response
                strcpy(header, "HTTP/1.0 500 Internal Server Error\r\n");
            }
        }
        else 
        {
            // Handle unsupported method
            // 405 Method Not Allowed
            strcpy(header, "HTTP/1.0 405 Method Not Allowed\r\n");
        }
    }
    else if(strcmp(endpoint, "taxestimator/") == 0)
    {
        if(strcmp(method, "GET") == 0)
        {
            is_file = 1;
            strcpy(header, "HTTP/1.0 200 OK\r\nContent-type:text/html\r\n\r\n");
            f = fopen("../../Clients/TaxEstimatorWebsite/TaxEstimator.html", "r");
        }
        else 
        {
            // Handle unsupported method
            // 405 Method Not Allowed
            strcpy(header, "HTTP/1.0 405 Method Not Allowed\r\n");
        }
    }
    else if (strcmp(endpoint, "taxestimator") == 0)
    {
        if(strcmp(method, "GET") == 0)
        {
            strcpy(header, "HTTP/1.1 302 Found\r\nLocation:taxestimator/\r\n\r\n");
        }
        else 
        {
            // Handle unsupported method
            // 405 Method Not Allowed
            strcpy(header, "HTTP/1.0 405 Method Not Allowed\r\n");
        }
    }
    else if(strcmp(endpoint, "taxestimator/TaxEstimator.js") == 0)
    {
        if(strcmp(method, "GET") == 0)
        {
            is_file = 1;
            strcpy(header, "HTTP/1.0 200 OK\r\nContent-type:text/javascript\r\n\r\n");
            f = fopen("../../Clients/TaxEstimatorWebsite/TaxEstimator.js", "r");
        }
        else 
        {
            // Handle unsupported method
            // 405 Method Not Allowed
            strcpy(header, "HTTP/1.0 405 Method Not Allowed\r\n");
        }
    }
    else if(strcmp(endpoint, "taxestimator/TaxEstimator.css") == 0)
    {
        if(strcmp(method, "GET") == 0)
        {
            is_file = 1;
            strcpy(header, "HTTP/1.0 200 OK\r\nContent-type:text/css\r\n\r\n");
            f = fopen("../../Clients/TaxEstimatorWebsite/TaxEstimator.css", "r");
        }
        else 
        {
            // Handle unsupported method
            // 405 Method Not Allowed
            strcpy(header, "HTTP/1.0 405 Method Not Allowed\r\n");
        }
    }
    else if(strcmp(endpoint, "taxestimator/favicon.png") == 0)
    {
        if(strcmp(method, "GET") == 0)
        {
            is_file = 1;
            strcpy(header, "HTTP/1.0 200 OK\r\nContent-type:image/png\r\n\r\n");
            f = fopen("../../Clients/TaxEstimatorWebsite/favicon.png", "r");
        }
        else 
        {
            // Handle unsupported method
            // 405 Method Not Allowed
            strcpy(header, "HTTP/1.0 405 Method Not Allowed\r\n");
        }
    }
    else
    {
        // Handle unsupported resource
        // 404 Not Found
        strcpy(header, "HTTP/1.0 404 Not Found\r\n");
    }

    if(is_file)
    {
        write(id, header, strlen(header));
        while((size = fread(file, 1, FILESIZE*sizeof(char), f)) > 0)
        {
            write(id, file, size);
        }
        fclose(f);
    } 
    else
    {
        strcat(header, response);
        strcpy(response, header);
        size = strlen(response);
        write(id, response, size);
    }

    // TODO: Log event
    if (is_file)
    {
        printf("%s, %s\n", endpoint, method);
    }
    else
    {
        printf("%s, %s, %s\n", endpoint, method, response);
    }
    printf("*************************************************************\n");
    
    // Clean up
    close(id);
    free(buffer);
    free(params_pointer);
    free(client_id);
    return (void *) 0;
}
Beispiel #5
0
static int alloc(struct aucodec_st **stp, struct aucodec *ac,
		 struct aucodec_prm *encp, struct aucodec_prm *decp,
		 const char *fmtp)
{
	struct aucodec_st *st;
	const uint32_t srate = aucodec_srate(ac);
	const uint8_t ch = aucodec_ch(ac);
	int err = 0;

	(void)decp;

	st = mem_zalloc(sizeof(*st), celt_destructor);
	if (!st)
		return ENOMEM;

	st->ac = mem_ref(ac);

	st->bitrate      = DEFAULT_BITRATE;
	st->low_overhead = celt_low_overhead;

	if (encp && encp->ptime) {
		st->frame_size = srate * ch * encp->ptime / 1000;
		DEBUG_NOTICE("calc ptime=%u  ---> frame_size=%u\n",
			     encp->ptime, st->frame_size);
	}
	else {
		st->frame_size = DEFAULT_FRAME_SIZE;
	}

	if (str_isset(fmtp))
		decode_params(st, fmtp);

	/* Common mode */
	st->mode = celt_mode_create(srate, st->frame_size, NULL);
	if (!st->mode) {
		DEBUG_WARNING("alloc: could not create CELT mode\n");
		err = EPROTO;
		goto out;
	}

#ifdef CELT_GET_FRAME_SIZE
	celt_mode_info(st->mode, CELT_GET_FRAME_SIZE, &st->frame_size);
#endif

	st->fsize = 2 * st->frame_size * ch;
	st->bytes_per_packet = (st->bitrate * st->frame_size / srate + 4)/8;

	DEBUG_NOTICE("alloc: frame_size=%u bitrate=%ubit/s fsize=%u"
		     " bytes_per_packet=%u\n",
		     st->frame_size, st->bitrate, st->fsize,
		     st->bytes_per_packet);

	/* Encoder */
#ifdef CELT_OLD_API
	st->enc = celt_encoder_create(st->mode, ch, NULL);
#else
	st->enc = celt_encoder_create(srate, ch, NULL);
#endif
	if (!st->enc) {
		DEBUG_WARNING("alloc: could not create CELT encoder\n");
		err = EPROTO;
		goto out;
	}

	/* Decoder */
#ifdef CELT_OLD_API
	st->dec = celt_decoder_create(st->mode, ch, NULL);
#else
	st->dec = celt_decoder_create(srate, ch, NULL);
#endif
	if (!st->dec) {
		DEBUG_WARNING("alloc: could not create CELT decoder\n");
		err = EPROTO;
		goto out;
	}

 out:
	if (err)
		mem_deref(st);
	else
		*stp = st;

	return err;
}
Beispiel #6
0
	int
main (

int		argc,
char **		argv
)
{
int			i;
int			j;
int			n;
int			num_instances;
bool			found;
char			buf [256];

	setbuf (stdout, NULL);

	decode_params (argc, argv);

	scanf ("%s", buf);

	/* Is this a TSPLIB or OR-LIBRARY file? */
	if (strncmp (buf, "NAME", 4) EQ 0) {

		/* This appears to be a TSPLIB file */

		/* Search for dimension field */
		found = FALSE;
		while (NOT feof (stdin)) {
			scanf ("%s", buf);
			if (strncmp (buf, "DIMENSION:", 10) EQ 0) {
				found = TRUE;
				break;
			}

			if (strncmp (buf, "DIMENSION", 9) EQ 0) {
				scanf ("%s", buf); /* read the : */
				found = TRUE;
				break;
			}
		}

		if (NOT found) {
			fprintf (stderr,"\nError: Cannot find dimension.\n\n");
			exit (1);
		}

		scanf ("%s", buf);
		n = atoi (buf);
		if (n < 1) {
			fprintf (stderr,"\nError: Bad dimension.\n\n");
			exit (1);
		}

		/* Search for one of the valid coordinate types */
		found = FALSE;
		while (NOT feof (stdin)) {
			scanf ("%s", buf);
			if ((strncmp (buf, "EUC_2D",  6) EQ 0) OR
			    (strncmp (buf, "MAX_2D",  6) EQ 0) OR
			    (strncmp (buf, "CEIL_2D", 7) EQ 0) OR
			    (strncmp (buf, "GEO",     3) EQ 0) OR
			    (strncmp (buf, "ATT",     3) EQ 0)) {
				found = TRUE;
				break;
			}
		}

		if (NOT found) {
			fprintf (stderr, "\nError: TSPLIB input file is not\n"
					 "a 2-D plane instance.\n\n");
			exit (1);
		}

		/* Search for the coordinate section */
		found = FALSE;
		while (NOT feof (stdin)) {
			scanf ("%s", buf);
			if (strncmp (buf, "NODE_COORD_SECTION", 18) EQ 0) {
				found = TRUE;
				break;
			}
		}

		if (NOT found) {
			fprintf (stderr,
				 "\nError: Cannot find node coordinates.\n\n");
			exit (1);
		}

		/* Now start dumping out the coordinates */
		for (i = 1; i <= n; i++) {
			scanf ("%s", buf);

			if (i NE atoi (buf)) {
				fprintf (stderr,
					 "\nError: Bad node number.\n\n");
				exit (1);
			}

			scanf ("%s", buf); /* x-coordinate */
			printf ("%s ", buf);
			scanf ("%s", buf); /* y-coordinate */
			printf ("%s\n", buf);
		}
	}
	else {
		num_instances = atoi (buf);

		if (num_instances < 1) {
			fprintf (stderr,
				 "\nError: Input file is neither OR-LIBRARY\n"
				 "or TSPLIB file.\n\n");
			exit (1);
		}

		if (orlib_instance > num_instances) {
			fprintf (stderr,
				 "\nError: Specified instance number (%d)\n"
				 "does not exist in OR-LIBRARY file.\n\n",
				 orlib_instance);
			exit (1);
		}

		/* Now dump out the correct instance */
		for (j = 1; j <= orlib_instance; j++) {
			scanf ("%s", buf);
			n = atoi (buf);

			if (n < 1) {
				fprintf (stderr,
					 "\nError: Bad number of points in instance %d.\n\n",
					 j);
				exit (1);
			}

			if (j EQ orlib_instance) {
				for (i = 1; i <= n; i++) {
					scanf ("%s", buf);
					printf ("%s ", buf);
					scanf ("%s", buf);
					printf ("%s\n", buf);
				}
			}
			else {
				for (i = 1; i <= n; i++) {
					scanf ("%s%s", buf, buf);
				}
			}
		}
	}

	exit (0);
}
Beispiel #7
0
int main(int argc, char **argv)
{
    game_params *p;
    game_state *s;
    char *id = NULL, *desc, *err;
    int grade = FALSE;
    int ret, diff, really_show_working = FALSE;

    while (--argc > 0) {
        char *p = *++argv;
        if (!strcmp(p, "-v")) {
            really_show_working = TRUE;
        } else if (!strcmp(p, "-g")) {
            grade = TRUE;
        } else if (*p == '-') {
            fprintf(stderr, "%s: unrecognised option `%s'\n", argv[0], p);
            return 1;
        } else {
            id = p;
        }
    }

    if (!id) {
        fprintf(stderr, "usage: %s [-g | -v] <game_id>\n", argv[0]);
        return 1;
    }

    desc = strchr(id, ':');
    if (!desc) {
        fprintf(stderr, "%s: game id expects a colon in it\n", argv[0]);
        return 1;
    }
    *desc++ = '\0';

    p = default_params();
    decode_params(p, id);
    err = validate_desc(p, desc);
    if (err) {
        fprintf(stderr, "%s: %s\n", argv[0], err);
        return 1;
    }
    s = new_game(NULL, p, desc);

    /*
     * When solving an Easy puzzle, we don't want to bother the
     * user with Hard-level deductions. For this reason, we grade
     * the puzzle internally before doing anything else.
     */
    ret = -1;			       /* placate optimiser */
    solver_show_working = FALSE;
    for (diff = 0; diff < DIFFCOUNT; diff++) {
	memcpy(s->grid, s->clues->immutable, p->w * p->w);
	ret = solver(p->w, s->clues->clues, s->grid, diff);
	if (ret <= diff)
	    break;
    }

    if (diff == DIFFCOUNT) {
	if (grade)
	    printf("Difficulty rating: ambiguous\n");
	else
	    printf("Unable to find a unique solution\n");
    } else {
	if (grade) {
	    if (ret == diff_impossible)
		printf("Difficulty rating: impossible (no solution exists)\n");
	    else
		printf("Difficulty rating: %s\n", towers_diffnames[ret]);
	} else {
	    solver_show_working = really_show_working;
	    memcpy(s->grid, s->clues->immutable, p->w * p->w);
	    ret = solver(p->w, s->clues->clues, s->grid, diff);
	    if (ret != diff)
		printf("Puzzle is inconsistent\n");
	    else
		fputs(game_text_format(s), stdout);
	}
    }

    return 0;
}
Beispiel #8
0
	int
main (

int		argc,
char **		argv
)
{
int			i;
int			nedges;
int			nmasks;
int			fpsave;
bitmap_t *		edge_mask;
bitmap_t *		all_fsets_mask;
bitmap_t *		no_fsets_mask;
int			count;
char			tbuf [20];
char			title [128];
struct cinfo		cinfo;

	fpsave = set_floating_point_double_precision ();

	setbuf (stdout, NULL);

	decode_params (argc, argv);

	init_tables ();

	read_phase_1_data (&cinfo);

	edge_mask	= cinfo.initial_edge_mask;

	convert_cpu_time (cinfo.p1time, tbuf);
	printf (" %% Phase 1: %s seconds\n", tbuf);

	/* Prepare for plotting all terminals. */
	define_Plot_Terminals (cinfo.pts, &cinfo.scale);

	nedges = cinfo.num_edges;
	nmasks = cinfo.num_edge_masks;

	all_fsets_mask = NEWA (nmasks, bitmap_t);
	no_fsets_mask = NEWA (nmasks, bitmap_t);
	for (i = 0; i < nmasks; i++) {
		all_fsets_mask [i] = 0;
		no_fsets_mask [i] = 0;
	}
	for (i = 0; i < nedges; i++) {
		SETBIT (all_fsets_mask, i);
	}

	if (Print_Points) {
		if ((cinfo.description NE NULL) AND
		    (cinfo.description [0] NE '\0')) {
			strcpy (title, cinfo.description);
		}
		else {
			sprintf (title, "%lu points", (int32u) cinfo.num_verts);
		}
		overlay_plot_subset (title, no_fsets_mask, &cinfo, BIG_PLOT);
	}
	if (Print_Full_Sets) {
		plot_full_sets (all_fsets_mask, &cinfo, SMALL_PLOT);
	}
	if (Print_Grouped_Full_Sets) {
		plot_full_sets_grouped (all_fsets_mask, &cinfo, SMALL_PLOT);
	}

	if (Print_Overlaid_Full_Sets) {
		sprintf (title,
			 "All FSTs:  %lu points,  %s seconds",
			 (int32u) cinfo.num_verts, tbuf);
		overlay_plot_subset (title, edge_mask, &cinfo, BIG_PLOT);
	}

	restore_floating_point_precision (fpsave);

	exit (0);
}
Beispiel #9
0
static struct _bodystruct *
bodystruct_part_decode (unsigned char **in, unsigned char *inend, bodystruct_t *parent, gint num, GError **err)
{
	struct _bodystruct *part, *list, *tail, *n;
	unsigned char *inptr;

	inptr = *in;

	while (inptr < inend && *inptr == ' ')
		inptr++;


	if (inptr == inend || *inptr != '(') {
		*in = inptr;
		return NULL;
	}

	inptr++; /* My '(' */

	part = bodystruct_new ();

	part->part_spec = NULL;
	part->parent = parent;

	if (parent) {
		if (parent->part_spec && *parent->part_spec) {
			if (!strcasecmp (parent->content.type, "message") && !strcasecmp (parent->content.subtype, "rfc822")) {
				part->part_spec = g_strdup (parent->part_spec);
			} else {
				part->part_spec = g_strdup_printf ("%s.%d", parent->part_spec, num);
			}
		} else {
			part->part_spec = g_strdup_printf ("%d", num);
		}
	} else {
		part->part_spec = g_strdup ("");
	}

	if (*inptr == '(') {
		gint cnt = 1;

		part->content.type = g_strdup ("MULTIPART");

		list = NULL;
		tail = (struct _bodystruct *) &list;

		while ((n = bodystruct_part_decode (&inptr, inend, part, cnt, err)) != NULL) 
		{
			tail->next = n;
			tail = n;
			cnt++;

			while (inptr < inend && *inptr == ' ')
				inptr++;

			if (*inptr == ')')
				break;
		}

		part->subparts = list;

		if (*inptr != ')') {
			part->content.subtype = decode_qstring (&inptr, inend, err);
			debug_printf ("contensubtype: %s\n", PRINT_NULL (part->content.subtype));
		}

		if (*inptr != ')') {
			part->content.params = decode_params (&inptr, inend, err);
			print_params (part->content.params);
		}

		/* if (*inptr != ')') {
		 *	parse_something_unknown (&inptr, inend, err);
		 * } */

		if (*inptr != ')') {
			parse_content_disposition (&inptr, inend, &part->disposition, err);
		}

		if (*inptr != ')') {
			parse_lang (&inptr, inend, part, err);
		}

		if (*inptr != ')') {
			end_this_piece (&inptr, inend, err);
		}

	} else {
		part->next = NULL;
		part->content.type = decode_qstring (&inptr, inend, err);
		if (!part->content.type)
			part->content.type = g_strdup ("TEXT");
		debug_printf ("contentype: %s\n", PRINT_NULL (part->content.type));

		part->content.subtype = decode_qstring (&inptr, inend, err);
		if (!part->content.subtype)
			part->content.subtype = g_strdup ("PLAIN");
		debug_printf ("contensubtype: %s\n", PRINT_NULL (part->content.subtype));

		part->disposition.type = NULL;
		part->disposition.params = NULL;
		part->encoding = NULL;
		part->envelope = NULL;
		part->subparts = NULL;


		if (!strcasecmp (part->content.type, "message") && !strcasecmp (part->content.subtype, "rfc822")) {

			if (*inptr != ')') {
				part->content.params = decode_params (&inptr, inend, err);
				print_params (part->content.params);
			}

			if (*inptr != ')') {
				part->content.cid = decode_qstring (&inptr, inend, err);
				debug_printf ("content.cid: %s\n", PRINT_NULL (part->content.cid));
			}

			if (*inptr != ')') {
				part->description = decode_qstring (&inptr, inend, err);
				debug_printf ("description: %s\n", PRINT_NULL (part->description));
			}

			if (*inptr != ')') {
				part->encoding = decode_qstring (&inptr, inend, err);
				if (!part->encoding)
					part->encoding = g_strdup ("7BIT");
				debug_printf ("encoding: %s\n", PRINT_NULL (part->encoding));
			}

			if (*inptr != ')') {
				part->octets = decode_num (&inptr, inend, err);
				debug_printf ("octets: %d\n", part->octets);
			}

			if (*inptr != ')') {
				part->envelope = decode_envelope (&inptr, inend, err);
			}

			if (*inptr != ')') {
				part->subparts = bodystruct_part_decode (&inptr, inend, part, 1, err);
			}

			if (*inptr != ')') {
				part->lines = decode_num (&inptr, inend, err);
				debug_printf ("lines: %d\n", part->lines);
			}

			if (*inptr != ')') {
				read_unknown_qstring (&inptr, inend, err);
			}

			if (*inptr != ')') {
				parse_content_disposition (&inptr, inend, &part->disposition, err);
			}

			if (*inptr != ')') {
				parse_lang (&inptr, inend, part, err);
			}

			if (*inptr != ')') {
				end_this_piece (&inptr, inend, err);
			}

		} else if (!strcasecmp (part->content.type, "text")) {

			if (*inptr != ')') {
				part->content.params = decode_params (&inptr, inend, err);
				print_params (part->content.params);
			}

			if (*inptr != ')') {
				part->content.cid = decode_qstring (&inptr, inend, err);
				debug_printf ("content.cid: %s\n", PRINT_NULL (part->content.cid));
			}

			if (*inptr != ')') {
				part->description = decode_qstring (&inptr, inend, err);
				debug_printf ("description: %s\n", PRINT_NULL (part->description));
			}

			if (*inptr != ')') {
				part->encoding = decode_qstring (&inptr, inend, err);
				debug_printf ("encoding: %s\n", PRINT_NULL (part->encoding));
			}

			if (*inptr != ')') {
				part->octets = decode_num (&inptr, inend, err);
				debug_printf ("octets: %d\n", part->octets);
			}

			if (*inptr != ')') {
				part->lines = decode_num (&inptr, inend, err);
				debug_printf ("lines: %d\n", part->lines);
			}

			if (*inptr != ')') {
				read_unknown_qstring (&inptr, inend, err);
			}

			if (*inptr != ')') {
				parse_content_disposition (&inptr, inend, &part->disposition, err);
			}

			if (*inptr != ')') {
				parse_lang (&inptr, inend, part, err);
			}

			if (*inptr != ')') {
				end_this_piece (&inptr, inend, err);
			}

		} else if (!strcasecmp (part->content.type, "APPLICATION")||
				!strcasecmp (part->content.type, "IMAGE") ||
				!strcasecmp (part->content.type, "VIDEO") ||
				!strcasecmp (part->content.type, "AUDIO"))
		{

			if (*inptr != ')') {
				part->content.params = decode_params (&inptr, inend, err);
				print_params (part->content.params);
			}

			if (*inptr != ')') {
				part->content.cid = decode_qstring (&inptr, inend, err);
				debug_printf ("content.cid: %s\n", PRINT_NULL (part->content.cid));
			}

			if (*inptr != ')') {
				part->description = decode_qstring (&inptr, inend, err);
				debug_printf ("description: %s\n", PRINT_NULL (part->description));
			}

			if (*inptr != ')') {
				part->encoding = decode_qstring (&inptr, inend, err);
				debug_printf ("encoding: %s\n", PRINT_NULL (part->encoding));
			}

			if (*inptr != ')') {
				part->octets = decode_num (&inptr, inend, err);
				debug_printf ("octets: %d\n", part->octets);
			}

			if (*inptr != ')') {
				read_unknown_qstring (&inptr, inend, err);
			}

			if (*inptr != ')') {
				parse_content_disposition (&inptr, inend, &part->disposition, err);
			}

			if (*inptr != ')') {
				parse_lang (&inptr, inend, part, err);
			}

			if (*inptr != ')') {
				end_this_piece (&inptr, inend, err);
			}

		} else {
			/* I don't know how it looks, so I just read it away */
			end_this_piece (&inptr, inend, err);
		}


	}

	if (*inptr != ')') {
		*in = inptr;
		set_error (err, in);
		bodystruct_free (part);
		return NULL;
	}

	inptr++; /* My ')' */

	*in = inptr;

	return part;
}