From: Michael R Sweet Date: Wed, 10 Oct 2018 04:18:00 +0000 (-0400) Subject: Migrate Windows conditional code to _WIN32 define. X-Git-Tag: v2.3b6~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24a06ed38135679efe65e3a6cf844c64cd04f79e;p=thirdparty%2Fcups.git Migrate Windows conditional code to _WIN32 define. --- diff --git a/backend/lpd.c b/backend/lpd.c index 0fbe38c443..e705ed406f 100644 --- a/backend/lpd.c +++ b/backend/lpd.c @@ -19,14 +19,14 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 # include #else # include # include # include # include -#endif /* WIN32 */ +#endif /* _WIN32 */ #ifdef __APPLE__ # include # include @@ -618,11 +618,11 @@ cups_rresvport(int *port, /* IO - Port number to bind to */ * -1... */ -#ifdef WIN32 +#ifdef _WIN32 closesocket(fd); #else close(fd); -#endif /* WIN32 */ +#endif /* _WIN32 */ return (-1); } @@ -730,11 +730,11 @@ lpd_queue(const char *hostname, /* I - Host to connect to */ ssize_t nbytes; /* Number of bytes written */ off_t tbytes; /* Total bytes written */ char buffer[32768]; /* Output buffer */ -#ifdef WIN32 +#ifdef _WIN32 DWORD tv; /* Timeout in milliseconds */ #else struct timeval tv; /* Timeout in secs and usecs */ -#endif /* WIN32 */ +#endif /* _WIN32 */ /* @@ -917,7 +917,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */ * Set the timeout... */ -#ifdef WIN32 +#ifdef _WIN32 tv = (DWORD)(timeout * 1000); setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)); @@ -928,7 +928,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */ setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); -#endif /* WIN32 */ +#endif /* _WIN32 */ fputs("STATE: -connecting-to-device\n", stderr); _cupsLangPrintFilter(stderr, "INFO", _("Connected to printer.")); diff --git a/backend/socket.c b/backend/socket.c index 0a94f08b84..675061dd9a 100644 --- a/backend/socket.c +++ b/backend/socket.c @@ -18,7 +18,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 # include #else # include @@ -27,7 +27,7 @@ # include # include # include -#endif /* WIN32 */ +#endif /* _WIN32 */ /* diff --git a/backend/test1284.c b/backend/test1284.c index 97825f5839..2da1086500 100644 --- a/backend/test1284.c +++ b/backend/test1284.c @@ -13,12 +13,12 @@ */ #include -#ifdef WIN32 +#ifdef _WIN32 # include #else # include # include -#endif /* WIN32 */ +#endif /* _WIN32 */ #include "ieee1284.c" diff --git a/backend/usb.c b/backend/usb.c index a870a6b6de..e1b2c03dc9 100644 --- a/backend/usb.c +++ b/backend/usb.c @@ -19,13 +19,13 @@ #include "backend-private.h" -#ifdef WIN32 +#ifdef _WIN32 # include #else # include # include # include -#endif /* WIN32 */ +#endif /* _WIN32 */ /* diff --git a/cgi-bin/cgi.h b/cgi-bin/cgi.h index 70a0edca53..c7e221b28c 100644 --- a/cgi-bin/cgi.h +++ b/cgi-bin/cgi.h @@ -15,12 +15,12 @@ # include # include -# ifdef WIN32 +# ifdef _WIN32 # include # include # else # include -# endif /* WIN32 */ +# endif /* _WIN32 */ # include # include diff --git a/ppdc/ppdc-source.cxx b/ppdc/ppdc-source.cxx index 4e8cba7bb3..c25d49668e 100644 --- a/ppdc/ppdc-source.cxx +++ b/ppdc/ppdc-source.cxx @@ -20,9 +20,9 @@ #include "data/epson.h" #include "data/hp.h" #include "data/label.h" -#ifndef WIN32 +#ifndef _WIN32 # include -#endif // !WIN32 +#endif // !_WIN32 // @@ -70,7 +70,7 @@ ppdcSource::ppdcSource(const char *f, // I - File to read vars->add(new ppdcVariable("CUPS_VERSION_MINOR", MAKE_STRING(CUPS_VERSION_MINOR))); vars->add(new ppdcVariable("CUPS_VERSION_PATCH", MAKE_STRING(CUPS_VERSION_PATCH))); -#ifdef WIN32 +#ifdef _WIN32 vars->add(new ppdcVariable("PLATFORM_NAME", "Windows")); vars->add(new ppdcVariable("PLATFORM_ARCH", "X86")); @@ -87,7 +87,7 @@ ppdcSource::ppdcSource(const char *f, // I - File to read vars->add(new ppdcVariable("PLATFORM_NAME", "unknown")); vars->add(new ppdcVariable("PLATFORM_ARCH", "unknown")); } -#endif // WIN32 +#endif // _WIN32 if (f) read_file(f, ffp); diff --git a/scheduler/cupsd.h b/scheduler/cupsd.h index c0174fae71..bc1350e7e7 100644 --- a/scheduler/cupsd.h +++ b/scheduler/cupsd.h @@ -27,11 +27,11 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 # include #else # include -#endif /* WIN32 */ +#endif /* _WIN32 */ #include "mime.h" diff --git a/scheduler/type.c b/scheduler/type.c index 1954374142..719afb7df9 100644 --- a/scheduler/type.c +++ b/scheduler/type.c @@ -1083,7 +1083,7 @@ mime_check_rules( break; case MIME_MAGIC_LOCALE : -#if defined(WIN32) || defined(__EMX__) || defined(__APPLE__) +#if defined(_WIN32) || defined(__EMX__) || defined(__APPLE__) result = !strcmp(rules->value.localev, setlocale(LC_ALL, "")); #else result = !strcmp(rules->value.localev, setlocale(LC_MESSAGES, "")); diff --git a/systemv/cupstestppd.c b/systemv/cupstestppd.c index 1880a2dfab..8e498a5962 100644 --- a/systemv/cupstestppd.c +++ b/systemv/cupstestppd.c @@ -18,9 +18,9 @@ #include #include #include -#ifdef WIN32 +#ifdef _WIN32 # define X_OK 0 -#endif /* WIN32 */ +#endif /* _WIN32 */ /* diff --git a/test/ippfind.c b/test/ippfind.c index 2993ea7f8d..0a698d0700 100644 --- a/test/ippfind.c +++ b/test/ippfind.c @@ -15,12 +15,12 @@ #define _CUPS_NO_DEPRECATED #include -#ifdef WIN32 +#ifdef _WIN32 # include # include #else # include -#endif /* WIN32 */ +#endif /* _WIN32 */ #include #ifdef HAVE_DNSSD # include @@ -34,9 +34,9 @@ # define kDNSServiceMaxDomainName AVAHI_DOMAIN_NAME_MAX #endif /* HAVE_DNSSD */ -#ifndef WIN32 +#ifndef _WIN32 extern char **environ; /* Process environment variables */ -#endif /* !WIN32 */ +#endif /* !_WIN32 */ /* @@ -1733,10 +1733,10 @@ dnssd_error_string(int error) /* I - Error number */ case kDNSServiceErr_PollingMode : return ("Service polling mode error."); -#ifndef WIN32 +#ifndef _WIN32 case kDNSServiceErr_Timeout : return ("Service timeout."); -#endif /* !WIN32 */ +#endif /* !_WIN32 */ } # elif defined(HAVE_AVAHI) @@ -1887,10 +1887,10 @@ exec_program(ippfind_srv_t *service, /* I - Service */ int i, /* Looping var */ myenvc, /* Number of environment variables */ status; /* Exit status of program */ -#ifndef WIN32 +#ifndef _WIN32 char program[1024]; /* Program to execute */ int pid; /* Process ID */ -#endif /* !WIN32 */ +#endif /* !_WIN32 */ /* @@ -2025,7 +2025,7 @@ exec_program(ippfind_srv_t *service, /* I - Service */ myargv[i] = strdup(args[i]); } -#ifdef WIN32 +#ifdef _WIN32 if (getenv("IPPFIND_DEBUG")) { printf("\nProgram:\n %s\n", args[0]); @@ -2088,7 +2088,7 @@ exec_program(ippfind_srv_t *service, /* I - Service */ while (wait(&status) != pid) ; } -#endif /* WIN32 */ +#endif /* _WIN32 */ /* * Free memory... @@ -2106,14 +2106,14 @@ exec_program(ippfind_srv_t *service, /* I - Service */ if (getenv("IPPFIND_DEBUG")) { -#ifdef WIN32 +#ifdef _WIN32 printf("Exit Status: %d\n", status); #else if (WIFEXITED(status)) printf("Exit Status: %d\n", WEXITSTATUS(status)); else printf("Terminating Signal: %d\n", WTERMSIG(status)); -#endif /* WIN32 */ +#endif /* _WIN32 */ } return (status == 0); @@ -2187,7 +2187,7 @@ get_service(cups_array_t *services, /* I - Service array */ static double get_time(void) { -#ifdef WIN32 +#ifdef _WIN32 struct _timeb curtime; /* Current Windows time */ _ftime(&curtime); @@ -2201,7 +2201,7 @@ get_time(void) return (0.0); else return (curtime.tv_sec + 0.000001 * curtime.tv_usec); -#endif /* WIN32 */ +#endif /* _WIN32 */ } diff --git a/test/ippserver.c b/test/ippserver.c index 8769094e8f..f291b389cc 100644 --- a/test/ippserver.c +++ b/test/ippserver.c @@ -31,7 +31,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 # include # include # include @@ -45,7 +45,7 @@ extern char **environ; # include # include # include -#endif /* WIN32 */ +#endif /* _WIN32 */ #ifdef HAVE_DNSSD # include @@ -662,7 +662,7 @@ main(int argc, /* I - Number of command-line args */ if (!port) { -#ifdef WIN32 +#ifdef _WIN32 /* * Windows is almost always used as a single user system, so use a default * port number of 8631. @@ -676,7 +676,7 @@ main(int argc, /* I - Number of command-line args */ */ port = 8000 + ((int)getuid() % 1000); -#endif /* WIN32 */ +#endif /* _WIN32 */ fprintf(stderr, "Listening on port %d.\n", port); } @@ -685,7 +685,7 @@ main(int argc, /* I - Number of command-line args */ { const char *tmpdir; /* Temporary directory */ -#ifdef WIN32 +#ifdef _WIN32 if ((tmpdir = getenv("TEMP")) == NULL) tmpdir = "C:/TEMP"; #elif defined(__APPLE__) && !TARGET_OS_IOS @@ -694,7 +694,7 @@ main(int argc, /* I - Number of command-line args */ #else if ((tmpdir = getenv("TMPDIR")) == NULL) tmpdir = "/tmp"; -#endif /* WIN32 */ +#endif /* _WIN32 */ snprintf(directory, sizeof(directory), "%s/ippserver.%d", tmpdir, (int)getpid()); @@ -1290,9 +1290,9 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) { int i, j; /* Looping vars */ _ipp_printer_t *printer; /* Printer */ -#ifndef WIN32 +#ifndef _WIN32 char path[1024]; /* Full path to command */ -#endif /* !WIN32 */ +#endif /* !_WIN32 */ char uri[1024], /* Printer URI */ #ifdef HAVE_SSL securi[1024], /* Secure printer URI */ @@ -1495,7 +1495,7 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) }; -#ifndef WIN32 +#ifndef _WIN32 /* * If a command was specified, make sure it exists and is executable... */ @@ -1521,7 +1521,7 @@ create_printer(const char *servername, /* I - Server hostname (NULL for default) command = path; } } -#endif /* !WIN32 */ +#endif /* !_WIN32 */ /* * Allocate memory for the printer... @@ -2497,9 +2497,9 @@ filter_cb(_ipp_filter_t *filter, /* I - Filter parameters */ * Filter attributes as needed... */ -#ifndef WIN32 /* Avoid MS compiler bug */ +#ifndef _WIN32 /* Avoid MS compiler bug */ (void)dst; -#endif /* !WIN32 */ +#endif /* !_WIN32 */ ipp_tag_t group = ippGetGroupTag(attr); const char *name = ippGetName(attr); @@ -6057,13 +6057,13 @@ process_job(_ipp_job_t *job) /* I - Job */ ipp_attribute_t *attr; /* Job attribute */ char val[1280], /* IPP_NAME=value */ *valptr; /* Pointer into string */ -#ifndef WIN32 +#ifndef _WIN32 int mypipe[2]; /* Pipe for stderr */ char line[2048], /* Line from stderr */ *ptr, /* Pointer into line */ *endptr; /* End of line */ ssize_t bytes; /* Bytes read */ -#endif /* !WIN32 */ +#endif /* !_WIN32 */ fprintf(stderr, "Running command \"%s %s\".\n", job->printer->command, job->filename); @@ -6121,7 +6121,7 @@ process_job(_ipp_job_t *job) /* I - Job */ * Now run the program... */ -#ifdef WIN32 +#ifdef _WIN32 status = _spawnvpe(_P_WAIT, job->printer->command, myargv, myenvp); #else @@ -6231,20 +6231,20 @@ process_job(_ipp_job_t *job) /* I - Job */ while (wait(&status) < 0); # endif /* HAVE_WAITPID */ } -#endif /* WIN32 */ +#endif /* _WIN32 */ if (status) { -#ifndef WIN32 +#ifndef _WIN32 if (WIFEXITED(status)) -#endif /* !WIN32 */ +#endif /* !_WIN32 */ fprintf(stderr, "Command \"%s\" exited with status %d.\n", job->printer->command, WEXITSTATUS(status)); -#ifndef WIN32 +#ifndef _WIN32 else fprintf(stderr, "Command \"%s\" terminated with signal %d.\n", job->printer->command, WTERMSIG(status)); -#endif /* !WIN32 */ +#endif /* !_WIN32 */ job->state = IPP_JSTATE_ABORTED; } else if (status < 0) diff --git a/test/ipptool.c b/test/ipptool.c index 9b5bc6395c..8d7630df2a 100644 --- a/test/ipptool.c +++ b/test/ipptool.c @@ -16,7 +16,7 @@ #include #include #include -#ifdef WIN32 +#ifdef _WIN32 # include # ifndef R_OK # define R_OK 0 @@ -24,7 +24,7 @@ #else # include # include -#endif /* WIN32 */ +#endif /* _WIN32 */ #ifndef O_BINARY # define O_BINARY 0 #endif /* !O_BINARY */ @@ -186,9 +186,9 @@ static void print_line(_cups_testdata_t *data, ipp_t *ipp, ipp_attribute_t *attr static void print_xml_header(_cups_testdata_t *data); static void print_xml_string(cups_file_t *outfile, const char *element, const char *s); static void print_xml_trailer(_cups_testdata_t *data, int success, const char *message); -#ifndef WIN32 +#ifndef _WIN32 static void sigterm_handler(int sig); -#endif /* WIN32 */ +#endif /* _WIN32 */ static int timeout_cb(http_t *http, void *user_data); static int token_cb(_ipp_file_t *f, _ipp_vars_t *vars, _cups_testdata_t *data, const char *token); static void usage(void) _CUPS_NORETURN; @@ -222,14 +222,14 @@ main(int argc, /* I - Number of command-line args */ /* Global data */ -#ifndef WIN32 +#ifndef _WIN32 /* * Catch SIGINT and SIGTERM... */ signal(SIGINT, sigterm_handler); signal(SIGTERM, sigterm_handler); -#endif /* !WIN32 */ +#endif /* !_WIN32 */ /* * Initialize the locale and variables... @@ -464,9 +464,9 @@ main(int argc, /* I - Number of command-line args */ snprintf(filename, sizeof(filename), "%s.gz", argv[i]); if (access(filename, 0) && filename[0] != '/' -#ifdef WIN32 +#ifdef _WIN32 && (!isalpha(filename[0] & 255) || filename[1] != ':') -#endif /* WIN32 */ +#endif /* _WIN32 */ ) { snprintf(filename, sizeof(filename), "%s/ipptool/%s", cg->cups_datadir, argv[i]); @@ -651,9 +651,9 @@ main(int argc, /* I - Number of command-line args */ } if (access(argv[i], 0) && argv[i][0] != '/' -#ifdef WIN32 +#ifdef _WIN32 && (!isalpha(argv[i][0] & 255) || argv[i][1] != ':') -#endif /* WIN32 */ +#endif /* _WIN32 */ ) { snprintf(testname, sizeof(testname), "%s/ipptool/%s", cg->cups_datadir, argv[i]); @@ -1094,11 +1094,11 @@ do_test(_ipp_file_t *f, /* I - IPP data file */ } if (!Cancel && status == HTTP_STATUS_ERROR && httpError(data->http) != EINVAL && -#ifdef WIN32 +#ifdef _WIN32 httpError(data->http) != WSAETIMEDOUT) #else httpError(data->http) != ETIMEDOUT) -#endif /* WIN32 */ +#endif /* _WIN32 */ { if (httpReconnect2(data->http, 30000, NULL)) data->prev_pass = 0; @@ -1121,11 +1121,11 @@ do_test(_ipp_file_t *f, /* I - IPP data file */ } if (!Cancel && status == HTTP_STATUS_ERROR && httpError(data->http) != EINVAL && -#ifdef WIN32 +#ifdef _WIN32 httpError(data->http) != WSAETIMEDOUT) #else httpError(data->http) != ETIMEDOUT) -#endif /* WIN32 */ +#endif /* _WIN32 */ { if (httpReconnect2(data->http, 30000, NULL)) data->prev_pass = 0; @@ -2022,9 +2022,9 @@ get_filename(const char *testfile, /* I - Current test file */ *dstptr = '\0'; } else if (!access(src, R_OK) || *src == '/' -#ifdef WIN32 +#ifdef _WIN32 || (isalpha(*src & 255) && src[1] == ':') -#endif /* WIN32 */ +#endif /* _WIN32 */ ) { /* @@ -2183,7 +2183,7 @@ iso_date(const ipp_uchar_t *date) /* I - IPP (RFC 1903) date/time value */ static void pause_message(const char *message) /* I - Message */ { -#ifdef WIN32 +#ifdef _WIN32 HANDLE tty; /* Console handle */ DWORD mode; /* Console mode */ char key; /* Key press */ @@ -2231,7 +2231,7 @@ pause_message(const char *message) /* I - Message */ close(tty); return; } -#endif /* WIN32 */ +#endif /* _WIN32 */ /* * Display the prompt... @@ -2239,7 +2239,7 @@ pause_message(const char *message) /* I - Message */ cupsFilePrintf(cupsFileStdout(), "%s\n---- PRESS ANY KEY ----", message); -#ifdef WIN32 +#ifdef _WIN32 /* * Read a key... */ @@ -2265,7 +2265,7 @@ pause_message(const char *message) /* I - Message */ tcsetattr(tty, TCSAFLUSH, &original); close(tty); -#endif /* WIN32 */ +#endif /* _WIN32 */ /* * Erase the "press any key" prompt... @@ -2928,7 +2928,7 @@ print_xml_trailer( } -#ifndef WIN32 +#ifndef _WIN32 /* * 'sigterm_handler()' - Handle SIGINT and SIGTERM. */ @@ -2943,7 +2943,7 @@ sigterm_handler(int sig) /* I - Signal number (unused) */ signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); } -#endif /* !WIN32 */ +#endif /* !_WIN32 */ /*