projects
/
mmh
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changed type of name argument to m_getfld() from unsigned char *
[mmh]
/
uip
/
mhparse.c
diff --git
a/uip/mhparse.c
b/uip/mhparse.c
index
d40d78c
..
8cfa899
100644
(file)
--- a/
uip/mhparse.c
+++ b/
uip/mhparse.c
@@
-12,7
+12,6
@@
#include <h/signals.h>
#include <h/md5.h>
#include <errno.h>
#include <h/signals.h>
#include <h/md5.h>
#include <errno.h>
-#include <setjmp.h>
#include <signal.h>
#include <h/mts.h>
#include <h/tws.h>
#include <signal.h>
#include <h/mts.h>
#include <h/tws.h>
@@
-20,15
+19,9
@@
#include <h/mhparse.h>
#include <h/utils.h>
#include <h/mhparse.h>
#include <h/utils.h>
-#ifdef HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif
-
extern int debugsw;
extern int debugsw;
-extern int endian; /* mhmisc.c */
-
extern pid_t xpid; /* mhshowsbr.c */
/* cache policies */
extern pid_t xpid; /* mhshowsbr.c */
/* cache policies */
@@
-53,11
+46,7
@@
struct k2v SubText[] = {
{ NULL, TEXT_UNKNOWN } /* this one must be last! */
};
{ NULL, TEXT_UNKNOWN } /* this one must be last! */
};
-struct k2v Charset[] = {
- { "us-ascii", CHARSET_USASCII },
- { "iso-8859-1", CHARSET_LATIN },
- { NULL, CHARSET_UNKNOWN } /* this one must be last! */
-};
+/* Charset[] removed -- yozo. Mon Oct 8 01:03:41 JST 2012 */
/*
* Structures for MULTIPART messages
/*
* Structures for MULTIPART messages
@@
-90,16
+79,12
@@
struct k2v SubApplication[] = {
};
};
-/* ftpsbr.c */
-int ftp_get (char *, char *, char *, char *, char *, char *, int, int);
-
/* mhcachesbr.c */
int find_cache (CT, int, int *, char *, char *, int);
/* mhmisc.c */
int part_ok (CT, int);
int type_ok (CT, int);
/* mhcachesbr.c */
int find_cache (CT, int, int *, char *, char *, int);
/* mhmisc.c */
int part_ok (CT, int);
int type_ok (CT, int);
-int make_intermediates (char *);
void content_error (char *, CT, char *, ...);
/* mhfree.c */
void content_error (char *, CT, char *, ...);
/* mhfree.c */
@@
-1046,6
+1031,8
@@
invalid:
static int
InitGeneric (CT ct)
{
static int
InitGeneric (CT ct)
{
+ NMH_UNUSED (ct);
+
return OK; /* not much to do here */
}
return OK; /* not much to do here */
}
@@
-1086,14
+1073,8
@@
InitText (CT ct)
/* check if content specified a character set */
if (*ap) {
/* check if content specified a character set */
if (*ap) {
- /* match character set or set to CHARSET_UNKNOWN */
- for (kv = Charset; kv->kv_key; kv++) {
- if (!mh_strcasecmp (*ep, kv->kv_key)) {
- chset = *ep;
- break;
- }
- }
- t->tx_charset = kv->kv_value;
+ chset = *ep;
+ t->tx_charset = CHARSET_SPECIFIED;
} else {
t->tx_charset = CHARSET_UNSPECIFIED;
}
} else {
t->tx_charset = CHARSET_UNSPECIFIED;
}
@@
-1734,9
+1715,9
@@
static int
openBase64 (CT ct, char **file)
{
int bitno, cc, digested;
openBase64 (CT ct, char **file)
{
int bitno, cc, digested;
- int fd, len, skip;
- unsigned long bits;
- unsigned char value, *b, *b1, *b2, *b3;
+ int fd, len, skip, own_ct_fp = 0;
+ uint32_t bits;
+ unsigned char value, b;
unsigned char *cp, *ep;
char buffer[BUFSIZ];
/* sbeck -- handle suffixes */
unsigned char *cp, *ep;
char buffer[BUFSIZ];
/* sbeck -- handle suffixes */
@@
-1744,11
+1725,6
@@
openBase64 (CT ct, char **file)
CE ce;
MD5_CTX mdContext;
CE ce;
MD5_CTX mdContext;
- b = (unsigned char *) &bits;
- b1 = &b[endian > 0 ? 1 : 2];
- b2 = &b[endian > 0 ? 2 : 1];
- b3 = &b[endian > 0 ? 3 : 0];
-
ce = ct->c_cefile;
if (ce->ce_fp) {
fseek (ce->ce_fp, 0L, SEEK_SET);
ce = ct->c_cefile;
if (ce->ce_fp) {
fseek (ce->ce_fp, 0L, SEEK_SET);
@@
-1783,8
+1759,8
@@
openBase64 (CT ct, char **file)
}
if (cp != NULL && *cp != '\0') {
if (ce->ce_unlink) {
}
if (cp != NULL && *cp != '\0') {
if (ce->ce_unlink) {
- // Temporary file already exists, so we rename to
- // version with extension.
+ /* Temporary file already exists, so we rename to
+ version with extension. */
char *file_org = strdup(ce->ce_file);
ce->ce_file = add (cp, ce->ce_file);
if (rename(file_org, ce->ce_file)) {
char *file_org = strdup(ce->ce_file);
ce->ce_file = add (cp, ce->ce_file);
if (rename(file_org, ce->ce_file)) {
@@
-1805,9
+1781,12
@@
openBase64 (CT ct, char **file)
if ((len = ct->c_end - ct->c_begin) < 0)
adios (NULL, "internal error(1)");
if ((len = ct->c_end - ct->c_begin) < 0)
adios (NULL, "internal error(1)");
- if (!ct->c_fp && (ct->c_fp = fopen (ct->c_file, "r")) == NULL) {
- content_error (ct->c_file, ct, "unable to open for reading");
- return NOTOK;
+ if (! ct->c_fp) {
+ if ((ct->c_fp = fopen (ct->c_file, "r")) == NULL) {
+ content_error (ct->c_file, ct, "unable to open for reading");
+ return NOTOK;
+ }
+ own_ct_fp = 1;
}
if ((digested = ct->c_digested))
}
if ((digested = ct->c_digested))
@@
-1854,17
+1833,20
@@
openBase64 (CT ct, char **file)
bits |= value << bitno;
test_end:
if ((bitno -= 6) < 0) {
bits |= value << bitno;
test_end:
if ((bitno -= 6) < 0) {
- putc ((char) *b1, ce->ce_fp);
+ b = (bits >> 16) & 0xff;
+ putc ((char) b, ce->ce_fp);
if (digested)
if (digested)
- MD5Update (&mdContext, b1, 1);
+ MD5Update (&mdContext, &b, 1);
if (skip < 2) {
if (skip < 2) {
- putc ((char) *b2, ce->ce_fp);
+ b = (bits >> 8) & 0xff;
+ putc ((char) b, ce->ce_fp);
if (digested)
if (digested)
- MD5Update (&mdContext, b2, 1);
+ MD5Update (&mdContext, &b, 1);
if (skip < 1) {
if (skip < 1) {
- putc ((char) *b3, ce->ce_fp);
+ b = bits & 0xff;
+ putc ((char) b, ce->ce_fp);
if (digested)
if (digested)
- MD5Update (&mdContext, b3, 1);
+ MD5Update (&mdContext, &b, 1);
}
}
}
}
@@
-1919,9
+1901,17
@@
self_delimiting:
ready_to_go:
*file = ce->ce_file;
ready_to_go:
*file = ce->ce_file;
+ if (own_ct_fp) {
+ fclose (ct->c_fp);
+ ct->c_fp = NULL;
+ }
return fileno (ce->ce_fp);
clean_up:
return fileno (ce->ce_fp);
clean_up:
+ if (own_ct_fp) {
+ fclose (ct->c_fp);
+ ct->c_fp = NULL;
+ }
free_encoding (ct, 0);
return NOTOK;
}
free_encoding (ct, 0);
return NOTOK;
}
@@
-1961,7
+1951,7
@@
InitQuoted (CT ct)
static int
openQuoted (CT ct, char **file)
{
static int
openQuoted (CT ct, char **file)
{
- int cc, digested, len, quoted;
+ int cc, digested, len, quoted, own_ct_fp = 0;
unsigned char *cp, *ep;
char buffer[BUFSIZ];
unsigned char mask;
unsigned char *cp, *ep;
char buffer[BUFSIZ];
unsigned char mask;
@@
-2004,8
+1994,8
@@
openQuoted (CT ct, char **file)
}
if (cp != NULL && *cp != '\0') {
if (ce->ce_unlink) {
}
if (cp != NULL && *cp != '\0') {
if (ce->ce_unlink) {
- // Temporary file already exists, so we rename to
- // version with extension.
+ /* Temporary file already exists, so we rename to
+ version with extension. */
char *file_org = strdup(ce->ce_file);
ce->ce_file = add (cp, ce->ce_file);
if (rename(file_org, ce->ce_file)) {
char *file_org = strdup(ce->ce_file);
ce->ce_file = add (cp, ce->ce_file);
if (rename(file_org, ce->ce_file)) {
@@
-2023,17
+2013,15
@@
openQuoted (CT ct, char **file)
return NOTOK;
}
return NOTOK;
}
- if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) {
- content_error (ce->ce_file, ct, "unable to fopen for reading/writing");
- return NOTOK;
- }
-
if ((len = ct->c_end - ct->c_begin) < 0)
adios (NULL, "internal error(2)");
if ((len = ct->c_end - ct->c_begin) < 0)
adios (NULL, "internal error(2)");
- if (!ct->c_fp && (ct->c_fp = fopen (ct->c_file, "r")) == NULL) {
- content_error (ct->c_file, ct, "unable to open for reading");
- return NOTOK;
+ if (! ct->c_fp) {
+ if ((ct->c_fp = fopen (ct->c_file, "r")) == NULL) {
+ content_error (ct->c_file, ct, "unable to open for reading");
+ return NOTOK;
+ }
+ own_ct_fp = 1;
}
if ((digested = ct->c_digested))
}
if ((digested = ct->c_digested))
@@
-2155,10
+2143,18
@@
openQuoted (CT ct, char **file)
ready_to_go:
*file = ce->ce_file;
ready_to_go:
*file = ce->ce_file;
+ if (own_ct_fp) {
+ fclose (ct->c_fp);
+ ct->c_fp = NULL;
+ }
return fileno (ce->ce_fp);
clean_up:
free_encoding (ct, 0);
return fileno (ce->ce_fp);
clean_up:
free_encoding (ct, 0);
+ if (own_ct_fp) {
+ fclose (ct->c_fp);
+ ct->c_fp = NULL;
+ }
return NOTOK;
}
return NOTOK;
}
@@
-2181,7
+2177,7
@@
Init7Bit (CT ct)
int
open7Bit (CT ct, char **file)
{
int
open7Bit (CT ct, char **file)
{
- int cc, fd, len;
+ int cc, fd, len, own_ct_fp = 0;
char buffer[BUFSIZ];
/* sbeck -- handle suffixes */
char *cp;
char buffer[BUFSIZ];
/* sbeck -- handle suffixes */
char *cp;
@@
-2222,8
+2218,8
@@
open7Bit (CT ct, char **file)
}
if (cp != NULL && *cp != '\0') {
if (ce->ce_unlink) {
}
if (cp != NULL && *cp != '\0') {
if (ce->ce_unlink) {
- // Temporary file already exists, so we rename to
- // version with extension.
+ /* Temporary file already exists, so we rename to
+ version with extension. */
char *file_org = strdup(ce->ce_file);
ce->ce_file = add (cp, ce->ce_file);
if (rename(file_org, ce->ce_file)) {
char *file_org = strdup(ce->ce_file);
ce->ce_file = add (cp, ce->ce_file);
if (rename(file_org, ce->ce_file)) {
@@
-2291,9
+2287,12
@@
open7Bit (CT ct, char **file)
if ((len = ct->c_end - ct->c_begin) < 0)
adios (NULL, "internal error(3)");
if ((len = ct->c_end - ct->c_begin) < 0)
adios (NULL, "internal error(3)");
- if (!ct->c_fp && (ct->c_fp = fopen (ct->c_file, "r")) == NULL) {
- content_error (ct->c_file, ct, "unable to open for reading");
- return NOTOK;
+ if (! ct->c_fp) {
+ if ((ct->c_fp = fopen (ct->c_file, "r")) == NULL) {
+ content_error (ct->c_file, ct, "unable to open for reading");
+ return NOTOK;
+ }
+ own_ct_fp = 1;
}
lseek (fd = fileno (ct->c_fp), (off_t) ct->c_begin, SEEK_SET);
}
lseek (fd = fileno (ct->c_fp), (off_t) ct->c_begin, SEEK_SET);
@@
-2330,10
+2329,18
@@
open7Bit (CT ct, char **file)
ready_to_go:
*file = ce->ce_file;
ready_to_go:
*file = ce->ce_file;
+ if (own_ct_fp) {
+ fclose (ct->c_fp);
+ ct->c_fp = NULL;
+ }
return fileno (ce->ce_fp);
clean_up:
free_encoding (ct, 0);
return fileno (ce->ce_fp);
clean_up:
free_encoding (ct, 0);
+ if (own_ct_fp) {
+ fclose (ct->c_fp);
+ ct->c_fp = NULL;
+ }
return NOTOK;
}
return NOTOK;
}
@@
-2489,10
+2496,8
@@
openFTP (CT ct, char **file)
if ((ftp = context_find (nmhaccessftp)) && !*ftp)
ftp = NULL;
if ((ftp = context_find (nmhaccessftp)) && !*ftp)
ftp = NULL;
-#ifndef BUILTIN_FTP
if (!ftp)
return NOTOK;
if (!ftp)
return NOTOK;
-#endif
switch (openExternal (e->eb_parent, e->eb_content, ce, file, &fd)) {
case NOTOK:
switch (openExternal (e->eb_parent, e->eb_content, ce, file, &fd)) {
case NOTOK:
@@
-2559,7
+2564,8
@@
openFTP (CT ct, char **file)
if (e->eb_flags) {
user = "anonymous";
if (e->eb_flags) {
user = "anonymous";
- snprintf (buffer, sizeof(buffer), "%s@%s", getusername (), LocalName ());
+ snprintf (buffer, sizeof(buffer), "%s@%s", getusername (),
+ LocalName (1));
pass = buffer;
} else {
ruserpass (e->eb_site, &username, &password);
pass = buffer;
} else {
ruserpass (e->eb_site, &username, &password);
@@
-2591,9
+2597,6
@@
openFTP (CT ct, char **file)
return NOTOK;
}
return NOTOK;
}
-#ifdef BUILTIN_FTP
- if (ftp)
-#endif
{
int child_id, i, vecp;
char *vec[9];
{
int child_id, i, vecp;
char *vec[9];
@@
-2612,7
+2615,7
@@
openFTP (CT ct, char **file)
fflush (stdout);
fflush (stdout);
- for (i = 0; (child_id = vfork ()) == NOTOK && i < 5; i++)
+ for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
sleep (5);
switch (child_id) {
case NOTOK:
sleep (5);
switch (child_id) {
case NOTOK:
@@
-2629,9
+2632,6
@@
openFTP (CT ct, char **file)
default:
if (pidXwait (child_id, NULL)) {
default:
if (pidXwait (child_id, NULL)) {
-#ifdef BUILTIN_FTP
-losing_ftp:
-#endif
username = password = NULL;
ce->ce_unlink = 1;
return NOTOK;
username = password = NULL;
ce->ce_unlink = 1;
return NOTOK;
@@
-2639,14
+2639,6
@@
losing_ftp:
break;
}
}
break;
}
}
-#ifdef BUILTIN_FTP
- else
- if (ftp_get (e->eb_site, user, pass, e->eb_dir, e->eb_name,
- ce->ce_file,
- e->eb_mode && !mh_strcasecmp (e->eb_mode, "ascii"), 0)
- == NOTOK)
- goto losing_ftp;
-#endif
if (cachefile[0]) {
if (caching)
if (cachefile[0]) {
if (caching)
@@
-2765,7
+2757,7
@@
openMail (CT ct, char **file)
vec[vecp++] = e->eb_body;
vec[vecp] = NULL;
vec[vecp++] = e->eb_body;
vec[vecp] = NULL;
- for (i = 0; (child_id = vfork ()) == NOTOK && i < 5; i++)
+ for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
sleep (5);
switch (child_id) {
case NOTOK:
sleep (5);
switch (child_id) {
case NOTOK:
@@
-2814,15
+2806,10
@@
static int
readDigest (CT ct, char *cp)
{
int bitno, skip;
readDigest (CT ct, char *cp)
{
int bitno, skip;
- unsigned long bits;
+ uint32_t bits;
char *bp = cp;
unsigned char *dp, value, *ep;
char *bp = cp;
unsigned char *dp, value, *ep;
- unsigned char *b, *b1, *b2, *b3;
- b = (unsigned char *) &bits,
- b1 = &b[endian > 0 ? 1 : 2],
- b2 = &b[endian > 0 ? 2 : 1],
- b3 = &b[endian > 0 ? 3 : 0];
bitno = 18;
bits = 0L;
skip = 0;
bitno = 18;
bits = 0L;
skip = 0;
@@
-2844,11
+2831,11
@@
test_end:
if ((bitno -= 6) < 0) {
if (dp + (3 - skip) > ep)
goto invalid_digest;
if ((bitno -= 6) < 0) {
if (dp + (3 - skip) > ep)
goto invalid_digest;
- *dp++ = *b1;
+ *dp++ = (bits >> 16) & 0xff;
if (skip < 2) {
if (skip < 2) {
- *dp++ = *b2;
+ *dp++ = (bits >> 8) & 0xff;
if (skip < 1)
if (skip < 1)
- *dp++ = *b3;
+ *dp++ = bits & 0xff;
}
bitno = 18;
bits = 0L;
}
bitno = 18;
bits = 0L;