comparison lib-src/movemail.c @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 8de8e3f6228a
children 4a2749e56f92
comparison
equal deleted inserted replaced
441:72a7cfa4a488 442:abe6d1db359e
67 #include <sys/stat.h> 67 #include <sys/stat.h>
68 #include <stdio.h> 68 #include <stdio.h>
69 #include <errno.h> 69 #include <errno.h>
70 #include "../src/sysfile.h" 70 #include "../src/sysfile.h"
71 #include "../src/syswait.h" 71 #include "../src/syswait.h"
72 #ifndef WINDOWSNT 72 #ifndef WIN32_NATIVE
73 #include "../src/systime.h" 73 #include "../src/systime.h"
74 #endif 74 #endif
75 #include <stdlib.h> 75 #include <stdlib.h>
76 #include <string.h> 76 #include <string.h>
77 #include "getopt.h" 77 #include "getopt.h"
85 85
86 #ifndef HAVE_STRERROR 86 #ifndef HAVE_STRERROR
87 char * strerror (int errnum); 87 char * strerror (int errnum);
88 #endif /* HAVE_STRERROR */ 88 #endif /* HAVE_STRERROR */
89 89
90 #ifdef MSDOS
91 #undef access
92 #endif /* MSDOS */
93
94 #ifndef DIRECTORY_SEP 90 #ifndef DIRECTORY_SEP
95 #define DIRECTORY_SEP '/' 91 #define DIRECTORY_SEP '/'
96 #endif 92 #endif
97 #ifndef IS_DIRECTORY_SEP 93 #ifndef IS_DIRECTORY_SEP
98 #define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP) 94 #define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
99 #endif 95 #endif
100 96
101 #ifdef WINDOWSNT 97 #ifdef WIN32_NATIVE
102 #undef access 98 #undef access
103 #undef unlink 99 #undef unlink
104 #define fork() 0 100 #define fork() 0
105 #define sys_wait(var) (*(var) = 0) 101 #define sys_wait(var) (*(var) = 0)
106 /* Unfortunately, Samba doesn't seem to properly lock Unix files even 102 /* Unfortunately, Samba doesn't seem to properly lock Unix files even
108 other NT programs). If you have direct file access using an NFS 104 other NT programs). If you have direct file access using an NFS
109 client or something other than Samba, the locking call might work 105 client or something other than Samba, the locking call might work
110 properly - make sure it does before you enable this! */ 106 properly - make sure it does before you enable this! */
111 #define DISABLE_DIRECT_ACCESS 107 #define DISABLE_DIRECT_ACCESS
112 #include <io.h> 108 #include <io.h>
113 #endif /* WINDOWSNT */ 109 #endif /* WIN32_NATIVE */
114 110
115 #if defined (HAVE_UNISTD_H) 111 #if defined (HAVE_UNISTD_H)
116 #include <unistd.h> 112 #include <unistd.h>
117 #endif /* unistd.h */ 113 #endif /* unistd.h */
118 #ifndef F_OK 114 #ifndef F_OK
202 #define DEFAULT_LOCKING LOCKING 198 #define DEFAULT_LOCKING LOCKING
203 #else 199 #else
204 #define DEFAULT_LOCKING DOTLOCKING 200 #define DEFAULT_LOCKING DOTLOCKING
205 #endif 201 #endif
206 202
203 #ifndef DISABLE_DIRECT_ACCESS
207 static void lock_dot(char *); 204 static void lock_dot(char *);
205 #endif
208 static void unlock_dot(char *); 206 static void unlock_dot(char *);
209 static int parse_lock_method(char *); 207 static int parse_lock_method(char *);
210 static char *unparse_lock_method(int); 208 static char *unparse_lock_method(int);
211 209
212 int 210 int
339 { 337 {
340 int retcode = popmail (inname + 3, outname, poppass); 338 int retcode = popmail (inname + 3, outname, poppass);
341 exit (retcode); 339 exit (retcode);
342 } 340 }
343 341
344 #ifndef WINDOWSNT 342 #ifndef WIN32_NATIVE
345 setuid (getuid ()); 343 setuid (getuid ());
346 #endif 344 #endif
347 #endif /* MAIL_USE_POP */ 345 #endif /* MAIL_USE_POP */
348 346
349 #ifndef DISABLE_DIRECT_ACCESS 347 #ifndef DISABLE_DIRECT_ACCESS
564 return concat (filename, ".lock", ""); 562 return concat (filename, ".lock", "");
565 } 563 }
566 564
567 static char *dotlock_filename = NULL; 565 static char *dotlock_filename = NULL;
568 566
567 #ifndef DISABLE_DIRECT_ACCESS
569 static void 568 static void
570 lock_dot(char *filename) 569 lock_dot(char *filename)
571 { 570 {
572 struct stat st; 571 struct stat st;
573 long now; 572 long now;
623 unlink (lockname); 622 unlink (lockname);
624 } 623 }
625 } 624 }
626 strcpy(dotlock_filename, filename); 625 strcpy(dotlock_filename, filename);
627 } 626 }
627 #endif /* not DISABLE_DIRECT_ACCESS */
628 628
629 static void 629 static void
630 unlock_dot(char *filename) 630 unlock_dot(char *filename)
631 { 631 {
632 unlink(dot_filename(filename)); 632 unlink(dot_filename(filename));
703 703
704 /* This is the guts of the interface to the Post Office Protocol. */ 704 /* This is the guts of the interface to the Post Office Protocol. */
705 705
706 #ifdef MAIL_USE_POP 706 #ifdef MAIL_USE_POP
707 707
708 #ifndef WINDOWSNT 708 #ifndef WIN32_NATIVE
709 #include <sys/socket.h> 709 #include <sys/socket.h>
710 #include <netinet/in.h> 710 #include <netinet/in.h>
711 #include <netdb.h> 711 #include <netdb.h>
712 #else 712 #else
713 #undef _WINSOCKAPI_ 713 #undef _WINSOCKAPI_
714 #include <winsock.h> 714 #include <winsock.h>
715 #endif 715 #endif
716 #include <stdio.h> 716 #include <stdio.h>
717 #include <pwd.h> 717 #include "../src/syspwd.h"
718 718
719 #define POP_ERROR (-1) 719 #define POP_ERROR (-1)
720 #define POP_RETRIEVED (0) 720 #define POP_RETRIEVED (0)
721 #define POP_DONE (1) 721 #define POP_DONE (1)
722 722
768 { 768 {
769 pop_close (server); 769 pop_close (server);
770 error ("Error in open: %s, %s", strerror (errno), outfile); 770 error ("Error in open: %s, %s", strerror (errno), outfile);
771 return (1); 771 return (1);
772 } 772 }
773 #if !defined(__CYGWIN32__) && !defined(WINDOWSNT) 773 #if !defined(CYGWIN) && !defined(WIN32_NATIVE)
774 fchown (mbfi, getuid (), (gid_t) -1); 774 fchown (mbfi, getuid (), (gid_t) -1);
775 #endif 775 #endif
776 776
777 if ((mbf = fdopen (mbfi, "wb")) == NULL) 777 if ((mbf = fdopen (mbfi, "wb")) == NULL)
778 { 778 {