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 *bstrncpy (char *dest, POOL_MEM &src, int maxlen);
44 char *bstrncat (char *dest, const char *src, int maxlen);
45 char *bstrncat (char *dest, POOL_MEM &src, int maxlen);
46 void *b_malloc (const char *file, int line, size_t size);
48 void *bmalloc (size_t size);
50 void *brealloc (void *buf, size_t size);
51 void *bcalloc (size_t size1, size_t size2);
52 int bsnprintf (char *str, int32_t size, const char *format, ...);
53 int bvsnprintf (char *str, int32_t size, const char *format, va_list ap);
54 int pool_sprintf (char *pool_buf, const char *fmt, ...);
55 void create_pid_file (char *dir, const char *progname, int port);
56 int delete_pid_file (char *dir, const char *progname, int port);
57 void drop (char *uid, char *gid);
58 int bmicrosleep (time_t sec, long usec);
59 char *bfgets (char *s, int size, FILE *fd);
60 void make_unique_filename (POOLMEM **name, int Id, char *what);
62 long long int strtoll (const char *ptr, char **endptr, int base);
64 void read_state_file(char *dir, const char *progname, int port);
65 int bstrerror(int errnum, char *buf, size_t bufsiz);
68 int32_t bnet_recv (BSOCK *bsock);
69 bool bnet_send (BSOCK *bsock);
70 bool bnet_fsend (BSOCK *bs, const char *fmt, ...);
71 bool bnet_set_buffer_size (BSOCK *bs, uint32_t size, int rw);
72 bool bnet_sig (BSOCK *bs, int sig);
73 int bnet_ssl_server (BSOCK *bsock, char *password, int ssl_need, int ssl_has);
74 int bnet_ssl_client (BSOCK *bsock, char *password, int ssl_need);
75 BSOCK * bnet_connect (JCR *jcr, int retry_interval,
76 int max_retry_time, const char *name, char *host, char *service,
77 int port, int verbose);
78 void bnet_close (BSOCK *bsock);
79 BSOCK * init_bsock (JCR *jcr, int sockfd, const char *who, const char *ip,
80 int port, struct sockaddr *client_addr);
81 BSOCK * dup_bsock (BSOCK *bsock);
82 void term_bsock (BSOCK *bsock);
83 const char *bnet_strerror (BSOCK *bsock);
84 const char *bnet_sig_to_ascii (BSOCK *bsock);
85 int bnet_wait_data (BSOCK *bsock, int sec);
86 int bnet_wait_data_intr (BSOCK *bsock, int sec);
87 int bnet_despool_to_bsock (BSOCK *bsock, void update(ssize_t size), ssize_t size);
88 bool is_bnet_stop (BSOCK *bsock);
89 int is_bnet_error (BSOCK *bsock);
90 void bnet_suppress_error_messages(BSOCK *bsock, bool flag);
91 dlist *bnet_host2ipaddrs(const char *host, int family, const char **errstr);
94 int bget_msg(BSOCK *sock);
97 BPIPE * open_bpipe(char *prog, int wait, const char *mode);
98 int close_wpipe(BPIPE *bpipe);
99 int close_bpipe(BPIPE *bpipe);
102 int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need);
103 int cram_md5_auth(BSOCK *bs, char *password, int ssl_need);
104 void hmac_md5(uint8_t* text, int text_len, uint8_t* key,
105 int key_len, uint8_t *hmac);
109 uint32_t bcrc32(uint8_t *buf, int len);
112 void daemon_start ();
115 uint64_t str_to_uint64(char *str);
116 int64_t str_to_int64(char *str);
117 char * edit_uint64_with_commas (uint64_t val, char *buf);
118 char * add_commas (char *val, char *buf);
119 char * edit_uint64 (uint64_t val, char *buf);
120 int duration_to_utime (char *str, utime_t *value);
121 int size_to_uint64(char *str, int str_len, uint64_t *rtn_value);
122 char *edit_utime (utime_t val, char *buf, int buf_len);
123 bool is_a_number (const char *num);
124 bool is_an_integer (const char *n);
125 bool is_name_valid (char *name, POOLMEM **msg);
127 /* jcr.c (most definitions are in src/jcr.h) */
128 void init_last_jobs_list();
129 void term_last_jobs_list();
130 void lock_last_jobs_list();
131 void unlock_last_jobs_list();
132 void read_last_jobs_list(int fd, uint64_t addr);
133 uint64_t write_last_jobs_list(int fd, uint64_t addr);
134 void write_state_file(char *dir, const char *progname, int port);
135 void job_end_push(JCR *jcr, void job_end_cb(JCR *jcr,void *), void *ctx);
139 LEX * lex_close_file (LEX *lf);
140 LEX * lex_open_file (LEX *lf, const char *fname, LEX_ERROR_HANDLER *scan_error);
141 int lex_get_char (LEX *lf);
142 void lex_unget_char (LEX *lf);
143 const char * lex_tok_to_str (int token);
144 int lex_get_token (LEX *lf, int expect);
147 void my_name_is (int argc, char *argv[], const char *name);
148 void init_msg (JCR *jcr, MSGS *msg);
149 void term_msg (void);
150 void close_msg (JCR *jcr);
151 void add_msg_dest (MSGS *msg, int dest, int type, char *where, char *dest_code);
152 void rem_msg_dest (MSGS *msg, int dest, int type, char *where);
153 void Jmsg (JCR *jcr, int type, time_t mtime, const char *fmt, ...);
154 void dispatch_message (JCR *jcr, int type, time_t mtime, char *buf);
155 void init_console_msg (const char *wd);
156 void free_msgs_res (MSGS *msgs);
157 void dequeue_messages (JCR *jcr);
158 void set_trace (int trace_flag);
159 void set_exit_on_error (int value);
162 void bnet_thread_server(dlist *addr, int max_clients, workq_t *client_wq,
163 void *handle_client_request(void *bsock));
164 void bnet_stop_thread_server(pthread_t tid);
165 void bnet_server (int port, void handle_client_request(BSOCK *bsock));
166 int net_connect (int port);
167 BSOCK * bnet_bind (int port);
168 BSOCK * bnet_accept (BSOCK *bsock, char *who);
171 char *getuser(uid_t uid);
172 void free_getuser_cache();
173 char *getgroup (gid_t gid);
174 void free_getgroup_cache();
177 void init_python_interpreter(const char *progname, const char *scripts);
178 void term_python_interpreter();
179 int generate_event(JCR *jcr, const char *event);
182 void init_signals (void terminate(int sig));
183 void init_stack_dump (void);
186 void strip_trailing_junk (char *str);
187 void strip_trailing_slashes (char *dir);
188 bool skip_spaces (char **msg);
189 bool skip_nonspaces (char **msg);
190 int fstrsch (const char *a, const char *b);
191 char *next_arg(char **s);
192 int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc,
193 char **argk, char **argv, int max_args);
194 void split_path_and_filename(const char *fname, POOLMEM **path,
195 int *pnl, POOLMEM **file, int *fnl);
196 int bsscanf(const char *buf, const char *fmt, ...);
200 int is_buf_zero (char *buf, int len);
201 void lcase (char *str);
202 void bash_spaces (char *str);
203 void bash_spaces (POOL_MEM &pm);
204 void unbash_spaces (char *str);
205 void unbash_spaces (POOL_MEM &pm);
206 char * encode_time (time_t time, char *buf);
207 char * encode_mode (mode_t mode, char *buf);
208 int do_shell_expansion (char *name, int name_len);
209 void jobstatus_to_ascii (int JobStatus, char *msg, int maxlen);
210 int run_program (char *prog, int wait, POOLMEM *results);
211 const char * job_type_to_str (int type);
212 const char * job_status_to_str (int stat);
213 const char * job_level_to_str (int level);
214 void make_session_key (char *key, char *seed, int mode);
215 POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to);
216 void set_working_directory(char *wd);
220 int start_watchdog(void);
221 int stop_watchdog(void);
222 watchdog_t *new_watchdog(void);
223 bool register_watchdog(watchdog_t *wd);
224 bool unregister_watchdog(watchdog_t *wd);
227 btimer_t *start_child_timer(pid_t pid, uint32_t wait);
228 void stop_child_timer(btimer_t *wid);
229 btimer_t *start_thread_timer(pthread_t tid, uint32_t wait);
230 void stop_thread_timer(btimer_t *wid);
231 btimer_t *start_bsock_timer(BSOCK *bs, uint32_t wait);
232 void stop_bsock_timer(btimer_t *wid);