1#ifndef __JBXL_TOOLS_HEADER_
2#define __JBXL_TOOLS_HEADER_
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>
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 "../"
109typedef union _union_val {
131typedef union _union_ptr {
155typedef struct _ringBuffer {
167#define mstream ringBuffer
171typedef 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)
216char*
awk (
char* str,
char cc,
int n);
217char*
cawk(
char* str,
char cc,
int n);
219void replace_char(
unsigned char* buf,
int len,
unsigned char frm,
unsigned char toc);
220char*
replace_str(
char* buf,
int len,
const char* frm,
const char* tos);
221char*
cut_str(
char* buf,
int ls,
int le);
223#define dup_string(s) dup_str((s))
233char*
chomp(
char* str);
236#define pack_char(s, c) pack_char_len((s), (c), -1)
261long unsigned long int ntohull(
long unsigned long int s);
262#define htonull(s) ntohull((s))
265short swaps(
unsigned short p);
266int swapl(
unsigned int p);
267long long int swapd(
long unsigned long int p);
270#define int_swap(p, s) {int swap=(p); (p)=(s); (s)=swap;}
273int bincmp(
unsigned char* b1,
unsigned char* b2,
int n);
274int strnrvscmp(
const char* s1,
const char* s2,
int n);
276char*
strstrcase(
const char* buf,
const char* nd);
279int ex_strncmp(
const char* s1,
const char* s2,
int n);
283#define ex_strcmp(a, b) ex_strncasecmp((a), (b), -1)
311void fdump(FILE* fp,
unsigned char* mesg,
int n);
312void print_16x(FILE* fp,
unsigned char* mesg,
int n);
313#define print_hex(o, m, n) fdump((o), (m), (n))
322void euc2sjis(
unsigned char *c1,
unsigned char *c2);
323void sjis2euc(
unsigned char *c1,
unsigned char *c2);
326int file_from_to(
const char* s,
const char* d,
const char* mode);
342unsigned char*
read_file (
const char* fname,
long unsigned int* size);
343long unsigned int write_file(
const char* fname,
unsigned char* buf,
long unsigned int size);
351#define random_str(n) temp_filename(NULL, (n))
363unsigned 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))
391unsigned char*
uuid2guid(
unsigned char* p);
392unsigned char*
guid2uuid(
unsigned char* p);
397long unsigned int get_used_memory(
void);
398long unsigned int get_free_memory(
void);
400void memory_check_start(
void);
401long unsigned int memory_check(
void);
403void set_sigterm_child(
void (*handler)(
int));
404void sigterm_child(
int signal);
406void ignore_sigterm_child(
void);
408void set_sigsegv_handler(
void (*handler)(
int));
409void trap_segmentation_falt(
int signal);
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