Exemple #1
0
 PConfigurationNode parse(std::string model) {
   parse_lang(model);
   return configurationNode;
 }
Exemple #2
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;
}