aboutsummaryrefslogtreecommitdiffstats
path: root/libasn1fix
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2005-02-25 14:20:30 +0000
committerLev Walkin <vlm@lionet.info>2005-02-25 14:20:30 +0000
commit4efbfb7e5553b41f4d725479823705aa6ef073cc (patch)
treeda88699c9d0001e9f7415a7b38e1fc2887bf3503 /libasn1fix
parent8d35c46db72ad6cf53e47c10253d9754af535f22 (diff)
portability fixes
Diffstat (limited to 'libasn1fix')
-rw-r--r--libasn1fix/asn1fix.c7
-rw-r--r--libasn1fix/asn1fix_constraint.c6
-rw-r--r--libasn1fix/asn1fix_constraint_compat.c4
-rw-r--r--libasn1fix/asn1fix_crange.c6
-rw-r--r--libasn1fix/asn1fix_cstring.c4
-rw-r--r--libasn1fix/asn1fix_export.h2
-rw-r--r--libasn1fix/asn1fix_internal.h18
-rw-r--r--libasn1fix/asn1fix_misc.c14
-rw-r--r--libasn1fix/check_fixer.c52
9 files changed, 74 insertions, 39 deletions
diff --git a/libasn1fix/asn1fix.c b/libasn1fix/asn1fix.c
index f120853c..22cd3671 100644
--- a/libasn1fix/asn1fix.c
+++ b/libasn1fix/asn1fix.c
@@ -1,10 +1,5 @@
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <stdarg.h>
-
-#include "asn1fix.h"
#include "asn1fix_internal.h"
+#include "asn1fix.h"
/* Print everything to stderr */
static void _default_error_logger(int _severity, const char *fmt, ...);
diff --git a/libasn1fix/asn1fix_constraint.c b/libasn1fix/asn1fix_constraint.c
index 8c6c73ca..9a32b49f 100644
--- a/libasn1fix/asn1fix_constraint.c
+++ b/libasn1fix/asn1fix_constraint.c
@@ -1,6 +1,6 @@
-#include <asn1fix_internal.h>
-#include <asn1fix_constraint.h>
-#include <asn1fix_crange.h>
+#include "asn1fix_internal.h"
+#include "asn1fix_constraint.h"
+#include "asn1fix_crange.h"
static void _remove_exceptions(arg_t *arg, asn1p_constraint_t *ct);
static int _constraint_value_resolve(arg_t *arg, asn1p_module_t *mod, asn1p_value_t **value);
diff --git a/libasn1fix/asn1fix_constraint_compat.c b/libasn1fix/asn1fix_constraint_compat.c
index effa0ad5..5eb93f0b 100644
--- a/libasn1fix/asn1fix_constraint_compat.c
+++ b/libasn1fix/asn1fix_constraint_compat.c
@@ -1,5 +1,5 @@
-#include <asn1fix_internal.h>
-#include <asn1fix_crange.h>
+#include "asn1fix_internal.h"
+#include "asn1fix_crange.h"
/*
* Check that a specific constraint is compatible
diff --git a/libasn1fix/asn1fix_crange.c b/libasn1fix/asn1fix_crange.c
index 974aa21c..1e6a0d08 100644
--- a/libasn1fix/asn1fix_crange.c
+++ b/libasn1fix/asn1fix_crange.c
@@ -1,6 +1,6 @@
-#include <asn1fix_internal.h>
-#include <asn1fix_constraint.h>
-#include <asn1fix_crange.h>
+#include "asn1fix_internal.h"
+#include "asn1fix_constraint.h"
+#include "asn1fix_crange.h"
#undef FATAL
#define FATAL(fmt, args...) do { \
diff --git a/libasn1fix/asn1fix_cstring.c b/libasn1fix/asn1fix_cstring.c
index b8a38833..9cbb42cf 100644
--- a/libasn1fix/asn1fix_cstring.c
+++ b/libasn1fix/asn1fix_cstring.c
@@ -2,7 +2,7 @@
struct _cstring_pattern {
char *start;
- int length;
+ size_t length;
};
static int _asn1f_cstring_find_line_pattern(char *s, struct _cstring_pattern *);
@@ -55,7 +55,7 @@ _asn1f_cstring_find_line_pattern(char *s, struct _cstring_pattern *cp) {
case '\0':
default:
if(newline_found) {
- cp->length = s - cp->start;
+ cp->length = (size_t)(s - cp->start);
return 1;
}
diff --git a/libasn1fix/asn1fix_export.h b/libasn1fix/asn1fix_export.h
index 5879b93f..99d80b71 100644
--- a/libasn1fix/asn1fix_export.h
+++ b/libasn1fix/asn1fix_export.h
@@ -5,7 +5,7 @@
#ifndef _ASN1FIX_EXPORT_H_
#define _ASN1FIX_EXPORT_H_
-#include <asn1fix_tags.h>
+#include "asn1fix_tags.h"
/*
* Create a human-readable representation of a reference and value.
diff --git a/libasn1fix/asn1fix_internal.h b/libasn1fix/asn1fix_internal.h
index 040750df..6b157785 100644
--- a/libasn1fix/asn1fix_internal.h
+++ b/libasn1fix/asn1fix_internal.h
@@ -10,13 +10,29 @@
*/
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <string.h>
#include <ctype.h> /* isupper() */
#include <errno.h>
#include <assert.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
#include <asn1parser.h> /* Our lovely ASN.1 parser module */
-#include <asn1fix.h>
+#include "asn1fix.h"
+
+#ifdef WIN32
+#define EX_NOINPUT 66
+#define EX_DATAERR 65
+#define snprintf _snprintf
+#define strcasecmp stricmp
+#endif
+
+#ifndef ETOOMANYREFS
+#define ETOOMANYREFS 144
+#endif
/*
* A definition of a function that will log error messages.
diff --git a/libasn1fix/asn1fix_misc.c b/libasn1fix/asn1fix_misc.c
index e9d156ce..15a16860 100644
--- a/libasn1fix/asn1fix_misc.c
+++ b/libasn1fix/asn1fix_misc.c
@@ -19,11 +19,11 @@ char const *
asn1f_printable_value(asn1p_value_t *v) {
static char buf[128];
static char *managedptr;
- static int managedptr_len;
+ static size_t managedptr_len;
int ret;
#define ENSURE(len) do { \
- int __len = (len); \
+ size_t __len = (len); \
if(__len >= managedptr_len) { \
if(managedptr) \
free(managedptr); \
@@ -69,7 +69,7 @@ asn1f_printable_value(asn1p_value_t *v) {
{
uint8_t *bitvector;
char *ptr;
- int len;
+ size_t len;
int i;
/*
* Compute number of bytes necessary
@@ -110,13 +110,13 @@ asn1f_printable_value(asn1p_value_t *v) {
*ptr++ = '\'';
*ptr++ = (bits%8)?'B':'H';
*ptr++ = 'H';
- assert((ptr - managedptr) == len);
+ assert(len == (size_t)(ptr - managedptr));
return managedptr;
}
case ATV_REFERENCED:
{
asn1p_ref_t *ref;
- char reflen;
+ size_t reflen;
char *ptr;
int i;
@@ -141,7 +141,7 @@ asn1f_printable_value(asn1p_value_t *v) {
*ptr++ = *nc;
}
*ptr++ = '\0';
- assert(reflen == (ptr - managedptr));
+ assert(reflen == (size_t)(ptr - managedptr));
return managedptr;
}
case ATV_CHOICE_IDENTIFIER:
@@ -158,7 +158,7 @@ asn1f_printable_value(asn1p_value_t *v) {
ret = snprintf(managedptr, managedptr_len + 1,
"%s: %s", cid, val);
- assert(ret >= 0 && ret <= managedptr_len);
+ assert(ret >= 0 && (size_t)ret <= managedptr_len);
free(val);
return managedptr;
}
diff --git a/libasn1fix/check_fixer.c b/libasn1fix/check_fixer.c
index 7129a563..8808f28d 100644
--- a/libasn1fix/check_fixer.c
+++ b/libasn1fix/check_fixer.c
@@ -1,15 +1,17 @@
#undef NDEBUG
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
+#include "asn1fix_internal.h"
+
+#ifdef WIN32
+#include <io.h>
+#include <direct.h>
+#define chdir _chdir
+#else
#include <dirent.h>
-#include <errno.h>
#include <sysexits.h>
+#endif
+#include <errno.h>
#include "asn1fix.h"
-#include "asn1fix_internal.h"
static int check(const char *fname,
enum asn1p_flags parser_flags,
@@ -19,12 +21,19 @@ static int post_fix_check_element(asn1p_module_t *mod, asn1p_expr_t *expr);
int
main(int ac, char **av) {
+#ifdef WIN32
+ intptr_t dir;
+ struct _finddata_t c_file;
+#else
struct dirent *dp;
DIR *dir;
+#endif
int failed = 0;
int completed = 0;
enum asn1p_flags parser_flags = A1P_NOFLAGS;
enum asn1f_flags fixer_flags = A1F_NOFLAGS;
+ const char *filename;
+ int len;
int ret;
/*
@@ -44,8 +53,13 @@ main(int ac, char **av) {
fprintf(stderr, "Testing in ./tests...\n");
ret = chdir("../tests");
assert(ret == 0);
+#ifdef WIN32
+ dir = _findfirst("*.asn1", &c_file);
+ assert(dir != -1L);
+#else
dir = opendir(".");
assert(dir);
+#endif /* WIN32 */
} else {
dir = 0;
}
@@ -54,21 +68,31 @@ main(int ac, char **av) {
* Scan every *.asn1 file and try to parse and fix it.
*/
if(dir) {
+#ifdef WIN32
+ do {
+ filename = c_file.name;
+#else
while((dp = readdir(dir))) {
- int len = strlen(dp->d_name);
- if(len && strcmp(dp->d_name + len - 5, ".asn1") == 0) {
- ret = check(dp->d_name,
- parser_flags, fixer_flags);
+ filename = dp->d_name;
+#endif /* WIN32 */
+ int len = strlen(filename);
+ if(len && strcmp(filename + len - 5, ".asn1") == 0) {
+ ret = check(filename, parser_flags,fixer_flags);
if(ret) {
- fprintf(stderr,
- "FAILED: %s\n",
- dp->d_name);
+ fprintf(stderr, "FAILED: %s\n",
+ filename);
failed++;
}
completed++;
}
+#ifdef WIN32
+ } while(_findnext(dir, &c_file) == 0);
+ _findclose(dir);
+#else
}
closedir(dir);
+#endif /* WIN32 */
+
fprintf(stderr,
"Tests COMPLETED: %d\n"