diff options
| author | Richard M. Stallman | 1994-10-19 22:52:57 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-10-19 22:52:57 +0000 |
| commit | 8148baf912290dccd9691e0df509bdf4312c8be6 (patch) | |
| tree | 3776bdd994a47583242057ab67bc939bd6b59b3b /lib-src | |
| parent | 1a9654a0c30ebaf6c00199c39d87be5bd3eb063a (diff) | |
| download | emacs-8148baf912290dccd9691e0df509bdf4312c8be6.tar.gz emacs-8148baf912290dccd9691e0df509bdf4312c8be6.zip | |
Only include ../src/config.h if HAVE_CONFIG_H is
defined, and if HAVE_CONFIG_H isn't defined, define
MAIL_USE_POP always (so that this file can be included in
other programs besides emacs).
Only declare h_errno if HAVE_H_ERRNO isn't defined or
HAVE_CONFIG_H isn't defined.
(find_crlf, getline): Instead of using strstr, use a
custom function for finding CRLF.
(my_strstr): Function deleted.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/pop.c | 77 |
1 files changed, 45 insertions, 32 deletions
diff --git a/lib-src/pop.c b/lib-src/pop.c index 66b26907105..878de5efc8d 100644 --- a/lib-src/pop.c +++ b/lib-src/pop.c | |||
| @@ -18,15 +18,22 @@ You should have received a copy of the GNU General Public License | |||
| 18 | along with GNU Emacs; see the file COPYING. If not, write to | 18 | along with GNU Emacs; see the file COPYING. If not, write to |
| 19 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | 19 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ |
| 20 | 20 | ||
| 21 | #define NO_SHORTNAMES /* Tell config not to load remap.h */ | 21 | #ifdef HAVE_CONFIG_H |
| 22 | #define NO_SHORTNAMES /* Tell config not to load remap.h */ | ||
| 22 | #include <../src/config.h> | 23 | #include <../src/config.h> |
| 24 | #else | ||
| 25 | #define MAIL_USE_POP | ||
| 26 | #endif | ||
| 23 | 27 | ||
| 24 | #under open | 28 | #ifdef MAIL_USE_POP |
| 25 | #undef close | 29 | |
| 30 | #ifdef HAVE_CONFIG_H | ||
| 31 | /* Cancel these substitutions made in config.h */ | ||
| 32 | #undef open | ||
| 26 | #undef read | 33 | #undef read |
| 27 | #undef write | 34 | #undef write |
| 28 | 35 | #undef close | |
| 29 | #ifdef MAIL_USE_POP | 36 | #endif |
| 30 | 37 | ||
| 31 | #include <sys/types.h> | 38 | #include <sys/types.h> |
| 32 | #include <netinet/in.h> | 39 | #include <netinet/in.h> |
| @@ -35,7 +42,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |||
| 35 | 42 | ||
| 36 | #ifdef sun | 43 | #ifdef sun |
| 37 | #include <malloc.h> | 44 | #include <malloc.h> |
| 38 | #endif | 45 | #endif /* sun */ |
| 39 | 46 | ||
| 40 | #ifdef HESIOD | 47 | #ifdef HESIOD |
| 41 | #include <hesiod.h> | 48 | #include <hesiod.h> |
| @@ -53,11 +60,6 @@ extern struct servent *hes_getservbyname (/* char *, char * */); | |||
| 53 | #include <errno.h> | 60 | #include <errno.h> |
| 54 | #include <stdio.h> | 61 | #include <stdio.h> |
| 55 | 62 | ||
| 56 | extern char *getenv (/* char * */); | ||
| 57 | extern char *getlogin (/* void */); | ||
| 58 | extern char *getpass (/* char * */); | ||
| 59 | extern char *strerror (/* int */); | ||
| 60 | |||
| 61 | #ifdef KERBEROS | 63 | #ifdef KERBEROS |
| 62 | #ifndef KRB5 | 64 | #ifndef KRB5 |
| 63 | #include <des.h> | 65 | #include <des.h> |
| @@ -67,15 +69,24 @@ extern char *strerror (/* int */); | |||
| 67 | #include <krb5/ext-proto.h> | 69 | #include <krb5/ext-proto.h> |
| 68 | #include <ctype.h> | 70 | #include <ctype.h> |
| 69 | #endif /* KRB5 */ | 71 | #endif /* KRB5 */ |
| 72 | #endif /* KERBEROS */ | ||
| 70 | 73 | ||
| 74 | extern char *getenv (/* char * */); | ||
| 75 | extern char *getlogin (/* void */); | ||
| 76 | extern char *getpass (/* char * */); | ||
| 77 | extern char *strerror (/* int */); | ||
| 78 | |||
| 79 | #ifdef KERBEROS | ||
| 80 | #ifndef KRB5 | ||
| 71 | extern int krb_sendauth (/* long, int, KTEXT, char *, char *, char *, | 81 | extern int krb_sendauth (/* long, int, KTEXT, char *, char *, char *, |
| 72 | u_long, MSG_DAT *, CREDENTIALS *, Key_schedule, | 82 | u_long, MSG_DAT *, CREDENTIALS *, Key_schedule, |
| 73 | struct sockaddr_in *, struct sockaddr_in *, | 83 | struct sockaddr_in *, struct sockaddr_in *, |
| 74 | char * */); | 84 | char * */); |
| 75 | extern char *krb_realmofhost (/* char * */); | 85 | extern char *krb_realmofhost (/* char * */); |
| 76 | #endif | 86 | #endif /* ! KRB5 */ |
| 87 | #endif /* KERBEROS */ | ||
| 77 | 88 | ||
| 78 | #ifndef HAVE_H_ERRNO | 89 | #if !defined(HAVE_H_ERRNO) || !defined(HAVE_CONFIG_H) |
| 79 | extern int h_errno; | 90 | extern int h_errno; |
| 80 | #endif | 91 | #endif |
| 81 | 92 | ||
| @@ -88,8 +99,7 @@ static int getok (/* popserver */); | |||
| 88 | static int gettermination (/* popserver */); | 99 | static int gettermination (/* popserver */); |
| 89 | #endif | 100 | #endif |
| 90 | static void pop_trash (/* popserver */); | 101 | static void pop_trash (/* popserver */); |
| 91 | 102 | static char *find_crlf (/* char * */); | |
| 92 | static char *my_strstr (); | ||
| 93 | 103 | ||
| 94 | #define ERROR_MAX 80 /* a pretty arbitrary size */ | 104 | #define ERROR_MAX 80 /* a pretty arbitrary size */ |
| 95 | #define POP_PORT 110 | 105 | #define POP_PORT 110 |
| @@ -1177,7 +1187,7 @@ getline (server) | |||
| 1177 | 1187 | ||
| 1178 | if (server->data) | 1188 | if (server->data) |
| 1179 | { | 1189 | { |
| 1180 | char *cp = my_strstr (server->buffer + server->buffer_index, "\r\n"); | 1190 | char *cp = find_crlf (server->buffer + server->buffer_index); |
| 1181 | if (cp) | 1191 | if (cp) |
| 1182 | { | 1192 | { |
| 1183 | int found; | 1193 | int found; |
| @@ -1241,7 +1251,7 @@ getline (server) | |||
| 1241 | server->data += ret; | 1251 | server->data += ret; |
| 1242 | server->buffer[server->data] = '\0'; | 1252 | server->buffer[server->data] = '\0'; |
| 1243 | 1253 | ||
| 1244 | cp = my_strstr (server->buffer, "\r\n"); | 1254 | cp = find_crlf (server->buffer); |
| 1245 | if (cp) | 1255 | if (cp) |
| 1246 | { | 1256 | { |
| 1247 | int data_used = (cp + 2) - server->buffer; | 1257 | int data_used = (cp + 2) - server->buffer; |
| @@ -1456,23 +1466,26 @@ pop_trash (server) | |||
| 1456 | } | 1466 | } |
| 1457 | } | 1467 | } |
| 1458 | 1468 | ||
| 1459 | /* Search in STRING for an occurrence of SUBSTRING | 1469 | /* Return a pointer to the first CRLF in IN_STRING, |
| 1460 | and return a pointer to that occurrence. | 1470 | or 0 if it does not contain one. */ |
| 1461 | Return 0 if SUBSTRING does not occur in STRING. */ | ||
| 1462 | 1471 | ||
| 1463 | static char * | 1472 | static char * |
| 1464 | my_strstr (string, substring) | 1473 | find_crlf (in_string) |
| 1465 | char *string, *substring; | 1474 | char *in_string; |
| 1466 | { | 1475 | { |
| 1467 | char *p = string; | 1476 | while (1) |
| 1468 | |||
| 1469 | while (*p) | ||
| 1470 | { | 1477 | { |
| 1471 | if (!strcmp (p, substring)) | 1478 | if (! *in_string) |
| 1472 | return p; | 1479 | return (0); |
| 1473 | p++; | 1480 | else if (*in_string == '\r') |
| 1481 | { | ||
| 1482 | if (*++in_string == '\n') | ||
| 1483 | return (in_string - 1); | ||
| 1484 | } | ||
| 1485 | else | ||
| 1486 | in_string++; | ||
| 1474 | } | 1487 | } |
| 1475 | return 0; | 1488 | /* NOTREACHED */ |
| 1476 | } | 1489 | } |
| 1477 | 1490 | ||
| 1478 | #endif /* MAIL_USE_POP */ | 1491 | #endif /* MAIL_USE_POP */ |