From d04d79a946340eb9c440a3655e5ad4b23d5147df Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 9 Nov 2012 22:31:43 +0000 Subject: [PATCH] 2012-11-09 23:28 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbssl/*.c * contrib/xhb/*.c * manual code cleanup (single {} blocks, commented code converted to #if 0/#endif, deleted extra empty lines, made code uncrustify friendly) * applied all uncrustify fixes, except for HB_FUNC_[TRANSLATE|EXEC|etc] related code in xhb which it messes up badly. And some horizontally layed out lines in hbssl. --- harbour/ChangeLog | 11 + harbour/contrib/hbssl/bio.c | 96 ++++---- harbour/contrib/hbssl/evpciph.c | 241 +++++++++---------- harbour/contrib/hbssl/evpmd.c | 52 ++-- harbour/contrib/hbssl/pem.c | 42 ++-- harbour/contrib/hbssl/ssl.c | 94 ++++---- harbour/contrib/hbssl/ssl_hb.c | 36 +-- harbour/contrib/hbssl/sslctx.c | 20 +- harbour/contrib/hbssl/x509.c | 4 +- harbour/contrib/xhb/dbgfxc.c | 4 +- harbour/contrib/xhb/fparse.c | 2 +- harbour/contrib/xhb/hbserv.c | 410 ++++++++++++++++---------------- harbour/contrib/xhb/hbsyslog.c | 195 ++++++++------- harbour/contrib/xhb/hbxml.c | 264 +++++++------------- harbour/contrib/xhb/txtline.c | 8 - harbour/contrib/xhb/xhbcopyf.c | 8 +- harbour/contrib/xhb/xhbfunc.c | 24 +- harbour/contrib/xhb/xhbtrim.c | 8 +- 18 files changed, 724 insertions(+), 795 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 250c386a8e..5225d005a6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,17 @@ The license applies to all entries newer than 2009-04-28. */ +2012-11-09 23:28 UTC+0100 Viktor Szakats (harbour syenar.net) + * contrib/hbssl/*.c + * contrib/xhb/*.c + * manual code cleanup (single {} blocks, commented + code converted to #if 0/#endif, deleted extra empty lines, + made code uncrustify friendly) + * applied all uncrustify fixes, except for + HB_FUNC_[TRANSLATE|EXEC|etc] related code in xhb which it + messes up badly. And some horizontally layed out + lines in hbssl. + 2012-11-09 20:49 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbpgsql/postgres.c ! added missing cast causing warning in msvc C mode diff --git a/harbour/contrib/hbssl/bio.c b/harbour/contrib/hbssl/bio.c index 4bc2baf5d1..f731094097 100644 --- a/harbour/contrib/hbssl/bio.c +++ b/harbour/contrib/hbssl/bio.c @@ -76,31 +76,31 @@ static BIO_METHOD * hb_BIO_METHOD_par( int iParam ) switch( hb_parni( iParam ) ) { - case HB_BIO_METHOD_S_NULL : p = BIO_s_null(); break; + case HB_BIO_METHOD_S_NULL: p = BIO_s_null(); break; #ifndef OPENSSL_NO_FP_API - case HB_BIO_METHOD_S_FILE : p = BIO_s_file(); break; + case HB_BIO_METHOD_S_FILE: p = BIO_s_file(); break; #endif - case HB_BIO_METHOD_S_MEM : p = BIO_s_mem(); break; - case HB_BIO_METHOD_S_SOCKET : p = BIO_s_socket(); break; - case HB_BIO_METHOD_S_CONNECT : p = BIO_s_connect(); break; - case HB_BIO_METHOD_S_ACCEPT : p = BIO_s_accept(); break; - case HB_BIO_METHOD_S_FD : p = BIO_s_fd(); break; + case HB_BIO_METHOD_S_MEM: p = BIO_s_mem(); break; + case HB_BIO_METHOD_S_SOCKET: p = BIO_s_socket(); break; + case HB_BIO_METHOD_S_CONNECT: p = BIO_s_connect(); break; + case HB_BIO_METHOD_S_ACCEPT: p = BIO_s_accept(); break; + case HB_BIO_METHOD_S_FD: p = BIO_s_fd(); break; #if 0 /* BIO_s_log() isn't exported via implibs on Windows at version 0.9.8k. [vszakats] */ #ifndef OPENSSL_SYS_OS2 - case HB_BIO_METHOD_S_LOG : p = BIO_s_log(); break; + case HB_BIO_METHOD_S_LOG: p = BIO_s_log(); break; #endif #endif - case HB_BIO_METHOD_S_BIO : p = BIO_s_bio(); break; + case HB_BIO_METHOD_S_BIO: p = BIO_s_bio(); break; #ifndef OPENSSL_NO_DGRAM - case HB_BIO_METHOD_S_DATAGRAM : p = BIO_s_datagram(); break; + case HB_BIO_METHOD_S_DATAGRAM: p = BIO_s_datagram(); break; #endif - case HB_BIO_METHOD_F_NULL : p = BIO_f_null(); break; - case HB_BIO_METHOD_F_BUFFER : p = BIO_f_buffer(); break; + case HB_BIO_METHOD_F_NULL: p = BIO_f_null(); break; + case HB_BIO_METHOD_F_BUFFER: p = BIO_f_buffer(); break; #ifdef OPENSSL_SYS_VMS - case HB_BIO_METHOD_F_LINEBUFFER : p = BIO_f_linebuffer(); break; + case HB_BIO_METHOD_F_LINEBUFFER: p = BIO_f_linebuffer(); break; #endif - case HB_BIO_METHOD_F_NBIO_TEST : p = BIO_f_nbio_test(); break; - default : p = NULL; + case HB_BIO_METHOD_F_NBIO_TEST: p = BIO_f_nbio_test(); break; + default: p = NULL; } return p; @@ -697,47 +697,47 @@ HB_FUNC( ERR_LOAD_BIO_STRINGS ) #if 0 -#define BIO_set_url(b,url) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,0,(char *)(url)) -#define BIO_set_proxies(b,p) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,1,(char *)(p)) +#define BIO_set_url( b, url ) BIO_ctrl( b, BIO_C_SET_PROXY_PARAM, 0, ( char * ) ( url ) ) +#define BIO_set_proxies( b, p ) BIO_ctrl( b, BIO_C_SET_PROXY_PARAM, 1, ( char * ) ( p ) ) /* BIO_set_nbio(b,n) */ -#define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s)) +#define BIO_set_filter_bio( b, s ) BIO_ctrl( b, BIO_C_SET_PROXY_PARAM, 2, ( char * ) ( s ) ) /* BIO *BIO_get_filter_bio(BIO *bio); */ -#define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)())) -#define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk) -#define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool) +#define BIO_set_proxy_cb( b, cb ) BIO_callback_ctrl( b, BIO_C_SET_PROXY_PARAM, 3, ( void *( *cb )( ) ) ) +#define BIO_set_proxy_header( b, sk ) BIO_ctrl( b, BIO_C_SET_PROXY_PARAM, 4, ( char * ) sk ) +#define BIO_set_no_connect_return( b, bool ) BIO_int_ctrl( b, BIO_C_SET_PROXY_PARAM, 5, bool ) -#define BIO_get_proxy_header(b,skp) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,0,(char *)skp) -#define BIO_get_proxies(b,pxy_p) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,1,(char *)(pxy_p)) -#define BIO_get_url(b,url) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url)) -#define BIO_get_no_connect_return(b) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL) +#define BIO_get_proxy_header( b, skp ) BIO_ctrl( b, BIO_C_GET_PROXY_PARAM, 0, ( char * ) skp ) +#define BIO_get_proxies( b, pxy_p ) BIO_ctrl( b, BIO_C_GET_PROXY_PARAM, 1, ( char * ) ( pxy_p ) ) +#define BIO_get_url( b, url ) BIO_ctrl( b, BIO_C_GET_PROXY_PARAM, 2, ( char * ) ( url ) ) +#define BIO_get_no_connect_return( b ) BIO_ctrl( b, BIO_C_GET_PROXY_PARAM, 5, NULL ) -#define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp) -#define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp) +#define BIO_set_fp( b, fp, c ) BIO_ctrl( b, BIO_C_SET_FILE_PTR, c, ( char * ) fp ) +#define BIO_get_fp( b, fpp ) BIO_ctrl( b, BIO_C_GET_FILE_PTR, 0, ( char * ) fpp ) -int BIO_indent(BIO *b,int indent,int max); -long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); -long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)(struct bio_st *, int, const char *, int, long, long)); -char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); -long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg); -BIO * BIO_push(BIO *b,BIO *append); -BIO * BIO_pop(BIO *b); -BIO * BIO_find_type(BIO *b,int bio_type); -BIO * BIO_next(BIO *b); -BIO * BIO_get_retry_BIO(BIO *bio, int *reason); -BIO * BIO_dup_chain(BIO *in); +int BIO_indent( BIO * b, int indent, int max ); +long BIO_ctrl( BIO * bp, int cmd, long larg, void * parg ); +long BIO_callback_ctrl( BIO * b, int cmd, void ( * fp )( struct bio_st *, int, const char *, int, long, long ) ); +char * BIO_ptr_ctrl( BIO * bp, int cmd, long larg ); +long BIO_int_ctrl( BIO * bp, int cmd, long larg, int iarg ); +BIO * BIO_push( BIO * b, BIO * append ); +BIO * BIO_pop( BIO * b ); +BIO * BIO_find_type( BIO * b, int bio_type ); +BIO * BIO_next( BIO * b ); +BIO * BIO_get_retry_BIO( BIO * bio, int * reason ); +BIO * BIO_dup_chain( BIO * in ); -int BIO_nread0(BIO *bio, char **buf); -int BIO_nread(BIO *bio, char **buf, int num); -int BIO_nwrite0(BIO *bio, char **buf); -int BIO_nwrite(BIO *bio, char **buf, int num); +int BIO_nread0( BIO * bio, char ** buf ); +int BIO_nread( BIO * bio, char ** buf, int num ); +int BIO_nwrite0( BIO * bio, char ** buf ); +int BIO_nwrite( BIO * bio, char ** buf, int num ); -BIO_METHOD * BIO_s_mem(void); +BIO_METHOD * BIO_s_mem( void ); -BIO_set_mem_eof_return(BIO *b,int v) -long BIO_get_mem_data(BIO *b, char **pp) -BIO_set_mem_buf(BIO *b,BUF_MEM *bm,int c) -BIO_get_mem_ptr(BIO *b,BUF_MEM **pp) +BIO_set_mem_eof_return( BIO * b, int v ) +long BIO_get_mem_data( BIO * b, char ** pp ) +BIO_set_mem_buf( BIO * b, BUF_MEM * bm, int c ) +BIO_get_mem_ptr( BIO * b, BUF_MEM * *pp ) -BIO *BIO_new_mem_buf(void *buf, int len); +BIO * BIO_new_mem_buf( void * buf, int len ); #endif diff --git a/harbour/contrib/hbssl/evpciph.c b/harbour/contrib/hbssl/evpciph.c index 482cddc9cd..7b12243dd3 100644 --- a/harbour/contrib/hbssl/evpciph.c +++ b/harbour/contrib/hbssl/evpciph.c @@ -68,15 +68,15 @@ static HB_GARBAGE_FUNC( EVP_CIPHER_CTX_release ) void ** ph = ( void ** ) Cargo; /* Check if pointer is not NULL to avoid multiple freeing */ - if( ph && * ph ) + if( ph && *ph ) { /* Cleanup the object */ - EVP_CIPHER_CTX_cleanup( ( EVP_CIPHER_CTX * ) * ph ); + EVP_CIPHER_CTX_cleanup( ( EVP_CIPHER_CTX * ) *ph ); /* Destroy the object */ - hb_xfree( * ph ); + hb_xfree( *ph ); /* set pointer to NULL just in case */ - * ph = NULL; + *ph = NULL; } } @@ -95,7 +95,7 @@ static EVP_CIPHER_CTX * hb_EVP_CIPHER_CTX_par( int iParam ) { void ** ph = ( void ** ) hb_parptrGC( &s_gcEVP_CIPHER_CTX_funcs, iParam ); - return ph ? ( EVP_CIPHER_CTX * ) * ph : NULL; + return ph ? ( EVP_CIPHER_CTX * ) *ph : NULL; } int hb_EVP_CIPHER_is( int iParam ) @@ -112,126 +112,126 @@ const EVP_CIPHER * hb_EVP_CIPHER_par( int iParam ) switch( hb_parni( iParam ) ) { - case HB_EVP_CIPHER_ENC_NULL : p = EVP_enc_null(); break; + case HB_EVP_CIPHER_ENC_NULL: p = EVP_enc_null(); break; #ifndef OPENSSL_NO_DES - case HB_EVP_CIPHER_DES_ECB : p = EVP_des_ecb(); break; - case HB_EVP_CIPHER_DES_EDE : p = EVP_des_ede(); break; - case HB_EVP_CIPHER_DES_EDE3 : p = EVP_des_ede3(); break; - case HB_EVP_CIPHER_DES_EDE_ECB : p = EVP_des_ede_ecb(); break; - case HB_EVP_CIPHER_DES_EDE3_ECB : p = EVP_des_ede3_ecb(); break; - case HB_EVP_CIPHER_DES_CFB64 : p = EVP_des_cfb64(); break; - case HB_EVP_CIPHER_DES_CFB : p = EVP_des_cfb(); break; - case HB_EVP_CIPHER_DES_CFB1 : p = EVP_des_cfb1(); break; - case HB_EVP_CIPHER_DES_CFB8 : p = EVP_des_cfb8(); break; - case HB_EVP_CIPHER_DES_EDE_CFB64 : p = EVP_des_ede_cfb64(); break; - case HB_EVP_CIPHER_DES_EDE_CFB : p = EVP_des_ede_cfb(); break; - case HB_EVP_CIPHER_DES_EDE3_CFB64 : p = EVP_des_ede3_cfb64(); break; - case HB_EVP_CIPHER_DES_EDE3_CFB : p = EVP_des_ede3_cfb(); break; - case HB_EVP_CIPHER_DES_EDE3_CFB1 : p = EVP_des_ede3_cfb1(); break; - case HB_EVP_CIPHER_DES_EDE3_CFB8 : p = EVP_des_ede3_cfb8(); break; - case HB_EVP_CIPHER_DES_OFB : p = EVP_des_ofb(); break; - case HB_EVP_CIPHER_DES_EDE_OFB : p = EVP_des_ede_ofb(); break; - case HB_EVP_CIPHER_DES_EDE3_OFB : p = EVP_des_ede3_ofb(); break; - case HB_EVP_CIPHER_DES_CBC : p = EVP_des_cbc(); break; - case HB_EVP_CIPHER_DES_EDE_CBC : p = EVP_des_ede_cbc(); break; - case HB_EVP_CIPHER_DES_EDE3_CBC : p = EVP_des_ede3_cbc(); break; - case HB_EVP_CIPHER_DESX_CBC : p = EVP_desx_cbc(); break; + case HB_EVP_CIPHER_DES_ECB: p = EVP_des_ecb(); break; + case HB_EVP_CIPHER_DES_EDE: p = EVP_des_ede(); break; + case HB_EVP_CIPHER_DES_EDE3: p = EVP_des_ede3(); break; + case HB_EVP_CIPHER_DES_EDE_ECB: p = EVP_des_ede_ecb(); break; + case HB_EVP_CIPHER_DES_EDE3_ECB: p = EVP_des_ede3_ecb(); break; + case HB_EVP_CIPHER_DES_CFB64: p = EVP_des_cfb64(); break; + case HB_EVP_CIPHER_DES_CFB: p = EVP_des_cfb(); break; + case HB_EVP_CIPHER_DES_CFB1: p = EVP_des_cfb1(); break; + case HB_EVP_CIPHER_DES_CFB8: p = EVP_des_cfb8(); break; + case HB_EVP_CIPHER_DES_EDE_CFB64: p = EVP_des_ede_cfb64(); break; + case HB_EVP_CIPHER_DES_EDE_CFB: p = EVP_des_ede_cfb(); break; + case HB_EVP_CIPHER_DES_EDE3_CFB64: p = EVP_des_ede3_cfb64(); break; + case HB_EVP_CIPHER_DES_EDE3_CFB: p = EVP_des_ede3_cfb(); break; + case HB_EVP_CIPHER_DES_EDE3_CFB1: p = EVP_des_ede3_cfb1(); break; + case HB_EVP_CIPHER_DES_EDE3_CFB8: p = EVP_des_ede3_cfb8(); break; + case HB_EVP_CIPHER_DES_OFB: p = EVP_des_ofb(); break; + case HB_EVP_CIPHER_DES_EDE_OFB: p = EVP_des_ede_ofb(); break; + case HB_EVP_CIPHER_DES_EDE3_OFB: p = EVP_des_ede3_ofb(); break; + case HB_EVP_CIPHER_DES_CBC: p = EVP_des_cbc(); break; + case HB_EVP_CIPHER_DES_EDE_CBC: p = EVP_des_ede_cbc(); break; + case HB_EVP_CIPHER_DES_EDE3_CBC: p = EVP_des_ede3_cbc(); break; + case HB_EVP_CIPHER_DESX_CBC: p = EVP_desx_cbc(); break; #endif #ifndef OPENSSL_NO_RC4 - case HB_EVP_CIPHER_RC4 : p = EVP_rc4(); break; - case HB_EVP_CIPHER_RC4_40 : p = EVP_rc4_40(); break; + case HB_EVP_CIPHER_RC4: p = EVP_rc4(); break; + case HB_EVP_CIPHER_RC4_40: p = EVP_rc4_40(); break; #endif #ifndef OPENSSL_NO_IDEA - case HB_EVP_CIPHER_IDEA_ECB : p = EVP_idea_ecb(); break; - case HB_EVP_CIPHER_IDEA_CFB64 : p = EVP_idea_cfb64(); break; - case HB_EVP_CIPHER_IDEA_CFB : p = EVP_idea_cfb(); break; - case HB_EVP_CIPHER_IDEA_OFB : p = EVP_idea_ofb(); break; - case HB_EVP_CIPHER_IDEA_CBC : p = EVP_idea_cbc(); break; + case HB_EVP_CIPHER_IDEA_ECB: p = EVP_idea_ecb(); break; + case HB_EVP_CIPHER_IDEA_CFB64: p = EVP_idea_cfb64(); break; + case HB_EVP_CIPHER_IDEA_CFB: p = EVP_idea_cfb(); break; + case HB_EVP_CIPHER_IDEA_OFB: p = EVP_idea_ofb(); break; + case HB_EVP_CIPHER_IDEA_CBC: p = EVP_idea_cbc(); break; #endif #ifndef OPENSSL_NO_RC2 - case HB_EVP_CIPHER_RC2_ECB : p = EVP_rc2_ecb(); break; - case HB_EVP_CIPHER_RC2_CBC : p = EVP_rc2_cbc(); break; - case HB_EVP_CIPHER_RC2_40_CBC : p = EVP_rc2_40_cbc(); break; - case HB_EVP_CIPHER_RC2_64_CBC : p = EVP_rc2_64_cbc(); break; - case HB_EVP_CIPHER_RC2_CFB64 : p = EVP_rc2_cfb64(); break; - case HB_EVP_CIPHER_RC2_CFB : p = EVP_rc2_cfb(); break; - case HB_EVP_CIPHER_RC2_OFB : p = EVP_rc2_ofb(); break; + case HB_EVP_CIPHER_RC2_ECB: p = EVP_rc2_ecb(); break; + case HB_EVP_CIPHER_RC2_CBC: p = EVP_rc2_cbc(); break; + case HB_EVP_CIPHER_RC2_40_CBC: p = EVP_rc2_40_cbc(); break; + case HB_EVP_CIPHER_RC2_64_CBC: p = EVP_rc2_64_cbc(); break; + case HB_EVP_CIPHER_RC2_CFB64: p = EVP_rc2_cfb64(); break; + case HB_EVP_CIPHER_RC2_CFB: p = EVP_rc2_cfb(); break; + case HB_EVP_CIPHER_RC2_OFB: p = EVP_rc2_ofb(); break; #endif #ifndef OPENSSL_NO_BF - case HB_EVP_CIPHER_BF_ECB : p = EVP_bf_ecb(); break; - case HB_EVP_CIPHER_BF_CBC : p = EVP_bf_cbc(); break; - case HB_EVP_CIPHER_BF_CFB64 : p = EVP_bf_cfb64(); break; - case HB_EVP_CIPHER_BF_CFB : p = EVP_bf_cfb(); break; - case HB_EVP_CIPHER_BF_OFB : p = EVP_bf_ofb(); break; + case HB_EVP_CIPHER_BF_ECB: p = EVP_bf_ecb(); break; + case HB_EVP_CIPHER_BF_CBC: p = EVP_bf_cbc(); break; + case HB_EVP_CIPHER_BF_CFB64: p = EVP_bf_cfb64(); break; + case HB_EVP_CIPHER_BF_CFB: p = EVP_bf_cfb(); break; + case HB_EVP_CIPHER_BF_OFB: p = EVP_bf_ofb(); break; #endif #ifndef OPENSSL_NO_CAST - case HB_EVP_CIPHER_CAST5_ECB : p = EVP_cast5_ecb(); break; - case HB_EVP_CIPHER_CAST5_CBC : p = EVP_cast5_cbc(); break; - case HB_EVP_CIPHER_CAST5_CFB64 : p = EVP_cast5_cfb64(); break; - case HB_EVP_CIPHER_CAST5_CFB : p = EVP_cast5_cfb(); break; - case HB_EVP_CIPHER_CAST5_OFB : p = EVP_cast5_ofb(); break; + case HB_EVP_CIPHER_CAST5_ECB: p = EVP_cast5_ecb(); break; + case HB_EVP_CIPHER_CAST5_CBC: p = EVP_cast5_cbc(); break; + case HB_EVP_CIPHER_CAST5_CFB64: p = EVP_cast5_cfb64(); break; + case HB_EVP_CIPHER_CAST5_CFB: p = EVP_cast5_cfb(); break; + case HB_EVP_CIPHER_CAST5_OFB: p = EVP_cast5_ofb(); break; #endif #ifndef OPENSSL_NO_RC5 - case HB_EVP_CIPHER_RC5_32_12_16_CBC : p = EVP_rc5_32_12_16_cbc(); break; - case HB_EVP_CIPHER_RC5_32_12_16_ECB : p = EVP_rc5_32_12_16_ecb(); break; - case HB_EVP_CIPHER_RC5_32_12_16_CFB64 : p = EVP_rc5_32_12_16_cfb64(); break; - case HB_EVP_CIPHER_RC5_32_12_16_CFB : p = EVP_rc5_32_12_16_cfb(); break; - case HB_EVP_CIPHER_RC5_32_12_16_OFB : p = EVP_rc5_32_12_16_ofb(); break; + case HB_EVP_CIPHER_RC5_32_12_16_CBC: p = EVP_rc5_32_12_16_cbc(); break; + case HB_EVP_CIPHER_RC5_32_12_16_ECB: p = EVP_rc5_32_12_16_ecb(); break; + case HB_EVP_CIPHER_RC5_32_12_16_CFB64: p = EVP_rc5_32_12_16_cfb64(); break; + case HB_EVP_CIPHER_RC5_32_12_16_CFB: p = EVP_rc5_32_12_16_cfb(); break; + case HB_EVP_CIPHER_RC5_32_12_16_OFB: p = EVP_rc5_32_12_16_ofb(); break; #endif #ifndef OPENSSL_NO_AES - case HB_EVP_CIPHER_AES_128_ECB : p = EVP_aes_128_ecb(); break; - case HB_EVP_CIPHER_AES_128_CBC : p = EVP_aes_128_cbc(); break; - case HB_EVP_CIPHER_AES_128_CFB1 : p = EVP_aes_128_cfb1(); break; - case HB_EVP_CIPHER_AES_128_CFB8 : p = EVP_aes_128_cfb8(); break; - case HB_EVP_CIPHER_AES_128_CFB128 : p = EVP_aes_128_cfb128(); break; - case HB_EVP_CIPHER_AES_128_CFB : p = EVP_aes_128_cfb(); break; - case HB_EVP_CIPHER_AES_128_OFB : p = EVP_aes_128_ofb(); break; - case HB_EVP_CIPHER_AES_192_ECB : p = EVP_aes_192_ecb(); break; - case HB_EVP_CIPHER_AES_192_CBC : p = EVP_aes_192_cbc(); break; - case HB_EVP_CIPHER_AES_192_CFB1 : p = EVP_aes_192_cfb1(); break; - case HB_EVP_CIPHER_AES_192_CFB8 : p = EVP_aes_192_cfb8(); break; - case HB_EVP_CIPHER_AES_192_CFB128 : p = EVP_aes_192_cfb128(); break; - case HB_EVP_CIPHER_AES_192_CFB : p = EVP_aes_192_cfb(); break; - case HB_EVP_CIPHER_AES_192_OFB : p = EVP_aes_192_ofb(); break; - case HB_EVP_CIPHER_AES_256_ECB : p = EVP_aes_256_ecb(); break; - case HB_EVP_CIPHER_AES_256_CBC : p = EVP_aes_256_cbc(); break; - case HB_EVP_CIPHER_AES_256_CFB1 : p = EVP_aes_256_cfb1(); break; - case HB_EVP_CIPHER_AES_256_CFB8 : p = EVP_aes_256_cfb8(); break; - case HB_EVP_CIPHER_AES_256_CFB128 : p = EVP_aes_256_cfb128(); break; - case HB_EVP_CIPHER_AES_256_CFB : p = EVP_aes_256_cfb(); break; - case HB_EVP_CIPHER_AES_256_OFB : p = EVP_aes_256_ofb(); break; + case HB_EVP_CIPHER_AES_128_ECB: p = EVP_aes_128_ecb(); break; + case HB_EVP_CIPHER_AES_128_CBC: p = EVP_aes_128_cbc(); break; + case HB_EVP_CIPHER_AES_128_CFB1: p = EVP_aes_128_cfb1(); break; + case HB_EVP_CIPHER_AES_128_CFB8: p = EVP_aes_128_cfb8(); break; + case HB_EVP_CIPHER_AES_128_CFB128: p = EVP_aes_128_cfb128(); break; + case HB_EVP_CIPHER_AES_128_CFB: p = EVP_aes_128_cfb(); break; + case HB_EVP_CIPHER_AES_128_OFB: p = EVP_aes_128_ofb(); break; + case HB_EVP_CIPHER_AES_192_ECB: p = EVP_aes_192_ecb(); break; + case HB_EVP_CIPHER_AES_192_CBC: p = EVP_aes_192_cbc(); break; + case HB_EVP_CIPHER_AES_192_CFB1: p = EVP_aes_192_cfb1(); break; + case HB_EVP_CIPHER_AES_192_CFB8: p = EVP_aes_192_cfb8(); break; + case HB_EVP_CIPHER_AES_192_CFB128: p = EVP_aes_192_cfb128(); break; + case HB_EVP_CIPHER_AES_192_CFB: p = EVP_aes_192_cfb(); break; + case HB_EVP_CIPHER_AES_192_OFB: p = EVP_aes_192_ofb(); break; + case HB_EVP_CIPHER_AES_256_ECB: p = EVP_aes_256_ecb(); break; + case HB_EVP_CIPHER_AES_256_CBC: p = EVP_aes_256_cbc(); break; + case HB_EVP_CIPHER_AES_256_CFB1: p = EVP_aes_256_cfb1(); break; + case HB_EVP_CIPHER_AES_256_CFB8: p = EVP_aes_256_cfb8(); break; + case HB_EVP_CIPHER_AES_256_CFB128: p = EVP_aes_256_cfb128(); break; + case HB_EVP_CIPHER_AES_256_CFB: p = EVP_aes_256_cfb(); break; + case HB_EVP_CIPHER_AES_256_OFB: p = EVP_aes_256_ofb(); break; #endif #ifndef OPENSSL_NO_CAMELLIA - case HB_EVP_CIPHER_CAMELLIA_128_ECB : p = EVP_camellia_128_ecb(); break; - case HB_EVP_CIPHER_CAMELLIA_128_CBC : p = EVP_camellia_128_cbc(); break; - case HB_EVP_CIPHER_CAMELLIA_128_CFB1 : p = EVP_camellia_128_cfb1(); break; - case HB_EVP_CIPHER_CAMELLIA_128_CFB8 : p = EVP_camellia_128_cfb8(); break; - case HB_EVP_CIPHER_CAMELLIA_128_CFB128 : p = EVP_camellia_128_cfb128(); break; - case HB_EVP_CIPHER_CAMELLIA_128_CFB : p = EVP_camellia_128_cfb(); break; - case HB_EVP_CIPHER_CAMELLIA_128_OFB : p = EVP_camellia_128_ofb(); break; - case HB_EVP_CIPHER_CAMELLIA_192_ECB : p = EVP_camellia_192_ecb(); break; - case HB_EVP_CIPHER_CAMELLIA_192_CBC : p = EVP_camellia_192_cbc(); break; - case HB_EVP_CIPHER_CAMELLIA_192_CFB1 : p = EVP_camellia_192_cfb1(); break; - case HB_EVP_CIPHER_CAMELLIA_192_CFB8 : p = EVP_camellia_192_cfb8(); break; - case HB_EVP_CIPHER_CAMELLIA_192_CFB128 : p = EVP_camellia_192_cfb128(); break; - case HB_EVP_CIPHER_CAMELLIA_192_CFB : p = EVP_camellia_192_cfb(); break; - case HB_EVP_CIPHER_CAMELLIA_192_OFB : p = EVP_camellia_192_ofb(); break; - case HB_EVP_CIPHER_CAMELLIA_256_ECB : p = EVP_camellia_256_ecb(); break; - case HB_EVP_CIPHER_CAMELLIA_256_CBC : p = EVP_camellia_256_cbc(); break; - case HB_EVP_CIPHER_CAMELLIA_256_CFB1 : p = EVP_camellia_256_cfb1(); break; - case HB_EVP_CIPHER_CAMELLIA_256_CFB8 : p = EVP_camellia_256_cfb8(); break; - case HB_EVP_CIPHER_CAMELLIA_256_CFB128 : p = EVP_camellia_256_cfb128(); break; - case HB_EVP_CIPHER_CAMELLIA_256_CFB : p = EVP_camellia_256_cfb(); break; - case HB_EVP_CIPHER_CAMELLIA_256_OFB : p = EVP_camellia_256_ofb(); break; + case HB_EVP_CIPHER_CAMELLIA_128_ECB: p = EVP_camellia_128_ecb(); break; + case HB_EVP_CIPHER_CAMELLIA_128_CBC: p = EVP_camellia_128_cbc(); break; + case HB_EVP_CIPHER_CAMELLIA_128_CFB1: p = EVP_camellia_128_cfb1(); break; + case HB_EVP_CIPHER_CAMELLIA_128_CFB8: p = EVP_camellia_128_cfb8(); break; + case HB_EVP_CIPHER_CAMELLIA_128_CFB128: p = EVP_camellia_128_cfb128(); break; + case HB_EVP_CIPHER_CAMELLIA_128_CFB: p = EVP_camellia_128_cfb(); break; + case HB_EVP_CIPHER_CAMELLIA_128_OFB: p = EVP_camellia_128_ofb(); break; + case HB_EVP_CIPHER_CAMELLIA_192_ECB: p = EVP_camellia_192_ecb(); break; + case HB_EVP_CIPHER_CAMELLIA_192_CBC: p = EVP_camellia_192_cbc(); break; + case HB_EVP_CIPHER_CAMELLIA_192_CFB1: p = EVP_camellia_192_cfb1(); break; + case HB_EVP_CIPHER_CAMELLIA_192_CFB8: p = EVP_camellia_192_cfb8(); break; + case HB_EVP_CIPHER_CAMELLIA_192_CFB128: p = EVP_camellia_192_cfb128(); break; + case HB_EVP_CIPHER_CAMELLIA_192_CFB: p = EVP_camellia_192_cfb(); break; + case HB_EVP_CIPHER_CAMELLIA_192_OFB: p = EVP_camellia_192_ofb(); break; + case HB_EVP_CIPHER_CAMELLIA_256_ECB: p = EVP_camellia_256_ecb(); break; + case HB_EVP_CIPHER_CAMELLIA_256_CBC: p = EVP_camellia_256_cbc(); break; + case HB_EVP_CIPHER_CAMELLIA_256_CFB1: p = EVP_camellia_256_cfb1(); break; + case HB_EVP_CIPHER_CAMELLIA_256_CFB8: p = EVP_camellia_256_cfb8(); break; + case HB_EVP_CIPHER_CAMELLIA_256_CFB128: p = EVP_camellia_256_cfb128(); break; + case HB_EVP_CIPHER_CAMELLIA_256_CFB: p = EVP_camellia_256_cfb(); break; + case HB_EVP_CIPHER_CAMELLIA_256_OFB: p = EVP_camellia_256_ofb(); break; #endif #ifndef OPENSSL_NO_SEED - case HB_EVP_CIPHER_SEED_ECB : p = EVP_seed_ecb(); break; - case HB_EVP_CIPHER_SEED_CBC : p = EVP_seed_cbc(); break; - case HB_EVP_CIPHER_SEED_CFB128 : p = EVP_seed_cfb128(); break; - case HB_EVP_CIPHER_SEED_CFB : p = EVP_seed_cfb(); break; - case HB_EVP_CIPHER_SEED_OFB : p = EVP_seed_ofb(); break; + case HB_EVP_CIPHER_SEED_ECB: p = EVP_seed_ecb(); break; + case HB_EVP_CIPHER_SEED_CBC: p = EVP_seed_cbc(); break; + case HB_EVP_CIPHER_SEED_CFB128: p = EVP_seed_cfb128(); break; + case HB_EVP_CIPHER_SEED_CFB: p = EVP_seed_cfb(); break; + case HB_EVP_CIPHER_SEED_OFB: p = EVP_seed_ofb(); break; #endif - default : p = NULL; + default: p = NULL; } return p; @@ -438,7 +438,7 @@ HB_FUNC( HB_EVP_CIPHER_CTX_CREATE ) EVP_CIPHER_CTX_init( ctx ); - * ph = ctx; + *ph = ctx; hb_retptrGC( ph ); } @@ -933,9 +933,9 @@ HB_FUNC( EVP_SEALINIT ) if( ctx ) { - int npubk = 0; - PHB_ITEM pArray = NULL; - EVP_PKEY * pkey1 = NULL; + int npubk = 0; + PHB_ITEM pArray = NULL; + EVP_PKEY * pkey1 = NULL; if( HB_ISARRAY( 5 ) ) npubk = ( int ) hb_arrayLen( pArray = hb_param( 5, HB_IT_ARRAY ) ); @@ -949,17 +949,18 @@ HB_FUNC( EVP_SEALINIT ) { unsigned char ** ek = ( unsigned char ** ) hb_xgrab( sizeof( unsigned char * ) * npubk ); int * ekl = ( int * ) hb_xgrab( sizeof( int ) * npubk ); - int ivl = EVP_CIPHER_iv_length( cipher ); + int ivl = EVP_CIPHER_iv_length( cipher ); unsigned char * iv = ivl > 0 ? ( unsigned char * ) hb_xgrab( ivl + 1 ) : NULL; + EVP_PKEY ** pubk = ( EVP_PKEY ** ) hb_xgrab( sizeof( EVP_PKEY * ) * npubk + 1 ); - PHB_ITEM pPKEY; - int tmp; + PHB_ITEM pPKEY; + int tmp; for( tmp = 0; tmp < npubk; tmp++ ) { pubk[ tmp ] = pkey1 ? pkey1 : ( EVP_PKEY * ) hb_arrayGetPtr( pArray, tmp + 1 ); - ek[ tmp ] = ( unsigned char * ) hb_xgrab( EVP_PKEY_size( pubk[ tmp ] ) + 1 ); - ekl[ tmp ] = 0; + ek[ tmp ] = ( unsigned char * ) hb_xgrab( EVP_PKEY_size( pubk[ tmp ] ) + 1 ); + ekl[ tmp ] = 0; } hb_retni( EVP_SealInit( ctx, @@ -1064,8 +1065,8 @@ HB_FUNC( EVP_OPENINIT ) if( hb_EVP_CIPHER_CTX_is( 1 ) && cipher ) { - EVP_CIPHER_CTX * ctx = hb_EVP_CIPHER_CTX_par( 1 ); - EVP_PKEY * priv = ( EVP_PKEY * ) hb_parptr( 5 ); + EVP_CIPHER_CTX * ctx = hb_EVP_CIPHER_CTX_par( 1 ); + EVP_PKEY * priv = ( EVP_PKEY * ) hb_parptr( 5 ); if( ctx && priv ) hb_retni( EVP_OpenInit( ctx, @@ -1143,10 +1144,10 @@ HB_FUNC( EVP_OPENFINAL ) #if 0 -#define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data) -#define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d)) +#define EVP_CIPHER_CTX_get_app_data( e ) ( ( e )->app_data ) +#define EVP_CIPHER_CTX_set_app_data( e, d ) ( ( e )->app_data = ( char * ) ( d ) ) -int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); -int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); +int EVP_CIPHER_param_to_asn1( EVP_CIPHER_CTX * c, ASN1_TYPE * type ); +int EVP_CIPHER_asn1_to_param( EVP_CIPHER_CTX * c, ASN1_TYPE * type ); #endif diff --git a/harbour/contrib/hbssl/evpmd.c b/harbour/contrib/hbssl/evpmd.c index 8f18ee4edc..1ec46c5092 100644 --- a/harbour/contrib/hbssl/evpmd.c +++ b/harbour/contrib/hbssl/evpmd.c @@ -68,13 +68,13 @@ static HB_GARBAGE_FUNC( EVP_MD_CTX_release ) void ** ph = ( void ** ) Cargo; /* Check if pointer is not NULL to avoid multiple freeing */ - if( ph && * ph ) + if( ph && *ph ) { /* Destroy the object */ - EVP_MD_CTX_destroy( ( EVP_MD_CTX * ) * ph ); + EVP_MD_CTX_destroy( ( EVP_MD_CTX * ) *ph ); /* set pointer to NULL just in case */ - * ph = NULL; + *ph = NULL; } } @@ -93,7 +93,7 @@ static EVP_MD_CTX * hb_EVP_MD_CTX_par( int iParam ) { void ** ph = ( void ** ) hb_parptrGC( &s_gcEVP_MD_CTX_funcs, iParam ); - return ph ? ( EVP_MD_CTX * ) * ph : NULL; + return ph ? ( EVP_MD_CTX * ) *ph : NULL; } int hb_EVP_MD_is( int iParam ) @@ -110,40 +110,40 @@ const EVP_MD * hb_EVP_MD_par( int iParam ) switch( hb_parni( iParam ) ) { - case HB_EVP_MD_MD_NULL : p = EVP_md_null(); break; + case HB_EVP_MD_MD_NULL: p = EVP_md_null(); break; #if ! defined( OPENSSL_NO_MD2 ) && OPENSSL_VERSION_NUMBER < 0x10000000L - case HB_EVP_MD_MD2 : p = EVP_md2(); break; + case HB_EVP_MD_MD2: p = EVP_md2(); break; #endif #ifndef OPENSSL_NO_MD4 - case HB_EVP_MD_MD4 : p = EVP_md4(); break; + case HB_EVP_MD_MD4: p = EVP_md4(); break; #endif #ifndef OPENSSL_NO_MD5 - case HB_EVP_MD_MD5 : p = EVP_md5(); break; + case HB_EVP_MD_MD5: p = EVP_md5(); break; #endif #ifndef OPENSSL_NO_SHA - case HB_EVP_MD_SHA : p = EVP_sha(); break; - case HB_EVP_MD_SHA1 : p = EVP_sha1(); break; - case HB_EVP_MD_DSS : p = EVP_dss(); break; - case HB_EVP_MD_DSS1 : p = EVP_dss1(); break; + case HB_EVP_MD_SHA: p = EVP_sha(); break; + case HB_EVP_MD_SHA1: p = EVP_sha1(); break; + case HB_EVP_MD_DSS: p = EVP_dss(); break; + case HB_EVP_MD_DSS1: p = EVP_dss1(); break; #if ! defined( HB_OPENSSL_OLD_OSX_ ) - case HB_EVP_MD_ECDSA : p = EVP_ecdsa(); break; + case HB_EVP_MD_ECDSA: p = EVP_ecdsa(); break; #endif #endif #ifndef OPENSSL_NO_SHA256 - case HB_EVP_MD_SHA224 : p = EVP_sha224(); break; - case HB_EVP_MD_SHA256 : p = EVP_sha256(); break; + case HB_EVP_MD_SHA224: p = EVP_sha224(); break; + case HB_EVP_MD_SHA256: p = EVP_sha256(); break; #endif #ifndef OPENSSL_NO_SHA512 - case HB_EVP_MD_SHA384 : p = EVP_sha384(); break; - case HB_EVP_MD_SHA512 : p = EVP_sha512(); break; + case HB_EVP_MD_SHA384: p = EVP_sha384(); break; + case HB_EVP_MD_SHA512: p = EVP_sha512(); break; #endif #ifndef OPENSSL_NO_MDC2 - case HB_EVP_MD_MDC2 : p = EVP_mdc2(); break; + case HB_EVP_MD_MDC2: p = EVP_mdc2(); break; #endif #ifndef OPENSSL_NO_RIPEMD - case HB_EVP_MD_RIPEMD160 : p = EVP_ripemd160(); break; + case HB_EVP_MD_RIPEMD160: p = EVP_ripemd160(); break; #endif - default : p = NULL; + default: p = NULL; } return p; @@ -248,7 +248,7 @@ HB_FUNC( EVP_MD_CTX_CREATE ) EVP_MD_CTX * ctx = EVP_MD_CTX_create(); - * ph = ctx; + *ph = ctx; hb_retptrGC( ph ); } @@ -297,7 +297,7 @@ HB_FUNC( EVP_MD_CTX_COPY ) if( hb_EVP_MD_CTX_is( 1 ) && hb_EVP_MD_CTX_is( 2 ) ) { EVP_MD_CTX * ctx_out = hb_EVP_MD_CTX_par( 1 ); - EVP_MD_CTX * ctx_in = hb_EVP_MD_CTX_par( 2 ); + EVP_MD_CTX * ctx_in = hb_EVP_MD_CTX_par( 2 ); if( ctx_out && ctx_in ) hb_retni( EVP_MD_CTX_copy( ctx_out, ctx_in ) ); @@ -311,7 +311,7 @@ HB_FUNC( EVP_MD_CTX_COPY_EX ) if( hb_EVP_MD_CTX_is( 1 ) && hb_EVP_MD_CTX_is( 2 ) ) { EVP_MD_CTX * ctx_out = hb_EVP_MD_CTX_par( 1 ); - EVP_MD_CTX * ctx_in = hb_EVP_MD_CTX_par( 2 ); + EVP_MD_CTX * ctx_in = hb_EVP_MD_CTX_par( 2 ); if( ctx_out && ctx_in ) hb_retni( EVP_MD_CTX_copy_ex( ctx_out, ctx_in ) ); @@ -372,7 +372,7 @@ HB_FUNC( EVP_DIGESTFINAL ) if( ctx ) { unsigned char * buffer = ( unsigned char * ) hb_xgrab( EVP_MAX_MD_SIZE + 1 ); - unsigned int size = 0; + unsigned int size = 0; hb_retni( EVP_DigestFinal( ctx, buffer, &size ) ); @@ -401,7 +401,7 @@ HB_FUNC( EVP_DIGESTFINAL_EX ) if( ctx ) { unsigned char * buffer = ( unsigned char * ) hb_xgrab( EVP_MAX_MD_SIZE + 1 ); - unsigned int size = 0; + unsigned int size = 0; hb_retni( EVP_DigestFinal_ex( ctx, buffer, &size ) ); @@ -473,7 +473,7 @@ HB_FUNC( EVP_SIGNFINAL ) if( ctx ) { unsigned char * buffer = ( unsigned char * ) hb_xgrab( EVP_PKEY_size( hb_EVP_PKEY_par( 3 ) ) + 1 ); - unsigned int size = 0; + unsigned int size = 0; hb_retni( EVP_SignFinal( ctx, buffer, &size, hb_EVP_PKEY_par( 3 ) ) ); diff --git a/harbour/contrib/hbssl/pem.c b/harbour/contrib/hbssl/pem.c index 58017ed457..86e4c5c259 100644 --- a/harbour/contrib/hbssl/pem.c +++ b/harbour/contrib/hbssl/pem.c @@ -94,8 +94,8 @@ HB_FUNC( ERR_LOAD_PEM_STRINGS ) ERR_load_PEM_strings(); } -typedef void * PEM_READ_BIO( BIO * bp, void ** x, pem_password_cb * cb, void * u ); -typedef void * PEM_WRITE_BIO( BIO * bp, void ** x, pem_password_cb * cb, void * u ); +typedef void * PEM_READ_BIO ( BIO * bp, void ** x, pem_password_cb * cb, void * u ); +typedef void * PEM_WRITE_BIO ( BIO * bp, void ** x, pem_password_cb * cb, void * u ); static void hb_PEM_read_bio( PEM_READ_BIO * func ) { @@ -116,12 +116,12 @@ static void hb_PEM_read_bio( PEM_READ_BIO * func ) if( pPassCallback ) { - hb_retptr( ( * func )( bio, NULL, hb_ssl_pem_password_cb, pPassCallback ) ); + hb_retptr( ( *func )( bio, NULL, hb_ssl_pem_password_cb, pPassCallback ) ); } else { /* NOTE: Dropping 'const' qualifier. [vszakats] */ - hb_retptr( ( * func )( bio, NULL, NULL, ( void * ) hb_parc( 2 ) ) ); + hb_retptr( ( *func )( bio, NULL, NULL, ( void * ) hb_parc( 2 ) ) ); } if( ! HB_ISPOINTER( 1 ) ) @@ -148,22 +148,22 @@ HB_FUNC( PEM_READ_BIO_PKCS7 ) { hb_PEM_read_bio( ( PEM_READ_BIO * ) PEM_ #if 0 -int PEM_write_bio_RSAPrivateKey( BIO *bp, RSA *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u); -int PEM_write_bio_DSAPrivateKey( BIO *bp, DSA *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u); -int PEM_write_bio_PrivateKey( BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u); -int PEM_write_bio_PKCS8PrivateKey( BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, char *kstr , int klen, pem_password_cb *cb, void *u); -int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid , char *kstr , int klen, pem_password_cb *cb, void *u); -int PEM_write_bio_PUBKEY( BIO *bp, EVP_PKEY *x); -int PEM_write_bio_RSAPublicKey( BIO *bp, RSA *x); -int PEM_write_bio_RSA_PUBKEY( BIO *bp, RSA *x); -int PEM_write_bio_DSA_PUBKEY( BIO *bp, DSA *x); -int PEM_write_bio_DSAparams( BIO *bp, DSA *x); -int PEM_write_bio_DHparams( BIO *bp, DH *x); -int PEM_write_bio_X509( BIO *bp, X509 *x); -int PEM_write_bio_X509_AUX( BIO *bp, X509 *x); -int PEM_write_bio_X509_REQ( BIO *bp, X509_REQ *x); -int PEM_write_bio_X509_REQ_NEW( BIO *bp, X509_REQ *x); -int PEM_write_bio_X509_CRL( BIO *bp, X509_CRL *x); -int PEM_write_bio_PKCS7( BIO *bp, PKCS7 *x); +int PEM_write_bio_RSAPrivateKey( BIO * bp, RSA * x, const EVP_CIPHER * enc, unsigned char * kstr, int klen, pem_password_cb * cb, void * u ); +int PEM_write_bio_DSAPrivateKey( BIO * bp, DSA * x, const EVP_CIPHER * enc, unsigned char * kstr, int klen, pem_password_cb * cb, void * u ); +int PEM_write_bio_PrivateKey( BIO * bp, EVP_PKEY * x, const EVP_CIPHER * enc, unsigned char * kstr, int klen, pem_password_cb * cb, void * u ); +int PEM_write_bio_PKCS8PrivateKey( BIO * bp, EVP_PKEY * x, const EVP_CIPHER * enc, char * kstr, int klen, pem_password_cb * cb, void * u ); +int PEM_write_bio_PKCS8PrivateKey_nid( BIO * bp, EVP_PKEY * x, int nid, char * kstr, int klen, pem_password_cb * cb, void * u ); +int PEM_write_bio_PUBKEY( BIO * bp, EVP_PKEY * x ); +int PEM_write_bio_RSAPublicKey( BIO * bp, RSA * x ); +int PEM_write_bio_RSA_PUBKEY( BIO * bp, RSA * x ); +int PEM_write_bio_DSA_PUBKEY( BIO * bp, DSA * x ); +int PEM_write_bio_DSAparams( BIO * bp, DSA * x ); +int PEM_write_bio_DHparams( BIO * bp, DH * x ); +int PEM_write_bio_X509( BIO * bp, X509 * x ); +int PEM_write_bio_X509_AUX( BIO * bp, X509 * x ); +int PEM_write_bio_X509_REQ( BIO * bp, X509_REQ * x ); +int PEM_write_bio_X509_REQ_NEW( BIO * bp, X509_REQ * x ); +int PEM_write_bio_X509_CRL( BIO * bp, X509_CRL * x ); +int PEM_write_bio_PKCS7( BIO * bp, PKCS7 * x ); #endif diff --git a/harbour/contrib/hbssl/ssl.c b/harbour/contrib/hbssl/ssl.c index 31103f4d8a..af38717551 100644 --- a/harbour/contrib/hbssl/ssl.c +++ b/harbour/contrib/hbssl/ssl.c @@ -96,11 +96,11 @@ HB_FUNC( SSLEAY_VERSION ) switch( value ) { - case HB_SSLEAY_VERSION : value = SSLEAY_VERSION; break; - case HB_SSLEAY_CFLAGS : value = SSLEAY_CFLAGS; break; - case HB_SSLEAY_BUILT_ON : value = SSLEAY_BUILT_ON; break; - case HB_SSLEAY_PLATFORM : value = SSLEAY_PLATFORM; break; - case HB_SSLEAY_DIR : value = SSLEAY_DIR; break; + case HB_SSLEAY_VERSION: value = SSLEAY_VERSION; break; + case HB_SSLEAY_CFLAGS: value = SSLEAY_CFLAGS; break; + case HB_SSLEAY_BUILT_ON: value = SSLEAY_BUILT_ON; break; + case HB_SSLEAY_PLATFORM: value = SSLEAY_PLATFORM; break; + case HB_SSLEAY_DIR: value = SSLEAY_DIR; break; } hb_retc( SSLeay_version( value ) ); @@ -121,13 +121,13 @@ static HB_GARBAGE_FUNC( SSL_release ) void ** ph = ( void ** ) Cargo; /* Check if pointer is not NULL to avoid multiple freeing */ - if( ph && * ph ) + if( ph && *ph ) { /* Destroy the object */ - SSL_free( ( SSL * ) * ph ); + SSL_free( ( SSL * ) *ph ); /* set pointer to NULL just in case */ - * ph = NULL; + *ph = NULL; } } @@ -146,7 +146,7 @@ SSL * hb_SSL_par( int iParam ) { void ** ph = ( void ** ) hb_parptrGC( &s_gcSSL_funcs, iParam ); - return ph ? ( SSL * ) * ph : NULL; + return ph ? ( SSL * ) *ph : NULL; } HB_FUNC( SSL_NEW ) @@ -161,7 +161,7 @@ HB_FUNC( SSL_NEW ) SSL * ssl = SSL_new( ctx ); - * ph = ssl; + *ph = ssl; hb_retptrGC( ph ); } @@ -182,7 +182,7 @@ HB_FUNC( SSL_DUP ) SSL * ssl = SSL_dup( ssl_par ); - * ph = ssl; + *ph = ssl; hb_retptrGC( ph ); } @@ -495,9 +495,9 @@ HB_FUNC( SSL_READ ) if( ssl ) { PHB_ITEM pItem = hb_param( 2, HB_IT_STRING ); - char * pBuffer; - HB_SIZE nLen; - int nRead = 0; + char * pBuffer; + HB_SIZE nLen; + int nRead = 0; if( pItem && HB_ISBYREF( 2 ) && hb_itemGetWriteCL( pItem, &pBuffer, &nLen ) ) @@ -529,9 +529,9 @@ HB_FUNC( SSL_PEEK ) if( ssl ) { PHB_ITEM pItem = hb_param( 2, HB_IT_STRING ); - char * pBuffer; - HB_SIZE nLen; - int nRead = 0; + char * pBuffer; + HB_SIZE nLen; + int nRead = 0; if( pItem && HB_ISBYREF( 2 ) && hb_itemGetWriteCL( pItem, &pBuffer, &nLen ) ) @@ -576,7 +576,7 @@ HB_FUNC( SSL_WRITE ) if( ssl ) { PHB_ITEM pBuffer = hb_param( 2, HB_IT_STRING ); - HB_SIZE nLen = hb_itemGetCLen( pBuffer ); + HB_SIZE nLen = hb_itemGetCLen( pBuffer ); if( HB_ISNUM( 3 ) ) { @@ -836,7 +836,7 @@ HB_FUNC( SSL_STATE_STRING_LONG ) hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } -/* +#if 0 HB_FUNC( SSL_GET_PSK_IDENTITY_HINT ) { @@ -864,7 +864,7 @@ HB_FUNC( SSL_GET_PSK_IDENTITY ) hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); } -*/ +#endif HB_FUNC( SSL_CHECK_PRIVATE_KEY ) { @@ -1305,7 +1305,7 @@ HB_FUNC( SSL_USE_CERTIFICATE ) { if( hb_SSL_is( 1 ) && hb_X509_is( 2 ) ) { - SSL * ssl = hb_SSL_par( 1 ); + SSL * ssl = hb_SSL_par( 1 ); X509 * x509 = hb_X509_par( 2 ); if( ssl && x509 ) @@ -1319,7 +1319,7 @@ HB_FUNC( SSL_ADD_CLIENT_CA ) { if( hb_SSL_is( 1 ) && hb_X509_is( 2 ) ) { - SSL * ssl = hb_SSL_par( 1 ); + SSL * ssl = hb_SSL_par( 1 ); X509 * x509 = hb_X509_par( 2 ); if( ssl && x509 ) @@ -1382,7 +1382,7 @@ HB_FUNC( SSL_GET_CIPHERS ) if( len > 0 ) { PHB_ITEM pArray = hb_itemArrayNew( len ); - int tmp; + int tmp; for( tmp = 0; tmp < len; tmp++ ) hb_arraySetPtr( pArray, tmp + 1, sk_SSL_CIPHER_value( stack, tmp ) ); @@ -1411,7 +1411,7 @@ HB_FUNC( SSL_GET_CLIENT_CA_LIST ) if( len > 0 ) { PHB_ITEM pArray = hb_itemArrayNew( len ); - int tmp; + int tmp; for( tmp = 0; tmp < len; tmp++ ) hb_arraySetPtr( pArray, tmp + 1, sk_X509_NAME_value( stack, tmp ) ); @@ -1436,7 +1436,7 @@ HB_FUNC( SSL_LOAD_CLIENT_CA_FILE ) if( len > 0 ) { PHB_ITEM pArray = hb_itemArrayNew( len ); - int tmp; + int tmp; for( tmp = 0; tmp < len; tmp++ ) hb_arraySetPtr( pArray, tmp + 1, sk_X509_NAME_value( stack, tmp ) ); @@ -1560,27 +1560,27 @@ HB_FUNC( SSL_SET_MSG_CALLBACK ) /* -void SSL_set_psk_client_callback(SSL *ssl, unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len)); -void SSL_set_psk_server_callback(SSL *ssl, unsigned int (*callback)(SSL *ssl, const char *identity, unsigned char *psk, int max_psk_len)); + void SSL_set_psk_client_callback(SSL *ssl, unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len)); + void SSL_set_psk_server_callback(SSL *ssl, unsigned int (*callback)(SSL *ssl, const char *identity, unsigned char *psk, int max_psk_len)); -EVP_PKEY * SSL_get_privatekey(SSL *ssl); + EVP_PKEY * SSL_get_privatekey(SSL *ssl); -STACK * SSL_get_peer_cert_chain(const SSL *ssl); -int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); -void SSL_set_app_data(SSL *ssl, char *arg); -int SSL_set_ex_data(SSL *ssl, int idx, char *arg); -char * SSL_get_app_data(SSL *ssl); -char * SSL_get_ex_data( ssl, int ); -int SSL_add_dir_cert_subjects_to_stack(STACK *stack, const char *dir); -int SSL_add_file_cert_subjects_to_stack(STACK *stack, const char *file); -STACK * SSL_dup_CA_list(STACK *sk); -SSL_CTX * SSL_get_SSL_CTX(const SSL *ssl); -int SSL_get_ex_data_X509_STORE_CTX_idx(void); -int SSL_get_ex_new_index(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void)) -void (*SSL_get_info_callback(const SSL *ssl);)() -SSL_SESSION *SSL_get_session(const SSL *ssl); -int (*SSL_get_verify_callback(const SSL *ssl))(int,X509_STORE_CTX *) -void SSL_set_client_CA_list(SSL *ssl, STACK *list); -void SSL_set_info_callback(SSL *ssl, void (*cb);(void)) -void SSL_set_verify(SSL *ssl, int mode, int (*callback);(void)) -*/ + STACK * SSL_get_peer_cert_chain(const SSL *ssl); + int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); + void SSL_set_app_data(SSL *ssl, char *arg); + int SSL_set_ex_data(SSL *ssl, int idx, char *arg); + char * SSL_get_app_data(SSL *ssl); + char * SSL_get_ex_data( ssl, int ); + int SSL_add_dir_cert_subjects_to_stack(STACK *stack, const char *dir); + int SSL_add_file_cert_subjects_to_stack(STACK *stack, const char *file); + STACK * SSL_dup_CA_list(STACK *sk); + SSL_CTX * SSL_get_SSL_CTX(const SSL *ssl); + int SSL_get_ex_data_X509_STORE_CTX_idx(void); + int SSL_get_ex_new_index(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void)) + void (*SSL_get_info_callback(const SSL *ssl);)() + SSL_SESSION *SSL_get_session(const SSL *ssl); + int (*SSL_get_verify_callback(const SSL *ssl))(int,X509_STORE_CTX *) + void SSL_set_client_CA_list(SSL *ssl, STACK *list); + void SSL_set_info_callback(SSL *ssl, void (*cb);(void)) + void SSL_set_verify(SSL *ssl, int mode, int (*callback);(void)) + */ diff --git a/harbour/contrib/hbssl/ssl_hb.c b/harbour/contrib/hbssl/ssl_hb.c index 3529e35380..c9992a0001 100644 --- a/harbour/contrib/hbssl/ssl_hb.c +++ b/harbour/contrib/hbssl/ssl_hb.c @@ -66,19 +66,19 @@ HB_FUNC( HB_SSL_READ_ALL ) if( ssl ) { - int iMax = hb_parnidef( 3, INT_MAX ); - int iTimeout = hb_parnidef( 4, -1 ); + int iMax = hb_parnidef( 3, INT_MAX ); + int iTimeout = hb_parnidef( 4, -1 ); int iBufferSize = hb_parnidef( 5, 80 ); - int iPos = 0; - int iAllocated = 0; - char * retval = NULL; + int iPos = 0; + int iAllocated = 0; + char * retval = NULL; - for( ;; ) + for(;; ) { char buffer[ 1 ]; - int iLen; - int sd = SSL_get_rfd( ssl ); + int iLen; + int sd = SSL_get_rfd( ssl ); if( SSL_pending( ssl ) || ( sd >= 0 && hb_socketSelectRead( ( HB_SOCKET ) sd, iTimeout ) ) ) @@ -104,7 +104,7 @@ HB_FUNC( HB_SSL_READ_ALL ) if( iPos == iAllocated ) { iAllocated += iBufferSize; - retval = ( char * ) hb_xrealloc( retval, iAllocated ); + retval = ( char * ) hb_xrealloc( retval, iAllocated ); } retval[ iPos++ ] = buffer[ 0 ]; @@ -136,19 +136,19 @@ HB_FUNC( HB_SSL_READ_LINE ) if( ssl ) { - int iMax = hb_parnidef( 3, INT_MAX ); - int iTimeout = hb_parnidef( 4, -1 ); + int iMax = hb_parnidef( 3, INT_MAX ); + int iTimeout = hb_parnidef( 4, -1 ); int iBufferSize = hb_parnidef( 5, 80 ); - int iPos = 0; - int iAllocated = 0; - char * retval = NULL; + int iPos = 0; + int iAllocated = 0; + char * retval = NULL; - for( ;; ) + for(;; ) { char buffer[ 1 ]; - int iLen; - int sd = SSL_get_rfd( ssl ); + int iLen; + int sd = SSL_get_rfd( ssl ); if( SSL_pending( ssl ) || ( sd >= 0 && hb_socketSelectRead( ( HB_SOCKET ) sd, iTimeout ) ) ) @@ -178,7 +178,7 @@ HB_FUNC( HB_SSL_READ_LINE ) if( iPos == iAllocated ) { iAllocated += iBufferSize; - retval = ( char * ) hb_xrealloc( retval, iAllocated ); + retval = ( char * ) hb_xrealloc( retval, iAllocated ); } retval[ iPos++ ] = buffer[ 0 ]; diff --git a/harbour/contrib/hbssl/sslctx.c b/harbour/contrib/hbssl/sslctx.c index baa9393df4..83a40f3149 100644 --- a/harbour/contrib/hbssl/sslctx.c +++ b/harbour/contrib/hbssl/sslctx.c @@ -101,17 +101,17 @@ const SSL_METHOD * hb_ssl_method_id_to_ptr( int n ) switch( n ) { #if OPENSSL_VERSION_NUMBER < 0x10000000L - case HB_SSL_CTX_NEW_METHOD_SSLV2: p = SSLv2_method(); break; - case HB_SSL_CTX_NEW_METHOD_SSLV2_SERVER: p = SSLv2_server_method(); break; - case HB_SSL_CTX_NEW_METHOD_SSLV2_CLIENT: p = SSLv2_client_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV2: p = SSLv2_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV2_SERVER: p = SSLv2_server_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV2_CLIENT: p = SSLv2_client_method(); break; #endif - case HB_SSL_CTX_NEW_METHOD_SSLV3: p = SSLv3_method(); break; - case HB_SSL_CTX_NEW_METHOD_SSLV3_SERVER: p = SSLv3_server_method(); break; - case HB_SSL_CTX_NEW_METHOD_SSLV3_CLIENT: p = SSLv3_client_method(); break; - case HB_SSL_CTX_NEW_METHOD_TLSV1: p = TLSv1_method(); break; - case HB_SSL_CTX_NEW_METHOD_TLSV1_SERVER: p = TLSv1_server_method(); break; - case HB_SSL_CTX_NEW_METHOD_TLSV1_CLIENT: p = TLSv1_client_method(); break; - case HB_SSL_CTX_NEW_METHOD_SSLV23: p = SSLv23_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV3: p = SSLv3_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV3_SERVER: p = SSLv3_server_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV3_CLIENT: p = SSLv3_client_method(); break; + case HB_SSL_CTX_NEW_METHOD_TLSV1: p = TLSv1_method(); break; + case HB_SSL_CTX_NEW_METHOD_TLSV1_SERVER: p = TLSv1_server_method(); break; + case HB_SSL_CTX_NEW_METHOD_TLSV1_CLIENT: p = TLSv1_client_method(); break; + case HB_SSL_CTX_NEW_METHOD_SSLV23: p = SSLv23_method(); break; case HB_SSL_CTX_NEW_METHOD_SSLV23_SERVER: p = SSLv23_server_method(); break; case HB_SSL_CTX_NEW_METHOD_SSLV23_CLIENT: p = SSLv23_client_method(); break; default: p = SSLv23_method(); diff --git a/harbour/contrib/hbssl/x509.c b/harbour/contrib/hbssl/x509.c index 60f398b6e1..42abb66467 100644 --- a/harbour/contrib/hbssl/x509.c +++ b/harbour/contrib/hbssl/x509.c @@ -75,7 +75,7 @@ static HB_GARBAGE_FUNC( X509_release ) { /* Destroy the object */ if( ph->fRelease ) - X509_free( ( X509 * ) ph->pX509 ); + X509_free( ( X509 * ) ph->pX509 ); /* set pointer to NULL just in case */ ph->pX509 = NULL; @@ -104,7 +104,7 @@ void hb_X509_ret( X509 * x509, HB_BOOL fRelease ) { PHB_X509 ph = ( PHB_X509 ) hb_gcAllocate( sizeof( HB_X509 ), &s_gcX509_funcs ); - ph->pX509 = x509; + ph->pX509 = x509; ph->fRelease = fRelease; hb_retptrGC( ( void * ) ph ); diff --git a/harbour/contrib/xhb/dbgfxc.c b/harbour/contrib/xhb/dbgfxc.c index 5f90789f88..8c98df43f4 100644 --- a/harbour/contrib/xhb/dbgfxc.c +++ b/harbour/contrib/xhb/dbgfxc.c @@ -59,7 +59,7 @@ static HB_BOOL s_bToOutputDebug = HB_TRUE; static HB_BOOL s_bToLogFile = HB_TRUE; -static HB_BOOL s_bEmptyLogFile = HB_TRUE; +static HB_BOOL s_bEmptyLogFile = HB_TRUE; HB_BOOL hb_ToOutDebugOnOff( HB_BOOL bOnOff ) { @@ -73,7 +73,7 @@ void hb_ToOutDebug( const char * sTraceMsg, ... ) { if( sTraceMsg && s_bToOutputDebug ) { - char buffer[ 1024 ]; + char buffer[ 1024 ]; va_list ap; va_start( ap, sTraceMsg ); diff --git a/harbour/contrib/xhb/fparse.c b/harbour/contrib/xhb/fparse.c index b8dc74a3cf..db76658d38 100644 --- a/harbour/contrib/xhb/fparse.c +++ b/harbour/contrib/xhb/fparse.c @@ -324,7 +324,7 @@ static HB_BOOL file_read( FILE * stream, char * string, int * iCharCount ) memset( string, ' ', MAX_READ ); - for( ;; ) + for(;; ) { ch = fgetc( stream ); diff --git a/harbour/contrib/xhb/hbserv.c b/harbour/contrib/xhb/hbserv.c index 861b251a50..cd5459970c 100644 --- a/harbour/contrib/xhb/hbserv.c +++ b/harbour/contrib/xhb/hbserv.c @@ -69,12 +69,12 @@ #endif /* These targets can't compile this module */ -#if !defined( HB_OS_DOS ) && \ - !defined( HB_OS_DARWIN_5 ) && \ - ! ( defined( HB_OS_WIN_CE ) && ( defined( __POCC__ ) || ( defined( _MSC_VER ) && ( _MSC_VER <= 1500 ) ) ) ) && \ - !defined( HB_OS_WIN_64 ) && \ - ( !defined( HB_OS_OS2 ) || defined( HB_OS_OS2_GCC ) ) && \ - !defined( __HAIKU__ ) +#if ! defined( HB_OS_DOS ) && \ + ! defined( HB_OS_DARWIN_5 ) && \ + ! ( defined( HB_OS_WIN_CE ) && ( defined( __POCC__ ) || ( defined( _MSC_VER ) && ( _MSC_VER <= 1500 ) ) ) ) && \ + ! defined( HB_OS_WIN_64 ) && \ + ( ! defined( HB_OS_OS2 ) || defined( HB_OS_OS2_GCC ) ) && \ + ! defined( __HAIKU__ ) /* TODO: Haiku will supposedly do this later on, read /boot/develop/headers/posix/signal.h */ #if defined( HB_OS_UNIX ) || defined( HB_OS_OS2_GCC ) @@ -86,32 +86,32 @@ /* TODO: we'll use hb_fsPopen for popening once we put it multiplatform. For now: */ #ifdef HB_OS_WIN - #define popen _popen - #define pclose _pclose + #define popen _popen + #define pclose _pclose #endif #ifdef __LCC__ -#define EXCEPTION_ILLEGAL_INSTRUCTION STATUS_ILLEGAL_INSTRUCTION +#define EXCEPTION_ILLEGAL_INSTRUCTION STATUS_ILLEGAL_INSTRUCTION #endif /************************************************** -* Global definition, valid for all systems -***************************************************/ + * Global definition, valid for all systems + ***************************************************/ static void s_serviceSetHBSig( void ); static void s_serviceSetDflSig( void ); static void s_signalHandlersInit( void ); -static PHB_ITEM sp_hooks = NULL; -static HB_BOOL bSignalEnabled = HB_TRUE; -static int sb_isService = 0; +static PHB_ITEM sp_hooks = NULL; +static HB_BOOL bSignalEnabled = HB_TRUE; +static int sb_isService = 0; /* There is a service mutex in multithreading */ static HB_CRITICAL_NEW( s_ServiceMutex ); /* This structure holds a translation to transform a certain OS level signal -into abstract HB_SIGNAL; os specific implementation must provide the -s_sigTable containing all the available translations */ + into abstract HB_SIGNAL; os specific implementation must provide the + s_sigTable containing all the available translations */ typedef struct { @@ -137,17 +137,17 @@ static int s_translateSignal( HB_UINT sig, HB_UINT subsig ); /* Implementation of the signal translation table */ static S_TUPLE s_sigTable[] = { - { SIGHUP, 0, HB_SIGNAL_REFRESH }, - { SIGINT, 0, HB_SIGNAL_INTERRUPT }, - { SIGQUIT, 0, HB_SIGNAL_QUIT }, - { SIGILL, 0, HB_SIGNAL_FAULT }, - { SIGABRT, 0, HB_SIGNAL_QUIT }, - { SIGFPE, 0, HB_SIGNAL_MATHERR }, - { SIGSEGV, 0, HB_SIGNAL_FAULT }, - { SIGTERM, 0, HB_SIGNAL_QUIT }, - { SIGUSR1, 0, HB_SIGNAL_USER1 }, - { SIGUSR2, 0, HB_SIGNAL_USER2 }, - { 0, 0, 0 } + { SIGHUP, 0, HB_SIGNAL_REFRESH }, + { SIGINT, 0, HB_SIGNAL_INTERRUPT }, + { SIGQUIT, 0, HB_SIGNAL_QUIT }, + { SIGILL, 0, HB_SIGNAL_FAULT }, + { SIGABRT, 0, HB_SIGNAL_QUIT }, + { SIGFPE, 0, HB_SIGNAL_MATHERR }, + { SIGSEGV, 0, HB_SIGNAL_FAULT }, + { SIGTERM, 0, HB_SIGNAL_QUIT }, + { SIGUSR1, 0, HB_SIGNAL_USER1 }, + { SIGUSR2, 0, HB_SIGNAL_USER2 }, + { 0, 0, 0 } }; #if defined( HB_OS_OS2_GCC ) || defined( __WATCOMC__ ) @@ -156,13 +156,13 @@ static void s_signalHandler( int sig ) static void s_signalHandler( int sig, siginfo_t * info, void * v ) #endif { - HB_UINT uiMask; - HB_UINT uiSig; + HB_UINT uiMask; + HB_UINT uiSig; PHB_ITEM pFunction, pExecArray, pRet; - HB_SIZE nPos; - int iRet; + HB_SIZE nPos; + int iRet; - #if !( defined( HB_OS_OS2_GCC ) || defined( __WATCOMC__ ) ) + #if ! ( defined( HB_OS_OS2_GCC ) || defined( __WATCOMC__ ) ) HB_SYMBOL_UNUSED( v ); #endif @@ -184,7 +184,7 @@ static void s_signalHandler( int sig, siginfo_t * info, void * v ) while( nPos > 0 ) { pFunction = hb_arrayGetItemPtr( sp_hooks, nPos ); - uiMask = ( HB_UINT ) hb_arrayGetNI( pFunction, 1 ); + uiMask = ( HB_UINT ) hb_arrayGetNI( pFunction, 1 ); if( uiMask & uiSig ) { /* we don't unlock the mutex now, even if it is @@ -196,7 +196,7 @@ static void s_signalHandler( int sig, siginfo_t * info, void * v ) /* the third parameter is an array: */ - pRet = hb_arrayGetItemPtr( pExecArray, 3); + pRet = hb_arrayGetItemPtr( pExecArray, 3 ); #if defined( HB_OS_OS2_GCC ) || defined( __WATCOMC__ ) hb_arrayNew( pRet, 1 ); #elif defined( HB_OS_BSD ) @@ -205,7 +205,7 @@ static void s_signalHandler( int sig, siginfo_t * info, void * v ) hb_arrayNew( pRet, 6 ); #endif hb_arraySetNI( pRet, HB_SERVICE_OSSIGNAL, sig ); - #if !( defined( HB_OS_OS2_GCC ) || defined( __WATCOMC__ ) ) + #if ! ( defined( HB_OS_OS2_GCC ) || defined( __WATCOMC__ ) ) #if defined( HB_OS_BSD ) if( info ) #endif @@ -244,7 +244,7 @@ static void s_signalHandler( int sig, siginfo_t * info, void * v ) restart signal. This solution is rude, while the other would allow clean VM termination... but it works. - */ + */ exit( 0 ); } } @@ -267,13 +267,14 @@ static void s_signalHandler( int sig, siginfo_t * info, void * v ) /* 2003 - to fix as soon as thread support is ready on OS/2 -*/ + */ #if defined( HB_THREAD_SUPPORT ) && ! defined( HB_OS_OS2 ) static void * s_signalListener( void * my_stack ) { static HB_BOOL bFirst = HB_TRUE; - sigset_t passall; - HB_STACK * pStack = ( HB_STACK * ) my_stack; + sigset_t passall; + HB_STACK * pStack = ( HB_STACK * ) my_stack; + #if defined( HB_OS_BSD ) int sig; #else @@ -309,7 +310,7 @@ static void * s_signalListener( void * my_stack ) pthread_setcanceltype( PTHREAD_CANCEL_DEFERRED, NULL ); pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, NULL ); - for( ;; ) + for(;; ) { /* allow safe cancelation */ HB_STACK_UNLOCK; @@ -369,55 +370,55 @@ static UINT s_uiErrorMode = 0; /* ------------------------------- implementation of the signal translation table Under windows, 0 is a system exception, while 1 is a user message -*/ + */ static S_TUPLE s_sigTable[] = { /* memory/processor fault exception */ - { 0, EXCEPTION_ACCESS_VIOLATION, HB_SIGNAL_FAULT }, - { 0, EXCEPTION_ILLEGAL_INSTRUCTION, HB_SIGNAL_FAULT }, - { 0, EXCEPTION_IN_PAGE_ERROR, HB_SIGNAL_FAULT }, - { 0, EXCEPTION_STACK_OVERFLOW, HB_SIGNAL_FAULT }, - { 0, EXCEPTION_PRIV_INSTRUCTION, HB_SIGNAL_FAULT }, - { 0, EXCEPTION_ARRAY_BOUNDS_EXCEEDED, HB_SIGNAL_FAULT }, - { 0, EXCEPTION_DATATYPE_MISALIGNMENT, HB_SIGNAL_FAULT }, + { 0, EXCEPTION_ACCESS_VIOLATION, HB_SIGNAL_FAULT }, + { 0, EXCEPTION_ILLEGAL_INSTRUCTION, HB_SIGNAL_FAULT }, + { 0, EXCEPTION_IN_PAGE_ERROR, HB_SIGNAL_FAULT }, + { 0, EXCEPTION_STACK_OVERFLOW, HB_SIGNAL_FAULT }, + { 0, EXCEPTION_PRIV_INSTRUCTION, HB_SIGNAL_FAULT }, + { 0, EXCEPTION_ARRAY_BOUNDS_EXCEEDED, HB_SIGNAL_FAULT }, + { 0, EXCEPTION_DATATYPE_MISALIGNMENT, HB_SIGNAL_FAULT }, /* Math exceptions */ - { 0, EXCEPTION_FLT_DENORMAL_OPERAND, HB_SIGNAL_MATHERR }, - { 0, EXCEPTION_FLT_INVALID_OPERATION, HB_SIGNAL_MATHERR }, - { 0, EXCEPTION_FLT_INEXACT_RESULT, HB_SIGNAL_MATHERR }, - { 0, EXCEPTION_FLT_DIVIDE_BY_ZERO, HB_SIGNAL_MATHERR }, - { 0, EXCEPTION_FLT_OVERFLOW, HB_SIGNAL_MATHERR }, - { 0, EXCEPTION_FLT_STACK_CHECK, HB_SIGNAL_MATHERR }, - { 0, EXCEPTION_FLT_UNDERFLOW, HB_SIGNAL_MATHERR }, - { 0, EXCEPTION_INT_DIVIDE_BY_ZERO, HB_SIGNAL_MATHERR }, - { 0, EXCEPTION_INT_OVERFLOW, HB_SIGNAL_MATHERR }, + { 0, EXCEPTION_FLT_DENORMAL_OPERAND, HB_SIGNAL_MATHERR }, + { 0, EXCEPTION_FLT_INVALID_OPERATION, HB_SIGNAL_MATHERR }, + { 0, EXCEPTION_FLT_INEXACT_RESULT, HB_SIGNAL_MATHERR }, + { 0, EXCEPTION_FLT_DIVIDE_BY_ZERO, HB_SIGNAL_MATHERR }, + { 0, EXCEPTION_FLT_OVERFLOW, HB_SIGNAL_MATHERR }, + { 0, EXCEPTION_FLT_STACK_CHECK, HB_SIGNAL_MATHERR }, + { 0, EXCEPTION_FLT_UNDERFLOW, HB_SIGNAL_MATHERR }, + { 0, EXCEPTION_INT_DIVIDE_BY_ZERO, HB_SIGNAL_MATHERR }, + { 0, EXCEPTION_INT_OVERFLOW, HB_SIGNAL_MATHERR }, /* User requests */ - { 1, WM_USER , HB_SIGNAL_USER1 }, - { 1, WM_USER + 1, HB_SIGNAL_USER2 }, - { 1, WM_USER + 2, HB_SIGNAL_REFRESH }, - { 1, WM_USER + 3, HB_SIGNAL_INTERRUPT }, - { 1, WM_QUIT, HB_SIGNAL_QUIT }, + { 1, WM_USER, HB_SIGNAL_USER1 }, + { 1, WM_USER + 1, HB_SIGNAL_USER2 }, + { 1, WM_USER + 2, HB_SIGNAL_REFRESH }, + { 1, WM_USER + 3, HB_SIGNAL_INTERRUPT }, + { 1, WM_QUIT, HB_SIGNAL_QUIT }, /* Console handler */ - { 2, CTRL_C_EVENT, HB_SIGNAL_INTERRUPT }, - { 2, CTRL_BREAK_EVENT, HB_SIGNAL_INTERRUPT }, - { 2, CTRL_CLOSE_EVENT, HB_SIGNAL_QUIT }, - { 2, CTRL_LOGOFF_EVENT, HB_SIGNAL_QUIT }, - { 2, CTRL_SHUTDOWN_EVENT, HB_SIGNAL_QUIT }, + { 2, CTRL_C_EVENT, HB_SIGNAL_INTERRUPT }, + { 2, CTRL_BREAK_EVENT, HB_SIGNAL_INTERRUPT }, + { 2, CTRL_CLOSE_EVENT, HB_SIGNAL_QUIT }, + { 2, CTRL_LOGOFF_EVENT, HB_SIGNAL_QUIT }, + { 2, CTRL_SHUTDOWN_EVENT, HB_SIGNAL_QUIT }, - {0 , 0, 0} + { 0, 0, 0 } }; /* ------------------------------- Manager of signals for windows -*/ + */ static LONG s_signalHandler( int type, int sig, PEXCEPTION_RECORD exc ) { PHB_ITEM pFunction, pExecArray, pRet; - HB_SIZE nPos; - HB_UINT uiSig, uiMask; - int iRet; + HB_SIZE nPos; + HB_UINT uiSig, uiMask; + int iRet; /* let's find the right signal handler. */ hb_threadEnterCriticalSection( &s_ServiceMutex ); @@ -437,7 +438,7 @@ static LONG s_signalHandler( int type, int sig, PEXCEPTION_RECORD exc ) while( nPos > 0 ) { pFunction = hb_arrayGetItemPtr( sp_hooks, nPos ); - uiMask = ( HB_UINT ) hb_arrayGetNI( pFunction, 1 ); + uiMask = ( HB_UINT ) hb_arrayGetNI( pFunction, 1 ); if( ( uiMask & uiSig ) == uiSig ) { /* we don't unlock the mutex now, even if it is @@ -448,15 +449,15 @@ static LONG s_signalHandler( int type, int sig, PEXCEPTION_RECORD exc ) hb_arraySetNI( pExecArray, 2, uiSig ); /* the third parameter is an array: - * 1: low-level signal - * 2: low-level subsignal - * 3: low-level system error - * 4: address that rised the signal - * 5: process id of the signal riser - * 6: UID of the riser - */ + * 1: low-level signal + * 2: low-level subsignal + * 3: low-level system error + * 4: address that rised the signal + * 5: process id of the signal riser + * 6: UID of the riser + */ - pRet = hb_arrayGetItemPtr( pExecArray, 3); + pRet = hb_arrayGetItemPtr( pExecArray, 3 ); hb_arrayNew( pRet, 6 ); hb_arraySetNI( pRet, HB_SERVICE_OSSIGNAL, type ); @@ -464,7 +465,7 @@ static LONG s_signalHandler( int type, int sig, PEXCEPTION_RECORD exc ) /* could be meaningless, but does not matter here */ hb_arraySetNI( pRet, HB_SERVICE_OSERROR, GetLastError() ); - if(type == 0 ) /* exception */ + if( type == 0 ) /* exception */ { hb_arraySetPtr( pRet, HB_SERVICE_ADDRESS, ( void * ) exc->ExceptionAddress ); } @@ -493,13 +494,12 @@ static LONG s_signalHandler( int type, int sig, PEXCEPTION_RECORD exc ) bSignalEnabled = HB_FALSE; hb_threadLeaveCriticalSection( &s_ServiceMutex ); hb_vmRequestQuit(); - #ifndef HB_THREAD_SUPPORT - hb_vmQuit(); - exit(0); - #else - hb_threadCancelInternal(); - #endif - +#ifndef HB_THREAD_SUPPORT + hb_vmQuit(); + exit( 0 ); +#else + hb_threadCancelInternal(); +#endif } } nPos--; @@ -553,7 +553,7 @@ BOOL WINAPI s_ConsoleHandlerRoutine( DWORD dwCtrlType ) if( TlsGetValue( hb_dwCurrentStack ) == 0 ) { - pStack = hb_threadCreateStack( GetCurrentThreadId() ); + pStack = hb_threadCreateStack( GetCurrentThreadId() ); pStack->th_h = GetCurrentThread(); TlsSetValue( hb_dwCurrentStack, ( void * ) pStack ); } @@ -579,8 +579,8 @@ BOOL WINAPI s_ConsoleHandlerRoutine( DWORD dwCtrlType ) *****************************************************************************/ /*----------------------------------------------------- - Set the signal handlers to our program interceptors. -*/ + Set the signal handlers to our program interceptors. + */ static void s_serviceSetHBSig( void ) { @@ -588,23 +588,23 @@ static void s_serviceSetHBSig( void ) #if defined( HB_OS_UNIX ) || defined( HB_OS_OS2_GCC ) struct sigaction act; - #if defined( HB_THREAD_SUPPORT ) && ! defined( HB_OS_OS2 ) - sigset_t blockall; - /* set signal mask */ - sigemptyset( &blockall ); - sigaddset( &blockall, SIGHUP ); - sigaddset( &blockall, SIGQUIT ); - sigaddset( &blockall, SIGILL ); - sigaddset( &blockall, SIGABRT ); - sigaddset( &blockall, SIGFPE ); - sigaddset( &blockall, SIGSEGV ); - sigaddset( &blockall, SIGTERM ); - sigaddset( &blockall, SIGUSR1 ); - sigaddset( &blockall, SIGUSR2 ); - sigaddset( &blockall, SIGHUP ); +#if defined( HB_THREAD_SUPPORT ) && ! defined( HB_OS_OS2 ) + sigset_t blockall; + /* set signal mask */ + sigemptyset( &blockall ); + sigaddset( &blockall, SIGHUP ); + sigaddset( &blockall, SIGQUIT ); + sigaddset( &blockall, SIGILL ); + sigaddset( &blockall, SIGABRT ); + sigaddset( &blockall, SIGFPE ); + sigaddset( &blockall, SIGSEGV ); + sigaddset( &blockall, SIGTERM ); + sigaddset( &blockall, SIGUSR1 ); + sigaddset( &blockall, SIGUSR2 ); + sigaddset( &blockall, SIGHUP ); - pthread_sigmask( SIG_SETMASK, &blockall, NULL ); - #endif + pthread_sigmask( SIG_SETMASK, &blockall, NULL ); +#endif /* to avoid problems with differ sigaction structures and uninitialized fields */ @@ -614,7 +614,7 @@ static void s_serviceSetHBSig( void ) act.sa_handler = s_signalHandler; #else /* using more descriptive sa_action instead of sa_handler */ - act.sa_handler = NULL; /* if act.sa.. is a union, we just clean this */ + act.sa_handler = NULL; /* if act.sa.. is a union, we just clean this */ act.sa_sigaction = s_signalHandler; /* this is what matters */ /* block al signals, we don't want to be interrupted. */ /*sigfillset( &act.sa_mask );*/ @@ -644,18 +644,18 @@ static void s_serviceSetHBSig( void ) #ifdef HB_OS_WIN /* disable all os-level error boxes */ s_uiErrorMode = SetErrorMode( - SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX | - SEM_NOOPENFILEERRORBOX ); + SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX | + SEM_NOOPENFILEERRORBOX ); SetUnhandledExceptionFilter( s_exceptionFilter ); - s_hMsgHook = SetWindowsHookEx( WH_GETMESSAGE, (HOOKPROC) s_MsgFilterFunc, NULL, GetCurrentThreadId() ); + s_hMsgHook = SetWindowsHookEx( WH_GETMESSAGE, ( HOOKPROC ) s_MsgFilterFunc, NULL, GetCurrentThreadId() ); SetConsoleCtrlHandler( s_ConsoleHandlerRoutine, TRUE ); #endif } /* --------------------------------------------------- Reset the signal handlers to the default OS value -*/ + */ static void s_serviceSetDflSig( void ) @@ -677,8 +677,8 @@ static void s_serviceSetDflSig( void ) SetUnhandledExceptionFilter( NULL ); if( s_hMsgHook != NULL ) { - UnhookWindowsHookEx( s_hMsgHook ); - s_hMsgHook = NULL; + UnhookWindowsHookEx( s_hMsgHook ); + s_hMsgHook = NULL; } SetErrorMode( s_uiErrorMode ); SetConsoleCtrlHandler( s_ConsoleHandlerRoutine, FALSE ); @@ -689,24 +689,25 @@ static void s_serviceSetDflSig( void ) /* --------------------------------------------------- This translates a signal into abstract HB_SIGNAL from os specific representation -*/ + */ static int s_translateSignal( HB_UINT sig, HB_UINT subsig ) { int i = 0; - while( s_sigTable[i].sig != 0 || s_sigTable[i].subsig !=0 || s_sigTable[i].translated != 0 ) + + while( s_sigTable[ i ].sig != 0 || s_sigTable[ i ].subsig != 0 || s_sigTable[ i ].translated != 0 ) { - if( s_sigTable[i].sig == sig && - ( s_sigTable[i].subsig == subsig || s_sigTable[i].subsig == 0 ) ) + if( s_sigTable[ i ].sig == sig && + ( s_sigTable[ i ].subsig == subsig || s_sigTable[ i ].subsig == 0 ) ) { - return s_sigTable[i].translated; + return s_sigTable[ i ].translated; } i++; } return HB_SIGNAL_UNKNOWN; } -static void hb_service_exit( void* cargo ) +static void hb_service_exit( void * cargo ) { HB_SYMBOL_UNUSED( cargo ); @@ -714,22 +715,22 @@ static void hb_service_exit( void* cargo ) } /** -* Initializes signal handler system -*/ + * Initializes signal handler system + */ static void s_signalHandlersInit() { - #if defined( HB_THREAD_SUPPORT ) && ( defined( HB_OS_UNIX ) || defined( HB_OS_UNIX ) ) - pthread_t res; - HB_STACK * pStack; +#if defined( HB_THREAD_SUPPORT ) && ( defined( HB_OS_UNIX ) || defined( HB_OS_UNIX ) ) + pthread_t res; + HB_STACK * pStack; - s_serviceSetHBSig(); + s_serviceSetHBSig(); - pStack = hb_threadCreateStack( 0 ); - pthread_create( &res, NULL, s_signalListener, pStack ); - #else - s_serviceSetHBSig(); - #endif + pStack = hb_threadCreateStack( 0 ); + pthread_create( &res, NULL, s_signalListener, pStack ); +#else + s_serviceSetHBSig(); +#endif sp_hooks = hb_itemNew( NULL ); hb_arrayNew( sp_hooks, 0 ); @@ -742,11 +743,11 @@ static void s_signalHandlersInit() *****************************************************************************/ /** -* Starts the service system. -* Initializes the needed variables. -* On unix: if the parameter is .T., puts the server in daemonic mode, detaching -* the main thread from the console and terminating it. -*/ + * Starts the service system. + * Initializes the needed variables. + * On unix: if the parameter is .T., puts the server in daemonic mode, detaching + * the main thread from the console and terminating it. + */ HB_FUNC( HB_STARTSERVICE ) { @@ -755,7 +756,7 @@ HB_FUNC( HB_STARTSERVICE ) if( iCount > 2 || ( sp_hooks == NULL && iCount > 1 ) ) { /* TODO: Right error code here */ - hb_errRT_BASE_SubstR( EG_ARG, 3012, "Service must be started before starting threads", NULL, 0); + hb_errRT_BASE_SubstR( EG_ARG, 3012, "Service must be started before starting threads", NULL, 0 ); return; } #endif @@ -774,13 +775,13 @@ HB_FUNC( HB_STARTSERVICE ) hb_vmRequestQuit(); return; } - #ifdef HB_THREAD_SUPPORT - #ifdef HB_THREAD_TLS_KEYWORD - hb_thread_stack = &hb_stackMT; - #else - pthread_setspecific( hb_pkCurrentStack, (void *) &hb_stackMT ); - #endif - #endif +#ifdef HB_THREAD_SUPPORT + #ifdef HB_THREAD_TLS_KEYWORD + hb_thread_stack = &hb_stackMT; + #else + pthread_setspecific( hb_pkCurrentStack, ( void * ) &hb_stackMT ); + #endif +#endif } } #endif @@ -804,9 +805,9 @@ HB_FUNC( HB_STARTSERVICE ) } /** -* Returns true if the current program is a service, that is if HB_StartService() has -* Been called. C version useful for internal api -*/ + * Returns true if the current program is a service, that is if HB_StartService() has + * Been called. C version useful for internal api + */ HB_BOOL hb_isService( void ) { @@ -814,9 +815,9 @@ HB_BOOL hb_isService( void ) } /** -* Clean up when system exits -* Called from hb_vmQuit() -*/ + * Clean up when system exits + * Called from hb_vmQuit() + */ void hb_serviceExit( void ) { @@ -831,22 +832,22 @@ void hb_serviceExit( void ) /** -* Returns true if the current program is a service, that is if HB_StartService() has -* Been called. -*/ + * Returns true if the current program is a service, that is if HB_StartService() has + * Been called. + */ HB_FUNC( HB_ISSERVICE ) { hb_retl( sb_isService ); } /** -* This is -at least- an helper functions that implements the main loop for -* the service/daemon system. -* The minimal thing to do is a hb_gcCollectAll(), because, generally, servers -* are not interactive, so they tend to have garbage to collect. -* Under windows, it peeks the pending messages and send the relevant ones -* (quit, user+1 and user+2) to our handling functions. -*/ + * This is -at least- an helper functions that implements the main loop for + * the service/daemon system. + * The minimal thing to do is a hb_gcCollectAll(), because, generally, servers + * are not interactive, so they tend to have garbage to collect. + * Under windows, it peeks the pending messages and send the relevant ones + * (quit, user+1 and user+2) to our handling functions. + */ HB_FUNC( HB_SERVICELOOP ) { @@ -854,10 +855,10 @@ HB_FUNC( HB_SERVICELOOP ) MSG msg; /* This is just here to trigger our internal hook routine, if the final application does not any message handling. - */ + */ if( ! PeekMessage( &msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE ) ) { - PeekMessage( &msg, NULL, WM_USER, WM_USER+3, PM_REMOVE ); + PeekMessage( &msg, NULL, WM_USER, WM_USER + 3, PM_REMOVE ); } #endif @@ -866,15 +867,15 @@ HB_FUNC( HB_SERVICELOOP ) HB_FUNC( HB_PUSHSIGNALHANDLER ) { - int iMask = hb_parni( 1 ); + int iMask = hb_parni( 1 ); PHB_ITEM pFunc = hb_param( 2, HB_IT_ANY ), pHandEntry; if( pFunc == NULL || iMask == 0 || - (! HB_IS_POINTER( pFunc ) && ! HB_IS_STRING( pFunc ) && ! HB_IS_BLOCK( pFunc ) ) - ) + ( ! HB_IS_POINTER( pFunc ) && ! HB_IS_STRING( pFunc ) && ! HB_IS_BLOCK( pFunc ) ) + ) { hb_errRT_BASE_SubstR( EG_ARG, 3012, "Wrong parameter count/type", NULL, - 2, hb_param( 1, HB_IT_ANY ), hb_param( 2, HB_IT_ANY )); + 2, hb_param( 1, HB_IT_ANY ), hb_param( 2, HB_IT_ANY ) ); return; } @@ -932,13 +933,13 @@ HB_FUNC( HB_POPSIGNALHANDLER ) } /** -* Return a character description of the low level signal that has been -* issued to signal handling routines. This is system dependant. -* TODO: Make it international through the xHarbour standard message system. -*/ + * Return a character description of the low level signal that has been + * issued to signal handling routines. This is system dependant. + * TODO: Make it international through the xHarbour standard message system. + */ HB_FUNC( HB_SIGNALDESC ) { - int iSig = hb_parni( 1 ); + int iSig = hb_parni( 1 ); int iSubSig = hb_parni( 2 ); /* UNIX MESSGES */ @@ -947,49 +948,49 @@ HB_FUNC( HB_SIGNALDESC ) switch( iSig ) { case SIGSEGV: switch( iSubSig ) - { + { #if ! defined( HB_OS_BSD ) && ! defined( HB_OS_OS2_GCC ) && ! defined( __WATCOMC__ ) - case SEGV_MAPERR: hb_retc_const( "Segmentation fault: address not mapped to object"); return; - case SEGV_ACCERR: hb_retc_const( "Segmentation fault: invalid permissions for mapped object"); return; + case SEGV_MAPERR: hb_retc_const( "Segmentation fault: address not mapped to object" ); return; + case SEGV_ACCERR: hb_retc_const( "Segmentation fault: invalid permissions for mapped object" ); return; #endif - default: hb_retc_const( "Segmentation fault" ); return; - } + default: hb_retc_const( "Segmentation fault" ); return; + } case SIGILL: switch( iSubSig ) - { + { #if ! defined( HB_OS_BSD ) && ! defined( HB_OS_OS2_GCC ) && ! defined( __WATCOMC__ ) - case ILL_ILLOPC: hb_retc_const( "Illegal operation: illegal opcode"); return; - case ILL_ILLOPN: hb_retc_const( "Illegal operation: illegal operand"); return; - case ILL_ILLADR: hb_retc_const( "Illegal operation: illegal addressing mode"); return; - case ILL_ILLTRP: hb_retc_const( "Illegal operation: illegal trap"); return; - case ILL_PRVOPC: hb_retc_const( "Illegal operation: privileged opcode"); return; - case ILL_PRVREG: hb_retc_const( "Illegal operation: privileged register"); return; - case ILL_COPROC: hb_retc_const( "Illegal operation: coprocessor error"); return; - case ILL_BADSTK: hb_retc_const( "Illegal operation: internal stack error"); return; + case ILL_ILLOPC: hb_retc_const( "Illegal operation: illegal opcode" ); return; + case ILL_ILLOPN: hb_retc_const( "Illegal operation: illegal operand" ); return; + case ILL_ILLADR: hb_retc_const( "Illegal operation: illegal addressing mode" ); return; + case ILL_ILLTRP: hb_retc_const( "Illegal operation: illegal trap" ); return; + case ILL_PRVOPC: hb_retc_const( "Illegal operation: privileged opcode" ); return; + case ILL_PRVREG: hb_retc_const( "Illegal operation: privileged register" ); return; + case ILL_COPROC: hb_retc_const( "Illegal operation: coprocessor error" ); return; + case ILL_BADSTK: hb_retc_const( "Illegal operation: internal stack error" ); return; #endif - default: hb_retc_const( "Illegal operation" ); return; - } + default: hb_retc_const( "Illegal operation" ); return; + } case SIGFPE: switch( iSubSig ) - { + { #if ! defined( HB_OS_OS2_GCC ) && ! defined( __WATCOMC__ ) #if ! defined( HB_OS_DARWIN ) - case FPE_INTDIV: hb_retc_const( "Floating point: integer divide by zero"); return; - case FPE_INTOVF: hb_retc_const( "Floating point: integer overflow"); return; + case FPE_INTDIV: hb_retc_const( "Floating point: integer divide by zero" ); return; + case FPE_INTOVF: hb_retc_const( "Floating point: integer overflow" ); return; #endif - case FPE_FLTDIV: hb_retc_const( "Floating point: floating point divide by zero"); return; - case FPE_FLTOVF: hb_retc_const( "Floating point: floating point overflow"); return; - case FPE_FLTUND: hb_retc_const( "Floating point: floating point underflow"); return; - case FPE_FLTRES: hb_retc_const( "Floating point: floating point inexact result"); return; + case FPE_FLTDIV: hb_retc_const( "Floating point: floating point divide by zero" ); return; + case FPE_FLTOVF: hb_retc_const( "Floating point: floating point overflow" ); return; + case FPE_FLTUND: hb_retc_const( "Floating point: floating point underflow" ); return; + case FPE_FLTRES: hb_retc_const( "Floating point: floating point inexact result" ); return; #if ! defined( HB_OS_VXWORKS ) - case FPE_FLTINV: hb_retc_const( "Floating point: floating point invalid operation"); return; + case FPE_FLTINV: hb_retc_const( "Floating point: floating point invalid operation" ); return; #endif #if ! defined( HB_OS_DARWIN ) - case FPE_FLTSUB: hb_retc_const( "Floating point: subscript out of range"); return; + case FPE_FLTSUB: hb_retc_const( "Floating point: subscript out of range" ); return; #endif #endif - default: hb_retc_const( "Floating point" ); return; - } + default: hb_retc_const( "Floating point" ); return; + } case SIGQUIT: hb_retc_const( "Quit" ); @@ -1086,22 +1087,23 @@ HB_FUNC( HB_SIGNALDESC ) /***************************************************************************** -* Debug help: generates a fault or a math error to see if signal catching -* is working -**************************************/ + * Debug help: generates a fault or a math error to see if signal catching + * is working + **************************************/ HB_FUNC( HB_SERVICEGENERATEFAULT ) { - int *pGPF = NULL; + int * pGPF = NULL; *pGPF = 0; /* if it doesn't cause GPF (on some platforms it's possible) try this */ - *(--pGPF) = 0; + *( --pGPF ) = 0; } HB_FUNC( HB_SERVICEGENERATEFPE ) { static double a = 100.0, b = 0.0; + a = a / b; } diff --git a/harbour/contrib/xhb/hbsyslog.c b/harbour/contrib/xhb/hbsyslog.c index 0586ed08b2..b878ac1021 100644 --- a/harbour/contrib/xhb/hbsyslog.c +++ b/harbour/contrib/xhb/hbsyslog.c @@ -4,7 +4,7 @@ /* Event logging system -*/ + */ #include "hbapi.h" #include "hbwinuni.h" @@ -13,122 +13,133 @@ #if defined( HB_OS_WIN ) - #include "windows.h" +# include "windows.h" - static HANDLE s_RegHandle; +static HANDLE s_RegHandle; #elif defined( HB_OS_UNIX ) && \ - ! defined( __WATCOMC__ ) && \ - ! defined( HB_OS_VXWORKS ) && \ - ! defined( HB_OS_SYMBIAN ) + ! defined( __WATCOMC__ ) && \ + ! defined( HB_OS_VXWORKS ) && \ + ! defined( HB_OS_SYMBIAN ) -#include +# include #endif HB_FUNC( HB_SYSLOGOPEN ) { - #if defined( HB_OS_WIN ) - #if ( WINVER >= 0x0400 ) && \ - ! ( defined( HB_OS_WIN_CE ) && defined( _MSC_VER ) && ( _MSC_VER <= 1310 ) ) - /* Ok, we compiled under NT, but we must not use this function - when RUNNING on a win98. */ - if( hb_iswinnt() ) - { - void * hSourceName; - s_RegHandle = RegisterEventSource( NULL, HB_PARSTRDEF( 1, &hSourceName, NULL ) ); - hb_strfree( hSourceName ); - hb_retl( HB_TRUE ); - } - else - hb_retl( HB_FALSE ); - #else - s_RegHandle = NULL; - hb_retl( HB_FALSE ); - #endif - #elif defined( HB_OS_UNIX ) && !defined( __WATCOMC__ ) && !defined( HB_OS_VXWORKS ) - openlog( hb_parcx( 1 ), LOG_NDELAY | LOG_NOWAIT | LOG_PID, LOG_USER ); +#if defined( HB_OS_WIN ) + +# if ( WINVER >= 0x0400 ) && \ + ! ( defined( HB_OS_WIN_CE ) && defined( _MSC_VER ) && ( _MSC_VER <= 1310 ) ) + + /* Ok, we compiled under NT, but we must not use this function + when RUNNING on a win98. */ + if( hb_iswinnt() ) + { + void * hSourceName; + s_RegHandle = RegisterEventSource( NULL, HB_PARSTRDEF( 1, &hSourceName, NULL ) ); + hb_strfree( hSourceName ); hb_retl( HB_TRUE ); - #else + } + else hb_retl( HB_FALSE ); - #endif +# else + s_RegHandle = NULL; + hb_retl( HB_FALSE ); +# endif + +#elif defined( HB_OS_UNIX ) && ! defined( __WATCOMC__ ) && ! defined( HB_OS_VXWORKS ) + openlog( hb_parcx( 1 ), LOG_NDELAY | LOG_NOWAIT | LOG_PID, LOG_USER ); + hb_retl( HB_TRUE ); +#else + hb_retl( HB_FALSE ); +#endif } HB_FUNC( HB_SYSLOGCLOSE ) { - #if defined( HB_OS_WIN ) - #if ( WINVER >= 0x0400 ) && \ - ! ( defined( HB_OS_WIN_CE ) && defined( _MSC_VER ) && ( _MSC_VER <= 1310 ) ) - if( hb_iswinnt() ) - { - DeregisterEventSource( s_RegHandle ); - hb_retl( HB_TRUE ); - } - else - #endif - hb_retl( HB_FALSE ); - #elif defined( HB_OS_UNIX ) && !defined( __WATCOMC__ ) && !defined( HB_OS_VXWORKS ) - closelog(); +#if defined( HB_OS_WIN ) + +# if ( WINVER >= 0x0400 ) && \ + ! ( defined( HB_OS_WIN_CE ) && defined( _MSC_VER ) && ( _MSC_VER <= 1310 ) ) + + if( hb_iswinnt() ) + { + DeregisterEventSource( s_RegHandle ); hb_retl( HB_TRUE ); - #else + } + else hb_retl( HB_FALSE ); - #endif +# else + hb_retl( HB_FALSE ); +# endif + +#elif defined( HB_OS_UNIX ) && ! defined( __WATCOMC__ ) && ! defined( HB_OS_VXWORKS ) + closelog(); + hb_retl( HB_TRUE ); +#else + hb_retl( HB_FALSE ); +#endif } HB_FUNC( HB_SYSLOGMESSAGE ) { - #if defined( HB_OS_WIN ) - #if ( WINVER >= 0x0400 ) && \ - ! ( defined( HB_OS_WIN_CE ) && defined( _MSC_VER ) && ( _MSC_VER <= 1310 ) ) - if( hb_iswinnt() ) - { - WORD logval; - void * hMsg; - LPCTSTR lpMsg = HB_PARSTRDEF( 1, &hMsg, NULL ); - switch( hb_parni( 2 ) ) - { - case HB_LOG_CRITICAL: logval = EVENTLOG_ERROR_TYPE; break; - case HB_LOG_ERROR: logval = EVENTLOG_ERROR_TYPE; break; - case HB_LOG_WARN: logval = EVENTLOG_WARNING_TYPE; break; - case HB_LOG_INFO: logval = EVENTLOG_INFORMATION_TYPE; break; - default: logval = EVENTLOG_AUDIT_SUCCESS; - } - hb_retl( ReportEvent( s_RegHandle, /* event log handle */ - logval, /* event type */ - 0, /* category zero */ - ( DWORD ) hb_parnl( 3 ), /* event identifier */ - NULL, /* no user security identifier */ - 1, /* one substitution string */ - 0, /* no data */ - &lpMsg, /* pointer to string array */ - NULL /* pointer to data */ - ) ? HB_TRUE : HB_FALSE ); - - hb_strfree( hMsg ); - } - else - #endif - hb_retl( HB_FALSE ); - - #elif defined( HB_OS_UNIX ) && \ - ! defined( __WATCOMC__ ) && \ - ! defined( HB_OS_VXWORKS ) && \ - ! defined( HB_OS_SYMBIAN ) - - int logval; +#if defined( HB_OS_WIN ) +# if ( WINVER >= 0x0400 ) && \ + ! ( defined( HB_OS_WIN_CE ) && defined( _MSC_VER ) && ( _MSC_VER <= 1310 ) ) + if( hb_iswinnt() ) + { + WORD logval; + void * hMsg; + LPCTSTR lpMsg = HB_PARSTRDEF( 1, &hMsg, NULL ); switch( hb_parni( 2 ) ) { - case HB_LOG_CRITICAL: logval = LOG_CRIT; break; - case HB_LOG_ERROR: logval = LOG_ERR; break; - case HB_LOG_WARN: logval = LOG_WARNING; break; - case HB_LOG_INFO: logval = LOG_INFO; break; - default: logval = LOG_DEBUG; + case HB_LOG_CRITICAL: logval = EVENTLOG_ERROR_TYPE; break; + case HB_LOG_ERROR: logval = EVENTLOG_ERROR_TYPE; break; + case HB_LOG_WARN: logval = EVENTLOG_WARNING_TYPE; break; + case HB_LOG_INFO: logval = EVENTLOG_INFORMATION_TYPE; break; + default: logval = EVENTLOG_AUDIT_SUCCESS; } + hb_retl( ReportEvent( s_RegHandle, /* event log handle */ + logval, /* event type */ + 0, /* category zero */ + ( DWORD ) hb_parnl( 3 ), /* event identifier */ + NULL, /* no user security identifier */ + 1, /* one substitution string */ + 0, /* no data */ + &lpMsg, /* pointer to string array */ + NULL /* pointer to data */ + ) ? HB_TRUE : HB_FALSE ); - syslog( logval, "[%lX]: %s", hb_parnl( 3 ), hb_parcx( 1 ) ); - hb_retl( HB_TRUE ); - #else + hb_strfree( hMsg ); + } + else hb_retl( HB_FALSE ); - #endif +# else + hb_retl( HB_FALSE ); +# endif + +#elif defined( HB_OS_UNIX ) && \ + ! defined( __WATCOMC__ ) && \ + ! defined( HB_OS_VXWORKS ) && \ + ! defined( HB_OS_SYMBIAN ) + + int logval; + + switch( hb_parni( 2 ) ) + { + case HB_LOG_CRITICAL: logval = LOG_CRIT; break; + case HB_LOG_ERROR: logval = LOG_ERR; break; + case HB_LOG_WARN: logval = LOG_WARNING; break; + case HB_LOG_INFO: logval = LOG_INFO; break; + default: logval = LOG_DEBUG; + } + + syslog( logval, "[%lX]: %s", hb_parnl( 3 ), hb_parcx( 1 ) ); + hb_retl( HB_TRUE ); +#else + hb_retl( HB_FALSE ); +#endif } diff --git a/harbour/contrib/xhb/hbxml.c b/harbour/contrib/xhb/hbxml.c index 8d77e98655..4eeba4b06b 100644 --- a/harbour/contrib/xhb/hbxml.c +++ b/harbour/contrib/xhb/hbxml.c @@ -101,28 +101,31 @@ static MXML_STATUS mxml_attribute_read( MXML_REFIL * data, PHB_ITEM doc, PHB_ITE static MXML_STATUS mxml_attribute_write( MXML_OUTPUT * out, PHBXML_ATTRIBUTE attr, int style ); /* Refil routines */ -/* Currently not used - static MXML_REFIL * mxml_refil_new( MXML_REFIL_FUNC func, char * buf, HB_ISIZ buflen, HB_ISIZ bufsize ); - static void mxml_refil_destory( MXML_REFIL * ref ); - */ +/* Currently not used */ +#if 0 +static MXML_REFIL * mxml_refil_new( MXML_REFIL_FUNC func, char * buf, HB_ISIZ buflen, HB_ISIZ bufsize ); +static void mxml_refil_destory( MXML_REFIL * ref ); +#endif static MXML_STATUS mxml_refil_setup( MXML_REFIL * ref, MXML_REFIL_FUNC func, char * buf, HB_ISIZ buflen, HB_ISIZ bufsize ); static int mxml_refil_getc( MXML_REFIL * ref ); #define mxml_refil_ungetc( ref, ch ) ref->sparechar = ch -/* Currently not used - static void mxml_refill_from_stream_func( MXML_REFIL * ref ); - */ +/* Currently not used */ +#if 0 +static void mxml_refill_from_stream_func( MXML_REFIL * ref ); +#endif static void mxml_refill_from_handle_func( MXML_REFIL * ref ); /* Output routines */ -/* Currently not used - static MXML_OUTPUT *mxml_output_new( MXML_OUTPUT_FUNC func, int node_count); - static void mxml_output_destroy( MXML_OUTPUT * out ); - static MXML_STATUS mxml_output_string( MXML_OUTPUT * out, const char * s ); - */ +/* Currently not used */ +#if 0 +static MXML_OUTPUT * mxml_output_new( MXML_OUTPUT_FUNC func, int node_count ); +static void mxml_output_destroy( MXML_OUTPUT * out ); +static MXML_STATUS mxml_output_string( MXML_OUTPUT * out, const char * s ); +#endif static MXML_STATUS mxml_output_setup( MXML_OUTPUT * out, MXML_OUTPUT_FUNC func, int node_count ); static MXML_STATUS mxml_output_char( MXML_OUTPUT * out, int c ); @@ -139,16 +142,15 @@ static void mxml_sgs_destroy( MXML_SGS * sgs ); static char * mxml_sgs_extract( MXML_SGS * sgs ); static MXML_STATUS mxml_sgs_append_char( MXML_SGS * sgs, char c ); static MXML_STATUS mxml_sgs_append_string_len( MXML_SGS * sgs, const char * s, HB_ISIZ slen ); -/* Currently not used - static MXML_STATUS mxml_sgs_append_string( MXML_SGS * sgs, char * s ); - */ +/* Currently not used */ +#if 0 +static MXML_STATUS mxml_sgs_append_string( MXML_SGS * sgs, char * s ); +#endif /* Error description */ static const char * mxml_error_desc( MXML_ERROR_CODE code ); - - /******************************************** HB-MXML glue code *********************************************/ @@ -196,7 +198,6 @@ static void hbxml_doc_new_node( PHB_ITEM pDoc, int amount ) Attribute oriented routines ************************************************************/ - static MXML_STATUS mxml_attribute_read( MXML_REFIL * ref, PHB_ITEM pDoc, PHB_ITEM pNode, PHBXML_ATTRIBUTE pDest, int style ) { int chr, quotechr = '"'; @@ -220,14 +221,21 @@ static MXML_STATUS mxml_attribute_read( MXML_REFIL * ref, PHB_ITEM pDoc, PHB_ITE { /* begin */ case 0: + switch( chr ) { - case MXML_LINE_TERMINATOR: hbxml_doc_new_line( pDoc ); break; + case MXML_LINE_TERMINATOR: + hbxml_doc_new_line( pDoc ); + break; /* We repeat line terminator here for portability */ - case MXML_SOFT_LINE_TERMINATOR: break; - case ' ': case '\t': break; + case MXML_SOFT_LINE_TERMINATOR: + break; + case ' ': + case '\t': + break; /* no attributes found */ - case '>': case '/': + case '>': + case '/': mxml_sgs_destroy( buf_name ); mxml_sgs_destroy( buf_attrib ); return MXML_STATUS_DONE; @@ -269,13 +277,9 @@ static MXML_STATUS mxml_attribute_read( MXML_REFIL * ref, PHB_ITEM pDoc, PHB_ITE } /* We repeat line terminator here for portability */ else if( chr == ' ' || chr == '\t' || chr == '\n' || chr == '\r' ) - { iStatus = 2; - } else if( chr == '=' ) - { iStatus = 3; - } else { hbxml_set_doc_status( ref, pDoc, pNode, MXML_STATUS_MALFORMED, MXML_ERROR_MALFATT ); @@ -286,13 +290,9 @@ static MXML_STATUS mxml_attribute_read( MXML_REFIL * ref, PHB_ITEM pDoc, PHB_ITE /* waiting for '=' */ case 2: if( chr == '=' ) - { iStatus = 3; - } else if( chr == MXML_LINE_TERMINATOR ) - { hbxml_doc_new_line( pDoc ); - } /* We repeat line terminator here for portability */ else if( chr == ' ' || chr == '\t' || chr == '\n' || chr == '\r' ) { @@ -329,9 +329,7 @@ static MXML_STATUS mxml_attribute_read( MXML_REFIL * ref, PHB_ITEM pDoc, PHB_ITE /* scanning the attribute content ( until next quotechr ) */ case 4: if( chr == quotechr ) - { iStatus = 6; - } else if( chr == '&' && ! ( style & MXML_STYLE_NOESCAPE ) ) { iStatus = 5; @@ -413,13 +411,10 @@ static MXML_STATUS mxml_attribute_read( MXML_REFIL * ref, PHB_ITEM pDoc, PHB_ITE } break; } - } if( ref->status != MXML_STATUS_OK ) - { return ref->status; - } if( iStatus < 6 ) { @@ -448,14 +443,11 @@ static MXML_STATUS mxml_attribute_write( MXML_OUTPUT * out, PHBXML_ATTRIBUTE pAt mxml_output_char( out, '"' ); if( ! ( style & MXML_STYLE_NOESCAPE ) ) - { mxml_output_string_escape( out, hb_itemGetCPtr( pAttr->pValue ) ); - } else - { mxml_output_string_len( out, hb_itemGetCPtr( pAttr->pValue ), hb_itemGetCLen( pAttr->pValue ) ); - } + mxml_output_char( out, '"' ); return out->status; @@ -494,7 +486,6 @@ static PHB_ITEM mxml_node_new( PHB_ITEM pDoc ) return pNode; } - /** * The unlink function is used to detach a node from the UPPER and PARENT hyerarcy. * The node is "removed" so that siblings node are "squished", and possible parents @@ -591,7 +582,6 @@ HB_FUNC( HBXML_NODE_INSERT_BEFORE ) mxml_node_insert_before( hb_param( 1, HB_IT_OBJECT ), hb_param( 2, HB_IT_OBJECT ) ); } - static void mxml_node_insert_after( PHB_ITEM pTg, PHB_ITEM pNode ) { /* Move tg->next into node->next */ @@ -664,7 +654,7 @@ static void mxml_node_add_below( PHB_ITEM pTg, PHB_ITEM pNode ) if( ! HB_IS_NIL( pChild ) ) { /* Scanning up to the last child */ - for( ;; ) + for(;; ) { hb_objSendMsg( pChild, "ONEXT", 0 ); if( HB_IS_NIL( hb_param( -1, HB_IT_ANY ) ) ) @@ -873,9 +863,7 @@ static void mxml_node_read_data( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM doc, /* trimming unneded spaces */ while( iPos > 1 && HB_ISSPACE( ( HB_BYTE ) buf[ iPos - 1 ] ) ) - { iPos--; - } buf[ iPos ] = 0; @@ -883,9 +871,7 @@ static void mxml_node_read_data( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM doc, hb_objSendMsg( pNode, "_NTYPE", 1, pItem ); if( iAllocated > iPos + 1 ) - { buf = ( char * ) MXML_REALLOCATOR( buf, iPos + 1 ); - } hb_itemPutCL( pItem, buf, iPos ); hb_objSendMsg( pNode, "_CDATA", 1, pItem ); @@ -908,9 +894,7 @@ static MXML_STATUS mxml_node_read_name( MXML_REFIL * ref, PHB_ITEM pNode, PHB_IT { chr = mxml_refil_getc( ref ); if( chr == MXML_EOF ) - { break; - } switch( iStatus ) { @@ -971,9 +955,8 @@ static MXML_STATUS mxml_node_read_name( MXML_REFIL * ref, PHB_ITEM pNode, PHB_IT buf[ iPos ] = 0; if( iAllocated > iPos + 1 ) - { buf = ( char * ) MXML_REALLOCATOR( buf, iPos + 1 ); - } + pItem = hb_itemPutCL( NULL, buf, iPos ); hb_objSendMsg( pNode, "_CNAME", 1, pItem ); hb_itemRelease( pItem ); @@ -1005,11 +988,13 @@ static MXML_STATUS mxml_node_read_attributes( MXML_REFIL * ref, } hb_objSendMsg( pNode, "_AATTRIBUTES", 1, attributes ); - /* Error already set. - if( ref->status != MXML_STATUS_OK ) - { + /* Error already set. */ +#if 0 + if( ref->status != MXML_STATUS_OK ) + { hbxml_set_doc_status( ref, doc, pNode, ref->status, ref->error ); - } */ + } +#endif hb_itemRelease( attributes ); hb_itemRelease( hbValue ); hb_itemRelease( hbName ); @@ -1039,9 +1024,7 @@ static void mxml_node_read_directive( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM } if( chr == MXML_LINE_TERMINATOR ) - { hbxml_doc_new_line( doc ); - } chr = mxml_refil_getc( ref ); } @@ -1052,9 +1035,8 @@ static void mxml_node_read_directive( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM buf[ iPos ] = 0; hb_objSendMsg( pNode, "_NTYPE", 1, pItem ); if( iAllocated > iPos + 1 ) - { buf = ( char * ) MXML_REALLOCATOR( buf, iPos + 1 ); - } + hb_itemPutCL( pItem, buf, iPos ); hb_objSendMsg( pNode, "_CDATA", 1, pItem ); hb_itemRelease( pItem ); @@ -1063,13 +1045,10 @@ static void mxml_node_read_directive( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM { MXML_DELETOR( buf ); hbxml_set_doc_status( ref, doc, pNode, ref->status, ref->error ); - return; } } else - { MXML_DELETOR( buf ); - } } static void mxml_node_read_pi( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM doc ) @@ -1081,9 +1060,7 @@ static void mxml_node_read_pi( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM doc ) /* let's read the xml PI instruction */ if( mxml_node_read_name( ref, pNode, doc ) != MXML_STATUS_OK ) - { return; - } /* and then we'll put all the "data" into the data member, up to ?> */ @@ -1124,7 +1101,6 @@ static void mxml_node_read_pi( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM doc ) mxml_refil_ungetc( ref, chr ); } break; - } if( iPos == iAllocated ) @@ -1140,9 +1116,8 @@ static void mxml_node_read_pi( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM doc ) buf[ iPos ] = 0; hb_objSendMsg( pNode, "_NTYPE", 1, pItem ); if( iAllocated > iPos + 1 ) - { buf = ( char * ) MXML_REALLOCATOR( buf, iPos + 1 ); - } + hb_itemPutCL( pItem, buf, iPos ); hb_objSendMsg( pNode, "_CDATA", 1, pItem ); hb_itemRelease( pItem ); @@ -1167,9 +1142,7 @@ static void mxml_node_read_tag( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM doc, if( mxml_node_read_name( ref, pNode, doc ) == MXML_STATUS_OK ) { if( mxml_node_read_attributes( ref, pNode, doc, style ) != MXML_STATUS_OK ) - { return; - } } /* if the list of attributes terminates with a '/', the last '>' is @@ -1180,14 +1153,10 @@ static void mxml_node_read_tag( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM doc, mxml_refil_ungetc( ref, chr ); /* recurse */ if( mxml_node_read( ref, pNode, doc, style ) != MXML_STATUS_OK ) - { return; - } } else if( ref->status != MXML_STATUS_OK ) - { hbxml_set_doc_status( ref, doc, pNode, ref->status, ref->error ); - } /* else the node is complete */ } @@ -1250,7 +1219,6 @@ static void mxml_node_read_comment( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM d mxml_refil_ungetc( ref, chr ); } break; - } if( iPos == iAllocated ) @@ -1264,9 +1232,8 @@ static void mxml_node_read_comment( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM d { buf[ iPos ] = 0; if( iAllocated > iPos + 1 ) - { buf = ( char * ) MXML_REALLOCATOR( buf, iPos + 1 ); - } + hb_itemPutCL( pItem, buf, iPos ); hb_objSendMsg( pNode, "_CDATA", 1, pItem ); } @@ -1311,71 +1278,46 @@ static void mxml_node_read_cdata( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM pDo /* scanning for C */ case 0: if( chr == 'C' ) - { iStatus = 1; - } else - { - iStatus = 100; /* error */ - } + iStatus = 100; /* error */ break; case 1: if( chr == 'D' ) - { iStatus = 2; - } else - { iStatus = 100; - } break; case 2: if( chr == 'A' ) - { iStatus = 3; - } else - { iStatus = 100; - } break; case 3: if( chr == 'T' ) - { iStatus = 4; - } else - { iStatus = 100; - } break; case 4: if( chr == 'A' ) - { iStatus = 5; - } else - { iStatus = 100; - } break; case 5: if( chr == '[' ) - { iStatus = 6; - } else - { iStatus = 100; - } break; } - } if( iStatus == 100 ) @@ -1447,9 +1389,8 @@ static void mxml_node_read_cdata( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM pDo { buf[ iPos ] = 0; if( iAllocated > iPos + 1 ) - { buf = ( char * ) MXML_REALLOCATOR( buf, iPos + 1 ); - } + hb_itemPutCL( pItem, buf, iPos ); hb_objSendMsg( pNode, "_CDATA", 1, pItem ); } @@ -1511,9 +1452,7 @@ static MXML_STATUS mxml_node_read( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM do { chr = mxml_refil_getc( ref ); if( chr == MXML_EOF ) - { break; - } if( ref->status != MXML_STATUS_OK ) { @@ -1525,7 +1464,6 @@ static MXML_STATUS mxml_node_read( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM do switch( iStatus ) { - case 0: /* outside nodes */ switch( chr ) { @@ -1548,9 +1486,7 @@ static MXML_STATUS mxml_node_read( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM do iStatus = -1; /* done */ } else if( chr == '!' ) - { iStatus = 2; - } else if( chr == '?' ) { node = mxml_node_new( doc ); @@ -1646,9 +1582,7 @@ static MXML_STATUS mxml_node_read( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM do /* I/O error or malformed error during closing? */ mxml_node_read_closing( ref, pNode, doc ); if( ref->status != MXML_STATUS_OK ) - { return ref->status; - } /* checking for data nodes */ hb_objSendMsg( pNode, "OCHILD", 0 ); @@ -1661,9 +1595,7 @@ static MXML_STATUS mxml_node_read( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM do { /* first data node ? */ if( data_node == NULL ) - { data_node = hb_itemNew( child_node ); - } /* ... or have we more than a data node? */ else { @@ -1687,7 +1619,6 @@ static MXML_STATUS mxml_node_read( MXML_REFIL * ref, PHB_ITEM pNode, PHB_ITEM do hb_itemRelease( data_node ); } hb_itemRelease( child_node ); - } return MXML_STATUS_OK; @@ -1785,25 +1716,18 @@ static MXML_STATUS mxml_node_write( MXML_OUTPUT * out, PHB_ITEM pNode, int style if( ! HB_IS_NIL( pItem ) ) { if( mustIndent && ( style & MXML_STYLE_INDENT ) ) - { mxml_node_file_indent( out, depth + 1, style ); - } if( ! ( style & MXML_STYLE_NOESCAPE ) ) - { mxml_output_string_escape( out, hb_itemGetCPtr( pItem ) ); - } else - { mxml_output_string_len( out, hb_itemGetCPtr( pItem ), hb_itemGetCLen( pItem ) ); - } } if( mustIndent && ( style & MXML_STYLE_INDENT ) ) mxml_node_file_indent( out, depth, style ); - mxml_output_string_len( out, "status != MXML_STATUS_OK ) - { return out->status; - } /* just for progress indicators */ out->node_done++; @@ -1902,7 +1819,6 @@ static MXML_STATUS mxml_node_write( MXML_OUTPUT * out, PHB_ITEM pNode, int style } - /*********************************************************** HBXML lib Virtual stream input/output routines @@ -1913,9 +1829,10 @@ static MXML_STATUS mxml_node_write( MXML_OUTPUT * out, PHB_ITEM pNode, int style * In this case, the func member is required. * Node count is optional, but highly wanted for progress indicators. */ -/* Currently not used - static MXML_OUTPUT *mxml_output_new( MXML_OUTPUT_FUNC func, int node_count) - { +/* Currently not used */ +#if 0 +static MXML_OUTPUT * mxml_output_new( MXML_OUTPUT_FUNC func, int node_count ) +{ MXML_OUTPUT * ret = ( MXML_OUTPUT * ) MXML_ALLOCATOR( sizeof( MXML_OUTPUT ) ); if( ret == NULL ) @@ -1926,8 +1843,8 @@ static MXML_STATUS mxml_node_write( MXML_OUTPUT * out, PHB_ITEM pNode, int style MXML_DELETOR( ret ); return NULL; - } - */ +} +#endif /** * Sets up output parameters. @@ -1938,9 +1855,7 @@ static MXML_STATUS mxml_node_write( MXML_OUTPUT * out, PHB_ITEM pNode, int style static MXML_STATUS mxml_output_setup( MXML_OUTPUT * out, MXML_OUTPUT_FUNC func, int node_count ) { if( func == NULL ) - { return MXML_STATUS_ERROR; - } out->output_func = func; out->node_count = node_count; @@ -1951,12 +1866,13 @@ static MXML_STATUS mxml_output_setup( MXML_OUTPUT * out, MXML_OUTPUT_FUNC func, return MXML_STATUS_ERROR; } -/* Currently not used - static void mxml_output_destroy( MXML_OUTPUT * out ) - { +/* Currently not used */ +#if 0 +static void mxml_output_destroy( MXML_OUTPUT * out ) +{ MXML_DELETOR( out ); - } - */ +} +#endif /**********************************************/ /* output functions */ @@ -1975,12 +1891,13 @@ static MXML_STATUS mxml_output_string_len( MXML_OUTPUT * out, const char * s, HB return out->status; } -/* Currently not used - static MXML_STATUS mxml_output_string( MXML_OUTPUT * out, const char * s ) - { +/* Currently not used */ +#if 0 +static MXML_STATUS mxml_output_string( MXML_OUTPUT * out, const char * s ) +{ return mxml_output_string_len( out, s, strlen( s ) ); - } - */ +} +#endif static MXML_STATUS mxml_output_string( MXML_OUTPUT * out, const char * s ) { @@ -2064,10 +1981,10 @@ static void mxml_output_func_to_sgs( MXML_OUTPUT * out, const char * s, HB_ISIZ * eof. If both func and buf are NULL, the creation fails, and the function * retunrs NULL. */ -/* Currently unused - static MXML_REFIL * mxml_refil_new( MXML_REFIL_FUNC func, char * buf, HB_ISIZ buflen, - HB_ISIZ bufsize ) - { +#if 0 +static MXML_REFIL * mxml_refil_new( MXML_REFIL_FUNC func, char * buf, HB_ISIZ buflen, + HB_ISIZ bufsize ) +{ MXML_REFIL * ret = ( MXML_REFIL * ) MXML_ALLOCATOR( sizeof( MXML_REFIL ) ); if( ret == NULL ) @@ -2078,7 +1995,8 @@ static void mxml_output_func_to_sgs( MXML_OUTPUT * out, const char * s, HB_ISIZ MXML_DELETOR( ret ); return NULL; - }*/ +} +#endif /** * Sets up refiller parameters. @@ -2096,7 +2014,6 @@ static void mxml_output_func_to_sgs( MXML_OUTPUT * out, const char * s, HB_ISIZ static MXML_STATUS mxml_refil_setup( MXML_REFIL * ref, MXML_REFIL_FUNC func, char * buf, HB_ISIZ buflen, HB_ISIZ bufsize ) { - if( buf == NULL && func == NULL ) return MXML_STATUS_ERROR; @@ -2127,12 +2044,13 @@ static MXML_STATUS mxml_refil_setup( MXML_REFIL * ref, MXML_REFIL_FUNC func, return MXML_STATUS_OK; } -/* Currently not used. - static void mxml_refil_destroy ( MXML_REFIL * ref ) - { +/* Currently not used. */ +#if 0 +static void mxml_refil_destroy( MXML_REFIL * ref ) +{ MXML_DELETOR( ref ); - } - */ +} +#endif static int mxml_refil_getc( MXML_REFIL * ref ) { @@ -2158,13 +2076,13 @@ static int mxml_refil_getc( MXML_REFIL * ref ) return ref->buffer[ ref->bufpos++ ]; } - -/* implemented as a macro - void mxml_refil_ungetc( MXML_REFIL * ref, int chr ) - { +/* implemented as a macro */ +#if 0 +void mxml_refil_ungetc( MXML_REFIL * ref, int chr ) +{ ref->sparechar = chr; - } - */ +} +#endif /** * Useful "fill" function that reads from a file handle @@ -2240,9 +2158,8 @@ static MXML_STATUS mxml_sgs_append_char( MXML_SGS * sgs, char c ) { buf = ( char * ) MXML_REALLOCATOR( sgs->buffer, sgs->allocated + MXML_ALLOC_BLOCK ); if( buf == NULL ) - { return MXML_STATUS_ERROR; - } + sgs->allocated += MXML_ALLOC_BLOCK; sgs->buffer = buf; } @@ -2276,12 +2193,13 @@ static MXML_STATUS mxml_sgs_append_string_len( MXML_SGS * sgs, const char * s, H } -/* Currently not used - static MXML_STATUS mxml_sgs_append_string( MXML_SGS * sgs, char * s ) - { +/* Currently not used */ +#if 0 +static MXML_STATUS mxml_sgs_append_string( MXML_SGS * sgs, char * s ) +{ return mxml_sgs_append_string_len( sgs, s, strlen( s ) ); - } - */ +} +#endif static char * mxml_sgs_extract( MXML_SGS * sgs ) { @@ -2290,13 +2208,9 @@ static char * mxml_sgs_extract( MXML_SGS * sgs ) sgs->buffer[ sgs->length ] = 0; if( sgs->allocated > sgs->length + 1 ) - { ret = ( char * ) MXML_REALLOCATOR( sgs->buffer, sgs->length + 1 ); - } else - { ret = sgs->buffer; - } MXML_DELETOR( sgs ); @@ -2336,8 +2250,6 @@ static const char * mxml_error_desc( MXML_ERROR_CODE code ) } - - /*********************************************************** HBXML lib xHarbour RTL & VM interface @@ -2369,9 +2281,7 @@ HB_FUNC( HBXML_DATAREAD ) } if( hb_itemGetWriteCL( pParam, &buf, &ulLen ) ) - { mxml_refil_setup( &refil, NULL, buf, ulLen, ulLen ); - } else /* can only be an integer, that is, a file handle */ { mxml_refil_setup( &refil, diff --git a/harbour/contrib/xhb/txtline.c b/harbour/contrib/xhb/txtline.c index b4d3cec365..67dc6e35c3 100644 --- a/harbour/contrib/xhb/txtline.c +++ b/harbour/contrib/xhb/txtline.c @@ -175,17 +175,11 @@ static HB_ISIZ hb_tabexpand( const char * szString, char * szRet, HB_ISIZ nEnd, for( nPos = 0; nPos <= nEnd; nPos++ ) { if( szString[ nPos ] == HB_CHAR_HT ) - { nSpAdded += ( ( nTabLen > 0 ) ? nTabLen - ( ( nPos + nSpAdded ) % nTabLen ) - 1 : 0 ); - } else if( ( nPos < nEnd && szString[ nPos ] == HB_CHAR_SOFT1 && szString[ nPos + 1 ] == HB_CHAR_SOFT2 ) || szString[ nPos ] == HB_CHAR_LF ) - { nSpAdded--; - } else - { *( szRet + nPos + nSpAdded ) = *( szString + nPos ); - } } return nSpAdded + nEnd; @@ -207,9 +201,7 @@ HB_FUNC( HB_TABEXPAND ) } if( ( nStrLen == 0 ) || ( nTabCount == 0 ) || ( nTabLen == 0 ) ) - { hb_retc( szText ); - } else { nSize = nStrLen + nTabCount * ( nTabLen - 1 ); diff --git a/harbour/contrib/xhb/xhbcopyf.c b/harbour/contrib/xhb/xhbcopyf.c index 0fb071ca65..bba07df1ec 100644 --- a/harbour/contrib/xhb/xhbcopyf.c +++ b/harbour/contrib/xhb/xhbcopyf.c @@ -61,11 +61,11 @@ #include #endif -#define BUFFER_SIZE 8192 +#define BUFFER_SIZE 8192 static HB_BOOL hb_copyfile( const char * szSource, const char * szDest, PHB_ITEM pBlock ) { - HB_BOOL bRetVal = HB_FALSE; + HB_BOOL bRetVal = HB_FALSE; HB_FHANDLE fhndSource; HB_TRACE( HB_TR_DEBUG, ( "hb_copyfile(%s, %s)", szSource, szDest ) ); @@ -94,7 +94,7 @@ static HB_BOOL hb_copyfile( const char * szSource, const char * szDest, PHB_ITEM { #if defined( HB_OS_UNIX ) struct stat struFileInfo; - int iSuccess = fstat( fhndSource, &struFileInfo ); + int iSuccess = fstat( fhndSource, &struFileInfo ); #endif HB_BYTE * buffer = ( HB_BYTE * ) hb_xgrab( BUFFER_SIZE ); HB_USHORT usRead; @@ -153,5 +153,5 @@ HB_FUNC( XHB_COPYFILE ) hb_retl( HB_FALSE ); } else - hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); /* NOTE: Undocumented but existing Clipper Run-time error */ + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); /* NOTE: Undocumented but existing Clipper Run-time error */ } diff --git a/harbour/contrib/xhb/xhbfunc.c b/harbour/contrib/xhb/xhbfunc.c index 52ef78a3a2..7137751faf 100644 --- a/harbour/contrib/xhb/xhbfunc.c +++ b/harbour/contrib/xhb/xhbfunc.c @@ -112,9 +112,9 @@ HB_FUNC_TRANSLATE( HB_CMDARGARGV, HB_PROGNAME ) HB_FUNC( HB_VMMODE ) { -#if defined( HB_NO_PROFILER ) && defined( HB_NO_TRACE ) && !defined( HB_GUI ) +#if defined( HB_NO_PROFILER ) && defined( HB_NO_TRACE ) && ! defined( HB_GUI ) hb_retni( 2 ); /* optimized for console applications */ -#elif defined( HB_NO_PROFILER ) && defined( HB_NO_TRACE ) && defined( HB_GUI ) +#elif defined( HB_NO_PROFILER ) && defined( HB_NO_TRACE ) && defined( HB_GUI ) hb_retni( 1 ); /* optimized for gui applications */ #else hb_retni( 0 ); /* no optimization */ @@ -138,8 +138,8 @@ HB_FUNC( XHB__KEYBOARD ) else if( HB_ISARRAY( 1 ) ) { PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY ); - HB_SIZE nIndex; - HB_SIZE nElements = hb_arrayLen( pArray ); + HB_SIZE nIndex; + HB_SIZE nElements = hb_arrayLen( pArray ); for( nIndex = 1; nIndex <= nElements; nIndex++ ) { @@ -159,7 +159,7 @@ HB_FUNC( XHB__KEYBOARD ) HB_FUNC( HB_CREATELEN8 ) { - char buffer[ 8 ]; + char buffer[ 8 ]; HB_MAXINT nValue; if( HB_ISNUM( 1 ) ) @@ -179,6 +179,7 @@ HB_FUNC( HB_CREATELEN8 ) HB_FUNC( HB_GETLEN8 ) { const char * buffer = hb_parc( 1 ); + if( buffer && hb_parclen( 1 ) >= 8 ) hb_retnint( HB_GET_LE_UINT64( buffer ) ); else @@ -188,6 +189,7 @@ HB_FUNC( HB_GETLEN8 ) HB_FUNC( HB_DESERIALBEGIN ) { PHB_ITEM pItem = hb_param( 1, HB_IT_STRING ); + if( pItem ) hb_itemReturn( pItem ); } @@ -214,10 +216,10 @@ HB_FUNC( HB_F_EOF ) HB_FUNC( CURDIRX ) { HB_ERRCODE uiErrorOld = hb_fsError(); - char * pbyBuffer = ( char * ) hb_xgrab( HB_PATH_MAX + 1 ); - PHB_ITEM pDrv = hb_param( 1, HB_IT_STRING ); - int iCurDrv = hb_fsCurDrv(); - int iDrv; + char * pbyBuffer = ( char * ) hb_xgrab( HB_PATH_MAX + 1 ); + PHB_ITEM pDrv = hb_param( 1, HB_IT_STRING ); + int iCurDrv = hb_fsCurDrv(); + int iDrv; if( pDrv && hb_parclen( 1 ) > 0 ) { @@ -264,8 +266,8 @@ HB_FUNC( HB_EXEC ) { if( HB_ISSYMBOL( 1 ) ) { - HB_BOOL fSend = HB_FALSE; - int iParams = hb_pcount() - 1; + HB_BOOL fSend = HB_FALSE; + int iParams = hb_pcount() - 1; if( iParams >= 1 ) { diff --git a/harbour/contrib/xhb/xhbtrim.c b/harbour/contrib/xhb/xhbtrim.c index 8eaaae34fc..42fc45345f 100644 --- a/harbour/contrib/xhb/xhbtrim.c +++ b/harbour/contrib/xhb/xhbtrim.c @@ -64,7 +64,7 @@ HB_FUNC( XHB_RTRIM ) if( pText ) { - HB_SIZE nLen, nSrc; + HB_SIZE nLen, nSrc; const char * szText = hb_itemGetCPtr( pText ); nSrc = hb_itemGetCLen( pText ); @@ -93,11 +93,11 @@ HB_FUNC( XHB_ALLTRIM ) if( pText ) { - HB_SIZE nLen, nSrc; + HB_SIZE nLen, nSrc; const char * szText = hb_itemGetCPtr( pText ); - nSrc = hb_itemGetCLen( pText ); - nLen = hb_strRTrimLen( szText, nSrc, hb_parl( 2 ) ); + nSrc = hb_itemGetCLen( pText ); + nLen = hb_strRTrimLen( szText, nSrc, hb_parl( 2 ) ); szText = hb_strLTrim( szText, &nLen ); if( nLen == nSrc )