$Log$
+ Revision 573.135 2001/06/06 04:22:25 ajc
+ * Moved memreadline() to tools.c
+ * internet_addressing.c: fixed conversion of fields to (hopefully) never get
+ into an active loop when encountering badly formed headers
+
Revision 573.134 2001/05/27 05:23:03 ajc
* Added a "no new messages" response in the client, displayed when a read
command turns up a zero message count.
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
msg->cm_fields['I'] = strdoop(value);
/* Strip angle brackets */
- if ((haschar(msg->cm_fields['I'], '<') == 1)
- && (haschar(msg->cm_fields['I'], '>') == 1)) {
- while ((strlen(msg->cm_fields['I']) > 0)
- && (msg->cm_fields['I'][0] != '<')) {
- strcpy(&msg->cm_fields['I'][0],
- &msg->cm_fields['I'][1]);
- }
+ while (haschar(msg->cm_fields['I'], '<') > 0) {
strcpy(&msg->cm_fields['I'][0],
&msg->cm_fields['I'][1]);
- for (i = 0; i<strlen(msg->cm_fields['I']); ++i)
- if (msg->cm_fields['I'][i] == '>')
- msg->cm_fields['I'][i] = 0;
}
+ for (i = 0; i<strlen(msg->cm_fields['I']); ++i)
+ if (msg->cm_fields['I'][i] == '>')
+ msg->cm_fields['I'][i] = 0;
}
processed = 1;
struct CtdlMessage *convert_internet_message(char *rfc822) {
struct CtdlMessage *msg;
- int pos, beg, end;
+ int pos, beg, end, msglen;
int done;
char buf[SIZ];
int converted;
*/
beg = pos;
end = (-1);
- for (pos=beg; ((pos<=strlen(rfc822))&&(end<0)); ++pos) {
+
+ msglen = strlen(rfc822);
+ while ( (end < 0) && (done == 0) ) {
+
if ((rfc822[pos]=='\n')
&& (!isspace(rfc822[pos+1]))) {
end = pos;
}
- if ( (rfc822[pos]=='\n') /* done w. headers? */
+
+ /* done with headers? */
+ if ( ((rfc822[pos]=='\n')
+ ||(rfc822[pos]=='\r') )
&& ( (rfc822[pos+1]=='\n')
- ||(rfc822[pos+1]=='\r'))) {
+ ||(rfc822[pos+1]=='\r')) ) {
+ end = pos;
+ done = 1;
+ }
+
+ if (pos >= (msglen-1) ) {
end = pos;
done = 1;
}
+ ++pos;
+
}
/* At this point we have a field. Are we interested in it? */
-/*
- * Utility function to "readline" from memory
- * (returns new pointer)
- */
-char *memreadline(char *start, char *buf, int maxlen)
-{
- char ch;
- char *ptr;
- int len = 0; /* tally our own length to avoid strlen() delays */
-
- ptr = start;
- memset(buf, 0, maxlen);
-
- while (1) {
- ch = *ptr++;
- if ( (len < (maxlen - 1)) && (ch != 13) && (ch != 10) ) {
- buf[strlen(buf) + 1] = 0;
- buf[strlen(buf)] = ch;
- ++len;
- }
- if ((ch == 10) || (ch == 0)) {
- return ptr;
- }
- }
-}
-
-
/*
* For non-multipart messages, we need to generate a quickie partnum of "1"
* to return to callback functions. Some callbacks demand it.
*/
void extract_key(char *target, char *source, char *key);
-
void mime_parser(char *content_start, char *content_end,
void (*CallBack)
(char *cbname,
return(0);
}
+
+
+/*
+ * Utility function to "readline" from memory
+ * (returns new pointer)
+ */
+char *memreadline(char *start, char *buf, int maxlen)
+{
+ char ch;
+ char *ptr;
+ int len = 0; /* tally our own length to avoid strlen() delays */
+
+ ptr = start;
+ memset(buf, 0, maxlen);
+
+ while (1) {
+ ch = *ptr++;
+ if ( (len < (maxlen - 1)) && (ch != 13) && (ch != 10) ) {
+ buf[strlen(buf) + 1] = 0;
+ buf[strlen(buf)] = ch;
+ ++len;
+ }
+ if ((ch == 10) || (ch == 0)) {
+ return ptr;
+ }
+ }
+}
+
+
void remove_token(char *source, int parmnum, char separator);
void fmt_date(char *buf, time_t thetime);
int is_msg_in_mset(char *mset, long msgnum);
+char *memreadline(char *start, char *buf, int maxlen);
#ifndef HAVE_STRNCASECMP
int strncasecmp(char *, char *, int)