2 * Prototypes for lib directory of Bacula
7 Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of
12 the License, or (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU General Public
20 License along with this program; if not, write to the Free
21 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 void free_attr(ATTR *attr);
31 int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr);
32 void build_attr_output_fnames(JCR *jcr, ATTR *attr);
33 void print_ls_output(JCR *jcr, ATTR *attr);
36 void base64_init (void);
37 int to_base64 (intmax_t value, char *where);
38 int from_base64 (intmax_t *value, char *where);
39 int bin_to_base64 (char *buf, char *bin, int len);
42 char *bstrncpy (char *dest, const char *src, int maxlen);
43 char *bstrncat (char *dest, const char *src, int maxlen);
44 void *b_malloc (const char *file, int line, size_t size);
46 void *bmalloc (size_t size);
48 void *brealloc (void *buf, size_t size);
49 void *bcalloc (size_t size1, size_t size2);
50 int bsnprintf (char *str, int32_t size, const char *format, ...);
51 int bvsnprintf (char *str, int32_t size, const char *format, va_list ap);
52 int pool_sprintf (char *pool_buf, const char *fmt, ...);
53 void create_pid_file (char *dir, const char *progname, int port);
54 int delete_pid_file (char *dir, const char *progname, int port);
55 void drop (char *uid, char *gid);
56 int bmicrosleep (time_t sec, long usec);
57 char *bfgets (char *s, int size, FILE *fd);
58 void make_unique_filename (POOLMEM **name, int Id, char *what);
60 long long int strtoll (const char *ptr, char **endptr, int base);
62 void read_state_file(char *dir, const char *progname, int port);
65 int32_t bnet_recv (BSOCK *bsock);
66 int bnet_send (BSOCK *bsock);
67 int bnet_fsend (BSOCK *bs, const char *fmt, ...);
68 int bnet_set_buffer_size (BSOCK *bs, uint32_t size, int rw);
69 int bnet_sig (BSOCK *bs, int sig);
70 int bnet_ssl_server (BSOCK *bsock, char *password, int ssl_need, int ssl_has);
71 int bnet_ssl_client (BSOCK *bsock, char *password, int ssl_need);
72 BSOCK * bnet_connect (JCR *jcr, int retry_interval,
73 int max_retry_time, const char *name, char *host, char *service,
74 int port, int verbose);
75 void bnet_close (BSOCK *bsock);
76 BSOCK * init_bsock (JCR *jcr, int sockfd, const char *who, char *ip,
77 int port, struct sockaddr_in *client_addr);
78 BSOCK * dup_bsock (BSOCK *bsock);
79 void term_bsock (BSOCK *bsock);
80 char * bnet_strerror (BSOCK *bsock);
81 char * bnet_sig_to_ascii (BSOCK *bsock);
82 int bnet_wait_data (BSOCK *bsock, int sec);
83 int bnet_wait_data_intr (BSOCK *bsock, int sec);
84 int bnet_despool_to_bsock (BSOCK *bsock);
85 int is_bnet_stop (BSOCK *bsock);
86 int is_bnet_error (BSOCK *bsock);
87 void bnet_suppress_error_messages(BSOCK *bsock, int flag);
90 int bget_msg(BSOCK *sock);
93 BPIPE * open_bpipe(char *prog, int wait, const char *mode);
94 int close_wpipe(BPIPE *bpipe);
95 int close_bpipe(BPIPE *bpipe);
98 int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need);
99 int cram_md5_auth(BSOCK *bs, char *password, int ssl_need);
100 void hmac_md5(uint8_t* text, int text_len, uint8_t* key,
101 int key_len, uint8_t *hmac);
105 uint32_t bcrc32(uint8_t *buf, int len);
108 void daemon_start ();
111 uint64_t str_to_uint64(char *str);
112 int64_t str_to_int64(char *str);
113 char * edit_uint64_with_commas (uint64_t val, char *buf);
114 char * add_commas (char *val, char *buf);
115 char * edit_uint64 (uint64_t val, char *buf);
116 int duration_to_utime (char *str, utime_t *value);
117 int size_to_uint64(char *str, int str_len, uint64_t *rtn_value);
118 char *edit_utime (utime_t val, char *buf);
119 int is_a_number (const char *num);
120 int is_an_integer (const char *n);
121 bool is_name_valid (char *name, POOLMEM **msg);
123 /* jcr.c (most definitions are in src/jcr.h) */
124 void init_last_jobs_list();
125 void term_last_jobs_list();
126 void lock_last_jobs_list();
127 void unlock_last_jobs_list();
128 void read_last_jobs_list(int fd, uint64_t addr);
129 uint64_t write_last_jobs_list(int fd, uint64_t addr);
130 void write_state_file(char *dir, const char *progname, int port);
131 void job_end_push(JCR *jcr, void job_end_cb(JCR *jcr));
135 LEX * lex_close_file (LEX *lf);
136 LEX * lex_open_file (LEX *lf, char *fname, LEX_ERROR_HANDLER *scan_error);
137 int lex_get_char (LEX *lf);
138 void lex_unget_char (LEX *lf);
139 const char * lex_tok_to_str (int token);
140 int lex_get_token (LEX *lf, int expect);
143 void my_name_is (int argc, char *argv[], const char *name);
144 void init_msg (JCR *jcr, MSGS *msg);
145 void term_msg (void);
146 void close_msg (JCR *jcr);
147 void add_msg_dest (MSGS *msg, int dest, int type, char *where, char *dest_code);
148 void rem_msg_dest (MSGS *msg, int dest, int type, char *where);
149 void Jmsg (JCR *jcr, int type, int level, const char *fmt, ...);
150 void dispatch_message (JCR *jcr, int type, int level, char *buf);
151 void init_console_msg (char *wd);
152 void free_msgs_res (MSGS *msgs);
153 void dequeue_messages (JCR *jcr);
154 void set_trace (int trace_flag);
158 void bnet_thread_server(char *bind_addr, int port, int max_clients, workq_t *client_wq,
159 void *handle_client_request(void *bsock));
160 void bnet_stop_thread_server(pthread_t tid);
161 void bnet_server (int port, void handle_client_request(BSOCK *bsock));
162 int net_connect (int port);
163 BSOCK * bnet_bind (int port);
164 BSOCK * bnet_accept (BSOCK *bsock, char *who);
167 char *getuser(uid_t uid);
168 void free_getuser_cache();
169 char *getgroup (gid_t gid);
170 void free_getgroup_cache();
174 void init_signals (void terminate(int sig));
175 void init_stack_dump (void);
178 void strip_trailing_junk (char *str);
179 void strip_trailing_slashes (char *dir);
180 bool skip_spaces (char **msg);
181 bool skip_nonspaces (char **msg);
182 int fstrsch (char *a, char *b);
183 int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc,
184 char **argk, char **argv, int max_args);
185 char *next_arg(char **s);
188 int is_buf_zero (char *buf, int len);
189 void lcase (char *str);
190 void bash_spaces (char *str);
191 void unbash_spaces (char *str);
192 char * encode_time (time_t time, char *buf);
193 char * encode_mode (mode_t mode, char *buf);
194 int do_shell_expansion (char *name, int name_len);
195 void jobstatus_to_ascii (int JobStatus, char *msg, int maxlen);
196 int pm_strcat (POOLMEM **pm, const char *str);
197 int pm_strcpy (POOLMEM **pm, const char *str);
198 int run_program (char *prog, int wait, POOLMEM *results);
199 char * job_type_to_str (int type);
200 char * job_status_to_str (int stat);
201 char * job_level_to_str (int level);
202 void make_session_key (char *key, char *seed, int mode);
203 POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to);
204 void set_working_directory(char *wd);
208 int start_watchdog(void);
209 int stop_watchdog(void);
210 watchdog_t *new_watchdog(void);
211 bool register_watchdog(watchdog_t *wd);
212 bool unregister_watchdog(watchdog_t *wd);
213 bool unregister_watchdog_unlocked(watchdog_t *wd);
216 btimer_t *start_child_timer(pid_t pid, uint32_t wait);
217 void stop_child_timer(btimer_t *wid);
218 btimer_t *start_thread_timer(pthread_t tid, uint32_t wait);
219 void stop_thread_timer(btimer_t *wid);
220 btimer_t *start_bsock_timer(BSOCK *bs, uint32_t wait);
221 void stop_bsock_timer(btimer_t *wid);