|
JunkBox_Lib 1.10.1
|
汎用ツールヘッダ More...
#include "common.h"#include <sys/types.h>#include <sys/stat.h>#include <stdarg.h>#include <ctype.h>#include <unistd.h>#include <sys/sysinfo.h>#include <errno.h>#include <signal.h>

Go to the source code of this file.
Data Structures | |
| union | unionVal |
| union | unionPtr |
| struct | ringBuffer |
| struct | rectAngle |
Macros | |
| #define | CHAR_CR 0x0d |
| 改行 | |
| #define | CHAR_LF 0x0a |
| ラインフィード | |
| #define | CHAR_TAB 0x09 |
| タブ | |
| #define | CODE_US 0 |
| #define | CODE_EN 0 |
| #define | CODE_EUC 1 |
| #define | CODE_SJIS 2 |
| #define | CODE_UTF8 3 |
| #define | UNKNOWN_ENDIAN 0 |
| #define | LITTLE_ENDIAN 1234 |
| #define | BIG_ENDIAN 4321 |
| #define | PDP_ENDIAN 3412 |
| #define | CHAR_DELI_DIR '/' |
| #define | STR_DELI_DIR "/" |
| #define | STR_CRNT_DIR "./" |
| #define | STR_UPST_DIR "../" |
| #define | mstream ringBuffer |
| バイト型 メッセージストリーム | |
| #define | LOCAL_IPv4 "127.0.0.1" |
| #define | LOCAL_IPv6 "::1" |
| #define | LOCAL_IPADDR LOCAL_IPv4 |
| #define | LOCAL_IPADDR6 LOCAL_IPv6 |
| #define | freeNull(p) {if(!isNull((void*)p)) free(p); (p)=NULL;} |
| #define | freenull(p) {if(!isNull((void*)p)) free(p); (p)=NULL;} |
| #define | free_null(p) freeNull((p)) |
| #define | _tochar(a) (char*)(a) |
| #define | dup_string(s) dup_str((s)) |
| dup_str() | |
| #define | pack_char(s, c) pack_char_len((s), (c), -1) |
| pack_char_len() | |
| #define | htonull(s) ntohull((s)) |
| Host形式からNetwork形式へ,64bit long unsigned long int データの変換 ntohull() | |
| #define | int_swap(p, s) {int swap=(p); (p)=(s); (s)=swap;} |
| データを入れ替える | |
| #define | ex_strcmp(a, b) ex_strncasecmp((a), (b), -1) |
| 文字列 aの長さに合わせて比較する.大文字小文字を区別しない.一致するなら TRUE | |
| #define | print_hex(o, m, n) fdump((o), (m), (n)) |
| #define | random_str(n) temp_filename(NULL, (n)) |
| ランダムな文字列を生成.要 free(). see temp_filename() | |
| #define | init_mstream() init_ringBuffer() |
| init_ringBuffer() | |
| #define | new_mstream(s) new_ringBuffer((s)) |
| new_ringBuffer() | |
| #define | make_mstream(s) make_ringBuffer((s)) |
| make_ringBuffer() | |
| #define | free_mstream(s) free_ringBuffer((s)) |
| free_ringBuffer() | |
| #define | del_mstream(s) del_ringBuffer((s)) |
| del_ringBuffer() | |
| #define | clear_mstream(s) clear_ringBuffer((s)) |
| clear_ringBuffer() | |
| #define | set_sigseg_handler(h) set_sigsegv_handler((h)) |
| set_sigsegv_handler() | |
| #define | copy_file(src, dst) file_from_to((src), (dst), "wb") |
| srcから dstへファイルをコピーする.file_from_to() | |
| #define | cat_file(src, dst) file_from_to((src), (dst), "ab") |
| srcから dstへファイルを catする. file_from_to() | |
| #define | isBigEndian (is_big_endian()) |
| #define | isLittleEndian (is_little_endian()) |
| #define | ntoh_st(p, s) {if(!isBigEndian) swap_byte((void*)(p),sizeof(*(p)),(s));} |
| network形式から host形式へ.構造体pに対して sバイトづつ変換. | |
| #define | hton_st(p, s) {if(!isBigEndian) swap_byte((void*)(p),sizeof(*(p)),(s));} |
| host形式から network形式へ.構造体pに対して sバイトづつ変換. | |
| #define | ntoh_ar(p, s) {if(!isBigEndian) swap_byte((void*)(p),(s),sizeof(*(p)));} |
| network形式から host形式へ.長さsバイトの配列pに対して変換 | |
| #define | hton_ar(p, s) {if(!isBigEndian) swap_byte((void*)(p),(s),sizeof(*(p)));} |
| host形式から network形式へ.長さsバイトの配列pに対して変換. | |
| #define | ntoh_data(p, s, c) {if(!isBigEndian) swap_byte((void*)(p),(s),(c));} |
| network形式からhost形式へ. cバイトづつ変換する. | |
| #define | hton_data(p, s, c) {if(!isBigEndian) swap_byte((void*)(p),(s),(c));} |
| host形式から network形式へ. cバイトづつ変換する. | |
| #define | JBXL_LOG_FILE "/var/log/jbxl.log" |
| デフォルトのログファイル | |
| #define | JBXL_ERR_FILE "/var/log/jbxl.err" |
| デフォルトのエラーファイル | |
| #define | PRINT_MESG print_message |
| 環境依存用の出力関数.print_message() | |
| #define | PRINT_ESC print_escape |
| 環境依存用の出力関数.print_escape() | |
| #define | PRINT_INFO print_message |
| 環境依存用の出力関数.print_message() | |
| #define | PRINT_WARN print_message |
| 環境依存用の出力関数.print_message() | |
| #define | PRINT_ERROR print_message |
| 環境依存用の出力関数.print_message() | |
| #define | EBUG |
| #define | DEBUG_MODE if(DebugMode==ON) |
| #define | NO_DEBUG_MODE if(DebugMode==OFF) |
| #define | DEBUG_INFO PRINT_INFO |
| デバッグ用出力関数.コンパイル時に削除可能 | |
| #define | DEBUG_WARN PRINT_WARN |
| デバッグ用出力関数.コンパイル時に削除可能 | |
| #define | DEBUG_ERROR PRINT_ERROR |
| デバッグ用出力関数.コンパイル時に削除可能 | |
| #define | DEBUG_MESG PRINT_MESG |
| デバッグ用出力関数.コンパイル時に削除可能 | |
Functions | |
| int | isNull (void *p) |
| char * | get_line (char *buf, int n) |
| 文字型データbufのバッファ内の n行目を取り出す.改行コードは削除される.要 free() | |
| char * | get_seq_data (char *buf, int *ptr) |
| 文字型データbufのバッファ内の 行データをシーケンシャルに取り出す. | |
| char * | awk (char *str, char cc, int n) |
| ccを区切り記号として, strのバッファ内の n番目の項目を返す.要 free() | |
| char * | cawk (char *str, char cc, int n) |
| 連続するccを区切り記号として, strのバッファ内の n番目の項目を返す.要 free() | |
| void | replace_char (unsigned char *buf, int len, unsigned char frm, unsigned char toc) |
| データbuf 中のバイトデータ frm を tocに変更する. | |
| char * | replace_str (char *buf, int len, const char *frm, const char *tos) |
| 文字列 buf中の frmを tosに書き換えたものを返す.free() してはいけない. | |
| char * | cut_str (char *buf, int ls, int le) |
| buf[ls]〜buf[le] を切り出す.要 free() | |
| char * | dup_str (char *buf) |
| 文字列を複製する.要 free() | |
| char * | skip_chars (char *pp, const char *check) |
| check[]中の何れかの文字までポインタをスキップさせる.ただし クォーテーション内は完全スキップ | |
| char * | skip_char (char *pp, char cc) |
| cc の文字までポインタをスキップさせる.ただし クォーテーション内は完全スキップ | |
| char * | skip_char_pair (char *pp, char pair, char end) |
| pair と end で閉じるまでポインタをスキップさせる.ただし クォーテーション内は完全スキップ | |
| char * | skip_string_end (char *pp) |
| 次の文字列を一つスキップする.最期のクォーテーションの位置を返す. | |
| char * | pack_char_len (char *pp, char cc, int len) |
| 文字列の一部の先頭のcc(複数),終わりのcc(複数),CR, LF を削除.要 free() | |
| char * | pack_head_tail_char (char *pp, char cc) |
| 文字の先頭のcc(複数),TAB, CR, LF.終わりのcc(複数),TAB, CR, LF を削除.要 free() | |
| char * | change_esc (char *pp) |
| 文字列中の CR, LF を \r, \n に変換する.要 free() | |
| char * | chomp (char *str) |
| 最初の改行コード以降を無効にする. | |
| char * | double_bs (char *fn) |
| 文字列中の \ を \\に置き換えた文字列を返す.要 free() | |
| char * | numbering_name (const char *fmt, int n) |
| フォーマット fmtに従って,nを含む文字列を作り出す.要 free() | |
| int | is_number (unsigned char *) |
| 数字かどうか判定する(簡易版).整数(1) と小数点付き数字(2) のみ. | |
| char * | itostr (int n) |
| int を文字に変換する.free() は不要 | |
| char * | ltostr (long int n) |
| long int を文字に変換する.free() は不要 | |
| char * | ultostr (long unsigned int n) |
| long unsigned int を文字に変換する.free() は不要 | |
| char * | lltostr (long long int n) |
| long long int を文字に変換する.free() は不要 | |
| char * | ulltostr (long unsigned long int n) |
| long unsigned long int を文字に変換する.free() は不要 | |
| char * | ftostr (float n) |
| float を文字に変換する.free() は不要 | |
| char * | dtostr (double n) |
| double を文字に変換する.free() は不要 | |
| char * | itostr_ts (int n) |
| int を文字に変換する.要 free() | |
| char * | ltostr_ts (long int n) |
| long int を文字に変換する.要 free() | |
| char * | ultostr_ts (long unsigned int n) |
| long unsigned int を文字に変換する.要 free() | |
| char * | lltostr_ts (long long int n) |
| long long int を文字に変換する.要 free() | |
| char * | ulltostr_ts (long unsigned long int n) |
| long unsigned long int を文字に変換する.要 free() | |
| char * | ftostr_ts (float n) |
| float を文字に変換する.要 free() | |
| char * | dtostr_ts (double n) |
| double を文字に変換する.要 free() | |
| int | count_lines (const char *buf) |
| 文字列データの行数を数える.行頭が '\0'の場合も1行と数える. | |
| int | hexstr2i (const char *str) |
| 16進の文字列を整数に変換する. | |
| long unsigned long int | ntohull (long unsigned long int s) |
| Network形式からHost形式へ,64bit long unsigned long int データの変換 | |
| void | swap_byte (void *p, int s, int b) |
| sの長さのpのバイト順序をbバイト毎に逆順にする. | |
| short | swaps (unsigned short p) |
| 16bit の上下8bitを入れ替える. | |
| int | swapl (unsigned int p) |
| 32bit pを8bitづつ逆順にする | |
| long long int | swapd (long unsigned long int p) |
| 64bit pを8bitづつ逆順にする | |
| void | reverse_str (uByte *p, int s) |
| バイト(octet)列を逆順にする. | |
| void | upper_string (char *str) |
| int | bincmp (unsigned char *b1, unsigned char *b2, int n) |
| バイナリデータを n Byte比べる.一致するなら 0 | |
| int | strnrvscmp (const char *s1, const char *s2, int n) |
| 文字列 s1と s2を後ろから n文字比較する.一致するなら 0 | |
| int | strncaservscmp (const char *s1, const char *s2, int n) |
| 文字列 s1と s2を後ろから n文字比較する.大文字小文字は区別しない.一致するなら 0 | |
| char * | strstrcase (const char *buf, const char *nd) |
| 文字列 bufの中に文字列 ndがあるかどうかをチェックする.大文字小文字は区別しない. | |
| int | ex_strncmp (const char *s1, const char *s2, int n) |
| 文字列 s1とs2を拡張比較する.一致するなら TRUE | |
| int | ex_strncasecmp (const char *s1, const char *s2, int n) |
| 文字列 s1とs2を拡張比較する.大文字小文字を区別しない.一致するなら TRUE | |
| int | ex_strnrvscmp (const char *s1, const char *s2, int n) |
| 文字列 s1とs2を後ろから拡張比較する.一致するなら TRUE | |
| int | ex_strncaservscmp (const char *s1, const char *s2, int n) |
| 文字列 s1とs2を後ろから拡張比較する.一致するなら TRUE | |
| int | is_little_endian (void) |
| エンディアンの動的チェック | |
| int | is_big_endian (void) |
| エンディアンの動的チェック | |
| void | check_endian (void) |
| システムのエンディアンを判別して,大域変数 HostEndian に設定する | |
| double | double_from_little_endian (void *ptr) |
| エンディアンによるデータ変換 | |
| float | float_from_little_endian (void *ptr) |
| int | int_from_little_endian (void *ptr) |
| unsigned int | uint_from_little_endian (void *ptr) |
| short | short_from_little_endian (void *ptr) |
| unsigned short | ushort_from_little_endian (void *ptr) |
| double | double_from_big_endian (void *ptr) |
| float | float_from_big_endian (void *ptr) |
| int | int_from_big_endian (void *ptr) |
| unsigned int | uint_from_big_endian (void *ptr) |
| short | short_from_big_endian (void *ptr) |
| unsigned short | ushort_from_big_endian (void *ptr) |
| char * | get_local_timestamp (time_t date, const char *format) |
| 要 free() | |
| char * | get_gmt_timestamp (time_t date, const char *format) |
| 要 free() | |
| void | print_escape (const char *format, char *mesg) |
| エスケープ文字を含むメッセージの出力(stderr) | |
| void | fdump (FILE *fp, unsigned char *mesg, int n) |
| 16進ダンプを吐き出す | |
| void | print_16x (FILE *fp, unsigned char *mesg, int n) |
| 16進ダンプを吐き出す(1行) | |
| char * | get_graphic_extension (uWord tex) |
| void | kanji_convert (unsigned char *mesg) |
| 大域変数 KnjiCodeに従って漢字コードを変換する. | |
| void | kanji_convert_euc2sjis (unsigned char *mesg) |
| EUCをSJISに変換する. | |
| void | kanji_convert_sjis2euc (unsigned char *mesg) |
| SJISをEUCに変換する. | |
| void | euc2sjis (unsigned char *c1, unsigned char *c2) |
| EUC -> SJIS. | |
| void | sjis2euc (unsigned char *c1, unsigned char *c2) |
| SJIS -> EUC. | |
| int | file_from_to (const char *s, const char *d, const char *mode) |
| modeに従って,ファイル sを dにコピーする. | |
| int | fp_from_to (FILE *s, FILE *d, long int sz) |
| ファイル sを dにコピーする. | |
| char * | get_file_name (const char *str) |
| フルパスからファイル名へのポインタを取り出す.free() してはいけない. | |
| char * | get_file_extension (const char *str) |
| フルパスからファイル名の拡張子へのポインタを取り出す.free() してはいけない. | |
| char * | del_file_name (const char *str) |
| フルパスを書き換えてファイル名部分を削除する.free() してはいけない. | |
| char * | del_file_extension (const char *str) |
| フルパスを書き換えて拡張子を削除する.free() してはいけない. | |
| char * | get_file_path (const char *str) |
| ファイル名を含むパスからパスのみを生成する.strは変化しない.要 free(). | |
| char * | cut_file_extension (const char *str) |
| 拡張子を削除したフパス名を生成する.strは変化しない.要 free(). | |
| long unsigned | file_size (const char *fn) |
| ファイルの大きさを返す. | |
| int | file_exist (const char *fn) |
| ファイルの存在を検査する. | |
| FILE * | file_chmod_open (const char *fn, const char *fm, mode_t mode) |
| ファイルの許可属性をmode へ変更した後,ファイルを fmモードでオープン | |
| char * | temp_filename (const char *, int) |
| /dev/urandom を利用して作業用ファイルのランダムなファイル名を得る. | |
| unsigned char * | read_file (const char *fname, long unsigned int *size) |
| ファイルからデータを読み込む | |
| long unsigned int | write_file (const char *fname, unsigned char *buf, long unsigned int size) |
| ファイルにデータを書き込む | |
| int | mkdirp (const char *path, mode_t mode) |
| mkdir -p path 相当. | |
| void | init_rand (void) |
| /dev/urandom からデータで乱数の系列を初期化する | |
| char * | randstr (int n) |
| ランダムに A-Za-z0-9 までの文字を n文字生成する. | |
| unsigned char * | randbit (int n) |
| ランダムに n bitのバイナリを生成する. | |
| unsigned char * | encode_base64 (unsigned char *str, int sz) |
| バイナリデータ bufを base64にエンコードする.要 free() | |
| unsigned char * | decode_base64 (unsigned char *str, int *sz) |
| bufを base64からデコードする.要 free() | |
| unsigned char * | encode_base64_filename (unsigned char *str, int sz, unsigned char cc) |
| バイナリデータ bufを Base64で encodeしてファイル名を作る.ただし '/' は cc として扱う.要 free() | |
| unsigned char * | decode_base64_filename (unsigned char *str, int *sz, unsigned char cc) |
| bufを Base64で decodeしてバイナリデータを取り出す.ただし cc は '/' として扱う.要 free() | |
| unsigned char * | encode_urlenc (unsigned char *str, int sz) |
| バイナリデータ bufを URLエンコードする.要 free() | |
| unsigned char * | decode_urlenc (unsigned char *str, int *sz) |
| buf を URLエンコードからデコードする.要 free() | |
| unsigned char * | encode_quoted_printable (unsigned char *str, int sz) |
| バイナリデータ bufを quoted printable にエンコードする.要 free() | |
| unsigned char * | decode_quoted_printable (unsigned char *str, int *sz) |
| buf を quoted printableからデコードする.要 free() | |
| unsigned char * | encode_hex (unsigned char cc) |
| キャラクタを16進コードの文字列に変換する.要 free() | |
| unsigned char | decode_hex (unsigned char c1, unsigned char c2) |
| 16進コードをキャラクタに変換する.O-9,A-F以外が指定された場合は0とみなす. 内容を書き換える. | |
| ringBuffer * | new_ringBuffer (int sz) |
| リングバッファを生成する. | |
| ringBuffer | init_ringBuffer (void) |
| リングバッファを初期化する. | |
| ringBuffer | make_ringBuffer (int sz) |
| バッファ部が存在するリングバッファを作り出す. | |
| void | del_ringBuffer (ringBuffer **pp) |
| リングバッファそのものを削除する.new_ringBuffer() と対. | |
| void | free_ringBuffer (ringBuffer *pp) |
| リングバッファを解放する.make_ringBuffer() と対. | |
| void | clear_ringBuffer (ringBuffer *pp) |
| リングバッファのデータを削除する. | |
| int | put_ringBuffer (ringBuffer *rb, unsigned char *pp, int sz) |
| リングバッファにデータを格納する. | |
| unsigned char * | get_ringBuffer (ringBuffer *rb, int sz) |
| リングバッファからデータを得る.要 free() | |
| int | seek_ringBuffer (ringBuffer *rb, int sz) |
| リングバッファのデータポインタを seek する. | |
| unsigned char * | ref_ringBuffer (ringBuffer *ring, int pos) |
| spoint 地点から pos番目のデータへの参照.posは 0から数える.spoint は変化しない. | |
| int | put_mstream (mstream *sb, unsigned char *pp) |
| メッセージ(文字列)ストリーム sb へメッセージ(の一部)を格納する | |
| unsigned char * | get_mstream (mstream *sb) |
| メッセージ(文字列)ストリーム sb から次のメッセージを取り出す.改行コードは削除される. | |
| unsigned char * | fgets_mstream (unsigned char *mesg, mstream *sb) |
| メッセージストリームからメッセージを一行だけ取り出す. | |
| unsigned char * | uuid2guid (unsigned char *p) |
| uuid を guid に変換する.要 free() | |
| unsigned char * | guid2uuid (unsigned char *p) |
| guid を uuid に変換する.要 free() | |
| long unsigned int | get_used_memory (void) |
| 使用中のメモリサイズを得る. | |
| long unsigned int | get_free_memory (void) |
| 未使用のメモリサイズを得る. | |
| void | memory_check_start (void) |
| long unsigned int | memory_check (void) |
| void | set_sigterm_child (void(*handler)(int)) |
| child プロセス終了時の処理を設定. | |
| void | sigterm_child (int signal) |
| child プロセス終了時の処理 | |
| void | ignore_sigterm_child (void) |
| 以後 child プロセスの終了を無視する. | |
| void | set_sigsegv_handler (void(*handler)(int)) |
| セグメンテーションエラー時のハンドラを設定 | |
| void | trap_segmentation_falt (int signal) |
| セグメンテーションエラー時にデフォルトで呼び出される関数. | |
| void | open_logfile (void) |
| デフォルトのログファイルをオープンする | |
| void | close_logfile (void) |
| デフォルトのログファイルをクローズする | |
| void | print_logfile (const char *,...) |
| デフォルトのログファイルにデータを書き込む | |
| void | open_errfile (void) |
| デフォルトのエラーファイルをオープンする | |
| void | close_errfile (void) |
| デフォルトのエラーファイルをクローズする | |
| void | print_errfile (const char *,...) |
| デフォルトのエラーファイルにデータを書き込む | |
| void | print_message (const char *,...) |
| バッファリングなしのメッセージ出力(stderr) | |
| void | fprint_message (FILE *, const char *,...) |
| バッファリングなしのメッセージ出力 | |
Variables | |
| int | DebugMode |
| ON の場合 ライブラリ全体がデバックモードであることを示す.デフォルトは OFF. | |
| int | UnitTestMode |
| ユニット単体でのテストを行う場合に使用する.デフォルトは OFF. | |
| int | KanjiCode |
| 処理用漢字コード.CODE_US, CODE_SJIS, CODE_EDUがある.デフォルトは CODE_US. | |
| int | HostEndian |
| ホストの Endian | |
| unsigned char | LocalIPNum [4] |
| 127.0.0.1 のバイナリ | |
| unsigned char | LocalIPNum6 [16] |
| ::1 のバイナリ | |
| long unsigned int | UsedMemoryBase |
| メモリチェック用 | |
| FILE * | FP_LogFile |
| FILE * | FP_ErrFile |
Definition in file tools.h.
| #define _tochar | ( | a | ) | (char*)(a) |
Definition at line 207 of file tools.h.
Referenced by check_ldap_passwd().
| #define BIG_ENDIAN 4321 |
Definition at line 92 of file tools.h.
Referenced by double_from_little_endian(), float_from_little_endian(), int_from_little_endian(), is_big_endian(), is_little_endian(), short_from_little_endian(), uint_from_little_endian(), and ushort_from_little_endian().
| #define cat_file | ( | src, | |
| dst ) file_from_to((src), (dst), "ab") |
| #define CHAR_CR 0x0d |
Definition at line 78 of file tools.h.
Referenced by change_esc(), chomp(), chomp_Buffer(), count_lines(), decode_mime_rfc2047(), decode_mime_rfc2231(), decode_mime_string(), decompline_Buffer_dim(), fgets_Buffer(), get_line(), get_line_Buffer(), get_mstream(), get_seq_data(), get_seq_data_Buffer(), get_sip_contact_uri(), get_sip_domain(), get_smtp_mailbox(), pack_char_len(), pack_head_tail_char(), put_mstream(), xml_main_parse(), xml_parse_content(), xml_parse_processing_node(), and xml_parse_start_node().
| #define CHAR_DELI_DIR '/' |
Definition at line 102 of file tools.h.
Referenced by relative_path_Buffer().
| #define CHAR_LF 0x0a |
Definition at line 79 of file tools.h.
Referenced by change_esc(), chomp(), chomp_Buffer(), count_lines(), decode_mime_rfc2047(), decode_mime_rfc2231(), decode_mime_string(), decompline_Buffer_dim(), fgets_Buffer(), get_line(), get_line_Buffer(), get_mstream(), get_seq_data(), get_seq_data_Buffer(), get_sip_contact_uri(), get_sip_domain(), get_smtp_mailbox(), pack_char_len(), pack_head_tail_char(), put_mstream(), ssl_recv_lines_Buffer(), ssl_tcp_recv_lines_Buffer(), tcp_recv_lines_Buffer(), xml_main_parse(), xml_parse_content(), xml_parse_processing_node(), and xml_parse_start_node().
| #define CHAR_TAB 0x09 |
Definition at line 80 of file tools.h.
Referenced by get_protocol_header_list_seq(), pack_char_len(), pack_head_tail_char(), restore_protocol_header(), xml_main_parse(), xml_parse_content(), xml_parse_processing_node(), and xml_parse_start_node().
| #define clear_mstream | ( | s | ) | clear_ringBuffer((s)) |
| #define CODE_SJIS 2 |
Definition at line 85 of file tools.h.
Referenced by kanji_convert(), and kanji_convert_Buffer().
| #define copy_file | ( | src, | |
| dst ) file_from_to((src), (dst), "wb") |
| #define DEBUG_ERROR PRINT_ERROR |
| #define DEBUG_INFO PRINT_INFO |
| #define DEBUG_MESG PRINT_MESG |
Definition at line 502 of file tools.h.
Referenced by _paint_3d(), check_auth(), chk_RZxy(), command_CRYPT(), command_KEYEX(), command_PASSWD(), command_USERID(), gz_decode_data(), gz_decode_fp(), llsd_bin_get_skin_weight(), open_ldap_connection(), read_dicom_file(), read_shape_index_file(), read_shape_main_file(), recv_http_file(), send_command_recv_ans(), and setup_jp2k().
| #define DEBUG_WARN PRINT_WARN |
| #define del_mstream | ( | s | ) | del_ringBuffer((s)) |
| #define ex_strcmp | ( | a, | |
| b ) ex_strncasecmp((a), (b), -1) |
Definition at line 283 of file tools.h.
Referenced by get_http_method(), and print_protocol_header().
| #define free_mstream | ( | s | ) | free_ringBuffer((s)) |
| #define freeNull | ( | p | ) | {if(!isNull((void*)p)) free(p); (p)=NULL;} |
Definition at line 201 of file tools.h.
Referenced by _tcp_bind(), _tcp_bind_setopt(), _tcp_client_bind_socket(), _tcp_client_socket(), _tcp_connect(), _tcp_server_bind(), _tcp_server_bind_setopt(), _tcp_server_socket(), _tcp_server_socket_setopt(), _udp_bind(), _udp_bind_setopt(), _udp_client_socket(), _udp_server_socket(), _udp_server_socket_setopt(), check_auth(), command_USERID(), curvature(), curvature3D(), del_ringBuffer(), free_JPEGImage(), free_pw(), free_ringBuffer(), free_TIFF_ifd(), get_smtp_rcpt(), gz_decode_file_replace(), is_same_network(), is_smtp_onecommand(), llsd_bin_main_parse(), make_JPEGImage(), make_xml_attr_bydouble(), make_xml_attr_byfloat(), make_xml_attr_byint(), open_ldap_connection(), read_tiff_file(), recv_http_Buffer(), recv_http_file(), simple_web_proxy(), write_jpeg_mem(), WSCurve(), x2crypt(), xml_main_parse(), xml_parse_processing_node(), and xml_parse_start_node().
| #define freenull | ( | p | ) | {if(!isNull((void*)p)) free(p); (p)=NULL;} |
| #define hton_ar | ( | p, | |
| s ) {if(!isBigEndian) swap_byte((void*)(p),(s),sizeof(*(p)));} |
Definition at line 428 of file tools.h.
Referenced by write_ct_file().
| #define hton_data | ( | p, | |
| s, | |||
| c ) {if(!isBigEndian) swap_byte((void*)(p),(s),(c));} |
| #define hton_st | ( | p, | |
| s ) {if(!isBigEndian) swap_byte((void*)(p),sizeof(*(p)),(s));} |
Definition at line 426 of file tools.h.
Referenced by write_cmn_file(), write_ct_file(), and write_ras_file_obit().
| #define init_mstream | ( | ) | init_ringBuffer() |
| #define int_swap | ( | p, | |
| s ) {int swap=(p); (p)=(s); (s)=swap;} |
| #define isBigEndian (is_big_endian()) |
| #define isLittleEndian (is_little_endian()) |
| #define JBXL_ERR_FILE "/var/log/jbxl.err" |
Definition at line 444 of file tools.h.
Referenced by open_errfile(), and print_errfile().
| #define JBXL_LOG_FILE "/var/log/jbxl.log" |
Definition at line 443 of file tools.h.
Referenced by open_logfile(), and print_logfile().
| #define LITTLE_ENDIAN 1234 |
Definition at line 91 of file tools.h.
Referenced by double_from_big_endian(), float_from_big_endian(), int_from_big_endian(), is_big_endian(), is_little_endian(), short_from_big_endian(), uint_from_big_endian(), and ushort_from_big_endian().
| #define LOCAL_IPADDR LOCAL_IPv4 |
| #define LOCAL_IPADDR6 LOCAL_IPv6 |
| #define make_mstream | ( | s | ) | make_ringBuffer((s)) |
Definition at line 385 of file tools.h.
Referenced by fgets_mstream(), ssl_recv_mstream(), ssl_recv_mstream_Buffer(), ssl_tcp_recv_mstream(), ssl_tcp_recv_mstream_Buffer(), tcp_recv_mstream(), and tcp_recv_mstream_Buffer().
| #define mstream ringBuffer |
| #define new_mstream | ( | s | ) | new_ringBuffer((s)) |
| #define ntoh_ar | ( | p, | |
| s ) {if(!isBigEndian) swap_byte((void*)(p),(s),sizeof(*(p)));} |
Definition at line 427 of file tools.h.
Referenced by read_xxx_file().
| #define ntoh_data | ( | p, | |
| s, | |||
| c ) {if(!isBigEndian) swap_byte((void*)(p),(s),(c));} |
| #define ntoh_st | ( | p, | |
| s ) {if(!isBigEndian) swap_byte((void*)(p),sizeof(*(p)),(s));} |
Definition at line 425 of file tools.h.
Referenced by read_cmn_file(), read_cmn_header(), read_ct_data(), read_ras_data(), read_ras_file(), and read_xxx_file().
| #define pack_char | ( | s, | |
| c ) pack_char_len((s), (c), -1) |
Definition at line 236 of file tools.h.
Referenced by bvh_get_seq_data(), get_smtp_rcpt(), get_tList_line_Buffer(), get_tList_seq_data_Buffer(), is_smtp_onecommand(), pack_Buffer(), and read_tList_fp().
| #define PRINT_ERROR print_message |
| #define PRINT_ESC print_escape |
| #define PRINT_INFO print_message |
| #define PRINT_MESG print_message |
Definition at line 475 of file tools.h.
Referenced by check_auth(), chk_RZxy(), command_CRYPT(), command_KEYEX(), command_PASSWD(), command_USERID(), del_delete_node_tTree(), del_non_keep_node_tTree(), extract_tTar(), gz_decode_data(), gz_decode_fp(), llsd_bin_get_block_data(), llsd_bin_get_length(), llsd_bin_get_skin_weight(), llsd_bin_main_parse(), open_ldap_connection(), print_escape(), print_protocol_header(), proc_tiff_ifd(), read_dicom_file(), read_jp2k_data(), read_shape_index_file(), read_shape_main_file(), recv_http_file(), send_command_recv_ans(), setup_jp2k(), start_CRYPT_transfer(), and trap_segmentation_falt().
| #define PRINT_WARN print_message |
| #define random_str | ( | n | ) | temp_filename(NULL, (n)) |
Definition at line 351 of file tools.h.
Referenced by make_Buffer_randomstr().
| #define set_sigseg_handler | ( | h | ) | set_sigsegv_handler((h)) |
| #define STR_CRNT_DIR "./" |
Definition at line 104 of file tools.h.
Referenced by relative_path_Buffer().
| #define STR_DELI_DIR "/" |
Definition at line 103 of file tools.h.
Referenced by relative_path_Buffer().
| #define STR_UPST_DIR "../" |
Definition at line 105 of file tools.h.
Referenced by relative_path_Buffer().
| #define UNKNOWN_ENDIAN 0 |
Definition at line 88 of file tools.h.
Referenced by check_endian(), double_from_big_endian(), double_from_little_endian(), float_from_big_endian(), float_from_little_endian(), int_from_big_endian(), int_from_little_endian(), short_from_big_endian(), short_from_little_endian(), uint_from_big_endian(), uint_from_little_endian(), ushort_from_big_endian(), and ushort_from_little_endian().
| char * awk | ( | char * | buf, |
| char | cc, | ||
| int | n ) |
char* awk(char* buf, char cc, int n)
ccを区切り記号として, strのバッファ内の n番目の項目を返す. 返されたデータは free()する必要がある.
| buf | 操作対象文字列. |
| cc | 区切り文字. |
| n | 項目の指定. 1から数える. |
Definition at line 567 of file tools.c.
References buf.
Referenced by awk_tList(), decode_mime_rfc2047(), decode_mime_rfc2231(), get_smtp_rcpt(), is_smtp_onecommand(), to_address_num(), to_address_num4(), to_address_num8(), and to_ipaddress_list().

| int bincmp | ( | unsigned char * | b1, |
| unsigned char * | b2, | ||
| int | n ) |
int bincmp(unsigned char* b1, unsigned char* b2, int n)
バイナリデータ s1と s2 nバイト比較する.
| b1 | 比較するバイナリデータ1 |
| b2 | 比較するバイナリデータ2 |
| n | 比較するバイト数 |
| 0 | 一致する |
| 1 | 一致しない |
Definition at line 650 of file tools.c.
| char * cawk | ( | char * | buf, |
| char | cc, | ||
| int | n ) |
char* cawk(char* buf, char cc, int n)
ccを区切り記号として, strのバッファ内の n番目の項目を返す.
n は 1から数える.連続する cc(区切り)は一つの区切りとみなす. 返されたデータは free()する必要がある.
| buf | 操作対象文字列. |
| cc | 区切り文字. |
| n | 項目の指定. |
Definition at line 609 of file tools.c.
References buf.
Referenced by cawk_tList().

| char * change_esc | ( | char * | mesg | ) |
char* change_esc(char* mesg)
文字列中の CR, LF を \r, \n に変換する. 返されたデータは free()する必要がある.
| mesg | 操作対象の文字列 |
Definition at line 1210 of file tools.c.
References CHAR_CR, and CHAR_LF.
Referenced by fprint_escape(), and print_escape().

| void check_endian | ( | void | ) |
void check_endian(void)
大域変数 HostEndian に LITTLE_ENDIAN か BIG_ENDIAN を設定する.
Definition at line 143 of file tools.c.
References HostEndian, is_little_endian(), and UNKNOWN_ENDIAN.
Referenced by double_from_big_endian(), double_from_little_endian(), float_from_big_endian(), float_from_little_endian(), int_from_big_endian(), int_from_little_endian(), short_from_big_endian(), short_from_little_endian(), uint_from_big_endian(), uint_from_little_endian(), ushort_from_big_endian(), and ushort_from_little_endian().


| char * chomp | ( | char * | buf | ) |
char* chomp(char* buf)
最初の改行コード以降を無視する.最初の改行コードのある場所に '\0' を代入する.
| [in,out] | buf | 改行を無効にする文字列. |
Definition at line 921 of file tools.c.
References buf, CHAR_CR, CHAR_LF, and len.
Referenced by get_mstream().

| void clear_ringBuffer | ( | ringBuffer * | rb | ) |
void clear_ringBuffer(ringBuffer* rb)
リングバッファ rb のデータをクリア(初期化)する.
| rb | リングバッファへのポインタ |
Definition at line 3312 of file tools.c.
References ringBuffer::buf, ringBuffer::bufsz, JBXL_NORMAL, and ringBuffer::state.
| void close_errfile | ( | void | ) |
void close_errfile(void)
デフォルトのエラーファイルをクローズする
Definition at line 3990 of file tools.c.
References FP_ErrFile.
| void close_logfile | ( | void | ) |
void close_logfile(void)
デフォルトのログファイルをクローズする
Definition at line 3915 of file tools.c.
References FP_LogFile.
| int count_lines | ( | const char * | buf | ) |
int count_lines(const char* buf)
文字列データ bufの行数を数える. 行頭が '\0' であっても 1行と数える
| buf | 行数を数える文字列データ |
Definition at line 1673 of file tools.c.
References buf, CHAR_CR, CHAR_LF, and line().

| char * cut_file_extension | ( | const char * | str | ) |
char* cut_file_extension(const char* str)
拡張子を削除したパス名を生成する.strは変化しない.要 free.
| str | ファイルのフルパス |
Definition at line 2282 of file tools.c.
References len.
| char * cut_str | ( | char * | buf, |
| int | ls, | ||
| int | le ) |
char* cut_str(char* buf, int ls, int le)
buf[ls] 〜 buf[le] を切り出してメモリに格納して返す. 返されたデータは free()する必要がある.
| buf | 操作対象の文字列 |
| ls | 切り出し開始の位置 |
| le | 切り出し終了の位置 |
Definition at line 1338 of file tools.c.
References buf, len, Max, and Min.
Referenced by check_passwd(), command_USERID(), and x2crypt().

| unsigned char * decode_base64 | ( | unsigned char * | buf, |
| int * | sz ) |
unsigned char* decode_base64(unsigned char* buf, int* sz)
bufを base64からデコードする.
変換は bufの先頭から順次行われる.A-Za-z0-9+/ 以外は無視する(例えば改行コード).
入力バッファ部が 4byte(6bit*4)の場合, 出力バッファ部は 3byte(8bit*3)となる. 入力バッファ部のバイト数が 4の倍数でない場合(不正なデータ), 足りない入力バッファ部には '='が挿入されているものとみなす.
返されたデータは free()する必要がある.
| buf | base64からデコードする文字列. | |
| [in,out] | sz | in: sz デコードされたデータの長さを格納する intへのポインタ.NULLでも良い. out: デコードされたデータのサイズ. |
Definition at line 2786 of file tools.c.
References buf, len, and setBit.
Referenced by decode_base64_Buffer(), decode_base64_filename(), and decode_mime_rfc2047().

| unsigned char * decode_base64_filename | ( | unsigned char * | buf, |
| int * | sz, | ||
| unsigned char | cc ) |
unsigned char* decode_base64_filename(unsigned char* buf, int* sz, unsigned char cc)
bufを Base64で decodeしてバイナリデータを取り出す.ただし cc は '/' として扱う.
Definition at line 2887 of file tools.c.
References buf, decode_base64(), and len.

| unsigned char decode_hex | ( | unsigned char | pp1, |
| unsigned char | pp2 ) |
unsigned char decode_hex(unsigned char pp1, unsigned char pp2)
16進コードをキャラクタに変換する.O-9,A-F以外が指定された場合は0とみなす.
| pp1 | 16進コードの上位4Bit. 0-9,A-F |
| pp2 | 16進コードの下位4Bit. 0-9,A-F |
Definition at line 3171 of file tools.c.
Referenced by decode_quoted_printable(), and decode_urlenc().

| unsigned char * decode_quoted_printable | ( | unsigned char * | buf, |
| int * | sz ) |
unsigned char* decode_quoted_printable(unsigned char* buf, int* sz)
buf を quoted printableからデコードする. 返されたデータは free()する必要がある.
| buf | デコードする文字列. | |
| [out] | sz | デコードされたデータの長さを格納する変数. |
Definition at line 3029 of file tools.c.
References buf, decode_hex(), and len.
Referenced by decode_mime_rfc2047().


| unsigned char * decode_urlenc | ( | unsigned char * | buf, |
| int * | sz ) |
unsigned char* decode_urlenc(unsigned char* buf, int* sz)
buf を URLエンコードからデコードする. 返されたデータは free()する必要がある.
| buf | デコードする文字列. | |
| [out] | sz | デコードされたデータの長さを格納する変数. |
Definition at line 2932 of file tools.c.
References buf, decode_hex(), and len.
Referenced by decode_mime_rfc2231().


| char * del_file_extension | ( | const char * | str | ) |
char* del_file_extension(const char* str)
フルパスから拡張子を削除する. strの中身を書き換えて,strを返す.free() してはいけない.
| str | ファイルのフルパス |
Definition at line 2256 of file tools.c.
References len.
| char * del_file_name | ( | const char * | str | ) |
char* del_file_name(const char* str)
フルパスからファイル名を削除する. strの中身を書き換えて,strを返す.free() してはいけない.
| str | ファイルのフルパス |
Definition at line 2094 of file tools.c.
References len.
| void del_ringBuffer | ( | ringBuffer ** | rb | ) |
void del_ringBuffer(ringBuffer** rb)
new_ringBuffer()で作り出したリングバッファを削除する.
| [in,out] | rb | in: 削除するリングバッファポインタへのポインタ. out: *rb はNULLになる. |
Definition at line 3232 of file tools.c.
References freeNull.
| char * double_bs | ( | char * | str | ) |
char* double_bs(char* str)
文字列中の バックスペース \を 2重 \\ に変えた文字列を返す. 返されたデータは free()する必要がある.
| str | 操作対象の文字列 |
| double double_from_big_endian | ( | void * | ptr | ) |
double double_from_big_endian(void* ptr)
Big Endian形式で格納されている double型の値を取り出す.
| ptr | 変数が格納されているメモリへのポインタ |
Definition at line 264 of file tools.c.
References check_endian(), HostEndian, LITTLE_ENDIAN, reverse_str(), and UNKNOWN_ENDIAN.

| double double_from_little_endian | ( | void * | ptr | ) |
double double_from_little_endian(void* ptr)
Little Endian形式で格納されている double型の値を取り出す.
| ptr | 変数が格納されているメモリへのポインタ |
Definition at line 156 of file tools.c.
References BIG_ENDIAN, check_endian(), HostEndian, reverse_str(), and UNKNOWN_ENDIAN.
Referenced by draw_shape_polygon(), and read_shape_main_file().


| char * dtostr | ( | double | n | ) |
char* dtostr(double n)
double型 nを文字列にして返す.
| n | 文字列に変換する値 |
Definition at line 1516 of file tools.c.
| char * dtostr_ts | ( | double | n | ) |
char* dtostr_ts(double n)
double型 nを文字列にして返す. Thread Safe
| n | 文字列に変換する値 |
Definition at line 1652 of file tools.c.
References LDATA.
Referenced by llsd_bin_main_parse(), and make_xml_attr_bydouble().

| char * dup_str | ( | char * | buf | ) |
char* dup_str(char* buf)
文字列 bufの複製を作り出す.返されたデータは free()する必要がある.
| buf | コピー元の文字列 |
Definition at line 1368 of file tools.c.
Referenced by get_string_from_json().

| unsigned char * encode_base64 | ( | unsigned char * | buf, |
| int | sz ) |
unsigned char* encode_base64(unsigned char* buf, int sz)
バイナリデータ bufを base64にエンコードする.
入力バッファ部が 3byte(8bit*3)の場合, 出力バッファ部は 4byte(6bit*4)となる. 入力バッファ部が 6bit境界でない場合, 6bit境界 まで 0が付加されたと見される.
出力バッファ部が 4byte境界でない場合, 4byte境界まで '='を付加して出力する. また,出力バッファ部での 60byte毎の改行は行わない.
一般に n byte 入力された場合, base64の出力の文字数は (n+2)/3*4 byte となる.
返されたデータは free()する必要がある.
| buf | base64にエンコードするデータ. |
| sz | データの長さを示す.-1以下の場合は buf は文字列とみなす. |
Definition at line 2848 of file tools.c.
References buf, getBit, len, and setBit.
Referenced by encode_base64_Buffer(), encode_base64_Buffer_bin(), encode_base64_filename(), encode_mime_string(), and temp_filename().

| unsigned char * encode_base64_filename | ( | unsigned char * | buf, |
| int | sz, | ||
| unsigned char | cc ) |
unsigned char* encode_base64_filename(unsigned char* buf, int sz, unsiged char cc)
バイナリデータ bufを Base64で encodeしてファイル名を作る.ただし '/' は cc として扱う.
Definition at line 2907 of file tools.c.
References buf, encode_base64(), and len.

| unsigned char * encode_hex | ( | unsigned char | cc | ) |
unsigned char* encode_hex(unsigned char cc)
キャラクタを16進コードの文字列に変換する. 返されたデータは free()する必要がある.
| cc | 変換するキャラクタ. |
| NULL | メモリ不足. |
Definition at line 3138 of file tools.c.
Referenced by encode_quoted_printable(), and encode_urlenc().

| unsigned char * encode_quoted_printable | ( | unsigned char * | buf, |
| int | sz ) |
unsigned char* encode_quoted_printable(unsigned char* buf, int sz)
バイナリデータ bufを quoted printable にエンコードする.
RFC2047 に従い,' ' は '_' にエンコードする.
エンコードしない文字 '=', '_' 以外の 0x21-0x7e
エンコードする文字 '=', '_', 0x00-0x20, 0x7f-0xff
返されたデータは free()する必要がある.
| buf | エンコードするデータ. |
| sz | エンコードするデータの長さ.-1以下の場合は buf は文字列とみなす. |
Definition at line 3074 of file tools.c.
References buf, encode_hex(), and len.
Referenced by encode_mime_string().


| unsigned char * encode_urlenc | ( | unsigned char * | buf, |
| int | sz ) |
unsigned char* encode_urlenc(unsigned char* buf, int sz)
バイナリデータ bufを URLエンコードする.
エンコードしない文字については色々な考え方があるが,最大公約数的に考えてこのプログラムでは以下のようにする.
エンコードしない文字 0-9, A-Z, a-z, -._
返されたデータは free()する必要がある.
| buf | エンコードするデータ. |
| sz | エンコードするデータの長さ.-1以下の場合は buf は文字列とみなす. |
Definition at line 2979 of file tools.c.
References buf, encode_hex(), and len.
Referenced by add_form_urlenc(), encode_mime_string(), and make_form_urlenc().


| void euc2sjis | ( | unsigned char * | c1, |
| unsigned char * | c2 ) |
void euc2sjis(unsigned char *c1, unsigned char *c2)
漢字コード変換.EUC → SJIS
| [in,out] | c1 | 変換する文字の第一バイト.内容が書き換えられる. |
| [in,out] | c2 | 変換する文字の第二バイト.内容が書き換えられる. |
Definition at line 2687 of file tools.c.
Referenced by kanji_convert_Buffer(), and kanji_convert_euc2sjis().

| int ex_strncasecmp | ( | const char * | dat, |
| const char * | key, | ||
| int | len ) |
int ex_strncasecmp(const char* dat, const char* key, int len)
拡張文字比較.ケース無視.
| dat | 比べる文字列1. |
| key | 比べる文字列2. |
| len | 1以上 一致させる長さ. |
| len | 0 完全一致. |
| len | -1 dat の長さに合わせる. |
| len | -2 key の長さに合わせる. |
| TRUE | 一致した |
| FALSE | 一致しなかった |
Definition at line 820 of file tools.c.
References FALSE, len, and TRUE.
Referenced by _next_strncasecmp_horizon_tTree(), _next_strncasecmp_vertical_tTree(), del_tList_key(), get_xml_attr_node(), strncasecmp_back_tList(), strncasecmp_tList(), and strncasecmp_tTree().

| int ex_strncaservscmp | ( | const char * | dat, |
| const char * | key, | ||
| int | len ) |
int ex_strncaervscmp(const char* dat, const char* key, int len)
拡張文字比較.後ろから比べる.ケース無視.
| dat | 比べる文字列1. |
| key | 比べる文字列2. |
| len | 1以上 一致させる長さ. |
| len | 0 完全一致. |
| len | -1 dat の長さに合わせる. |
| len | -2 key の長さに合わせる. |
| TRUE | 一致した |
| FALSE | 一致しなかった |
Definition at line 892 of file tools.c.
References FALSE, len, strncaservscmp(), and TRUE.
Referenced by strncaservscmp_back_tList(), and strncaservscmp_tList().


| int ex_strncmp | ( | const char * | dat, |
| const char * | key, | ||
| int | len ) |
int ex_strncmp(const char* dat, const char* key, int len)
拡張文字比較
| dat | 比べる文字列1. |
| key | 比べる文字列2. |
| len | 1以上 一致させる長さ. |
| len | 0 完全一致. |
| len | -1 dat の長さに合わせる. |
| len | -2 key の長さに合わせる. |
| TRUE | 一致した |
| FALSE | 一致しなかった |
Definition at line 784 of file tools.c.
References FALSE, len, and TRUE.
Referenced by _next_strncmp_horizon_tTree(), _next_strncmp_vertical_tTree(), replace_all_tTree_node(), strncmp_back_tList(), strncmp_tList(), and strncmp_tTree().

| int ex_strnrvscmp | ( | const char * | dat, |
| const char * | key, | ||
| int | len ) |
int ex_strnrvscmp(const char* dat, const char* key, int len)
拡張文字比較.後ろから比べる.
| dat | 比べる文字列1. |
| key | 比べる文字列2. |
| len | 1以上 一致させる長さ. |
| len | 0 完全一致. |
| len | -1 dat の長さに合わせる. |
| len | -2 key の長さに合わせる. |
| TRUE | 一致した |
| FALSE | 一致しなかった |
Definition at line 856 of file tools.c.
References FALSE, len, strnrvscmp(), and TRUE.
Referenced by strnrvscmp_back_tList(), and strnrvscmp_tList().


| void fdump | ( | FILE * | fp, |
| unsigned char * | mesg, | ||
| int | n ) |
void fdump(FILE* fp, unsigned char* mesg, int n)
デバッグ用 16進ダンプ出力.
mesgの nバイトを16進表示する.n<0 の場合は 文字列とみなす.
| fp | 出力するファイルへのポインタ.NULLの場合は stderr |
| mesg | 表示するデータ. |
| n | 表示するバイト数 |
Definition at line 4176 of file tools.c.
References len.
Referenced by dump_http_header(), and dump_tList().

| unsigned char * fgets_mstream | ( | unsigned char * | mesg, |
| mstream * | sb ) |
unsigned char* fgets_mstream(unsigned char* mesg, mstream* sb)
メッセージストリームからメッセージを一行だけ取り出す.
メッセージ mesg はメッセージストリームに一旦バッファリングされ,この関数により一行ずつ読み出される.
結果が返される時,行中の改行コードは削除され,行末には必ず \0 が入る.
メッセージストリームのバッファ部が確保されていない場合は,最初に呼び出された時点で確保される.
一旦この関数を使用して,受信データをバッファリングしたら,最後まで読み取りには必ず同じストリームを使用して
この関数を呼び出さばければならない.そうで無い場合は受信データの整合性は保証されない.
| mesg | バッファに一旦格納されるメッセージ.NULLでも可. | |
| [in] | sb | ストリームバッファ(リングバッファ型のストリームバッファ). |
| [out] | sb | sb->buf バッファ部が確保さえていなければ,自動的に確保される. |
| [out] | sb | sb->state JBXL_ERROR: メッセージストリーム操作中は異常な状態にある. |
| [out] | sb | sb->state JBXL_NODATA: メッセージストリーム中に有効なデータがない.return は NULL |
Definition at line 3591 of file tools.c.
References get_mstream(), JBXL_NODATA, JBXL_NORMAL, make_mstream, put_mstream(), and RECVBUFSZ.
Referenced by fgets_mstream_Buffer().


| FILE * file_chmod_open | ( | const char * | fn, |
| const char * | fm, | ||
| mode_t | mode ) |
FILE* file_chmod_open(const char* fn, const char* fm, mode_t mode)
指定したファイルが存在して読み込み可能であれば,属性をmode へ変更した後,ファイルを fmモードでオープンしなおして,ファイルポインタを返す.
存在しなければ,ファイルを作成して属性を変更し,その後,ファイルを fmモードでオープンしなおして, ファイルポインタを返す.
属性の指定方法については man 2 chmod を参照すること.
| fn | ファイル名 |
| fm | ファイルモード,"r","w","a"..... |
| mode | 属性.see... man 2 chmod |
| NULL以外 | オープンしたファイルポインタ |
| NULL | 失敗. |
Definition at line 2366 of file tools.c.
References file_exist().
Referenced by check_server_spki().


| int file_exist | ( | const char * | fn | ) |
int file_exist(const char* fn)
指定したファイルが存在して読み込み可能であれば「真」をそうでなければ「偽」を返す.
ファイルを一度オープンして確認するので,時間が掛かる. 読み込み可能なファイルを確認するのであれば,file_size()の方が(たぶん)早い.
| fn | ファイル名 |
| TRUE | ファイルが存在し,読みこみ可能. |
| FALSE | ファイルが存在しないか,または読みこみ不可能. |
Definition at line 2337 of file tools.c.
Referenced by file_chmod_open(), sql_open(), and temp_filename().

| int file_from_to | ( | const char * | src, |
| const char * | dst, | ||
| const char * | mode ) |
int file_from_to(const char* src, const char* dst, const char* mode)
modeに従って,ファイル srcを dstにコピーする.
| src | コピー元(ソース)ファイル名 |
| dst | コピー先(ディスティネーション)ファイル名 |
| mode | コピー先ファイルのオープンモード.fopenに同じ."r", "w", "a", "r+", "w+", "a+", .... |
| 0以上 | コピーしたサイズ |
| JBXL_MALLOC_ERROR | 作業用メモリが足りない. |
| JBXL_FILE_EXIST_ERROR | ソースファイルが存在しない.(シンボリックリンクも×) |
| JBXL_FILE_OPEN_ERROR | ソースファイルのオープン失敗 |
| JBXL_FILE_DESTOPEN_ERROR | ディスティネーションファイルのオープン失敗 |
Definition at line 1985 of file tools.c.
References buf, file_size(), JBXL_FILE_DESTOPEN_ERROR, JBXL_FILE_EXIST_ERROR, JBXL_FILE_OPEN_ERROR, JBXL_MALLOC_ERROR, and UNUSED.

| long unsigned file_size | ( | const char * | fn | ) |
unsigned long int file_size(const char* fn)
通常のファイルの大きさを返す.シンボリックリンクなどは 0.
| fn | ファイル名 |
Definition at line 2309 of file tools.c.
Referenced by file_from_to(), read_Buffer_file(), read_cmn_file(), read_cmn_header(), read_dicom_file(), read_file(), read_xxx_file(), send_http_file(), and send_http_res_file().

| float float_from_big_endian | ( | void * | ptr | ) |
float float_from_big_endian(void* ptr)
Big Endian形式で格納されている float型の値を取り出す.
| ptr | 変数が格納されているメモリへのポインタ |
Definition at line 282 of file tools.c.
References check_endian(), HostEndian, LITTLE_ENDIAN, reverse_str(), and UNKNOWN_ENDIAN.

| float float_from_little_endian | ( | void * | ptr | ) |
float float_from_little_endian(void* ptr)
Little Endian形式で格納されている float型の値を取り出す.
| ptr | 変数が格納されているメモリへのポインタ |
Definition at line 174 of file tools.c.
References BIG_ENDIAN, check_endian(), HostEndian, reverse_str(), and UNKNOWN_ENDIAN.

| int fp_from_to | ( | FILE * | src, |
| FILE * | dst, | ||
| long int | sz ) |
int fp_from_to(FILE* src, FILE* dst, long int sz)
ファイル srcを dstにコピーする.
| src | コピー元(ソース)のファイルポインタ |
| dst | コピー先(ディスティネーション)のファイルポインタ |
| sz | コピー元(ソース)のサイズ |
| 0以上 | コピーしたサイズ |
| JBXL_MALLOC_ERROR | 作業用メモリが足りない. |
| JBXL_ARGS_ERROR | ファイルサイズの指定がおかしい. |
| JBXL_FILE_OPEN_ERROR | ソースファイルのオープン失敗. |
| JBXL_FILE_DESTOPEN_ERROR | ディスティネーションファイルのオープン失敗. |
Definition at line 2035 of file tools.c.
References buf, JBXL_ARGS_ERROR, JBXL_FILE_DESTOPEN_ERROR, JBXL_FILE_OPEN_ERROR, JBXL_MALLOC_ERROR, and UNUSED.
| void fprint_message | ( | FILE * | fp, |
| const char * | fmt, | ||
| ... ) |
void fprint_message(FILE fp, const char fmt, ...)
バッファリング無しのメッセージ出力
| fp | 出力先のファイルポインタ |
| fmt | 出力フォーマット.printf() に準拠. |
Definition at line 4088 of file tools.c.
References len.
Referenced by fprint_escape().

| void free_ringBuffer | ( | ringBuffer * | rb | ) |
void free_ringBuffer(ringBuffer* rb)
リングバッファのバッファ部を開放する.
| rb | リングバッファへのポインタ |
Definition at line 3295 of file tools.c.
References ringBuffer::buf, freeNull, JBXL_NORMAL, and ringBuffer::state.
| char * ftostr | ( | float | n | ) |
| char * ftostr_ts | ( | float | n | ) |
char* ftostr_ts(float n)
float型 nを文字列にして返す. Thread Safe
| n | 文字列に変換する値 |
Definition at line 1632 of file tools.c.
References LDATA.
Referenced by make_xml_attr_byfloat().

| char * get_file_extension | ( | const char * | str | ) |
char* get_file_extension(const char* str)
フルパスからファイル名の拡張子へのポインタを取り出す.
| str | ファイルのフルパス |
Definition at line 2225 of file tools.c.
References len.
Referenced by add_resource_list().

| char * get_file_name | ( | const char * | str | ) |
char* get_file_name(const char* str)
フルパスからファイル名へのポインタを取り出す. str中のポインタを返すので,free() してはいけない.
| str | ファイルのフルパス |
Definition at line 2066 of file tools.c.
References len.
Referenced by add_resource_list().

| char * get_file_path | ( | const char * | str | ) |
char* make_file_path(const char* str)
フルパスからパスを生成する.strは変化しない.要 free.
非推奨:get_file_path() を使え.
| str | ファイルのフルパス |
ファイルパスからパス部分のみを得る.strは変化しない.要 free.
| str | ファイルのパス |
Definition at line 2191 of file tools.c.
References len.
| long unsigned int get_free_memory | ( | void | ) |
unsigned long int get_free_memory(void)
未使用のメモリサイズを得る.
Definition at line 3718 of file tools.c.
| char * get_gmt_timestamp | ( | time_t | date, |
| const char * | format ) |
| char * get_graphic_extension | ( | uWord | tex | ) |
Definition at line 4250 of file tools.c.
References _GraphicFileExtension, JBXL_TEXTURE_JP2K, JBXL_TEXTURE_JPEG, JBXL_TEXTURE_PNG, JBXL_TEXTURE_RAS, JBXL_TEXTURE_TGA, JBXL_TEXTURE_TIFF, and L_OCT.
| char * get_line | ( | char * | buf, |
| int | n ) |
char* get_line(char* buf, int n)
文字型データstrのバッファ内の n行目を取り出す.改行コードは削除される.
取り出した行を char型変数のバッファに格納して返す.
バッファの最後が '\0' で終わっている場合,バッファを越えて行を読もうとした場合は NULL を返す.
'\0' で終わっていない場合,バッファが何処で終わりかを知る事は(簡単な方法では)できない.
返されたデータは free()する必要がある.
| buf | 操作対象文の字列型データ(含む改行) |
| n | 行の指定.1 から数える. |
Definition at line 484 of file tools.c.
References buf, CHAR_CR, and CHAR_LF.
Referenced by command_PASSWD(), and x2crypt().

| char * get_local_timestamp | ( | time_t | date, |
| const char * | format ) |
char* get_localtime(char c1, char c2, char c3, char c4)
非推奨.use get_local_timestamp(time(0), "%Y/%m/%dT%H:%M:%SZ")
ローカルタイムを "年c1月c1日c2時c3分c3秒c4" の形式で返す.
返ってきた char* ポインタは free() してはいけない.
char* get_localtime_ts(char c1, char c2, char c3, char c4)
非推奨.use get_local_timestamp(time(0), "%Y/%m/%dT%H:%M:%SZ")
ローカルタイムを "年c1月c1日c2時c3分c3秒c4" の形式で返す.
返ってきた char* ポインタは free() すること.
Definition at line 440 of file tools.c.
References buf.
| unsigned char * get_mstream | ( | mstream * | sb | ) |
unsigned char* get_mstream(mstream* sb)
メッセージ(文字列)ストリーム sb から次のメッセージを取り出す.改行コードは削除される.
ここで,メッセージとは \r\n, \r または \n で区切られている文字列でのことである.
| [in] | sb | メッセージストリームへのポインタ |
| [out] | sb | state JBXL_NORMAL: ストリームは正常状態.JBXL_ERROR: ストリームは異常な状態にある.(未実装) |
| NULL以外 | 取り出したストリームデータへのポインタ.要 free |
| NULL | データ取得失敗.現在有効なメッセージデータは無い.または単に失敗した. |
Definition at line 3531 of file tools.c.
References CHAR_CR, CHAR_LF, chomp(), get_ringBuffer(), JBXL_ERROR, JBXL_NORMAL, and len.
Referenced by fgets_mstream(), ssl_recv_mstream(), ssl_recv_mstream_Buffer(), ssl_tcp_recv_mstream(), ssl_tcp_recv_mstream_Buffer(), tcp_recv_mstream(), and tcp_recv_mstream_Buffer().


| unsigned char * get_ringBuffer | ( | ringBuffer * | rb, |
| int | sz ) |
unsigned char* get_ringBuffer(ringBuffer* rb, int sz)
リングバッファ rb から szバイトのデータを取り出す.
返されたデータは free()する必要がある.
| [in] | rb | リングバッファへのポインタ |
| [out] | rb | state JBXL_NORMAL: バッファは正常状態.JBXL_ERROR: バッファは異常な状態にある. |
| sz | 取り出すバイト数. |
| NULL以外 | 取り出したデータへのポインタ.データサイズは sz + 1.要 free |
| NULL | データ取得失敗.現在有効なデータサイズはszより小さい.または単に失敗した. |
Definition at line 3382 of file tools.c.
References ringBuffer::buf, ringBuffer::bufsz, ringBuffer::datasz, and ringBuffer::spoint.
Referenced by get_mstream().

| char * get_seq_data | ( | char * | buf, |
| int * | ptr ) |
char* get_seq_data(char* buf, int* ptr)
文字型データ bufのバッファ内の行データをシーケンシャルに取り出す.
改行コードは削除される.連続して呼び出す場合,一番最初は *ptrに 0を設定し,以後は *ptrの内容は変えない.
取り出した行を char型変数のバッファに格納して返す.
バッファの最後が '\0' で終わっている場合,バッファを越えて行を読もうとした時は NULL を返す.
'\0' で終わっていない場合,バッファが何処で終わりかを知る事は(簡単な方法では)できない.
返されたデータは free() する必要がある.
| [in] | buf | 操作対象文の字列型データ(含む改行) |
| [in] | ptr | 読み込みを開始するデータの位置(バイト). |
| [out] | ptr | 次のデータが始まる位置(バイト). |
Definition at line 529 of file tools.c.
| long unsigned int get_used_memory | ( | void | ) |
unsigned long int get_used_memory(void)
使用中のメモリサイズを得る.
Definition at line 3702 of file tools.c.
Referenced by memory_check(), and memory_check_start().

| unsigned char * guid2uuid | ( | unsigned char * | p | ) |
unsigned char* guid2uuid(unsigned char* p)
テキストのGUID をバイナリのUUID に変換する.要 free()
入力が GUIDの形式でない時は,処理結果は保証されない.
| p | テキストの GUID |
Definition at line 3654 of file tools.c.
| int hexstr2i | ( | const char * | str | ) |
16進数の文字列を整数に変換する.
空白は無視する.空白以外の16進数でない文字が出現したら,そこで変換を止める
| str | 整数に変換する 16進の文字列 |
Definition at line 1706 of file tools.c.
References len.
Referenced by get_chunked_size().

| void ignore_sigterm_child | ( | void | ) |
| void init_rand | ( | void | ) |
void init_rand(void)
/dev/urandom から乱数の系列を初期化する
/dev/urandom が読めない場合は,呼び出された時の時間(秒数)によって乱数の系列を初期化する.
Definition at line 1747 of file tools.c.
References UNUSED.
| ringBuffer init_ringBuffer | ( | void | ) |
初期化された ringBuffer変数を返す.
Definition at line 3250 of file tools.c.
References JBXL_NORMAL, and ringBuffer::state.
| int int_from_big_endian | ( | void * | ptr | ) |
int int_from_big_endian(void* ptr)
Big Endian形式で格納されている int型の値を取り出す.
| ptr | 変数が格納されているメモリへのポインタ |
Definition at line 300 of file tools.c.
References check_endian(), HostEndian, LITTLE_ENDIAN, reverse_str(), and UNKNOWN_ENDIAN.
Referenced by read_shape_index_file(), and read_shape_main_file().


| int int_from_little_endian | ( | void * | ptr | ) |
int int_from_little_endian(void* ptr)
Little Endian形式で格納されている int型の値を取り出す.
| ptr | 変数が格納されているメモリへのポインタ |
Definition at line 192 of file tools.c.
References BIG_ENDIAN, check_endian(), HostEndian, reverse_str(), and UNKNOWN_ENDIAN.
Referenced by draw_shape_polygon(), read_shape_index_file(), and read_shape_main_file().


| int is_big_endian | ( | void | ) |
エンディアンの動的チェック
一度呼び出すと,大域変数 HostEndian に LITTLE_ENDIAN か BIG_ENDIAN が設定される.
| TRUE | Big Endian |
| FALSE | Little Endian |
Definition at line 114 of file tools.c.
References BIG_ENDIAN, FALSE, HostEndian, LITTLE_ENDIAN, and TRUE.
Referenced by get_tiff_ifd().

| int is_little_endian | ( | void | ) |
エンディアンの動的チェック
一度呼び出すと,大域変数 HostEndian に LITTLE_ENDIAN か BIG_ENDIAN が設定される.
| TRUE | Little Endian |
| FALSE | Big Endian |
Definition at line 80 of file tools.c.
References BIG_ENDIAN, FALSE, HostEndian, LITTLE_ENDIAN, and TRUE.
Referenced by check_endian(), get_tiff_ifd(), ntohull(), and read_user_data().

| int is_number | ( | unsigned char * | str | ) |
int is_number(unsigned char* str)
文字列が数字かどうか反転する.
| 検査する文字列 |
Definition at line 1394 of file tools.c.
References len.
Referenced by json_array_parse(), and json_parse_prop().

| int isNull | ( | void * | p | ) |
int isNull(void* p)
ポインタが NULLかどうかを検査する.
Windowsの場合,無効ポインタも検出する.
| p | 検査するポインタ. |
| TRUE | ポインタがNULL,または無効(Windowsの場合) |
| FALSE | ポインタはNULLではなく有効(Windowsの場合)である. |
Definition at line 51 of file tools.c.
| char * itostr | ( | int | n | ) |
| char * itostr_ts | ( | int | n | ) |
char* itostr_ts(int n)
int型 nを文字列にして返す.Thread Safe
| n | 文字列に変換する値 |
Definition at line 1532 of file tools.c.
References LDATA.
Referenced by _tcp_bind(), _tcp_bind_setopt(), _tcp_client_bind_socket(), _tcp_client_socket(), _tcp_connect(), _tcp_server_bind(), _tcp_server_bind_setopt(), _tcp_server_socket(), _tcp_server_socket_setopt(), _udp_bind(), _udp_bind_setopt(), _udp_client_socket(), _udp_server_socket(), _udp_server_socket_setopt(), llsd_bin_main_parse(), make_xml_attr_byint(), open_ldap_connection(), recv_http_Buffer(), and recv_http_file().

| void kanji_convert | ( | unsigned char * | mesg | ) |
void kanji_convert(unsigned char* mesg)
大域変数 KnjiCodeに従って漢字コードを変換する.
| [in,out] | mesg | 変換する文字列を持つ unsigned char*型データ.内容が書き換えられる. |
Definition at line 2629 of file tools.c.
References CODE_SJIS, kanji_convert_euc2sjis(), and KanjiCode.

| void kanji_convert_euc2sjis | ( | unsigned char * | mesg | ) |
void kanji_convert_euc2sjis(unsigned char* mesg)
EUCをSJISに変換する.
| [in,out] | mesg | 変換する文字列を持つ unsigned char*型データ.内容が書き換えられる. |
Definition at line 2644 of file tools.c.
References euc2sjis().
Referenced by kanji_convert().


| void kanji_convert_sjis2euc | ( | unsigned char * | mesg | ) |
void kanji_convert_sjis2euc(unsigned char* mesg)
SJISをEUCに変換する.
| [in,out] | mesg | 変換する文字列を持つ unsigned char*型データ.内容が書き換えられる. |
Definition at line 2664 of file tools.c.
References sjis2euc().

| char * lltostr | ( | long long int | n | ) |
| char * lltostr_ts | ( | long long int | n | ) |
char* lltostr_ts(long long int n)
long long int型 nを文字列にして返す.Thread Safe
| n | 文字列に変換する値 |
Definition at line 1592 of file tools.c.
References LDATA.
| char * ltostr | ( | long int | n | ) |
| char * ltostr_ts | ( | long int | n | ) |
char* ltostr_ts(long int n)
long int型 nを文字列にして返す.Thread Safe
| n | 文字列に変換する値 |
Definition at line 1552 of file tools.c.
References LDATA.
| ringBuffer make_ringBuffer | ( | int | sz | ) |
ringBuffer make_ringBuffer(int sz)
バッファ部が存在するリングバッファを作り出す. バッファ部は free()する必要がある.
| sz | リングバッファのバッファ部のサイズ |
Definition at line 3270 of file tools.c.
References ringBuffer::buf, ringBuffer::bufsz, JBXL_NORMAL, and ringBuffer::state.
| long unsigned int memory_check | ( | void | ) |
Definition at line 3734 of file tools.c.
References get_used_memory(), and UsedMemoryBase.

| void memory_check_start | ( | void | ) |
Definition at line 3728 of file tools.c.
References get_used_memory(), and UsedMemoryBase.

| int mkdirp | ( | const char * | path, |
| mode_t | mode ) |
Definition at line 2511 of file tools.c.
References JBXL_ARGS_ERROR, JBXL_DIR_MAKE_ERROR, JBXL_FILE_EXIST_ERROR, and JBXL_NORMAL.
Referenced by extract_tTar().

| ringBuffer * new_ringBuffer | ( | int | sz | ) |
ringBuffer* new_ringBuffer(int sz)
リングバッファ型変数を生成する.
返されたデータは del_ringBuffer() する必要がある.
Definition at line 3204 of file tools.c.
References ringBuffer::buf, ringBuffer::bufsz, JBXL_NORMAL, and ringBuffer::state.
| long unsigned long int ntohull | ( | long unsigned long int | s | ) |
| char * numbering_name | ( | const char * | fmt, |
| int | n ) |
char* numbering_name(const char* fmt, int n)
フォーマット fmtに従って,nを含む文字列を作り出す. 返されたデータは free()する必要がある.
| fmt | フォーマット用文字列.ex. "%d %f\n" see printf() |
| n | 文字に変換する整数. |
| void open_errfile | ( | void | ) |
void open_errfile(void)
デフォルトのエラーファイルをオープンする
Definition at line 3976 of file tools.c.
References FP_ErrFile, FP_LogFile, and JBXL_ERR_FILE.
| void open_logfile | ( | void | ) |
void open_logfile(void)
デフォルトのログファイルをオープンする
Definition at line 3901 of file tools.c.
References FP_LogFile, and JBXL_LOG_FILE.
| char * pack_char_len | ( | char * | mesg, |
| char | cc, | ||
| int | len ) |
char* pack_char(char* mesg, char cc)
文字列中及び,先頭のcc(複数),終わりのcc(複数),CR, LF を削除
タブは空白に変換.メッセージ中の連続する cc は 1個に変換. 返されたデータは free()する必要がある.
CR, LF も削除(無視)されるので注意.
| mesg | 操作対象の文字列 |
| cc | 削除する文字 |
文字列の一部の先頭のcc(複数),終わりのcc(複数),CR, LF を削除
タブは空白に変換.メッセージ中の連続する cc は 1個に変換. 返されたデータは free()する必要がある.
CR, LF も削除(無視)されるので注意.
| mesg | 操作対象の文字列 |
| cc | 削除する文字 |
| len | 操作する文字列の長さ |
Definition at line 1154 of file tools.c.
| char * pack_head_tail_char | ( | char * | mesg, |
| char | cc ) |
char* pack_head_tail_char(char* mesg, char cc)
文字列の先頭のcc(複数),終わりのcc(複数),TAB, CR, LF を削除
文字列の先頭,終わり部分でない場所にある ccは削除されない. 返されたデータは free()する必要がある.
| mesg | 操作対象の文字列 |
| cc | 削除する文字 |
Definition at line 1092 of file tools.c.
References CHAR_CR, CHAR_LF, and CHAR_TAB.
Referenced by xml_parse_content(), and xml_parse_end_node().

| void print_16x | ( | FILE * | fp, |
| unsigned char * | mesg, | ||
| int | n ) |
void print_16x(FILE* fp, unsigned char* mesg, int n)
デバッグ用 16進一行出力.
mesgの nバイトの16進を一行,空白なしで表示する.n<0 の場合は 文字列とみなす.
| fp | 出力するファイルへのポインタ.NULLの場合は stderr |
| mesg | 表示するデータ. |
| n | 表示するバイト数 |
Definition at line 4227 of file tools.c.
References len.
| void print_errfile | ( | const char * | fmt, |
| ... ) |
void print_errfile(const char* fmt, ...)
デフォルトのエラーファイルにデータを書き込む
Definition at line 4006 of file tools.c.
References FALSE, FP_ErrFile, JBXL_ERR_FILE, len, and TRUE.
| void print_escape | ( | const char * | fmt, |
| char * | mesg ) |
void print_escape(const char* fmt, const char* mesg)
エスケープ文字を含むメッセージの出力.(stderr)
現在は CR, LF のみ \r, \n に変換する.see change_esc()
| fmt | 出力フォーマット.printf() に準拠. |
| mesg | エスケープ文字を含む文字列. |
Definition at line 4124 of file tools.c.
References change_esc(), and PRINT_MESG.

| void print_logfile | ( | const char * | fmt, |
| ... ) |
void print_logfile(const char* fmt, ...)
デフォルトのログファイルにデータを書き込む
Definition at line 3931 of file tools.c.
References FALSE, FP_LogFile, JBXL_LOG_FILE, len, and TRUE.
| void print_message | ( | const char * | fmt, |
| ... ) |
void print_message(const char* fmt, ...)
バッファリング無しのメッセージ出力(stderr)
| fmt | 出力フォーマット.printf() に準拠. |
Definition at line 4054 of file tools.c.
References len.
| int put_mstream | ( | mstream * | sb, |
| unsigned char * | mesg ) |
int put_mstream(mstream* sb, unsigned char* mesg)
メッセージ(文字列)ストリーム sb へメッセージ(の一部)を格納する.
ここで,メッセージとは \r\n, \r または \n で区切られている文字列でのことである.
| [in] | sb | メッセージストリームへのポインタ |
| [out] | sb | state JBXL_NORMAL: ストリームは正常状態.JBXL_ERROR: ストリームは異常な状態にある. |
| mesg | 格納するメッセージ,またはその一部 |
| 0以上 | 書き込んだバイト数(CRLFを含む) |
| JBXL_ARGS_ERROR | 引数にNULLのデータがある. |
| JBXL_TOOLS_BUF_ERROR | バッファ(データ格納)部の領域がない. |
| JBXL_TOOLS_BUFSZ_ERROR | バッファ(データ格納)部の大きさがたりない. |
Definition at line 3490 of file tools.c.
References CHAR_CR, CHAR_LF, JBXL_ARGS_ERROR, JBXL_ERROR, JBXL_NORMAL, JBXL_TOOLS_BUF_ERROR, len, and put_ringBuffer().
Referenced by fgets_mstream(), ssl_recv_mstream(), ssl_recv_mstream_Buffer(), ssl_tcp_recv_mstream(), ssl_tcp_recv_mstream_Buffer(), tcp_recv_mstream(), and tcp_recv_mstream_Buffer().


| int put_ringBuffer | ( | ringBuffer * | rb, |
| unsigned char * | pp, | ||
| int | sz ) |
int put_ringBuffer(ringBuffer* rb, unsigned char* pp, int sz)
リングバッファ rb へデータを szバイト格納する.
| [in] | rb | リングバッファへのポインタ |
| [out] | rb | state JBXL_NORMAL: バッファは正常状態.JBXL_ERROR: バッファは異常な状態にある. |
| pp | 格納するデータへのポインタ. | |
| sz | 格納するデータのサイズ(Byte) |
| 0以上 | 書き込んだバイト数. |
| JBXL_ARGS_ERROR | 引数にNULLのデータがある. |
| JBXL_TOOLS_BUF_ERROR | バッファ(データ格納)部の領域がない. |
| JBXL_TOOLS_BUFSZ_ERROR | バッファ(データ格納)部の大きさがたりない.データはputされなかった. |
Definition at line 3341 of file tools.c.
References ringBuffer::buf, ringBuffer::bufsz, ringBuffer::datasz, ringBuffer::epoint, JBXL_ARGS_ERROR, JBXL_ERROR, JBXL_NORMAL, JBXL_TOOLS_BUF_ERROR, JBXL_TOOLS_BUFSZ_ERROR, and ringBuffer::state.
Referenced by put_mstream().

| unsigned char * randbit | ( | int | n | ) |
unsigned char* randbit(int n)
ランダムに n bitのバイナリを生成する. 返されたデータは free()する必要がある.
| n | 出力する bit数. |
Definition at line 1804 of file tools.c.
References setBit.
| char * randstr | ( | int | n | ) |
char* randstr(int n)
ランダムに A-Za-z0-9 までの文字を n文字生成する. 返されたデータは free()する必要がある.
| n | 出力する文字数. |
Definition at line 1777 of file tools.c.
Referenced by command_USERID(), and temp_filename().

| unsigned char * read_file | ( | const char * | fname, |
| long unsigned int * | size ) |
unsigned char* read_file(const char* fname, long unsigned int* size)
ファイルを読み込んで,データへのポインタを返す.
| fname | ファイル名 |
| size | 読み込んだデータのサイズを返す. |
Definition at line 2460 of file tools.c.
References buf, file_size(), and UNUSED.
Referenced by read_tiff_file().


| unsigned char * ref_ringBuffer | ( | ringBuffer * | rb, |
| int | pos ) |
unsigned char* ref_ringBuffer(ringBuffer* rb, int pos)
リングバッファ rb の spoint + pos の位置にあるデータへの参照.
| rb | リングバッファへのポインタ |
| pos | 参照するデータの spoint からの位置. |
| 参照データへのポインタ. |
Definition at line 3454 of file tools.c.
References ringBuffer::buf, ringBuffer::bufsz, ringBuffer::datasz, and ringBuffer::spoint.
| void replace_char | ( | unsigned char * | buf, |
| int | len, | ||
| unsigned char | frm, | ||
| unsigned char | toc ) |
void replace_char(unsigned char* buf, int len, unsigned char frm, unsigned char toc)
buf中の frm (char) を tosで置き換える.
| buf | 操作対象のデータ.バイナリも可. |
| len | bufの領域の大きさ(長さ)'\0'を含む.<= 0 の場合は buf を文字列として扱う. |
| frm | 変換するバイトデータ |
| tos | 変換後の倍とデータ |
Definition at line 1252 of file tools.c.
| char * replace_str | ( | char * | buf, |
| int | len, | ||
| const char * | frm, | ||
| const char * | tos ) |
char* replace_str(char* buf, int len, const char* frm, const char* tos)
buf中の文字列 frmを tosで置き換える.
bufには十分な領域がなければならない.frmは bufとメモリ領域が重なってはいけない.
失敗した場合は NULLを返し,bufの内容は変化しない.
| [in] | buf | 操作対象の文字列 |
| [out] | buf | 変換された文字列 |
| len | buf中の変換対象のbufの領域の大きさ(長さ) | |
| frm | 変換する文字列 | |
| tos | 変換後の文字列 |
Definition at line 1282 of file tools.c.
Referenced by bvh_get_seq_data().

| void reverse_str | ( | uByte * | p, |
| int | s ) |
void reverse_str(uByte* p, int s)
バイト列を逆順にする.
| [in,out] | p | バイトデータへのポインタ. |
| s | バイトデータの長さ. |
Definition at line 1952 of file tools.c.
Referenced by double_from_big_endian(), double_from_little_endian(), float_from_big_endian(), float_from_little_endian(), int_from_big_endian(), int_from_little_endian(), short_from_big_endian(), short_from_little_endian(), swap_byte(), uint_from_big_endian(), uint_from_little_endian(), ushort_from_big_endian(), and ushort_from_little_endian().

| int seek_ringBuffer | ( | ringBuffer * | rb, |
| int | sz ) |
int seek_ringBuffer(ringBuffer* rb, int sz)
リングバッファ rb の読み取り開始ポインタ spoint を sz 移動させる.
| rb | リングバッファへのポインタ |
| sz | 開始ポインタを移動させる量.負数(バック)も可. |
Definition at line 3423 of file tools.c.
References ringBuffer::buf, ringBuffer::bufsz, ringBuffer::datasz, FALSE, ringBuffer::spoint, and TRUE.
| void set_sigsegv_handler | ( | void(*)(int) | handler | ) |
void set_sigsegv_handler(void (*handler)(int))
セグメンテーションエラー時のハンドラを設定.
引数に NULLを指定した場合は,ハンドラ関数として trap_segmentation_falt() を使用.
| (*handler)() | セグメンテーションエラー時に呼び出される関数へのポインタ |
Definition at line 3828 of file tools.c.
References trap_segmentation_falt().

| void set_sigterm_child | ( | void(*)(int) | handler | ) |
void set_sigterm_child(void (*handler)(int))
child プロセス終了時の処理を設定.
| (*handler)() | チャイルドプロセス終了時に呼び出される関数へのポインタ@ NULL の場合は void sigterm_child(int signal) が設定される. |
Definition at line 3762 of file tools.c.
References sigterm_child().

| short short_from_big_endian | ( | void * | ptr | ) |
short short_from_big_endian(void* ptr)
Big Endian形式で格納されている short int型の値を取り出す.
| ptr | 変数が格納されているメモリへのポインタ |
Definition at line 336 of file tools.c.
References check_endian(), HostEndian, LITTLE_ENDIAN, reverse_str(), and UNKNOWN_ENDIAN.

| short short_from_little_endian | ( | void * | ptr | ) |
short short_from_little_endian(void* ptr)
Little Endian形式で格納されている short int型の値を取り出す.
| ptr | 変数が格納されているメモリへのポインタ |
Definition at line 228 of file tools.c.
References BIG_ENDIAN, check_endian(), HostEndian, reverse_str(), and UNKNOWN_ENDIAN.

| void sigterm_child | ( | int | signal | ) |
void sigterm_child(int signal)
child プロセス終了時の処理
| signal | ハンドラのシグナル番号.システムによって設定される. |
Definition at line 3786 of file tools.c.
References UNUSED.
Referenced by set_sigterm_child().

| void sjis2euc | ( | unsigned char * | c1, |
| unsigned char * | c2 ) |
void sjis2euc(unsigned char *c1, unsigned char *c2)
漢字コード変換.SJIS → EUC
| [in,out] | c1 | 変換する文字の第一バイト.内容が書き換えられる. |
| [in,out] | c2 | 変換する文字の第二バイト.内容が書き換えられる. |
Definition at line 2716 of file tools.c.
Referenced by kanji_convert_sjis2euc().

| char * skip_char | ( | char * | pp, |
| char | cc ) |
char* skip_char(char* pp, char cc)
文字列 pp の中で,次の cc までポインタをスキップさせる.
ただし," ", ' ' 内に該当文字があった場合,それらは無視される.
| pp | 文字列の先頭ポインタ |
| cc | スキップする文字を格納した文字列. |
Definition at line 985 of file tools.c.
| char * skip_char_pair | ( | char * | pp, |
| char | pair, | ||
| char | end ) |
char* skip_char_pair(char* pp, char pair, char end)
pair から始まって end で閉じるまで,ポインタをスキップさせる.ただし " " と ' ' 内は完全スキップ
pair と end は対になっている必要がある.
pp は pair の位置を指しているのが望ましい.指していなくても動くけど....
ペアの end がない場合は '\0' へのポインタを返す.
| pp | 操作対象の文字列 |
| pair | ペアとなる最初の文字 |
| end | ペアとなる最後の文字 |
Definition at line 1022 of file tools.c.
Referenced by json_array_parse(), and json_parse_prop().

| char * skip_chars | ( | char * | pp, |
| const char * | check ) |
char* skip_chars(char* pp, const char* check)
ppの指す文字列中で,check[]に格納されたいずれかの文字までポインタをスキップさせる.
ただし," ", ' ' 内に該当文字があった場合,それらは無視される.
| pp | 文字列の先頭ポインタ |
| check | スキップする文字を格納した文字列. |
Definition at line 948 of file tools.c.
Referenced by json_array_parse(), xml_parse_comment_node(), xml_parse_data_node(), xml_parse_end_node(), xml_parse_processing_node(), and xml_parse_start_node().

| char * skip_string_end | ( | char * | pp | ) |
char* skip_string_end(char* pp)
文字列の最後までポインタをスキップする.
ppの指す文字列 "〜" または '〜' の最後の クォーテーションへのポインタ
| pp | 文字列の先頭の クォーテーションへのポインタ |
Definition at line 1060 of file tools.c.
Referenced by json_parse_prop().

| int strncaservscmp | ( | const char * | s1, |
| const char * | s2, | ||
| int | n ) |
int strncaservscmp(const char* s1, const char* s2, int n)
文字列 s1と s2を後ろから n文字比較する.
| 0 | 一致する |
| 1 | 一致しない |
Definition at line 703 of file tools.c.
Referenced by ex_strncaservscmp().

| int strnrvscmp | ( | const char * | s1, |
| const char * | s2, | ||
| int | n ) |
int strnrvscmp(const char* s1, const char* s2, int n)
文字列 s1と s2を後ろから n文字比較する.
| 0 | 一致する |
| 1 | 一致しない |
Definition at line 674 of file tools.c.
Referenced by ex_strnrvscmp(), is_host_in_list(), and recv_mesg_until_end().

| char * strstrcase | ( | const char * | buf, |
| const char * | nd ) |
char* strstrcase(const char* buf, const char* nd)
文字列 bufの中に部分文字列 ndがあるかどうかをチェックする.大文字小文字を区別しない.
大文字小文字を区別しない点を除けば,strstr() と同じ.
つまり strcasestr() と同じ.標準で strcasestr()が存在しない場合に使用.
| buf | 検索対象の文字列 |
| nd | 検索する部分文字列 |
Definition at line 736 of file tools.c.
References buf, and upper_string().
Referenced by get_mime_enckind(), get_mime_filename(), get_sip_via_address(), insert_sip_record_route(), replace_sip_contact(), search_protocol_header_partvalue(), strstrcase_back_tList(), and strstrcase_tList().


| void swap_byte | ( | void * | p, |
| int | s, | ||
| int | c ) |
void swap_byte(void* p, int s, int c)
上位バイトと下位バイトを逆順にする.
pが指す長さ sのデータを cバイトづつ逆順にする.
| [in,out] | p | データへのポインタ. |
| s | データの長さ.バイト単位. | |
| c | 逆順にするデータの長さ.バイト単位. |
Definition at line 1854 of file tools.c.
References reverse_str().

| long long int swapd | ( | long unsigned long int | p | ) |
| int swapl | ( | unsigned int | p | ) |
int型 32bit pを8bitづつ逆順にする
ntohl(), htonl()の代替関数.Windows用.
| p | 入れ替える値 |
Definition at line 1896 of file tools.c.
Referenced by get_tiff_ifd(), and get_tiff_uint_field().

| short swaps | ( | unsigned short | p | ) |
short swaps(unsigned short p)
short型(16bit)pの上下8bitを入れ替える. ntohs(), htons()の代替関数.Windows用.
| p | 入れ替える値 |
Definition at line 1872 of file tools.c.
Referenced by get_tiff_ifd(), get_tiff_uint_field(), and read_user_data().

| char * temp_filename | ( | const char * | dir, |
| int | flen ) |
char* temp_filename(const char* dir, int flen)
/dev/urandom を利用して作業用ファイルのランダムなファイル名を得る.
/dev/urandom が読めない場合は randstr() を利用する. 返されたデータは free()する必要がある.
| dir | 作業ファイルを作るディレクトリ |
| flen | 生成するファイル名の長さ |
Definition at line 2397 of file tools.c.
References encode_base64(), file_exist(), randstr(), and UNUSED.
Referenced by gz_decode_file_replace(), and save_http_xml().


| void trap_segmentation_falt | ( | int | signal | ) |
void trap_segmentation_falt(int signal)
セグメンテーションエラー時にデフォルトで呼び出される関数.
| signal | ハンドラのシグナル番号.システムによって設定される. |
Definition at line 3849 of file tools.c.
References PRINT_MESG.
Referenced by set_sigsegv_handler().

| unsigned int uint_from_big_endian | ( | void * | ptr | ) |
unsigned int uint_from_big_endian(void* ptr)
Big Endian形式で格納されている unsigned int型の値を取り出す.
| ptr | 変数が格納されているメモリへのポインタ |
Definition at line 318 of file tools.c.
References check_endian(), HostEndian, LITTLE_ENDIAN, reverse_str(), and UNKNOWN_ENDIAN.

| unsigned int uint_from_little_endian | ( | void * | ptr | ) |
unsigned int uint_from_little_endian(void* ptr)
Little Endian形式で格納されている unsigned int型の値を取り出す.
| ptr | 変数が格納されているメモリへのポインタ |
Definition at line 210 of file tools.c.
References BIG_ENDIAN, check_endian(), HostEndian, reverse_str(), and UNKNOWN_ENDIAN.

| char * ulltostr | ( | long unsigned long int | n | ) |
| char * ulltostr_ts | ( | long unsigned long int | n | ) |
| char * ultostr | ( | long unsigned int | n | ) |
| char * ultostr_ts | ( | long unsigned int | n | ) |
| void upper_string | ( | char * | str | ) |
str中の小文字を大文字に変換する
| [in,out] | str | 変換する文字列へのポインタ.内容が書き換えられる. |
Definition at line 2756 of file tools.c.
Referenced by strstrcase().

| unsigned short ushort_from_big_endian | ( | void * | ptr | ) |
unsigned short ushort_from_big_endian(void* ptr)
Big Endian形式で格納されている unsigned short int型の値を取り出す.
| ptr | 変数が格納されているメモリへのポインタ |
Definition at line 354 of file tools.c.
References check_endian(), HostEndian, LITTLE_ENDIAN, reverse_str(), and UNKNOWN_ENDIAN.

| unsigned short ushort_from_little_endian | ( | void * | ptr | ) |
unsigned short ushort_from_little_endian(void* ptr)
Little Endian形式で格納されている unsigned short int型の値を取り出す.
| ptr | 変数が格納されているメモリへのポインタ |
Definition at line 246 of file tools.c.
References BIG_ENDIAN, check_endian(), HostEndian, reverse_str(), and UNKNOWN_ENDIAN.

| unsigned char * uuid2guid | ( | unsigned char * | p | ) |
unsigned char* uuid2guid(unsigned char* p)
バイナリの UUID を テキストのGUIDに変換する.要 free()
| p | バイナリの UUID. 128bit |
Definition at line 3628 of file tools.c.
References LGUID.
Referenced by llsd_bin_main_parse().

| long unsigned int write_file | ( | const char * | fname, |
| unsigned char * | buf, | ||
| long unsigned int | size ) |
unsigned long int write_file(const char* fname, unsigned char* buf, long unsigned int size)
ファイルにデータを書き込む
| fname | ファイル名. |
| buf | 書き込むデータへのポインタ. |
| size | 書き込むデータのサイズ. |
Definition at line 2497 of file tools.c.
References buf.
Referenced by extract_tTar().

|
extern |
Definition at line 3893 of file tools.c.
Referenced by close_errfile(), open_errfile(), and print_errfile().
|
extern |
Definition at line 3892 of file tools.c.
Referenced by close_logfile(), open_errfile(), open_logfile(), and print_logfile().
|
extern |
ホストの Endian
Definition at line 21 of file tools.c.
Referenced by check_endian(), double_from_big_endian(), double_from_little_endian(), float_from_big_endian(), float_from_little_endian(), int_from_big_endian(), int_from_little_endian(), is_big_endian(), is_little_endian(), short_from_big_endian(), short_from_little_endian(), uint_from_big_endian(), uint_from_little_endian(), ushort_from_big_endian(), and ushort_from_little_endian().
|
extern |
処理用漢字コード.CODE_US, CODE_SJIS, CODE_EDUがある.デフォルトは CODE_US.
Definition at line 20 of file tools.c.
Referenced by kanji_convert(), and kanji_convert_Buffer().
|
extern |
|
extern |
|
extern |
Definition at line 23 of file tools.c.
Referenced by memory_check(), and memory_check_start().