1 #ifndef __JBXL_TOOLS_HEADER_
2 #define __JBXL_TOOLS_HEADER_
12 #include <sys/types.h>
25 #include <sys/sysinfo.h>
29 #ifdef HAVE_ARPA_INET_H
30 #include <arpa/inet.h>
33 #ifdef TIME_WITH_SYS_TIME
40 #ifdef HAVE_SYS_TIME_H
45 #ifdef HAVE_SYS_PARAM_H
46 #include <sys/param.h>
56 #ifdef HAVE_SYS_WAIT_H
60 #ifdef HAVE_SYS_ERRNO_H
61 #include <sys/errno.h>
70 #define HUGE_VALF ((double)HUGE_VAL)
88 #define UNKNOWN_ENDIAN 0
91 #define LITTLE_ENDIAN 1234
92 #define BIG_ENDIAN 4321
93 #define PDP_ENDIAN 3412
97 #define CHAR_DELI_DIR '\\'
98 #define STR_DELI_DIR "\\"
99 #define STR_CRNT_DIR ".\\"
100 #define STR_UPST_DIR "..\\"
102 #define CHAR_DELI_DIR '/'
103 #define STR_DELI_DIR "/"
104 #define STR_CRNT_DIR "./"
105 #define STR_UPST_DIR "../"
109 typedef union _union_val {
131 typedef union _union_ptr {
155 typedef struct _ringBuffer {
167 #define mstream ringBuffer
171 typedef struct _rectangle {
191 #define LOCAL_IPv4 "127.0.0.1"
192 #define LOCAL_IPv6 "::1"
193 #define LOCAL_IPADDR LOCAL_IPv4
194 #define LOCAL_IPADDR6 LOCAL_IPv6
201 #define freeNull(p) {if(!isNull((void*)p)) free(p); (p)=NULL;}
202 #define freenull(p) {if(!isNull((void*)p)) free(p); (p)=NULL;}
205 #define free_null(p) freeNull((p))
207 #define _tochar(a) (char*)(a)
216 char*
awk (
char* str,
char cc,
int n);
217 char*
cawk(
char* str,
char cc,
int n);
223 #define dup_string(s) dup_str((s))
225 char*
skip_chars(
char* pp,
const char* check);
233 char*
chomp(
char* str);
236 #define pack_char(s, c) pack_char_len((s), (c), -1)
244 char*
lltostr(
long long int n);
261 long unsigned long int ntohull(
long unsigned long int s);
262 #define htonull(s) ntohull((s))
265 short swaps(
unsigned short p);
266 int swapl(
unsigned int p);
267 long long int swapd(
long unsigned long int p);
270 #define int_swap(p, s) {int swap=(p); (p)=(s); (s)=swap;}
273 int bincmp(
unsigned char* b1,
unsigned char* b2,
int n);
274 int strnrvscmp(
const char* s1,
const char* s2,
int n);
279 int ex_strncmp(
const char* s1,
const char* s2,
int n);
283 #define ex_strcmp(a, b) ex_strncasecmp((a), (b), -1)
311 void fdump(FILE* fp,
unsigned char* mesg,
int n);
312 void print_16x(FILE* fp,
unsigned char* mesg,
int n);
313 #define print_hex(o, m, n) fdump((o), (m), (n))
322 void euc2sjis(
unsigned char *c1,
unsigned char *c2);
323 void sjis2euc(
unsigned char *c1,
unsigned char *c2);
326 int file_from_to(
const char* s,
const char* d,
const char* mode);
327 int fp_from_to(FILE* s, FILE* d,
long int sz);
342 unsigned char*
read_file (
const char* fname,
long unsigned int* size);
343 long unsigned int write_file(
const char* fname,
unsigned char*
buf,
long unsigned int size);
345 int mkdirp(
const char* path, mode_t mode);
351 #define random_str(n) temp_filename(NULL, (n))
363 unsigned char decode_hex(
unsigned char c1,
unsigned char c2);
383 #define init_mstream() init_ringBuffer()
384 #define new_mstream(s) new_ringBuffer((s))
385 #define make_mstream(s) make_ringBuffer((s))
386 #define free_mstream(s) free_ringBuffer((s))
387 #define del_mstream(s) del_ringBuffer((s))
388 #define clear_mstream(s) clear_ringBuffer((s))
391 unsigned char*
uuid2guid(
unsigned char* p);
392 unsigned char*
guid2uuid(
unsigned char* p);
411 #define set_sigseg_handler(h) set_sigsegv_handler((h))
419 #define copy_file(src, dst) file_from_to((src), (dst), "wb")
420 #define cat_file(src, dst) file_from_to((src), (dst), "ab")
422 #define isBigEndian (is_big_endian())
423 #define isLittleEndian (is_little_endian())
425 #define ntoh_st(p, s) {if(!isBigEndian) swap_byte((void*)(p),sizeof(*(p)),(s));}
426 #define hton_st(p, s) {if(!isBigEndian) swap_byte((void*)(p),sizeof(*(p)),(s));}
427 #define ntoh_ar(p, s) {if(!isBigEndian) swap_byte((void*)(p),(s),sizeof(*(p)));}
428 #define hton_ar(p, s) {if(!isBigEndian) swap_byte((void*)(p),(s),sizeof(*(p)));}
430 #define ntoh_data(p, s, c) {if(!isBigEndian) swap_byte((void*)(p),(s),(c));}
431 #define hton_data(p, s, c) {if(!isBigEndian) swap_byte((void*)(p),(s),(c));}
440 #define JBXL_LOG_FILE "\\jbxl.log"
441 #define JBXL_ERR_FILE "\\jbxl.err"
443 #define JBXL_LOG_FILE "/var/log/jbxl.log"
444 #define JBXL_ERR_FILE "/var/log/jbxl.err"
469 #define PRINT_MESG(...) {}
470 #define PRINT_ESC(...) {}
471 #define PRINT_INFO(...) {}
472 #define PRINT_WARN(...) {}
473 #define PRINT_ERROR(...) {}
475 #define PRINT_MESG print_message
476 #define PRINT_ESC print_escape
477 #define PRINT_INFO print_message
478 #define PRINT_WARN print_message
479 #define PRINT_ERROR print_message
502 #define DEBUG_MODE if(DebugMode==ON)
503 #define NO_DEBUG_MODE if(DebugMode==OFF)
511 #define DEBUG_INFO PRINT_INFO
512 #define DEBUG_WARN PRINT_WARN
513 #define DEBUG_ERROR PRINT_ERROR
514 #define DEBUG_MESG PRINT_MESG
516 #define DEBUG_INFO(...) {}
517 #define DEBUG_WARN(...) {}
518 #define DEBUG_ERROR(...) {}
519 #define DEBUG_MESG(...) {}
unsigned short uWord
2Byte
int datasz
保存されているデータの全体の長さ
int datano
格納されているデータの数(メッセージデータ用)
int npoint
次のメッセージのスタートポイント(メッセージデータ用)
int epoint
バッファデータの終点+1 (データの追加点)
long unsigned int * ulintp
unsigned short int * usintp
long unsigned long int * ullintp
long unsigned long int ullint