First pass at applying KNF to the OpenSSL code, which almost makes it
authorjsing <jsing@openbsd.org>
Tue, 15 Apr 2014 13:41:53 +0000 (13:41 +0000)
committerjsing <jsing@openbsd.org>
Tue, 15 Apr 2014 13:41:53 +0000 (13:41 +0000)
readable. This pass is whitespace only and can readily be verified using
tr and md5.

50 files changed:
lib/libcrypto/arm_arch.h
lib/libcrypto/armcap.c
lib/libcrypto/buildinf.h
lib/libcrypto/cpt_err.c
lib/libcrypto/cryptlib.c
lib/libcrypto/crypto.h
lib/libcrypto/cversion.c
lib/libcrypto/ebcdic.c
lib/libcrypto/ex_data.c
lib/libcrypto/fips_ers.c
lib/libcrypto/md32_common.h
lib/libcrypto/mem.c
lib/libcrypto/mem_clr.c
lib/libcrypto/mem_dbg.c
lib/libcrypto/o_dir_test.c
lib/libcrypto/o_fips.c
lib/libcrypto/o_init.c
lib/libcrypto/o_str.c
lib/libcrypto/o_str.h
lib/libcrypto/o_time.c
lib/libcrypto/ossl_typ.h
lib/libcrypto/ppccap.c
lib/libcrypto/s390xcap.c
lib/libcrypto/sparcv9cap.c
lib/libcrypto/uid.c
lib/libssl/src/crypto/arm_arch.h
lib/libssl/src/crypto/armcap.c
lib/libssl/src/crypto/buildinf.h
lib/libssl/src/crypto/cpt_err.c
lib/libssl/src/crypto/cryptlib.c
lib/libssl/src/crypto/crypto.h
lib/libssl/src/crypto/cversion.c
lib/libssl/src/crypto/ebcdic.c
lib/libssl/src/crypto/ex_data.c
lib/libssl/src/crypto/fips_ers.c
lib/libssl/src/crypto/md32_common.h
lib/libssl/src/crypto/mem.c
lib/libssl/src/crypto/mem_clr.c
lib/libssl/src/crypto/mem_dbg.c
lib/libssl/src/crypto/o_dir_test.c
lib/libssl/src/crypto/o_fips.c
lib/libssl/src/crypto/o_init.c
lib/libssl/src/crypto/o_str.c
lib/libssl/src/crypto/o_str.h
lib/libssl/src/crypto/o_time.c
lib/libssl/src/crypto/ossl_typ.h
lib/libssl/src/crypto/ppccap.c
lib/libssl/src/crypto/s390xcap.c
lib/libssl/src/crypto/sparcv9cap.c
lib/libssl/src/crypto/uid.c

index 5a83107..0ccafb2 100644 (file)
@@ -43,7 +43,7 @@
 
 #if !__ASSEMBLER__
 extern unsigned int OPENSSL_armcap_P;
-                                     
+
 #define ARMV7_NEON      (1<<0)
 #define ARMV7_TICK      (1<<1)
 #endif
index 9abaf39..0625587 100644 (file)
@@ -12,7 +12,8 @@ unsigned int OPENSSL_armcap_P;
 static sigset_t all_masked;
 
 static sigjmp_buf ill_jmp;
-static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); }
+       static void ill_handler (int sig) { siglongjmp(ill_jmp, sig);
+}
 
 /*
  * Following subroutines could have been inlined, but it's not all
@@ -21,60 +22,61 @@ static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); }
 void _armv7_neon_probe(void);
 unsigned int _armv7_tick(void);
 
-unsigned int OPENSSL_rdtsc(void)
-       {
+unsigned int
+OPENSSL_rdtsc(void)
+{
        if (OPENSSL_armcap_P & ARMV7_TICK)
                return _armv7_tick();
        else
                return 0;
-       }
+}
 
 #if defined(__GNUC__) && __GNUC__>=2
 void OPENSSL_cpuid_setup(void) __attribute__((constructor));
 #endif
-void OPENSSL_cpuid_setup(void)
-       {
+
+void
+OPENSSL_cpuid_setup(void)
+{
        char *e;
-       struct sigaction        ill_oact,ill_act;
+       struct sigaction        ill_oact, ill_act;
        sigset_t                oset;
-       static int trigger=0;
-
-       if (trigger) return;
-       trigger=1;
-       if ((e=getenv("OPENSSL_armcap")))
-               {
-               OPENSSL_armcap_P=strtoul(e,NULL,0);
+       static int trigger = 0;
+
+       if (trigger)
                return;
-               }
+       trigger = 1;
+
+       if ((e = getenv("OPENSSL_armcap"))) {
+               OPENSSL_armcap_P = strtoul(e, NULL, 0);
+               return;
+       }
 
        sigfillset(&all_masked);
-       sigdelset(&all_masked,SIGILL);
-       sigdelset(&all_masked,SIGTRAP);
-       sigdelset(&all_masked,SIGFPE);
-       sigdelset(&all_masked,SIGBUS);
-       sigdelset(&all_masked,SIGSEGV);
+       sigdelset(&all_masked, SIGILL);
+       sigdelset(&all_masked, SIGTRAP);
+       sigdelset(&all_masked, SIGFPE);
+       sigdelset(&all_masked, SIGBUS);
+       sigdelset(&all_masked, SIGSEGV);
 
        OPENSSL_armcap_P = 0;
 
-       memset(&ill_act,0,sizeof(ill_act));
+       memset(&ill_act, 0, sizeof(ill_act));
        ill_act.sa_handler = ill_handler;
-       ill_act.sa_mask    = all_masked;
+       ill_act.sa_mask = all_masked;
 
-       sigprocmask(SIG_SETMASK,&ill_act.sa_mask,&oset);
-       sigaction(SIGILL,&ill_act,&ill_oact);
+       sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset);
+       sigaction(SIGILL, &ill_act, &ill_oact);
 
-       if (sigsetjmp(ill_jmp,1) == 0)
-               {
+       if (sigsetjmp(ill_jmp, 1) == 0) {
                _armv7_neon_probe();
                OPENSSL_armcap_P |= ARMV7_NEON;
-               }
-       if (sigsetjmp(ill_jmp,1) == 0)
-               {
+       }
+       if (sigsetjmp(ill_jmp, 1) == 0) {
                _armv7_tick();
                OPENSSL_armcap_P |= ARMV7_TICK;
-               }
-
-       sigaction (SIGILL,&ill_oact,NULL);
-       sigprocmask(SIG_SETMASK,&oset,NULL);
        }
+
+       sigaction (SIGILL, &ill_oact, NULL);
+       sigprocmask(SIG_SETMASK, &oset, NULL);
+}
index 957f09d..8fdb24c 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef MK1MF_BUILD
-  /* auto-generated by crypto/Makefile for crypto/cversion.c */
-  #define CFLAGS "cc -O"
-  #define PLATFORM "dist"
-  #define DATE "Sat Aug 21 10:52:09 EST 2010"
+/* auto-generated by crypto/Makefile for crypto/cversion.c */
+#define CFLAGS "cc -O"
+#define PLATFORM "dist"
+#define DATE "Sat Aug 21 10:52:09 EST 2010"
 #endif
index 289005f..a8e94cc 100644 (file)
 #define ERR_FUNC(func) ERR_PACK(ERR_LIB_CRYPTO,func,0)
 #define ERR_REASON(reason) ERR_PACK(ERR_LIB_CRYPTO,0,reason)
 
-static ERR_STRING_DATA CRYPTO_str_functs[]=
-       {
-{ERR_FUNC(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX),   "CRYPTO_get_ex_new_index"},
-{ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID),  "CRYPTO_get_new_dynlockid"},
-{ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_LOCKID),     "CRYPTO_get_new_lockid"},
-{ERR_FUNC(CRYPTO_F_CRYPTO_SET_EX_DATA),        "CRYPTO_set_ex_data"},
-{ERR_FUNC(CRYPTO_F_DEF_ADD_INDEX),     "DEF_ADD_INDEX"},
-{ERR_FUNC(CRYPTO_F_DEF_GET_CLASS),     "DEF_GET_CLASS"},
-{ERR_FUNC(CRYPTO_F_FIPS_MODE_SET),     "FIPS_mode_set"},
-{ERR_FUNC(CRYPTO_F_INT_DUP_EX_DATA),   "INT_DUP_EX_DATA"},
-{ERR_FUNC(CRYPTO_F_INT_FREE_EX_DATA),  "INT_FREE_EX_DATA"},
-{ERR_FUNC(CRYPTO_F_INT_NEW_EX_DATA),   "INT_NEW_EX_DATA"},
-{0,NULL}
-       };
+static ERR_STRING_DATA CRYPTO_str_functs[]= {
+       {ERR_FUNC(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX),    "CRYPTO_get_ex_new_index"},
+       {ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID),   "CRYPTO_get_new_dynlockid"},
+       {ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_LOCKID),      "CRYPTO_get_new_lockid"},
+       {ERR_FUNC(CRYPTO_F_CRYPTO_SET_EX_DATA), "CRYPTO_set_ex_data"},
+       {ERR_FUNC(CRYPTO_F_DEF_ADD_INDEX),      "DEF_ADD_INDEX"},
+       {ERR_FUNC(CRYPTO_F_DEF_GET_CLASS),      "DEF_GET_CLASS"},
+       {ERR_FUNC(CRYPTO_F_FIPS_MODE_SET),      "FIPS_mode_set"},
+       {ERR_FUNC(CRYPTO_F_INT_DUP_EX_DATA),    "INT_DUP_EX_DATA"},
+       {ERR_FUNC(CRYPTO_F_INT_FREE_EX_DATA),   "INT_FREE_EX_DATA"},
+       {ERR_FUNC(CRYPTO_F_INT_NEW_EX_DATA),    "INT_NEW_EX_DATA"},
+       {0, NULL}
+};
 
-static ERR_STRING_DATA CRYPTO_str_reasons[]=
-       {
-{ERR_REASON(CRYPTO_R_FIPS_MODE_NOT_SUPPORTED),"fips mode not supported"},
-{ERR_REASON(CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK),"no dynlock create callback"},
-{0,NULL}
-       };
+static ERR_STRING_DATA CRYPTO_str_reasons[]= {
+       {ERR_REASON(CRYPTO_R_FIPS_MODE_NOT_SUPPORTED), "fips mode not supported"},
+       {ERR_REASON(CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK), "no dynlock create callback"},
+       {0, NULL}
+};
 
 #endif
 
-void ERR_load_CRYPTO_strings(void)
-       {
+void
+ERR_load_CRYPTO_strings(void)
+{
 #ifndef OPENSSL_NO_ERR
-
-       if (ERR_func_error_string(CRYPTO_str_functs[0].error) == NULL)
-               {
-               ERR_load_strings(0,CRYPTO_str_functs);
-               ERR_load_strings(0,CRYPTO_str_reasons);
-               }
-#endif
+       if (ERR_func_error_string(CRYPTO_str_functs[0].error) == NULL) {
+               ERR_load_strings(0, CRYPTO_str_functs);
+               ERR_load_strings(0, CRYPTO_str_reasons);
        }
+#endif
+}
index 082b2e8..89667d1 100644 (file)
 #include <openssl/safestack.h>
 
 #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16)
-static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */
+static double SSLeay_MSVC5_hack = 0.0; /* and for VC1.5 */
 #endif
 
 DECLARE_STACK_OF(CRYPTO_dynlock)
 
 /* real #defines in crypto.h, keep these upto date */
-static const char* const lock_names[CRYPTO_NUM_LOCKS] =
-       {
+static const char* const lock_names[CRYPTO_NUM_LOCKS] = {
        "<<ERROR>>",
        "err",
        "ex_data",
@@ -170,35 +169,35 @@ static const char* const lock_names[CRYPTO_NUM_LOCKS] =
 #if CRYPTO_NUM_LOCKS != 41
 # error "Inconsistency between crypto.h and cryptlib.c"
 #endif
-       };
+};
 
 /* This is for applications to allocate new type names in the non-dynamic
    array of lock names.  These are numbered with positive numbers.  */
-static STACK_OF(OPENSSL_STRING) *app_locks=NULL;
+static STACK_OF(OPENSSL_STRING) *app_locks = NULL;
 
 /* For applications that want a more dynamic way of handling threads, the
    following stack is used.  These are externally numbered with negative
    numbers.  */
-static STACK_OF(CRYPTO_dynlock) *dyn_locks=NULL;
-
+static STACK_OF(CRYPTO_dynlock) *dyn_locks = NULL;
 
-static void (*locking_callback)(int mode,int type,
-       const char *file,int line)=0;
-static int (*add_lock_callback)(int *pointer,int amount,
-       int type,const char *file,int line)=0;
+static void (*locking_callback)(int mode, int type,
+    const char *file, int line) = 0;
+static int (*add_lock_callback)(int *pointer, int amount,
+    int type, const char *file, int line) = 0;
 #ifndef OPENSSL_NO_DEPRECATED
-static unsigned long (*id_callback)(void)=0;
+static unsigned long (*id_callback)(void) = 0;
 #endif
-static void (*threadid_callback)(CRYPTO_THREADID *)=0;
-static struct CRYPTO_dynlock_value *(*dynlock_create_callback)
-       (const char *file,int line)=0;
+static void (*threadid_callback)(CRYPTO_THREADID *) = 0;
+static struct CRYPTO_dynlock_value *(*dynlock_create_callback)(
+    const char *file, int line) = 0;
 static void (*dynlock_lock_callback)(int mode,
-       struct CRYPTO_dynlock_value *l, const char *file,int line)=0;
+    struct CRYPTO_dynlock_value *l, const char *file, int line) = 0;
 static void (*dynlock_destroy_callback)(struct CRYPTO_dynlock_value *l,
-       const char *file,int line)=0;
+    const char *file, int line) = 0;
 
-int CRYPTO_get_new_lockid(char *name)
-       {
+int
+CRYPTO_get_new_lockid(char *name)
+{
        char *str;
        int i;
 
@@ -207,141 +206,130 @@ int CRYPTO_get_new_lockid(char *name)
         * a DLL using /MT. Without this, the application cannot use
         * any floating point printf's.
         * It also seems to be needed for Visual C 1.5 (win16) */
-       SSLeay_MSVC5_hack=(double)name[0]*(double)name[1];
+       SSLeay_MSVC5_hack = (double)name[0]*(double)name[1];
 #endif
 
-       if ((app_locks == NULL) && ((app_locks=sk_OPENSSL_STRING_new_null()) == NULL))
-               {
-               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
-               return(0);
-               }
-       if ((str=BUF_strdup(name)) == NULL)
-               {
-               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
-               return(0);
-               }
-       i=sk_OPENSSL_STRING_push(app_locks,str);
+       if ((app_locks == NULL) && ((app_locks = sk_OPENSSL_STRING_new_null()) == NULL)) {
+               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE);
+               return (0);
+       }
+       if ((str = BUF_strdup(name)) == NULL) {
+               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE);
+               return (0);
+       }
+       i = sk_OPENSSL_STRING_push(app_locks, str);
        if (!i)
                OPENSSL_free(str);
        else
-               i+=CRYPTO_NUM_LOCKS; /* gap of one :-) */
-       return(i);
-       }
+               i += CRYPTO_NUM_LOCKS; /* gap of one :-) */
+       return (i);
+}
 
-int CRYPTO_num_locks(void)
-       {
+int
+CRYPTO_num_locks(void)
+{
        return CRYPTO_NUM_LOCKS;
-       }
+}
 
-int CRYPTO_get_new_dynlockid(void)
-       {
+int
+CRYPTO_get_new_dynlockid(void)
+{
        int i = 0;
        CRYPTO_dynlock *pointer = NULL;
 
-       if (dynlock_create_callback == NULL)
-               {
-               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK);
-               return(0);
-               }
+       if (dynlock_create_callback == NULL) {
+               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK);
+               return (0);
+       }
        CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
        if ((dyn_locks == NULL)
-               && ((dyn_locks=sk_CRYPTO_dynlock_new_null()) == NULL))
-               {
+               && ((dyn_locks = sk_CRYPTO_dynlock_new_null()) == NULL)) {
                CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
-               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
-               return(0);
-               }
+               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE);
+               return (0);
+       }
        CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
 
        pointer = (CRYPTO_dynlock *)OPENSSL_malloc(sizeof(CRYPTO_dynlock));
-       if (pointer == NULL)
-               {
-               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
-               return(0);
-               }
+       if (pointer == NULL) {
+               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE);
+               return (0);
+       }
        pointer->references = 1;
-       pointer->data = dynlock_create_callback(__FILE__,__LINE__);
-       if (pointer->data == NULL)
-               {
+       pointer->data = dynlock_create_callback(__FILE__, __LINE__);
+       if (pointer->data == NULL) {
                OPENSSL_free(pointer);
-               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
-               return(0);
-               }
+               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE);
+               return (0);
+       }
 
        CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
        /* First, try to find an existing empty slot */
-       i=sk_CRYPTO_dynlock_find(dyn_locks,NULL);
+       i = sk_CRYPTO_dynlock_find(dyn_locks, NULL);
        /* If there was none, push, thereby creating a new one */
        if (i == -1)
                /* Since sk_push() returns the number of items on the
                   stack, not the location of the pushed item, we need
                   to transform the returned number into a position,
                   by decreasing it.  */
-               i=sk_CRYPTO_dynlock_push(dyn_locks,pointer) - 1;
+               i = sk_CRYPTO_dynlock_push(dyn_locks, pointer) - 1;
        else
                /* If we found a place with a NULL pointer, put our pointer
                   in it.  */
-               (void)sk_CRYPTO_dynlock_set(dyn_locks,i,pointer);
+               (void)sk_CRYPTO_dynlock_set(dyn_locks, i, pointer);
        CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
 
-       if (i == -1)
-               {
-               dynlock_destroy_callback(pointer->data,__FILE__,__LINE__);
+       if (i == -1) {
+               dynlock_destroy_callback(pointer->data, __FILE__, __LINE__);
                OPENSSL_free(pointer);
-               }
-       else
+       } else
                i += 1; /* to avoid 0 */
-       return -i;
-       }
+       return - i;
+}
 
-void CRYPTO_destroy_dynlockid(int i)
-       {
+void
+CRYPTO_destroy_dynlockid(int i)
+{
        CRYPTO_dynlock *pointer = NULL;
        if (i)
-               i = -i-1;
+               i = -i - 1;
        if (dynlock_destroy_callback == NULL)
                return;
 
        CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
 
-       if (dyn_locks == NULL || i >= sk_CRYPTO_dynlock_num(dyn_locks))
-               {
+       if (dyn_locks == NULL || i >= sk_CRYPTO_dynlock_num(dyn_locks)) {
                CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
                return;
-               }
+       }
        pointer = sk_CRYPTO_dynlock_value(dyn_locks, i);
-       if (pointer != NULL)
-               {
+       if (pointer != NULL) {
                --pointer->references;
 #ifdef REF_CHECK
-               if (pointer->references < 0)
-                       {
-                       fprintf(stderr,"CRYPTO_destroy_dynlockid, bad reference count\n");
+               if (pointer->references < 0) {
+                       fprintf(stderr, "CRYPTO_destroy_dynlockid, bad reference count\n");
                        abort();
-                       }
-               else
+               } else
 #endif
-                       if (pointer->references <= 0)
-                               {
-                               (void)sk_CRYPTO_dynlock_set(dyn_locks, i, NULL);
-                               }
-                       else
-                               pointer = NULL;
-               }
+               if (pointer->references <= 0) {
+                       (void)sk_CRYPTO_dynlock_set(dyn_locks, i, NULL);
+               } else
+                       pointer = NULL;
+       }
        CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
 
-       if (pointer)
-               {
-               dynlock_destroy_callback(pointer->data,__FILE__,__LINE__);
+       if (pointer) {
+               dynlock_destroy_callback(pointer->data, __FILE__, __LINE__);
                OPENSSL_free(pointer);
-               }
        }
+}
 
-struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i)
-       {
+struct CRYPTO_dynlock_value
+*CRYPTO_get_dynlock_value(int i)
+{
        CRYPTO_dynlock *pointer = NULL;
        if (i)
-               i = -i-1;
+               i = -i - 1;
 
        CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
 
@@ -355,97 +343,102 @@ struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i)
        if (pointer)
                return pointer->data;
        return NULL;
-       }
+}
 
-struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))
-       (const char *file,int line)
-       {
-       return(dynlock_create_callback);
-       }
+struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(
+    const char *file, int line)
+{
+       return (dynlock_create_callback);
+}
 
 void (*CRYPTO_get_dynlock_lock_callback(void))(int mode,
-       struct CRYPTO_dynlock_value *l, const char *file,int line)
-       {
-       return(dynlock_lock_callback);
-       }
-
-void (*CRYPTO_get_dynlock_destroy_callback(void))
-       (struct CRYPTO_dynlock_value *l, const char *file,int line)
-       {
-       return(dynlock_destroy_callback);
-       }
+    struct CRYPTO_dynlock_value *l, const char *file, int line)
+{
+       return (dynlock_lock_callback);
+}
 
-void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*func)
-       (const char *file, int line))
-       {
-       dynlock_create_callback=func;
-       }
+void (*CRYPTO_get_dynlock_destroy_callback(void))(
+    struct CRYPTO_dynlock_value *l, const char *file, int line)
+{
+       return (dynlock_destroy_callback);
+}
 
-void CRYPTO_set_dynlock_lock_callback(void (*func)(int mode,
-       struct CRYPTO_dynlock_value *l, const char *file, int line))
-       {
-       dynlock_lock_callback=func;
-       }
+void
+CRYPTO_set_dynlock_create_callback(
+    struct CRYPTO_dynlock_value *(*func)(const char *file, int line))
+{
+       dynlock_create_callback = func;
+}
 
-void CRYPTO_set_dynlock_destroy_callback(void (*func)
-       (struct CRYPTO_dynlock_value *l, const char *file, int line))
-       {
-       dynlock_destroy_callback=func;
-       }
+void
+CRYPTO_set_dynlock_lock_callback(void (*func)(int mode,
+    struct CRYPTO_dynlock_value *l, const char *file, int line))
+{
+       dynlock_lock_callback = func;
+}
 
+void
+CRYPTO_set_dynlock_destroy_callback(
+    void (*func)(struct CRYPTO_dynlock_value *l, const char *file, int line))
+{
+       dynlock_destroy_callback = func;
+}
 
-void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
-               int line)
-       {
-       return(locking_callback);
-       }
+void (*CRYPTO_get_locking_callback(void))(int mode, int type,
+    const char *file, int line)
+{
+       return (locking_callback);
+}
 
-int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type,
-                                         const char *file,int line)
-       {
-       return(add_lock_callback);
-       }
+int (*CRYPTO_get_add_lock_callback(void))(int *num, int mount, int type,
+    const char *file, int line)
+{
+       return (add_lock_callback);
+}
 
-void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
-                                             const char *file,int line))
-       {
+void
+CRYPTO_set_locking_callback(void (*func)(int mode, int type,
+    const char *file, int line))
+{
        /* Calling this here ensures initialisation before any threads
         * are started.
         */
        OPENSSL_init();
-       locking_callback=func;
-       }
+       locking_callback = func;
+}
 
-void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
-                                             const char *file,int line))
-       {
-       add_lock_callback=func;
-       }
+void
+CRYPTO_set_add_lock_callback(int (*func)(int *num, int mount, int type,
+    const char *file, int line))
+{
+       add_lock_callback = func;
+}
 
 /* the memset() here and in set_pointer() seem overkill, but for the sake of
  * CRYPTO_THREADID_cmp() this avoids any platform silliness that might cause two
  * "equal" THREADID structs to not be memcmp()-identical. */
-void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val)
-       {
+void
+CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val)
+{
        memset(id, 0, sizeof(*id));
        id->val = val;
-       }
+}
 
 static const unsigned char hash_coeffs[] = { 3, 5, 7, 11, 13, 17, 19, 23 };
-void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr)
-       {
+void
+CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr)
+{
        unsigned char *dest = (void *)&id->val;
        unsigned int accum = 0;
        unsigned char dnum = sizeof(id->val);
 
        memset(id, 0, sizeof(*id));
        id->ptr = ptr;
-       if (sizeof(id->val) >= sizeof(id->ptr))
-               {
+       if (sizeof(id->val) >= sizeof(id->ptr)) {
                /* 'ptr' can be embedded in 'val' without loss of uniqueness */
                id->val = (unsigned long)id->ptr;
                return;
-               }
+       }
        /* hash ptr ==> val. Each byte of 'val' gets the mod-256 total of a
         * linear function over the bytes in 'ptr', the co-efficients of which
         * are a sequence of low-primes (hash_coeffs is an 8-element cycle) -
@@ -456,44 +449,43 @@ void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr)
         * a black-belt, I'd scan big-endian pointers in reverse to give
         * low-order bits more play, but this isn't crypto and I'd prefer nobody
         * mistake it as such. Plus I'm lazy. */
-       while (dnum--)
-               {
+       while (dnum--) {
                const unsigned char *src = (void *)&id->ptr;
                unsigned char snum = sizeof(id->ptr);
                while (snum--)
-                       accum += *(src++) * hash_coeffs[(snum + dnum) & 7];
+               accum += *(src++) * hash_coeffs[(snum + dnum) & 7];
                accum += dnum;
                *(dest++) = accum & 255;
-               }
        }
+}
 
-int CRYPTO_THREADID_set_callback(void (*func)(CRYPTO_THREADID *))
-       {
+int
+CRYPTO_THREADID_set_callback(void (*func)(CRYPTO_THREADID *))
+{
        if (threadid_callback)
                return 0;
        threadid_callback = func;
        return 1;
-       }
+}
 
 void (*CRYPTO_THREADID_get_callback(void))(CRYPTO_THREADID *)
-       {
+{
        return threadid_callback;
-       }
+}
 
-void CRYPTO_THREADID_current(CRYPTO_THREADID *id)
-       {
-       if (threadid_callback)
-               {
+void
+CRYPTO_THREADID_current(CRYPTO_THREADID *id)
+{
+       if (threadid_callback) {
                threadid_callback(id);
                return;
-               }
+       }
 #ifndef OPENSSL_NO_DEPRECATED
        /* If the deprecated callback was set, fall back to that */
-       if (id_callback)
-               {
+       if (id_callback) {
                CRYPTO_THREADID_set_numeric(id, id_callback());
                return;
-               }
+       }
 #endif
        /* Else pick a backup */
 #ifdef OPENSSL_SYS_WIN16
@@ -506,64 +498,68 @@ void CRYPTO_THREADID_current(CRYPTO_THREADID *id)
        /* For everything else, default to using the address of 'errno' */
        CRYPTO_THREADID_set_pointer(id, (void*)&errno);
 #endif
-       }
+}
 
-int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b)
-       {
+int
+CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b)
+{
        return memcmp(a, b, sizeof(*a));
-       }
+}
 
-void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src)
-       {
+void
+CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src)
+{
        memcpy(dest, src, sizeof(*src));
-       }
+}
 
-unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id)
-       {
+unsigned long
+CRYPTO_THREADID_hash(const CRYPTO_THREADID *id)
+{
        return id->val;
-       }
+}
 
 #ifndef OPENSSL_NO_DEPRECATED
 unsigned long (*CRYPTO_get_id_callback(void))(void)
-       {
-       return(id_callback);
-       }
+{
+       return (id_callback);
+}
 
-void CRYPTO_set_id_callback(unsigned long (*func)(void))
-       {
-       id_callback=func;
-       }
+void
+CRYPTO_set_id_callback(unsigned long (*func)(void))
+{
+       id_callback = func;
+}
 
-unsigned long CRYPTO_thread_id(void)
-       {
-       unsigned long ret=0;
+unsigned long
+CRYPTO_thread_id(void)
+{
+       unsigned long ret = 0;
 
-       if (id_callback == NULL)
-               {
+       if (id_callback == NULL) {
 #ifdef OPENSSL_SYS_WIN16
-               ret=(unsigned long)GetCurrentTask();
+               ret = (unsigned long)GetCurrentTask();
 #elif defined(OPENSSL_SYS_WIN32)
-               ret=(unsigned long)GetCurrentThreadId();
+               ret = (unsigned long)GetCurrentThreadId();
 #elif defined(GETPID_IS_MEANINGLESS)
-               ret=1L;
+               ret = 1L;
 #elif defined(OPENSSL_SYS_BEOS)
-               ret=(unsigned long)find_thread(NULL);
+               ret = (unsigned long)find_thread(NULL);
 #else
-               ret=(unsigned long)getpid();
+               ret = (unsigned long)getpid();
 #endif
-               }
-       else
-               ret=id_callback();
-       return(ret);
-       }
+       } else
+               ret = id_callback();
+       return (ret);
+}
 #endif
 
-void CRYPTO_lock(int mode, int type, const char *file, int line)
-       {
+void
+CRYPTO_lock(int mode, int type, const char *file, int line)
+{
 #ifdef LOCK_DEBUG
-               {
+       {
                CRYPTO_THREADID id;
-               char *rw_text,*operation_text;
+               char *rw_text, *operation_text;
 
                if (mode & CRYPTO_LOCK)
                        operation_text="lock  ";
@@ -580,101 +576,98 @@ void CRYPTO_lock(int mode, int type, const char *file, int line)
                        rw_text="ERROR";
 
                CRYPTO_THREADID_current(&id);
-               fprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\n",
-                       CRYPTO_THREADID_hash(&id), rw_text, operation_text,
-                       CRYPTO_get_lock_name(type), file, line);
-               }
+               fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\n",
+               CRYPTO_THREADID_hash(&id), rw_text, operation_text,
+               CRYPTO_get_lock_name(type), file, line);
+       }
 #endif
-       if (type < 0)
-               {
-               if (dynlock_lock_callback != NULL)
-                       {
-                       struct CRYPTO_dynlock_value *pointer
-                               = CRYPTO_get_dynlock_value(type);
+       if (type < 0) {
+               if (dynlock_lock_callback != NULL) {
+                       struct CRYPTO_dynlock_value *pointer =
+                           CRYPTO_get_dynlock_value(type);
 
                        OPENSSL_assert(pointer != NULL);
 
                        dynlock_lock_callback(mode, pointer, file, line);
 
                        CRYPTO_destroy_dynlockid(type);
-                       }
                }
-       else
-               if (locking_callback != NULL)
-                       locking_callback(mode,type,file,line);
-       }
+       } else if (locking_callback != NULL)
+               locking_callback(mode, type, file, line);
+}
 
-int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
-            int line)
-       {
+int
+CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
+    int line)
+{
        int ret = 0;
 
-       if (add_lock_callback != NULL)
-               {
+       if (add_lock_callback != NULL) {
 #ifdef LOCK_DEBUG
                int before= *pointer;
 #endif
 
-               ret=add_lock_callback(pointer,amount,type,file,line);
+               ret = add_lock_callback(pointer, amount, type, file, line);
 #ifdef LOCK_DEBUG
                {
-               CRYPTO_THREADID id;
-               CRYPTO_THREADID_current(&id);
-               fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",
-                       CRYPTO_THREADID_hash(&id), before,amount,ret,
+                       CRYPTO_THREADID id;
+                       CRYPTO_THREADID_current(&id);
+                       fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",
+                       CRYPTO_THREADID_hash(&id), before, amount, ret,
                        CRYPTO_get_lock_name(type),
-                       file,line);
+                       file, line);
                }
 #endif
-               }
-       else
-               {
-               CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,file,line);
+       } else {
+               CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE, type, file, line);
 
-               ret= *pointer+amount;
+               ret= *pointer + amount;
 #ifdef LOCK_DEBUG
                {
-               CRYPTO_THREADID id;
-               CRYPTO_THREADID_current(&id);
-               fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",
+                       CRYPTO_THREADID id;
+                       CRYPTO_THREADID_current(&id);
+                       fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",
                        CRYPTO_THREADID_hash(&id),
-                       *pointer,amount,ret,
+                       *pointer, amount, ret,
                        CRYPTO_get_lock_name(type),
-                       file,line);
+                       file, line);
                }
 #endif
-               *pointer=ret;
-               CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,file,line);
-               }
-       return(ret);
+               *pointer = ret;
+               CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE, type, file, line);
        }
+       return (ret);
+}
 
-const char *CRYPTO_get_lock_name(int type)
-       {
+const char
+*CRYPTO_get_lock_name(int type)
+{
        if (type < 0)
                return("dynamic");
        else if (type < CRYPTO_NUM_LOCKS)
-               return(lock_names[type]);
-       else if (type-CRYPTO_NUM_LOCKS > sk_OPENSSL_STRING_num(app_locks))
+               return (lock_names[type]);
+       else if (type - CRYPTO_NUM_LOCKS > sk_OPENSSL_STRING_num(app_locks))
                return("ERROR");
        else
-               return(sk_OPENSSL_STRING_value(app_locks,type-CRYPTO_NUM_LOCKS));
-       }
+               return (sk_OPENSSL_STRING_value(app_locks, type - CRYPTO_NUM_LOCKS));
+}
 
 #if    defined(__i386)   || defined(__i386__)   || defined(_M_IX86) || \
        defined(__INTEL__) || \
        defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
 
 unsigned int  OPENSSL_ia32cap_P[2];
-unsigned long *OPENSSL_ia32cap_loc(void)
-{   if (sizeof(long)==4)
-       /*
-        * If 32-bit application pulls address of OPENSSL_ia32cap_P[0]
-        * clear second element to maintain the illusion that vector
-        * is 32-bit.
-        */
-       OPENSSL_ia32cap_P[1]=0;
-    return (unsigned long *)OPENSSL_ia32cap_P;
+unsigned long
+*OPENSSL_ia32cap_loc(void)
+{
+       if (sizeof(long) == 4)
+               /*
+                * If 32-bit application pulls address of OPENSSL_ia32cap_P[0]
+                * clear second element to maintain the illusion that vector
+                * is 32-bit.
+                */
+               OPENSSL_ia32cap_P[1] = 0;
+       return (unsigned long *)OPENSSL_ia32cap_P;
 }
 
 #if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)
@@ -684,43 +677,48 @@ typedef unsigned __int64 IA32CAP;
 #else
 typedef unsigned long long IA32CAP;
 #endif
-void OPENSSL_cpuid_setup(void)
-{ static int trigger=0;
-  IA32CAP OPENSSL_ia32_cpuid(void);
-  IA32CAP vec;
-  char *env;
-
-    if (trigger)       return;
+void
+OPENSSL_cpuid_setup(void)
+{
+       static int trigger = 0;
+       IA32CAP OPENSSL_ia32_cpuid(void);
+       IA32CAP vec;
+       char *env;
+
+       if (trigger)
+               return;
 
-    trigger=1;
-    if ((env=getenv("OPENSSL_ia32cap"))) {
-       int off = (env[0]=='~')?1:0;
+       trigger = 1;
+       if ((env = getenv("OPENSSL_ia32cap"))) {
+               int off = (env[0]=='~') ? 1 : 0;
 #if defined(_WIN32)
-       if (!sscanf(env+off,"%I64i",&vec)) vec = strtoul(env+off,NULL,0);
+               if (!sscanf(env+off, "%I64i", &vec)) vec = strtoul(env+off, NULL, 0);
 #else
-       if (!sscanf(env+off,"%lli",(long long *)&vec)) vec = strtoul(env+off,NULL,0);
+               if (!sscanf(env+off, "%lli",(long long *)&vec)) vec = strtoul(env+off, NULL, 0);
 #endif
-       if (off) vec = OPENSSL_ia32_cpuid()&~vec;
-    }
-    else
-       vec = OPENSSL_ia32_cpuid();
+               if (off)
+                       vec = OPENSSL_ia32_cpuid()&~vec;
+       } else
+               vec = OPENSSL_ia32_cpuid();
 
     /*
      * |(1<<10) sets a reserved bit to signal that variable
      * was initialized already... This is to avoid interference
      * with cpuid snippets in ELF .init segment.
      */
-    OPENSSL_ia32cap_P[0] = (unsigned int)vec|(1<<10);
-    OPENSSL_ia32cap_P[1] = (unsigned int)(vec>>32);
+       OPENSSL_ia32cap_P[0] = (unsigned int)vec|(1 << 10);
+       OPENSSL_ia32cap_P[1] = (unsigned int)(vec >> 32);
 }
 #endif
 
 #else
-unsigned long *OPENSSL_ia32cap_loc(void) { return NULL; }
+       unsigned long *OPENSSL_ia32cap_loc(void) { return NULL;
+}
 #endif
 int OPENSSL_NONPIC_relocated = 0;
 #if !defined(OPENSSL_CPUID_SETUP) && !defined(OPENSSL_CPUID_OBJ)
-void OPENSSL_cpuid_setup(void) {}
+void
+OPENSSL_cpuid_setup(void) {}
 #endif
 
 #if (defined(_WIN32) || defined(__CYGWIN__)) && defined(_WINDLL)
@@ -734,25 +732,23 @@ void OPENSSL_cpuid_setup(void) {}
 /* All we really need to do is remove the 'error' state when a thread
  * detaches */
 
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
-            LPVOID lpvReserved)
-       {
-       switch(fdwReason)
-               {
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+       switch (fdwReason) {
        case DLL_PROCESS_ATTACH:
                OPENSSL_cpuid_setup();
 #if defined(_WIN32_WINNT)
                {
-               IMAGE_DOS_HEADER *dos_header = (IMAGE_DOS_HEADER *)hinstDLL;
-               IMAGE_NT_HEADERS *nt_headers;
-
-               if (dos_header->e_magic==IMAGE_DOS_SIGNATURE)
-                       {
-                       nt_headers = (IMAGE_NT_HEADERS *)((char *)dos_header
-                                               + dos_header->e_lfanew);
-                       if (nt_headers->Signature==IMAGE_NT_SIGNATURE &&
-                           hinstDLL!=(HINSTANCE)(nt_headers->OptionalHeader.ImageBase))
-                               OPENSSL_NONPIC_relocated=1;
+                       IMAGE_DOS_HEADER *dos_header = (IMAGE_DOS_HEADER *)hinstDLL;
+                       IMAGE_NT_HEADERS *nt_headers;
+
+                       if (dos_header->e_magic == IMAGE_DOS_SIGNATURE) {
+                               nt_headers = (IMAGE_NT_HEADERS *)((char *)dos_header
+                               + dos_header->e_lfanew);
+                               if (nt_headers->Signature == IMAGE_NT_SIGNATURE &&
+                                       hinstDLL != (HINSTANCE)(nt_headers->OptionalHeader.ImageBase))
+                               OPENSSL_NONPIC_relocated = 1;
                        }
                }
 #endif
@@ -763,9 +759,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
                break;
        case DLL_PROCESS_DETACH:
                break;
-               }
-       return(TRUE);
        }
+       return (TRUE);
+}
 #endif
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -783,138 +779,166 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
 #endif
 
 #if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
-int OPENSSL_isservice(void)
-{ HWINSTA h;
-  DWORD len;
-  WCHAR *name;
-  static union { void *p; int (*f)(void); } _OPENSSL_isservice = { NULL };
-
-    if (_OPENSSL_isservice.p == NULL) {
-       HANDLE h = GetModuleHandle(NULL);
-       if (h != NULL)
-           _OPENSSL_isservice.p = GetProcAddress(h,"_OPENSSL_isservice");
-       if (_OPENSSL_isservice.p == NULL)
-           _OPENSSL_isservice.p = (void *)-1;
-    }
-
-    if (_OPENSSL_isservice.p != (void *)-1)
-       return (*_OPENSSL_isservice.f)();
-
-    (void)GetDesktopWindow(); /* return value is ignored */
-
-    h = GetProcessWindowStation();
-    if (h==NULL) return -1;
-
-    if (GetUserObjectInformationW (h,UOI_NAME,NULL,0,&len) ||
-       GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+int
+OPENSSL_isservice(void)
+       { HWINSTA h;
+       DWORD len;
+       WCHAR *name;
+               static union { void *p;
+               int (*f)(void);
+       } _OPENSSL_isservice = { NULL };
+
+       if (_OPENSSL_isservice.p == NULL) {
+               HANDLE h = GetModuleHandle(NULL);
+               if (h != NULL)
+                       _OPENSSL_isservice.p = GetProcAddress(h, "_OPENSSL_isservice");
+               if (_OPENSSL_isservice.p == NULL)
+                       _OPENSSL_isservice.p = (void *) - 1;
+       }
+
+       if (_OPENSSL_isservice.p != (void *) - 1)
+               return (*_OPENSSL_isservice.f)();
+
+       (void)GetDesktopWindow(); /* return value is ignored */
+
+       h = GetProcessWindowStation();
+       if (h == NULL)
+               return -1;
+
+       if (GetUserObjectInformationW (h, UOI_NAME, NULL, 0, &len) ||
+               GetLastError() != ERROR_INSUFFICIENT_BUFFER)
        return -1;
 
-    if (len>512) return -1;            /* paranoia */
-    len++,len&=~1;                     /* paranoia */
-    name=(WCHAR *)alloca(len+sizeof(WCHAR));
-    if (!GetUserObjectInformationW (h,UOI_NAME,name,len,&len))
-       return -1;
-
-    len++,len&=~1;                     /* paranoia */
-    name[len/sizeof(WCHAR)]=L'\0';     /* paranoia */
+       if (len > 512)
+               return -1;
+       /* paranoia */
+       len++, len&=~1;
+       /* paranoia */
+       name = (WCHAR *)alloca(len + sizeof(WCHAR));
+       if (!GetUserObjectInformationW (h, UOI_NAME, name, len, &len))
+               return -1;
+
+       len++, len&=~1;
+       /* paranoia */
+       name[len/sizeof(WCHAR)]=L'\0';  /* paranoia */
 #if 1
     /* This doesn't cover "interactive" services [working with real
      * WinSta0's] nor programs started non-interactively by Task
      * Scheduler [those are working with SAWinSta]. */
-    if (wcsstr(name,L"Service-0x"))    return 1;
+       if (wcsstr(name, L"Service-0x"))        return 1;
 #else
-    /* This covers all non-interactive programs such as services. */
-    if (!wcsstr(name,L"WinSta0"))      return 1;
+       /* This covers all non-interactive programs such as services. */
+       if (!wcsstr(name, L"WinSta0"))  return 1;
 #endif
-    else                               return 0;
+       else                            return 0;
 }
 #else
-int OPENSSL_isservice(void) { return 0; }
+       int OPENSSL_isservice(void) { return 0;
+}
 #endif
 
 void OPENSSL_showfatal (const char *fmta,...)
-{ va_list ap;
-  TCHAR buf[256];
-  const TCHAR *fmt;
+       { va_list ap;
+       TCHAR buf[256];
+       const TCHAR *fmt;
 #ifdef STD_ERROR_HANDLE        /* what a dirty trick! */
-  HANDLE h;
-
-    if ((h=GetStdHandle(STD_ERROR_HANDLE)) != NULL &&
-       GetFileType(h)!=FILE_TYPE_UNKNOWN)
-    {  /* must be console application */
-       va_start (ap,fmta);
-       vfprintf (stderr,fmta,ap);
-       va_end (ap);
-       return;
-    }
+       HANDLE h;
+
+       if ((h = GetStdHandle(STD_ERROR_HANDLE)) != NULL &&
+               GetFileType(h) != FILE_TYPE_UNKNOWN)
+               {       /* must be console application */
+               va_start (ap, fmta);
+               vfprintf (stderr, fmta, ap);
+               va_end (ap);
+               return;
+       }
 #endif
 
-    if (sizeof(TCHAR)==sizeof(char))
-       fmt=(const TCHAR *)fmta;
-    else do
-    { int    keepgoing;
-      size_t len_0=strlen(fmta)+1,i;
-      WCHAR *fmtw;
-
-       fmtw = (WCHAR *)alloca(len_0*sizeof(WCHAR));
-       if (fmtw == NULL) { fmt=(const TCHAR *)L"no stack?"; break; }
+       if (sizeof(TCHAR) == sizeof(char))
+               fmt = (const TCHAR *)fmta;
+       else do
+               { int    keepgoing;
+               size_t len_0 = strlen(fmta) + 1, i;
+               WCHAR *fmtw;
+
+               fmtw = (WCHAR *)alloca(len_0*sizeof(WCHAR));
+               if (fmtw == NULL) {
+                       fmt = (const TCHAR *)L"no stack?";
+                       break;
+               }
 
 #ifndef OPENSSL_NO_MULTIBYTE
-       if (!MultiByteToWideChar(CP_ACP,0,fmta,len_0,fmtw,len_0))
+               if (!MultiByteToWideChar(CP_ACP, 0, fmta, len_0, fmtw, len_0))
 #endif
-           for (i=0;i<len_0;i++) fmtw[i]=(WCHAR)fmta[i];
-
-       for (i=0;i<len_0;i++)
-       {   if (fmtw[i]==L'%') do
-           {   keepgoing=0;
-               switch (fmtw[i+1])
-               {   case L'0': case L'1': case L'2': case L'3': case L'4':
-                   case L'5': case L'6': case L'7': case L'8': case L'9':
-                   case L'.': case L'*':
-                   case L'-':  i++; keepgoing=1; break;
-                   case L's':  fmtw[i+1]=L'S';   break;
-                   case L'S':  fmtw[i+1]=L's';   break;
-                   case L'c':  fmtw[i+1]=L'C';   break;
-                   case L'C':  fmtw[i+1]=L'c';   break;
+               for (i = 0;i < len_0;i++) fmtw[i] = (WCHAR)fmta[i];
+
+               for (i = 0; i < len_0; i++)
+                               {   if (fmtw[i]==L'%') do
+                               {       keepgoing = 0;
+                               switch (fmtw[i + 1])
+                                       {   case L'0': case L'1': case L'2': case L'3': case L'4':
+                               case L'5': case L'6': case L'7': case L'8': case L'9':
+                               case L'.': case L'*':
+                               case L'-':
+                                       i++;
+                                       keepgoing = 1;
+                                       break;
+                               case L's':
+                                       fmtw[i + 1] = L'S';
+                                       break;
+                               case L'S':
+                                       fmtw[i + 1] = L's';
+                                       break;
+                               case L'c':
+                                       fmtw[i + 1] = L'C';
+                                       break;
+                               case L'C':
+                                       fmtw[i + 1] = L'c';
+                                       break;
+                               }
+                       } while (keepgoing);
                }
-           } while (keepgoing);
-       }
-       fmt = (const TCHAR *)fmtw;
-    } while (0);
+               fmt = (const TCHAR *)fmtw;
+       } while (0);
 
-    va_start (ap,fmta);
-    _vsntprintf (buf,sizeof(buf)/sizeof(TCHAR)-1,fmt,ap);
-    buf [sizeof(buf)/sizeof(TCHAR)-1] = _T('\0');
-    va_end (ap);
+       va_start (ap, fmta);
+       _vsntprintf (buf, sizeof(buf)/sizeof(TCHAR) - 1, fmt, ap);
+       buf [sizeof(buf)/sizeof(TCHAR) - 1] = _T('\0');
+       va_end (ap);
 
 #if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
-    /* this -------------v--- guards NT-specific calls */
-    if (check_winnt() && OPENSSL_isservice() > 0)
-    {  HANDLE h = RegisterEventSource(0,_T("OPENSSL"));
-       const TCHAR *pmsg=buf;
-       ReportEvent(h,EVENTLOG_ERROR_TYPE,0,0,0,1,0,&pmsg,0);
-       DeregisterEventSource(h);
-    }
-    else
+       /* this -------------v--- guards NT-specific calls */
+       if (check_winnt() && OPENSSL_isservice() > 0)
+                       {       HANDLE h = RegisterEventSource(0, _T("OPENSSL"));
+               const TCHAR *pmsg = buf;
+               ReportEvent(h, EVENTLOG_ERROR_TYPE, 0, 0, 0, 1, 0, &pmsg, 0);
+               DeregisterEventSource(h);
+       } else
 #endif
-       MessageBox (NULL,buf,_T("OpenSSL: FATAL"),MB_OK|MB_ICONSTOP);
+       MessageBox (NULL, buf, _T("OpenSSL: FATAL"), MB_OK|MB_ICONSTOP);
 }
 #else
-void OPENSSL_showfatal (const char *fmta,...)
-{ va_list ap;
+void OPENSSL_showfatal(const char *fmta, ...)
+{
+       va_list ap;
 
-    va_start (ap,fmta);
-    vfprintf (stderr,fmta,ap);
-    va_end (ap);
+       va_start (ap, fmta);
+       vfprintf (stderr, fmta, ap);
+       va_end (ap);
+}
+
+int OPENSSL_isservice(void)
+{
+       return 0;
 }
-int OPENSSL_isservice (void) { return 0; }
 #endif
 
-void OpenSSLDie(const char *file,int line,const char *assertion)
-       {
+void
+OpenSSLDie(const char *file, int line, const char *assertion)
+{
        OPENSSL_showfatal(
-               "%s(%d): OpenSSL internal error, assertion failed: %s\n",
-               file,line,assertion);
+           "%s(%d): OpenSSL internal error, assertion failed: %s\n",
+           file, line, assertion);
 #if !defined(_WIN32) || defined(__CYGWIN__)
        abort();
 #else
@@ -922,12 +946,16 @@ void OpenSSLDie(const char *file,int line,const char *assertion)
        raise(SIGABRT);
        _exit(3);
 #endif
-       }
+}
 
-void *OPENSSL_stderr(void)     { return stderr; }
+void *OPENSSL_stderr(void)
+{
+       return stderr;
+}
 
-int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len)
-       {
+int
+CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len)
+{
        size_t i;
        const unsigned char *a = in_a;
        const unsigned char *b = in_b;
@@ -937,4 +965,4 @@ int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len)
                x |= a[i] ^ b[i];
 
        return x;
-       }
+}
index 76bc595..baeba25 100644 (file)
@@ -154,23 +154,22 @@ extern "C" {
 typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
 /* Called when a new object is created */
 typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
-                                       int idx, long argl, void *argp);
+    int idx, long argl, void *argp);
 /* Called when an object is free()ed */
 typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
-                                       int idx, long argl, void *argp);
+    int idx, long argl, void *argp);
 /* Called when we need to dup an object */
-typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, 
-                                       int idx, long argl, void *argp);
+typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,
+    void *from_d, int idx, long argl, void *argp);
 #endif
 
 /* A generic structure to pass assorted data in a expandable way */
-typedef struct openssl_item_st
-       {
+typedef struct openssl_item_st {
        int code;
        void *value;            /* Not used for flag attributes */
        size_t value_size;      /* Max size of value for output, length for input */
        size_t *value_length;   /* Returned length of value for output */
-       } OPENSSL_ITEM;
+} OPENSSL_ITEM;
 
 
 /* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock
@@ -249,11 +248,10 @@ typedef struct openssl_item_st
    and deallocate locks in a dynamic fashion.  The following typedef
    makes this possible in a type-safe manner.  */
 /* struct CRYPTO_dynlock_value has to be defined by the application. */
-typedef struct
-       {
+typedef struct {
        int references;
        struct CRYPTO_dynlock_value *data;
-       } CRYPTO_dynlock;
+} CRYPTO_dynlock;
 
 
 /* The following can be used to detect memory leaks in the SSLeay library.
@@ -278,24 +276,22 @@ typedef struct
 /* predec of the BIO type */
 typedef struct bio_st BIO_dummy;
 
-struct crypto_ex_data_st
-       {
+struct crypto_ex_data_st {
        STACK_OF(void) *sk;
        int dummy; /* gcc is screwing up this data structure :-( */
-       };
+};
 DECLARE_STACK_OF(void)
 
 /* This stuff is basically class callback functions
  * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */
 
-typedef struct crypto_ex_data_func_st
-       {
+typedef struct crypto_ex_data_func_st {
        long argl;      /* Arbitary long */
        void *argp;     /* Arbitary void * */
        CRYPTO_EX_new *new_func;
        CRYPTO_EX_free *free_func;
        CRYPTO_EX_dup *dup_func;
-       } CRYPTO_EX_DATA_FUNCS;
+} CRYPTO_EX_DATA_FUNCS;
 
 DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
 
@@ -392,18 +388,18 @@ int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
 int CRYPTO_ex_data_new_class(void);
 /* Within a given class, get/register a new index */
 int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
-               CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
-               CRYPTO_EX_free *free_func);
+    CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
+    CRYPTO_EX_free *free_func);
 /* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given
  * class (invokes whatever per-class callbacks are applicable) */
 int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
 int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
-               CRYPTO_EX_DATA *from);
+    CRYPTO_EX_DATA *from);
 void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
 /* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index
  * (relative to the class type involved) */
 int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
-void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx);
+void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);
 /* This function cleans up all "ex_data" state. It mustn't be called under
  * potential race-conditions. */
 void CRYPTO_cleanup_all_ex_data(void);
@@ -411,22 +407,21 @@ void CRYPTO_cleanup_all_ex_data(void);
 int CRYPTO_get_new_lockid(char *name);
 
 int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */
-void CRYPTO_lock(int mode, int type,const char *file,int line);
-void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
-                                             const char *file,int line));
-void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
-               int line);
-void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
-                                             const char *file, int line));
-int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type,
-                                         const char *file,int line);
+void CRYPTO_lock(int mode, int type, const char *file, int line);
+void CRYPTO_set_locking_callback(void (*func)(int mode, int type,
+    const char *file, int line));
+void (*CRYPTO_get_locking_callback(void))(int mode, int type,
+    const char *file, int line);
+void CRYPTO_set_add_lock_callback(int (*func)(int *num, int mount, int type,
+    const char *file, int line));
+int (*CRYPTO_get_add_lock_callback(void))(int *num, int mount, int type,
+    const char *file, int line);
 
 /* Don't use this structure directly. */
-typedef struct crypto_threadid_st
-       {
+typedef struct crypto_threadid_st {
        void *ptr;
        unsigned long val;
-       } CRYPTO_THREADID;
+} CRYPTO_THREADID;
 /* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */
 void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val);
 void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);
@@ -443,8 +438,8 @@ unsigned long CRYPTO_thread_id(void);
 #endif
 
 const char *CRYPTO_get_lock_name(int type);
-int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
-                   int line);
+int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
+    int line);
 
 int CRYPTO_get_new_dynlockid(void);
 void CRYPTO_destroy_dynlockid(int i);
@@ -452,46 +447,43 @@ struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
 void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line));
 void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line));
 void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line));
-struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line);
-void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line);
-void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line);
+struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file, int line);
+void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line);
+void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file, int line);
 
 /* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
  * call the latter last if you need different functions */
-int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
+int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t), void (*f)(void *));
 int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
-int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int),
-                                void *(*r)(void *,size_t,const char *,int),
-                                void (*f)(void *));
-int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
-                                       void (*free_func)(void *));
-int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
-                                  void (*r)(void *,void *,int,const char *,int,int),
-                                  void (*f)(void *,int),
-                                  void (*so)(long),
-                                  long (*go)(void));
-void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
+int CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int),
+    void *(*r)(void *, size_t, const char *, int), void (*f)(void *));
+int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int),
+    void (*free_func)(void *));
+int CRYPTO_set_mem_debug_functions(
+    void (*m)(void *, int, const char *, int, int),
+    void (*r)(void *, void *, int, const char *, int, int),
+    void (*f)(void *, int), void (*so)(long), long (*go)(void));
+void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
+    void (**f)(void *));
 void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
-void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int),
-                                 void *(**r)(void *, size_t,const char *,int),
-                                 void (**f)(void *));
-void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
-                                        void (**f)(void *));
-void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
-                                   void (**r)(void *,void *,int,const char *,int,int),
-                                   void (**f)(void *,int),
-                                   void (**so)(long),
-                                   long (**go)(void));
+void CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int),
+    void *(**r)(void *, size_t, const char *, int), void (**f)(void *));
+void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int),
+    void (**f)(void *));
+void CRYPTO_get_mem_debug_functions(
+    void (**m)(void *, int, const char *, int, int),
+    void (**r)(void *, void *, int, const char *, int, int),
+    void (**f)(void *, int), void (**so)(long), long (**go)(void));
 
 void *CRYPTO_malloc_locked(int num, const char *file, int line);
 void CRYPTO_free_locked(void *ptr);
 void *CRYPTO_malloc(int num, const char *file, int line);
 char *CRYPTO_strdup(const char *str, const char *file, int line);
 void CRYPTO_free(void *ptr);
-void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
-void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
-                          int line);
-void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
+void *CRYPTO_realloc(void *addr, int num, const char *file, int line);
+void *CRYPTO_realloc_clean(void *addr, int old_num, int num,
+    const char *file, int line);
+void *CRYPTO_remalloc(void *addr, int num, const char *file, int line);
 
 void OPENSSL_cleanse(void *ptr, size_t len);
 
@@ -512,9 +504,9 @@ int CRYPTO_remove_all_info(void);
  * 0:  called before the actual memory allocation has taken place
  * 1:  called after the actual memory allocation has taken place
  */
-void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
-void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
-void CRYPTO_dbg_free(void *addr,int before_p);
+void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line, int before_p);
+void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, const char *file, int line, int before_p);
+void CRYPTO_dbg_free(void *addr, int before_p);
 /* Tell the debugging code about options.  By default, the following values
  * apply:
  *
@@ -536,7 +528,7 @@ typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
 void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
 
 /* die if we have to */
-void OpenSSLDie(const char *file,int line,const char *assertion);
+void OpenSSLDie(const char *file, int line, const char *assertion);
 #define OPENSSL_assert(e)       (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))
 
 unsigned long *OPENSSL_ia32cap_loc(void);
index ea9f25f..1fe92a4 100644 (file)
 #include "buildinf.h"
 #endif
 
-const char *SSLeay_version(int t)
-       {
+const char
+*SSLeay_version(int t)
+{
        if (t == SSLEAY_VERSION)
                return OPENSSL_VERSION_TEXT;
-       if (t == SSLEAY_BUILT_ON)
-               {
+       if (t == SSLEAY_BUILT_ON) {
 #ifdef DATE
-               static char buf[sizeof(DATE)+11];
+               static char buf[sizeof(DATE) + 11];
 
-               BIO_snprintf(buf,sizeof buf,"built on: %s",DATE);
-               return(buf);
+               BIO_snprintf(buf, sizeof buf, "built on: %s", DATE);
+               return (buf);
 #else
                return("built on: date not available");
 #endif
-               }
-       if (t == SSLEAY_CFLAGS)
-               {
+       }
+       if (t == SSLEAY_CFLAGS) {
 #ifdef CFLAGS
-               static char buf[sizeof(CFLAGS)+11];
+               static char buf[sizeof(CFLAGS) + 11];
 
-               BIO_snprintf(buf,sizeof buf,"compiler: %s",CFLAGS);
-               return(buf);
+               BIO_snprintf(buf, sizeof buf, "compiler: %s", CFLAGS);
+               return (buf);
 #else
                return("compiler: information not available");
 #endif
-               }
-       if (t == SSLEAY_PLATFORM)
-               {
+       }
+       if (t == SSLEAY_PLATFORM) {
 #ifdef PLATFORM
-               static char buf[sizeof(PLATFORM)+11];
+               static char buf[sizeof(PLATFORM) + 11];
 
-               BIO_snprintf(buf,sizeof buf,"platform: %s", PLATFORM);
-               return(buf);
+               BIO_snprintf(buf, sizeof buf, "platform: %s", PLATFORM);
+               return (buf);
 #else
                return("platform: information not available");
 #endif
-               }
-       if (t == SSLEAY_DIR)
-               {
+       }
+       if (t == SSLEAY_DIR) {
 #ifdef OPENSSLDIR
                return "OPENSSLDIR: \"" OPENSSLDIR "\"";
 #else
                return "OPENSSLDIR: N/A";
 #endif
-               }
-       return("not available");
-       }
-
-unsigned long SSLeay(void)
-       {
-       return(SSLEAY_VERSION_NUMBER);
        }
+       return("not available");
+}
 
+unsigned long
+SSLeay(void)
+{
+       return (SSLEAY_VERSION_NUMBER);
+}
index 43e53bc..2ac26ab 100644 (file)
@@ -4,7 +4,7 @@
 
 #include <openssl/e_os2.h>
 #if defined(PEDANTIC) || defined(__DECC) || defined(OPENSSL_SYS_MACOSX)
-static void *dummy=&dummy;
+static void *dummy = &dummy;
 #endif
 
 #else /*CHARSET_EBCDIC*/
@@ -30,38 +30,38 @@ static void *dummy=&dummy;
 
 /* Here's the bijective ebcdic-to-ascii table: */
 const unsigned char os_toascii[256] = {
-/*00*/ 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
-       0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
-/*10*/ 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
-       0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
-/*20*/ 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
-       0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /*................*/
-/*30*/ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
-       0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /*................*/
-/*40*/ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
-       0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* .........`.<(+|*/
-/*50*/ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
-       0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f, /*&.........!$*);.*/
-/*60*/ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
-       0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /*-/........^,%_>?*/
-/*70*/ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
-       0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /*..........:#@'="*/
-/*80*/ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
-       0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /*.abcdefghi......*/
-/*90*/ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
-       0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /*.jklmnopqr......*/
-/*a0*/ 0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
-       0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, /*..stuvwxyz......*/
-/*b0*/ 0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
-       0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7, /*...........[\]..*/
-/*c0*/ 0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
-       0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /*.ABCDEFGHI......*/
-/*d0*/ 0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
-       0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff, /*.JKLMNOPQR......*/
-/*e0*/ 0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
-       0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /*..STUVWXYZ......*/
-/*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
-       0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e  /*0123456789.{.}.~*/
+/*00*/  0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
+       0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
+/*10*/  0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
+       0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
+/*20*/  0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
+       0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /*................*/
+/*30*/  0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
+       0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /*................*/
+/*40*/  0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
+       0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* .........`.<(+|*/
+/*50*/  0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
+       0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f, /*&.........!$*);.*/
+/*60*/  0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
+       0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /*-/........^,%_>?*/
+/*70*/  0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
+       0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /*..........:#@'="*/
+/*80*/  0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+       0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /*.abcdefghi......*/
+/*90*/  0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+       0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /*.jklmnopqr......*/
+/*a0*/  0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+       0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, /*..stuvwxyz......*/
+/*b0*/  0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
+       0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7, /*...........[\]..*/
+/*c0*/  0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+       0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /*.ABCDEFGHI......*/
+/*d0*/  0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+       0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff, /*.JKLMNOPQR......*/
+/*e0*/  0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+       0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /*..STUVWXYZ......*/
+/*f0*/  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+       0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e  /*0123456789.{.}.~*/
 };
 
 
@@ -111,38 +111,38 @@ Bijective EBCDIC (character set IBM-1047) to US-ASCII table:
 This table is bijective - there are no ambigous or duplicate characters.
 */
 const unsigned char os_toascii[256] = {
-    0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f, /* 00-0f:           */
-    0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
-    0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97, /* 10-1f:           */
-    0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
-    0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b, /* 20-2f:           */
-    0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /* ................ */
-    0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30-3f:           */
-    0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /* ................ */
-    0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 40-4f:           */
-    0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /*  ...........<(+| */
-    0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 50-5f:           */
-    0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* &.........!$*);^ */
-    0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 60-6f:           */
-    0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* -/.........,%_>? */
-    0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 70-7f:           */
-    0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* .........`:#@'=" */
-    0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80-8f:           */
-    0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* .abcdefghi...... */
-    0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 90-9f:           */
-    0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* .jklmnopqr...... */
-    0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* a0-af:           */
-    0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae, /* .~stuvwxyz...[.. */
-    0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* b0-bf:           */
-    0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7, /* .............].. */
-    0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* c0-cf:           */
-    0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* {ABCDEFGHI...... */
-    0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* d0-df:           */
-    0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* }JKLMNOPQR...... */
-    0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* e0-ef:           */
-    0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* \.STUVWXYZ...... */
-    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* f0-ff:           */
-    0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f  /* 0123456789...... */
+       0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f, /* 00-0f:           */
+       0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
+       0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97, /* 10-1f:           */
+       0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
+       0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b, /* 20-2f:           */
+       0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /* ................ */
+       0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30-3f:           */
+       0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /* ................ */
+       0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 40-4f:           */
+       0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /*  ...........<(+| */
+       0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 50-5f:           */
+       0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* &.........!$*);^ */
+       0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 60-6f:           */
+       0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* -/.........,%_>? */
+       0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 70-7f:           */
+       0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* .........`:#@'=" */
+       0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80-8f:           */
+       0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* .abcdefghi...... */
+       0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 90-9f:           */
+       0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* .jklmnopqr...... */
+       0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* a0-af:           */
+       0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae, /* .~stuvwxyz...[.. */
+       0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* b0-bf:           */
+       0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7, /* .............].. */
+       0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* c0-cf:           */
+               0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* {ABCDEFGHI...... */
+               0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* d0-df:           */
+       0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* }JKLMNOPQR...... */
+       0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* e0-ef:           */
+       0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* \.STUVWXYZ...... */
+       0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* f0-ff:           */
+       0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f  /* 0123456789...... */
 };
 
 
@@ -151,38 +151,38 @@ The US-ASCII to EBCDIC (character set IBM-1047) table:
 This table is bijective (no ambiguous or duplicate characters)
 */
 const unsigned char os_toebcdic[256] = {
-    0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, /* 00-0f:           */
-    0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
-    0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, /* 10-1f:           */
-    0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
-    0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 20-2f:           */
-    0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /*  !"#$%&'()*+,-./ */
-    0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 30-3f:           */
-    0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0123456789:;<=>? */
-    0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 40-4f:           */
-    0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* @ABCDEFGHIJKLMNO */
-    0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 50-5f:           */
-    0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d, /* PQRSTUVWXYZ[\]^_ */
-    0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60-6f:           */
-    0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* `abcdefghijklmno */
-    0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 70-7f:           */
-    0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07, /* pqrstuvwxyz{|}~. */
-    0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08, /* 80-8f:           */
-    0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /* ................ */
-    0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17, /* 90-9f:           */
-    0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0xff, /* ................ */
-    0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, /* a0-af:           */
-    0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc, /* ................ */
-    0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, /* b0-bf:           */
-    0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /* ................ */
-    0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, /* c0-cf:           */
-    0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* ................ */
-    0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, /* d0-df:           */
-    0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59, /* ................ */
-    0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, /* e0-ef:           */
-    0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* ................ */
-    0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* f0-ff:           */
-    0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf  /* ................ */
+       0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, /* 00-0f:           */
+       0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
+       0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, /* 10-1f:           */
+       0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
+       0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 20-2f:           */
+       0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /*  !"#$%&'()*+,-./ */
+       0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 30-3f:           */
+       0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0123456789:;<=>? */
+       0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 40-4f:           */
+       0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* @ABCDEFGHIJKLMNO */
+       0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 50-5f:           */
+       0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d, /* PQRSTUVWXYZ[\]^_ */
+       0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60-6f:           */
+       0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* `abcdefghijklmno */
+       0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 70-7f:           */
+       0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07, /* pqrstuvwxyz{|}~. */
+       0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08, /* 80-8f:           */
+       0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /* ................ */
+       0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17, /* 90-9f:           */
+       0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0xff, /* ................ */
+       0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, /* a0-af:           */
+       0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc, /* ................ */
+       0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, /* b0-bf:           */
+       0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /* ................ */
+       0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, /* c0-cf:           */
+       0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* ................ */
+       0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, /* d0-df:           */
+       0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59, /* ................ */
+       0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, /* e0-ef:           */
+       0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* ................ */
+       0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* f0-ff:           */
+       0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf  /* ................ */
 };
 #endif /*_OSD_POSIX*/
 
@@ -195,27 +195,27 @@ const unsigned char os_toebcdic[256] = {
 void *
 ebcdic2ascii(void *dest, const void *srce, size_t count)
 {
-    unsigned char *udest = dest;
-    const unsigned char *usrce = srce;
+       unsigned char *udest = dest;
+       const unsigned char *usrce = srce;
 
-    while (count-- != 0) {
-        *udest++ = os_toascii[*usrce++];
-    }
+       while (count-- != 0) {
+               *udest++ = os_toascii[*usrce++];
+       }
 
-    return dest;
+       return dest;
 }
 
 void *
 ascii2ebcdic(void *dest, const void *srce, size_t count)
 {
-    unsigned char *udest = dest;
-    const unsigned char *usrce = srce;
+       unsigned char *udest = dest;
+       const unsigned char *usrce = srce;
 
-    while (count-- != 0) {
-        *udest++ = os_toebcdic[*usrce++];
-    }
+       while (count-- != 0) {
+               *udest++ = os_toebcdic[*usrce++];
+       }
 
-    return dest;
+       return dest;
 }
 
 #endif
index e2bc829..44bad59 100644 (file)
 #include <openssl/lhash.h>
 
 /* What an "implementation of ex_data functionality" looks like */
-struct st_CRYPTO_EX_DATA_IMPL
-       {
+struct st_CRYPTO_EX_DATA_IMPL {
        /*********************/
        /* GLOBAL OPERATIONS */
        /* Return a new class index */
@@ -154,79 +153,83 @@ struct st_CRYPTO_EX_DATA_IMPL
        /* PER-CLASS OPERATIONS */
        /* Get a new method index within a class */
        int (*cb_get_new_index)(int class_index, long argl, void *argp,
-                       CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
-                       CRYPTO_EX_free *free_func);
+           CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
+           CRYPTO_EX_free *free_func);
        /* Initialise a new CRYPTO_EX_DATA of a given class */
        int (*cb_new_ex_data)(int class_index, void *obj,
-                       CRYPTO_EX_DATA *ad);
+           CRYPTO_EX_DATA *ad);
        /* Duplicate a CRYPTO_EX_DATA of a given class onto a copy */
        int (*cb_dup_ex_data)(int class_index, CRYPTO_EX_DATA *to,
-                       CRYPTO_EX_DATA *from);
+           CRYPTO_EX_DATA *from);
        /* Cleanup a CRYPTO_EX_DATA of a given class */
        void (*cb_free_ex_data)(int class_index, void *obj,
-                       CRYPTO_EX_DATA *ad);
-       };
+           CRYPTO_EX_DATA *ad);
+};
 
 /* The implementation we use at run-time */
 static const CRYPTO_EX_DATA_IMPL *impl = NULL;
 
 /* To call "impl" functions, use this macro rather than referring to 'impl' directly, eg.
- * EX_IMPL(get_new_index)(...); */
+ * EX_IMPL(get_new_index)(...);
+*/
 #define EX_IMPL(a) impl->cb_##a
 
 /* Predeclare the "default" ex_data implementation */
 static int int_new_class(void);
 static void int_cleanup(void);
 static int int_get_new_index(int class_index, long argl, void *argp,
-               CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
-               CRYPTO_EX_free *free_func);
+    CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
+    CRYPTO_EX_free *free_func);
 static int int_new_ex_data(int class_index, void *obj,
-               CRYPTO_EX_DATA *ad);
+    CRYPTO_EX_DATA *ad);
 static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
-               CRYPTO_EX_DATA *from);
+    CRYPTO_EX_DATA *from);
 static void int_free_ex_data(int class_index, void *obj,
-               CRYPTO_EX_DATA *ad);
-static CRYPTO_EX_DATA_IMPL impl_default =
-       {
+    CRYPTO_EX_DATA *ad);
+
+static CRYPTO_EX_DATA_IMPL impl_default = {
        int_new_class,
        int_cleanup,
        int_get_new_index,
        int_new_ex_data,
        int_dup_ex_data,
        int_free_ex_data
-       };
+};
 
 /* Internal function that checks whether "impl" is set and if not, sets it to
  * the default. */
-static void impl_check(void)
-       {
+static void
+impl_check(void)
+{
        CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
-       if(!impl)
+       if (!impl)
                impl = &impl_default;
        CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
-       }
+}
 /* A macro wrapper for impl_check that first uses a non-locked test before
  * invoking the function (which checks again inside a lock). */
 #define IMPL_CHECK if(!impl) impl_check();
 
 /* API functions to get/set the "ex_data" implementation */
-const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void)
-       {
+const CRYPTO_EX_DATA_IMPL
+*CRYPTO_get_ex_data_implementation(void)
+{
        IMPL_CHECK
        return impl;
-       }
-int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i)
-       {
+}
+
+int
+CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i)
+{
        int toret = 0;
        CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
-       if(!impl)
-               {
+       if (!impl) {
                impl = i;
                toret = 1;
-               }
+       }
        CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
        return toret;
-       }
+}
 
 /****************************************************************************/
 /* Interal (default) implementation of "ex_data" support. API functions are
@@ -249,288 +252,283 @@ DECLARE_LHASH_OF(EX_CLASS_ITEM);
 static LHASH_OF(EX_CLASS_ITEM) *ex_data = NULL;
 
 /* The callbacks required in the "ex_data" hash table */
-static unsigned long ex_class_item_hash(const EX_CLASS_ITEM *a)
-       {
+static unsigned long
+ex_class_item_hash(const EX_CLASS_ITEM *a)
+{
        return a->class_index;
-       }
+}
+
 static IMPLEMENT_LHASH_HASH_FN(ex_class_item, EX_CLASS_ITEM)
 
-static int ex_class_item_cmp(const EX_CLASS_ITEM *a, const EX_CLASS_ITEM *b)
-       {
+static int
+ex_class_item_cmp(const EX_CLASS_ITEM *a, const EX_CLASS_ITEM *b)
+{
        return a->class_index - b->class_index;
-       }
+}
+
 static IMPLEMENT_LHASH_COMP_FN(ex_class_item, EX_CLASS_ITEM)
 
 /* Internal functions used by the "impl_default" implementation to access the
  * state */
 
-static int ex_data_check(void)
-       {
+static int
+ex_data_check(void)
+{
        int toret = 1;
        CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
-       if(!ex_data
-          && (ex_data = lh_EX_CLASS_ITEM_new()) == NULL)
-               toret = 0;
+       if (!ex_data
+               && (ex_data = lh_EX_CLASS_ITEM_new()) == NULL)
+       toret = 0;
        CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
        return toret;
-       }
+}
 /* This macros helps reduce the locking from repeated checks because the
  * ex_data_check() function checks ex_data again inside a lock. */
 #define EX_DATA_CHECK(iffail) if(!ex_data && !ex_data_check()) {iffail}
 
 /* This "inner" callback is used by the callback function that follows it */
-static void def_cleanup_util_cb(CRYPTO_EX_DATA_FUNCS *funcs)
-       {
+static void
+def_cleanup_util_cb(CRYPTO_EX_DATA_FUNCS *funcs)
+{
        OPENSSL_free(funcs);
-       }
+}
 
 /* This callback is used in lh_doall to destroy all EX_CLASS_ITEM values from
  * "ex_data" prior to the ex_data hash table being itself destroyed. Doesn't do
  * any locking. */
-static void def_cleanup_cb(void *a_void)
-       {
+static void
+def_cleanup_cb(void *a_void)
+{
        EX_CLASS_ITEM *item = (EX_CLASS_ITEM *)a_void;
        sk_CRYPTO_EX_DATA_FUNCS_pop_free(item->meth, def_cleanup_util_cb);
        OPENSSL_free(item);
-       }
+}
 
 /* Return the EX_CLASS_ITEM from the "ex_data" hash table that corresponds to a
  * given class. Handles locking. */
-static EX_CLASS_ITEM *def_get_class(int class_index)
-       {
+static EX_CLASS_ITEM
+*def_get_class(int class_index)
+{
        EX_CLASS_ITEM d, *p, *gen;
        EX_DATA_CHECK(return NULL;)
        d.class_index = class_index;
        CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
        p = lh_EX_CLASS_ITEM_retrieve(ex_data, &d);
-       if(!p)
-               {
+       if (!p) {
                gen = OPENSSL_malloc(sizeof(EX_CLASS_ITEM));
-               if(gen)
-                       {
+               if (gen) {
                        gen->class_index = class_index;
                        gen->meth_num = 0;
                        gen->meth = sk_CRYPTO_EX_DATA_FUNCS_new_null();
-                       if(!gen->meth)
+                       if (!gen->meth)
                                OPENSSL_free(gen);
-                       else
-                               {
+                       else {
                                /* Because we're inside the ex_data lock, the
                                 * return value from the insert will be NULL */
                                (void)lh_EX_CLASS_ITEM_insert(ex_data, gen);
                                p = gen;
-                               }
                        }
                }
+       }
        CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
-       if(!p)
-               CRYPTOerr(CRYPTO_F_DEF_GET_CLASS,ERR_R_MALLOC_FAILURE);
+       if (!p)
+               CRYPTOerr(CRYPTO_F_DEF_GET_CLASS, ERR_R_MALLOC_FAILURE);
        return p;
-       }
+}
 
 /* Add a new method to the given EX_CLASS_ITEM and return the corresponding
  * index (or -1 for error). Handles locking. */
-static int def_add_index(EX_CLASS_ITEM *item, long argl, void *argp,
-               CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
-               CRYPTO_EX_free *free_func)
-       {
+static int
+def_add_index(EX_CLASS_ITEM *item, long argl, void *argp,
+    CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
+{
        int toret = -1;
        CRYPTO_EX_DATA_FUNCS *a = (CRYPTO_EX_DATA_FUNCS *)OPENSSL_malloc(
-                                       sizeof(CRYPTO_EX_DATA_FUNCS));
-       if(!a)
-               {
-               CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX,ERR_R_MALLOC_FAILURE);
+       sizeof(CRYPTO_EX_DATA_FUNCS));
+       if (!a) {
+               CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX, ERR_R_MALLOC_FAILURE);
                return -1;
-               }
-       a->argl=argl;
-       a->argp=argp;
-       a->new_func=new_func;
-       a->dup_func=dup_func;
-       a->free_func=free_func;
+       }
+       a->argl = argl;
+       a->argp = argp;
+       a->new_func = new_func;
+       a->dup_func = dup_func;
+       a->free_func = free_func;
        CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
-       while (sk_CRYPTO_EX_DATA_FUNCS_num(item->meth) <= item->meth_num)
-               {
-               if (!sk_CRYPTO_EX_DATA_FUNCS_push(item->meth, NULL))
-                       {
-                       CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX,ERR_R_MALLOC_FAILURE);
+       while (sk_CRYPTO_EX_DATA_FUNCS_num(item->meth) <= item->meth_num) {
+               if (!sk_CRYPTO_EX_DATA_FUNCS_push(item->meth, NULL)) {
+                       CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX, ERR_R_MALLOC_FAILURE);
                        OPENSSL_free(a);
                        goto err;
-                       }
                }
+       }
        toret = item->meth_num++;
        (void)sk_CRYPTO_EX_DATA_FUNCS_set(item->meth, toret, a);
 err:
        CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
        return toret;
-       }
+}
 
 /**************************************************************/
 /* The functions in the default CRYPTO_EX_DATA_IMPL structure */
 
-static int int_new_class(void)
-       {
+static int
+int_new_class(void)
+{
        int toret;
        CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
        toret = ex_class++;
        CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
        return toret;
-       }
+}
 
-static void int_cleanup(void)
-       {
+static void
+int_cleanup(void)
+{
        EX_DATA_CHECK(return;)
        lh_EX_CLASS_ITEM_doall(ex_data, def_cleanup_cb);
        lh_EX_CLASS_ITEM_free(ex_data);
        ex_data = NULL;
        impl = NULL;
-       }
+}
 
-static int int_get_new_index(int class_index, long argl, void *argp,
-               CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
-               CRYPTO_EX_free *free_func)
-       {
+static int
+int_get_new_index(int class_index, long argl, void *argp,
+    CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
+CRYPTO_EX_free *free_func)
+{
        EX_CLASS_ITEM *item = def_get_class(class_index);
-       if(!item)
+       if (!item)
                return -1;
        return def_add_index(item, argl, argp, new_func, dup_func, free_func);
-       }
+}
 
 /* Thread-safe by copying a class's array of "CRYPTO_EX_DATA_FUNCS" entries in
  * the lock, then using them outside the lock. NB: Thread-safety only applies to
  * the global "ex_data" state (ie. class definitions), not thread-safe on 'ad'
  * itself. */
-static int int_new_ex_data(int class_index, void *obj,
-               CRYPTO_EX_DATA *ad)
-       {
-       int mx,i;
+static int
+int_new_ex_data(int class_index, void *obj,
+    CRYPTO_EX_DATA *ad)
+{
+       int mx, i;
        void *ptr;
        CRYPTO_EX_DATA_FUNCS **storage = NULL;
        EX_CLASS_ITEM *item = def_get_class(class_index);
-       if(!item)
+       if (!item)
                /* error is already set */
                return 0;
        ad->sk = NULL;
        CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
        mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
-       if(mx > 0)
-               {
+       if (mx > 0) {
                storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS*));
-               if(!storage)
+               if (!storage)
                        goto skip;
-               for(i = 0; i < mx; i++)
-                       storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth,i);
-               }
+               for (i = 0; i < mx; i++)
+                       storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth, i);
+       }
 skip:
        CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);
-       if((mx > 0) && !storage)
-               {
-               CRYPTOerr(CRYPTO_F_INT_NEW_EX_DATA,ERR_R_MALLOC_FAILURE);
+       if ((mx > 0) && !storage) {
+               CRYPTOerr(CRYPTO_F_INT_NEW_EX_DATA, ERR_R_MALLOC_FAILURE);
                return 0;
-               }
-       for(i = 0; i < mx; i++)
-               {
-               if(storage[i] && storage[i]->new_func)
-                       {
+       }
+       for (i = 0; i < mx; i++) {
+               if (storage[i] && storage[i]->new_func) {
                        ptr = CRYPTO_get_ex_data(ad, i);
-                       storage[i]->new_func(obj,ptr,ad,i,
-                               storage[i]->argl,storage[i]->argp);
-                       }
+                       storage[i]->new_func(obj, ptr, ad, i,
+                       storage[i]->argl, storage[i]->argp);
                }
-       if(storage)
+       }
+       if (storage)
                OPENSSL_free(storage);
        return 1;
-       }
+}
 
 /* Same thread-safety notes as for "int_new_ex_data" */
-static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
-               CRYPTO_EX_DATA *from)
-       {
+static int
+int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
+    CRYPTO_EX_DATA *from)
+{
        int mx, j, i;
        char *ptr;
        CRYPTO_EX_DATA_FUNCS **storage = NULL;
        EX_CLASS_ITEM *item;
-       if(!from->sk)
+       if (!from->sk)
                /* 'to' should be "blank" which *is* just like 'from' */
                return 1;
-       if((item = def_get_class(class_index)) == NULL)
+       if ((item = def_get_class(class_index)) == NULL)
                return 0;
        CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
        mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
        j = sk_void_num(from->sk);
-       if(j < mx)
+       if (j < mx)
                mx = j;
-       if(mx > 0)
-               {
+       if (mx > 0) {
                storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS*));
-               if(!storage)
+               if (!storage)
                        goto skip;
-               for(i = 0; i < mx; i++)
-                       storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth,i);
-               }
+               for (i = 0; i < mx; i++)
+                       storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth, i);
+       }
 skip:
        CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);
-       if((mx > 0) && !storage)
-               {
-               CRYPTOerr(CRYPTO_F_INT_DUP_EX_DATA,ERR_R_MALLOC_FAILURE);
+       if ((mx > 0) && !storage) {
+               CRYPTOerr(CRYPTO_F_INT_DUP_EX_DATA, ERR_R_MALLOC_FAILURE);
                return 0;
-               }
-       for(i = 0; i < mx; i++)
-               {
+       }
+       for (i = 0; i < mx; i++) {
                ptr = CRYPTO_get_ex_data(from, i);
-               if(storage[i] && storage[i]->dup_func)
-                       storage[i]->dup_func(to,from,&ptr,i,
-                               storage[i]->argl,storage[i]->argp);
-               CRYPTO_set_ex_data(to,i,ptr);
-               }
-       if(storage)
+               if (storage[i] && storage[i]->dup_func)
+                       storage[i]->dup_func(to, from, &ptr, i,
+                           storage[i]->argl, storage[i]->argp);
+               CRYPTO_set_ex_data(to, i, ptr);
+       }
+       if (storage)
                OPENSSL_free(storage);
        return 1;
-       }
+}
 
 /* Same thread-safety notes as for "int_new_ex_data" */
-static void int_free_ex_data(int class_index, void *obj,
-               CRYPTO_EX_DATA *ad)
-       {
-       int mx,i;
+static void
+int_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
+{
+       int mx, i;
        EX_CLASS_ITEM *item;
        void *ptr;
        CRYPTO_EX_DATA_FUNCS **storage = NULL;
-       if((item = def_get_class(class_index)) == NULL)
+       if ((item = def_get_class(class_index)) == NULL)
                return;
        CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
        mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
-       if(mx > 0)
-               {
+       if (mx > 0) {
                storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS*));
-               if(!storage)
+               if (!storage)
                        goto skip;
-               for(i = 0; i < mx; i++)
-                       storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth,i);
-               }
+               for (i = 0; i < mx; i++)
+                       storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth, i);
+       }
 skip:
        CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);
-       if((mx > 0) && !storage)
-               {
-               CRYPTOerr(CRYPTO_F_INT_FREE_EX_DATA,ERR_R_MALLOC_FAILURE);
+       if ((mx > 0) && !storage) {
+               CRYPTOerr(CRYPTO_F_INT_FREE_EX_DATA, ERR_R_MALLOC_FAILURE);
                return;
+       }
+       for (i = 0; i < mx; i++) {
+               if (storage[i] && storage[i]->free_func) {
+                       ptr = CRYPTO_get_ex_data(ad, i);
+                       storage[i]->free_func(obj, ptr, ad, i,
+                       storage[i]->argl, storage[i]->argp);
                }
-       for(i = 0; i < mx; i++)
-               {
-               if(storage[i] && storage[i]->free_func)
-                       {
-                       ptr = CRYPTO_get_ex_data(ad,i);
-                       storage[i]->free_func(obj,ptr,ad,i,
-                               storage[i]->argl,storage[i]->argp);
-                       }
-               }
-       if(storage)
+       }
+       if (storage)
                OPENSSL_free(storage);
-       if(ad->sk)
-               {
+       if (ad->sk) {
                sk_void_free(ad->sk);
-               ad->sk=NULL;
-               }
+               ad->sk = NULL;
        }
+}
 
 /********************************************************************/
 /* API functions that defer all "state" operations to the "ex_data"
@@ -538,99 +536,101 @@ skip:
 
 /* Obtain an index for a new class (not the same as getting a new index within
  * an existing class - this is actually getting a new *class*) */
-int CRYPTO_ex_data_new_class(void)
-       {
+int
+CRYPTO_ex_data_new_class(void)
+{
        IMPL_CHECK
        return EX_IMPL(new_class)();
-       }
+}
 
 /* Release all "ex_data" state to prevent memory leaks. This can't be made
  * thread-safe without overhauling a lot of stuff, and shouldn't really be
  * called under potential race-conditions anyway (it's for program shutdown
  * after all). */
-void CRYPTO_cleanup_all_ex_data(void)
-       {
+void
+CRYPTO_cleanup_all_ex_data(void)
+{
        IMPL_CHECK
        EX_IMPL(cleanup)();
-       }
+}
 
 /* Inside an existing class, get/register a new index. */
-int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
-               CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
-               CRYPTO_EX_free *free_func)
-       {
+int
+CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
+    CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
+{
        int ret = -1;
 
        IMPL_CHECK
        ret = EX_IMPL(get_new_index)(class_index,
-                       argl, argp, new_func, dup_func, free_func);
+       argl, argp, new_func, dup_func, free_func);
        return ret;
-       }
+}
 
 /* Initialise a new CRYPTO_EX_DATA for use in a particular class - including
  * calling new() callbacks for each index in the class used by this variable */
-int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
-       {
+int
+CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
+{
        IMPL_CHECK
        return EX_IMPL(new_ex_data)(class_index, obj, ad);
-       }
+}
 
 /* Duplicate a CRYPTO_EX_DATA variable - including calling dup() callbacks for
  * each index in the class used by this variable */
-int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
-            CRYPTO_EX_DATA *from)
-       {
+int
+CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from)
+{
        IMPL_CHECK
        return EX_IMPL(dup_ex_data)(class_index, to, from);
-       }
+}
 
 /* Cleanup a CRYPTO_EX_DATA variable - including calling free() callbacks for
  * each index in the class used by this variable */
-void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
-       {
+void
+CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
+{
        IMPL_CHECK
        EX_IMPL(free_ex_data)(class_index, obj, ad);
-       }
+}
 
 /* For a given CRYPTO_EX_DATA variable, set the value corresponding to a
  * particular index in the class used by this variable */
-int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val)
-       {
+int
+CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val)
+{
        int i;
 
-       if (ad->sk == NULL)
-               {
-               if ((ad->sk=sk_void_new_null()) == NULL)
-                       {
-                       CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA,ERR_R_MALLOC_FAILURE);
-                       return(0);
-                       }
+       if (ad->sk == NULL) {
+               if ((ad->sk = sk_void_new_null()) == NULL) {
+                       CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA, ERR_R_MALLOC_FAILURE);
+                       return (0);
                }
-       i=sk_void_num(ad->sk);
-
-       while (i <= idx)
-               {
-               if (!sk_void_push(ad->sk,NULL))
-                       {
-                       CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA,ERR_R_MALLOC_FAILURE);
-                       return(0);
-                       }
-               i++;
+       }
+       i = sk_void_num(ad->sk);
+
+       while (i <= idx) {
+               if (!sk_void_push(ad->sk, NULL)) {
+                       CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA, ERR_R_MALLOC_FAILURE);
+                       return (0);
                }
-       sk_void_set(ad->sk,idx,val);
-       return(1);
+               i++;
        }
+       sk_void_set(ad->sk, idx, val);
+       return (1);
+}
 
 /* For a given CRYPTO_EX_DATA_ variable, get the value corresponding to a
  * particular index in the class used by this variable */
-void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
-       {
+void
+*CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
+{
        if (ad->sk == NULL)
-               return(0);
+               return (0);
        else if (idx >= sk_void_num(ad->sk))
-               return(0);
+               return (0);
        else
-               return(sk_void_value(ad->sk,idx));
-       }
+               return (sk_void_value(ad->sk, idx));
+}
 
 IMPLEMENT_STACK_OF(CRYPTO_EX_DATA_FUNCS)
index 09f1174..1788ed2 100644 (file)
@@ -3,5 +3,5 @@
 #ifdef OPENSSL_FIPS
 # include "fips_err.h"
 #else
-static void *dummy=&dummy;
+static void *dummy = &dummy;
 #endif
index bb73819..bfb610e 100644 (file)
 #  if defined(__POWERPC__)
 #   define ROTATE(a,n) __rlwinm(a,n,0,31)
 #  elif defined(__MC68K__)
-    /* Motorola specific tweak. <appro@fy.chalmers.se> */
+/* Motorola specific tweak. <appro@fy.chalmers.se> */
 #   define ROTATE(a,n) ( n<24 ? __rol(a,n) : __ror(a,32-n) )
 #  else
 #   define ROTATE(a,n) __rol(a,n)
 #endif
 #if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
 # ifndef B_ENDIAN
-   /* See comment in DATA_ORDER_IS_BIG_ENDIAN section. */
+/* See comment in DATA_ORDER_IS_BIG_ENDIAN section. */
 #  define HOST_c2l(c,l)        ((l)=*((const unsigned int *)(c)), (c)+=4, l)
 #  define HOST_l2c(l,c)        (*((unsigned int *)(c))=(l), (c)+=4, l)
 # endif
  * Time for some action:-)
  */
 
-int HASH_UPDATE (HASH_CTX *c, const void *data_, size_t len)
-       {
-       const unsigned char *data=data_;
+int
+HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len)
+{
+       const unsigned char *data = data_;
        unsigned char *p;
        HASH_LONG l;
        size_t n;
 
-       if (len==0) return 1;
+       if (len == 0)
+               return 1;
 
-       l=(c->Nl+(((HASH_LONG)len)<<3))&0xffffffffUL;
+       l = (c->Nl + (((HASH_LONG)len) << 3))&0xffffffffUL;
        /* 95-05-24 eay Fixed a bug with the overflow handling, thanks to
         * Wei Dai <weidai@eskimo.com> for pointing it out. */
        if (l < c->Nl) /* overflow */
                c->Nh++;
        c->Nh+=(HASH_LONG)(len>>29);    /* might cause compiler warning on 16-bit */
-       c->Nl=l;
+       c->Nl = l;
 
        n = c->num;
-       if (n != 0)
-               {
-               p=(unsigned char *)c->data;
-
-               if (len >= HASH_CBLOCK || len+n >= HASH_CBLOCK)
-                       {
-                       memcpy (p+n,data,HASH_CBLOCK-n);
-                       HASH_BLOCK_DATA_ORDER (c,p,1);
-                       n      = HASH_CBLOCK-n;
-                       data  += n;
-                       len   -= n;
+       if (n != 0) {
+               p = (unsigned char *)c->data;
+
+               if (len >= HASH_CBLOCK || len + n >= HASH_CBLOCK) {
+                       memcpy (p + n, data, HASH_CBLOCK - n);
+                       HASH_BLOCK_DATA_ORDER (c, p, 1);
+                       n = HASH_CBLOCK - n;
+                       data += n;
+                       len -= n;
                        c->num = 0;
                        memset (p,0,HASH_CBLOCK);       /* keep it zeroed */
-                       }
-               else
-                       {
-                       memcpy (p+n,data,len);
+               } else {
+                       memcpy (p + n, data, len);
                        c->num += (unsigned int)len;
                        return 1;
-                       }
                }
+       }
 
        n = len/HASH_CBLOCK;
-       if (n > 0)
-               {
-               HASH_BLOCK_DATA_ORDER (c,data,n);
+       if (n > 0) {
+               HASH_BLOCK_DATA_ORDER (c, data, n);
                n    *= HASH_CBLOCK;
                data += n;
-               len  -= n;
-               }
+               len -= n;
+       }
 
-       if (len != 0)
-               {
+       if (len != 0) {
                p = (unsigned char *)c->data;
                c->num = (unsigned int)len;
-               memcpy (p,data,len);
-               }
-       return 1;
+               memcpy (p, data, len);
        }
+       return 1;
+}
 
 
 void HASH_TRANSFORM (HASH_CTX *c, const unsigned char *data)
-       {
-       HASH_BLOCK_DATA_ORDER (c,data,1);
-       }
+{
+       HASH_BLOCK_DATA_ORDER (c, data, 1);
+}
 
 
 int HASH_FINAL (unsigned char *md, HASH_CTX *c)
-       {
+{
        unsigned char *p = (unsigned char *)c->data;
        size_t n = c->num;
 
        p[n] = 0x80; /* there is always room for one */
        n++;
 
-       if (n > (HASH_CBLOCK-8))
-               {
-               memset (p+n,0,HASH_CBLOCK-n);
-               n=0;
-               HASH_BLOCK_DATA_ORDER (c,p,1);
-               }
-       memset (p+n,0,HASH_CBLOCK-8-n);
+       if (n > (HASH_CBLOCK - 8)) {
+               memset (p + n, 0, HASH_CBLOCK - n);
+               n = 0;
+               HASH_BLOCK_DATA_ORDER (c, p, 1);
+       }
+       memset (p + n, 0, HASH_CBLOCK - 8 - n);
 
-       p += HASH_CBLOCK-8;
+       p += HASH_CBLOCK - 8;
 #if   defined(DATA_ORDER_IS_BIG_ENDIAN)
-       (void)HOST_l2c(c->Nh,p);
-       (void)HOST_l2c(c->Nl,p);
+       (void)HOST_l2c(c->Nh, p);
+       (void)HOST_l2c(c->Nl, p);
 #elif defined(DATA_ORDER_IS_LITTLE_ENDIAN)
-       (void)HOST_l2c(c->Nl,p);
-       (void)HOST_l2c(c->Nh,p);
+       (void)HOST_l2c(c->Nl, p);
+       (void)HOST_l2c(c->Nh, p);
 #endif
        p -= HASH_CBLOCK;
-       HASH_BLOCK_DATA_ORDER (c,p,1);
-       c->num=0;
-       memset (p,0,HASH_CBLOCK);
+       HASH_BLOCK_DATA_ORDER (c, p, 1);
+       c->num = 0;
+       memset (p, 0, HASH_CBLOCK);
 
 #ifndef HASH_MAKE_STRING
 #error "HASH_MAKE_STRING must be defined!"
 #else
-       HASH_MAKE_STRING(c,md);
+       HASH_MAKE_STRING(c, md);
 #endif
 
        return 1;
-       }
+}
 
 #ifndef MD32_REG_T
 #if defined(__alpha) || defined(__sparcv9) || defined(__mips)
index 55e829d..86e5ff1 100644 (file)
 #include "cryptlib.h"
 
 
-static int allow_customize = 1;      /* we provide flexible functions for */
-static int allow_customize_debug = 1;/* exchanging memory-related functions at
-                                      * run-time, but this must be done
-                                      * before any blocks are actually
-                                      * allocated; or we'll run into huge
-                                      * problems when malloc/free pairs
-                                      * don't match etc. */
-
-
+static int allow_customize = 1;
+/* we provide flexible functions for */
+static int allow_customize_debug = 1;/* exchanging memory - related functions at
+                                       * run - time, but this must be done
+                                       * before any blocks are actually
+                                       * allocated; or we'll run into huge
+                                       * problems when malloc/free pairs
+                                       * don't match etc. */
 
 /* the following pointers may be changed as long as 'allow_customize' is set */
 
-static void *(*malloc_func)(size_t)         = malloc;
-static void *default_malloc_ex(size_t num, const char *file, int line)
-       { return malloc_func(num); }
-static void *(*malloc_ex_func)(size_t, const char *file, int line)
-        = default_malloc_ex;
-
-static void *(*realloc_func)(void *, size_t)= realloc;
-static void *default_realloc_ex(void *str, size_t num,
-        const char *file, int line)
-       { return realloc_func(str,num); }
-static void *(*realloc_ex_func)(void *, size_t, const char *file, int line)
-        = default_realloc_ex;
-
-static void (*free_func)(void *)            = free;
-
-static void *(*malloc_locked_func)(size_t)  = malloc;
-static void *default_malloc_locked_ex(size_t num, const char *file, int line)
-       { return malloc_locked_func(num); }
-static void *(*malloc_locked_ex_func)(size_t, const char *file, int line)
-        = default_malloc_locked_ex;
-
-static void (*free_locked_func)(void *)     = free;
-
+static void *(*malloc_func)(size_t) = malloc;
+static void
+*default_malloc_ex(size_t num, const char *file, int line)
+{
+       return malloc_func(num);
+}
+static void *(*malloc_ex_func)(size_t, const char *file, int line) =
+    default_malloc_ex;
+
+static void *(*realloc_func)(void *, size_t) = realloc;
+static void
+*default_realloc_ex(void *str, size_t num, const char *file, int line)
+{
+       return realloc_func(str, num);
+}
+static void *(*realloc_ex_func)(void *, size_t, const char *file, int line) =
+    default_realloc_ex;
+
+static void (*free_func)(void *) = free;
+
+static void *(*malloc_locked_func)(size_t) = malloc;
+static void
+*default_malloc_locked_ex(size_t num, const char *file, int line)
+{
+       return malloc_locked_func(num);
+}
+static void *(*malloc_locked_ex_func)(size_t, const char *file, int line) =
+    default_malloc_locked_ex;
+
+static void (*free_locked_func)(void *) = free;
 
 
 /* may be changed as long as 'allow_customize_debug' is set */
 /* XXX use correct function pointer types */
 #ifdef CRYPTO_MDEBUG
 /* use default functions from mem_dbg.c */
-static void (*malloc_debug_func)(void *,int,const char *,int,int)
-       = CRYPTO_dbg_malloc;
-static void (*realloc_debug_func)(void *,void *,int,const char *,int,int)
-       = CRYPTO_dbg_realloc;
-static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free;
+static void (*malloc_debug_func)(void *, int, const char *, int, int) =
+    CRYPTO_dbg_malloc;
+static void (*realloc_debug_func)(void *, void *, int, const char *, int, int) =
+    CRYPTO_dbg_realloc;
+static void (*free_debug_func)(void *, int) = CRYPTO_dbg_free;
 static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options;
 static long (*get_debug_options_func)(void) = CRYPTO_dbg_get_options;
 #else
 /* applications can use CRYPTO_malloc_debug_init() to select above case
  * at run-time */
-static void (*malloc_debug_func)(void *,int,const char *,int,int) = NULL;
-static void (*realloc_debug_func)(void *,void *,int,const char *,int,int)
-       = NULL;
-static void (*free_debug_func)(void *,int) = NULL;
+static void (*malloc_debug_func)(void *, int, const char *, int, int) = NULL;
+static void (*realloc_debug_func)(void *, void *, int, const char *, int, int) =
+    NULL;
+static void (*free_debug_func)(void *, int) = NULL;
 static void (*set_debug_options_func)(long) = NULL;
 static long (*get_debug_options_func)(void) = NULL;
 #endif
 
-int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t),
-       void (*f)(void *))
-       {
+int
+CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t),
+    void (*f)(void *))
+{
        /* Dummy call just to ensure OPENSSL_init() gets linked in */
        OPENSSL_init();
        if (!allow_customize)
                return 0;
        if ((m == 0) || (r == 0) || (f == 0))
                return 0;
-       malloc_func=m; malloc_ex_func=default_malloc_ex;
-       realloc_func=r; realloc_ex_func=default_realloc_ex;
-       free_func=f;
-       malloc_locked_func=m; malloc_locked_ex_func=default_malloc_locked_ex;
-       free_locked_func=f;
+       malloc_func = m;
+       malloc_ex_func = default_malloc_ex;
+       realloc_func = r;
+       realloc_ex_func = default_realloc_ex;
+       free_func = f;
+       malloc_locked_func = m;
+       malloc_locked_ex_func = default_malloc_locked_ex;
+       free_locked_func = f;
        return 1;
-       }
+}
 
-int CRYPTO_set_mem_ex_functions(
-        void *(*m)(size_t,const char *,int),
-        void *(*r)(void *, size_t,const char *,int),
-       void (*f)(void *))
-       {
+int
+CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int),
+    void *(*r)(void *, size_t, const char *, int), void (*f)(void *))
+{
        if (!allow_customize)
                return 0;
        if ((m == 0) || (r == 0) || (f == 0))
                return 0;
-       malloc_func=0; malloc_ex_func=m;
-       realloc_func=0; realloc_ex_func=r;
-       free_func=f;
-       malloc_locked_func=0; malloc_locked_ex_func=m;
-       free_locked_func=f;
+       malloc_func = 0;
+       malloc_ex_func = m;
+       realloc_func = 0;
+       realloc_ex_func = r;
+       free_func = f;
+       malloc_locked_func = 0;
+       malloc_locked_ex_func = m;
+       free_locked_func = f;
        return 1;
-       }
+}
 
-int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *))
-       {
+int
+CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *))
+{
        if (!allow_customize)
                return 0;
        if ((m == NULL) || (f == NULL))
                return 0;
-       malloc_locked_func=m; malloc_locked_ex_func=default_malloc_locked_ex;
-       free_locked_func=f;
+       malloc_locked_func = m;
+       malloc_locked_ex_func = default_malloc_locked_ex;
+       free_locked_func = f;
        return 1;
-       }
+}
 
-int CRYPTO_set_locked_mem_ex_functions(
-        void *(*m)(size_t,const char *,int),
-        void (*f)(void *))
-       {
+int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int),
+    void (*f)(void *))
+{
        if (!allow_customize)
                return 0;
        if ((m == NULL) || (f == NULL))
                return 0;
-       malloc_locked_func=0; malloc_locked_ex_func=m;
-       free_func=f;
+       malloc_locked_func = 0;
+       malloc_locked_ex_func = m;
+       free_func = f;
        return 1;
-       }
+}
 
-int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
-                                  void (*r)(void *,void *,int,const char *,int,int),
-                                  void (*f)(void *,int),
-                                  void (*so)(long),
-                                  long (*go)(void))
-       {
+int
+CRYPTO_set_mem_debug_functions(void (*m)(void *, int, const char *, int, int),
+    void (*r)(void *, void *, int, const char *, int, int),
+    void (*f)(void *, int), void (*so)(long), long (*go)(void))
+{
        if (!allow_customize_debug)
                return 0;
        OPENSSL_init();
-       malloc_debug_func=m;
-       realloc_debug_func=r;
-       free_debug_func=f;
-       set_debug_options_func=so;
-       get_debug_options_func=go;
+       malloc_debug_func = m;
+       realloc_debug_func = r;
+       free_debug_func = f;
+       set_debug_options_func = so;
+       get_debug_options_func = go;
        return 1;
-       }
-
-
-void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
-       void (**f)(void *))
-       {
-       if (m != NULL) *m = (malloc_ex_func == default_malloc_ex) ? 
-                            malloc_func : 0;
-       if (r != NULL) *r = (realloc_ex_func == default_realloc_ex) ? 
-                            realloc_func : 0;
-       if (f != NULL) *f=free_func;
-       }
-
-void CRYPTO_get_mem_ex_functions(
-        void *(**m)(size_t,const char *,int),
-        void *(**r)(void *, size_t,const char *,int),
-       void (**f)(void *))
-       {
-       if (m != NULL) *m = (malloc_ex_func != default_malloc_ex) ?
-                           malloc_ex_func : 0;
-       if (r != NULL) *r = (realloc_ex_func != default_realloc_ex) ?
-                           realloc_ex_func : 0;
-       if (f != NULL) *f=free_func;
-       }
-
-void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *))
-       {
-       if (m != NULL) *m = (malloc_locked_ex_func == default_malloc_locked_ex) ? 
-                            malloc_locked_func : 0;
-       if (f != NULL) *f=free_locked_func;
-       }
-
-void CRYPTO_get_locked_mem_ex_functions(
-        void *(**m)(size_t,const char *,int),
-        void (**f)(void *))
-       {
-       if (m != NULL) *m = (malloc_locked_ex_func != default_malloc_locked_ex) ?
-                           malloc_locked_ex_func : 0;
-       if (f != NULL) *f=free_locked_func;
-       }
-
-void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
-                                   void (**r)(void *,void *,int,const char *,int,int),
-                                   void (**f)(void *,int),
-                                   void (**so)(long),
-                                   long (**go)(void))
-       {
-       if (m != NULL) *m=malloc_debug_func;
-       if (r != NULL) *r=realloc_debug_func;
-       if (f != NULL) *f=free_debug_func;
-       if (so != NULL) *so=set_debug_options_func;
-       if (go != NULL) *go=get_debug_options_func;
-       }
-
-
-void *CRYPTO_malloc_locked(int num, const char *file, int line)
-       {
+}
+
+
+void
+CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
+    void (**f)(void *))
+{
+       if (m != NULL)
+               *m = (malloc_ex_func == default_malloc_ex) ? malloc_func : 0;
+       if (r != NULL)
+               *r = (realloc_ex_func == default_realloc_ex) ? realloc_func : 0;
+       if (f != NULL)
+               *f = free_func;
+}
+
+void CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int),
+    void *(**r)(void *, size_t, const char *, int), void (**f)(void *))
+{
+       if (m != NULL)
+               *m = (malloc_ex_func != default_malloc_ex) ? malloc_ex_func : 0;
+       if (r != NULL)
+               *r = (realloc_ex_func != default_realloc_ex) ?
+                   realloc_ex_func : 0;
+       if (f != NULL)
+               *f = free_func;
+}
+
+void
+CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *))
+{
+       if (m != NULL)
+               *m = (malloc_locked_ex_func == default_malloc_locked_ex) ?
+                   malloc_locked_func : 0;
+       if (f != NULL)
+               *f = free_locked_func;
+}
+
+void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int),
+    void (**f)(void *))
+{
+       if (m != NULL)
+               *m = (malloc_locked_ex_func != default_malloc_locked_ex) ?
+                   malloc_locked_ex_func : 0;
+       if (f != NULL)
+               *f = free_locked_func;
+}
+
+void
+CRYPTO_get_mem_debug_functions(void (**m)(void *, int, const char *, int, int),
+    void (**r)(void *, void *, int, const char *, int, int),
+    void (**f)(void *, int), void (**so)(long), long (**go)(void))
+{
+       if (m != NULL)
+               *m = malloc_debug_func;
+       if (r != NULL)
+               *r = realloc_debug_func;
+       if (f != NULL)
+               *f = free_debug_func;
+       if (so != NULL)
+               *so = set_debug_options_func;
+       if (go != NULL)
+               *go = get_debug_options_func;
+}
+
+
+void
+*CRYPTO_malloc_locked(int num, const char *file, int line)
+{
        void *ret = NULL;
 
-       if (num <= 0) return NULL;
+       if (num <= 0)
+               return NULL;
 
        allow_customize = 0;
-       if (malloc_debug_func != NULL)
-               {
+       if (malloc_debug_func != NULL) {
                allow_customize_debug = 0;
                malloc_debug_func(NULL, num, file, line, 0);
-               }
-       ret = malloc_locked_ex_func(num,file,line);
+       }
+       ret = malloc_locked_ex_func(num, file, line);
 #ifdef LEVITTE_DEBUG_MEM
        fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);
 #endif
@@ -272,17 +296,18 @@ void *CRYPTO_malloc_locked(int num, const char *file, int line)
         /* Create a dependency on the value of 'cleanse_ctr' so our memory
          * sanitisation function can't be optimised out. NB: We only do
          * this for >2Kb so the overhead doesn't bother us. */
-        if(ret && (num > 2048))
-       {       extern unsigned char cleanse_ctr;
+       if (ret && (num > 2048)) {
+               extern unsigned char cleanse_ctr;
                ((unsigned char *)ret)[0] = cleanse_ctr;
        }
 #endif
 
        return ret;
-       }
+}
 
-void CRYPTO_free_locked(void *str)
-       {
+void
+CRYPTO_free_locked(void *str)
+{
        if (free_debug_func != NULL)
                free_debug_func(str, 0);
 #ifdef LEVITTE_DEBUG_MEM
@@ -291,21 +316,22 @@ void CRYPTO_free_locked(void *str)
        free_locked_func(str);
        if (free_debug_func != NULL)
                free_debug_func(NULL, 1);
-       }
+}
 
-void *CRYPTO_malloc(int num, const char *file, int line)
-       {
+void
+*CRYPTO_malloc(int num, const char *file, int line)
+{
        void *ret = NULL;
 
-       if (num <= 0) return NULL;
+       if (num <= 0)
+               return NULL;
 
        allow_customize = 0;
-       if (malloc_debug_func != NULL)
-               {
+       if (malloc_debug_func != NULL) {
                allow_customize_debug = 0;
                malloc_debug_func(NULL, num, file, line, 0);
-               }
-       ret = malloc_ex_func(num,file,line);
+       }
+       ret = malloc_ex_func(num, file, line);
 #ifdef LEVITTE_DEBUG_MEM
        fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);
 #endif
@@ -316,35 +342,39 @@ void *CRYPTO_malloc(int num, const char *file, int line)
         /* Create a dependency on the value of 'cleanse_ctr' so our memory
          * sanitisation function can't be optimised out. NB: We only do
          * this for >2Kb so the overhead doesn't bother us. */
-        if(ret && (num > 2048))
-       {       extern unsigned char cleanse_ctr;
-                ((unsigned char *)ret)[0] = cleanse_ctr;
+       if (ret && (num > 2048)) {
+               extern unsigned char cleanse_ctr;
+               ((unsigned char *)ret)[0] = cleanse_ctr;
        }
 #endif
 
        return ret;
-       }
-char *CRYPTO_strdup(const char *str, const char *file, int line)
-       {
-       size_t len = strlen(str)+1;
+}
+
+char
+*CRYPTO_strdup(const char *str, const char *file, int line)
+{
+       size_t len = strlen(str) + 1;
        char *ret = CRYPTO_malloc(len, file, line);
 
        memcpy(ret, str, len);
        return ret;
-       }
+}
 
-void *CRYPTO_realloc(void *str, int num, const char *file, int line)
-       {
+void
+*CRYPTO_realloc(void *str, int num, const char *file, int line)
+{
        void *ret = NULL;
 
        if (str == NULL)
                return CRYPTO_malloc(num, file, line);
 
-       if (num <= 0) return NULL;
+       if (num <= 0)
+               return NULL;
 
        if (realloc_debug_func != NULL)
                realloc_debug_func(str, NULL, num, file, line, 0);
-       ret = realloc_ex_func(str,num,file,line);
+       ret = realloc_ex_func(str, num, file, line);
 #ifdef LEVITTE_DEBUG_MEM
        fprintf(stderr, "LEVITTE_DEBUG_MEM:         | 0x%p -> 0x%p (%d)\n", str, ret, num);
 #endif
@@ -352,44 +382,47 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line)
                realloc_debug_func(str, ret, num, file, line, 1);
 
        return ret;
-       }
+}
 
-void *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
-                          int line)
-       {
+void
+*CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
+int line)
+{
        void *ret = NULL;
 
        if (str == NULL)
                return CRYPTO_malloc(num, file, line);
 
-       if (num <= 0) return NULL;
+       if (num <= 0)
+               return NULL;
 
        /* We don't support shrinking the buffer. Note the memcpy that copies
         * |old_len| bytes to the new buffer, below. */
-       if (num < old_len) return NULL;
+       if (num < old_len)
+               return NULL;
 
        if (realloc_debug_func != NULL)
                realloc_debug_func(str, NULL, num, file, line, 0);
-       ret=malloc_ex_func(num,file,line);
-       if(ret)
-               {
-               memcpy(ret,str,old_len);
-               OPENSSL_cleanse(str,old_len);
+       ret = malloc_ex_func(num, file, line);
+       if (ret) {
+               memcpy(ret, str, old_len);
+               OPENSSL_cleanse(str, old_len);
                free_func(str);
-               }
+       }
 #ifdef LEVITTE_DEBUG_MEM
        fprintf(stderr,
-               "LEVITTE_DEBUG_MEM:         | 0x%p -> 0x%p (%d)\n",
-               str, ret, num);
+           "LEVITTE_DEBUG_MEM:         | 0x%p -> 0x%p (%d)\n",
+           str, ret, num);
 #endif
        if (realloc_debug_func != NULL)
                realloc_debug_func(str, ret, num, file, line, 1);
 
        return ret;
-       }
+}
 
-void CRYPTO_free(void *str)
-       {
+void
+CRYPTO_free(void *str)
+{
        if (free_debug_func != NULL)
                free_debug_func(str, 0);
 #ifdef LEVITTE_DEBUG_MEM
@@ -398,24 +431,28 @@ void CRYPTO_free(void *str)
        free_func(str);
        if (free_debug_func != NULL)
                free_debug_func(NULL, 1);
-       }
-
-void *CRYPTO_remalloc(void *a, int num, const char *file, int line)
-       {
-       if (a != NULL) OPENSSL_free(a);
-       a=(char *)OPENSSL_malloc(num);
-       return(a);
-       }
-
-void CRYPTO_set_mem_debug_options(long bits)
-       {
+}
+
+void
+*CRYPTO_remalloc(void *a, int num, const char *file, int line)
+{
+       if (a != NULL)
+               OPENSSL_free(a);
+       a = (char *)OPENSSL_malloc(num);
+       return (a);
+}
+
+void
+CRYPTO_set_mem_debug_options(long bits)
+{
        if (set_debug_options_func != NULL)
                set_debug_options_func(bits);
-       }
+}
 
-long CRYPTO_get_mem_debug_options(void)
-       {
+long
+CRYPTO_get_mem_debug_options(void)
+{
        if (get_debug_options_func != NULL)
                return get_debug_options_func();
        return 0;
-       }
+}
index add1f78..fc108c8 100644 (file)
 
 unsigned char cleanse_ctr = 0;
 
-void OPENSSL_cleanse(void *ptr, size_t len)
-       {
+void
+OPENSSL_cleanse(void *ptr, size_t len)
+{
        unsigned char *p = ptr;
        size_t loop = len, ctr = cleanse_ctr;
-       while(loop--)
-               {
+       while (loop--) {
                *(p++) = (unsigned char)ctr;
                ctr += (17 + ((size_t)p & 0xF));
-               }
-       p=memchr(ptr, (unsigned char)ctr, len);
-       if(p)
+       }
+       p = memchr(ptr, (unsigned char)ctr, len);
+       if (p)
                ctr += (63 + (size_t)p);
        cleanse_ctr = (unsigned char)ctr;
-       }
+}
index ac79339..9324ec4 100644 (file)
 #include <openssl/bio.h>
 #include <openssl/lhash.h>
 
-static int mh_mode=CRYPTO_MEM_CHECK_OFF;
+static int mh_mode = CRYPTO_MEM_CHECK_OFF;
 /* The state changes to CRYPTO_MEM_CHECK_ON | CRYPTO_MEM_CHECK_ENABLE
  * when the application asks for it (usually after library initialisation
  * for which no book-keeping is desired).
@@ -136,10 +136,9 @@ static int mh_mode=CRYPTO_MEM_CHECK_OFF;
 static unsigned long order = 0; /* number of memory requests */
 
 DECLARE_LHASH_OF(MEM);
-static LHASH_OF(MEM) *mh=NULL; /* hash-table of memory requests
-                               * (address as key); access requires
-                               * MALLOC2 lock */
-
+static LHASH_OF(MEM) *mh = NULL; /* hash - table of memory requests
+                                 * (address as key); access requires
+                                 * MALLOC2 lock */
 
 typedef struct app_mem_info_st
 /* For application-defined information (static C-string `info')
@@ -149,28 +148,28 @@ typedef struct app_mem_info_st
  *   CRYPTO_pop_info()           to pop an entry,
  *   CRYPTO_remove_all_info()    to pop all entries.
  */
-       {
+{
        CRYPTO_THREADID threadid;
        const char *file;
        int line;
        const char *info;
        struct app_mem_info_st *next; /* tail of thread's stack */
        int references;
-       } APP_INFO;
+} APP_INFO;
 
 static void app_info_free(APP_INFO *);
 
 DECLARE_LHASH_OF(APP_INFO);
-static LHASH_OF(APP_INFO) *amih=NULL; /* hash-table with those
-                                      * app_mem_info_st's that are at
-                                      * the top of their thread's
-                                      * stack (with `thread' as key);
-                                      * access requires MALLOC2
-                                      * lock */
+static LHASH_OF(APP_INFO) *amih = NULL; /* hash - table with those
+                                        * app_mem_info_st's that are at
+                                        * the top of their thread's
+                                        * stack (with `thread' as key);
+                                        * access requires MALLOC2
+                                        * lock */
 
 typedef struct mem_st
 /* memory-block description */
-       {
+{
        void *addr;
        int num;
        const char *file;
@@ -179,47 +178,46 @@ typedef struct mem_st
        unsigned long order;
        time_t time;
        APP_INFO *app_info;
-       } MEM;
+} MEM;
 
 static long options =             /* extra information to be recorded */
 #if defined(CRYPTO_MDEBUG_TIME) || defined(CRYPTO_MDEBUG_ALL)
-       V_CRYPTO_MDEBUG_TIME |
+V_CRYPTO_MDEBUG_TIME |
 #endif
 #if defined(CRYPTO_MDEBUG_THREAD) || defined(CRYPTO_MDEBUG_ALL)
-       V_CRYPTO_MDEBUG_THREAD |
+V_CRYPTO_MDEBUG_THREAD |
 #endif
-       0;
+0;
 
 
 static unsigned int num_disable = 0; /* num_disable > 0
-                                      *     iff
-                                      * mh_mode == CRYPTO_MEM_CHECK_ON (w/o ..._ENABLE)
-                                      */
+                                     *     iff
+                                     * mh_mode == CRYPTO_MEM_CHECK_ON (w/o ..._ENABLE)
+                                     */
 
 /* Valid iff num_disable > 0.  CRYPTO_LOCK_MALLOC2 is locked exactly in this
  * case (by the thread named in disabling_thread).
  */
 static CRYPTO_THREADID disabling_threadid;
 
-static void app_info_free(APP_INFO *inf)
-       {
-       if (--(inf->references) <= 0)
-               {
-               if (inf->next != NULL)
-                       {
+static void
+app_info_free(APP_INFO *inf)
+{
+       if (--(inf->references) <= 0) {
+               if (inf->next != NULL) {
                        app_info_free(inf->next);
-                       }
-               OPENSSL_free(inf);
                }
+               OPENSSL_free(inf);
        }
+}
 
-int CRYPTO_mem_ctrl(int mode)
-       {
-       int ret=mh_mode;
+int
+CRYPTO_mem_ctrl(int mode)
+{
+       int ret = mh_mode;
 
        CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
-       switch (mode)
-               {
+       switch (mode) {
        /* for applications (not to be called while multiple threads
         * use the library): */
        case CRYPTO_MEM_CHECK_ON: /* aka MemCheck_start() */
@@ -232,14 +230,13 @@ int CRYPTO_mem_ctrl(int mode)
                                    or there'll be a lot of confusion */
                break;
 
-       /* switch off temporarily (for library-internal use): */
+               /* switch off temporarily (for library-internal use): */
        case CRYPTO_MEM_CHECK_DISABLE: /* aka MemCheck_off() */
-               if (mh_mode & CRYPTO_MEM_CHECK_ON)
-                       {
+               if (mh_mode & CRYPTO_MEM_CHECK_ON) {
                        CRYPTO_THREADID cur;
                        CRYPTO_THREADID_current(&cur);
                        if (!num_disable || CRYPTO_THREADID_cmp(&disabling_threadid, &cur)) /* otherwise we already have the MALLOC2 lock */
-                               {
+                       {
                                /* Long-time lock CRYPTO_LOCK_MALLOC2 must not be claimed while
                                 * we're holding CRYPTO_LOCK_MALLOC, or we'll deadlock if
                                 * somebody else holds CRYPTO_LOCK_MALLOC2 (and cannot release
@@ -257,412 +254,402 @@ int CRYPTO_mem_ctrl(int mode)
                                CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
                                mh_mode &= ~CRYPTO_MEM_CHECK_ENABLE;
                                CRYPTO_THREADID_cpy(&disabling_threadid, &cur);
-                               }
-                       num_disable++;
                        }
+                       num_disable++;
+               }
                break;
        case CRYPTO_MEM_CHECK_ENABLE: /* aka MemCheck_on() */
-               if (mh_mode & CRYPTO_MEM_CHECK_ON)
-                       {
+               if (mh_mode & CRYPTO_MEM_CHECK_ON) {
                        if (num_disable) /* always true, or something is going wrong */
-                               {
+                       {
                                num_disable--;
-                               if (num_disable == 0)
-                                       {
+                               if (num_disable == 0) {
                                        mh_mode|=CRYPTO_MEM_CHECK_ENABLE;
                                        CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
-                                       }
                                }
                        }
+               }
                break;
 
        default:
                break;
-               }
-       CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
-       return(ret);
        }
+       CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
+       return (ret);
+}
 
-int CRYPTO_is_mem_check_on(void)
-       {
+int
+CRYPTO_is_mem_check_on(void)
+{
        int ret = 0;
 
-       if (mh_mode & CRYPTO_MEM_CHECK_ON)
-               {
+       if (mh_mode & CRYPTO_MEM_CHECK_ON) {
                CRYPTO_THREADID cur;
                CRYPTO_THREADID_current(&cur);
                CRYPTO_r_lock(CRYPTO_LOCK_MALLOC);
 
-               ret = (mh_mode & CRYPTO_MEM_CHECK_ENABLE)
-                       || CRYPTO_THREADID_cmp(&disabling_threadid, &cur);
+               ret = (mh_mode & CRYPTO_MEM_CHECK_ENABLE) ||
+                   CRYPTO_THREADID_cmp(&disabling_threadid, &cur);
 
                CRYPTO_r_unlock(CRYPTO_LOCK_MALLOC);
-               }
-       return(ret);
-       }       
+       }
+       return (ret);
+}
 
 
-void CRYPTO_dbg_set_options(long bits)
-       {
+void
+CRYPTO_dbg_set_options(long bits)
+{
        options = bits;
-       }
+}
 
-long CRYPTO_dbg_get_options(void)
-       {
+long
+CRYPTO_dbg_get_options(void)
+{
        return options;
-       }
+}
 
-static int mem_cmp(const MEM *a, const MEM *b)
-       {
+static int
+mem_cmp(const MEM *a, const MEM *b)
+{
 #ifdef _WIN64
-       const char *ap=(const char *)a->addr,
-                  *bp=(const char *)b->addr;
-       if (ap==bp)     return 0;
-       else if (ap>bp) return 1;
-       else            return -1;
+       const char *ap = (const char *)a->addr,
+       *bp = (const char *)b->addr;
+       if (ap == bp)
+               return 0;
+       else if (ap > bp)       return 1;
+               else            return -1;
 #else
        return (const char *)a->addr - (const char *)b->addr;
 #endif
-       }
+}
+
 static IMPLEMENT_LHASH_COMP_FN(mem, MEM)
 
-static unsigned long mem_hash(const MEM *a)
-       {
+static unsigned long
+mem_hash(const MEM *a)
+{
        unsigned long ret;
 
-       ret=(unsigned long)a->addr;
+       ret = (unsigned long)a->addr;
 
-       ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
-       return(ret);
-       }
-static IMPLEMENT_LHASH_HASH_FN(mem, MEM)
+       ret = ret * 17851 + (ret >> 14) * 7 + (ret >> 4) * 251;
+       return (ret);
+}
+
+static
+IMPLEMENT_LHASH_HASH_FN(mem, MEM)
 
 /* static int app_info_cmp(APP_INFO *a, APP_INFO *b) */
-static int app_info_cmp(const void *a_void, const void *b_void)
-       {
+static int
+app_info_cmp(const void *a_void, const void *b_void)
+{
        return CRYPTO_THREADID_cmp(&((const APP_INFO *)a_void)->threadid,
-                               &((const APP_INFO *)b_void)->threadid);
-       }
+           &((const APP_INFO *)b_void)->threadid);
+}
+
 static IMPLEMENT_LHASH_COMP_FN(app_info, APP_INFO)
 
-static unsigned long app_info_hash(const APP_INFO *a)
-       {
+static unsigned long
+app_info_hash(const APP_INFO *a)
+{
        unsigned long ret;
 
        ret = CRYPTO_THREADID_hash(&a->threadid);
        /* This is left in as a "who am I to question legacy?" measure */
-       ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
-       return(ret);
-       }
+       ret = ret * 17851 + (ret >> 14) * 7 + (ret >> 4) * 251;
+       return (ret);
+}
+
 static IMPLEMENT_LHASH_HASH_FN(app_info, APP_INFO)
 
-static APP_INFO *pop_info(void)
-       {
+static APP_INFO
+*pop_info(void)
+{
        APP_INFO tmp;
        APP_INFO *ret = NULL;
 
-       if (amih != NULL)
-               {
+       if (amih != NULL) {
                CRYPTO_THREADID_current(&tmp.threadid);
-               if ((ret=lh_APP_INFO_delete(amih,&tmp)) != NULL)
-                       {
-                       APP_INFO *next=ret->next;
+               if ((ret = lh_APP_INFO_delete(amih, &tmp)) != NULL) {
+                       APP_INFO *next = ret->next;
 
-                       if (next != NULL)
-                               {
+                       if (next != NULL) {
                                next->references++;
-                               (void)lh_APP_INFO_insert(amih,next);
-                               }
+                               (void)lh_APP_INFO_insert(amih, next);
+                       }
 #ifdef LEVITTE_DEBUG_MEM
-                       if (CRYPTO_THREADID_cmp(&ret->threadid, &tmp.threadid))
-                               {
+                       if (CRYPTO_THREADID_cmp(&ret->threadid, &tmp.threadid)) {
                                fprintf(stderr, "pop_info(): deleted info has other thread ID (%lu) than the current thread (%lu)!!!!\n",
-                                       CRYPTO_THREADID_hash(&ret->threadid),
-                                       CRYPTO_THREADID_hash(&tmp.threadid));
+                               CRYPTO_THREADID_hash(&ret->threadid),
+                               CRYPTO_THREADID_hash(&tmp.threadid));
                                abort();
-                               }
+                       }
 #endif
-                       if (--(ret->references) <= 0)
-                               {
+                       if (--(ret->references) <= 0) {
                                ret->next = NULL;
                                if (next != NULL)
                                        next->references--;
                                OPENSSL_free(ret);
-                               }
                        }
                }
-       return(ret);
        }
+       return (ret);
+}
 
-int CRYPTO_push_info_(const char *info, const char *file, int line)
-       {
+int
+CRYPTO_push_info_(const char *info, const char *file, int line)
+{
        APP_INFO *ami, *amim;
-       int ret=0;
+       int ret = 0;
 
-       if (is_MemCheck_on())
-               {
+       if (is_MemCheck_on()) {
                MemCheck_off(); /* obtain MALLOC2 lock */
 
-               if ((ami = (APP_INFO *)OPENSSL_malloc(sizeof(APP_INFO))) == NULL)
-                       {
-                       ret=0;
+               if ((ami = (APP_INFO *)OPENSSL_malloc(sizeof(APP_INFO))) == NULL) {
+                       ret = 0;
                        goto err;
-                       }
-               if (amih == NULL)
-                       {
-                       if ((amih=lh_APP_INFO_new()) == NULL)
-                               {
+               }
+               if (amih == NULL) {
+                       if ((amih = lh_APP_INFO_new()) == NULL) {
                                OPENSSL_free(ami);
-                               ret=0;
+                               ret = 0;
                                goto err;
-                               }
                        }
+               }
 
                CRYPTO_THREADID_current(&ami->threadid);
-               ami->file=file;
-               ami->line=line;
-               ami->info=info;
-               ami->references=1;
-               ami->next=NULL;
+               ami->file = file;
+               ami->line = line;
+               ami->info = info;
+               ami->references = 1;
+               ami->next = NULL;
 
-               if ((amim=lh_APP_INFO_insert(amih,ami)) != NULL)
-                       {
+               if ((amim = lh_APP_INFO_insert(amih, ami)) != NULL) {
 #ifdef LEVITTE_DEBUG_MEM
-                       if (CRYPTO_THREADID_cmp(&ami->threadid, &amim->threadid))
-                               {
+                       if (CRYPTO_THREADID_cmp(&ami->threadid, &amim->threadid)) {
                                fprintf(stderr, "CRYPTO_push_info(): previous info has other thread ID (%lu) than the current thread (%lu)!!!!\n",
-                                       CRYPTO_THREADID_hash(&amim->threadid),
-                                       CRYPTO_THREADID_hash(&ami->threadid));
+                               CRYPTO_THREADID_hash(&amim->threadid),
+                               CRYPTO_THREADID_hash(&ami->threadid));
                                abort();
-                               }
-#endif
-                       ami->next=amim;
                        }
- err:
-               MemCheck_on(); /* release MALLOC2 lock */
+#endif
+                       ami->next = amim;
                }
-
-       return(ret);
+               err:
+               MemCheck_on(); /* release MALLOC2 lock */
        }
 
-int CRYPTO_pop_info(void)
-       {
-       int ret=0;
+       return (ret);
+}
+
+int
+CRYPTO_pop_info(void)
+{
+       int ret = 0;
 
        if (is_MemCheck_on()) /* _must_ be true, or something went severely wrong */
-               {
+       {
                MemCheck_off(); /* obtain MALLOC2 lock */
 
-               ret=(pop_info() != NULL);
+               ret = (pop_info() != NULL);
 
                MemCheck_on(); /* release MALLOC2 lock */
-               }
-       return(ret);
        }
+       return (ret);
+}
 
-int CRYPTO_remove_all_info(void)
-       {
-       int ret=0;
+int
+CRYPTO_remove_all_info(void)
+{
+       int ret = 0;
 
        if (is_MemCheck_on()) /* _must_ be true */
-               {
+       {
                MemCheck_off(); /* obtain MALLOC2 lock */
 
-               while(pop_info() != NULL)
-                       ret++;
+               while (pop_info() != NULL)
+               ret++;
 
                MemCheck_on(); /* release MALLOC2 lock */
-               }
-       return(ret);
        }
+       return (ret);
+}
 
 
-static unsigned long break_order_num=0;
-void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
-       int before_p)
-       {
-       MEM *m,*mm;
-       APP_INFO tmp,*amim;
+static unsigned long break_order_num = 0;
+void
+CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
+    int before_p)
+{
+       MEM *m, *mm;
+       APP_INFO tmp, *amim;
 
-       switch(before_p & 127)
-               {
+       switch (before_p & 127) {
        case 0:
                break;
        case 1:
                if (addr == NULL)
                        break;
 
-               if (is_MemCheck_on())
-                       {
+               if (is_MemCheck_on()) {
                        MemCheck_off(); /* make sure we hold MALLOC2 lock */
-                       if ((m=(MEM *)OPENSSL_malloc(sizeof(MEM))) == NULL)
-                               {
+                       if ((m = (MEM *)OPENSSL_malloc(sizeof(MEM))) == NULL) {
                                OPENSSL_free(addr);
                                MemCheck_on(); /* release MALLOC2 lock
                                                * if num_disabled drops to 0 */
                                return;
-                               }
-                       if (mh == NULL)
-                               {
-                               if ((mh=lh_MEM_new()) == NULL)
-                                       {
+                       }
+                       if (mh == NULL) {
+                               if ((mh = lh_MEM_new()) == NULL) {
                                        OPENSSL_free(addr);
                                        OPENSSL_free(m);
-                                       addr=NULL;
+                                       addr = NULL;
                                        goto err;
-                                       }
                                }
+                       }
 
-                       m->addr=addr;
-                       m->file=file;
-                       m->line=line;
-                       m->num=num;
+                       m->addr = addr;
+                       m->file = file;
+                       m->line = line;
+                       m->num = num;
                        if (options & V_CRYPTO_MDEBUG_THREAD)
                                CRYPTO_THREADID_current(&m->threadid);
                        else
                                memset(&m->threadid, 0, sizeof(m->threadid));
 
-                       if (order == break_order_num)
-                               {
+                       if (order == break_order_num) {
                                /* BREAK HERE */
-                               m->order=order;
-                               }
-                       m->order=order++;
+                               m->order = order;
+                       }
+                       m->order = order++;
 #ifdef LEVITTE_DEBUG_MEM
                        fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] %c 0x%p (%d)\n",
-                               m->order,
-                               (before_p & 128) ? '*' : '+',
-                               m->addr, m->num);
+                           m->order,
+                           (before_p & 128) ? '*' : '+',
+                           m->addr, m->num);
 #endif
                        if (options & V_CRYPTO_MDEBUG_TIME)
-                               m->time=time(NULL);
+                               m->time = time(NULL);
                        else
-                               m->time=0;
+                               m->time = 0;
 
                        CRYPTO_THREADID_current(&tmp.threadid);
-                       m->app_info=NULL;
-                       if (amih != NULL
-                           && (amim=lh_APP_INFO_retrieve(amih,&tmp)) != NULL)
-                               {
+                       m->app_info = NULL;
+                       if (amih != NULL &&
+                           (amim = lh_APP_INFO_retrieve(amih, &tmp)) != NULL) {
                                m->app_info = amim;
                                amim->references++;
-                               }
+                       }
 
-                       if ((mm=lh_MEM_insert(mh, m)) != NULL)
-                               {
+                       if ((mm = lh_MEM_insert(mh, m)) != NULL) {
                                /* Not good, but don't sweat it */
-                               if (mm->app_info != NULL)
-                                       {
+                               if (mm->app_info != NULL) {
                                        mm->app_info->references--;
-                                       }
-                               OPENSSL_free(mm);
                                }
-               err:
+                               OPENSSL_free(mm);
+                       }
+err:
                        MemCheck_on(); /* release MALLOC2 lock
                                        * if num_disabled drops to 0 */
-                       }
-               break;
                }
-       return;
+               break;
        }
+       return;
+}
 
-void CRYPTO_dbg_free(void *addr, int before_p)
-       {
-       MEM m,*mp;
+void
+CRYPTO_dbg_free(void *addr, int before_p)
+{
+       MEM m, *mp;
 
-       switch(before_p)
-               {
+       switch (before_p) {
        case 0:
                if (addr == NULL)
                        break;
 
-               if (is_MemCheck_on() && (mh != NULL))
-                       {
+               if (is_MemCheck_on() && (mh != NULL)) {
                        MemCheck_off(); /* make sure we hold MALLOC2 lock */
 
-                       m.addr=addr;
-                       mp=lh_MEM_delete(mh,&m);
-                       if (mp != NULL)
-                               {
+                       m.addr = addr;
+                       mp = lh_MEM_delete(mh, &m);
+                       if (mp != NULL) {
 #ifdef LEVITTE_DEBUG_MEM
-                       fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] - 0x%p (%d)\n",
+                               fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] - 0x%p (%d)\n",
                                mp->order, mp->addr, mp->num);
 #endif
                                if (mp->app_info != NULL)
                                        app_info_free(mp->app_info);
                                OPENSSL_free(mp);
-                               }
+                       }
 
                        MemCheck_on(); /* release MALLOC2 lock
                                        * if num_disabled drops to 0 */
-                       }
+               }
                break;
        case 1:
                break;
-               }
        }
+}
 
-void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
-       const char *file, int line, int before_p)
-       {
-       MEM m,*mp;
+void
+CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
+    const char *file, int line, int before_p)
+{
+       MEM m, *mp;
 
 #ifdef LEVITTE_DEBUG_MEM
        fprintf(stderr, "LEVITTE_DEBUG_MEM: --> CRYPTO_dbg_malloc(addr1 = %p, addr2 = %p, num = %d, file = \"%s\", line = %d, before_p = %d)\n",
-               addr1, addr2, num, file, line, before_p);
+       addr1, addr2, num, file, line, before_p);
 #endif
 
-       switch(before_p)
-               {
+       switch (before_p) {
        case 0:
                break;
        case 1:
                if (addr2 == NULL)
                        break;
 
-               if (addr1 == NULL)
-                       {
+               if (addr1 == NULL) {
                        CRYPTO_dbg_malloc(addr2, num, file, line, 128 | before_p);
                        break;
-                       }
+               }
 
-               if (is_MemCheck_on())
-                       {
+               if (is_MemCheck_on()) {
                        MemCheck_off(); /* make sure we hold MALLOC2 lock */
 
-                       m.addr=addr1;
-                       mp=lh_MEM_delete(mh,&m);
-                       if (mp != NULL)
-                               {
+                       m.addr = addr1;
+                       mp = lh_MEM_delete(mh, &m);
+                       if (mp != NULL) {
 #ifdef LEVITTE_DEBUG_MEM
                                fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] * 0x%p (%d) -> 0x%p (%d)\n",
-                                       mp->order,
-                                       mp->addr, mp->num,
-                                       addr2, num);
+                                   mp->order,
+                                   mp->addr, mp->num,
+                                   addr2, num);
 #endif
-                               mp->addr=addr2;
-                               mp->num=num;
-                               (void)lh_MEM_insert(mh,mp);
-                               }
+                               mp->addr = addr2;
+                               mp->num = num;
+                               (void)lh_MEM_insert(mh, mp);
+                       }
 
                        MemCheck_on(); /* release MALLOC2 lock
                                        * if num_disabled drops to 0 */
-                       }
-               break;
                }
-       return;
+               break;
        }
+       return;
+}
 
 
-typedef struct mem_leak_st
-       {
+typedef struct mem_leak_st {
        BIO *bio;
        int chunks;
        long bytes;
-       } MEM_LEAK;
+} MEM_LEAK;
 
-static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
-       {
+static void
+print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
+{
        char buf[1024];
        char *bufp = buf;
        APP_INFO *amip;
@@ -672,89 +659,83 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
 
 #define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
 
-       if(m->addr == (char *)l->bio)
-           return;
+       if (m->addr == (char *)l->bio)
+               return;
 
-       if (options & V_CRYPTO_MDEBUG_TIME)
-               {
+       if (options & V_CRYPTO_MDEBUG_TIME) {
                lcl = localtime(&m->time);
-       
+
                BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
-                       lcl->tm_hour,lcl->tm_min,lcl->tm_sec);
+               lcl->tm_hour, lcl->tm_min, lcl->tm_sec);
                bufp += strlen(bufp);
-               }
+       }
 
        BIO_snprintf(bufp, BUF_REMAIN, "%5lu file=%s, line=%d, ",
-               m->order,m->file,m->line);
+       m->order, m->file, m->line);
        bufp += strlen(bufp);
 
-       if (options & V_CRYPTO_MDEBUG_THREAD)
-               {
+       if (options & V_CRYPTO_MDEBUG_THREAD) {
                BIO_snprintf(bufp, BUF_REMAIN, "thread=%lu, ",
-                       CRYPTO_THREADID_hash(&m->threadid));
+               CRYPTO_THREADID_hash(&m->threadid));
                bufp += strlen(bufp);
-               }
+       }
 
        BIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%08lX\n",
-               m->num,(unsigned long)m->addr);
+       m->num,(unsigned long)m->addr);
        bufp += strlen(bufp);
 
-       BIO_puts(l->bio,buf);
-       
+       BIO_puts(l->bio, buf);
+
        l->chunks++;
-       l->bytes+=m->num;
+       l->bytes += m->num;
 
-       amip=m->app_info;
-       ami_cnt=0;
+       amip = m->app_info;
+       ami_cnt = 0;
        if (!amip)
                return;
        CRYPTO_THREADID_cpy(&ti, &amip->threadid);
 
-       do
-               {
+       do {
                int buf_len;
                int info_len;
 
                ami_cnt++;
-               memset(buf,'>',ami_cnt);
+               memset(buf, '>', ami_cnt);
                BIO_snprintf(buf + ami_cnt, sizeof buf - ami_cnt,
-                       " thread=%lu, file=%s, line=%d, info=\"",
-                       CRYPTO_THREADID_hash(&amip->threadid), amip->file,
-                       amip->line);
-               buf_len=strlen(buf);
-               info_len=strlen(amip->info);
-               if (128 - buf_len - 3 < info_len)
-                       {
+               " thread=%lu, file=%s, line=%d, info=\"",
+               CRYPTO_THREADID_hash(&amip->threadid), amip->file,
+               amip->line);
+               buf_len = strlen(buf);
+               info_len = strlen(amip->info);
+               if (128 - buf_len - 3 < info_len) {
                        memcpy(buf + buf_len, amip->info, 128 - buf_len - 3);
                        buf_len = 128 - 3;
-                       }
-               else
-                       {
+               } else {
                        BUF_strlcpy(buf + buf_len, amip->info,
-                                   sizeof buf - buf_len);
+                       sizeof buf - buf_len);
                        buf_len = strlen(buf);
-                       }
+               }
                BIO_snprintf(buf + buf_len, sizeof buf - buf_len, "\"\n");
-               
-               BIO_puts(l->bio,buf);
+
+               BIO_puts(l->bio, buf);
 
                amip = amip->next;
-               }
-       while(amip && !CRYPTO_THREADID_cmp(&amip->threadid, &ti));
+       } while (amip && !CRYPTO_THREADID_cmp(&amip->threadid, &ti));
 
 #ifdef LEVITTE_DEBUG_MEM
-       if (amip)
-               {
+       if (amip) {
                fprintf(stderr, "Thread switch detected in backtrace!!!!\n");
                abort();
-               }
-#endif
        }
+#endif
+}
 
-static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM, MEM_LEAK)
+static
+IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM, MEM_LEAK)
 
-void CRYPTO_mem_leaks(BIO *b)
-       {
+void
+CRYPTO_mem_leaks(BIO *b)
+{
        MEM_LEAK ml;
 
        if (mh == NULL && amih == NULL)
@@ -762,22 +743,19 @@ void CRYPTO_mem_leaks(BIO *b)
 
        MemCheck_off(); /* obtain MALLOC2 lock */
 
-       ml.bio=b;
-       ml.bytes=0;
-       ml.chunks=0;
+       ml.bio = b;
+       ml.bytes = 0;
+       ml.chunks = 0;
        if (mh != NULL)
-               lh_MEM_doall_arg(mh, LHASH_DOALL_ARG_FN(print_leak), MEM_LEAK,
-                                &ml);
-       if (ml.chunks != 0)
-               {
-               BIO_printf(b,"%ld bytes leaked in %d chunks\n",
-                          ml.bytes,ml.chunks);
+               lh_MEM_doall_arg(mh, LHASH_DOALL_ARG_FN(print_leak),
+                   MEM_LEAK, &ml);
+       if (ml.chunks != 0) {
+               BIO_printf(b, "%ld bytes leaked in %d chunks\n",
+               ml.bytes, ml.chunks);
 #ifdef CRYPTO_MDEBUG_ABORT
                abort();
 #endif
-               }
-       else
-               {
+       } else {
                /* Make sure that, if we found no leaks, memory-leak debugging itself
                 * does not introduce memory leaks (which might irritate
                 * external debugging tools).
@@ -802,43 +780,43 @@ void CRYPTO_mem_leaks(BIO *b)
                old_mh_mode = mh_mode;
                mh_mode = CRYPTO_MEM_CHECK_OFF;
 
-               if (mh != NULL)
-                       {
+               if (mh != NULL) {
                        lh_MEM_free(mh);
                        mh = NULL;
-                       }
-               if (amih != NULL)
-                       {
-                       if (lh_APP_INFO_num_items(amih) == 0) 
-                               {
+               }
+               if (amih != NULL) {
+                       if (lh_APP_INFO_num_items(amih) == 0) {
                                lh_APP_INFO_free(amih);
                                amih = NULL;
-                               }
                        }
+               }
 
                mh_mode = old_mh_mode;
                CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
-               }
-       MemCheck_on(); /* release MALLOC2 lock */
        }
+       MemCheck_on(); /* release MALLOC2 lock */
+}
 
 #ifndef OPENSSL_NO_FP_API
-void CRYPTO_mem_leaks_fp(FILE *fp)
-       {
+void
+CRYPTO_mem_leaks_fp(FILE *fp)
+{
        BIO *b;
 
-       if (mh == NULL) return;
+       if (mh == NULL)
+               return;
        /* Need to turn off memory checking when allocated BIOs ... especially
         * as we're creating them at a time when we're trying to check we've not
         * left anything un-free()'d!! */
        MemCheck_off();
        b = BIO_new(BIO_s_file());
        MemCheck_on();
-       if(!b) return;
-       BIO_set_fp(b,fp,BIO_NOCLOSE);
+       if (!b)
+               return;
+       BIO_set_fp(b, fp, BIO_NOCLOSE);
        CRYPTO_mem_leaks(b);
        BIO_free(b);
-       }
+}
 #endif
 
 
@@ -857,18 +835,21 @@ void CRYPTO_mem_leaks_fp(FILE *fp)
 
 typedef CRYPTO_MEM_LEAK_CB *PCRYPTO_MEM_LEAK_CB;
 
-static void cb_leak_doall_arg(const MEM *m, PCRYPTO_MEM_LEAK_CB *cb)
-       {
-       (*cb)(m->order,m->file,m->line,m->num,m->addr);
-       }
+static void
+cb_leak_doall_arg(const MEM *m, PCRYPTO_MEM_LEAK_CB *cb)
+{
+       (*cb)(m->order, m->file, m->line, m->num, m->addr);
+}
 
 static IMPLEMENT_LHASH_DOALL_ARG_FN(cb_leak, const MEM, PCRYPTO_MEM_LEAK_CB)
 
-void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb)
-       {
-       if (mh == NULL) return;
+void
+CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb)
+{
+       if (mh == NULL)
+               return;
        CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
        lh_MEM_doall_arg(mh, LHASH_DOALL_ARG_FN(cb_leak), PCRYPTO_MEM_LEAK_CB,
-                        &cb);
+       &cb);
        CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
-       }
+}
index 238717c..2973458 100644 (file)
 #error "No supported platform defined!"
 #endif
 
-int main()
+int
+main()
 {
-  OPENSSL_DIR_CTX *ctx = NULL;
-  const char *result;
+       OPENSSL_DIR_CTX *ctx = NULL;
+       const char *result;
 
-  while((result = OPENSSL_DIR_read(&ctx, CURRDIR)) != NULL)
-    {
-      printf("%s\n", result);
-    }
+       while ((result = OPENSSL_DIR_read(&ctx, CURRDIR)) != NULL) {
+               printf("%s\n", result);
+       }
 
-  if (errno)
-    {
-      perror("test_dir");
-      exit(1);
-    }
+       if (errno) {
+               perror("test_dir");
+               exit(1);
+       }
 
-  if (!OPENSSL_DIR_end(&ctx))
-    {
-      perror("test_dir");
-      exit(2);
-    }
-  exit(0);
+       if (!OPENSSL_DIR_end(&ctx)) {
+               perror("test_dir");
+               exit(2);
+       }
+       exit(0);
 }
index f6d1b21..9c185cf 100644 (file)
 #include <openssl/rand.h>
 #endif
 
-int FIPS_mode(void)
-       {
+int
+FIPS_mode(void)
+{
        OPENSSL_init();
 #ifdef OPENSSL_FIPS
        return FIPS_module_mode();
 #else
        return 0;
 #endif
-       }
+}
 
-int FIPS_mode_set(int r)
-       {
+int
+FIPS_mode_set(int r)
+{
        OPENSSL_init();
 #ifdef OPENSSL_FIPS
 #ifndef FIPS_AUTH_USER_PASS
@@ -92,5 +94,4 @@ int FIPS_mode_set(int r)
        CRYPTOerr(CRYPTO_F_FIPS_MODE_SET, CRYPTO_R_FIPS_MODE_NOT_SUPPORTED);
        return 0;
 #endif
-       }
-
+}
index db4cdc4..07c8e0d 100644 (file)
@@ -63,8 +63,9 @@
  * Currently only sets FIPS callbacks
  */
 
-void OPENSSL_init(void)
-       {
+void
+OPENSSL_init(void)
+{
        static int done = 0;
        if (done)
                return;
@@ -78,5 +79,4 @@ void OPENSSL_init(void)
 #if 0
        fprintf(stderr, "Called OPENSSL_init\n");
 #endif
-       }
-
+}
index 56104a6..c3ab1f8 100644 (file)
 # include <strings.h>
 #endif
 
-int OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n)
-       {
+int
+OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n)
+{
 #if defined(OPENSSL_IMPLEMENTS_strncasecmp)
-       while (*str1 && *str2 && n)
-               {
+       while (*str1 && *str2 && n) {
                int res = toupper(*str1) - toupper(*str2);
-               if (res) return res < 0 ? -1 : 1;
+               if (res)
+                       return res < 0 ? -1 : 1;
                str1++;
                str2++;
                n--;
-               }
+       }
        if (n == 0)
                return 0;
        if (*str1)
@@ -90,22 +91,25 @@ int OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n)
         * defined as well. */
        return strncasecmp(str1, str2, n);
 #endif
-       }
-int OPENSSL_strcasecmp(const char *str1, const char *str2)
-       {
+}
+
+int
+OPENSSL_strcasecmp(const char *str1, const char *str2)
+{
 #if defined(OPENSSL_IMPLEMENTS_strncasecmp)
-       return OPENSSL_strncasecmp(str1, str2, (size_t)-1);
+       return OPENSSL_strncasecmp(str1, str2, (size_t) - 1);
 #else
        return strcasecmp(str1, str2);
 #endif
-       }
+}
 
-int OPENSSL_memcmp(const void *v1,const void *v2,size_t n)
-       {
-       const unsigned char *c1=v1,*c2=v2;
-       int ret=0;
+int
+OPENSSL_memcmp(const void *v1, const void *v2, size_t n)
+{
+       const unsigned char *c1 = v1, *c2 = v2;
+       int ret = 0;
 
-       while(n && (ret=*c1-*c2)==0) n--,c1++,c2++;
+       while (n && (ret = *c1 - *c2) == 0) n--, c1++, c2++;
 
        return ret;
-       }
+}
index dfc9849..e2a3fde 100644 (file)
@@ -63,6 +63,6 @@
 
 int OPENSSL_strcasecmp(const char *str1, const char *str2);
 int OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n);
-int OPENSSL_memcmp(const void *p1,const void *p2,size_t n);
+int OPENSSL_memcmp(const void *p1, const void *p2, size_t n);
 
 #endif
index 5fb5d4e..44f7ba3 100644 (file)
 #include <string.h>
 #include "o_time.h"
 
-struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
-       {
+struct tm
+*OPENSSL_gmtime(const time_t *timer, struct tm *result) {
        struct tm *ts = NULL;
 
 #if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_OS2) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r)) && !defined(OPENSSL_SYS_MACOSX) && !defined(OPENSSL_SYS_SUNOS)
        /* should return &data, but doesn't on some systems,
           so we don't even look at the return value */
-       gmtime_r(timer,result);
+       gmtime_r(timer, result);
        ts = result;
 #else
        ts = gmtime(timer);
@@ -81,7 +81,7 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
        ts = result;
 #endif
        return ts;
-       }
+}
 
 /* Take a tm structure and add an offset to it. This avoids any OS issues
  * with restricted date types and overflows which cause the year 2038
@@ -93,29 +93,27 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
 static long date_to_julian(int y, int m, int d);
 static void julian_to_date(long jd, int *y, int *m, int *d);
 
-int OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec)
-       {
+int
+OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec)
+{
        int offset_hms, offset_day;
        long time_jd;
        int time_year, time_month, time_day;
        /* split offset into days and day seconds */
        offset_day = offset_sec / SECS_PER_DAY;
        /* Avoid sign issues with % operator */
-       offset_hms  = offset_sec - (offset_day * SECS_PER_DAY);
+       offset_hms = offset_sec - (offset_day * SECS_PER_DAY);
        offset_day += off_day;
        /* Add current time seconds to offset */
        offset_hms += tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec;
        /* Adjust day seconds if overflow */
-       if (offset_hms >= SECS_PER_DAY)
-               {
+       if (offset_hms >= SECS_PER_DAY) {
                offset_day++;
                offset_hms -= SECS_PER_DAY;
-               }
-       else if (offset_hms < 0)
-               {
+       } else if (offset_hms < 0) {
                offset_day--;
                offset_hms += SECS_PER_DAY;
-               }
+       }
 
        /* Convert date of time structure into a Julian day number.
         */
@@ -150,22 +148,24 @@ int OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec)
        tm->tm_sec = offset_hms % 60;
 
        return 1;
-               
+
 }
 
 /* Convert date to and from julian day
  * Uses Fliegel & Van Flandern algorithm
  */
-static long date_to_julian(int y, int m, int d)
+static long
+date_to_julian(int y, int m, int d)
 {
        return (1461 * (y + 4800 + (m - 14) / 12)) / 4 +
-               (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 -
-               (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 +
-               d - 32075;
+           (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 -
+           (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 +
+           d - 32075;
 }
 
-static void julian_to_date(long jd, int *y, int *m, int *d)
-       {
+static void
+julian_to_date(long jd, int *y, int *m, int *d)
+{
        long  L = jd + 68569;
        long  n = (4 * L) / 146097;
        long  i, j;
@@ -178,7 +178,7 @@ static void julian_to_date(long jd, int *y, int *m, int *d)
        L = j / 11;
        *m = j + 2 - (12 * L);
        *y = 100 * (n - 49) + i + L;
-       }
+}
 
 #ifdef OPENSSL_TIME_TEST
 
@@ -189,20 +189,21 @@ static void julian_to_date(long jd, int *y, int *m, int *d)
  * trigger the very errors the routines fix.
  */
 
-int main(int argc, char **argv)
-       {
+int
+main(int argc, char **argv)
+{
        long offset;
-       for (offset = 0; offset < 1000000; offset++)
-               {
+       for (offset = 0; offset < 1000000; offset++) {
                check_time(offset);
                check_time(-offset);
                check_time(offset * 1000);
                check_time(-offset * 1000);
-               }
        }
+}
 
-int check_time(long offset)
-       {
+int
+check_time(long offset)
+{
        struct tm tm1, tm2;
        time_t t1, t2;
        time(&t1);
@@ -211,20 +212,20 @@ int check_time(long offset)
        OPENSSL_gmtime(&t1, &tm1);
        OPENSSL_gmtime_adj(&tm1, 0, offset);
        if ((tm1.tm_year == tm2.tm_year) &&
-           (tm1.tm_mon == tm2.tm_mon) &&
-           (tm1.tm_mday == tm2.tm_mday) &&
-           (tm1.tm_hour == tm2.tm_hour) &&
-           (tm1.tm_min == tm2.tm_min) &&
-           (tm1.tm_sec == tm2.tm_sec))
-               return 1;
+               (tm1.tm_mon == tm2.tm_mon) &&
+       (tm1.tm_mday == tm2.tm_mday) &&
+       (tm1.tm_hour == tm2.tm_hour) &&
+       (tm1.tm_min == tm2.tm_min) &&
+       (tm1.tm_sec == tm2.tm_sec))
+       return 1;
        fprintf(stderr, "TIME ERROR!!\n");
        fprintf(stderr, "Time1: %d/%d/%d, %d:%02d:%02d\n",
-                       tm2.tm_mday, tm2.tm_mon + 1, tm2.tm_year + 1900,
-                       tm2.tm_hour, tm2.tm_min, tm2.tm_sec);
+       tm2.tm_mday, tm2.tm_mon + 1, tm2.tm_year + 1900,
+       tm2.tm_hour, tm2.tm_min, tm2.tm_sec);
        fprintf(stderr, "Time2: %d/%d/%d, %d:%02d:%02d\n",
-                       tm1.tm_mday, tm1.tm_mon + 1, tm1.tm_year + 1900,
-                       tm1.tm_hour, tm1.tm_min, tm1.tm_sec);
+       tm1.tm_mday, tm1.tm_mon + 1, tm1.tm_year + 1900,
+       tm1.tm_hour, tm1.tm_min, tm1.tm_sec);
        return 0;
-       }
+}
 
 #endif
index ea9227f..ae79bf8 100644 (file)
@@ -182,18 +182,18 @@ typedef struct DIST_POINT_st DIST_POINT;
 typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;
 typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;
 
-  /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */
+/* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */
 #define DECLARE_PKCS12_STACK_OF(type) /* Nothing */
 #define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */
 
 typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
 /* Callback types for crypto.h */
 typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
-                                       int idx, long argl, void *argp);
+    int idx, long argl, void *argp);
 typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
-                                       int idx, long argl, void *argp);
-typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, 
-                                       int idx, long argl, void *argp);
+    int idx, long argl, void *argp);
+typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,
+    void *from_d, int idx, long argl, void *argp);
 
 typedef struct ocsp_req_ctx_st OCSP_REQ_CTX;
 typedef struct ocsp_response_st OCSP_RESPONSE;
index f71ba66..16cc9c4 100644 (file)
@@ -15,112 +15,110 @@ static int OPENSSL_ppccap_P = 0;
 static sigset_t all_masked;
 
 #ifdef OPENSSL_BN_ASM_MONT
-int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num)
-       {
+int
+bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
+    const BN_ULONG *np, const BN_ULONG *n0, int num)
+{
        int bn_mul_mont_fpu64(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num);
        int bn_mul_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num);
 
-       if (sizeof(size_t)==4)
-               {
+       if (sizeof(size_t) == 4) {
 #if (defined(__APPLE__) && defined(__MACH__))
-               if (num>=8 && (num&3)==0 && (OPENSSL_ppccap_P&PPC_FPU64))
-                       return bn_mul_mont_fpu64(rp,ap,bp,np,n0,num);
+               if (num >= 8 && (num&3) == 0 && (OPENSSL_ppccap_P&PPC_FPU64))
+                       return bn_mul_mont_fpu64(rp, ap, bp, np, n0, num);
 #else
                /* boundary of 32 was experimentally determined on
                   Linux 2.6.22, might have to be adjusted on AIX... */
-               if (num>=32 && (num&3)==0 && (OPENSSL_ppccap_P&PPC_FPU64))
-                       {
+               if (num >= 32 && (num&3) == 0 && (OPENSSL_ppccap_P&PPC_FPU64)) {
                        sigset_t oset;
                        int ret;
 
-                       sigprocmask(SIG_SETMASK,&all_masked,&oset);
-                       ret=bn_mul_mont_fpu64(rp,ap,bp,np,n0,num);
-                       sigprocmask(SIG_SETMASK,&oset,NULL);
+                       sigprocmask(SIG_SETMASK, &all_masked, &oset);
+                       ret = bn_mul_mont_fpu64(rp, ap, bp, np, n0, num);
+                       sigprocmask(SIG_SETMASK, &oset, NULL);
 
                        return ret;
-                       }
-#endif
                }
-       else if ((OPENSSL_ppccap_P&PPC_FPU64))
+#endif
+       } else if ((OPENSSL_ppccap_P&PPC_FPU64))
                /* this is a "must" on POWER6, but run-time detection
                 * is not implemented yet... */
-               return bn_mul_mont_fpu64(rp,ap,bp,np,n0,num);
+               return bn_mul_mont_fpu64(rp, ap, bp, np, n0, num);
 
-       return bn_mul_mont_int(rp,ap,bp,np,n0,num);
-       }
+       return bn_mul_mont_int(rp, ap, bp, np, n0, num);
+}
 #endif
 
 static sigjmp_buf ill_jmp;
-static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); }
+static void ill_handler (int sig)
+{
+       siglongjmp(ill_jmp, sig);
+}
 
 void OPENSSL_ppc64_probe(void);
 void OPENSSL_altivec_probe(void);
 
-void OPENSSL_cpuid_setup(void)
-       {
+void
+OPENSSL_cpuid_setup(void)
+{
        char *e;
-       struct sigaction        ill_oact,ill_act;
+       struct sigaction        ill_oact, ill_act;
        sigset_t                oset;
-       static int trigger=0;
+       static int trigger = 0;
+
+       if (trigger)
+               return;
+       trigger = 1;
 
-       if (trigger) return;
-       trigger=1;
        sigfillset(&all_masked);
-       sigdelset(&all_masked,SIGILL);
-       sigdelset(&all_masked,SIGTRAP);
+       sigdelset(&all_masked, SIGILL);
+       sigdelset(&all_masked, SIGTRAP);
 #ifdef SIGEMT
-       sigdelset(&all_masked,SIGEMT);
+       sigdelset(&all_masked, SIGEMT);
 #endif
-       sigdelset(&all_masked,SIGFPE);
-       sigdelset(&all_masked,SIGBUS);
-       sigdelset(&all_masked,SIGSEGV);
+       sigdelset(&all_masked, SIGFPE);
+       sigdelset(&all_masked, SIGBUS);
+       sigdelset(&all_masked, SIGSEGV);
 
-       if ((e=getenv("OPENSSL_ppccap")))
-               {
-               OPENSSL_ppccap_P=strtoul(e,NULL,0);
+       if ((e = getenv("OPENSSL_ppccap"))) {
+               OPENSSL_ppccap_P = strtoul(e, NULL, 0);
                return;
-               }
+       }
 
        OPENSSL_ppccap_P = 0;
 
 #if defined(_AIX)
-       if (sizeof(size_t)==4
+       if (sizeof(size_t) == 4
 # if defined(_SC_AIX_KERNEL_BITMODE)
-           && sysconf(_SC_AIX_KERNEL_BITMODE)!=64
+       && sysconf(_SC_AIX_KERNEL_BITMODE) != 64
 # endif
-          )
-               return;
+       )
+       return;
 #endif
 
-       memset(&ill_act,0,sizeof(ill_act));
+       memset(&ill_act, 0, sizeof(ill_act));
        ill_act.sa_handler = ill_handler;
-       ill_act.sa_mask    = all_masked;
+       ill_act.sa_mask = all_masked;
 
-       sigprocmask(SIG_SETMASK,&ill_act.sa_mask,&oset);
-       sigaction(SIGILL,&ill_act,&ill_oact);
+       sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset);
+       sigaction(SIGILL, &ill_act, &ill_oact);
 
-       if (sizeof(size_t)==4)
-               {
-               if (sigsetjmp(ill_jmp,1) == 0)
-                       {
+       if (sizeof(size_t) == 4) {
+               if (sigsetjmp(ill_jmp, 1) == 0) {
                        OPENSSL_ppc64_probe();
                        OPENSSL_ppccap_P |= PPC_FPU64;
-                       }
                }
-       else
-               {
+       } else {
                /*
                 * Wanted code detecting POWER6 CPU and setting PPC_FPU64
                 */
-               }
+       }
 
-       if (sigsetjmp(ill_jmp,1) == 0)
-               {
+       if (sigsetjmp(ill_jmp, 1) == 0) {
                OPENSSL_altivec_probe();
                OPENSSL_ppccap_P |= PPC_ALTIVEC;
-               }
-
-       sigaction (SIGILL,&ill_oact,NULL);
-       sigprocmask(SIG_SETMASK,&oset,NULL);
        }
+
+       sigaction (SIGILL, &ill_oact, NULL);
+       sigprocmask(SIG_SETMASK, &oset, NULL);
+}
index f2e94ef..77f6260 100644 (file)
@@ -7,31 +7,36 @@
 extern unsigned long OPENSSL_s390xcap_P[];
 
 static sigjmp_buf ill_jmp;
-static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); }
+static void ill_handler (int sig)
+{
+       siglongjmp(ill_jmp, sig);
+}
 
 unsigned long OPENSSL_s390x_facilities(void);
 
-void OPENSSL_cpuid_setup(void)
-       {
+void
+OPENSSL_cpuid_setup(void)
+{
        sigset_t oset;
-       struct sigaction ill_act,oact;
+       struct sigaction ill_act, oact;
 
-       if (OPENSSL_s390xcap_P[0]) return;
+       if (OPENSSL_s390xcap_P[0])
+               return;
 
-       OPENSSL_s390xcap_P[0] = 1UL<<(8*sizeof(unsigned long)-1);
+       OPENSSL_s390xcap_P[0] = 1UL << (8*sizeof(unsigned long) - 1);
 
-       memset(&ill_act,0,sizeof(ill_act));
+       memset(&ill_act, 0, sizeof(ill_act));
        ill_act.sa_handler = ill_handler;
        sigfillset(&ill_act.sa_mask);
-       sigdelset(&ill_act.sa_mask,SIGILL);
-       sigdelset(&ill_act.sa_mask,SIGTRAP);
-       sigprocmask(SIG_SETMASK,&ill_act.sa_mask,&oset);
-       sigaction (SIGILL,&ill_act,&oact);
+       sigdelset(&ill_act.sa_mask, SIGILL);
+       sigdelset(&ill_act.sa_mask, SIGTRAP);
+       sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset);
+       sigaction (SIGILL, &ill_act, &oact);
 
        /* protection against missing store-facility-list-extended */
-       if (sigsetjmp(ill_jmp,1) == 0)
+       if (sigsetjmp(ill_jmp, 1) == 0)
                OPENSSL_s390x_facilities();
 
-       sigaction (SIGILL,&oact,NULL);
-       sigprocmask(SIG_SETMASK,&oset,NULL);
-       }
+       sigaction (SIGILL, &oact, NULL);
+       sigprocmask(SIG_SETMASK, &oset, NULL);
+}
index 43b3ac6..08f7de3 100644 (file)
 #define SPARCV9_VIS2           (1<<3)  /* reserved */
 #define SPARCV9_FMADD          (1<<4)  /* reserved for SPARC64 V */
 
-static int OPENSSL_sparcv9cap_P=SPARCV9_TICK_PRIVILEGED;
-
-int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num)
-       {
-       int bn_mul_mont_fpu(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num);
-       int bn_mul_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num);
-
-       if (num>=8 && !(num&1) &&
-           (OPENSSL_sparcv9cap_P&(SPARCV9_PREFER_FPU|SPARCV9_VIS1)) ==
-               (SPARCV9_PREFER_FPU|SPARCV9_VIS1))
-               return bn_mul_mont_fpu(rp,ap,bp,np,n0,num);
+static int OPENSSL_sparcv9cap_P = SPARCV9_TICK_PRIVILEGED;
+
+int
+bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
+    const BN_ULONG *np, const BN_ULONG *n0, int num)
+{
+       int bn_mul_mont_fpu(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num);
+       int bn_mul_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num);
+
+       if (num >= 8 && !(num & 1) &&
+           (OPENSSL_sparcv9cap_P & (SPARCV9_PREFER_FPU|SPARCV9_VIS1)) ==
+           (SPARCV9_PREFER_FPU|SPARCV9_VIS1))
+               return bn_mul_mont_fpu(rp, ap, bp, np, n0, num);
        else
-               return bn_mul_mont_int(rp,ap,bp,np,n0,num);
-       }
+               return bn_mul_mont_int(rp, ap, bp, np, n0, num);
+}
 
 unsigned long  _sparcv9_rdtick(void);
 void           _sparcv9_vis1_probe(void);
@@ -33,8 +35,9 @@ unsigned long _sparcv9_vis1_instrument(void);
 void           _sparcv9_vis2_probe(void);
 void           _sparcv9_fmadd_probe(void);
 
-unsigned long OPENSSL_rdtsc(void)
-       {
+unsigned long
+OPENSSL_rdtsc(void)
+{
        if (OPENSSL_sparcv9cap_P&SPARCV9_TICK_PRIVILEGED)
 #if defined(__sun) && defined(__SVR4)
                return gethrtime();
@@ -43,7 +46,7 @@ unsigned long OPENSSL_rdtsc(void)
 #endif
        else
                return _sparcv9_rdtick();
-       }
+}
 
 #if 0 && defined(__sun) && defined(__SVR4)
 /* This code path is disabled, because of incompatibility of
@@ -54,21 +57,22 @@ unsigned long OPENSSL_rdtsc(void)
 #include <libdevinfo.h>
 #include <sys/systeminfo.h>
 
-typedef di_node_t (*di_init_t)(const char *,uint_t);
+typedef di_node_t (*di_init_t)(const char *, uint_t);
 typedef void      (*di_fini_t)(di_node_t);
 typedef char *    (*di_node_name_t)(di_node_t);
-typedef int       (*di_walk_node_t)(di_node_t,uint_t,di_node_name_t,int (*)(di_node_t,di_node_name_t));
+typedef int       (*di_walk_node_t)(di_node_t, uint_t, di_node_name_t, int (*)(di_node_t, di_node_name_t));
 
 #define DLLINK(h,name) (name=(name##_t)dlsym((h),#name))
 
-static int walk_nodename(di_node_t node, di_node_name_t di_node_name)
-       {
+static int
+walk_nodename(di_node_t node, di_node_name_t di_node_name)
+{
        char *name = (*di_node_name)(node);
 
        /* This is expected to catch all UltraSPARC flavors prior T1 */
-       if (!strcmp (name,"SUNW,UltraSPARC") ||
+       if (!strcmp (name, "SUNW, UltraSPARC") ||
            !strncmp(name,"SUNW,UltraSPARC-I",17))  /* covers II,III,IV */
-               {
+       {
                OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU|SPARCV9_VIS1;
 
                /* %tick is privileged only on UltraSPARC-I/II, but not IIe */
@@ -76,51 +80,48 @@ static int walk_nodename(di_node_t node, di_node_name_t di_node_name)
                        OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED;
 
                return DI_WALK_TERMINATE;
-               }
+       }
        /* This is expected to catch remaining UltraSPARCs, such as T1 */
-       else if (!strncmp(name,"SUNW,UltraSPARC",15))
-               {
+       else if (!strncmp(name, "SUNW, UltraSPARC", 15)) {
                OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED;
 
                return DI_WALK_TERMINATE;
-               }
+       }
 
        return DI_WALK_CONTINUE;
-       }
+}
 
-void OPENSSL_cpuid_setup(void)
-       {
+void
+OPENSSL_cpuid_setup(void)
+{
        void *h;
-       char *e,si[256];
-       static int trigger=0;
+       char *e, si[256];
+       static int trigger = 0;
 
-       if (trigger) return;
-       trigger=1;
+       if (trigger)
+               return;
+       trigger = 1;
 
-       if ((e=getenv("OPENSSL_sparcv9cap")))
-               {
-               OPENSSL_sparcv9cap_P=strtoul(e,NULL,0);
+       if ((e = getenv("OPENSSL_sparcv9cap"))) {
+               OPENSSL_sparcv9cap_P = strtoul(e, NULL, 0);
                return;
-               }
+       }
 
-       if (sysinfo(SI_MACHINE,si,sizeof(si))>0)
-               {
-               if (strcmp(si,"sun4v"))
+       if (sysinfo(SI_MACHINE, si, sizeof(si)) > 0) {
+               if (strcmp(si, "sun4v"))
                        /* FPU is preferred for all CPUs, but US-T1/2 */
                        OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU;
-               }
+       }
 
-       if (sysinfo(SI_ISALIST,si,sizeof(si))>0)
-               {
-               if (strstr(si,"+vis"))
+       if (sysinfo(SI_ISALIST, si, sizeof(si)) > 0) {
+               if (strstr(si, "+vis"))
                        OPENSSL_sparcv9cap_P |= SPARCV9_VIS1;
-               if (strstr(si,"+vis2"))
-                       {
+               if (strstr(si, "+vis2")) {
                        OPENSSL_sparcv9cap_P |= SPARCV9_VIS2;
                        OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED;
                        return;
-                       }
                }
+       }
 #ifdef M_KEEP
        /*
         * Solaris libdevinfo.so.1 is effectively incomatible with
@@ -129,109 +130,115 @@ void OPENSSL_cpuid_setup(void)
         * free(3LIBMALLOC) called by di_fini. Prior call to
         * mallopt(M_KEEP,0) somehow helps... But not always...
         */
-       if ((h = dlopen(NULL,RTLD_LAZY)))
-               {
-               union { void *p; int (*f)(int,int); } sym;
-               if ((sym.p = dlsym(h,"mallopt"))) (*sym.f)(M_KEEP,0);
-               dlclose(h);
-               }
+       if ((h = dlopen(NULL, RTLD_LAZY))) {
+                       union { void *p;
+                       int (*f)(int, int);
+               } sym;
+               if ((sym.p = dlsym(h, "mallopt"))) (*sym.f)(M_KEEP, 0);
+                       dlclose(h);
+       }
 #endif
-       if ((h = dlopen("libdevinfo.so.1",RTLD_LAZY))) do
-               {
-               di_init_t       di_init;
-               di_fini_t       di_fini;
-               di_walk_node_t  di_walk_node;
-               di_node_name_t  di_node_name;
-               di_node_t       root_node;
-
-               if (!DLLINK(h,di_init))         break;
-               if (!DLLINK(h,di_fini))         break;
-               if (!DLLINK(h,di_walk_node))    break;
-               if (!DLLINK(h,di_node_name))    break;
-
-               if ((root_node = (*di_init)("/",DINFOSUBTREE))!=DI_NODE_NIL)
-                       {
-                       (*di_walk_node)(root_node,DI_WALK_SIBFIRST,
-                                       di_node_name,walk_nodename);
-                       (*di_fini)(root_node);
+       if ((h = dlopen("libdevinfo.so.1", RTLD_LAZY)))
+               do {
+                       di_init_t       di_init;
+                       di_fini_t       di_fini;
+                       di_walk_node_t  di_walk_node;
+                       di_node_name_t  di_node_name;
+                       di_node_t       root_node;
+
+                       if (!DLLINK(h, di_init))
+                               break;
+                       if (!DLLINK(h, di_fini))
+                               break;
+                       if (!DLLINK(h, di_walk_node))
+                               break;
+                       if (!DLLINK(h, di_node_name))
+                               break;
+
+                       if ((root_node = (*di_init)("/", DINFOSUBTREE)) !=
+                           DI_NODE_NIL) {
+                               (*di_walk_node)(root_node, DI_WALK_SIBFIRST,
+                                  di_node_name, walk_nodename);
+                               (*di_fini)(root_node);
                        }
-               } while(0);
+               } while (0);
 
-       if (h) dlclose(h);
-       }
+       if (h)
+               dlclose(h);
+}
 
 #else
 
 static sigjmp_buf common_jmp;
-static void common_handler(int sig) { siglongjmp(common_jmp,sig); }
-
-void OPENSSL_cpuid_setup(void)
-       {
+static void common_handler(int sig)
+{
+       siglongjmp(common_jmp, sig);
+}
+
+void
+OPENSSL_cpuid_setup(void)
+{
        char *e;
-       struct sigaction        common_act,ill_oact,bus_oact;
-       sigset_t                all_masked,oset;
-       static int trigger=0;
-
-       if (trigger) return;
-       trigger=1;
-       if ((e=getenv("OPENSSL_sparcv9cap")))
-               {
-               OPENSSL_sparcv9cap_P=strtoul(e,NULL,0);
+       struct sigaction        common_act, ill_oact, bus_oact;
+       sigset_t                all_masked, oset;
+       static int trigger = 0;
+
+       if (trigger)
                return;
-               }
+       trigger = 1;
+
+       if ((e = getenv("OPENSSL_sparcv9cap"))) {
+               OPENSSL_sparcv9cap_P = strtoul(e, NULL, 0);
+               return;
+       }
 
        /* Initial value, fits UltraSPARC-I&II... */
        OPENSSL_sparcv9cap_P = SPARCV9_PREFER_FPU|SPARCV9_TICK_PRIVILEGED;
 
        sigfillset(&all_masked);
-       sigdelset(&all_masked,SIGILL);
-       sigdelset(&all_masked,SIGTRAP);
+       sigdelset(&all_masked, SIGILL);
+       sigdelset(&all_masked, SIGTRAP);
 #ifdef SIGEMT
-       sigdelset(&all_masked,SIGEMT);
+       sigdelset(&all_masked, SIGEMT);
 #endif
-       sigdelset(&all_masked,SIGFPE);
-       sigdelset(&all_masked,SIGBUS);
-       sigdelset(&all_masked,SIGSEGV);
-       sigprocmask(SIG_SETMASK,&all_masked,&oset);
+       sigdelset(&all_masked, SIGFPE);
+       sigdelset(&all_masked, SIGBUS);
+       sigdelset(&all_masked, SIGSEGV);
+       sigprocmask(SIG_SETMASK, &all_masked, &oset);
 
-       memset(&common_act,0,sizeof(common_act));
+       memset(&common_act, 0, sizeof(common_act));
        common_act.sa_handler = common_handler;
-       common_act.sa_mask    = all_masked;
+       common_act.sa_mask = all_masked;
 
-       sigaction(SIGILL,&common_act,&ill_oact);
+       sigaction(SIGILL, &common_act, &ill_oact);
        sigaction(SIGBUS,&common_act,&bus_oact);/* T1 fails 16-bit ldda [on Linux] */
 
-       if (sigsetjmp(common_jmp,1) == 0)
-               {
+       if (sigsetjmp(common_jmp, 1) == 0) {
                _sparcv9_rdtick();
                OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED;
-               }
+       }
 
-       if (sigsetjmp(common_jmp,1) == 0)
-               {
+       if (sigsetjmp(common_jmp, 1) == 0) {
                _sparcv9_vis1_probe();
                OPENSSL_sparcv9cap_P |= SPARCV9_VIS1;
                /* detect UltraSPARC-Tx, see sparccpud.S for details... */
                if (_sparcv9_vis1_instrument() >= 12)
                        OPENSSL_sparcv9cap_P &= ~(SPARCV9_VIS1|SPARCV9_PREFER_FPU);
-               else
-                       {
+               else {
                        _sparcv9_vis2_probe();
                        OPENSSL_sparcv9cap_P |= SPARCV9_VIS2;
-                       }
                }
+       }
 
-       if (sigsetjmp(common_jmp,1) == 0)
-               {
+       if (sigsetjmp(common_jmp, 1) == 0) {
                _sparcv9_fmadd_probe();
                OPENSSL_sparcv9cap_P |= SPARCV9_FMADD;
-               }
+       }
 
-       sigaction(SIGBUS,&bus_oact,NULL);
-       sigaction(SIGILL,&ill_oact,NULL);
+       sigaction(SIGBUS, &bus_oact, NULL);
+       sigaction(SIGILL, &ill_oact, NULL);
 
-       sigprocmask(SIG_SETMASK,&oset,NULL);
-       }
+       sigprocmask(SIG_SETMASK, &oset, NULL);
+}
 
 #endif
index b1fd52b..fcfa05c 100644 (file)
 
 #include OPENSSL_UNISTD
 
-int OPENSSL_issetugid(void)
-       {
+int
+OPENSSL_issetugid(void)
+{
        return issetugid();
-       }
+}
 
 #elif defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE)
 
-int OPENSSL_issetugid(void)
-       {
+int
+OPENSSL_issetugid(void)
+{
        return 0;
-       }
+}
 
 #else
 
 #include OPENSSL_UNISTD
 #include <sys/types.h>
 
-int OPENSSL_issetugid(void)
-       {
-       if (getuid() != geteuid()) return 1;
-       if (getgid() != getegid()) return 1;
+int
+OPENSSL_issetugid(void)
+{
+       if (getuid()
+               != geteuid()) return 1;
+       if (getgid()
+               != getegid()) return 1;
        return 0;
-       }
+}
 #endif
-
-
-
index 5a83107..0ccafb2 100644 (file)
@@ -43,7 +43,7 @@
 
 #if !__ASSEMBLER__
 extern unsigned int OPENSSL_armcap_P;
-                                     
+
 #define ARMV7_NEON      (1<<0)
 #define ARMV7_TICK      (1<<1)
 #endif
index 9abaf39..0625587 100644 (file)
@@ -12,7 +12,8 @@ unsigned int OPENSSL_armcap_P;
 static sigset_t all_masked;
 
 static sigjmp_buf ill_jmp;
-static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); }
+       static void ill_handler (int sig) { siglongjmp(ill_jmp, sig);
+}
 
 /*
  * Following subroutines could have been inlined, but it's not all
@@ -21,60 +22,61 @@ static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); }
 void _armv7_neon_probe(void);
 unsigned int _armv7_tick(void);
 
-unsigned int OPENSSL_rdtsc(void)
-       {
+unsigned int
+OPENSSL_rdtsc(void)
+{
        if (OPENSSL_armcap_P & ARMV7_TICK)
                return _armv7_tick();
        else
                return 0;
-       }
+}
 
 #if defined(__GNUC__) && __GNUC__>=2
 void OPENSSL_cpuid_setup(void) __attribute__((constructor));
 #endif
-void OPENSSL_cpuid_setup(void)
-       {
+
+void
+OPENSSL_cpuid_setup(void)
+{
        char *e;
-       struct sigaction        ill_oact,ill_act;
+       struct sigaction        ill_oact, ill_act;
        sigset_t                oset;
-       static int trigger=0;
-
-       if (trigger) return;
-       trigger=1;
-       if ((e=getenv("OPENSSL_armcap")))
-               {
-               OPENSSL_armcap_P=strtoul(e,NULL,0);
+       static int trigger = 0;
+
+       if (trigger)
                return;
-               }
+       trigger = 1;
+
+       if ((e = getenv("OPENSSL_armcap"))) {
+               OPENSSL_armcap_P = strtoul(e, NULL, 0);
+               return;
+       }
 
        sigfillset(&all_masked);
-       sigdelset(&all_masked,SIGILL);
-       sigdelset(&all_masked,SIGTRAP);
-       sigdelset(&all_masked,SIGFPE);
-       sigdelset(&all_masked,SIGBUS);
-       sigdelset(&all_masked,SIGSEGV);
+       sigdelset(&all_masked, SIGILL);
+       sigdelset(&all_masked, SIGTRAP);
+       sigdelset(&all_masked, SIGFPE);
+       sigdelset(&all_masked, SIGBUS);
+       sigdelset(&all_masked, SIGSEGV);
 
        OPENSSL_armcap_P = 0;
 
-       memset(&ill_act,0,sizeof(ill_act));
+       memset(&ill_act, 0, sizeof(ill_act));
        ill_act.sa_handler = ill_handler;
-       ill_act.sa_mask    = all_masked;
+       ill_act.sa_mask = all_masked;
 
-       sigprocmask(SIG_SETMASK,&ill_act.sa_mask,&oset);
-       sigaction(SIGILL,&ill_act,&ill_oact);
+       sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset);
+       sigaction(SIGILL, &ill_act, &ill_oact);
 
-       if (sigsetjmp(ill_jmp,1) == 0)
-               {
+       if (sigsetjmp(ill_jmp, 1) == 0) {
                _armv7_neon_probe();
                OPENSSL_armcap_P |= ARMV7_NEON;
-               }
-       if (sigsetjmp(ill_jmp,1) == 0)
-               {
+       }
+       if (sigsetjmp(ill_jmp, 1) == 0) {
                _armv7_tick();
                OPENSSL_armcap_P |= ARMV7_TICK;
-               }
-
-       sigaction (SIGILL,&ill_oact,NULL);
-       sigprocmask(SIG_SETMASK,&oset,NULL);
        }
+
+       sigaction (SIGILL, &ill_oact, NULL);
+       sigprocmask(SIG_SETMASK, &oset, NULL);
+}
index 957f09d..8fdb24c 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef MK1MF_BUILD
-  /* auto-generated by crypto/Makefile for crypto/cversion.c */
-  #define CFLAGS "cc -O"
-  #define PLATFORM "dist"
-  #define DATE "Sat Aug 21 10:52:09 EST 2010"
+/* auto-generated by crypto/Makefile for crypto/cversion.c */
+#define CFLAGS "cc -O"
+#define PLATFORM "dist"
+#define DATE "Sat Aug 21 10:52:09 EST 2010"
 #endif
index 289005f..a8e94cc 100644 (file)
 #define ERR_FUNC(func) ERR_PACK(ERR_LIB_CRYPTO,func,0)
 #define ERR_REASON(reason) ERR_PACK(ERR_LIB_CRYPTO,0,reason)
 
-static ERR_STRING_DATA CRYPTO_str_functs[]=
-       {
-{ERR_FUNC(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX),   "CRYPTO_get_ex_new_index"},
-{ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID),  "CRYPTO_get_new_dynlockid"},
-{ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_LOCKID),     "CRYPTO_get_new_lockid"},
-{ERR_FUNC(CRYPTO_F_CRYPTO_SET_EX_DATA),        "CRYPTO_set_ex_data"},
-{ERR_FUNC(CRYPTO_F_DEF_ADD_INDEX),     "DEF_ADD_INDEX"},
-{ERR_FUNC(CRYPTO_F_DEF_GET_CLASS),     "DEF_GET_CLASS"},
-{ERR_FUNC(CRYPTO_F_FIPS_MODE_SET),     "FIPS_mode_set"},
-{ERR_FUNC(CRYPTO_F_INT_DUP_EX_DATA),   "INT_DUP_EX_DATA"},
-{ERR_FUNC(CRYPTO_F_INT_FREE_EX_DATA),  "INT_FREE_EX_DATA"},
-{ERR_FUNC(CRYPTO_F_INT_NEW_EX_DATA),   "INT_NEW_EX_DATA"},
-{0,NULL}
-       };
+static ERR_STRING_DATA CRYPTO_str_functs[]= {
+       {ERR_FUNC(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX),    "CRYPTO_get_ex_new_index"},
+       {ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID),   "CRYPTO_get_new_dynlockid"},
+       {ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_LOCKID),      "CRYPTO_get_new_lockid"},
+       {ERR_FUNC(CRYPTO_F_CRYPTO_SET_EX_DATA), "CRYPTO_set_ex_data"},
+       {ERR_FUNC(CRYPTO_F_DEF_ADD_INDEX),      "DEF_ADD_INDEX"},
+       {ERR_FUNC(CRYPTO_F_DEF_GET_CLASS),      "DEF_GET_CLASS"},
+       {ERR_FUNC(CRYPTO_F_FIPS_MODE_SET),      "FIPS_mode_set"},
+       {ERR_FUNC(CRYPTO_F_INT_DUP_EX_DATA),    "INT_DUP_EX_DATA"},
+       {ERR_FUNC(CRYPTO_F_INT_FREE_EX_DATA),   "INT_FREE_EX_DATA"},
+       {ERR_FUNC(CRYPTO_F_INT_NEW_EX_DATA),    "INT_NEW_EX_DATA"},
+       {0, NULL}
+};
 
-static ERR_STRING_DATA CRYPTO_str_reasons[]=
-       {
-{ERR_REASON(CRYPTO_R_FIPS_MODE_NOT_SUPPORTED),"fips mode not supported"},
-{ERR_REASON(CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK),"no dynlock create callback"},
-{0,NULL}
-       };
+static ERR_STRING_DATA CRYPTO_str_reasons[]= {
+       {ERR_REASON(CRYPTO_R_FIPS_MODE_NOT_SUPPORTED), "fips mode not supported"},
+       {ERR_REASON(CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK), "no dynlock create callback"},
+       {0, NULL}
+};
 
 #endif
 
-void ERR_load_CRYPTO_strings(void)
-       {
+void
+ERR_load_CRYPTO_strings(void)
+{
 #ifndef OPENSSL_NO_ERR
-
-       if (ERR_func_error_string(CRYPTO_str_functs[0].error) == NULL)
-               {
-               ERR_load_strings(0,CRYPTO_str_functs);
-               ERR_load_strings(0,CRYPTO_str_reasons);
-               }
-#endif
+       if (ERR_func_error_string(CRYPTO_str_functs[0].error) == NULL) {
+               ERR_load_strings(0, CRYPTO_str_functs);
+               ERR_load_strings(0, CRYPTO_str_reasons);
        }
+#endif
+}
index 082b2e8..89667d1 100644 (file)
 #include <openssl/safestack.h>
 
 #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16)
-static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */
+static double SSLeay_MSVC5_hack = 0.0; /* and for VC1.5 */
 #endif
 
 DECLARE_STACK_OF(CRYPTO_dynlock)
 
 /* real #defines in crypto.h, keep these upto date */
-static const char* const lock_names[CRYPTO_NUM_LOCKS] =
-       {
+static const char* const lock_names[CRYPTO_NUM_LOCKS] = {
        "<<ERROR>>",
        "err",
        "ex_data",
@@ -170,35 +169,35 @@ static const char* const lock_names[CRYPTO_NUM_LOCKS] =
 #if CRYPTO_NUM_LOCKS != 41
 # error "Inconsistency between crypto.h and cryptlib.c"
 #endif
-       };
+};
 
 /* This is for applications to allocate new type names in the non-dynamic
    array of lock names.  These are numbered with positive numbers.  */
-static STACK_OF(OPENSSL_STRING) *app_locks=NULL;
+static STACK_OF(OPENSSL_STRING) *app_locks = NULL;
 
 /* For applications that want a more dynamic way of handling threads, the
    following stack is used.  These are externally numbered with negative
    numbers.  */
-static STACK_OF(CRYPTO_dynlock) *dyn_locks=NULL;
-
+static STACK_OF(CRYPTO_dynlock) *dyn_locks = NULL;
 
-static void (*locking_callback)(int mode,int type,
-       const char *file,int line)=0;
-static int (*add_lock_callback)(int *pointer,int amount,
-       int type,const char *file,int line)=0;
+static void (*locking_callback)(int mode, int type,
+    const char *file, int line) = 0;
+static int (*add_lock_callback)(int *pointer, int amount,
+    int type, const char *file, int line) = 0;
 #ifndef OPENSSL_NO_DEPRECATED
-static unsigned long (*id_callback)(void)=0;
+static unsigned long (*id_callback)(void) = 0;
 #endif
-static void (*threadid_callback)(CRYPTO_THREADID *)=0;
-static struct CRYPTO_dynlock_value *(*dynlock_create_callback)
-       (const char *file,int line)=0;
+static void (*threadid_callback)(CRYPTO_THREADID *) = 0;
+static struct CRYPTO_dynlock_value *(*dynlock_create_callback)(
+    const char *file, int line) = 0;
 static void (*dynlock_lock_callback)(int mode,
-       struct CRYPTO_dynlock_value *l, const char *file,int line)=0;
+    struct CRYPTO_dynlock_value *l, const char *file, int line) = 0;
 static void (*dynlock_destroy_callback)(struct CRYPTO_dynlock_value *l,
-       const char *file,int line)=0;
+    const char *file, int line) = 0;
 
-int CRYPTO_get_new_lockid(char *name)
-       {
+int
+CRYPTO_get_new_lockid(char *name)
+{
        char *str;
        int i;
 
@@ -207,141 +206,130 @@ int CRYPTO_get_new_lockid(char *name)
         * a DLL using /MT. Without this, the application cannot use
         * any floating point printf's.
         * It also seems to be needed for Visual C 1.5 (win16) */
-       SSLeay_MSVC5_hack=(double)name[0]*(double)name[1];
+       SSLeay_MSVC5_hack = (double)name[0]*(double)name[1];
 #endif
 
-       if ((app_locks == NULL) && ((app_locks=sk_OPENSSL_STRING_new_null()) == NULL))
-               {
-               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
-               return(0);
-               }
-       if ((str=BUF_strdup(name)) == NULL)
-               {
-               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
-               return(0);
-               }
-       i=sk_OPENSSL_STRING_push(app_locks,str);
+       if ((app_locks == NULL) && ((app_locks = sk_OPENSSL_STRING_new_null()) == NULL)) {
+               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE);
+               return (0);
+       }
+       if ((str = BUF_strdup(name)) == NULL) {
+               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE);
+               return (0);
+       }
+       i = sk_OPENSSL_STRING_push(app_locks, str);
        if (!i)
                OPENSSL_free(str);
        else
-               i+=CRYPTO_NUM_LOCKS; /* gap of one :-) */
-       return(i);
-       }
+               i += CRYPTO_NUM_LOCKS; /* gap of one :-) */
+       return (i);
+}
 
-int CRYPTO_num_locks(void)
-       {
+int
+CRYPTO_num_locks(void)
+{
        return CRYPTO_NUM_LOCKS;
-       }
+}
 
-int CRYPTO_get_new_dynlockid(void)
-       {
+int
+CRYPTO_get_new_dynlockid(void)
+{
        int i = 0;
        CRYPTO_dynlock *pointer = NULL;
 
-       if (dynlock_create_callback == NULL)
-               {
-               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK);
-               return(0);
-               }
+       if (dynlock_create_callback == NULL) {
+               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK);
+               return (0);
+       }
        CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
        if ((dyn_locks == NULL)
-               && ((dyn_locks=sk_CRYPTO_dynlock_new_null()) == NULL))
-               {
+               && ((dyn_locks = sk_CRYPTO_dynlock_new_null()) == NULL)) {
                CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
-               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
-               return(0);
-               }
+               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE);
+               return (0);
+       }
        CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
 
        pointer = (CRYPTO_dynlock *)OPENSSL_malloc(sizeof(CRYPTO_dynlock));
-       if (pointer == NULL)
-               {
-               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
-               return(0);
-               }
+       if (pointer == NULL) {
+               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE);
+               return (0);
+       }
        pointer->references = 1;
-       pointer->data = dynlock_create_callback(__FILE__,__LINE__);
-       if (pointer->data == NULL)
-               {
+       pointer->data = dynlock_create_callback(__FILE__, __LINE__);
+       if (pointer->data == NULL) {
                OPENSSL_free(pointer);
-               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
-               return(0);
-               }
+               CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE);
+               return (0);
+       }
 
        CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
        /* First, try to find an existing empty slot */
-       i=sk_CRYPTO_dynlock_find(dyn_locks,NULL);
+       i = sk_CRYPTO_dynlock_find(dyn_locks, NULL);
        /* If there was none, push, thereby creating a new one */
        if (i == -1)
                /* Since sk_push() returns the number of items on the
                   stack, not the location of the pushed item, we need
                   to transform the returned number into a position,
                   by decreasing it.  */
-               i=sk_CRYPTO_dynlock_push(dyn_locks,pointer) - 1;
+               i = sk_CRYPTO_dynlock_push(dyn_locks, pointer) - 1;
        else
                /* If we found a place with a NULL pointer, put our pointer
                   in it.  */
-               (void)sk_CRYPTO_dynlock_set(dyn_locks,i,pointer);
+               (void)sk_CRYPTO_dynlock_set(dyn_locks, i, pointer);
        CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
 
-       if (i == -1)
-               {
-               dynlock_destroy_callback(pointer->data,__FILE__,__LINE__);
+       if (i == -1) {
+               dynlock_destroy_callback(pointer->data, __FILE__, __LINE__);
                OPENSSL_free(pointer);
-               }
-       else
+       } else
                i += 1; /* to avoid 0 */
-       return -i;
-       }
+       return - i;
+}
 
-void CRYPTO_destroy_dynlockid(int i)
-       {
+void
+CRYPTO_destroy_dynlockid(int i)
+{
        CRYPTO_dynlock *pointer = NULL;
        if (i)
-               i = -i-1;
+               i = -i - 1;
        if (dynlock_destroy_callback == NULL)
                return;
 
        CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
 
-       if (dyn_locks == NULL || i >= sk_CRYPTO_dynlock_num(dyn_locks))
-               {
+       if (dyn_locks == NULL || i >= sk_CRYPTO_dynlock_num(dyn_locks)) {
                CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
                return;
-               }
+       }
        pointer = sk_CRYPTO_dynlock_value(dyn_locks, i);
-       if (pointer != NULL)
-               {
+       if (pointer != NULL) {
                --pointer->references;
 #ifdef REF_CHECK
-               if (pointer->references < 0)
-                       {
-                       fprintf(stderr,"CRYPTO_destroy_dynlockid, bad reference count\n");
+               if (pointer->references < 0) {
+                       fprintf(stderr, "CRYPTO_destroy_dynlockid, bad reference count\n");
                        abort();
-                       }
-               else
+               } else
 #endif
-                       if (pointer->references <= 0)
-                               {
-                               (void)sk_CRYPTO_dynlock_set(dyn_locks, i, NULL);
-                               }
-                       else
-                               pointer = NULL;
-               }
+               if (pointer->references <= 0) {
+                       (void)sk_CRYPTO_dynlock_set(dyn_locks, i, NULL);
+               } else
+                       pointer = NULL;
+       }
        CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
 
-       if (pointer)
-               {
-               dynlock_destroy_callback(pointer->data,__FILE__,__LINE__);
+       if (pointer) {
+               dynlock_destroy_callback(pointer->data, __FILE__, __LINE__);
                OPENSSL_free(pointer);
-               }
        }
+}
 
-struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i)
-       {
+struct CRYPTO_dynlock_value
+*CRYPTO_get_dynlock_value(int i)
+{
        CRYPTO_dynlock *pointer = NULL;
        if (i)
-               i = -i-1;
+               i = -i - 1;
 
        CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
 
@@ -355,97 +343,102 @@ struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i)
        if (pointer)
                return pointer->data;
        return NULL;
-       }
+}
 
-struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))
-       (const char *file,int line)
-       {
-       return(dynlock_create_callback);
-       }
+struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(
+    const char *file, int line)
+{
+       return (dynlock_create_callback);
+}
 
 void (*CRYPTO_get_dynlock_lock_callback(void))(int mode,
-       struct CRYPTO_dynlock_value *l, const char *file,int line)
-       {
-       return(dynlock_lock_callback);
-       }
-
-void (*CRYPTO_get_dynlock_destroy_callback(void))
-       (struct CRYPTO_dynlock_value *l, const char *file,int line)
-       {
-       return(dynlock_destroy_callback);
-       }
+    struct CRYPTO_dynlock_value *l, const char *file, int line)
+{
+       return (dynlock_lock_callback);
+}
 
-void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*func)
-       (const char *file, int line))
-       {
-       dynlock_create_callback=func;
-       }
+void (*CRYPTO_get_dynlock_destroy_callback(void))(
+    struct CRYPTO_dynlock_value *l, const char *file, int line)
+{
+       return (dynlock_destroy_callback);
+}
 
-void CRYPTO_set_dynlock_lock_callback(void (*func)(int mode,
-       struct CRYPTO_dynlock_value *l, const char *file, int line))
-       {
-       dynlock_lock_callback=func;
-       }
+void
+CRYPTO_set_dynlock_create_callback(
+    struct CRYPTO_dynlock_value *(*func)(const char *file, int line))
+{
+       dynlock_create_callback = func;
+}
 
-void CRYPTO_set_dynlock_destroy_callback(void (*func)
-       (struct CRYPTO_dynlock_value *l, const char *file, int line))
-       {
-       dynlock_destroy_callback=func;
-       }
+void
+CRYPTO_set_dynlock_lock_callback(void (*func)(int mode,
+    struct CRYPTO_dynlock_value *l, const char *file, int line))
+{
+       dynlock_lock_callback = func;
+}
 
+void
+CRYPTO_set_dynlock_destroy_callback(
+    void (*func)(struct CRYPTO_dynlock_value *l, const char *file, int line))
+{
+       dynlock_destroy_callback = func;
+}
 
-void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
-               int line)
-       {
-       return(locking_callback);
-       }
+void (*CRYPTO_get_locking_callback(void))(int mode, int type,
+    const char *file, int line)
+{
+       return (locking_callback);
+}
 
-int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type,
-                                         const char *file,int line)
-       {
-       return(add_lock_callback);
-       }
+int (*CRYPTO_get_add_lock_callback(void))(int *num, int mount, int type,
+    const char *file, int line)
+{
+       return (add_lock_callback);
+}
 
-void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
-                                             const char *file,int line))
-       {
+void
+CRYPTO_set_locking_callback(void (*func)(int mode, int type,
+    const char *file, int line))
+{
        /* Calling this here ensures initialisation before any threads
         * are started.
         */
        OPENSSL_init();
-       locking_callback=func;
-       }
+       locking_callback = func;
+}
 
-void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
-                                             const char *file,int line))
-       {
-       add_lock_callback=func;
-       }
+void
+CRYPTO_set_add_lock_callback(int (*func)(int *num, int mount, int type,
+    const char *file, int line))
+{
+       add_lock_callback = func;
+}
 
 /* the memset() here and in set_pointer() seem overkill, but for the sake of
  * CRYPTO_THREADID_cmp() this avoids any platform silliness that might cause two
  * "equal" THREADID structs to not be memcmp()-identical. */
-void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val)
-       {
+void
+CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val)
+{
        memset(id, 0, sizeof(*id));
        id->val = val;
-       }
+}
 
 static const unsigned char hash_coeffs[] = { 3, 5, 7, 11, 13, 17, 19, 23 };
-void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr)
-       {
+void
+CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr)
+{
        unsigned char *dest = (void *)&id->val;
        unsigned int accum = 0;
        unsigned char dnum = sizeof(id->val);
 
        memset(id, 0, sizeof(*id));
        id->ptr = ptr;
-       if (sizeof(id->val) >= sizeof(id->ptr))
-               {
+       if (sizeof(id->val) >= sizeof(id->ptr)) {
                /* 'ptr' can be embedded in 'val' without loss of uniqueness */
                id->val = (unsigned long)id->ptr;
                return;
-               }
+       }
        /* hash ptr ==> val. Each byte of 'val' gets the mod-256 total of a
         * linear function over the bytes in 'ptr', the co-efficients of which
         * are a sequence of low-primes (hash_coeffs is an 8-element cycle) -
@@ -456,44 +449,43 @@ void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr)
         * a black-belt, I'd scan big-endian pointers in reverse to give
         * low-order bits more play, but this isn't crypto and I'd prefer nobody
         * mistake it as such. Plus I'm lazy. */
-       while (dnum--)
-               {
+       while (dnum--) {
                const unsigned char *src = (void *)&id->ptr;
                unsigned char snum = sizeof(id->ptr);
                while (snum--)
-                       accum += *(src++) * hash_coeffs[(snum + dnum) & 7];
+               accum += *(src++) * hash_coeffs[(snum + dnum) & 7];
                accum += dnum;
                *(dest++) = accum & 255;
-               }
        }
+}
 
-int CRYPTO_THREADID_set_callback(void (*func)(CRYPTO_THREADID *))
-       {
+int
+CRYPTO_THREADID_set_callback(void (*func)(CRYPTO_THREADID *))
+{
        if (threadid_callback)
                return 0;
        threadid_callback = func;
        return 1;
-       }
+}
 
 void (*CRYPTO_THREADID_get_callback(void))(CRYPTO_THREADID *)
-       {
+{
        return threadid_callback;
-       }
+}
 
-void CRYPTO_THREADID_current(CRYPTO_THREADID *id)
-       {
-       if (threadid_callback)
-               {
+void
+CRYPTO_THREADID_current(CRYPTO_THREADID *id)
+{
+       if (threadid_callback) {
                threadid_callback(id);
                return;
-               }
+       }
 #ifndef OPENSSL_NO_DEPRECATED
        /* If the deprecated callback was set, fall back to that */
-       if (id_callback)
-               {
+       if (id_callback) {
                CRYPTO_THREADID_set_numeric(id, id_callback());
                return;
-               }
+       }
 #endif
        /* Else pick a backup */
 #ifdef OPENSSL_SYS_WIN16
@@ -506,64 +498,68 @@ void CRYPTO_THREADID_current(CRYPTO_THREADID *id)
        /* For everything else, default to using the address of 'errno' */
        CRYPTO_THREADID_set_pointer(id, (void*)&errno);
 #endif
-       }
+}
 
-int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b)
-       {
+int
+CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b)
+{
        return memcmp(a, b, sizeof(*a));
-       }
+}
 
-void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src)
-       {
+void
+CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src)
+{
        memcpy(dest, src, sizeof(*src));
-       }
+}
 
-unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id)
-       {
+unsigned long
+CRYPTO_THREADID_hash(const CRYPTO_THREADID *id)
+{
        return id->val;
-       }
+}
 
 #ifndef OPENSSL_NO_DEPRECATED
 unsigned long (*CRYPTO_get_id_callback(void))(void)
-       {
-       return(id_callback);
-       }
+{
+       return (id_callback);
+}
 
-void CRYPTO_set_id_callback(unsigned long (*func)(void))
-       {
-       id_callback=func;
-       }
+void
+CRYPTO_set_id_callback(unsigned long (*func)(void))
+{
+       id_callback = func;
+}
 
-unsigned long CRYPTO_thread_id(void)
-       {
-       unsigned long ret=0;
+unsigned long
+CRYPTO_thread_id(void)
+{
+       unsigned long ret = 0;
 
-       if (id_callback == NULL)
-               {
+       if (id_callback == NULL) {
 #ifdef OPENSSL_SYS_WIN16
-               ret=(unsigned long)GetCurrentTask();
+               ret = (unsigned long)GetCurrentTask();
 #elif defined(OPENSSL_SYS_WIN32)
-               ret=(unsigned long)GetCurrentThreadId();
+               ret = (unsigned long)GetCurrentThreadId();
 #elif defined(GETPID_IS_MEANINGLESS)
-               ret=1L;
+               ret = 1L;
 #elif defined(OPENSSL_SYS_BEOS)
-               ret=(unsigned long)find_thread(NULL);
+               ret = (unsigned long)find_thread(NULL);
 #else
-               ret=(unsigned long)getpid();
+               ret = (unsigned long)getpid();
 #endif
-               }
-       else
-               ret=id_callback();
-       return(ret);
-       }
+       } else
+               ret = id_callback();
+       return (ret);
+}
 #endif
 
-void CRYPTO_lock(int mode, int type, const char *file, int line)
-       {
+void
+CRYPTO_lock(int mode, int type, const char *file, int line)
+{
 #ifdef LOCK_DEBUG
-               {
+       {
                CRYPTO_THREADID id;
-               char *rw_text,*operation_text;
+               char *rw_text, *operation_text;
 
                if (mode & CRYPTO_LOCK)
                        operation_text="lock  ";
@@ -580,101 +576,98 @@ void CRYPTO_lock(int mode, int type, const char *file, int line)
                        rw_text="ERROR";
 
                CRYPTO_THREADID_current(&id);
-               fprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\n",
-                       CRYPTO_THREADID_hash(&id), rw_text, operation_text,
-                       CRYPTO_get_lock_name(type), file, line);
-               }
+               fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\n",
+               CRYPTO_THREADID_hash(&id), rw_text, operation_text,
+               CRYPTO_get_lock_name(type), file, line);
+       }
 #endif
-       if (type < 0)
-               {
-               if (dynlock_lock_callback != NULL)
-                       {
-                       struct CRYPTO_dynlock_value *pointer
-                               = CRYPTO_get_dynlock_value(type);
+       if (type < 0) {
+               if (dynlock_lock_callback != NULL) {
+                       struct CRYPTO_dynlock_value *pointer =
+                           CRYPTO_get_dynlock_value(type);
 
                        OPENSSL_assert(pointer != NULL);
 
                        dynlock_lock_callback(mode, pointer, file, line);
 
                        CRYPTO_destroy_dynlockid(type);
-                       }
                }
-       else
-               if (locking_callback != NULL)
-                       locking_callback(mode,type,file,line);
-       }
+       } else if (locking_callback != NULL)
+               locking_callback(mode, type, file, line);
+}
 
-int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
-            int line)
-       {
+int
+CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
+    int line)
+{
        int ret = 0;
 
-       if (add_lock_callback != NULL)
-               {
+       if (add_lock_callback != NULL) {
 #ifdef LOCK_DEBUG
                int before= *pointer;
 #endif
 
-               ret=add_lock_callback(pointer,amount,type,file,line);
+               ret = add_lock_callback(pointer, amount, type, file, line);
 #ifdef LOCK_DEBUG
                {
-               CRYPTO_THREADID id;
-               CRYPTO_THREADID_current(&id);
-               fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",
-                       CRYPTO_THREADID_hash(&id), before,amount,ret,
+                       CRYPTO_THREADID id;
+                       CRYPTO_THREADID_current(&id);
+                       fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",
+                       CRYPTO_THREADID_hash(&id), before, amount, ret,
                        CRYPTO_get_lock_name(type),
-                       file,line);
+                       file, line);
                }
 #endif
-               }
-       else
-               {
-               CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,file,line);
+       } else {
+               CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE, type, file, line);
 
-               ret= *pointer+amount;
+               ret= *pointer + amount;
 #ifdef LOCK_DEBUG
                {
-               CRYPTO_THREADID id;
-               CRYPTO_THREADID_current(&id);
-               fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",
+                       CRYPTO_THREADID id;
+                       CRYPTO_THREADID_current(&id);
+                       fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",
                        CRYPTO_THREADID_hash(&id),
-                       *pointer,amount,ret,
+                       *pointer, amount, ret,
                        CRYPTO_get_lock_name(type),
-                       file,line);
+                       file, line);
                }
 #endif
-               *pointer=ret;
-               CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,file,line);
-               }
-       return(ret);
+               *pointer = ret;
+               CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE, type, file, line);
        }
+       return (ret);
+}
 
-const char *CRYPTO_get_lock_name(int type)
-       {
+const char
+*CRYPTO_get_lock_name(int type)
+{
        if (type < 0)
                return("dynamic");
        else if (type < CRYPTO_NUM_LOCKS)
-               return(lock_names[type]);
-       else if (type-CRYPTO_NUM_LOCKS > sk_OPENSSL_STRING_num(app_locks))
+               return (lock_names[type]);
+       else if (type - CRYPTO_NUM_LOCKS > sk_OPENSSL_STRING_num(app_locks))
                return("ERROR");
        else
-               return(sk_OPENSSL_STRING_value(app_locks,type-CRYPTO_NUM_LOCKS));
-       }
+               return (sk_OPENSSL_STRING_value(app_locks, type - CRYPTO_NUM_LOCKS));
+}
 
 #if    defined(__i386)   || defined(__i386__)   || defined(_M_IX86) || \
        defined(__INTEL__) || \
        defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
 
 unsigned int  OPENSSL_ia32cap_P[2];
-unsigned long *OPENSSL_ia32cap_loc(void)
-{   if (sizeof(long)==4)
-       /*
-        * If 32-bit application pulls address of OPENSSL_ia32cap_P[0]
-        * clear second element to maintain the illusion that vector
-        * is 32-bit.
-        */
-       OPENSSL_ia32cap_P[1]=0;
-    return (unsigned long *)OPENSSL_ia32cap_P;
+unsigned long
+*OPENSSL_ia32cap_loc(void)
+{
+       if (sizeof(long) == 4)
+               /*
+                * If 32-bit application pulls address of OPENSSL_ia32cap_P[0]
+                * clear second element to maintain the illusion that vector
+                * is 32-bit.
+                */
+               OPENSSL_ia32cap_P[1] = 0;
+       return (unsigned long *)OPENSSL_ia32cap_P;
 }
 
 #if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)
@@ -684,43 +677,48 @@ typedef unsigned __int64 IA32CAP;
 #else
 typedef unsigned long long IA32CAP;
 #endif
-void OPENSSL_cpuid_setup(void)
-{ static int trigger=0;
-  IA32CAP OPENSSL_ia32_cpuid(void);
-  IA32CAP vec;
-  char *env;
-
-    if (trigger)       return;
+void
+OPENSSL_cpuid_setup(void)
+{
+       static int trigger = 0;
+       IA32CAP OPENSSL_ia32_cpuid(void);
+       IA32CAP vec;
+       char *env;
+
+       if (trigger)
+               return;
 
-    trigger=1;
-    if ((env=getenv("OPENSSL_ia32cap"))) {
-       int off = (env[0]=='~')?1:0;
+       trigger = 1;
+       if ((env = getenv("OPENSSL_ia32cap"))) {
+               int off = (env[0]=='~') ? 1 : 0;
 #if defined(_WIN32)
-       if (!sscanf(env+off,"%I64i",&vec)) vec = strtoul(env+off,NULL,0);
+               if (!sscanf(env+off, "%I64i", &vec)) vec = strtoul(env+off, NULL, 0);
 #else
-       if (!sscanf(env+off,"%lli",(long long *)&vec)) vec = strtoul(env+off,NULL,0);
+               if (!sscanf(env+off, "%lli",(long long *)&vec)) vec = strtoul(env+off, NULL, 0);
 #endif
-       if (off) vec = OPENSSL_ia32_cpuid()&~vec;
-    }
-    else
-       vec = OPENSSL_ia32_cpuid();
+               if (off)
+                       vec = OPENSSL_ia32_cpuid()&~vec;
+       } else
+               vec = OPENSSL_ia32_cpuid();
 
     /*
      * |(1<<10) sets a reserved bit to signal that variable
      * was initialized already... This is to avoid interference
      * with cpuid snippets in ELF .init segment.
      */
-    OPENSSL_ia32cap_P[0] = (unsigned int)vec|(1<<10);
-    OPENSSL_ia32cap_P[1] = (unsigned int)(vec>>32);
+       OPENSSL_ia32cap_P[0] = (unsigned int)vec|(1 << 10);
+       OPENSSL_ia32cap_P[1] = (unsigned int)(vec >> 32);
 }
 #endif
 
 #else
-unsigned long *OPENSSL_ia32cap_loc(void) { return NULL; }
+       unsigned long *OPENSSL_ia32cap_loc(void) { return NULL;
+}
 #endif
 int OPENSSL_NONPIC_relocated = 0;
 #if !defined(OPENSSL_CPUID_SETUP) && !defined(OPENSSL_CPUID_OBJ)
-void OPENSSL_cpuid_setup(void) {}
+void
+OPENSSL_cpuid_setup(void) {}
 #endif
 
 #if (defined(_WIN32) || defined(__CYGWIN__)) && defined(_WINDLL)
@@ -734,25 +732,23 @@ void OPENSSL_cpuid_setup(void) {}
 /* All we really need to do is remove the 'error' state when a thread
  * detaches */
 
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
-            LPVOID lpvReserved)
-       {
-       switch(fdwReason)
-               {
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+       switch (fdwReason) {
        case DLL_PROCESS_ATTACH:
                OPENSSL_cpuid_setup();
 #if defined(_WIN32_WINNT)
                {
-               IMAGE_DOS_HEADER *dos_header = (IMAGE_DOS_HEADER *)hinstDLL;
-               IMAGE_NT_HEADERS *nt_headers;
-
-               if (dos_header->e_magic==IMAGE_DOS_SIGNATURE)
-                       {
-                       nt_headers = (IMAGE_NT_HEADERS *)((char *)dos_header
-                                               + dos_header->e_lfanew);
-                       if (nt_headers->Signature==IMAGE_NT_SIGNATURE &&
-                           hinstDLL!=(HINSTANCE)(nt_headers->OptionalHeader.ImageBase))
-                               OPENSSL_NONPIC_relocated=1;
+                       IMAGE_DOS_HEADER *dos_header = (IMAGE_DOS_HEADER *)hinstDLL;
+                       IMAGE_NT_HEADERS *nt_headers;
+
+                       if (dos_header->e_magic == IMAGE_DOS_SIGNATURE) {
+                               nt_headers = (IMAGE_NT_HEADERS *)((char *)dos_header
+                               + dos_header->e_lfanew);
+                               if (nt_headers->Signature == IMAGE_NT_SIGNATURE &&
+                                       hinstDLL != (HINSTANCE)(nt_headers->OptionalHeader.ImageBase))
+                               OPENSSL_NONPIC_relocated = 1;
                        }
                }
 #endif
@@ -763,9 +759,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
                break;
        case DLL_PROCESS_DETACH:
                break;
-               }
-       return(TRUE);
        }
+       return (TRUE);
+}
 #endif
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -783,138 +779,166 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
 #endif
 
 #if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
-int OPENSSL_isservice(void)
-{ HWINSTA h;
-  DWORD len;
-  WCHAR *name;
-  static union { void *p; int (*f)(void); } _OPENSSL_isservice = { NULL };
-
-    if (_OPENSSL_isservice.p == NULL) {
-       HANDLE h = GetModuleHandle(NULL);
-       if (h != NULL)
-           _OPENSSL_isservice.p = GetProcAddress(h,"_OPENSSL_isservice");
-       if (_OPENSSL_isservice.p == NULL)
-           _OPENSSL_isservice.p = (void *)-1;
-    }
-
-    if (_OPENSSL_isservice.p != (void *)-1)
-       return (*_OPENSSL_isservice.f)();
-
-    (void)GetDesktopWindow(); /* return value is ignored */
-
-    h = GetProcessWindowStation();
-    if (h==NULL) return -1;
-
-    if (GetUserObjectInformationW (h,UOI_NAME,NULL,0,&len) ||
-       GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+int
+OPENSSL_isservice(void)
+       { HWINSTA h;
+       DWORD len;
+       WCHAR *name;
+               static union { void *p;
+               int (*f)(void);
+       } _OPENSSL_isservice = { NULL };
+
+       if (_OPENSSL_isservice.p == NULL) {
+               HANDLE h = GetModuleHandle(NULL);
+               if (h != NULL)
+                       _OPENSSL_isservice.p = GetProcAddress(h, "_OPENSSL_isservice");
+               if (_OPENSSL_isservice.p == NULL)
+                       _OPENSSL_isservice.p = (void *) - 1;
+       }
+
+       if (_OPENSSL_isservice.p != (void *) - 1)
+               return (*_OPENSSL_isservice.f)();
+
+       (void)GetDesktopWindow(); /* return value is ignored */
+
+       h = GetProcessWindowStation();
+       if (h == NULL)
+               return -1;
+
+       if (GetUserObjectInformationW (h, UOI_NAME, NULL, 0, &len) ||
+               GetLastError() != ERROR_INSUFFICIENT_BUFFER)
        return -1;
 
-    if (len>512) return -1;            /* paranoia */
-    len++,len&=~1;                     /* paranoia */
-    name=(WCHAR *)alloca(len+sizeof(WCHAR));
-    if (!GetUserObjectInformationW (h,UOI_NAME,name,len,&len))
-       return -1;
-
-    len++,len&=~1;                     /* paranoia */
-    name[len/sizeof(WCHAR)]=L'\0';     /* paranoia */
+       if (len > 512)
+               return -1;
+       /* paranoia */
+       len++, len&=~1;
+       /* paranoia */
+       name = (WCHAR *)alloca(len + sizeof(WCHAR));
+       if (!GetUserObjectInformationW (h, UOI_NAME, name, len, &len))
+               return -1;
+
+       len++, len&=~1;
+       /* paranoia */
+       name[len/sizeof(WCHAR)]=L'\0';  /* paranoia */
 #if 1
     /* This doesn't cover "interactive" services [working with real
      * WinSta0's] nor programs started non-interactively by Task
      * Scheduler [those are working with SAWinSta]. */
-    if (wcsstr(name,L"Service-0x"))    return 1;
+       if (wcsstr(name, L"Service-0x"))        return 1;
 #else
-    /* This covers all non-interactive programs such as services. */
-    if (!wcsstr(name,L"WinSta0"))      return 1;
+       /* This covers all non-interactive programs such as services. */
+       if (!wcsstr(name, L"WinSta0"))  return 1;
 #endif
-    else                               return 0;
+       else                            return 0;
 }
 #else
-int OPENSSL_isservice(void) { return 0; }
+       int OPENSSL_isservice(void) { return 0;
+}
 #endif
 
 void OPENSSL_showfatal (const char *fmta,...)
-{ va_list ap;
-  TCHAR buf[256];
-  const TCHAR *fmt;
+       { va_list ap;
+       TCHAR buf[256];
+       const TCHAR *fmt;
 #ifdef STD_ERROR_HANDLE        /* what a dirty trick! */
-  HANDLE h;
-
-    if ((h=GetStdHandle(STD_ERROR_HANDLE)) != NULL &&
-       GetFileType(h)!=FILE_TYPE_UNKNOWN)
-    {  /* must be console application */
-       va_start (ap,fmta);
-       vfprintf (stderr,fmta,ap);
-       va_end (ap);
-       return;
-    }
+       HANDLE h;
+
+       if ((h = GetStdHandle(STD_ERROR_HANDLE)) != NULL &&
+               GetFileType(h) != FILE_TYPE_UNKNOWN)
+               {       /* must be console application */
+               va_start (ap, fmta);
+               vfprintf (stderr, fmta, ap);
+               va_end (ap);
+               return;
+       }
 #endif
 
-    if (sizeof(TCHAR)==sizeof(char))
-       fmt=(const TCHAR *)fmta;
-    else do
-    { int    keepgoing;
-      size_t len_0=strlen(fmta)+1,i;
-      WCHAR *fmtw;
-
-       fmtw = (WCHAR *)alloca(len_0*sizeof(WCHAR));
-       if (fmtw == NULL) { fmt=(const TCHAR *)L"no stack?"; break; }
+       if (sizeof(TCHAR) == sizeof(char))
+               fmt = (const TCHAR *)fmta;
+       else do
+               { int    keepgoing;
+               size_t len_0 = strlen(fmta) + 1, i;
+               WCHAR *fmtw;
+
+               fmtw = (WCHAR *)alloca(len_0*sizeof(WCHAR));
+               if (fmtw == NULL) {
+                       fmt = (const TCHAR *)L"no stack?";
+                       break;
+               }
 
 #ifndef OPENSSL_NO_MULTIBYTE
-       if (!MultiByteToWideChar(CP_ACP,0,fmta,len_0,fmtw,len_0))
+               if (!MultiByteToWideChar(CP_ACP, 0, fmta, len_0, fmtw, len_0))
 #endif
-           for (i=0;i<len_0;i++) fmtw[i]=(WCHAR)fmta[i];
-
-       for (i=0;i<len_0;i++)
-       {   if (fmtw[i]==L'%') do
-           {   keepgoing=0;
-               switch (fmtw[i+1])
-               {   case L'0': case L'1': case L'2': case L'3': case L'4':
-                   case L'5': case L'6': case L'7': case L'8': case L'9':
-                   case L'.': case L'*':
-                   case L'-':  i++; keepgoing=1; break;
-                   case L's':  fmtw[i+1]=L'S';   break;
-                   case L'S':  fmtw[i+1]=L's';   break;
-                   case L'c':  fmtw[i+1]=L'C';   break;
-                   case L'C':  fmtw[i+1]=L'c';   break;
+               for (i = 0;i < len_0;i++) fmtw[i] = (WCHAR)fmta[i];
+
+               for (i = 0; i < len_0; i++)
+                               {   if (fmtw[i]==L'%') do
+                               {       keepgoing = 0;
+                               switch (fmtw[i + 1])
+                                       {   case L'0': case L'1': case L'2': case L'3': case L'4':
+                               case L'5': case L'6': case L'7': case L'8': case L'9':
+                               case L'.': case L'*':
+                               case L'-':
+                                       i++;
+                                       keepgoing = 1;
+                                       break;
+                               case L's':
+                                       fmtw[i + 1] = L'S';
+                                       break;
+                               case L'S':
+                                       fmtw[i + 1] = L's';
+                                       break;
+                               case L'c':
+                                       fmtw[i + 1] = L'C';
+                                       break;
+                               case L'C':
+                                       fmtw[i + 1] = L'c';
+                                       break;
+                               }
+                       } while (keepgoing);
                }
-           } while (keepgoing);
-       }
-       fmt = (const TCHAR *)fmtw;
-    } while (0);
+               fmt = (const TCHAR *)fmtw;
+       } while (0);
 
-    va_start (ap,fmta);
-    _vsntprintf (buf,sizeof(buf)/sizeof(TCHAR)-1,fmt,ap);
-    buf [sizeof(buf)/sizeof(TCHAR)-1] = _T('\0');
-    va_end (ap);
+       va_start (ap, fmta);
+       _vsntprintf (buf, sizeof(buf)/sizeof(TCHAR) - 1, fmt, ap);
+       buf [sizeof(buf)/sizeof(TCHAR) - 1] = _T('\0');
+       va_end (ap);
 
 #if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
-    /* this -------------v--- guards NT-specific calls */
-    if (check_winnt() && OPENSSL_isservice() > 0)
-    {  HANDLE h = RegisterEventSource(0,_T("OPENSSL"));
-       const TCHAR *pmsg=buf;
-       ReportEvent(h,EVENTLOG_ERROR_TYPE,0,0,0,1,0,&pmsg,0);
-       DeregisterEventSource(h);
-    }
-    else
+       /* this -------------v--- guards NT-specific calls */
+       if (check_winnt() && OPENSSL_isservice() > 0)
+                       {       HANDLE h = RegisterEventSource(0, _T("OPENSSL"));
+               const TCHAR *pmsg = buf;
+               ReportEvent(h, EVENTLOG_ERROR_TYPE, 0, 0, 0, 1, 0, &pmsg, 0);
+               DeregisterEventSource(h);
+       } else
 #endif
-       MessageBox (NULL,buf,_T("OpenSSL: FATAL"),MB_OK|MB_ICONSTOP);
+       MessageBox (NULL, buf, _T("OpenSSL: FATAL"), MB_OK|MB_ICONSTOP);
 }
 #else
-void OPENSSL_showfatal (const char *fmta,...)
-{ va_list ap;
+void OPENSSL_showfatal(const char *fmta, ...)
+{
+       va_list ap;
 
-    va_start (ap,fmta);
-    vfprintf (stderr,fmta,ap);
-    va_end (ap);
+       va_start (ap, fmta);
+       vfprintf (stderr, fmta, ap);
+       va_end (ap);
+}
+
+int OPENSSL_isservice(void)
+{
+       return 0;
 }
-int OPENSSL_isservice (void) { return 0; }
 #endif
 
-void OpenSSLDie(const char *file,int line,const char *assertion)
-       {
+void
+OpenSSLDie(const char *file, int line, const char *assertion)
+{
        OPENSSL_showfatal(
-               "%s(%d): OpenSSL internal error, assertion failed: %s\n",
-               file,line,assertion);
+           "%s(%d): OpenSSL internal error, assertion failed: %s\n",
+           file, line, assertion);
 #if !defined(_WIN32) || defined(__CYGWIN__)
        abort();
 #else
@@ -922,12 +946,16 @@ void OpenSSLDie(const char *file,int line,const char *assertion)
        raise(SIGABRT);
        _exit(3);
 #endif
-       }
+}
 
-void *OPENSSL_stderr(void)     { return stderr; }
+void *OPENSSL_stderr(void)
+{
+       return stderr;
+}
 
-int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len)
-       {
+int
+CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len)
+{
        size_t i;
        const unsigned char *a = in_a;
        const unsigned char *b = in_b;
@@ -937,4 +965,4 @@ int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len)
                x |= a[i] ^ b[i];
 
        return x;
-       }
+}
index 76bc595..baeba25 100644 (file)
@@ -154,23 +154,22 @@ extern "C" {
 typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
 /* Called when a new object is created */
 typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
-                                       int idx, long argl, void *argp);
+    int idx, long argl, void *argp);
 /* Called when an object is free()ed */
 typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
-                                       int idx, long argl, void *argp);
+    int idx, long argl, void *argp);
 /* Called when we need to dup an object */
-typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, 
-                                       int idx, long argl, void *argp);
+typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,
+    void *from_d, int idx, long argl, void *argp);
 #endif
 
 /* A generic structure to pass assorted data in a expandable way */
-typedef struct openssl_item_st
-       {
+typedef struct openssl_item_st {
        int code;
        void *value;            /* Not used for flag attributes */
        size_t value_size;      /* Max size of value for output, length for input */
        size_t *value_length;   /* Returned length of value for output */
-       } OPENSSL_ITEM;
+} OPENSSL_ITEM;
 
 
 /* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock
@@ -249,11 +248,10 @@ typedef struct openssl_item_st
    and deallocate locks in a dynamic fashion.  The following typedef
    makes this possible in a type-safe manner.  */
 /* struct CRYPTO_dynlock_value has to be defined by the application. */
-typedef struct
-       {
+typedef struct {
        int references;
        struct CRYPTO_dynlock_value *data;
-       } CRYPTO_dynlock;
+} CRYPTO_dynlock;
 
 
 /* The following can be used to detect memory leaks in the SSLeay library.
@@ -278,24 +276,22 @@ typedef struct
 /* predec of the BIO type */
 typedef struct bio_st BIO_dummy;
 
-struct crypto_ex_data_st
-       {
+struct crypto_ex_data_st {
        STACK_OF(void) *sk;
        int dummy; /* gcc is screwing up this data structure :-( */
-       };
+};
 DECLARE_STACK_OF(void)
 
 /* This stuff is basically class callback functions
  * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */
 
-typedef struct crypto_ex_data_func_st
-       {
+typedef struct crypto_ex_data_func_st {
        long argl;      /* Arbitary long */
        void *argp;     /* Arbitary void * */
        CRYPTO_EX_new *new_func;
        CRYPTO_EX_free *free_func;
        CRYPTO_EX_dup *dup_func;
-       } CRYPTO_EX_DATA_FUNCS;
+} CRYPTO_EX_DATA_FUNCS;
 
 DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
 
@@ -392,18 +388,18 @@ int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
 int CRYPTO_ex_data_new_class(void);
 /* Within a given class, get/register a new index */
 int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
-               CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
-               CRYPTO_EX_free *free_func);
+    CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
+    CRYPTO_EX_free *free_func);
 /* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given
  * class (invokes whatever per-class callbacks are applicable) */
 int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
 int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
-               CRYPTO_EX_DATA *from);
+    CRYPTO_EX_DATA *from);
 void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
 /* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index
  * (relative to the class type involved) */
 int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
-void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx);
+void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);
 /* This function cleans up all "ex_data" state. It mustn't be called under
  * potential race-conditions. */
 void CRYPTO_cleanup_all_ex_data(void);
@@ -411,22 +407,21 @@ void CRYPTO_cleanup_all_ex_data(void);
 int CRYPTO_get_new_lockid(char *name);
 
 int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */
-void CRYPTO_lock(int mode, int type,const char *file,int line);
-void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
-                                             const char *file,int line));
-void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
-               int line);
-void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
-                                             const char *file, int line));
-int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type,
-                                         const char *file,int line);
+void CRYPTO_lock(int mode, int type, const char *file, int line);
+void CRYPTO_set_locking_callback(void (*func)(int mode, int type,
+    const char *file, int line));
+void (*CRYPTO_get_locking_callback(void))(int mode, int type,
+    const char *file, int line);
+void CRYPTO_set_add_lock_callback(int (*func)(int *num, int mount, int type,
+    const char *file, int line));
+int (*CRYPTO_get_add_lock_callback(void))(int *num, int mount, int type,
+    const char *file, int line);
 
 /* Don't use this structure directly. */
-typedef struct crypto_threadid_st
-       {
+typedef struct crypto_threadid_st {
        void *ptr;
        unsigned long val;
-       } CRYPTO_THREADID;
+} CRYPTO_THREADID;
 /* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */
 void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val);
 void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);
@@ -443,8 +438,8 @@ unsigned long CRYPTO_thread_id(void);
 #endif
 
 const char *CRYPTO_get_lock_name(int type);
-int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
-                   int line);
+int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
+    int line);
 
 int CRYPTO_get_new_dynlockid(void);
 void CRYPTO_destroy_dynlockid(int i);
@@ -452,46 +447,43 @@ struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
 void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line));
 void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line));
 void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line));
-struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line);
-void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line);
-void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line);
+struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file, int line);
+void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line);
+void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file, int line);
 
 /* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
  * call the latter last if you need different functions */
-int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
+int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t), void (*f)(void *));
 int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
-int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int),
-                                void *(*r)(void *,size_t,const char *,int),
-                                void (*f)(void *));
-int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
-                                       void (*free_func)(void *));
-int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
-                                  void (*r)(void *,void *,int,const char *,int,int),
-                                  void (*f)(void *,int),
-                                  void (*so)(long),
-                                  long (*go)(void));
-void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
+int CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int),
+    void *(*r)(void *, size_t, const char *, int), void (*f)(void *));
+int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int),
+    void (*free_func)(void *));
+int CRYPTO_set_mem_debug_functions(
+    void (*m)(void *, int, const char *, int, int),
+    void (*r)(void *, void *, int, const char *, int, int),
+    void (*f)(void *, int), void (*so)(long), long (*go)(void));
+void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
+    void (**f)(void *));
 void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
-void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int),
-                                 void *(**r)(void *, size_t,const char *,int),
-                                 void (**f)(void *));
-void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
-                                        void (**f)(void *));
-void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
-                                   void (**r)(void *,void *,int,const char *,int,int),
-                                   void (**f)(void *,int),
-                                   void (**so)(long),
-                                   long (**go)(void));
+void CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int),
+    void *(**r)(void *, size_t, const char *, int), void (**f)(void *));
+void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int),
+    void (**f)(void *));
+void CRYPTO_get_mem_debug_functions(
+    void (**m)(void *, int, const char *, int, int),
+    void (**r)(void *, void *, int, const char *, int, int),
+    void (**f)(void *, int), void (**so)(long), long (**go)(void));
 
 void *CRYPTO_malloc_locked(int num, const char *file, int line);
 void CRYPTO_free_locked(void *ptr);
 void *CRYPTO_malloc(int num, const char *file, int line);
 char *CRYPTO_strdup(const char *str, const char *file, int line);
 void CRYPTO_free(void *ptr);
-void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
-void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
-                          int line);
-void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
+void *CRYPTO_realloc(void *addr, int num, const char *file, int line);
+void *CRYPTO_realloc_clean(void *addr, int old_num, int num,
+    const char *file, int line);
+void *CRYPTO_remalloc(void *addr, int num, const char *file, int line);
 
 void OPENSSL_cleanse(void *ptr, size_t len);
 
@@ -512,9 +504,9 @@ int CRYPTO_remove_all_info(void);
  * 0:  called before the actual memory allocation has taken place
  * 1:  called after the actual memory allocation has taken place
  */
-void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
-void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
-void CRYPTO_dbg_free(void *addr,int before_p);
+void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line, int before_p);
+void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, const char *file, int line, int before_p);
+void CRYPTO_dbg_free(void *addr, int before_p);
 /* Tell the debugging code about options.  By default, the following values
  * apply:
  *
@@ -536,7 +528,7 @@ typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
 void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
 
 /* die if we have to */
-void OpenSSLDie(const char *file,int line,const char *assertion);
+void OpenSSLDie(const char *file, int line, const char *assertion);
 #define OPENSSL_assert(e)       (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))
 
 unsigned long *OPENSSL_ia32cap_loc(void);
index ea9f25f..1fe92a4 100644 (file)
 #include "buildinf.h"
 #endif
 
-const char *SSLeay_version(int t)
-       {
+const char
+*SSLeay_version(int t)
+{
        if (t == SSLEAY_VERSION)
                return OPENSSL_VERSION_TEXT;
-       if (t == SSLEAY_BUILT_ON)
-               {
+       if (t == SSLEAY_BUILT_ON) {
 #ifdef DATE
-               static char buf[sizeof(DATE)+11];
+               static char buf[sizeof(DATE) + 11];
 
-               BIO_snprintf(buf,sizeof buf,"built on: %s",DATE);
-               return(buf);
+               BIO_snprintf(buf, sizeof buf, "built on: %s", DATE);
+               return (buf);
 #else
                return("built on: date not available");
 #endif
-               }
-       if (t == SSLEAY_CFLAGS)
-               {
+       }
+       if (t == SSLEAY_CFLAGS) {
 #ifdef CFLAGS
-               static char buf[sizeof(CFLAGS)+11];
+               static char buf[sizeof(CFLAGS) + 11];
 
-               BIO_snprintf(buf,sizeof buf,"compiler: %s",CFLAGS);
-               return(buf);
+               BIO_snprintf(buf, sizeof buf, "compiler: %s", CFLAGS);
+               return (buf);
 #else
                return("compiler: information not available");
 #endif
-               }
-       if (t == SSLEAY_PLATFORM)
-               {
+       }
+       if (t == SSLEAY_PLATFORM) {
 #ifdef PLATFORM
-               static char buf[sizeof(PLATFORM)+11];
+               static char buf[sizeof(PLATFORM) + 11];
 
-               BIO_snprintf(buf,sizeof buf,"platform: %s", PLATFORM);
-               return(buf);
+               BIO_snprintf(buf, sizeof buf, "platform: %s", PLATFORM);
+               return (buf);
 #else
                return("platform: information not available");
 #endif
-               }
-       if (t == SSLEAY_DIR)
-               {
+       }
+       if (t == SSLEAY_DIR) {
 #ifdef OPENSSLDIR
                return "OPENSSLDIR: \"" OPENSSLDIR "\"";
 #else
                return "OPENSSLDIR: N/A";
 #endif
-               }
-       return("not available");
-       }
-
-unsigned long SSLeay(void)
-       {
-       return(SSLEAY_VERSION_NUMBER);
        }
+       return("not available");
+}
 
+unsigned long
+SSLeay(void)
+{
+       return (SSLEAY_VERSION_NUMBER);
+}
index 43e53bc..2ac26ab 100644 (file)
@@ -4,7 +4,7 @@
 
 #include <openssl/e_os2.h>
 #if defined(PEDANTIC) || defined(__DECC) || defined(OPENSSL_SYS_MACOSX)
-static void *dummy=&dummy;
+static void *dummy = &dummy;
 #endif
 
 #else /*CHARSET_EBCDIC*/
@@ -30,38 +30,38 @@ static void *dummy=&dummy;
 
 /* Here's the bijective ebcdic-to-ascii table: */
 const unsigned char os_toascii[256] = {
-/*00*/ 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
-       0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
-/*10*/ 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
-       0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
-/*20*/ 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
-       0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /*................*/
-/*30*/ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
-       0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /*................*/
-/*40*/ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
-       0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* .........`.<(+|*/
-/*50*/ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
-       0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f, /*&.........!$*);.*/
-/*60*/ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
-       0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /*-/........^,%_>?*/
-/*70*/ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
-       0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /*..........:#@'="*/
-/*80*/ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
-       0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /*.abcdefghi......*/
-/*90*/ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
-       0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /*.jklmnopqr......*/
-/*a0*/ 0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
-       0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, /*..stuvwxyz......*/
-/*b0*/ 0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
-       0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7, /*...........[\]..*/
-/*c0*/ 0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
-       0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /*.ABCDEFGHI......*/
-/*d0*/ 0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
-       0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff, /*.JKLMNOPQR......*/
-/*e0*/ 0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
-       0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /*..STUVWXYZ......*/
-/*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
-       0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e  /*0123456789.{.}.~*/
+/*00*/  0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
+       0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
+/*10*/  0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
+       0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
+/*20*/  0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
+       0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /*................*/
+/*30*/  0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
+       0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /*................*/
+/*40*/  0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
+       0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* .........`.<(+|*/
+/*50*/  0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
+       0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f, /*&.........!$*);.*/
+/*60*/  0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
+       0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /*-/........^,%_>?*/
+/*70*/  0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
+       0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /*..........:#@'="*/
+/*80*/  0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+       0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /*.abcdefghi......*/
+/*90*/  0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+       0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /*.jklmnopqr......*/
+/*a0*/  0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+       0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, /*..stuvwxyz......*/
+/*b0*/  0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
+       0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7, /*...........[\]..*/
+/*c0*/  0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+       0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /*.ABCDEFGHI......*/
+/*d0*/  0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+       0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff, /*.JKLMNOPQR......*/
+/*e0*/  0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+       0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /*..STUVWXYZ......*/
+/*f0*/  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+       0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e  /*0123456789.{.}.~*/
 };
 
 
@@ -111,38 +111,38 @@ Bijective EBCDIC (character set IBM-1047) to US-ASCII table:
 This table is bijective - there are no ambigous or duplicate characters.
 */
 const unsigned char os_toascii[256] = {
-    0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f, /* 00-0f:           */
-    0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
-    0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97, /* 10-1f:           */
-    0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
-    0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b, /* 20-2f:           */
-    0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /* ................ */
-    0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30-3f:           */
-    0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /* ................ */
-    0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 40-4f:           */
-    0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /*  ...........<(+| */
-    0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 50-5f:           */
-    0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* &.........!$*);^ */
-    0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 60-6f:           */
-    0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* -/.........,%_>? */
-    0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 70-7f:           */
-    0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* .........`:#@'=" */
-    0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80-8f:           */
-    0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* .abcdefghi...... */
-    0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 90-9f:           */
-    0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* .jklmnopqr...... */
-    0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* a0-af:           */
-    0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae, /* .~stuvwxyz...[.. */
-    0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* b0-bf:           */
-    0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7, /* .............].. */
-    0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* c0-cf:           */
-    0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* {ABCDEFGHI...... */
-    0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* d0-df:           */
-    0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* }JKLMNOPQR...... */
-    0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* e0-ef:           */
-    0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* \.STUVWXYZ...... */
-    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* f0-ff:           */
-    0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f  /* 0123456789...... */
+       0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f, /* 00-0f:           */
+       0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
+       0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97, /* 10-1f:           */
+       0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
+       0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b, /* 20-2f:           */
+       0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /* ................ */
+       0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30-3f:           */
+       0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /* ................ */
+       0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 40-4f:           */
+       0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /*  ...........<(+| */
+       0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 50-5f:           */
+       0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* &.........!$*);^ */
+       0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 60-6f:           */
+       0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* -/.........,%_>? */
+       0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 70-7f:           */
+       0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* .........`:#@'=" */
+       0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80-8f:           */
+       0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* .abcdefghi...... */
+       0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 90-9f:           */
+       0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* .jklmnopqr...... */
+       0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* a0-af:           */
+       0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae, /* .~stuvwxyz...[.. */
+       0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* b0-bf:           */
+       0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7, /* .............].. */
+       0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* c0-cf:           */
+               0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* {ABCDEFGHI...... */
+               0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* d0-df:           */
+       0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* }JKLMNOPQR...... */
+       0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* e0-ef:           */
+       0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* \.STUVWXYZ...... */
+       0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* f0-ff:           */
+       0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f  /* 0123456789...... */
 };
 
 
@@ -151,38 +151,38 @@ The US-ASCII to EBCDIC (character set IBM-1047) table:
 This table is bijective (no ambiguous or duplicate characters)
 */
 const unsigned char os_toebcdic[256] = {
-    0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, /* 00-0f:           */
-    0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
-    0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, /* 10-1f:           */
-    0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
-    0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 20-2f:           */
-    0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /*  !"#$%&'()*+,-./ */
-    0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 30-3f:           */
-    0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0123456789:;<=>? */
-    0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 40-4f:           */
-    0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* @ABCDEFGHIJKLMNO */
-    0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 50-5f:           */
-    0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d, /* PQRSTUVWXYZ[\]^_ */
-    0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60-6f:           */
-    0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* `abcdefghijklmno */
-    0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 70-7f:           */
-    0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07, /* pqrstuvwxyz{|}~. */
-    0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08, /* 80-8f:           */
-    0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /* ................ */
-    0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17, /* 90-9f:           */
-    0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0xff, /* ................ */
-    0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, /* a0-af:           */
-    0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc, /* ................ */
-    0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, /* b0-bf:           */
-    0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /* ................ */
-    0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, /* c0-cf:           */
-    0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* ................ */
-    0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, /* d0-df:           */
-    0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59, /* ................ */
-    0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, /* e0-ef:           */
-    0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* ................ */
-    0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* f0-ff:           */
-    0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf  /* ................ */
+       0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, /* 00-0f:           */
+       0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
+       0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, /* 10-1f:           */
+       0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
+       0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 20-2f:           */
+       0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /*  !"#$%&'()*+,-./ */
+       0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 30-3f:           */
+       0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0123456789:;<=>? */
+       0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 40-4f:           */
+       0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* @ABCDEFGHIJKLMNO */
+       0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 50-5f:           */
+       0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d, /* PQRSTUVWXYZ[\]^_ */
+       0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60-6f:           */
+       0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* `abcdefghijklmno */
+       0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 70-7f:           */
+       0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07, /* pqrstuvwxyz{|}~. */
+       0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08, /* 80-8f:           */
+       0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /* ................ */
+       0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17, /* 90-9f:           */
+       0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0xff, /* ................ */
+       0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, /* a0-af:           */
+       0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc, /* ................ */
+       0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, /* b0-bf:           */
+       0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /* ................ */
+       0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, /* c0-cf:           */
+       0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* ................ */
+       0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, /* d0-df:           */
+       0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59, /* ................ */
+       0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, /* e0-ef:           */
+       0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* ................ */
+       0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* f0-ff:           */
+       0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf  /* ................ */
 };
 #endif /*_OSD_POSIX*/
 
@@ -195,27 +195,27 @@ const unsigned char os_toebcdic[256] = {
 void *
 ebcdic2ascii(void *dest, const void *srce, size_t count)
 {
-    unsigned char *udest = dest;
-    const unsigned char *usrce = srce;
+       unsigned char *udest = dest;
+       const unsigned char *usrce = srce;
 
-    while (count-- != 0) {
-        *udest++ = os_toascii[*usrce++];
-    }
+       while (count-- != 0) {
+               *udest++ = os_toascii[*usrce++];
+       }
 
-    return dest;
+       return dest;
 }
 
 void *
 ascii2ebcdic(void *dest, const void *srce, size_t count)
 {
-    unsigned char *udest = dest;
-    const unsigned char *usrce = srce;
+       unsigned char *udest = dest;
+       const unsigned char *usrce = srce;
 
-    while (count-- != 0) {
-        *udest++ = os_toebcdic[*usrce++];
-    }
+       while (count-- != 0) {
+               *udest++ = os_toebcdic[*usrce++];
+       }
 
-    return dest;
+       return dest;
 }
 
 #endif
index e2bc829..44bad59 100644 (file)
 #include <openssl/lhash.h>
 
 /* What an "implementation of ex_data functionality" looks like */
-struct st_CRYPTO_EX_DATA_IMPL
-       {
+struct st_CRYPTO_EX_DATA_IMPL {
        /*********************/
        /* GLOBAL OPERATIONS */
        /* Return a new class index */
@@ -154,79 +153,83 @@ struct st_CRYPTO_EX_DATA_IMPL
        /* PER-CLASS OPERATIONS */
        /* Get a new method index within a class */
        int (*cb_get_new_index)(int class_index, long argl, void *argp,
-                       CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
-                       CRYPTO_EX_free *free_func);
+           CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
+           CRYPTO_EX_free *free_func);
        /* Initialise a new CRYPTO_EX_DATA of a given class */
        int (*cb_new_ex_data)(int class_index, void *obj,
-                       CRYPTO_EX_DATA *ad);
+           CRYPTO_EX_DATA *ad);
        /* Duplicate a CRYPTO_EX_DATA of a given class onto a copy */
        int (*cb_dup_ex_data)(int class_index, CRYPTO_EX_DATA *to,
-                       CRYPTO_EX_DATA *from);
+           CRYPTO_EX_DATA *from);
        /* Cleanup a CRYPTO_EX_DATA of a given class */
        void (*cb_free_ex_data)(int class_index, void *obj,
-                       CRYPTO_EX_DATA *ad);
-       };
+           CRYPTO_EX_DATA *ad);
+};
 
 /* The implementation we use at run-time */
 static const CRYPTO_EX_DATA_IMPL *impl = NULL;
 
 /* To call "impl" functions, use this macro rather than referring to 'impl' directly, eg.
- * EX_IMPL(get_new_index)(...); */
+ * EX_IMPL(get_new_index)(...);
+*/
 #define EX_IMPL(a) impl->cb_##a
 
 /* Predeclare the "default" ex_data implementation */
 static int int_new_class(void);
 static void int_cleanup(void);
 static int int_get_new_index(int class_index, long argl, void *argp,
-               CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
-               CRYPTO_EX_free *free_func);
+    CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
+    CRYPTO_EX_free *free_func);
 static int int_new_ex_data(int class_index, void *obj,
-               CRYPTO_EX_DATA *ad);
+    CRYPTO_EX_DATA *ad);
 static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
-               CRYPTO_EX_DATA *from);
+    CRYPTO_EX_DATA *from);
 static void int_free_ex_data(int class_index, void *obj,
-               CRYPTO_EX_DATA *ad);
-static CRYPTO_EX_DATA_IMPL impl_default =
-       {
+    CRYPTO_EX_DATA *ad);
+
+static CRYPTO_EX_DATA_IMPL impl_default = {
        int_new_class,
        int_cleanup,
        int_get_new_index,
        int_new_ex_data,
        int_dup_ex_data,
        int_free_ex_data
-       };
+};
 
 /* Internal function that checks whether "impl" is set and if not, sets it to
  * the default. */
-static void impl_check(void)
-       {
+static void
+impl_check(void)
+{
        CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
-       if(!impl)
+       if (!impl)
                impl = &impl_default;
        CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
-       }
+}
 /* A macro wrapper for impl_check that first uses a non-locked test before
  * invoking the function (which checks again inside a lock). */
 #define IMPL_CHECK if(!impl) impl_check();
 
 /* API functions to get/set the "ex_data" implementation */
-const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void)
-       {
+const CRYPTO_EX_DATA_IMPL
+*CRYPTO_get_ex_data_implementation(void)
+{
        IMPL_CHECK
        return impl;
-       }
-int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i)
-       {
+}
+
+int
+CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i)
+{
        int toret = 0;
        CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
-       if(!impl)
-               {
+       if (!impl) {
                impl = i;
                toret = 1;
-               }
+       }
        CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
        return toret;
-       }
+}
 
 /****************************************************************************/
 /* Interal (default) implementation of "ex_data" support. API functions are
@@ -249,288 +252,283 @@ DECLARE_LHASH_OF(EX_CLASS_ITEM);
 static LHASH_OF(EX_CLASS_ITEM) *ex_data = NULL;
 
 /* The callbacks required in the "ex_data" hash table */
-static unsigned long ex_class_item_hash(const EX_CLASS_ITEM *a)
-       {
+static unsigned long
+ex_class_item_hash(const EX_CLASS_ITEM *a)
+{
        return a->class_index;
-       }
+}
+
 static IMPLEMENT_LHASH_HASH_FN(ex_class_item, EX_CLASS_ITEM)
 
-static int ex_class_item_cmp(const EX_CLASS_ITEM *a, const EX_CLASS_ITEM *b)
-       {
+static int
+ex_class_item_cmp(const EX_CLASS_ITEM *a, const EX_CLASS_ITEM *b)
+{
        return a->class_index - b->class_index;
-       }
+}
+
 static IMPLEMENT_LHASH_COMP_FN(ex_class_item, EX_CLASS_ITEM)
 
 /* Internal functions used by the "impl_default" implementation to access the
  * state */
 
-static int ex_data_check(void)
-       {
+static int
+ex_data_check(void)
+{
        int toret = 1;
        CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
-       if(!ex_data
-          && (ex_data = lh_EX_CLASS_ITEM_new()) == NULL)
-               toret = 0;
+       if (!ex_data
+               && (ex_data = lh_EX_CLASS_ITEM_new()) == NULL)
+       toret = 0;
        CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
        return toret;
-       }
+}
 /* This macros helps reduce the locking from repeated checks because the
  * ex_data_check() function checks ex_data again inside a lock. */
 #define EX_DATA_CHECK(iffail) if(!ex_data && !ex_data_check()) {iffail}
 
 /* This "inner" callback is used by the callback function that follows it */
-static void def_cleanup_util_cb(CRYPTO_EX_DATA_FUNCS *funcs)
-       {
+static void
+def_cleanup_util_cb(CRYPTO_EX_DATA_FUNCS *funcs)
+{
        OPENSSL_free(funcs);
-       }
+}
 
 /* This callback is used in lh_doall to destroy all EX_CLASS_ITEM values from
  * "ex_data" prior to the ex_data hash table being itself destroyed. Doesn't do
  * any locking. */
-static void def_cleanup_cb(void *a_void)
-       {
+static void
+def_cleanup_cb(void *a_void)
+{
        EX_CLASS_ITEM *item = (EX_CLASS_ITEM *)a_void;
        sk_CRYPTO_EX_DATA_FUNCS_pop_free(item->meth, def_cleanup_util_cb);
        OPENSSL_free(item);
-       }
+}
 
 /* Return the EX_CLASS_ITEM from the "ex_data" hash table that corresponds to a
  * given class. Handles locking. */
-static EX_CLASS_ITEM *def_get_class(int class_index)
-       {
+static EX_CLASS_ITEM
+*def_get_class(int class_index)
+{
        EX_CLASS_ITEM d, *p, *gen;
        EX_DATA_CHECK(return NULL;)
        d.class_index = class_index;
        CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
        p = lh_EX_CLASS_ITEM_retrieve(ex_data, &d);
-       if(!p)
-               {
+       if (!p) {
                gen = OPENSSL_malloc(sizeof(EX_CLASS_ITEM));
-               if(gen)
-                       {
+               if (gen) {
                        gen->class_index = class_index;
                        gen->meth_num = 0;
                        gen->meth = sk_CRYPTO_EX_DATA_FUNCS_new_null();
-                       if(!gen->meth)
+                       if (!gen->meth)
                                OPENSSL_free(gen);
-                       else
-                               {
+                       else {
                                /* Because we're inside the ex_data lock, the
                                 * return value from the insert will be NULL */
                                (void)lh_EX_CLASS_ITEM_insert(ex_data, gen);
                                p = gen;
-                               }
                        }
                }
+       }
        CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
-       if(!p)
-               CRYPTOerr(CRYPTO_F_DEF_GET_CLASS,ERR_R_MALLOC_FAILURE);
+       if (!p)
+               CRYPTOerr(CRYPTO_F_DEF_GET_CLASS, ERR_R_MALLOC_FAILURE);
        return p;
-       }
+}
 
 /* Add a new method to the given EX_CLASS_ITEM and return the corresponding
  * index (or -1 for error). Handles locking. */
-static int def_add_index(EX_CLASS_ITEM *item, long argl, void *argp,
-               CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
-               CRYPTO_EX_free *free_func)
-       {
+static int
+def_add_index(EX_CLASS_ITEM *item, long argl, void *argp,
+    CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
+{
        int toret = -1;
        CRYPTO_EX_DATA_FUNCS *a = (CRYPTO_EX_DATA_FUNCS *)OPENSSL_malloc(
-                                       sizeof(CRYPTO_EX_DATA_FUNCS));
-       if(!a)
-               {
-               CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX,ERR_R_MALLOC_FAILURE);
+       sizeof(CRYPTO_EX_DATA_FUNCS));
+       if (!a) {
+               CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX, ERR_R_MALLOC_FAILURE);
                return -1;
-               }
-       a->argl=argl;
-       a->argp=argp;
-       a->new_func=new_func;
-       a->dup_func=dup_func;
-       a->free_func=free_func;
+       }
+       a->argl = argl;
+       a->argp = argp;
+       a->new_func = new_func;
+       a->dup_func = dup_func;
+       a->free_func = free_func;
        CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
-       while (sk_CRYPTO_EX_DATA_FUNCS_num(item->meth) <= item->meth_num)
-               {
-               if (!sk_CRYPTO_EX_DATA_FUNCS_push(item->meth, NULL))
-                       {
-                       CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX,ERR_R_MALLOC_FAILURE);
+       while (sk_CRYPTO_EX_DATA_FUNCS_num(item->meth) <= item->meth_num) {
+               if (!sk_CRYPTO_EX_DATA_FUNCS_push(item->meth, NULL)) {
+                       CRYPTOerr(CRYPTO_F_DEF_ADD_INDEX, ERR_R_MALLOC_FAILURE);
                        OPENSSL_free(a);
                        goto err;
-                       }
                }
+       }
        toret = item->meth_num++;
        (void)sk_CRYPTO_EX_DATA_FUNCS_set(item->meth, toret, a);
 err:
        CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
        return toret;
-       }
+}
 
 /**************************************************************/
 /* The functions in the default CRYPTO_EX_DATA_IMPL structure */
 
-static int int_new_class(void)
-       {
+static int
+int_new_class(void)
+{
        int toret;
        CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
        toret = ex_class++;
        CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);
        return toret;
-       }
+}
 
-static void int_cleanup(void)
-       {
+static void
+int_cleanup(void)
+{
        EX_DATA_CHECK(return;)
        lh_EX_CLASS_ITEM_doall(ex_data, def_cleanup_cb);
        lh_EX_CLASS_ITEM_free(ex_data);
        ex_data = NULL;
        impl = NULL;
-       }
+}
 
-static int int_get_new_index(int class_index, long argl, void *argp,
-               CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
-               CRYPTO_EX_free *free_func)
-       {
+static int
+int_get_new_index(int class_index, long argl, void *argp,
+    CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
+CRYPTO_EX_free *free_func)
+{
        EX_CLASS_ITEM *item = def_get_class(class_index);
-       if(!item)
+       if (!item)
                return -1;
        return def_add_index(item, argl, argp, new_func, dup_func, free_func);
-       }
+}
 
 /* Thread-safe by copying a class's array of "CRYPTO_EX_DATA_FUNCS" entries in
  * the lock, then using them outside the lock. NB: Thread-safety only applies to
  * the global "ex_data" state (ie. class definitions), not thread-safe on 'ad'
  * itself. */
-static int int_new_ex_data(int class_index, void *obj,
-               CRYPTO_EX_DATA *ad)
-       {
-       int mx,i;
+static int
+int_new_ex_data(int class_index, void *obj,
+    CRYPTO_EX_DATA *ad)
+{
+       int mx, i;
        void *ptr;
        CRYPTO_EX_DATA_FUNCS **storage = NULL;
        EX_CLASS_ITEM *item = def_get_class(class_index);
-       if(!item)
+       if (!item)
                /* error is already set */
                return 0;
        ad->sk = NULL;
        CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
        mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
-       if(mx > 0)
-               {
+       if (mx > 0) {
                storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS*));
-               if(!storage)
+               if (!storage)
                        goto skip;
-               for(i = 0; i < mx; i++)
-                       storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth,i);
-               }
+               for (i = 0; i < mx; i++)
+                       storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth, i);
+       }
 skip:
        CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);
-       if((mx > 0) && !storage)
-               {
-               CRYPTOerr(CRYPTO_F_INT_NEW_EX_DATA,ERR_R_MALLOC_FAILURE);
+       if ((mx > 0) && !storage) {
+               CRYPTOerr(CRYPTO_F_INT_NEW_EX_DATA, ERR_R_MALLOC_FAILURE);
                return 0;
-               }
-       for(i = 0; i < mx; i++)
-               {
-               if(storage[i] && storage[i]->new_func)
-                       {
+       }
+       for (i = 0; i < mx; i++) {
+               if (storage[i] && storage[i]->new_func) {
                        ptr = CRYPTO_get_ex_data(ad, i);
-                       storage[i]->new_func(obj,ptr,ad,i,
-                               storage[i]->argl,storage[i]->argp);
-                       }
+                       storage[i]->new_func(obj, ptr, ad, i,
+                       storage[i]->argl, storage[i]->argp);
                }
-       if(storage)
+       }
+       if (storage)
                OPENSSL_free(storage);
        return 1;
-       }
+}
 
 /* Same thread-safety notes as for "int_new_ex_data" */
-static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
-               CRYPTO_EX_DATA *from)
-       {
+static int
+int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
+    CRYPTO_EX_DATA *from)
+{
        int mx, j, i;
        char *ptr;
        CRYPTO_EX_DATA_FUNCS **storage = NULL;
        EX_CLASS_ITEM *item;
-       if(!from->sk)
+       if (!from->sk)
                /* 'to' should be "blank" which *is* just like 'from' */
                return 1;
-       if((item = def_get_class(class_index)) == NULL)
+       if ((item = def_get_class(class_index)) == NULL)
                return 0;
        CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
        mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
        j = sk_void_num(from->sk);
-       if(j < mx)
+       if (j < mx)
                mx = j;
-       if(mx > 0)
-               {
+       if (mx > 0) {
                storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS*));
-               if(!storage)
+               if (!storage)
                        goto skip;
-               for(i = 0; i < mx; i++)
-                       storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth,i);
-               }
+               for (i = 0; i < mx; i++)
+                       storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth, i);
+       }
 skip:
        CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);
-       if((mx > 0) && !storage)
-               {
-               CRYPTOerr(CRYPTO_F_INT_DUP_EX_DATA,ERR_R_MALLOC_FAILURE);
+       if ((mx > 0) && !storage) {
+               CRYPTOerr(CRYPTO_F_INT_DUP_EX_DATA, ERR_R_MALLOC_FAILURE);
                return 0;
-               }
-       for(i = 0; i < mx; i++)
-               {
+       }
+       for (i = 0; i < mx; i++) {
                ptr = CRYPTO_get_ex_data(from, i);
-               if(storage[i] && storage[i]->dup_func)
-                       storage[i]->dup_func(to,from,&ptr,i,
-                               storage[i]->argl,storage[i]->argp);
-               CRYPTO_set_ex_data(to,i,ptr);
-               }
-       if(storage)
+               if (storage[i] && storage[i]->dup_func)
+                       storage[i]->dup_func(to, from, &ptr, i,
+                           storage[i]->argl, storage[i]->argp);
+               CRYPTO_set_ex_data(to, i, ptr);
+       }
+       if (storage)
                OPENSSL_free(storage);
        return 1;
-       }
+}
 
 /* Same thread-safety notes as for "int_new_ex_data" */
-static void int_free_ex_data(int class_index, void *obj,
-               CRYPTO_EX_DATA *ad)
-       {
-       int mx,i;
+static void
+int_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
+{
+       int mx, i;
        EX_CLASS_ITEM *item;
        void *ptr;
        CRYPTO_EX_DATA_FUNCS **storage = NULL;
-       if((item = def_get_class(class_index)) == NULL)
+       if ((item = def_get_class(class_index)) == NULL)
                return;
        CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
        mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
-       if(mx > 0)
-               {
+       if (mx > 0) {
                storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS*));
-               if(!storage)
+               if (!storage)
                        goto skip;
-               for(i = 0; i < mx; i++)
-                       storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth,i);
-               }
+               for (i = 0; i < mx; i++)
+                       storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth, i);
+       }
 skip:
        CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);
-       if((mx > 0) && !storage)
-               {
-               CRYPTOerr(CRYPTO_F_INT_FREE_EX_DATA,ERR_R_MALLOC_FAILURE);
+       if ((mx > 0) && !storage) {
+               CRYPTOerr(CRYPTO_F_INT_FREE_EX_DATA, ERR_R_MALLOC_FAILURE);
                return;
+       }
+       for (i = 0; i < mx; i++) {
+               if (storage[i] && storage[i]->free_func) {
+                       ptr = CRYPTO_get_ex_data(ad, i);
+                       storage[i]->free_func(obj, ptr, ad, i,
+                       storage[i]->argl, storage[i]->argp);
                }
-       for(i = 0; i < mx; i++)
-               {
-               if(storage[i] && storage[i]->free_func)
-                       {
-                       ptr = CRYPTO_get_ex_data(ad,i);
-                       storage[i]->free_func(obj,ptr,ad,i,
-                               storage[i]->argl,storage[i]->argp);
-                       }
-               }
-       if(storage)
+       }
+       if (storage)
                OPENSSL_free(storage);
-       if(ad->sk)
-               {
+       if (ad->sk) {
                sk_void_free(ad->sk);
-               ad->sk=NULL;
-               }
+               ad->sk = NULL;
        }
+}
 
 /********************************************************************/
 /* API functions that defer all "state" operations to the "ex_data"
@@ -538,99 +536,101 @@ skip:
 
 /* Obtain an index for a new class (not the same as getting a new index within
  * an existing class - this is actually getting a new *class*) */
-int CRYPTO_ex_data_new_class(void)
-       {
+int
+CRYPTO_ex_data_new_class(void)
+{
        IMPL_CHECK
        return EX_IMPL(new_class)();
-       }
+}
 
 /* Release all "ex_data" state to prevent memory leaks. This can't be made
  * thread-safe without overhauling a lot of stuff, and shouldn't really be
  * called under potential race-conditions anyway (it's for program shutdown
  * after all). */
-void CRYPTO_cleanup_all_ex_data(void)
-       {
+void
+CRYPTO_cleanup_all_ex_data(void)
+{
        IMPL_CHECK
        EX_IMPL(cleanup)();
-       }
+}
 
 /* Inside an existing class, get/register a new index. */
-int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
-               CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
-               CRYPTO_EX_free *free_func)
-       {
+int
+CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
+    CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
+{
        int ret = -1;
 
        IMPL_CHECK
        ret = EX_IMPL(get_new_index)(class_index,
-                       argl, argp, new_func, dup_func, free_func);
+       argl, argp, new_func, dup_func, free_func);
        return ret;
-       }
+}
 
 /* Initialise a new CRYPTO_EX_DATA for use in a particular class - including
  * calling new() callbacks for each index in the class used by this variable */
-int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
-       {
+int
+CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
+{
        IMPL_CHECK
        return EX_IMPL(new_ex_data)(class_index, obj, ad);
-       }
+}
 
 /* Duplicate a CRYPTO_EX_DATA variable - including calling dup() callbacks for
  * each index in the class used by this variable */
-int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
-            CRYPTO_EX_DATA *from)
-       {
+int
+CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from)
+{
        IMPL_CHECK
        return EX_IMPL(dup_ex_data)(class_index, to, from);
-       }
+}
 
 /* Cleanup a CRYPTO_EX_DATA variable - including calling free() callbacks for
  * each index in the class used by this variable */
-void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
-       {
+void
+CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
+{
        IMPL_CHECK
        EX_IMPL(free_ex_data)(class_index, obj, ad);
-       }
+}
 
 /* For a given CRYPTO_EX_DATA variable, set the value corresponding to a
  * particular index in the class used by this variable */
-int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val)
-       {
+int
+CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val)
+{
        int i;
 
-       if (ad->sk == NULL)
-               {
-               if ((ad->sk=sk_void_new_null()) == NULL)
-                       {
-                       CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA,ERR_R_MALLOC_FAILURE);
-                       return(0);
-                       }
+       if (ad->sk == NULL) {
+               if ((ad->sk = sk_void_new_null()) == NULL) {
+                       CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA, ERR_R_MALLOC_FAILURE);
+                       return (0);
                }
-       i=sk_void_num(ad->sk);
-
-       while (i <= idx)
-               {
-               if (!sk_void_push(ad->sk,NULL))
-                       {
-                       CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA,ERR_R_MALLOC_FAILURE);
-                       return(0);
-                       }
-               i++;
+       }
+       i = sk_void_num(ad->sk);
+
+       while (i <= idx) {
+               if (!sk_void_push(ad->sk, NULL)) {
+                       CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA, ERR_R_MALLOC_FAILURE);
+                       return (0);
                }
-       sk_void_set(ad->sk,idx,val);
-       return(1);
+               i++;
        }
+       sk_void_set(ad->sk, idx, val);
+       return (1);
+}
 
 /* For a given CRYPTO_EX_DATA_ variable, get the value corresponding to a
  * particular index in the class used by this variable */
-void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
-       {
+void
+*CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
+{
        if (ad->sk == NULL)
-               return(0);
+               return (0);
        else if (idx >= sk_void_num(ad->sk))
-               return(0);
+               return (0);
        else
-               return(sk_void_value(ad->sk,idx));
-       }
+               return (sk_void_value(ad->sk, idx));
+}
 
 IMPLEMENT_STACK_OF(CRYPTO_EX_DATA_FUNCS)
index 09f1174..1788ed2 100644 (file)
@@ -3,5 +3,5 @@
 #ifdef OPENSSL_FIPS
 # include "fips_err.h"
 #else
-static void *dummy=&dummy;
+static void *dummy = &dummy;
 #endif
index bb73819..bfb610e 100644 (file)
 #  if defined(__POWERPC__)
 #   define ROTATE(a,n) __rlwinm(a,n,0,31)
 #  elif defined(__MC68K__)
-    /* Motorola specific tweak. <appro@fy.chalmers.se> */
+/* Motorola specific tweak. <appro@fy.chalmers.se> */
 #   define ROTATE(a,n) ( n<24 ? __rol(a,n) : __ror(a,32-n) )
 #  else
 #   define ROTATE(a,n) __rol(a,n)
 #endif
 #if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
 # ifndef B_ENDIAN
-   /* See comment in DATA_ORDER_IS_BIG_ENDIAN section. */
+/* See comment in DATA_ORDER_IS_BIG_ENDIAN section. */
 #  define HOST_c2l(c,l)        ((l)=*((const unsigned int *)(c)), (c)+=4, l)
 #  define HOST_l2c(l,c)        (*((unsigned int *)(c))=(l), (c)+=4, l)
 # endif
  * Time for some action:-)
  */
 
-int HASH_UPDATE (HASH_CTX *c, const void *data_, size_t len)
-       {
-       const unsigned char *data=data_;
+int
+HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len)
+{
+       const unsigned char *data = data_;
        unsigned char *p;
        HASH_LONG l;
        size_t n;
 
-       if (len==0) return 1;
+       if (len == 0)
+               return 1;
 
-       l=(c->Nl+(((HASH_LONG)len)<<3))&0xffffffffUL;
+       l = (c->Nl + (((HASH_LONG)len) << 3))&0xffffffffUL;
        /* 95-05-24 eay Fixed a bug with the overflow handling, thanks to
         * Wei Dai <weidai@eskimo.com> for pointing it out. */
        if (l < c->Nl) /* overflow */
                c->Nh++;
        c->Nh+=(HASH_LONG)(len>>29);    /* might cause compiler warning on 16-bit */
-       c->Nl=l;
+       c->Nl = l;
 
        n = c->num;
-       if (n != 0)
-               {
-               p=(unsigned char *)c->data;
-
-               if (len >= HASH_CBLOCK || len+n >= HASH_CBLOCK)
-                       {
-                       memcpy (p+n,data,HASH_CBLOCK-n);
-                       HASH_BLOCK_DATA_ORDER (c,p,1);
-                       n      = HASH_CBLOCK-n;
-                       data  += n;
-                       len   -= n;
+       if (n != 0) {
+               p = (unsigned char *)c->data;
+
+               if (len >= HASH_CBLOCK || len + n >= HASH_CBLOCK) {
+                       memcpy (p + n, data, HASH_CBLOCK - n);
+                       HASH_BLOCK_DATA_ORDER (c, p, 1);
+                       n = HASH_CBLOCK - n;
+                       data += n;
+                       len -= n;
                        c->num = 0;
                        memset (p,0,HASH_CBLOCK);       /* keep it zeroed */
-                       }
-               else
-                       {
-                       memcpy (p+n,data,len);
+               } else {
+                       memcpy (p + n, data, len);
                        c->num += (unsigned int)len;
                        return 1;
-                       }
                }
+       }
 
        n = len/HASH_CBLOCK;
-       if (n > 0)
-               {
-               HASH_BLOCK_DATA_ORDER (c,data,n);
+       if (n > 0) {
+               HASH_BLOCK_DATA_ORDER (c, data, n);
                n    *= HASH_CBLOCK;
                data += n;
-               len  -= n;
-               }
+               len -= n;
+       }
 
-       if (len != 0)
-               {
+       if (len != 0) {
                p = (unsigned char *)c->data;
                c->num = (unsigned int)len;
-               memcpy (p,data,len);
-               }
-       return 1;
+               memcpy (p, data, len);
        }
+       return 1;
+}
 
 
 void HASH_TRANSFORM (HASH_CTX *c, const unsigned char *data)
-       {
-       HASH_BLOCK_DATA_ORDER (c,data,1);
-       }
+{
+       HASH_BLOCK_DATA_ORDER (c, data, 1);
+}
 
 
 int HASH_FINAL (unsigned char *md, HASH_CTX *c)
-       {
+{
        unsigned char *p = (unsigned char *)c->data;
        size_t n = c->num;
 
        p[n] = 0x80; /* there is always room for one */
        n++;
 
-       if (n > (HASH_CBLOCK-8))
-               {
-               memset (p+n,0,HASH_CBLOCK-n);
-               n=0;
-               HASH_BLOCK_DATA_ORDER (c,p,1);
-               }
-       memset (p+n,0,HASH_CBLOCK-8-n);
+       if (n > (HASH_CBLOCK - 8)) {
+               memset (p + n, 0, HASH_CBLOCK - n);
+               n = 0;
+               HASH_BLOCK_DATA_ORDER (c, p, 1);
+       }
+       memset (p + n, 0, HASH_CBLOCK - 8 - n);
 
-       p += HASH_CBLOCK-8;
+       p += HASH_CBLOCK - 8;
 #if   defined(DATA_ORDER_IS_BIG_ENDIAN)
-       (void)HOST_l2c(c->Nh,p);
-       (void)HOST_l2c(c->Nl,p);
+       (void)HOST_l2c(c->Nh, p);
+       (void)HOST_l2c(c->Nl, p);
 #elif defined(DATA_ORDER_IS_LITTLE_ENDIAN)
-       (void)HOST_l2c(c->Nl,p);
-       (void)HOST_l2c(c->Nh,p);
+       (void)HOST_l2c(c->Nl, p);
+       (void)HOST_l2c(c->Nh, p);
 #endif
        p -= HASH_CBLOCK;
-       HASH_BLOCK_DATA_ORDER (c,p,1);
-       c->num=0;
-       memset (p,0,HASH_CBLOCK);
+       HASH_BLOCK_DATA_ORDER (c, p, 1);
+       c->num = 0;
+       memset (p, 0, HASH_CBLOCK);
 
 #ifndef HASH_MAKE_STRING
 #error "HASH_MAKE_STRING must be defined!"
 #else
-       HASH_MAKE_STRING(c,md);
+       HASH_MAKE_STRING(c, md);
 #endif
 
        return 1;
-       }
+}
 
 #ifndef MD32_REG_T
 #if defined(__alpha) || defined(__sparcv9) || defined(__mips)
index 55e829d..86e5ff1 100644 (file)
 #include "cryptlib.h"
 
 
-static int allow_customize = 1;      /* we provide flexible functions for */
-static int allow_customize_debug = 1;/* exchanging memory-related functions at
-                                      * run-time, but this must be done
-                                      * before any blocks are actually
-                                      * allocated; or we'll run into huge
-                                      * problems when malloc/free pairs
-                                      * don't match etc. */
-
-
+static int allow_customize = 1;
+/* we provide flexible functions for */
+static int allow_customize_debug = 1;/* exchanging memory - related functions at
+                                       * run - time, but this must be done
+                                       * before any blocks are actually
+                                       * allocated; or we'll run into huge
+                                       * problems when malloc/free pairs
+                                       * don't match etc. */
 
 /* the following pointers may be changed as long as 'allow_customize' is set */
 
-static void *(*malloc_func)(size_t)         = malloc;
-static void *default_malloc_ex(size_t num, const char *file, int line)
-       { return malloc_func(num); }
-static void *(*malloc_ex_func)(size_t, const char *file, int line)
-        = default_malloc_ex;
-
-static void *(*realloc_func)(void *, size_t)= realloc;
-static void *default_realloc_ex(void *str, size_t num,
-        const char *file, int line)
-       { return realloc_func(str,num); }
-static void *(*realloc_ex_func)(void *, size_t, const char *file, int line)
-        = default_realloc_ex;
-
-static void (*free_func)(void *)            = free;
-
-static void *(*malloc_locked_func)(size_t)  = malloc;
-static void *default_malloc_locked_ex(size_t num, const char *file, int line)
-       { return malloc_locked_func(num); }
-static void *(*malloc_locked_ex_func)(size_t, const char *file, int line)
-        = default_malloc_locked_ex;
-
-static void (*free_locked_func)(void *)     = free;
-
+static void *(*malloc_func)(size_t) = malloc;
+static void
+*default_malloc_ex(size_t num, const char *file, int line)
+{
+       return malloc_func(num);
+}
+static void *(*malloc_ex_func)(size_t, const char *file, int line) =
+    default_malloc_ex;
+
+static void *(*realloc_func)(void *, size_t) = realloc;
+static void
+*default_realloc_ex(void *str, size_t num, const char *file, int line)
+{
+       return realloc_func(str, num);
+}
+static void *(*realloc_ex_func)(void *, size_t, const char *file, int line) =
+    default_realloc_ex;
+
+static void (*free_func)(void *) = free;
+
+static void *(*malloc_locked_func)(size_t) = malloc;
+static void
+*default_malloc_locked_ex(size_t num, const char *file, int line)
+{
+       return malloc_locked_func(num);
+}
+static void *(*malloc_locked_ex_func)(size_t, const char *file, int line) =
+    default_malloc_locked_ex;
+
+static void (*free_locked_func)(void *) = free;
 
 
 /* may be changed as long as 'allow_customize_debug' is set */
 /* XXX use correct function pointer types */
 #ifdef CRYPTO_MDEBUG
 /* use default functions from mem_dbg.c */
-static void (*malloc_debug_func)(void *,int,const char *,int,int)
-       = CRYPTO_dbg_malloc;
-static void (*realloc_debug_func)(void *,void *,int,const char *,int,int)
-       = CRYPTO_dbg_realloc;
-static void (*free_debug_func)(void *,int) = CRYPTO_dbg_free;
+static void (*malloc_debug_func)(void *, int, const char *, int, int) =
+    CRYPTO_dbg_malloc;
+static void (*realloc_debug_func)(void *, void *, int, const char *, int, int) =
+    CRYPTO_dbg_realloc;
+static void (*free_debug_func)(void *, int) = CRYPTO_dbg_free;
 static void (*set_debug_options_func)(long) = CRYPTO_dbg_set_options;
 static long (*get_debug_options_func)(void) = CRYPTO_dbg_get_options;
 #else
 /* applications can use CRYPTO_malloc_debug_init() to select above case
  * at run-time */
-static void (*malloc_debug_func)(void *,int,const char *,int,int) = NULL;
-static void (*realloc_debug_func)(void *,void *,int,const char *,int,int)
-       = NULL;
-static void (*free_debug_func)(void *,int) = NULL;
+static void (*malloc_debug_func)(void *, int, const char *, int, int) = NULL;
+static void (*realloc_debug_func)(void *, void *, int, const char *, int, int) =
+    NULL;
+static void (*free_debug_func)(void *, int) = NULL;
 static void (*set_debug_options_func)(long) = NULL;
 static long (*get_debug_options_func)(void) = NULL;
 #endif
 
-int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t),
-       void (*f)(void *))
-       {
+int
+CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t),
+    void (*f)(void *))
+{
        /* Dummy call just to ensure OPENSSL_init() gets linked in */
        OPENSSL_init();
        if (!allow_customize)
                return 0;
        if ((m == 0) || (r == 0) || (f == 0))
                return 0;
-       malloc_func=m; malloc_ex_func=default_malloc_ex;
-       realloc_func=r; realloc_ex_func=default_realloc_ex;
-       free_func=f;
-       malloc_locked_func=m; malloc_locked_ex_func=default_malloc_locked_ex;
-       free_locked_func=f;
+       malloc_func = m;
+       malloc_ex_func = default_malloc_ex;
+       realloc_func = r;
+       realloc_ex_func = default_realloc_ex;
+       free_func = f;
+       malloc_locked_func = m;
+       malloc_locked_ex_func = default_malloc_locked_ex;
+       free_locked_func = f;
        return 1;
-       }
+}
 
-int CRYPTO_set_mem_ex_functions(
-        void *(*m)(size_t,const char *,int),
-        void *(*r)(void *, size_t,const char *,int),
-       void (*f)(void *))
-       {
+int
+CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int),
+    void *(*r)(void *, size_t, const char *, int), void (*f)(void *))
+{
        if (!allow_customize)
                return 0;
        if ((m == 0) || (r == 0) || (f == 0))
                return 0;
-       malloc_func=0; malloc_ex_func=m;
-       realloc_func=0; realloc_ex_func=r;
-       free_func=f;
-       malloc_locked_func=0; malloc_locked_ex_func=m;
-       free_locked_func=f;
+       malloc_func = 0;
+       malloc_ex_func = m;
+       realloc_func = 0;
+       realloc_ex_func = r;
+       free_func = f;
+       malloc_locked_func = 0;
+       malloc_locked_ex_func = m;
+       free_locked_func = f;
        return 1;
-       }
+}
 
-int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *))
-       {
+int
+CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*f)(void *))
+{
        if (!allow_customize)
                return 0;
        if ((m == NULL) || (f == NULL))
                return 0;
-       malloc_locked_func=m; malloc_locked_ex_func=default_malloc_locked_ex;
-       free_locked_func=f;
+       malloc_locked_func = m;
+       malloc_locked_ex_func = default_malloc_locked_ex;
+       free_locked_func = f;
        return 1;
-       }
+}
 
-int CRYPTO_set_locked_mem_ex_functions(
-        void *(*m)(size_t,const char *,int),
-        void (*f)(void *))
-       {
+int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int),
+    void (*f)(void *))
+{
        if (!allow_customize)
                return 0;
        if ((m == NULL) || (f == NULL))
                return 0;
-       malloc_locked_func=0; malloc_locked_ex_func=m;
-       free_func=f;
+       malloc_locked_func = 0;
+       malloc_locked_ex_func = m;
+       free_func = f;
        return 1;
-       }
+}
 
-int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
-                                  void (*r)(void *,void *,int,const char *,int,int),
-                                  void (*f)(void *,int),
-                                  void (*so)(long),
-                                  long (*go)(void))
-       {
+int
+CRYPTO_set_mem_debug_functions(void (*m)(void *, int, const char *, int, int),
+    void (*r)(void *, void *, int, const char *, int, int),
+    void (*f)(void *, int), void (*so)(long), long (*go)(void))
+{
        if (!allow_customize_debug)
                return 0;
        OPENSSL_init();
-       malloc_debug_func=m;
-       realloc_debug_func=r;
-       free_debug_func=f;
-       set_debug_options_func=so;
-       get_debug_options_func=go;
+       malloc_debug_func = m;
+       realloc_debug_func = r;
+       free_debug_func = f;
+       set_debug_options_func = so;
+       get_debug_options_func = go;
        return 1;
-       }
-
-
-void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
-       void (**f)(void *))
-       {
-       if (m != NULL) *m = (malloc_ex_func == default_malloc_ex) ? 
-                            malloc_func : 0;
-       if (r != NULL) *r = (realloc_ex_func == default_realloc_ex) ? 
-                            realloc_func : 0;
-       if (f != NULL) *f=free_func;
-       }
-
-void CRYPTO_get_mem_ex_functions(
-        void *(**m)(size_t,const char *,int),
-        void *(**r)(void *, size_t,const char *,int),
-       void (**f)(void *))
-       {
-       if (m != NULL) *m = (malloc_ex_func != default_malloc_ex) ?
-                           malloc_ex_func : 0;
-       if (r != NULL) *r = (realloc_ex_func != default_realloc_ex) ?
-                           realloc_ex_func : 0;
-       if (f != NULL) *f=free_func;
-       }
-
-void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *))
-       {
-       if (m != NULL) *m = (malloc_locked_ex_func == default_malloc_locked_ex) ? 
-                            malloc_locked_func : 0;
-       if (f != NULL) *f=free_locked_func;
-       }
-
-void CRYPTO_get_locked_mem_ex_functions(
-        void *(**m)(size_t,const char *,int),
-        void (**f)(void *))
-       {
-       if (m != NULL) *m = (malloc_locked_ex_func != default_malloc_locked_ex) ?
-                           malloc_locked_ex_func : 0;
-       if (f != NULL) *f=free_locked_func;
-       }
-
-void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
-                                   void (**r)(void *,void *,int,const char *,int,int),
-                                   void (**f)(void *,int),
-                                   void (**so)(long),
-                                   long (**go)(void))
-       {
-       if (m != NULL) *m=malloc_debug_func;
-       if (r != NULL) *r=realloc_debug_func;
-       if (f != NULL) *f=free_debug_func;
-       if (so != NULL) *so=set_debug_options_func;
-       if (go != NULL) *go=get_debug_options_func;
-       }
-
-
-void *CRYPTO_malloc_locked(int num, const char *file, int line)
-       {
+}
+
+
+void
+CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
+    void (**f)(void *))
+{
+       if (m != NULL)
+               *m = (malloc_ex_func == default_malloc_ex) ? malloc_func : 0;
+       if (r != NULL)
+               *r = (realloc_ex_func == default_realloc_ex) ? realloc_func : 0;
+       if (f != NULL)
+               *f = free_func;
+}
+
+void CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int),
+    void *(**r)(void *, size_t, const char *, int), void (**f)(void *))
+{
+       if (m != NULL)
+               *m = (malloc_ex_func != default_malloc_ex) ? malloc_ex_func : 0;
+       if (r != NULL)
+               *r = (realloc_ex_func != default_realloc_ex) ?
+                   realloc_ex_func : 0;
+       if (f != NULL)
+               *f = free_func;
+}
+
+void
+CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *))
+{
+       if (m != NULL)
+               *m = (malloc_locked_ex_func == default_malloc_locked_ex) ?
+                   malloc_locked_func : 0;
+       if (f != NULL)
+               *f = free_locked_func;
+}
+
+void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int),
+    void (**f)(void *))
+{
+       if (m != NULL)
+               *m = (malloc_locked_ex_func != default_malloc_locked_ex) ?
+                   malloc_locked_ex_func : 0;
+       if (f != NULL)
+               *f = free_locked_func;
+}
+
+void
+CRYPTO_get_mem_debug_functions(void (**m)(void *, int, const char *, int, int),
+    void (**r)(void *, void *, int, const char *, int, int),
+    void (**f)(void *, int), void (**so)(long), long (**go)(void))
+{
+       if (m != NULL)
+               *m = malloc_debug_func;
+       if (r != NULL)
+               *r = realloc_debug_func;
+       if (f != NULL)
+               *f = free_debug_func;
+       if (so != NULL)
+               *so = set_debug_options_func;
+       if (go != NULL)
+               *go = get_debug_options_func;
+}
+
+
+void
+*CRYPTO_malloc_locked(int num, const char *file, int line)
+{
        void *ret = NULL;
 
-       if (num <= 0) return NULL;
+       if (num <= 0)
+               return NULL;
 
        allow_customize = 0;
-       if (malloc_debug_func != NULL)
-               {
+       if (malloc_debug_func != NULL) {
                allow_customize_debug = 0;
                malloc_debug_func(NULL, num, file, line, 0);
-               }
-       ret = malloc_locked_ex_func(num,file,line);
+       }
+       ret = malloc_locked_ex_func(num, file, line);
 #ifdef LEVITTE_DEBUG_MEM
        fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);
 #endif
@@ -272,17 +296,18 @@ void *CRYPTO_malloc_locked(int num, const char *file, int line)
         /* Create a dependency on the value of 'cleanse_ctr' so our memory
          * sanitisation function can't be optimised out. NB: We only do
          * this for >2Kb so the overhead doesn't bother us. */
-        if(ret && (num > 2048))
-       {       extern unsigned char cleanse_ctr;
+       if (ret && (num > 2048)) {
+               extern unsigned char cleanse_ctr;
                ((unsigned char *)ret)[0] = cleanse_ctr;
        }
 #endif
 
        return ret;
-       }
+}
 
-void CRYPTO_free_locked(void *str)
-       {
+void
+CRYPTO_free_locked(void *str)
+{
        if (free_debug_func != NULL)
                free_debug_func(str, 0);
 #ifdef LEVITTE_DEBUG_MEM
@@ -291,21 +316,22 @@ void CRYPTO_free_locked(void *str)
        free_locked_func(str);
        if (free_debug_func != NULL)
                free_debug_func(NULL, 1);
-       }
+}
 
-void *CRYPTO_malloc(int num, const char *file, int line)
-       {
+void
+*CRYPTO_malloc(int num, const char *file, int line)
+{
        void *ret = NULL;
 
-       if (num <= 0) return NULL;
+       if (num <= 0)
+               return NULL;
 
        allow_customize = 0;
-       if (malloc_debug_func != NULL)
-               {
+       if (malloc_debug_func != NULL) {
                allow_customize_debug = 0;
                malloc_debug_func(NULL, num, file, line, 0);
-               }
-       ret = malloc_ex_func(num,file,line);
+       }
+       ret = malloc_ex_func(num, file, line);
 #ifdef LEVITTE_DEBUG_MEM
        fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);
 #endif
@@ -316,35 +342,39 @@ void *CRYPTO_malloc(int num, const char *file, int line)
         /* Create a dependency on the value of 'cleanse_ctr' so our memory
          * sanitisation function can't be optimised out. NB: We only do
          * this for >2Kb so the overhead doesn't bother us. */
-        if(ret && (num > 2048))
-       {       extern unsigned char cleanse_ctr;
-                ((unsigned char *)ret)[0] = cleanse_ctr;
+       if (ret && (num > 2048)) {
+               extern unsigned char cleanse_ctr;
+               ((unsigned char *)ret)[0] = cleanse_ctr;
        }
 #endif
 
        return ret;
-       }
-char *CRYPTO_strdup(const char *str, const char *file, int line)
-       {
-       size_t len = strlen(str)+1;
+}
+
+char
+*CRYPTO_strdup(const char *str, const char *file, int line)
+{
+       size_t len = strlen(str) + 1;
        char *ret = CRYPTO_malloc(len, file, line);
 
        memcpy(ret, str, len);
        return ret;
-       }
+}
 
-void *CRYPTO_realloc(void *str, int num, const char *file, int line)
-       {
+void
+*CRYPTO_realloc(void *str, int num, const char *file, int line)
+{
        void *ret = NULL;
 
        if (str == NULL)
                return CRYPTO_malloc(num, file, line);
 
-       if (num <= 0) return NULL;
+       if (num <= 0)
+               return NULL;
 
        if (realloc_debug_func != NULL)
                realloc_debug_func(str, NULL, num, file, line, 0);
-       ret = realloc_ex_func(str,num,file,line);
+       ret = realloc_ex_func(str, num, file, line);
 #ifdef LEVITTE_DEBUG_MEM
        fprintf(stderr, "LEVITTE_DEBUG_MEM:         | 0x%p -> 0x%p (%d)\n", str, ret, num);
 #endif
@@ -352,44 +382,47 @@ void *CRYPTO_realloc(void *str, int num, const char *file, int line)
                realloc_debug_func(str, ret, num, file, line, 1);
 
        return ret;
-       }
+}
 
-void *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
-                          int line)
-       {
+void
+*CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
+int line)
+{
        void *ret = NULL;
 
        if (str == NULL)
                return CRYPTO_malloc(num, file, line);
 
-       if (num <= 0) return NULL;
+       if (num <= 0)
+               return NULL;
 
        /* We don't support shrinking the buffer. Note the memcpy that copies
         * |old_len| bytes to the new buffer, below. */
-       if (num < old_len) return NULL;
+       if (num < old_len)
+               return NULL;
 
        if (realloc_debug_func != NULL)
                realloc_debug_func(str, NULL, num, file, line, 0);
-       ret=malloc_ex_func(num,file,line);
-       if(ret)
-               {
-               memcpy(ret,str,old_len);
-               OPENSSL_cleanse(str,old_len);
+       ret = malloc_ex_func(num, file, line);
+       if (ret) {
+               memcpy(ret, str, old_len);
+               OPENSSL_cleanse(str, old_len);
                free_func(str);
-               }
+       }
 #ifdef LEVITTE_DEBUG_MEM
        fprintf(stderr,
-               "LEVITTE_DEBUG_MEM:         | 0x%p -> 0x%p (%d)\n",
-               str, ret, num);
+           "LEVITTE_DEBUG_MEM:         | 0x%p -> 0x%p (%d)\n",
+           str, ret, num);
 #endif
        if (realloc_debug_func != NULL)
                realloc_debug_func(str, ret, num, file, line, 1);
 
        return ret;
-       }
+}
 
-void CRYPTO_free(void *str)
-       {
+void
+CRYPTO_free(void *str)
+{
        if (free_debug_func != NULL)
                free_debug_func(str, 0);
 #ifdef LEVITTE_DEBUG_MEM
@@ -398,24 +431,28 @@ void CRYPTO_free(void *str)
        free_func(str);
        if (free_debug_func != NULL)
                free_debug_func(NULL, 1);
-       }
-
-void *CRYPTO_remalloc(void *a, int num, const char *file, int line)
-       {
-       if (a != NULL) OPENSSL_free(a);
-       a=(char *)OPENSSL_malloc(num);
-       return(a);
-       }
-
-void CRYPTO_set_mem_debug_options(long bits)
-       {
+}
+
+void
+*CRYPTO_remalloc(void *a, int num, const char *file, int line)
+{
+       if (a != NULL)
+               OPENSSL_free(a);
+       a = (char *)OPENSSL_malloc(num);
+       return (a);
+}
+
+void
+CRYPTO_set_mem_debug_options(long bits)
+{
        if (set_debug_options_func != NULL)
                set_debug_options_func(bits);
-       }
+}
 
-long CRYPTO_get_mem_debug_options(void)
-       {
+long
+CRYPTO_get_mem_debug_options(void)
+{
        if (get_debug_options_func != NULL)
                return get_debug_options_func();
        return 0;
-       }
+}
index add1f78..fc108c8 100644 (file)
 
 unsigned char cleanse_ctr = 0;
 
-void OPENSSL_cleanse(void *ptr, size_t len)
-       {
+void
+OPENSSL_cleanse(void *ptr, size_t len)
+{
        unsigned char *p = ptr;
        size_t loop = len, ctr = cleanse_ctr;
-       while(loop--)
-               {
+       while (loop--) {
                *(p++) = (unsigned char)ctr;
                ctr += (17 + ((size_t)p & 0xF));
-               }
-       p=memchr(ptr, (unsigned char)ctr, len);
-       if(p)
+       }
+       p = memchr(ptr, (unsigned char)ctr, len);
+       if (p)
                ctr += (63 + (size_t)p);
        cleanse_ctr = (unsigned char)ctr;
-       }
+}
index ac79339..9324ec4 100644 (file)
 #include <openssl/bio.h>
 #include <openssl/lhash.h>
 
-static int mh_mode=CRYPTO_MEM_CHECK_OFF;
+static int mh_mode = CRYPTO_MEM_CHECK_OFF;
 /* The state changes to CRYPTO_MEM_CHECK_ON | CRYPTO_MEM_CHECK_ENABLE
  * when the application asks for it (usually after library initialisation
  * for which no book-keeping is desired).
@@ -136,10 +136,9 @@ static int mh_mode=CRYPTO_MEM_CHECK_OFF;
 static unsigned long order = 0; /* number of memory requests */
 
 DECLARE_LHASH_OF(MEM);
-static LHASH_OF(MEM) *mh=NULL; /* hash-table of memory requests
-                               * (address as key); access requires
-                               * MALLOC2 lock */
-
+static LHASH_OF(MEM) *mh = NULL; /* hash - table of memory requests
+                                 * (address as key); access requires
+                                 * MALLOC2 lock */
 
 typedef struct app_mem_info_st
 /* For application-defined information (static C-string `info')
@@ -149,28 +148,28 @@ typedef struct app_mem_info_st
  *   CRYPTO_pop_info()           to pop an entry,
  *   CRYPTO_remove_all_info()    to pop all entries.
  */
-       {
+{
        CRYPTO_THREADID threadid;
        const char *file;
        int line;
        const char *info;
        struct app_mem_info_st *next; /* tail of thread's stack */
        int references;
-       } APP_INFO;
+} APP_INFO;
 
 static void app_info_free(APP_INFO *);
 
 DECLARE_LHASH_OF(APP_INFO);
-static LHASH_OF(APP_INFO) *amih=NULL; /* hash-table with those
-                                      * app_mem_info_st's that are at
-                                      * the top of their thread's
-                                      * stack (with `thread' as key);
-                                      * access requires MALLOC2
-                                      * lock */
+static LHASH_OF(APP_INFO) *amih = NULL; /* hash - table with those
+                                        * app_mem_info_st's that are at
+                                        * the top of their thread's
+                                        * stack (with `thread' as key);
+                                        * access requires MALLOC2
+                                        * lock */
 
 typedef struct mem_st
 /* memory-block description */
-       {
+{
        void *addr;
        int num;
        const char *file;
@@ -179,47 +178,46 @@ typedef struct mem_st
        unsigned long order;
        time_t time;
        APP_INFO *app_info;
-       } MEM;
+} MEM;
 
 static long options =             /* extra information to be recorded */
 #if defined(CRYPTO_MDEBUG_TIME) || defined(CRYPTO_MDEBUG_ALL)
-       V_CRYPTO_MDEBUG_TIME |
+V_CRYPTO_MDEBUG_TIME |
 #endif
 #if defined(CRYPTO_MDEBUG_THREAD) || defined(CRYPTO_MDEBUG_ALL)
-       V_CRYPTO_MDEBUG_THREAD |
+V_CRYPTO_MDEBUG_THREAD |
 #endif
-       0;
+0;
 
 
 static unsigned int num_disable = 0; /* num_disable > 0
-                                      *     iff
-                                      * mh_mode == CRYPTO_MEM_CHECK_ON (w/o ..._ENABLE)
-                                      */
+                                     *     iff
+                                     * mh_mode == CRYPTO_MEM_CHECK_ON (w/o ..._ENABLE)
+                                     */
 
 /* Valid iff num_disable > 0.  CRYPTO_LOCK_MALLOC2 is locked exactly in this
  * case (by the thread named in disabling_thread).
  */
 static CRYPTO_THREADID disabling_threadid;
 
-static void app_info_free(APP_INFO *inf)
-       {
-       if (--(inf->references) <= 0)
-               {
-               if (inf->next != NULL)
-                       {
+static void
+app_info_free(APP_INFO *inf)
+{
+       if (--(inf->references) <= 0) {
+               if (inf->next != NULL) {
                        app_info_free(inf->next);
-                       }
-               OPENSSL_free(inf);
                }
+               OPENSSL_free(inf);
        }
+}
 
-int CRYPTO_mem_ctrl(int mode)
-       {
-       int ret=mh_mode;
+int
+CRYPTO_mem_ctrl(int mode)
+{
+       int ret = mh_mode;
 
        CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
-       switch (mode)
-               {
+       switch (mode) {
        /* for applications (not to be called while multiple threads
         * use the library): */
        case CRYPTO_MEM_CHECK_ON: /* aka MemCheck_start() */
@@ -232,14 +230,13 @@ int CRYPTO_mem_ctrl(int mode)
                                    or there'll be a lot of confusion */
                break;
 
-       /* switch off temporarily (for library-internal use): */
+               /* switch off temporarily (for library-internal use): */
        case CRYPTO_MEM_CHECK_DISABLE: /* aka MemCheck_off() */
-               if (mh_mode & CRYPTO_MEM_CHECK_ON)
-                       {
+               if (mh_mode & CRYPTO_MEM_CHECK_ON) {
                        CRYPTO_THREADID cur;
                        CRYPTO_THREADID_current(&cur);
                        if (!num_disable || CRYPTO_THREADID_cmp(&disabling_threadid, &cur)) /* otherwise we already have the MALLOC2 lock */
-                               {
+                       {
                                /* Long-time lock CRYPTO_LOCK_MALLOC2 must not be claimed while
                                 * we're holding CRYPTO_LOCK_MALLOC, or we'll deadlock if
                                 * somebody else holds CRYPTO_LOCK_MALLOC2 (and cannot release
@@ -257,412 +254,402 @@ int CRYPTO_mem_ctrl(int mode)
                                CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);
                                mh_mode &= ~CRYPTO_MEM_CHECK_ENABLE;
                                CRYPTO_THREADID_cpy(&disabling_threadid, &cur);
-                               }
-                       num_disable++;
                        }
+                       num_disable++;
+               }
                break;
        case CRYPTO_MEM_CHECK_ENABLE: /* aka MemCheck_on() */
-               if (mh_mode & CRYPTO_MEM_CHECK_ON)
-                       {
+               if (mh_mode & CRYPTO_MEM_CHECK_ON) {
                        if (num_disable) /* always true, or something is going wrong */
-                               {
+                       {
                                num_disable--;
-                               if (num_disable == 0)
-                                       {
+                               if (num_disable == 0) {
                                        mh_mode|=CRYPTO_MEM_CHECK_ENABLE;
                                        CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
-                                       }
                                }
                        }
+               }
                break;
 
        default:
                break;
-               }
-       CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
-       return(ret);
        }
+       CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
+       return (ret);
+}
 
-int CRYPTO_is_mem_check_on(void)
-       {
+int
+CRYPTO_is_mem_check_on(void)
+{
        int ret = 0;
 
-       if (mh_mode & CRYPTO_MEM_CHECK_ON)
-               {
+       if (mh_mode & CRYPTO_MEM_CHECK_ON) {
                CRYPTO_THREADID cur;
                CRYPTO_THREADID_current(&cur);
                CRYPTO_r_lock(CRYPTO_LOCK_MALLOC);
 
-               ret = (mh_mode & CRYPTO_MEM_CHECK_ENABLE)
-                       || CRYPTO_THREADID_cmp(&disabling_threadid, &cur);
+               ret = (mh_mode & CRYPTO_MEM_CHECK_ENABLE) ||
+                   CRYPTO_THREADID_cmp(&disabling_threadid, &cur);
 
                CRYPTO_r_unlock(CRYPTO_LOCK_MALLOC);
-               }
-       return(ret);
-       }       
+       }
+       return (ret);
+}
 
 
-void CRYPTO_dbg_set_options(long bits)
-       {
+void
+CRYPTO_dbg_set_options(long bits)
+{
        options = bits;
-       }
+}
 
-long CRYPTO_dbg_get_options(void)
-       {
+long
+CRYPTO_dbg_get_options(void)
+{
        return options;
-       }
+}
 
-static int mem_cmp(const MEM *a, const MEM *b)
-       {
+static int
+mem_cmp(const MEM *a, const MEM *b)
+{
 #ifdef _WIN64
-       const char *ap=(const char *)a->addr,
-                  *bp=(const char *)b->addr;
-       if (ap==bp)     return 0;
-       else if (ap>bp) return 1;
-       else            return -1;
+       const char *ap = (const char *)a->addr,
+       *bp = (const char *)b->addr;
+       if (ap == bp)
+               return 0;
+       else if (ap > bp)       return 1;
+               else            return -1;
 #else
        return (const char *)a->addr - (const char *)b->addr;
 #endif
-       }
+}
+
 static IMPLEMENT_LHASH_COMP_FN(mem, MEM)
 
-static unsigned long mem_hash(const MEM *a)
-       {
+static unsigned long
+mem_hash(const MEM *a)
+{
        unsigned long ret;
 
-       ret=(unsigned long)a->addr;
+       ret = (unsigned long)a->addr;
 
-       ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
-       return(ret);
-       }
-static IMPLEMENT_LHASH_HASH_FN(mem, MEM)
+       ret = ret * 17851 + (ret >> 14) * 7 + (ret >> 4) * 251;
+       return (ret);
+}
+
+static
+IMPLEMENT_LHASH_HASH_FN(mem, MEM)
 
 /* static int app_info_cmp(APP_INFO *a, APP_INFO *b) */
-static int app_info_cmp(const void *a_void, const void *b_void)
-       {
+static int
+app_info_cmp(const void *a_void, const void *b_void)
+{
        return CRYPTO_THREADID_cmp(&((const APP_INFO *)a_void)->threadid,
-                               &((const APP_INFO *)b_void)->threadid);
-       }
+           &((const APP_INFO *)b_void)->threadid);
+}
+
 static IMPLEMENT_LHASH_COMP_FN(app_info, APP_INFO)
 
-static unsigned long app_info_hash(const APP_INFO *a)
-       {
+static unsigned long
+app_info_hash(const APP_INFO *a)
+{
        unsigned long ret;
 
        ret = CRYPTO_THREADID_hash(&a->threadid);
        /* This is left in as a "who am I to question legacy?" measure */
-       ret=ret*17851+(ret>>14)*7+(ret>>4)*251;
-       return(ret);
-       }
+       ret = ret * 17851 + (ret >> 14) * 7 + (ret >> 4) * 251;
+       return (ret);
+}
+
 static IMPLEMENT_LHASH_HASH_FN(app_info, APP_INFO)
 
-static APP_INFO *pop_info(void)
-       {
+static APP_INFO
+*pop_info(void)
+{
        APP_INFO tmp;
        APP_INFO *ret = NULL;
 
-       if (amih != NULL)
-               {
+       if (amih != NULL) {
                CRYPTO_THREADID_current(&tmp.threadid);
-               if ((ret=lh_APP_INFO_delete(amih,&tmp)) != NULL)
-                       {
-                       APP_INFO *next=ret->next;
+               if ((ret = lh_APP_INFO_delete(amih, &tmp)) != NULL) {
+                       APP_INFO *next = ret->next;
 
-                       if (next != NULL)
-                               {
+                       if (next != NULL) {
                                next->references++;
-                               (void)lh_APP_INFO_insert(amih,next);
-                               }
+                               (void)lh_APP_INFO_insert(amih, next);
+                       }
 #ifdef LEVITTE_DEBUG_MEM
-                       if (CRYPTO_THREADID_cmp(&ret->threadid, &tmp.threadid))
-                               {
+                       if (CRYPTO_THREADID_cmp(&ret->threadid, &tmp.threadid)) {
                                fprintf(stderr, "pop_info(): deleted info has other thread ID (%lu) than the current thread (%lu)!!!!\n",
-                                       CRYPTO_THREADID_hash(&ret->threadid),
-                                       CRYPTO_THREADID_hash(&tmp.threadid));
+                               CRYPTO_THREADID_hash(&ret->threadid),
+                               CRYPTO_THREADID_hash(&tmp.threadid));
                                abort();
-                               }
+                       }
 #endif
-                       if (--(ret->references) <= 0)
-                               {
+                       if (--(ret->references) <= 0) {
                                ret->next = NULL;
                                if (next != NULL)
                                        next->references--;
                                OPENSSL_free(ret);
-                               }
                        }
                }
-       return(ret);
        }
+       return (ret);
+}
 
-int CRYPTO_push_info_(const char *info, const char *file, int line)
-       {
+int
+CRYPTO_push_info_(const char *info, const char *file, int line)
+{
        APP_INFO *ami, *amim;
-       int ret=0;
+       int ret = 0;
 
-       if (is_MemCheck_on())
-               {
+       if (is_MemCheck_on()) {
                MemCheck_off(); /* obtain MALLOC2 lock */
 
-               if ((ami = (APP_INFO *)OPENSSL_malloc(sizeof(APP_INFO))) == NULL)
-                       {
-                       ret=0;
+               if ((ami = (APP_INFO *)OPENSSL_malloc(sizeof(APP_INFO))) == NULL) {
+                       ret = 0;
                        goto err;
-                       }
-               if (amih == NULL)
-                       {
-                       if ((amih=lh_APP_INFO_new()) == NULL)
-                               {
+               }
+               if (amih == NULL) {
+                       if ((amih = lh_APP_INFO_new()) == NULL) {
                                OPENSSL_free(ami);
-                               ret=0;
+                               ret = 0;
                                goto err;
-                               }
                        }
+               }
 
                CRYPTO_THREADID_current(&ami->threadid);
-               ami->file=file;
-               ami->line=line;
-               ami->info=info;
-               ami->references=1;
-               ami->next=NULL;
+               ami->file = file;
+               ami->line = line;
+               ami->info = info;
+               ami->references = 1;
+               ami->next = NULL;
 
-               if ((amim=lh_APP_INFO_insert(amih,ami)) != NULL)
-                       {
+               if ((amim = lh_APP_INFO_insert(amih, ami)) != NULL) {
 #ifdef LEVITTE_DEBUG_MEM
-                       if (CRYPTO_THREADID_cmp(&ami->threadid, &amim->threadid))
-                               {
+                       if (CRYPTO_THREADID_cmp(&ami->threadid, &amim->threadid)) {
                                fprintf(stderr, "CRYPTO_push_info(): previous info has other thread ID (%lu) than the current thread (%lu)!!!!\n",
-                                       CRYPTO_THREADID_hash(&amim->threadid),
-                                       CRYPTO_THREADID_hash(&ami->threadid));
+                               CRYPTO_THREADID_hash(&amim->threadid),
+                               CRYPTO_THREADID_hash(&ami->threadid));
                                abort();
-                               }
-#endif
-                       ami->next=amim;
                        }
- err:
-               MemCheck_on(); /* release MALLOC2 lock */
+#endif
+                       ami->next = amim;
                }
-
-       return(ret);
+               err:
+               MemCheck_on(); /* release MALLOC2 lock */
        }
 
-int CRYPTO_pop_info(void)
-       {
-       int ret=0;
+       return (ret);
+}
+
+int
+CRYPTO_pop_info(void)
+{
+       int ret = 0;
 
        if (is_MemCheck_on()) /* _must_ be true, or something went severely wrong */
-               {
+       {
                MemCheck_off(); /* obtain MALLOC2 lock */
 
-               ret=(pop_info() != NULL);
+               ret = (pop_info() != NULL);
 
                MemCheck_on(); /* release MALLOC2 lock */
-               }
-       return(ret);
        }
+       return (ret);
+}
 
-int CRYPTO_remove_all_info(void)
-       {
-       int ret=0;
+int
+CRYPTO_remove_all_info(void)
+{
+       int ret = 0;
 
        if (is_MemCheck_on()) /* _must_ be true */
-               {
+       {
                MemCheck_off(); /* obtain MALLOC2 lock */
 
-               while(pop_info() != NULL)
-                       ret++;
+               while (pop_info() != NULL)
+               ret++;
 
                MemCheck_on(); /* release MALLOC2 lock */
-               }
-       return(ret);
        }
+       return (ret);
+}
 
 
-static unsigned long break_order_num=0;
-void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
-       int before_p)
-       {
-       MEM *m,*mm;
-       APP_INFO tmp,*amim;
+static unsigned long break_order_num = 0;
+void
+CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line,
+    int before_p)
+{
+       MEM *m, *mm;
+       APP_INFO tmp, *amim;
 
-       switch(before_p & 127)
-               {
+       switch (before_p & 127) {
        case 0:
                break;
        case 1:
                if (addr == NULL)
                        break;
 
-               if (is_MemCheck_on())
-                       {
+               if (is_MemCheck_on()) {
                        MemCheck_off(); /* make sure we hold MALLOC2 lock */
-                       if ((m=(MEM *)OPENSSL_malloc(sizeof(MEM))) == NULL)
-                               {
+                       if ((m = (MEM *)OPENSSL_malloc(sizeof(MEM))) == NULL) {
                                OPENSSL_free(addr);
                                MemCheck_on(); /* release MALLOC2 lock
                                                * if num_disabled drops to 0 */
                                return;
-                               }
-                       if (mh == NULL)
-                               {
-                               if ((mh=lh_MEM_new()) == NULL)
-                                       {
+                       }
+                       if (mh == NULL) {
+                               if ((mh = lh_MEM_new()) == NULL) {
                                        OPENSSL_free(addr);
                                        OPENSSL_free(m);
-                                       addr=NULL;
+                                       addr = NULL;
                                        goto err;
-                                       }
                                }
+                       }
 
-                       m->addr=addr;
-                       m->file=file;
-                       m->line=line;
-                       m->num=num;
+                       m->addr = addr;
+                       m->file = file;
+                       m->line = line;
+                       m->num = num;
                        if (options & V_CRYPTO_MDEBUG_THREAD)
                                CRYPTO_THREADID_current(&m->threadid);
                        else
                                memset(&m->threadid, 0, sizeof(m->threadid));
 
-                       if (order == break_order_num)
-                               {
+                       if (order == break_order_num) {
                                /* BREAK HERE */
-                               m->order=order;
-                               }
-                       m->order=order++;
+                               m->order = order;
+                       }
+                       m->order = order++;
 #ifdef LEVITTE_DEBUG_MEM
                        fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] %c 0x%p (%d)\n",
-                               m->order,
-                               (before_p & 128) ? '*' : '+',
-                               m->addr, m->num);
+                           m->order,
+                           (before_p & 128) ? '*' : '+',
+                           m->addr, m->num);
 #endif
                        if (options & V_CRYPTO_MDEBUG_TIME)
-                               m->time=time(NULL);
+                               m->time = time(NULL);
                        else
-                               m->time=0;
+                               m->time = 0;
 
                        CRYPTO_THREADID_current(&tmp.threadid);
-                       m->app_info=NULL;
-                       if (amih != NULL
-                           && (amim=lh_APP_INFO_retrieve(amih,&tmp)) != NULL)
-                               {
+                       m->app_info = NULL;
+                       if (amih != NULL &&
+                           (amim = lh_APP_INFO_retrieve(amih, &tmp)) != NULL) {
                                m->app_info = amim;
                                amim->references++;
-                               }
+                       }
 
-                       if ((mm=lh_MEM_insert(mh, m)) != NULL)
-                               {
+                       if ((mm = lh_MEM_insert(mh, m)) != NULL) {
                                /* Not good, but don't sweat it */
-                               if (mm->app_info != NULL)
-                                       {
+                               if (mm->app_info != NULL) {
                                        mm->app_info->references--;
-                                       }
-                               OPENSSL_free(mm);
                                }
-               err:
+                               OPENSSL_free(mm);
+                       }
+err:
                        MemCheck_on(); /* release MALLOC2 lock
                                        * if num_disabled drops to 0 */
-                       }
-               break;
                }
-       return;
+               break;
        }
+       return;
+}
 
-void CRYPTO_dbg_free(void *addr, int before_p)
-       {
-       MEM m,*mp;
+void
+CRYPTO_dbg_free(void *addr, int before_p)
+{
+       MEM m, *mp;
 
-       switch(before_p)
-               {
+       switch (before_p) {
        case 0:
                if (addr == NULL)
                        break;
 
-               if (is_MemCheck_on() && (mh != NULL))
-                       {
+               if (is_MemCheck_on() && (mh != NULL)) {
                        MemCheck_off(); /* make sure we hold MALLOC2 lock */
 
-                       m.addr=addr;
-                       mp=lh_MEM_delete(mh,&m);
-                       if (mp != NULL)
-                               {
+                       m.addr = addr;
+                       mp = lh_MEM_delete(mh, &m);
+                       if (mp != NULL) {
 #ifdef LEVITTE_DEBUG_MEM
-                       fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] - 0x%p (%d)\n",
+                               fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] - 0x%p (%d)\n",
                                mp->order, mp->addr, mp->num);
 #endif
                                if (mp->app_info != NULL)
                                        app_info_free(mp->app_info);
                                OPENSSL_free(mp);
-                               }
+                       }
 
                        MemCheck_on(); /* release MALLOC2 lock
                                        * if num_disabled drops to 0 */
-                       }
+               }
                break;
        case 1:
                break;
-               }
        }
+}
 
-void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
-       const char *file, int line, int before_p)
-       {
-       MEM m,*mp;
+void
+CRYPTO_dbg_realloc(void *addr1, void *addr2, int num,
+    const char *file, int line, int before_p)
+{
+       MEM m, *mp;
 
 #ifdef LEVITTE_DEBUG_MEM
        fprintf(stderr, "LEVITTE_DEBUG_MEM: --> CRYPTO_dbg_malloc(addr1 = %p, addr2 = %p, num = %d, file = \"%s\", line = %d, before_p = %d)\n",
-               addr1, addr2, num, file, line, before_p);
+       addr1, addr2, num, file, line, before_p);
 #endif
 
-       switch(before_p)
-               {
+       switch (before_p) {
        case 0:
                break;
        case 1:
                if (addr2 == NULL)
                        break;
 
-               if (addr1 == NULL)
-                       {
+               if (addr1 == NULL) {
                        CRYPTO_dbg_malloc(addr2, num, file, line, 128 | before_p);
                        break;
-                       }
+               }
 
-               if (is_MemCheck_on())
-                       {
+               if (is_MemCheck_on()) {
                        MemCheck_off(); /* make sure we hold MALLOC2 lock */
 
-                       m.addr=addr1;
-                       mp=lh_MEM_delete(mh,&m);
-                       if (mp != NULL)
-                               {
+                       m.addr = addr1;
+                       mp = lh_MEM_delete(mh, &m);
+                       if (mp != NULL) {
 #ifdef LEVITTE_DEBUG_MEM
                                fprintf(stderr, "LEVITTE_DEBUG_MEM: [%5ld] * 0x%p (%d) -> 0x%p (%d)\n",
-                                       mp->order,
-                                       mp->addr, mp->num,
-                                       addr2, num);
+                                   mp->order,
+                                   mp->addr, mp->num,
+                                   addr2, num);
 #endif
-                               mp->addr=addr2;
-                               mp->num=num;
-                               (void)lh_MEM_insert(mh,mp);
-                               }
+                               mp->addr = addr2;
+                               mp->num = num;
+                               (void)lh_MEM_insert(mh, mp);
+                       }
 
                        MemCheck_on(); /* release MALLOC2 lock
                                        * if num_disabled drops to 0 */
-                       }
-               break;
                }
-       return;
+               break;
        }
+       return;
+}
 
 
-typedef struct mem_leak_st
-       {
+typedef struct mem_leak_st {
        BIO *bio;
        int chunks;
        long bytes;
-       } MEM_LEAK;
+} MEM_LEAK;
 
-static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
-       {
+static void
+print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
+{
        char buf[1024];
        char *bufp = buf;
        APP_INFO *amip;
@@ -672,89 +659,83 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
 
 #define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
 
-       if(m->addr == (char *)l->bio)
-           return;
+       if (m->addr == (char *)l->bio)
+               return;
 
-       if (options & V_CRYPTO_MDEBUG_TIME)
-               {
+       if (options & V_CRYPTO_MDEBUG_TIME) {
                lcl = localtime(&m->time);
-       
+
                BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
-                       lcl->tm_hour,lcl->tm_min,lcl->tm_sec);
+               lcl->tm_hour, lcl->tm_min, lcl->tm_sec);
                bufp += strlen(bufp);
-               }
+       }
 
        BIO_snprintf(bufp, BUF_REMAIN, "%5lu file=%s, line=%d, ",
-               m->order,m->file,m->line);
+       m->order, m->file, m->line);
        bufp += strlen(bufp);
 
-       if (options & V_CRYPTO_MDEBUG_THREAD)
-               {
+       if (options & V_CRYPTO_MDEBUG_THREAD) {
                BIO_snprintf(bufp, BUF_REMAIN, "thread=%lu, ",
-                       CRYPTO_THREADID_hash(&m->threadid));
+               CRYPTO_THREADID_hash(&m->threadid));
                bufp += strlen(bufp);
-               }
+       }
 
        BIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%08lX\n",
-               m->num,(unsigned long)m->addr);
+       m->num,(unsigned long)m->addr);
        bufp += strlen(bufp);
 
-       BIO_puts(l->bio,buf);
-       
+       BIO_puts(l->bio, buf);
+
        l->chunks++;
-       l->bytes+=m->num;
+       l->bytes += m->num;
 
-       amip=m->app_info;
-       ami_cnt=0;
+       amip = m->app_info;
+       ami_cnt = 0;
        if (!amip)
                return;
        CRYPTO_THREADID_cpy(&ti, &amip->threadid);
 
-       do
-               {
+       do {
                int buf_len;
                int info_len;
 
                ami_cnt++;
-               memset(buf,'>',ami_cnt);
+               memset(buf, '>', ami_cnt);
                BIO_snprintf(buf + ami_cnt, sizeof buf - ami_cnt,
-                       " thread=%lu, file=%s, line=%d, info=\"",
-                       CRYPTO_THREADID_hash(&amip->threadid), amip->file,
-                       amip->line);
-               buf_len=strlen(buf);
-               info_len=strlen(amip->info);
-               if (128 - buf_len - 3 < info_len)
-                       {
+               " thread=%lu, file=%s, line=%d, info=\"",
+               CRYPTO_THREADID_hash(&amip->threadid), amip->file,
+               amip->line);
+               buf_len = strlen(buf);
+               info_len = strlen(amip->info);
+               if (128 - buf_len - 3 < info_len) {
                        memcpy(buf + buf_len, amip->info, 128 - buf_len - 3);
                        buf_len = 128 - 3;
-                       }
-               else
-                       {
+               } else {
                        BUF_strlcpy(buf + buf_len, amip->info,
-                                   sizeof buf - buf_len);
+                       sizeof buf - buf_len);
                        buf_len = strlen(buf);
-                       }
+               }
                BIO_snprintf(buf + buf_len, sizeof buf - buf_len, "\"\n");
-               
-               BIO_puts(l->bio,buf);
+
+               BIO_puts(l->bio, buf);
 
                amip = amip->next;
-               }
-       while(amip && !CRYPTO_THREADID_cmp(&amip->threadid, &ti));
+       } while (amip && !CRYPTO_THREADID_cmp(&amip->threadid, &ti));
 
 #ifdef LEVITTE_DEBUG_MEM
-       if (amip)
-               {
+       if (amip) {
                fprintf(stderr, "Thread switch detected in backtrace!!!!\n");
                abort();
-               }
-#endif
        }
+#endif
+}
 
-static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM, MEM_LEAK)
+static
+IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM, MEM_LEAK)
 
-void CRYPTO_mem_leaks(BIO *b)
-       {
+void
+CRYPTO_mem_leaks(BIO *b)
+{
        MEM_LEAK ml;
 
        if (mh == NULL && amih == NULL)
@@ -762,22 +743,19 @@ void CRYPTO_mem_leaks(BIO *b)
 
        MemCheck_off(); /* obtain MALLOC2 lock */
 
-       ml.bio=b;
-       ml.bytes=0;
-       ml.chunks=0;
+       ml.bio = b;
+       ml.bytes = 0;
+       ml.chunks = 0;
        if (mh != NULL)
-               lh_MEM_doall_arg(mh, LHASH_DOALL_ARG_FN(print_leak), MEM_LEAK,
-                                &ml);
-       if (ml.chunks != 0)
-               {
-               BIO_printf(b,"%ld bytes leaked in %d chunks\n",
-                          ml.bytes,ml.chunks);
+               lh_MEM_doall_arg(mh, LHASH_DOALL_ARG_FN(print_leak),
+                   MEM_LEAK, &ml);
+       if (ml.chunks != 0) {
+               BIO_printf(b, "%ld bytes leaked in %d chunks\n",
+               ml.bytes, ml.chunks);
 #ifdef CRYPTO_MDEBUG_ABORT
                abort();
 #endif
-               }
-       else
-               {
+       } else {
                /* Make sure that, if we found no leaks, memory-leak debugging itself
                 * does not introduce memory leaks (which might irritate
                 * external debugging tools).
@@ -802,43 +780,43 @@ void CRYPTO_mem_leaks(BIO *b)
                old_mh_mode = mh_mode;
                mh_mode = CRYPTO_MEM_CHECK_OFF;
 
-               if (mh != NULL)
-                       {
+               if (mh != NULL) {
                        lh_MEM_free(mh);
                        mh = NULL;
-                       }
-               if (amih != NULL)
-                       {
-                       if (lh_APP_INFO_num_items(amih) == 0) 
-                               {
+               }
+               if (amih != NULL) {
+                       if (lh_APP_INFO_num_items(amih) == 0) {
                                lh_APP_INFO_free(amih);
                                amih = NULL;
-                               }
                        }
+               }
 
                mh_mode = old_mh_mode;
                CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);
-               }
-       MemCheck_on(); /* release MALLOC2 lock */
        }
+       MemCheck_on(); /* release MALLOC2 lock */
+}
 
 #ifndef OPENSSL_NO_FP_API
-void CRYPTO_mem_leaks_fp(FILE *fp)
-       {
+void
+CRYPTO_mem_leaks_fp(FILE *fp)
+{
        BIO *b;
 
-       if (mh == NULL) return;
+       if (mh == NULL)
+               return;
        /* Need to turn off memory checking when allocated BIOs ... especially
         * as we're creating them at a time when we're trying to check we've not
         * left anything un-free()'d!! */
        MemCheck_off();
        b = BIO_new(BIO_s_file());
        MemCheck_on();
-       if(!b) return;
-       BIO_set_fp(b,fp,BIO_NOCLOSE);
+       if (!b)
+               return;
+       BIO_set_fp(b, fp, BIO_NOCLOSE);
        CRYPTO_mem_leaks(b);
        BIO_free(b);
-       }
+}
 #endif
 
 
@@ -857,18 +835,21 @@ void CRYPTO_mem_leaks_fp(FILE *fp)
 
 typedef CRYPTO_MEM_LEAK_CB *PCRYPTO_MEM_LEAK_CB;
 
-static void cb_leak_doall_arg(const MEM *m, PCRYPTO_MEM_LEAK_CB *cb)
-       {
-       (*cb)(m->order,m->file,m->line,m->num,m->addr);
-       }
+static void
+cb_leak_doall_arg(const MEM *m, PCRYPTO_MEM_LEAK_CB *cb)
+{
+       (*cb)(m->order, m->file, m->line, m->num, m->addr);
+}
 
 static IMPLEMENT_LHASH_DOALL_ARG_FN(cb_leak, const MEM, PCRYPTO_MEM_LEAK_CB)
 
-void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb)
-       {
-       if (mh == NULL) return;
+void
+CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb)
+{
+       if (mh == NULL)
+               return;
        CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
        lh_MEM_doall_arg(mh, LHASH_DOALL_ARG_FN(cb_leak), PCRYPTO_MEM_LEAK_CB,
-                        &cb);
+       &cb);
        CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
-       }
+}
index 238717c..2973458 100644 (file)
 #error "No supported platform defined!"
 #endif
 
-int main()
+int
+main()
 {
-  OPENSSL_DIR_CTX *ctx = NULL;
-  const char *result;
+       OPENSSL_DIR_CTX *ctx = NULL;
+       const char *result;
 
-  while((result = OPENSSL_DIR_read(&ctx, CURRDIR)) != NULL)
-    {
-      printf("%s\n", result);
-    }
+       while ((result = OPENSSL_DIR_read(&ctx, CURRDIR)) != NULL) {
+               printf("%s\n", result);
+       }
 
-  if (errno)
-    {
-      perror("test_dir");
-      exit(1);
-    }
+       if (errno) {
+               perror("test_dir");
+               exit(1);
+       }
 
-  if (!OPENSSL_DIR_end(&ctx))
-    {
-      perror("test_dir");
-      exit(2);
-    }
-  exit(0);
+       if (!OPENSSL_DIR_end(&ctx)) {
+               perror("test_dir");
+               exit(2);
+       }
+       exit(0);
 }
index f6d1b21..9c185cf 100644 (file)
 #include <openssl/rand.h>
 #endif
 
-int FIPS_mode(void)
-       {
+int
+FIPS_mode(void)
+{
        OPENSSL_init();
 #ifdef OPENSSL_FIPS
        return FIPS_module_mode();
 #else
        return 0;
 #endif
-       }
+}
 
-int FIPS_mode_set(int r)
-       {
+int
+FIPS_mode_set(int r)
+{
        OPENSSL_init();
 #ifdef OPENSSL_FIPS
 #ifndef FIPS_AUTH_USER_PASS
@@ -92,5 +94,4 @@ int FIPS_mode_set(int r)
        CRYPTOerr(CRYPTO_F_FIPS_MODE_SET, CRYPTO_R_FIPS_MODE_NOT_SUPPORTED);
        return 0;
 #endif
-       }
-
+}
index db4cdc4..07c8e0d 100644 (file)
@@ -63,8 +63,9 @@
  * Currently only sets FIPS callbacks
  */
 
-void OPENSSL_init(void)
-       {
+void
+OPENSSL_init(void)
+{
        static int done = 0;
        if (done)
                return;
@@ -78,5 +79,4 @@ void OPENSSL_init(void)
 #if 0
        fprintf(stderr, "Called OPENSSL_init\n");
 #endif
-       }
-
+}
index 56104a6..c3ab1f8 100644 (file)
 # include <strings.h>
 #endif
 
-int OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n)
-       {
+int
+OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n)
+{
 #if defined(OPENSSL_IMPLEMENTS_strncasecmp)
-       while (*str1 && *str2 && n)
-               {
+       while (*str1 && *str2 && n) {
                int res = toupper(*str1) - toupper(*str2);
-               if (res) return res < 0 ? -1 : 1;
+               if (res)
+                       return res < 0 ? -1 : 1;
                str1++;
                str2++;
                n--;
-               }
+       }
        if (n == 0)
                return 0;
        if (*str1)
@@ -90,22 +91,25 @@ int OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n)
         * defined as well. */
        return strncasecmp(str1, str2, n);
 #endif
-       }
-int OPENSSL_strcasecmp(const char *str1, const char *str2)
-       {
+}
+
+int
+OPENSSL_strcasecmp(const char *str1, const char *str2)
+{
 #if defined(OPENSSL_IMPLEMENTS_strncasecmp)
-       return OPENSSL_strncasecmp(str1, str2, (size_t)-1);
+       return OPENSSL_strncasecmp(str1, str2, (size_t) - 1);
 #else
        return strcasecmp(str1, str2);
 #endif
-       }
+}
 
-int OPENSSL_memcmp(const void *v1,const void *v2,size_t n)
-       {
-       const unsigned char *c1=v1,*c2=v2;
-       int ret=0;
+int
+OPENSSL_memcmp(const void *v1, const void *v2, size_t n)
+{
+       const unsigned char *c1 = v1, *c2 = v2;
+       int ret = 0;
 
-       while(n && (ret=*c1-*c2)==0) n--,c1++,c2++;
+       while (n && (ret = *c1 - *c2) == 0) n--, c1++, c2++;
 
        return ret;
-       }
+}
index dfc9849..e2a3fde 100644 (file)
@@ -63,6 +63,6 @@
 
 int OPENSSL_strcasecmp(const char *str1, const char *str2);
 int OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n);
-int OPENSSL_memcmp(const void *p1,const void *p2,size_t n);
+int OPENSSL_memcmp(const void *p1, const void *p2, size_t n);
 
 #endif
index 5fb5d4e..44f7ba3 100644 (file)
 #include <string.h>
 #include "o_time.h"
 
-struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
-       {
+struct tm
+*OPENSSL_gmtime(const time_t *timer, struct tm *result) {
        struct tm *ts = NULL;
 
 #if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_OS2) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r)) && !defined(OPENSSL_SYS_MACOSX) && !defined(OPENSSL_SYS_SUNOS)
        /* should return &data, but doesn't on some systems,
           so we don't even look at the return value */
-       gmtime_r(timer,result);
+       gmtime_r(timer, result);
        ts = result;
 #else
        ts = gmtime(timer);
@@ -81,7 +81,7 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
        ts = result;
 #endif
        return ts;
-       }
+}
 
 /* Take a tm structure and add an offset to it. This avoids any OS issues
  * with restricted date types and overflows which cause the year 2038
@@ -93,29 +93,27 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
 static long date_to_julian(int y, int m, int d);
 static void julian_to_date(long jd, int *y, int *m, int *d);
 
-int OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec)
-       {
+int
+OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec)
+{
        int offset_hms, offset_day;
        long time_jd;
        int time_year, time_month, time_day;
        /* split offset into days and day seconds */
        offset_day = offset_sec / SECS_PER_DAY;
        /* Avoid sign issues with % operator */
-       offset_hms  = offset_sec - (offset_day * SECS_PER_DAY);
+       offset_hms = offset_sec - (offset_day * SECS_PER_DAY);
        offset_day += off_day;
        /* Add current time seconds to offset */
        offset_hms += tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec;
        /* Adjust day seconds if overflow */
-       if (offset_hms >= SECS_PER_DAY)
-               {
+       if (offset_hms >= SECS_PER_DAY) {
                offset_day++;
                offset_hms -= SECS_PER_DAY;
-               }
-       else if (offset_hms < 0)
-               {
+       } else if (offset_hms < 0) {
                offset_day--;
                offset_hms += SECS_PER_DAY;
-               }
+       }
 
        /* Convert date of time structure into a Julian day number.
         */
@@ -150,22 +148,24 @@ int OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec)
        tm->tm_sec = offset_hms % 60;
 
        return 1;
-               
+
 }
 
 /* Convert date to and from julian day
  * Uses Fliegel & Van Flandern algorithm
  */
-static long date_to_julian(int y, int m, int d)
+static long
+date_to_julian(int y, int m, int d)
 {
        return (1461 * (y + 4800 + (m - 14) / 12)) / 4 +
-               (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 -
-               (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 +
-               d - 32075;
+           (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 -
+           (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 +
+           d - 32075;
 }
 
-static void julian_to_date(long jd, int *y, int *m, int *d)
-       {
+static void
+julian_to_date(long jd, int *y, int *m, int *d)
+{
        long  L = jd + 68569;
        long  n = (4 * L) / 146097;
        long  i, j;
@@ -178,7 +178,7 @@ static void julian_to_date(long jd, int *y, int *m, int *d)
        L = j / 11;
        *m = j + 2 - (12 * L);
        *y = 100 * (n - 49) + i + L;
-       }
+}
 
 #ifdef OPENSSL_TIME_TEST
 
@@ -189,20 +189,21 @@ static void julian_to_date(long jd, int *y, int *m, int *d)
  * trigger the very errors the routines fix.
  */
 
-int main(int argc, char **argv)
-       {
+int
+main(int argc, char **argv)
+{
        long offset;
-       for (offset = 0; offset < 1000000; offset++)
-               {
+       for (offset = 0; offset < 1000000; offset++) {
                check_time(offset);
                check_time(-offset);
                check_time(offset * 1000);
                check_time(-offset * 1000);
-               }
        }
+}
 
-int check_time(long offset)
-       {
+int
+check_time(long offset)
+{
        struct tm tm1, tm2;
        time_t t1, t2;
        time(&t1);
@@ -211,20 +212,20 @@ int check_time(long offset)
        OPENSSL_gmtime(&t1, &tm1);
        OPENSSL_gmtime_adj(&tm1, 0, offset);
        if ((tm1.tm_year == tm2.tm_year) &&
-           (tm1.tm_mon == tm2.tm_mon) &&
-           (tm1.tm_mday == tm2.tm_mday) &&
-           (tm1.tm_hour == tm2.tm_hour) &&
-           (tm1.tm_min == tm2.tm_min) &&
-           (tm1.tm_sec == tm2.tm_sec))
-               return 1;
+               (tm1.tm_mon == tm2.tm_mon) &&
+       (tm1.tm_mday == tm2.tm_mday) &&
+       (tm1.tm_hour == tm2.tm_hour) &&
+       (tm1.tm_min == tm2.tm_min) &&
+       (tm1.tm_sec == tm2.tm_sec))
+       return 1;
        fprintf(stderr, "TIME ERROR!!\n");
        fprintf(stderr, "Time1: %d/%d/%d, %d:%02d:%02d\n",
-                       tm2.tm_mday, tm2.tm_mon + 1, tm2.tm_year + 1900,
-                       tm2.tm_hour, tm2.tm_min, tm2.tm_sec);
+       tm2.tm_mday, tm2.tm_mon + 1, tm2.tm_year + 1900,
+       tm2.tm_hour, tm2.tm_min, tm2.tm_sec);
        fprintf(stderr, "Time2: %d/%d/%d, %d:%02d:%02d\n",
-                       tm1.tm_mday, tm1.tm_mon + 1, tm1.tm_year + 1900,
-                       tm1.tm_hour, tm1.tm_min, tm1.tm_sec);
+       tm1.tm_mday, tm1.tm_mon + 1, tm1.tm_year + 1900,
+       tm1.tm_hour, tm1.tm_min, tm1.tm_sec);
        return 0;
-       }
+}
 
 #endif
index ea9227f..ae79bf8 100644 (file)
@@ -182,18 +182,18 @@ typedef struct DIST_POINT_st DIST_POINT;
 typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;
 typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;
 
-  /* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */
+/* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */
 #define DECLARE_PKCS12_STACK_OF(type) /* Nothing */
 #define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */
 
 typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
 /* Callback types for crypto.h */
 typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
-                                       int idx, long argl, void *argp);
+    int idx, long argl, void *argp);
 typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
-                                       int idx, long argl, void *argp);
-typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, 
-                                       int idx, long argl, void *argp);
+    int idx, long argl, void *argp);
+typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,
+    void *from_d, int idx, long argl, void *argp);
 
 typedef struct ocsp_req_ctx_st OCSP_REQ_CTX;
 typedef struct ocsp_response_st OCSP_RESPONSE;
index f71ba66..16cc9c4 100644 (file)
@@ -15,112 +15,110 @@ static int OPENSSL_ppccap_P = 0;
 static sigset_t all_masked;
 
 #ifdef OPENSSL_BN_ASM_MONT
-int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num)
-       {
+int
+bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
+    const BN_ULONG *np, const BN_ULONG *n0, int num)
+{
        int bn_mul_mont_fpu64(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num);
        int bn_mul_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num);
 
-       if (sizeof(size_t)==4)
-               {
+       if (sizeof(size_t) == 4) {
 #if (defined(__APPLE__) && defined(__MACH__))
-               if (num>=8 && (num&3)==0 && (OPENSSL_ppccap_P&PPC_FPU64))
-                       return bn_mul_mont_fpu64(rp,ap,bp,np,n0,num);
+               if (num >= 8 && (num&3) == 0 && (OPENSSL_ppccap_P&PPC_FPU64))
+                       return bn_mul_mont_fpu64(rp, ap, bp, np, n0, num);
 #else
                /* boundary of 32 was experimentally determined on
                   Linux 2.6.22, might have to be adjusted on AIX... */
-               if (num>=32 && (num&3)==0 && (OPENSSL_ppccap_P&PPC_FPU64))
-                       {
+               if (num >= 32 && (num&3) == 0 && (OPENSSL_ppccap_P&PPC_FPU64)) {
                        sigset_t oset;
                        int ret;
 
-                       sigprocmask(SIG_SETMASK,&all_masked,&oset);
-                       ret=bn_mul_mont_fpu64(rp,ap,bp,np,n0,num);
-                       sigprocmask(SIG_SETMASK,&oset,NULL);
+                       sigprocmask(SIG_SETMASK, &all_masked, &oset);
+                       ret = bn_mul_mont_fpu64(rp, ap, bp, np, n0, num);
+                       sigprocmask(SIG_SETMASK, &oset, NULL);
 
                        return ret;
-                       }
-#endif
                }
-       else if ((OPENSSL_ppccap_P&PPC_FPU64))
+#endif
+       } else if ((OPENSSL_ppccap_P&PPC_FPU64))
                /* this is a "must" on POWER6, but run-time detection
                 * is not implemented yet... */
-               return bn_mul_mont_fpu64(rp,ap,bp,np,n0,num);
+               return bn_mul_mont_fpu64(rp, ap, bp, np, n0, num);
 
-       return bn_mul_mont_int(rp,ap,bp,np,n0,num);
-       }
+       return bn_mul_mont_int(rp, ap, bp, np, n0, num);
+}
 #endif
 
 static sigjmp_buf ill_jmp;
-static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); }
+static void ill_handler (int sig)
+{
+       siglongjmp(ill_jmp, sig);
+}
 
 void OPENSSL_ppc64_probe(void);
 void OPENSSL_altivec_probe(void);
 
-void OPENSSL_cpuid_setup(void)
-       {
+void
+OPENSSL_cpuid_setup(void)
+{
        char *e;
-       struct sigaction        ill_oact,ill_act;
+       struct sigaction        ill_oact, ill_act;
        sigset_t                oset;
-       static int trigger=0;
+       static int trigger = 0;
+
+       if (trigger)
+               return;
+       trigger = 1;
 
-       if (trigger) return;
-       trigger=1;
        sigfillset(&all_masked);
-       sigdelset(&all_masked,SIGILL);
-       sigdelset(&all_masked,SIGTRAP);
+       sigdelset(&all_masked, SIGILL);
+       sigdelset(&all_masked, SIGTRAP);
 #ifdef SIGEMT
-       sigdelset(&all_masked,SIGEMT);
+       sigdelset(&all_masked, SIGEMT);
 #endif
-       sigdelset(&all_masked,SIGFPE);
-       sigdelset(&all_masked,SIGBUS);
-       sigdelset(&all_masked,SIGSEGV);
+       sigdelset(&all_masked, SIGFPE);
+       sigdelset(&all_masked, SIGBUS);
+       sigdelset(&all_masked, SIGSEGV);
 
-       if ((e=getenv("OPENSSL_ppccap")))
-               {
-               OPENSSL_ppccap_P=strtoul(e,NULL,0);
+       if ((e = getenv("OPENSSL_ppccap"))) {
+               OPENSSL_ppccap_P = strtoul(e, NULL, 0);
                return;
-               }
+       }
 
        OPENSSL_ppccap_P = 0;
 
 #if defined(_AIX)
-       if (sizeof(size_t)==4
+       if (sizeof(size_t) == 4
 # if defined(_SC_AIX_KERNEL_BITMODE)
-           && sysconf(_SC_AIX_KERNEL_BITMODE)!=64
+       && sysconf(_SC_AIX_KERNEL_BITMODE) != 64
 # endif
-          )
-               return;
+       )
+       return;
 #endif
 
-       memset(&ill_act,0,sizeof(ill_act));
+       memset(&ill_act, 0, sizeof(ill_act));
        ill_act.sa_handler = ill_handler;
-       ill_act.sa_mask    = all_masked;
+       ill_act.sa_mask = all_masked;
 
-       sigprocmask(SIG_SETMASK,&ill_act.sa_mask,&oset);
-       sigaction(SIGILL,&ill_act,&ill_oact);
+       sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset);
+       sigaction(SIGILL, &ill_act, &ill_oact);
 
-       if (sizeof(size_t)==4)
-               {
-               if (sigsetjmp(ill_jmp,1) == 0)
-                       {
+       if (sizeof(size_t) == 4) {
+               if (sigsetjmp(ill_jmp, 1) == 0) {
                        OPENSSL_ppc64_probe();
                        OPENSSL_ppccap_P |= PPC_FPU64;
-                       }
                }
-       else
-               {
+       } else {
                /*
                 * Wanted code detecting POWER6 CPU and setting PPC_FPU64
                 */
-               }
+       }
 
-       if (sigsetjmp(ill_jmp,1) == 0)
-               {
+       if (sigsetjmp(ill_jmp, 1) == 0) {
                OPENSSL_altivec_probe();
                OPENSSL_ppccap_P |= PPC_ALTIVEC;
-               }
-
-       sigaction (SIGILL,&ill_oact,NULL);
-       sigprocmask(SIG_SETMASK,&oset,NULL);
        }
+
+       sigaction (SIGILL, &ill_oact, NULL);
+       sigprocmask(SIG_SETMASK, &oset, NULL);
+}
index f2e94ef..77f6260 100644 (file)
@@ -7,31 +7,36 @@
 extern unsigned long OPENSSL_s390xcap_P[];
 
 static sigjmp_buf ill_jmp;
-static void ill_handler (int sig) { siglongjmp(ill_jmp,sig); }
+static void ill_handler (int sig)
+{
+       siglongjmp(ill_jmp, sig);
+}
 
 unsigned long OPENSSL_s390x_facilities(void);
 
-void OPENSSL_cpuid_setup(void)
-       {
+void
+OPENSSL_cpuid_setup(void)
+{
        sigset_t oset;
-       struct sigaction ill_act,oact;
+       struct sigaction ill_act, oact;
 
-       if (OPENSSL_s390xcap_P[0]) return;
+       if (OPENSSL_s390xcap_P[0])
+               return;
 
-       OPENSSL_s390xcap_P[0] = 1UL<<(8*sizeof(unsigned long)-1);
+       OPENSSL_s390xcap_P[0] = 1UL << (8*sizeof(unsigned long) - 1);
 
-       memset(&ill_act,0,sizeof(ill_act));
+       memset(&ill_act, 0, sizeof(ill_act));
        ill_act.sa_handler = ill_handler;
        sigfillset(&ill_act.sa_mask);
-       sigdelset(&ill_act.sa_mask,SIGILL);
-       sigdelset(&ill_act.sa_mask,SIGTRAP);
-       sigprocmask(SIG_SETMASK,&ill_act.sa_mask,&oset);
-       sigaction (SIGILL,&ill_act,&oact);
+       sigdelset(&ill_act.sa_mask, SIGILL);
+       sigdelset(&ill_act.sa_mask, SIGTRAP);
+       sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset);
+       sigaction (SIGILL, &ill_act, &oact);
 
        /* protection against missing store-facility-list-extended */
-       if (sigsetjmp(ill_jmp,1) == 0)
+       if (sigsetjmp(ill_jmp, 1) == 0)
                OPENSSL_s390x_facilities();
 
-       sigaction (SIGILL,&oact,NULL);
-       sigprocmask(SIG_SETMASK,&oset,NULL);
-       }
+       sigaction (SIGILL, &oact, NULL);
+       sigprocmask(SIG_SETMASK, &oset, NULL);
+}
index 43b3ac6..08f7de3 100644 (file)
 #define SPARCV9_VIS2           (1<<3)  /* reserved */
 #define SPARCV9_FMADD          (1<<4)  /* reserved for SPARC64 V */
 
-static int OPENSSL_sparcv9cap_P=SPARCV9_TICK_PRIVILEGED;
-
-int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num)
-       {
-       int bn_mul_mont_fpu(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num);
-       int bn_mul_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num);
-
-       if (num>=8 && !(num&1) &&
-           (OPENSSL_sparcv9cap_P&(SPARCV9_PREFER_FPU|SPARCV9_VIS1)) ==
-               (SPARCV9_PREFER_FPU|SPARCV9_VIS1))
-               return bn_mul_mont_fpu(rp,ap,bp,np,n0,num);
+static int OPENSSL_sparcv9cap_P = SPARCV9_TICK_PRIVILEGED;
+
+int
+bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
+    const BN_ULONG *np, const BN_ULONG *n0, int num)
+{
+       int bn_mul_mont_fpu(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num);
+       int bn_mul_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num);
+
+       if (num >= 8 && !(num & 1) &&
+           (OPENSSL_sparcv9cap_P & (SPARCV9_PREFER_FPU|SPARCV9_VIS1)) ==
+           (SPARCV9_PREFER_FPU|SPARCV9_VIS1))
+               return bn_mul_mont_fpu(rp, ap, bp, np, n0, num);
        else
-               return bn_mul_mont_int(rp,ap,bp,np,n0,num);
-       }
+               return bn_mul_mont_int(rp, ap, bp, np, n0, num);
+}
 
 unsigned long  _sparcv9_rdtick(void);
 void           _sparcv9_vis1_probe(void);
@@ -33,8 +35,9 @@ unsigned long _sparcv9_vis1_instrument(void);
 void           _sparcv9_vis2_probe(void);
 void           _sparcv9_fmadd_probe(void);
 
-unsigned long OPENSSL_rdtsc(void)
-       {
+unsigned long
+OPENSSL_rdtsc(void)
+{
        if (OPENSSL_sparcv9cap_P&SPARCV9_TICK_PRIVILEGED)
 #if defined(__sun) && defined(__SVR4)
                return gethrtime();
@@ -43,7 +46,7 @@ unsigned long OPENSSL_rdtsc(void)
 #endif
        else
                return _sparcv9_rdtick();
-       }
+}
 
 #if 0 && defined(__sun) && defined(__SVR4)
 /* This code path is disabled, because of incompatibility of
@@ -54,21 +57,22 @@ unsigned long OPENSSL_rdtsc(void)
 #include <libdevinfo.h>
 #include <sys/systeminfo.h>
 
-typedef di_node_t (*di_init_t)(const char *,uint_t);
+typedef di_node_t (*di_init_t)(const char *, uint_t);
 typedef void      (*di_fini_t)(di_node_t);
 typedef char *    (*di_node_name_t)(di_node_t);
-typedef int       (*di_walk_node_t)(di_node_t,uint_t,di_node_name_t,int (*)(di_node_t,di_node_name_t));
+typedef int       (*di_walk_node_t)(di_node_t, uint_t, di_node_name_t, int (*)(di_node_t, di_node_name_t));
 
 #define DLLINK(h,name) (name=(name##_t)dlsym((h),#name))
 
-static int walk_nodename(di_node_t node, di_node_name_t di_node_name)
-       {
+static int
+walk_nodename(di_node_t node, di_node_name_t di_node_name)
+{
        char *name = (*di_node_name)(node);
 
        /* This is expected to catch all UltraSPARC flavors prior T1 */
-       if (!strcmp (name,"SUNW,UltraSPARC") ||
+       if (!strcmp (name, "SUNW, UltraSPARC") ||
            !strncmp(name,"SUNW,UltraSPARC-I",17))  /* covers II,III,IV */
-               {
+       {
                OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU|SPARCV9_VIS1;
 
                /* %tick is privileged only on UltraSPARC-I/II, but not IIe */
@@ -76,51 +80,48 @@ static int walk_nodename(di_node_t node, di_node_name_t di_node_name)
                        OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED;
 
                return DI_WALK_TERMINATE;
-               }
+       }
        /* This is expected to catch remaining UltraSPARCs, such as T1 */
-       else if (!strncmp(name,"SUNW,UltraSPARC",15))
-               {
+       else if (!strncmp(name, "SUNW, UltraSPARC", 15)) {
                OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED;
 
                return DI_WALK_TERMINATE;
-               }
+       }
 
        return DI_WALK_CONTINUE;
-       }
+}
 
-void OPENSSL_cpuid_setup(void)
-       {
+void
+OPENSSL_cpuid_setup(void)
+{
        void *h;
-       char *e,si[256];
-       static int trigger=0;
+       char *e, si[256];
+       static int trigger = 0;
 
-       if (trigger) return;
-       trigger=1;
+       if (trigger)
+               return;
+       trigger = 1;
 
-       if ((e=getenv("OPENSSL_sparcv9cap")))
-               {
-               OPENSSL_sparcv9cap_P=strtoul(e,NULL,0);
+       if ((e = getenv("OPENSSL_sparcv9cap"))) {
+               OPENSSL_sparcv9cap_P = strtoul(e, NULL, 0);
                return;
-               }
+       }
 
-       if (sysinfo(SI_MACHINE,si,sizeof(si))>0)
-               {
-               if (strcmp(si,"sun4v"))
+       if (sysinfo(SI_MACHINE, si, sizeof(si)) > 0) {
+               if (strcmp(si, "sun4v"))
                        /* FPU is preferred for all CPUs, but US-T1/2 */
                        OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU;
-               }
+       }
 
-       if (sysinfo(SI_ISALIST,si,sizeof(si))>0)
-               {
-               if (strstr(si,"+vis"))
+       if (sysinfo(SI_ISALIST, si, sizeof(si)) > 0) {
+               if (strstr(si, "+vis"))
                        OPENSSL_sparcv9cap_P |= SPARCV9_VIS1;
-               if (strstr(si,"+vis2"))
-                       {
+               if (strstr(si, "+vis2")) {
                        OPENSSL_sparcv9cap_P |= SPARCV9_VIS2;
                        OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED;
                        return;
-                       }
                }
+       }
 #ifdef M_KEEP
        /*
         * Solaris libdevinfo.so.1 is effectively incomatible with
@@ -129,109 +130,115 @@ void OPENSSL_cpuid_setup(void)
         * free(3LIBMALLOC) called by di_fini. Prior call to
         * mallopt(M_KEEP,0) somehow helps... But not always...
         */
-       if ((h = dlopen(NULL,RTLD_LAZY)))
-               {
-               union { void *p; int (*f)(int,int); } sym;
-               if ((sym.p = dlsym(h,"mallopt"))) (*sym.f)(M_KEEP,0);
-               dlclose(h);
-               }
+       if ((h = dlopen(NULL, RTLD_LAZY))) {
+                       union { void *p;
+                       int (*f)(int, int);
+               } sym;
+               if ((sym.p = dlsym(h, "mallopt"))) (*sym.f)(M_KEEP, 0);
+                       dlclose(h);
+       }
 #endif
-       if ((h = dlopen("libdevinfo.so.1",RTLD_LAZY))) do
-               {
-               di_init_t       di_init;
-               di_fini_t       di_fini;
-               di_walk_node_t  di_walk_node;
-               di_node_name_t  di_node_name;
-               di_node_t       root_node;
-
-               if (!DLLINK(h,di_init))         break;
-               if (!DLLINK(h,di_fini))         break;
-               if (!DLLINK(h,di_walk_node))    break;
-               if (!DLLINK(h,di_node_name))    break;
-
-               if ((root_node = (*di_init)("/",DINFOSUBTREE))!=DI_NODE_NIL)
-                       {
-                       (*di_walk_node)(root_node,DI_WALK_SIBFIRST,
-                                       di_node_name,walk_nodename);
-                       (*di_fini)(root_node);
+       if ((h = dlopen("libdevinfo.so.1", RTLD_LAZY)))
+               do {
+                       di_init_t       di_init;
+                       di_fini_t       di_fini;
+                       di_walk_node_t  di_walk_node;
+                       di_node_name_t  di_node_name;
+                       di_node_t       root_node;
+
+                       if (!DLLINK(h, di_init))
+                               break;
+                       if (!DLLINK(h, di_fini))
+                               break;
+                       if (!DLLINK(h, di_walk_node))
+                               break;
+                       if (!DLLINK(h, di_node_name))
+                               break;
+
+                       if ((root_node = (*di_init)("/", DINFOSUBTREE)) !=
+                           DI_NODE_NIL) {
+                               (*di_walk_node)(root_node, DI_WALK_SIBFIRST,
+                                  di_node_name, walk_nodename);
+                               (*di_fini)(root_node);
                        }
-               } while(0);
+               } while (0);
 
-       if (h) dlclose(h);
-       }
+       if (h)
+               dlclose(h);
+}
 
 #else
 
 static sigjmp_buf common_jmp;
-static void common_handler(int sig) { siglongjmp(common_jmp,sig); }
-
-void OPENSSL_cpuid_setup(void)
-       {
+static void common_handler(int sig)
+{
+       siglongjmp(common_jmp, sig);
+}
+
+void
+OPENSSL_cpuid_setup(void)
+{
        char *e;
-       struct sigaction        common_act,ill_oact,bus_oact;
-       sigset_t                all_masked,oset;
-       static int trigger=0;
-
-       if (trigger) return;
-       trigger=1;
-       if ((e=getenv("OPENSSL_sparcv9cap")))
-               {
-               OPENSSL_sparcv9cap_P=strtoul(e,NULL,0);
+       struct sigaction        common_act, ill_oact, bus_oact;
+       sigset_t                all_masked, oset;
+       static int trigger = 0;
+
+       if (trigger)
                return;
-               }
+       trigger = 1;
+
+       if ((e = getenv("OPENSSL_sparcv9cap"))) {
+               OPENSSL_sparcv9cap_P = strtoul(e, NULL, 0);
+               return;
+       }
 
        /* Initial value, fits UltraSPARC-I&II... */
        OPENSSL_sparcv9cap_P = SPARCV9_PREFER_FPU|SPARCV9_TICK_PRIVILEGED;
 
        sigfillset(&all_masked);
-       sigdelset(&all_masked,SIGILL);
-       sigdelset(&all_masked,SIGTRAP);
+       sigdelset(&all_masked, SIGILL);
+       sigdelset(&all_masked, SIGTRAP);
 #ifdef SIGEMT
-       sigdelset(&all_masked,SIGEMT);
+       sigdelset(&all_masked, SIGEMT);
 #endif
-       sigdelset(&all_masked,SIGFPE);
-       sigdelset(&all_masked,SIGBUS);
-       sigdelset(&all_masked,SIGSEGV);
-       sigprocmask(SIG_SETMASK,&all_masked,&oset);
+       sigdelset(&all_masked, SIGFPE);
+       sigdelset(&all_masked, SIGBUS);
+       sigdelset(&all_masked, SIGSEGV);
+       sigprocmask(SIG_SETMASK, &all_masked, &oset);
 
-       memset(&common_act,0,sizeof(common_act));
+       memset(&common_act, 0, sizeof(common_act));
        common_act.sa_handler = common_handler;
-       common_act.sa_mask    = all_masked;
+       common_act.sa_mask = all_masked;
 
-       sigaction(SIGILL,&common_act,&ill_oact);
+       sigaction(SIGILL, &common_act, &ill_oact);
        sigaction(SIGBUS,&common_act,&bus_oact);/* T1 fails 16-bit ldda [on Linux] */
 
-       if (sigsetjmp(common_jmp,1) == 0)
-               {
+       if (sigsetjmp(common_jmp, 1) == 0) {
                _sparcv9_rdtick();
                OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED;
-               }
+       }
 
-       if (sigsetjmp(common_jmp,1) == 0)
-               {
+       if (sigsetjmp(common_jmp, 1) == 0) {
                _sparcv9_vis1_probe();
                OPENSSL_sparcv9cap_P |= SPARCV9_VIS1;
                /* detect UltraSPARC-Tx, see sparccpud.S for details... */
                if (_sparcv9_vis1_instrument() >= 12)
                        OPENSSL_sparcv9cap_P &= ~(SPARCV9_VIS1|SPARCV9_PREFER_FPU);
-               else
-                       {
+               else {
                        _sparcv9_vis2_probe();
                        OPENSSL_sparcv9cap_P |= SPARCV9_VIS2;
-                       }
                }
+       }
 
-       if (sigsetjmp(common_jmp,1) == 0)
-               {
+       if (sigsetjmp(common_jmp, 1) == 0) {
                _sparcv9_fmadd_probe();
                OPENSSL_sparcv9cap_P |= SPARCV9_FMADD;
-               }
+       }
 
-       sigaction(SIGBUS,&bus_oact,NULL);
-       sigaction(SIGILL,&ill_oact,NULL);
+       sigaction(SIGBUS, &bus_oact, NULL);
+       sigaction(SIGILL, &ill_oact, NULL);
 
-       sigprocmask(SIG_SETMASK,&oset,NULL);
-       }
+       sigprocmask(SIG_SETMASK, &oset, NULL);
+}
 
 #endif
index b1fd52b..fcfa05c 100644 (file)
 
 #include OPENSSL_UNISTD
 
-int OPENSSL_issetugid(void)
-       {
+int
+OPENSSL_issetugid(void)
+{
        return issetugid();
-       }
+}
 
 #elif defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE)
 
-int OPENSSL_issetugid(void)
-       {
+int
+OPENSSL_issetugid(void)
+{
        return 0;
-       }
+}
 
 #else
 
 #include OPENSSL_UNISTD
 #include <sys/types.h>
 
-int OPENSSL_issetugid(void)
-       {
-       if (getuid() != geteuid()) return 1;
-       if (getgid() != getegid()) return 1;
+int
+OPENSSL_issetugid(void)
+{
+       if (getuid()
+               != geteuid()) return 1;
+       if (getgid()
+               != getegid()) return 1;
        return 0;
-       }
+}
 #endif
-
-
-