This commit is contained in:
Lev Walkin 2010-11-20 09:47:13 -08:00
parent 464166ca44
commit 936595643a
11 changed files with 35 additions and 35 deletions

View File

@ -42,7 +42,7 @@
#include <asn1c_compat.h> /* Portable basename(3) and dirname(3) */ #include <asn1c_compat.h> /* Portable basename(3) and dirname(3) */
#ifdef WIN32 #ifdef _WIN32
#include <io.h> #include <io.h>
#include <direct.h> #include <direct.h>
#else #else
@ -345,7 +345,7 @@ importStandardModules(asn1p_t *asn, const char *skeletons_dir) {
char *target_dir; char *target_dir;
int target_dir_len; int target_dir_len;
int len; int len;
#ifdef WIN32 #ifdef _WIN32
intptr_t dir; intptr_t dir;
struct _finddata_t c_file; struct _finddata_t c_file;
char *pattern; char *pattern;
@ -369,7 +369,7 @@ importStandardModules(asn1p_t *asn, const char *skeletons_dir) {
snprintf(target_dir, target_dir_len + 1, "%s/standard-modules", snprintf(target_dir, target_dir_len + 1, "%s/standard-modules",
skeletons_dir); skeletons_dir);
#ifdef WIN32 #ifdef _WIN32
len = target_dir_len + sizeof("/*.asn1"); len = target_dir_len + sizeof("/*.asn1");
pattern = malloc(len); pattern = malloc(len);
assert(pattern); assert(pattern);
@ -386,7 +386,7 @@ importStandardModules(asn1p_t *asn, const char *skeletons_dir) {
return -1; return -1;
} }
#ifdef WIN32 #ifdef _WIN32
do { do {
filename = c_file.name; filename = c_file.name;
#else #else
@ -416,7 +416,7 @@ importStandardModules(asn1p_t *asn, const char *skeletons_dir) {
} }
asn1p_delete(new_asn); asn1p_delete(new_asn);
#ifdef WIN32 #ifdef _WIN32
} while(_findnext(dir, &c_file) == 0); } while(_findnext(dir, &c_file) == 0);
_findclose(dir); _findclose(dir);
#else #else

View File

@ -46,9 +46,9 @@
#include <sys/stat.h> /* for stat(2) */ #include <sys/stat.h> /* for stat(2) */
#endif #endif
#ifndef WIN32 #ifndef _WIN32
#include <sysexits.h> /* for EX_USAGE & others */ #include <sysexits.h> /* for EX_USAGE & others */
#else /* WIN32 */ #else /* _WIN32 */
#ifndef EX_USAGE #ifndef EX_USAGE
#define EX_USAGE 64 #define EX_USAGE 64
#endif #endif
@ -66,5 +66,5 @@
#endif #endif
#define alloca _alloca #define alloca _alloca
#define snprintf _snprintf #define snprintf _snprintf
#endif /* WIN32 */ #endif /* _WIN32 */

View File

@ -6,7 +6,7 @@
#include <errno.h> #include <errno.h>
#include <sysexits.h> #include <sysexits.h>
#ifdef WIN32 #ifdef _WIN32
#define setuid(s) #define setuid(s)
#define getuid() #define getuid()
#define setgid(s) #define setgid(s)

View File

@ -6,7 +6,7 @@
#endif #endif
#ifndef DEFFILEMODE /* Normally in <sys/stat.h> */ #ifndef DEFFILEMODE /* Normally in <sys/stat.h> */
#ifdef WIN32 #ifdef _WIN32
#define DEFFILEMODE (S_IREAD|S_IWRITE) #define DEFFILEMODE (S_IREAD|S_IWRITE)
#else #else
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
@ -21,7 +21,7 @@
FILE * FILE *
asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) { asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
int created = 1; int created = 1;
#ifndef WIN32 #ifndef _WIN32
struct stat sb; struct stat sb;
#endif #endif
char *fname; char *fname;
@ -44,7 +44,7 @@ asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
* Create temporary file. * Create temporary file.
*/ */
fd = mkstemp(fname); fd = mkstemp(fname);
#ifndef WIN32 #ifndef _WIN32
(void)fchmod(fd, DEFFILEMODE); (void)fchmod(fd, DEFFILEMODE);
#endif #endif
} else { } else {
@ -62,7 +62,7 @@ asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
return NULL; return NULL;
} }
#ifndef WIN32 #ifndef _WIN32
/* /*
* Check sanity. * Check sanity.
*/ */
@ -76,7 +76,7 @@ asn1c_open_file(const char *name, const char *ext, char **opt_tmpname) {
(void)ftruncate(fd, 0); (void)ftruncate(fd, 0);
#else #else
_chsize(fd, 0); _chsize(fd, 0);
#endif /* WIN32 */ #endif /* _WIN32 */
/* /*
* Convert file descriptor into file pointer. * Convert file descriptor into file pointer.

View File

@ -22,7 +22,7 @@
#include <unistd.h> /* for unlink(2) */ #include <unistd.h> /* for unlink(2) */
#endif #endif
#ifdef WIN32 #ifdef _WIN32
#include <io.h> #include <io.h>
#include <malloc.h> #include <malloc.h>
#include <fcntl.h> #include <fcntl.h>

View File

@ -356,7 +356,7 @@ identical_files(const char *fname1, const char *fname2) {
size_t olen, nlen; size_t olen, nlen;
int retval = 1; /* Files are identical */ int retval = 1; /* Files are identical */
#ifndef WIN32 #ifndef _WIN32
struct stat sb; struct stat sb;
if(lstat(fname1, &sb) || !S_ISREG(sb.st_mode) if(lstat(fname1, &sb) || !S_ISREG(sb.st_mode)
@ -431,7 +431,7 @@ real_copy(const char *src, const char *dst) {
static int static int
asn1c_copy_over(arg_t *arg, char *path) { asn1c_copy_over(arg_t *arg, char *path) {
char *fname; char *fname;
#ifdef WIN32 #ifdef _WIN32
int use_real_copy = 1; int use_real_copy = 1;
#else #else
int use_real_copy = (arg->flags & A1C_SKELETONS_COPY); int use_real_copy = (arg->flags & A1C_SKELETONS_COPY);

View File

@ -23,7 +23,7 @@
#include <asn1parser.h> /* Our lovely ASN.1 parser module */ #include <asn1parser.h> /* Our lovely ASN.1 parser module */
#include "asn1fix.h" #include "asn1fix.h"
#ifdef WIN32 #ifdef _WIN32
#define EX_NOINPUT 66 #define EX_NOINPUT 66
#define EX_DATAERR 65 #define EX_DATAERR 65
#define snprintf _snprintf #define snprintf _snprintf

View File

@ -1,7 +1,7 @@
#undef NDEBUG #undef NDEBUG
#include "asn1fix_internal.h" #include "asn1fix_internal.h"
#ifdef WIN32 #ifdef _WIN32
#include <io.h> #include <io.h>
#include <direct.h> #include <direct.h>
#define chdir _chdir #define chdir _chdir
@ -21,7 +21,7 @@ static int post_fix_check_element(asn1p_module_t *mod, asn1p_expr_t *expr);
int int
main(int ac, char **av) { main(int ac, char **av) {
#ifdef WIN32 #ifdef _WIN32
intptr_t dir; intptr_t dir;
struct _finddata_t c_file; struct _finddata_t c_file;
#else #else
@ -53,13 +53,13 @@ main(int ac, char **av) {
fprintf(stderr, "Testing in ./tests...\n"); fprintf(stderr, "Testing in ./tests...\n");
ret = chdir("../tests"); ret = chdir("../tests");
assert(ret == 0); assert(ret == 0);
#ifdef WIN32 #ifdef _WIN32
dir = _findfirst("*.asn1", &c_file); dir = _findfirst("*.asn1", &c_file);
assert(dir != -1L); assert(dir != -1L);
#else #else
dir = opendir("."); dir = opendir(".");
assert(dir); assert(dir);
#endif /* WIN32 */ #endif /* _WIN32 */
} else { } else {
dir = 0; dir = 0;
} }
@ -68,13 +68,13 @@ main(int ac, char **av) {
* Scan every *.asn1 file and try to parse and fix it. * Scan every *.asn1 file and try to parse and fix it.
*/ */
if(dir) { if(dir) {
#ifdef WIN32 #ifdef _WIN32
do { do {
filename = c_file.name; filename = c_file.name;
#else #else
while((dp = readdir(dir))) { while((dp = readdir(dir))) {
filename = dp->d_name; filename = dp->d_name;
#endif /* WIN32 */ #endif /* _WIN32 */
len = strlen(filename); len = strlen(filename);
if(len <= 5 || strcmp(filename + len - 5, ".asn1")) if(len <= 5 || strcmp(filename + len - 5, ".asn1"))
continue; continue;
@ -85,13 +85,13 @@ main(int ac, char **av) {
failed++; failed++;
} }
completed++; completed++;
#ifdef WIN32 #ifdef _WIN32
} while(_findnext(dir, &c_file) == 0); } while(_findnext(dir, &c_file) == 0);
_findclose(dir); _findclose(dir);
#else #else
} }
closedir(dir); closedir(dir);
#endif /* WIN32 */ #endif /* _WIN32 */
fprintf(stderr, fprintf(stderr,

View File

@ -69,7 +69,7 @@ asn1p_parse_buffer(const char *buffer, int size /* = -1 */, enum asn1p_flags fla
*/ */
asn1p_t * asn1p_t *
asn1p_parse_file(const char *filename, enum asn1p_flags flags) { asn1p_parse_file(const char *filename, enum asn1p_flags flags) {
#ifndef WIN32 #ifndef _WIN32
struct stat sb; struct stat sb;
#endif #endif
asn1p_t *a = 0; asn1p_t *a = 0;
@ -88,7 +88,7 @@ asn1p_parse_file(const char *filename, enum asn1p_flags flags) {
return NULL; return NULL;
} }
#ifndef WIN32 #ifndef _WIN32
if(fstat(fileno(fp), &sb) if(fstat(fileno(fp), &sb)
|| !S_ISREG(sb.st_mode)) { || !S_ISREG(sb.st_mode)) {
fclose(fp); fclose(fp);
@ -97,7 +97,7 @@ asn1p_parse_file(const char *filename, enum asn1p_flags flags) {
errno = EINVAL; errno = EINVAL;
return NULL; return NULL;
} }
#endif /* WIN32 */ #endif /* _WIN32 */
asn1p_lineno = 1; asn1p_lineno = 1;

View File

@ -14,7 +14,7 @@
#include <time.h> #include <time.h>
#endif /* __CYGWIN__ */ #endif /* __CYGWIN__ */
#if defined(WIN32) #if defined(_WIN32)
#pragma message( "PLEASE STOP AND READ!") #pragma message( "PLEASE STOP AND READ!")
#pragma message( " localtime_r is implemented via localtime(), which may be not thread-safe.") #pragma message( " localtime_r is implemented via localtime(), which may be not thread-safe.")
#pragma message( " gmtime_r is implemented via gmtime(), which may be not thread-safe.") #pragma message( " gmtime_r is implemented via gmtime(), which may be not thread-safe.")
@ -41,7 +41,7 @@ static struct tm *gmtime_r(const time_t *tloc, struct tm *result) {
#define putenv(c) _putenv(c) #define putenv(c) _putenv(c)
#define _EMULATE_TIMEGM #define _EMULATE_TIMEGM
#endif /* WIN32 */ #endif /* _WIN32 */
#if defined(sun) || defined(_sun_) || defined(__solaris__) #if defined(sun) || defined(_sun_) || defined(__solaris__)
#define _EMULATE_TIMEGM #define _EMULATE_TIMEGM

View File

@ -21,7 +21,7 @@
#include <stdarg.h> /* For va_start */ #include <stdarg.h> /* For va_start */
#include <stddef.h> /* for offsetof and ptrdiff_t */ #include <stddef.h> /* for offsetof and ptrdiff_t */
#ifdef WIN32 #ifdef _WIN32
#include <malloc.h> #include <malloc.h>
#define snprintf _snprintf #define snprintf _snprintf
@ -46,7 +46,7 @@ typedef unsigned char uint8_t;
typedef unsigned short uint16_t; typedef unsigned short uint16_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
#endif /* ASSUMESTDTYPES */ #endif /* ASSUMESTDTYPES */
#define WIN32_LEAN_AND_MEAN #define _WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <float.h> #include <float.h>
#define isnan _isnan #define isnan _isnan
@ -57,7 +57,7 @@ typedef unsigned int uint32_t;
#include <stdint.h> #include <stdint.h>
#endif /* _MSC_VER */ #endif /* _MSC_VER */
#else /* !WIN32 */ #else /* !_WIN32 */
#if defined(__vxworks) #if defined(__vxworks)
#include <types/vxTypes.h> #include <types/vxTypes.h>
@ -90,7 +90,7 @@ typedef unsigned int uint32_t;
#endif /* defined(__vxworks) */ #endif /* defined(__vxworks) */
#endif /* WIN32 */ #endif /* _WIN32 */
#if __GNUC__ >= 3 #if __GNUC__ >= 3
#ifndef GCC_PRINTFLIKE #ifndef GCC_PRINTFLIKE