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