* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
{
const unsigned char *p, *mark;
size_t n;
-
+
for (mark=NULL, p=line, n=0; n < len; n++, p++)
{
if (strchr (" \t\r\n", *p ))
else
mark = NULL;
}
-
- if (mark)
+
+ if (mark)
return mark - line;
return len;
}
while (*b)
*a++ = *b++;
*a = 0;
-
+
return (char*)a;
}
#endif
{
assert (!msg->current_part->boundary);
msg->current_part->boundary = malloc (strlen (s) + 1);
- if (msg->current_part->boundary)
+ if (msg->current_part->boundary)
{
part_t part;
-
+
strcpy (msg->current_part->boundary, s);
msg->boundary = msg->current_part->boundary;
part = new_part ();
hdr->cont = (*line == ' ' || *line == '\t');
memcpy (hdr->line, line, length);
hdr->line[length] = 0; /* Make it a string. */
-
+
/* Transform a field name into canonical format. */
if (!hdr->cont && strchr (line, ':'))
capitalize_header_name (hdr->line);
int
rfc822parse_insert (rfc822parse_t msg, const unsigned char *line, size_t length)
{
- return (msg->in_body
+ return (msg->in_body
? insert_body (msg, line, length)
: insert_header (msg, line, length));
}
* WHICH gives the mode:
* -1 := Take the last occurence
* n := Take the n-th one.
- *
+ *
* Returns a newly allocated buffer or NULL on error. errno is set in
* case of a memory failure or set to 0 if the requested field is not
* available.
- *
+ *
* If VALUEOFF is not NULL it will receive the offset of the first non
* space character in the value part of the line (i.e. after the first
* colon).
HDR_LINE l;
if (!msg) /* Close. */
- return NULL;
+ return NULL;
if (*context == msg || !msg->current_part)
return NULL;
static const char tspecials[] = "/?=<>@,;:\\[]\"()";
static const char tspecials2[] = "/?=<>@.,;:"; /* FIXME: really
include '.'?*/
- static struct
+ static struct
{
const unsigned char *name;
size_t namelen;
s++; /* Move over the colon. */
for (;;)
{
- if (!*s)
+ while (!*s)
{
if (!hdr->next || !hdr->next->cont)
- break;
+ return tok; /* Ready. */
+
+ /* Next item is a header continuation line. */
hdr = hdr->next;
s = hdr->line;
}
invalid = 0;
for (s++;; s++)
{
- if (!*s)
+ while (!*s)
{
if (!hdr->next || !hdr->next->cont)
- break;
+ goto oparen_out;
+ /* Next item is a header continuation line. */
hdr = hdr->next;
s = hdr->line;
}
else if (*s == '\"')
in_quote = 1;
}
+ oparen_out:
if (!*s)
; /* Actually this is an error, but we don't care about it. */
else
else if (*s2 == '\\' && s2[1]) /* what about continuation? */
s2++;
}
-
+
t = (t
? append_to_token (t, s, s2 - s)
: new_token (term == '\"'? tQUOTED : tDOMAINLIT, s, s2 - s));
if (!t)
goto failure;
-
+
if (*s2 || !hdr->next || !hdr->next->cont)
break;
+ /* Next item is a header continuation line. */
hdr = hdr->next;
s = hdr->line;
}
s++;
}
}
-
- return tok;
+ /*NOTREACHED*/
failure:
{
Returns a pointer to the value which is valid as long as the
parse context is valid; NULL is returned in case that attr is not
defined in the header, a missing value is reppresented by an empty string.
-
+
With LOWER_VALUE set to true, a matching field valuebe be
lowercased.
-
+
Note, that ATTR should be lowercase.
*/
const char *
part_t save_part; /* ugly hack - we should have a function to
get part inforation. */
const char *s;
-
+
save_part = msg->current_part;
msg->current_part = part;
ctx = rfc822parse_parse_field (msg, "Content-Type", -1);
if (part->down)
dump_structure (msg, part->down, indent + 1);
}
-
+
}
return;
s = rfc822parse_query_parameter (ctx, name, 0);
if (s)
- printf ("*** %s: `%s'\n", name, s);
+ printf ("*** %s: '%s'\n", name, s);
}
const char *s1, *s2;
s1 = rfc822parse_query_media_type (ctx, &s2);
if (s1)
- printf ("*** media: `%s/%s'\n", s1, s2);
+ printf ("*** media: '%s/%s'\n", s1, s2);
else
printf ("*** media: [not found]\n");
show_param (ctx, "boundary");
}
else
printf ("*** media: text/plain [assumed]\n");
-
+
}