Mercurial > hg > xemacs-beta
comparison lib-src/pop.c @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | de805c49cfc1 |
children | 11054d720c21 |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 Boston, MA 02111-1307, USA. */ | 20 Boston, MA 02111-1307, USA. */ |
21 | 21 |
22 #ifdef HAVE_CONFIG_H | 22 #ifdef HAVE_CONFIG_H |
23 #define NO_SHORTNAMES /* Tell config not to load remap.h */ | 23 #define NO_SHORTNAMES /* Tell config not to load remap.h */ |
24 #define DONT_ENCAPSULATE | 24 #include <../src/config.h> |
25 #include <config.h> | |
26 #else | 25 #else |
27 #define MAIL_USE_POP | 26 #define MAIL_USE_POP |
28 #endif | 27 #endif |
29 | 28 |
30 #ifdef MAIL_USE_POP | 29 #ifdef MAIL_USE_POP |
31 | 30 |
31 #ifdef HAVE_CONFIG_H | |
32 /* Cancel these substitutions made in config.h */ | |
33 #undef open | |
34 #undef read | |
35 #undef write | |
36 #undef close | |
37 #endif | |
38 | |
32 #include <sys/types.h> | 39 #include <sys/types.h> |
33 #ifdef WIN32_NATIVE | 40 #ifdef WINDOWSNT |
34 #include <winsock.h> | 41 #include <winsock.h> |
35 #undef SOCKET_ERROR | 42 #undef SOCKET_ERROR |
36 #define RECV(s,buf,len,flags) recv(s,buf,len,flags) | 43 #define RECV(s,buf,len,flags) recv(s,buf,len,flags) |
37 #define SEND(s,buf,len,flags) send(s,buf,len,flags) | 44 #define SEND(s,buf,len,flags) send(s,buf,len,flags) |
38 #define CLOSESOCKET(s) closesocket(s) | 45 #define CLOSESOCKET(s) closesocket(s) |
58 * hesiod.h does. | 65 * hesiod.h does. |
59 */ | 66 */ |
60 extern struct servent *hes_getservbyname (/* char *, char * */); | 67 extern struct servent *hes_getservbyname (/* char *, char * */); |
61 #endif | 68 #endif |
62 | 69 |
63 #include "../src/syspwd.h" | 70 #include <pwd.h> |
64 #ifndef WIN32_NATIVE | |
65 #include <netdb.h> | 71 #include <netdb.h> |
66 #endif | |
67 #include <errno.h> | 72 #include <errno.h> |
68 #include <stdio.h> | 73 #include <stdio.h> |
69 | 74 |
70 #ifdef HAVE_UNISTD_H | |
71 #include <unistd.h> | 75 #include <unistd.h> |
72 #endif | |
73 #include <sys/stat.h> | 76 #include <sys/stat.h> |
74 #ifndef WIN32_NATIVE | |
75 #include <sys/file.h> | 77 #include <sys/file.h> |
76 #endif | |
77 #include "../src/syswait.h" | 78 #include "../src/syswait.h" |
78 #ifndef WIN32_NATIVE | 79 #ifndef WINDOWSNT |
79 #include "../src/systime.h" | 80 #include "../src/systime.h" |
80 #endif | 81 #endif |
81 #include <stdlib.h> | 82 #include <stdlib.h> |
82 #include <string.h> | 83 #include <string.h> |
83 | 84 |
100 char * */); | 101 char * */); |
101 extern char *krb_realmofhost (/* char * */); | 102 extern char *krb_realmofhost (/* char * */); |
102 #endif /* ! KRB5 */ | 103 #endif /* ! KRB5 */ |
103 #endif /* KERBEROS */ | 104 #endif /* KERBEROS */ |
104 | 105 |
105 #ifndef WIN32_NATIVE | 106 #ifndef WINDOWSNT |
106 #if !defined(HAVE_H_ERRNO) || !defined(HAVE_CONFIG_H) | 107 #if !defined(HAVE_H_ERRNO) || !defined(HAVE_CONFIG_H) |
107 extern int h_errno; | 108 extern int h_errno; |
108 #endif | 109 #endif |
109 #endif | 110 #endif |
110 | 111 |
120 static char *find_crlf (char *); | 121 static char *find_crlf (char *); |
121 | 122 |
122 #define ERROR_MAX 80 /* a pretty arbitrary size */ | 123 #define ERROR_MAX 80 /* a pretty arbitrary size */ |
123 #define POP_PORT 110 | 124 #define POP_PORT 110 |
124 #define KPOP_PORT 1109 | 125 #define KPOP_PORT 1109 |
125 #if defined(WIN32_NATIVE) || defined(CYGWIN) | 126 #if defined(WINDOWSNT) || defined(__CYGWIN32__) |
126 #define POP_SERVICE "pop3" /* we don't want the POP2 port! */ | 127 #define POP_SERVICE "pop3" /* we don't want the POP2 port! */ |
127 #else | 128 #else |
128 #define POP_SERVICE "pop" | 129 #define POP_SERVICE "pop" |
129 #endif | 130 #endif |
130 #ifdef KERBEROS | 131 #ifdef KERBEROS |
181 if (! username) | 182 if (! username) |
182 { | 183 { |
183 username = getenv ("USER"); | 184 username = getenv ("USER"); |
184 if (! (username && *username)) | 185 if (! (username && *username)) |
185 { | 186 { |
186 #ifndef WIN32_NATIVE | 187 #ifndef WINDOWSNT |
187 username = getlogin (); | 188 username = getlogin (); |
188 if (! (username && *username)) | 189 if (! (username && *username)) |
189 { | 190 { |
190 struct passwd *passwd; | 191 struct passwd *passwd; |
191 passwd = getpwuid (getuid ()); | 192 passwd = getpwuid (getuid ()); |
250 #define DONT_NEED_PASSWORD 0 | 251 #define DONT_NEED_PASSWORD 0 |
251 #endif | 252 #endif |
252 | 253 |
253 if ((! password) && (! DONT_NEED_PASSWORD)) | 254 if ((! password) && (! DONT_NEED_PASSWORD)) |
254 { | 255 { |
255 #ifndef WIN32_NATIVE | 256 #ifndef WINDOWSNT |
256 if (! (flags & POP_NO_GETPASS)) | 257 if (! (flags & POP_NO_GETPASS)) |
257 { | 258 { |
258 password = getpass ("Enter POP password:"); | 259 password = getpass ("Enter POP password:"); |
259 } | 260 } |
260 #endif | 261 #endif |
919 if (sendline (server, "QUIT") || getok (server)) | 920 if (sendline (server, "QUIT") || getok (server)) |
920 { | 921 { |
921 ret = -1; | 922 ret = -1; |
922 } | 923 } |
923 | 924 |
924 CLOSESOCKET (server->file); | 925 close (server->file); |
925 } | 926 } |
926 | 927 |
927 if (server->buffer) | 928 if (server->buffer) |
928 free (server->buffer); | 929 free (server->buffer); |
929 free ((char *) server); | 930 free ((char *) server); |
930 | 931 |
931 return (ret); | 932 return (ret); |
932 } | 933 } |
933 | 934 |
934 #ifdef WIN32_NATIVE | 935 #ifdef WINDOWSNT |
935 static int have_winsock = 0; | 936 static int have_winsock = 0; |
936 #endif | 937 #endif |
937 | 938 |
938 /* | 939 /* |
939 * Function: socket_connection | 940 * Function: socket_connection |
974 #endif /* KRB5 */ | 975 #endif /* KRB5 */ |
975 #endif /* KERBEROS */ | 976 #endif /* KERBEROS */ |
976 | 977 |
977 int try_count = 0; | 978 int try_count = 0; |
978 | 979 |
979 #ifdef WIN32_NATIVE | 980 #ifdef WINDOWSNT |
980 { | 981 { |
981 WSADATA winsockData; | 982 WSADATA winsockData; |
982 if (WSAStartup (0x101, &winsockData) == 0) | 983 if (WSAStartup (0x101, &winsockData) == 0) |
983 have_winsock = 1; | 984 have_winsock = 1; |
984 } | 985 } |
1479 free (server->buffer); | 1480 free (server->buffer); |
1480 server->buffer = 0; | 1481 server->buffer = 0; |
1481 } | 1482 } |
1482 } | 1483 } |
1483 | 1484 |
1484 #ifdef WIN32_NATIVE | 1485 #ifdef WINDOWSNT |
1485 if (have_winsock) | 1486 if (have_winsock) |
1486 WSACleanup (); | 1487 WSACleanup (); |
1487 #endif | 1488 #endif |
1488 } | 1489 } |
1489 | 1490 |