Mercurial > dwindows
comparison compat.c @ 176:4e3407df0e38
Specify calling convention for compat functions.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 01 Dec 2002 14:04:08 +0000 |
parents | 0fc45e386376 |
children | f225f16bebbd |
comparison
equal
deleted
inserted
replaced
175:d78d08440246 | 176:4e3407df0e38 |
---|---|
37 usleep(period * 1000); | 37 usleep(period * 1000); |
38 #endif | 38 #endif |
39 } | 39 } |
40 #endif | 40 #endif |
41 | 41 |
42 int sockread (int a, void *b, int c, int d) | 42 int API sockread (int a, void *b, int c, int d) |
43 { | 43 { |
44 #if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) | 44 #if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) |
45 return recv(a,b,c,d); | 45 return recv(a,b,c,d); |
46 #else | 46 #else |
47 return read(a,b,c); | 47 return read(a,b,c); |
48 #endif | 48 #endif |
49 } | 49 } |
50 | 50 |
51 int sockwrite (int a, void *b, int c, int d) | 51 int API sockwrite (int a, void *b, int c, int d) |
52 { | 52 { |
53 #if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) | 53 #if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) |
54 return send(a,b,c,d); | 54 return send(a,b,c,d); |
55 #else | 55 #else |
56 return write(a,b,c); | 56 return write(a,b,c); |
57 #endif | 57 #endif |
58 } | 58 } |
59 | 59 |
60 int sockclose(int a) | 60 int API sockclose(int a) |
61 { | 61 { |
62 #ifdef __IBMC__ | 62 #ifdef __IBMC__ |
63 return soclose(a); | 63 return soclose(a); |
64 #elif defined(__WIN32__) && !defined(__CYGWIN32__) | 64 #elif defined(__WIN32__) && !defined(__CYGWIN32__) |
65 return closesocket(a); | 65 return closesocket(a); |
66 #else | 66 #else |
67 return close(a); | 67 return close(a); |
68 #endif | 68 #endif |
69 } | 69 } |
70 | 70 |
71 int makedir(char *path) | 71 int API makedir(char *path) |
72 { | 72 { |
73 #if defined(__IBMC__) || defined(__WATCOMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) | 73 #if defined(__IBMC__) || defined(__WATCOMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__)) |
74 return mkdir(path); | 74 return mkdir(path); |
75 #else | 75 #else |
76 return mkdir(path,S_IRWXU); | 76 return mkdir(path,S_IRWXU); |
77 #endif | 77 #endif |
78 } | 78 } |
79 | 79 |
80 void nonblock(int fd) | 80 void API nonblock(int fd) |
81 { | 81 { |
82 #if defined(__OS2__) && !defined(__EMX__) | 82 #if defined(__OS2__) && !defined(__EMX__) |
83 static int _nonblock = 1; | 83 static int _nonblock = 1; |
84 | 84 |
85 ioctl(fd, FIONBIO, (char *)&_nonblock, sizeof(_nonblock)); | 85 ioctl(fd, FIONBIO, (char *)&_nonblock, sizeof(_nonblock)); |
90 #else | 90 #else |
91 fcntl(fd, F_SETFL, O_NONBLOCK); | 91 fcntl(fd, F_SETFL, O_NONBLOCK); |
92 #endif | 92 #endif |
93 } | 93 } |
94 | 94 |
95 void block(int fd) | 95 void API block(int fd) |
96 { | 96 { |
97 #if defined(__OS2__) && !defined(__EMX__) | 97 #if defined(__OS2__) && !defined(__EMX__) |
98 static int _nonblock = 0; | 98 static int _nonblock = 0; |
99 | 99 |
100 ioctl(fd, FIONBIO, (char *)&_nonblock, sizeof(_nonblock)); | 100 ioctl(fd, FIONBIO, (char *)&_nonblock, sizeof(_nonblock)); |
105 #else | 105 #else |
106 fcntl(fd, F_SETFL, 0); | 106 fcntl(fd, F_SETFL, 0); |
107 #endif | 107 #endif |
108 } | 108 } |
109 | 109 |
110 int socksprintf(int fd, char *format, ...) | 110 int API socksprintf(int fd, char *format, ...) |
111 { | 111 { |
112 va_list args; | 112 va_list args; |
113 char outbuf[1024]; | 113 char outbuf[1024]; |
114 int len; | 114 int len; |
115 | 115 |
121 sockwrite(fd, outbuf, len, 0); | 121 sockwrite(fd, outbuf, len, 0); |
122 | 122 |
123 return len; | 123 return len; |
124 } | 124 } |
125 | 125 |
126 void sockinit(void) | 126 void API sockinit(void) |
127 { | 127 { |
128 #ifdef __IBMC__ | 128 #ifdef __IBMC__ |
129 sock_init(); | 129 sock_init(); |
130 #elif defined(__WIN32__) || defined(WINNT) | 130 #elif defined(__WIN32__) || defined(WINNT) |
131 WSADATA wsa; | 131 WSADATA wsa; |
132 | 132 |
133 WSAStartup(MAKEWORD (1, 1), &wsa); | 133 WSAStartup(MAKEWORD (1, 1), &wsa); |
134 #endif /* !WIN32 */ | 134 #endif /* !WIN32 */ |
135 } | 135 } |
136 | 136 |
137 void sockshutdown(void) | 137 void API sockshutdown(void) |
138 { | 138 { |
139 #if defined(__WIN32__) || defined(WINNT) | 139 #if defined(__WIN32__) || defined(WINNT) |
140 WSACleanup(); | 140 WSACleanup(); |
141 #endif /* !WIN32 */ | 141 #endif /* !WIN32 */ |
142 } | 142 } |
143 | 143 |
144 int sockpipe(int *pipes) | 144 int API sockpipe(int *pipes) |
145 { | 145 { |
146 #ifndef NO_DOMAIN_SOCKETS | 146 #ifndef NO_DOMAIN_SOCKETS |
147 #ifndef HAVE_PIPE | 147 #ifndef HAVE_PIPE |
148 struct sockaddr_un un; | 148 struct sockaddr_un un; |
149 #endif | 149 #endif |
206 if(pipes[0] < 0 || pipes[1] < 0) | 206 if(pipes[0] < 0 || pipes[1] < 0) |
207 return -1; | 207 return -1; |
208 return 0; | 208 return 0; |
209 } | 209 } |
210 | 210 |
211 long double drivefree(int drive) | 211 long double API drivefree(int drive) |
212 { | 212 { |
213 #if defined(__EMX__) || defined(__OS2__) | 213 #if defined(__EMX__) || defined(__OS2__) |
214 ULONG aulFSInfoBuf[40] = {0}; | 214 ULONG aulFSInfoBuf[40] = {0}; |
215 APIRET rc = NO_ERROR; | 215 APIRET rc = NO_ERROR; |
216 | 216 |
303 } | 303 } |
304 return 0; | 304 return 0; |
305 #endif | 305 #endif |
306 } | 306 } |
307 | 307 |
308 long double drivesize(int drive) | 308 long double API drivesize(int drive) |
309 { | 309 { |
310 #if defined(__EMX__) || defined(__OS2__) | 310 #if defined(__EMX__) || defined(__OS2__) |
311 ULONG aulFSInfoBuf[40] = {0}; | 311 ULONG aulFSInfoBuf[40] = {0}; |
312 APIRET rc = NO_ERROR; | 312 APIRET rc = NO_ERROR; |
313 | 313 |
400 } | 400 } |
401 return 0; | 401 return 0; |
402 #endif | 402 #endif |
403 } | 403 } |
404 | 404 |
405 int isdrive(int drive) | 405 int API isdrive(int drive) |
406 { | 406 { |
407 #if defined(__EMX__) || defined(__OS2__) | 407 #if defined(__EMX__) || defined(__OS2__) |
408 APIRET rc = NO_ERROR; | 408 APIRET rc = NO_ERROR; |
409 FSINFO volinfo; | 409 FSINFO volinfo; |
410 | 410 |
491 } | 491 } |
492 #endif | 492 #endif |
493 return 0; | 493 return 0; |
494 } | 494 } |
495 | 495 |
496 void getfsname(int drive, char *buf, int len) | 496 void API getfsname(int drive, char *buf, int len) |
497 { | 497 { |
498 #ifdef __UNIX__ | 498 #ifdef __UNIX__ |
499 #ifdef __FreeBSD__ | 499 #ifdef __FreeBSD__ |
500 struct statfs *fsp; | 500 struct statfs *fsp; |
501 int entries, index = 1; | 501 int entries, index = 1; |
551 #else | 551 #else |
552 _snprintf(buf, len, "Drive %c", (char)drive + 'A' - 1); | 552 _snprintf(buf, len, "Drive %c", (char)drive + 'A' - 1); |
553 #endif | 553 #endif |
554 } | 554 } |
555 | 555 |
556 void setfileinfo(char *filename, char *url, char *logfile) | 556 void API setfileinfo(char *filename, char *url, char *logfile) |
557 { | 557 { |
558 time_t ltime; | 558 time_t ltime; |
559 struct tm *tm; | 559 struct tm *tm; |
560 char buffer[200], timebuf[200]; | 560 char buffer[200], timebuf[200]; |
561 #ifdef __OS2__ | 561 #ifdef __OS2__ |
627 | 627 |
628 #define FSI_MAX 100 | 628 #define FSI_MAX 100 |
629 #endif | 629 #endif |
630 | 630 |
631 /* Sharable fopen() and fclose() calls. */ | 631 /* Sharable fopen() and fclose() calls. */ |
632 FILE *fsopen(char *path, char *modes) | 632 FILE * API fsopen(char *path, char *modes) |
633 { | 633 { |
634 #if (defined(__OS2__) && !defined(__WATCOMC__)) || defined(__WIN32__) | 634 #if (defined(__OS2__) && !defined(__WATCOMC__)) || defined(__WIN32__) |
635 int z; | 635 int z; |
636 | 636 |
637 if(!FSIRoot) | 637 if(!FSIRoot) |
676 #else | 676 #else |
677 return fopen(path, modes); | 677 return fopen(path, modes); |
678 #endif | 678 #endif |
679 } | 679 } |
680 | 680 |
681 int fsclose(FILE *fp) | 681 int API fsclose(FILE *fp) |
682 { | 682 { |
683 #if defined(__OS2__) || defined(__WIN32__) | 683 #if defined(__OS2__) || defined(__WIN32__) |
684 if(FSIRoot) | 684 if(FSIRoot) |
685 { | 685 { |
686 | 686 |
699 } | 699 } |
700 #endif | 700 #endif |
701 return fclose(fp); | 701 return fclose(fp); |
702 } | 702 } |
703 | 703 |
704 char *fsgets(char *str, int size, FILE *stream) | 704 char * API fsgets(char *str, int size, FILE *stream) |
705 { | 705 { |
706 return fgets(str, size, stream); | 706 return fgets(str, size, stream); |
707 } | 707 } |
708 | 708 |
709 int fsseek(FILE *stream, long offset, int whence) | 709 int API fsseek(FILE *stream, long offset, int whence) |
710 { | 710 { |
711 return fseek(stream, offset, whence); | 711 return fseek(stream, offset, whence); |
712 } | 712 } |
713 | 713 |
714 static int locale_number = -1, locale_count = 0; | 714 static int locale_number = -1, locale_count = 0; |
775 #endif | 775 #endif |
776 | 776 |
777 /* Initialize the locale engine | 777 /* Initialize the locale engine |
778 * Returns: TRUE on success, FALSE on failure. | 778 * Returns: TRUE on success, FALSE on failure. |
779 */ | 779 */ |
780 int locale_init(char *filename, int my_locale) | 780 int API locale_init(char *filename, int my_locale) |
781 { | 781 { |
782 FILE *fp = fopen(filename, FOPEN_READ_TEXT); | 782 FILE *fp = fopen(filename, FOPEN_READ_TEXT); |
783 static char text[1025]; | 783 static char text[1025]; |
784 int count = 0; | 784 int count = 0; |
785 | 785 |
869 } | 869 } |
870 return 0; | 870 return 0; |
871 } | 871 } |
872 | 872 |
873 /* Retrieve a localized string if available */ | 873 /* Retrieve a localized string if available */ |
874 char *locale_string(char *default_text, int message) | 874 char * API locale_string(char *default_text, int message) |
875 { | 875 { |
876 if(locale_number > -1 && message < locale_count && message > -1 && locale_text[message]) | 876 if(locale_number > -1 && message < locale_count && message > -1 && locale_text[message]) |
877 return locale_text[message]; | 877 return locale_text[message]; |
878 return default_text; | 878 return default_text; |
879 } | 879 } |