2 * (c); Oleg Puchinin 2006
3 * graycardinalster@gmail.com
7 #ifndef DEFINE_GCLIBC_H
8 #define DEFINE_GCLIBC_H
15 #include <netinet/in.h>
16 #include <arpa/inet.h>
19 #ifdef gclib_c__export
20 #undef gclib_c__export
24 #define gclib_c__export extern "C"
26 #define gclib_c__export extern
34 gclib_c__export
void buf_W8 (char ** pkt
, unsigned char data
);
35 gclib_c__export
void buf_W16 (char ** pkt
, uint16_t data
);
36 gclib_c__export
void buf_W32 (char ** pkt
, unsigned int data
);
37 gclib_c__export
void buf_WS (char ** pkt
, char *S
);
38 gclib_c__export
void buf_WSZ (char ** pkt
, char *S
);
39 gclib_c__export
void buf_WD (char ** pkt
, char *S
, int size
);
40 gclib_c__export
unsigned char buf_R8 (char ** pkt
);
41 gclib_c__export
uint16_t buf_R16 (char ** pkt
);
42 gclib_c__export
uint32_t buf_R32 (char ** pkt
);
43 gclib_c__export
char * buf_RD (char ** pkt
, int len
);
44 #define buf_Wstruct(pkt, s) do { buf_WD (pkt, (char *) s, sizeof (*s)); } while (0)
45 #define buf_Rstruct(arga, argb) (argb *) buf_RD (arga, sizeof (argb))
48 gclib_c__export
void print_the_time (FILE * file_my
);
49 gclib_c__export
int close_pipe (int *fds
);
50 gclib_c__export
int Dfork (char *exec
, int *fd_in
, int *fd_out
, int *fd_err
);
51 gclib_c__export
void Dfastsort_s(char ** a
, long N
);
52 gclib_c__export
void Dtimer ();
53 gclib_c__export
struct timeval
*the_time ();
55 gclib_c__export
int Dterm_one_kick (int fd
);
56 gclib_c__export
char *Dversion ();
57 gclib_c__export
int Dfnwrite (char * p_lpsz_filename
, void * p_lp_buffer
,int int_size
);
58 gclib_c__export
int Dfnread (char * f_name
, void * p_lp_buffer
, int int_size
);
59 gclib_c__export
int Dselect (int FILENO
, int SEC
, int USEC
);
60 gclib_c__export
char * DFILE (const char * m_filename
, int *rsize
);
61 gclib_c__export
struct stat
* DSTAT (const char * S
);
62 gclib_c__export
struct stat
* DLSTAT (const char * S
);
63 gclib_c__export
int DIONREAD (int fd
);
64 gclib_c__export
int fsize (const char * S
);
65 gclib_c__export
int fdsize (int fd
);
66 gclib_c__export
char * DFDMAP (int fd
);
67 gclib_c__export
char * DFMAP (const char *d_file
, int *out_fd
, int *d_out_size
);
68 gclib_c__export
char * Dread_to_eof (int fd
, int *d_out_size
);
69 gclib_c__export
int move_stream (int fd_in
, int fd_out
);
70 gclib_c__export
int Dnonblock(int fd
);
71 gclib_c__export
char * gc_realloc (char * PTR
, int old_size
, int new_size
);
72 gclib_c__export
void * memdup (void * PTR
, int size
);
73 gclib_c__export
int Dsplit(char * lpsz_String
, char *ch
, char ** outbuffer
, int int_buffersize
);
74 gclib_c__export
char * Dstrmid(char * lpsz_string
,char * param1
, char * param2
);
75 gclib_c__export
char * chomp (char * S
);
76 gclib_c__export
char * DSTR (FILE * m_file
);
77 gclib_c__export
char * strchr_r (char * S
, char ch
, int d_len
);
78 gclib_c__export
char * strchrs (char *S
, char ch
, char ch2
, char ch3
, char ch4
);
79 gclib_c__export
char * Dstrstr_r (char *where
, char * str
);
80 gclib_c__export
char * Dstrndup (char *ptr
, int n
);
81 gclib_c__export
char * Dtimestr (char * buf
, int max
);
82 gclib_c__export
int Dsyms (char * from
, char * to
, char sym
);
83 gclib_c__export
char * Dmemchr (char *from
, int n
, char ch
);
84 gclib_c__export
int Dunix_sendto(void * lp_data
,int int_size
,char * lpsz_path
);
85 gclib_c__export
int Dsendto (int sock
, void * lp_data
, int int_size
, const char * address
,int port
);
86 gclib_c__export
int Dsendto2 (void * lp_data
, int int_size
, const char * address
, int port
);
87 gclib_c__export
int Dbind (int sock
, char * addr
, int port
);
88 gclib_c__export
int Dsocket ();
89 gclib_c__export
int Dsocket_udp ();
90 gclib_c__export
int Dconnect (int sock
, const char * addr
, int port
);
91 gclib_c__export
int Dgethostbyname(const char * lpsz_hostname
,struct in_addr
* address
);
92 gclib_c__export
char * Dgetnamebyhost(struct in_addr
* params
);
93 gclib_c__export
int Drecvfrom (int fd
, char * buf
, int size
, char * peer_ip
, int * peer_port
);
94 gclib_c__export
int Dbroadcast (int fd
);
95 gclib_c__export
int Dpoll_scan (struct pollfd
**p
, int count
, int position
);
96 gclib_c__export
char * Dmid_strchr (char *ptr
, char *end
, char ch
);
97 gclib_c__export
char * Dmid_getstr (char *buf
, char *end
);
98 gclib_c__export
int Dtransmit (char *f_name
, int sd
);
99 gclib_c__export
int Dtransmit_udp (char *f_name
, int sd
, char *ip
, uint16_t port
);
100 gclib_c__export
char * Drand_str (char * buf
, int count
);
101 gclib_c__export
char * int2str (int i
);
102 gclib_c__export
char * Dprogram_read (char *EXEC
, int * len_out
);
103 gclib_c__export
char * stail (char *S
);
104 gclib_c__export
char * strmov (char *buf
, char * S
);
105 gclib_c__export
char * strip (char *str
) ;
106 gclib_c__export
char * strip2 (char *str
) ;
107 gclib_c__export
char * Dmemmem (char *haystack
, size_t haystacklen
, char *needle
, size_t needlelen
) ;
108 gclib_c__export
char * Dmid_memmem (char * begin
, char * last
, char * needle
, size_t needlelen
) ;
109 gclib_c__export
int Dtmpfd (char *name
) ;
110 gclib_c__export
int fdclose (int * fd
) ;
111 gclib_c__export
char * fext (char *name
) ;
112 gclib_c__export
char * Dsprintf (char * fmt
, ...) ;
113 gclib_c__export
int logToFile (char * fileName
, char * fmt
, ...) ;
114 gclib_c__export
int copyFile (char * sourceName
, char * destName
) ;
117 gclib_c__export
int sem_init (int * KEY
);
118 gclib_c__export
int sem_init_rw (int * KEY
);
119 gclib_c__export
int down (int sem
);
120 gclib_c__export
int up (int sem
);
121 gclib_c__export
int down_read (int sem
);
122 gclib_c__export
int down_write (int sem
);
123 gclib_c__export
int up_read (int sem
);
124 gclib_c__export
int up_write (int sem
);
127 gclib_c__export
void bxor (char * src
, char *key
, int count
, int key_size
);
128 gclib_c__export
unsigned char * base64_code (unsigned char * S
, int SIZE
);
129 gclib_c__export
unsigned char * base64_decode (unsigned char * S
, int SIZE
);
131 #define if_digit(S) ((*S >= '0') && (*S <= '9'))
132 #define if_abc(S) ((*S >= 'a' && *S <= 'z') || (*S >= 'A' && *S <= 'Z'))
133 #define OR(var,val1,val2) ((var == val1) || (var == val2))
136 #define EQ(arga, argb) (!strcmp (arga, argb))
140 #define NE(arga, argb) (strcmp (arga, argb))
144 #define chop(arg1) arg1[strlen(arg1) - 1] = 0
147 #define DROP(arga) if (arga) { free (arga); arga = NULL; }
148 #define CNEW(arga,argb) (arga *)malloc (sizeof (arga)*(argb))
150 #undef gclib_c__export