]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/protos.h
Vacation work -- see tech log
[bacula/bacula] / bacula / src / lib / protos.h
1 /*
2  * Prototypes for lib directory of Bacula
3  *
4  *   Version $Id$
5  */
6 /*
7    Copyright (C) 2000-2005 Kern Sibbald
8
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.
13
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.
18
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,
22    MA 02111-1307, USA.
23
24  */
25
26 struct JCR;
27
28 /* attr.c */
29 ATTR     *new_attr();
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);
34
35 /* base64.c */
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);
40
41 /* bsys.c */
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);
47 #ifndef DEBUG
48 void     *bmalloc                (size_t size);
49 #endif
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);
61 #ifndef HAVE_STRTOLL
62 long long int strtoll            (const char *ptr, char **endptr, int base);
63 #endif
64 void      read_state_file(char *dir, const char *progname, int port);
65 int       bstrerror(int errnum, char *buf, size_t bufsiz);
66
67 /* bnet.c */
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);
92
93 /* bget_msg.c */
94 int      bget_msg(BSOCK *sock);
95
96 /* bpipe.c */
97 BPIPE *          open_bpipe(char *prog, int wait, const char *mode);
98 int              close_wpipe(BPIPE *bpipe);
99 int              close_bpipe(BPIPE *bpipe);
100
101 /* cram-md5.c */
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);
106
107 /* crc32.c */
108
109 uint32_t bcrc32(uint8_t *buf, int len);
110
111 /* daemon.c */
112 void     daemon_start            ();
113
114 /* edit.c */
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 char *           edit_int64              (int64_t val, char *buf);
121 int              duration_to_utime       (char *str, utime_t *value);
122 int              size_to_uint64(char *str, int str_len, uint64_t *rtn_value);
123 char             *edit_utime             (utime_t val, char *buf, int buf_len);
124 bool             is_a_number             (const char *num);
125 bool             is_an_integer           (const char *n);
126 bool             is_name_valid           (char *name, POOLMEM **msg);
127
128 /* jcr.c (most definitions are in src/jcr.h) */
129 void init_last_jobs_list();
130 void term_last_jobs_list();
131 void lock_last_jobs_list();
132 void unlock_last_jobs_list();
133 void read_last_jobs_list(int fd, uint64_t addr);
134 uint64_t write_last_jobs_list(int fd, uint64_t addr);
135 void write_state_file(char *dir, const char *progname, int port);
136 void job_end_push(JCR *jcr, void job_end_cb(JCR *jcr,void *), void *ctx);
137
138
139 /* lex.c */
140 LEX *     lex_close_file         (LEX *lf);
141 LEX *     lex_open_file          (LEX *lf, const char *fname, LEX_ERROR_HANDLER *scan_error);
142 int       lex_get_char           (LEX *lf);
143 void      lex_unget_char         (LEX *lf);
144 const char *  lex_tok_to_str     (int token);
145 int       lex_get_token          (LEX *lf, int expect);
146
147 /* message.c */
148 void       my_name_is            (int argc, char *argv[], const char *name);
149 void       init_msg              (JCR *jcr, MSGS *msg);
150 void       term_msg              (void);
151 void       close_msg             (JCR *jcr);
152 void       add_msg_dest          (MSGS *msg, int dest, int type, char *where, char *dest_code);
153 void       rem_msg_dest          (MSGS *msg, int dest, int type, char *where);
154 void       Jmsg                  (JCR *jcr, int type, time_t mtime, const char *fmt, ...);
155 void       dispatch_message      (JCR *jcr, int type, time_t mtime, char *buf);
156 void       init_console_msg      (const char *wd);
157 void       free_msgs_res         (MSGS *msgs);
158 void       dequeue_messages      (JCR *jcr);
159 void       set_trace             (int trace_flag);
160 void       set_exit_on_error     (int value);
161
162 /* bnet_server.c */
163 void       bnet_thread_server(dlist *addr, int max_clients, workq_t *client_wq,
164                    void *handle_client_request(void *bsock));
165 void       bnet_stop_thread_server(pthread_t tid);
166 void             bnet_server             (int port, void handle_client_request(BSOCK *bsock));
167 int              net_connect             (int port);
168 BSOCK *          bnet_bind               (int port);
169 BSOCK *          bnet_accept             (BSOCK *bsock, char *who);
170
171 /* idcache.c */
172 char *getuser(uid_t uid);
173 void free_getuser_cache();
174 char *getgroup (gid_t gid);
175 void free_getgroup_cache();
176
177 /* python.c */
178 typedef int (EVENT_HANDLER)(JCR *jcr, const char *event);
179 void init_python_interpreter(const char *progname, const char *scripts);
180 void term_python_interpreter();
181 extern EVENT_HANDLER *generate_event;
182
183 /* signal.c */
184 void             init_signals             (void terminate(int sig));
185 void             init_stack_dump          (void);
186
187 /* scan.c */
188 void             strip_trailing_junk     (char *str);
189 void             strip_trailing_slashes  (char *dir);
190 bool             skip_spaces             (char **msg);
191 bool             skip_nonspaces          (char **msg);
192 int              fstrsch                 (const char *a, const char *b);
193 char            *next_arg(char **s);
194 int              parse_args(POOLMEM *cmd, POOLMEM **args, int *argc,
195                         char **argk, char **argv, int max_args);
196 void            split_path_and_filename(const char *fname, POOLMEM **path,
197                         int *pnl, POOLMEM **file, int *fnl);
198 int             bsscanf(const char *buf, const char *fmt, ...);
199
200
201 /* util.c */
202 int              is_buf_zero             (char *buf, int len);
203 void             lcase                   (char *str);
204 void             bash_spaces             (char *str);
205 void             bash_spaces             (POOL_MEM &pm);
206 void             unbash_spaces           (char *str);
207 void             unbash_spaces           (POOL_MEM &pm);
208 char *           encode_time             (time_t time, char *buf);
209 char *           encode_mode             (mode_t mode, char *buf);
210 int              do_shell_expansion      (char *name, int name_len);
211 void             jobstatus_to_ascii      (int JobStatus, char *msg, int maxlen);
212 int              run_program             (char *prog, int wait, POOLMEM *results);
213 int              run_program_full_output (char *prog, int wait, POOLMEM *results);
214 const char *     job_type_to_str         (int type);
215 const char *     job_status_to_str       (int stat);
216 const char *     job_level_to_str        (int level);
217 void             make_session_key        (char *key, char *seed, int mode);
218 POOLMEM         *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to);
219 void             set_working_directory(char *wd);
220
221
222 /* watchdog.c */
223 int start_watchdog(void);
224 int stop_watchdog(void);
225 watchdog_t *new_watchdog(void);
226 bool register_watchdog(watchdog_t *wd);
227 bool unregister_watchdog(watchdog_t *wd);
228
229 /* timers.c */
230 btimer_t *start_child_timer(pid_t pid, uint32_t wait);
231 void stop_child_timer(btimer_t *wid);
232 btimer_t *start_thread_timer(pthread_t tid, uint32_t wait);
233 void stop_thread_timer(btimer_t *wid);
234 btimer_t *start_bsock_timer(BSOCK *bs, uint32_t wait);
235 void stop_bsock_timer(btimer_t *wid);