The error I when I installed 1.34.2 clients:
The BACULA-FD file is
linked to missing export KERNEL32.DLL:GetFileAttributesExA.
+- Add link to doc in message when authentication fails.
+- Add db_ensure...slot_unique to BDB.
Documentation to do: (any release a little bit at a time)
mount it.
- Implement Fixed storage LabelFormat test.
- Add reporting in attr despooling.
-
#define fgets(x,y,z) bfgets((x), (y), (z))
/* Use our sscanf, which is safer and works with known sizes */
-// #define sscanf bsscanf
+#define sscanf bsscanf
#ifdef DEBUG
#define bstrdup(str) strcpy((char *)b_malloc(__FILE__,__LINE__,strlen((str))+1),(str))
}
int
-db_find_last_jobid(JCR *jcr, B_DB *mdb, char *Name, JOB_DBR *jr)
+db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr)
{ return 0; }
#define __SQL_H_ 1
-typedef void (DB_LIST_HANDLER)(void *, char *);
+typedef void (DB_LIST_HANDLER)(void *, const char *);
typedef int (DB_RESULT_HANDLER)(void *, int, char **);
#define db_lock(mdb) _db_lock(__FILE__, __LINE__, mdb)
void list_dashes(B_DB *mdb, DB_LIST_HANDLER *send, void *ctx);
int get_sql_record_max(JCR *jcr, B_DB *mdb);
int check_tables_version(JCR *jcr, B_DB *mdb);
-void _db_unlock(char *file, int line, B_DB *mdb);
-void _db_lock(char *file, int line, B_DB *mdb);
+void _db_unlock(const char *file, int line, B_DB *mdb);
+void _db_lock(const char *file, int line, B_DB *mdb);
#endif /* __SQL_H_ */
* never have errors, or it is really fatal.
*/
B_DB *
-db_init_database(JCR *jcr, char *db_name, char *db_user, char *db_password,
- char *db_address, int db_port, char *db_socket)
+db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password,
+ const char *db_address, int db_port, const char *db_socket)
{
B_DB *mdb;
* Submit a general SQL command (cmd), and for each row returned,
* the sqlite_handler is called with the ctx.
*/
-int db_sql_query(B_DB *mdb, char *query, DB_RESULT_HANDLER *result_handler, void *ctx)
+int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler, void *ctx)
{
SQL_ROW row;
* never have errors, or it is really fatal.
*/
B_DB *
-db_init_database(JCR *jcr, char *db_name, char *db_user, char *db_password,
- char *db_address, int db_port, char *db_socket)
+db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password,
+ const char *db_address, int db_port, const char *db_socket)
{
B_DB *mdb;
* Submit a general SQL command (cmd), and for each row returned,
* the sqlite_handler is called with the ctx.
*/
-int db_sql_query(B_DB *mdb, char *query, DB_RESULT_HANDLER *result_handler, void *ctx)
+int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler, void *ctx)
{
SQL_ROW row;
/* Database prototypes */
/* sql.c */
-B_DB *db_init_database(JCR *jcr, char *db_name, char *db_user, char *db_password,
- char *db_address, int db_port, char *db_socket);
+B_DB *db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password,
+ const char *db_address, int db_port, const char *db_socket);
int db_open_database(JCR *jcr, B_DB *db);
void db_close_database(JCR *jcr, B_DB *db);
void db_escape_string(char *snew, char *old, int len);
char *db_strerror(B_DB *mdb);
int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index);
-int db_sql_query(B_DB *mdb, char *cmd, DB_RESULT_HANDLER *result_handler, void *ctx);
+int db_sql_query(B_DB *mdb, const char *cmd, DB_RESULT_HANDLER *result_handler, void *ctx);
void db_start_transaction(JCR *jcr, B_DB *mdb);
void db_end_transaction(JCR *jcr, B_DB *mdb);
/* find.c */
int db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime);
-int db_find_last_jobid(JCR *jcr, B_DB *mdb, char *Name, JOB_DBR *jr);
+int db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr);
int db_find_next_volume(JCR *jcr, B_DB *mdb, int index, bool InChanger, MEDIA_DBR *mr);
/* get.c */
/* Check that the tables correspond to the version we want */
int check_tables_version(JCR *jcr, B_DB *mdb)
{
- char *query = "SELECT VersionId FROM Version";
+ const char *query = "SELECT VersionId FROM Version";
bacula_db_version = 0;
db_sql_query(mdb, query, int_handler, (void *)&bacula_db_version);
/* Utility routine for queries. The database MUST be locked before calling here. */
int
-QueryDB(char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
+QueryDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
{
int status;
if ((status=sql_query(mdb, cmd)) != 0) {
* 1 on success
*/
int
-InsertDB(char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
+InsertDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
{
if (sql_query(mdb, cmd)) {
m_msg(file, line, &mdb->errmsg, _("insert %s failed:\n%s\n"), cmd, sql_strerror(mdb));
* 1 on success
*/
int
-UpdateDB(char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
+UpdateDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
{
if (sql_query(mdb, cmd)) {
* n number of rows affected
*/
int
-DeleteDB(char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
+DeleteDB(const char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
{
if (sql_query(mdb, cmd)) {
* thread without blocking, but must be unlocked the number of
* times it was locked.
*/
-void _db_lock(char *file, int line, B_DB *mdb)
+void _db_lock(const char *file, int line, B_DB *mdb)
{
int errstat;
if ((errstat=rwl_writelock(&mdb->lock)) != 0) {
* same thread up to the number of times that thread called
* db_lock()/
*/
-void _db_unlock(char *file, int line, B_DB *mdb)
+void _db_unlock(const char *file, int line, B_DB *mdb)
{
int errstat;
if ((errstat=rwl_writeunlock(&mdb->lock)) != 0) {
/* Imported subroutines */
extern void print_dashes(B_DB *mdb);
extern void print_result(B_DB *mdb);
-extern int QueryDB(char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
-extern int InsertDB(char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
-extern int UpdateDB(char *file, int line, JCR *jcr, B_DB *db, char *update_cmd);
+extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
+extern int InsertDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
+extern int UpdateDB(const char *file, int line, JCR *jcr, B_DB *db, char *update_cmd);
extern void split_path_and_file(JCR *jcr, B_DB *mdb, const char *fname);
/* Imported subroutines */
extern void print_dashes(B_DB *mdb);
extern void print_result(B_DB *mdb);
-extern int QueryDB(char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
-extern int DeleteDB(char *file, int line, JCR *jcr, B_DB *db, char *delete_cmd);
+extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
+extern int DeleteDB(const char *file, int line, JCR *jcr, B_DB *db, char *delete_cmd);
/*
* Delete Pool record, must also delete all associated
/* Imported subroutines */
extern void print_result(B_DB *mdb);
-extern int QueryDB(char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
+extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
/*
* Find job start time if JobId specified, otherwise
* 0 on failure
*/
int
-db_find_last_jobid(JCR *jcr, B_DB *mdb, char *Name, JOB_DBR *jr)
+db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr)
{
SQL_ROW row;
{
SQL_ROW row;
int numrows;
- char *changer, *order;
+ const char *changer, *order;
db_lock(mdb);
if (item == -1) { /* find oldest volume */
/* Imported subroutines */
extern void print_result(B_DB *mdb);
-extern int QueryDB(char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
+extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
extern void split_path_and_file(JCR *jcr, B_DB *mdb, const char *fname);
/* Imported subroutines */
extern void list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
-extern int QueryDB(char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
+extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
/*
/* Imported subroutines */
extern void print_result(B_DB *mdb);
-extern int UpdateDB(char *file, int line, JCR *jcr, B_DB *db, char *update_cmd);
+extern int UpdateDB(const char *file, int line, JCR *jcr, B_DB *db, char *update_cmd);
/* -----------------------------------------------------------------------
*
* -----------------------------------------------------------------------
*/
-extern char *working_directory;
+extern const char *working_directory;
/* List of open databases */
static BQUEUE db_list = {&db_list, &db_list};
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-int QueryDB(char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
+int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
/*
* never have errors, or it is really fatal.
*/
B_DB *
-db_init_database(JCR *jcr, char *db_name, char *db_user, char *db_password,
- char *db_address, int db_port, char *db_socket)
+db_init_database(JCR *jcr, const char *db_name, const char *db_user, const char *db_password,
+ const char *db_address, int db_port, const char *db_socket)
{
B_DB *mdb;
* Submit a general SQL command (cmd), and for each row returned,
* the sqlite_handler is called with the ctx.
*/
-int db_sql_query(B_DB *mdb, char *query, DB_RESULT_HANDLER *result_handler, void *ctx)
+int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler, void *ctx)
{
struct rh_data rh_data;
int stat;
#include "jcr.h"
-void senditf(char *fmt, ...);
-void sendit(char *buf);
+void senditf(const char *fmt, ...);
+void sendit(const char *buf);
/* Commands sent to Director */
static char hello[] = "Hello %s calling\n";
/* Forward referenced functions */
static void terminate_console(int sig);
-int get_cmd(FILE *input, char *prompt, BSOCK *sock, int sec);
+int get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec);
static int do_outputcmd(FILE *input, BSOCK *UA_sock);
-void senditf(char *fmt, ...);
-void sendit(char *buf);
+void senditf(const char *fmt, ...);
+void sendit(const char *buf);
/* Static variables */
static char *configfile = NULL;
{
fprintf(stderr, _(
"\nVersion: " VERSION " (" BDATE ") %s %s %s\n\n"
-"Usage: bconsole [-s] [-c config_file] [-d debug_level] [config_file]\n"
+"Usage: bconsole [-s] [-c config_file] [-d debug_level]\n"
" -c <file> set configuration file to file\n"
" -dnn set debug level to nn\n"
" -s no signals\n"
/*
* These are the @command
*/
-struct cmdstruct { char *key; int (*func)(FILE *input, BSOCK *UA_sock); char *help; };
+struct cmdstruct { const char *key; int (*func)(FILE *input, BSOCK *UA_sock); const char *help; };
static struct cmdstruct commands[] = {
{ N_("input"), inputcmd, _("input from file")},
{ N_("output"), outputcmd, _("output to file")},
static void read_and_process_input(FILE *input, BSOCK *UA_sock)
{
- char *prompt = "*";
+ const char *prompt = "*";
bool at_prompt = false;
int tty_input = isatty(fileno(input));
int stat;
int
-get_cmd(FILE *input, char *prompt, BSOCK *sock, int sec)
+get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec)
{
char *line;
* -1 if EOF or error
*/
int
-get_cmd(FILE *input, char *prompt, BSOCK *sock, int sec)
+get_cmd(FILE *input, const char *prompt, BSOCK *sock, int sec)
{
int len;
if (!stop) {
static int do_outputcmd(FILE *input, BSOCK *UA_sock)
{
FILE *fd;
- char *mode = "a+";
+ const char *mode = "a+";
if (argc > 3) {
sendit(_("Too many arguments on output/tee command.\n"));
/*
* Send a line to the output file and or the terminal
*/
-void senditf(char *fmt,...)
+void senditf(const char *fmt,...)
{
char buf[3000];
va_list arg_ptr;
sendit(buf);
}
-void sendit(char *buf)
+void sendit(const char *buf)
{
#ifdef xHAVE_CONIO
if (output == stdout || tee) {
/* Dump contents of resource */
-void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ...), void *sock)
+void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock)
{
URES *res = (URES *)reshdr;
int recurse = 1;
R_ADDRESS,
R_PASSWORD,
R_TYPE,
- R_BACKUP,
+ R_BACKUP
};
{
char sdt[50], edt[50];
char term_code[100];
- char *term_msg;
+ const char *term_msg;
int msg_type;
MEDIA_DBR mr;
static char FDOKhello[] = "2000 OK Hello\n";
/* Sent to User Agent */
-static char Dir_sorry[] = N_("1999 You are not authorized.\n");
+static char Dir_sorry[] = "1999 You are not authorized.\n";
/* Forward referenced functions */
char sdt[50], edt[50];
char ec1[30], ec2[30], ec3[30], ec4[30], ec5[30], compress[50];
char term_code[100], fd_term_msg[100], sd_term_msg[100];
- char *term_msg;
+ const char *term_msg;
int msg_type;
MEDIA_DBR mr;
double kbps, compression;
*/
unbash_spaces(mr.VolumeName);
if (db_get_media_record(jcr, jcr->db, &mr)) {
- char *reason = NULL; /* detailed reason for rejection */
+ const char *reason = NULL; /* detailed reason for rejection */
/*
* If we are reading, accept any volume (reason == NULL)
* If we are writing, check if the Volume is valid
{NULL, 0}
};
-char *level_to_str(int level)
+const char *level_to_str(int level)
{
int i;
static char level_no[30];
- char *str = level_no;
+ const char *str = level_no;
bsnprintf(level_no, sizeof(level_no), "%d", level); /* default if not found */
for (i=0; joblevels[i].level_name; i++) {
}
/* Dump contents of resource */
-void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ...), void *sock)
+void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock)
{
URES *res = (URES *)reshdr;
bool recurse = true;
/* Used for certain KeyWord tables */
struct s_kw {
- char *name;
+ const char *name;
int token;
};
/* Job Level keyword structure */
struct s_jl {
- char *level_name; /* level keyword */
+ const char *level_name; /* level keyword */
int level; /* level */
int job_type; /* JobType permitting this level */
};
/* Job Type keyword structure */
struct s_jt {
- char *type_name;
+ const char *type_name;
int job_type;
};
static int job_item(JCR *jcr, int code,
const char **val_ptr, int *val_len, int *val_size)
{
- char *str = " ";
+ const char *str = " ";
char buf[20];
switch (code) {
}
-struct s_built_in_vars {char *var_name; int code; int (*func)(JCR *jcr, int code,
+struct s_built_in_vars {const char *var_name; int code; int (*func)(JCR *jcr, int code,
const char **val_ptr, int *val_len, int *val_size);};
/*
FILE *bs;
char buf[1000];
BSOCK *fd = jcr->file_bsock;
- char *bootstrap = "bootstrap\n";
+ const char *bootstrap = "bootstrap\n";
Dmsg1(400, "send_bootstrap_file: %s\n", jcr->RestoreBootstrap);
if (!jcr->RestoreBootstrap) {
* Returns: 0 on failure
* 1 on success
*/
-int response(JCR *jcr, BSOCK *fd, char *resp, char *cmd, e_prtmsg prtmsg)
+int response(JCR *jcr, BSOCK *fd, char *resp, const char *cmd, e_prtmsg prtmsg)
{
int n;
/* Options for FileSet keywords */
struct s_fs_opt {
- char *name;
+ const char *name;
int keyword;
- char *option;
+ const char *option;
};
/*
* Returns: unique job name in jcr->Job
* date/time in jcr->start_time
*/
-void create_unique_job_name(JCR *jcr, char *base_name)
+void create_unique_job_name(JCR *jcr, const char *base_name)
{
/* Job start mutex */
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
* Returns: on failure - reason = NULL
* on success - reason - pointer to reason
*/
-void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, char **reason)
+void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **reason)
{
int ok;
extern void catalog_update(JCR *jcr, BSOCK *bs, char *buf);
/* dird_conf.c */
-extern char *level_to_str(int level);
+extern const char *level_to_str(int level);
/* expand.c */
int variable_expansion(JCR *jcr, char *inp, POOLMEM **exp);
DISPLAY_ERROR,
NO_DISPLAY
};
-extern int response(JCR *jcr, BSOCK *fd, char *resp, char *cmd, e_prtmsg prtmsg);
+extern int response(JCR *jcr, BSOCK *fd, char *resp, const char *cmd, e_prtmsg prtmsg);
/* job.c */
extern void set_jcr_defaults(JCR *jcr, JOB *job);
-extern void create_unique_job_name(JCR *jcr, char *base_name);
+extern void create_unique_job_name(JCR *jcr, const char *base_name);
extern void update_job_end_record(JCR *jcr);
extern int get_or_create_client_record(JCR *jcr);
extern void run_job(JCR *jcr);
/* next_vol.c */
int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, bool create);
bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr);
-void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, char **reason);
+void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **reason);
/* newvol.c */
bool newVolume(JCR *jcr, MEDIA_DBR *mr);
bool acl_access_ok(UAContext *ua, int acl, char *item, int len);
/* ua_cmds.c */
-int do_a_command(UAContext *ua, char *cmd);
-int do_a_dot_command(UAContext *ua, char *cmd);
-int qmessagescmd(UAContext *ua, char *cmd);
+int do_a_command(UAContext *ua, const char *cmd);
+int do_a_dot_command(UAContext *ua, const char *cmd);
+int qmessagescmd(UAContext *ua, const char *cmd);
int open_db(UAContext *ua);
void close_db(UAContext *ua);
enum e_pool_op {
void set_pool_dbr_defaults_in_media_dbr(MEDIA_DBR *mr, POOL_DBR *pr);
/* ua_input.c */
-int get_cmd(UAContext *ua, char *prompt);
-int get_pint(UAContext *ua, char *prompt);
-int get_yesno(UAContext *ua, char *prompt);
+int get_cmd(UAContext *ua, const char *prompt);
+int get_pint(UAContext *ua, const char *prompt);
+int get_yesno(UAContext *ua, const char *prompt);
void parse_ua_args(UAContext *ua);
/* ua_label.c */
-bool is_volume_name_legal(UAContext *ua, char *name);
+bool is_volume_name_legal(UAContext *ua, const char *name);
/* ua_output.c */
-void prtit(void *ctx, char *msg);
+void prtit(void *ctx, const char *msg);
int complete_jcr_for_job(JCR *jcr, JOB *job, POOL *pool);
RUN *find_next_run(RUN *run, JOB *job, time_t &runtime);
/* ua_server.c */
-void bsendmsg(void *sock, char *fmt, ...);
+void bsendmsg(void *sock, const char *fmt, ...);
UAContext *new_ua_context(JCR *jcr);
-JCR *new_control_jcr(char *base_name, int job_type);
+JCR *new_control_jcr(const char *base_name, int job_type);
void free_ua_context(UAContext *ua);
/* ua_select.c */
int select_pool_dbr(UAContext *ua, POOL_DBR *pr);
int select_client_dbr(UAContext *ua, CLIENT_DBR *cr);
-void start_prompt(UAContext *ua, char *msg);
-void add_prompt(UAContext *ua, char *prompt);
-int do_prompt(UAContext *ua, char *automsg, char *msg, char *prompt, int max_prompt);
+void start_prompt(UAContext *ua, const char *msg);
+void add_prompt(UAContext *ua, const char *prompt);
+int do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt, int max_prompt);
CAT *get_catalog_resource(UAContext *ua);
STORE *get_storage_resource(UAContext *ua, int use_default);
int get_media_type(UAContext *ua, char *MediaType, int max_media);
CLIENT *get_client_resource(UAContext *ua);
int get_job_dbr(UAContext *ua, JOB_DBR *jr);
-int find_arg_keyword(UAContext *ua, char **list);
-int find_arg(UAContext *ua, char *keyword);
-int find_arg_with_value(UAContext *ua, char *keyword);
-int do_keyword_prompt(UAContext *ua, char *msg, char **list);
-int confirm_retention(UAContext *ua, utime_t *ret, char *msg);
+int find_arg_keyword(UAContext *ua, const char **list);
+int find_arg(UAContext *ua, const char *keyword);
+int find_arg_with_value(UAContext *ua, const char *keyword);
+int do_keyword_prompt(UAContext *ua, const char *msg, const char **list);
+int confirm_retention(UAContext *ua, utime_t *ret, const char *msg);
/* ua_tree.c */
bool user_select_files_from_tree(TREE_CTX *tree);
{
struct s_oldest_ctx oldest;
POOLMEM *query = get_pool_memory(PM_EMSG);
- char *select =
+ const char *select =
"SELECT MediaId,LastWritten FROM Media "
"WHERE PoolId=%u AND Recycle=1 AND VolStatus='Purged' "
"AND MediaType='%s' %s"
/* Send restore command */
char replace, *where;
-
+ char empty = '\0';
+
if (jcr->replace != 0) {
replace = jcr->replace;
} else if (jcr->job->replace != 0) {
} else if (jcr->job->RestoreWhere) {
where = jcr->job->RestoreWhere; /* no override take from job */
} else {
- where = ""; /* None */
+ where = ∅ /* None */
}
jcr->prefix_links = jcr->job->PrefixLinks;
bash_spaces(where);
char sdt[MAX_TIME_LENGTH], edt[MAX_TIME_LENGTH];
char ec1[30], ec2[30], ec3[30];
char term_code[100], fd_term_msg[100], sd_term_msg[100];
- char *term_msg;
+ const char *term_msg;
int msg_type;
double kbps;
s_monthly,
s_hourly,
s_wom, /* 1st, 2nd, ...*/
- s_woy, /* week of year w00 - w53 */
+ s_woy /* week of year w00 - w53 */
};
struct s_keyw {
- char *name; /* keyword */
+ const char *name; /* keyword */
enum e_state state; /* parser state */
int code; /* state value */
};
/* Forward referenced subroutines */
static void find_runs();
static void add_job(JOB *job, RUN *run, time_t now, time_t runtime);
-static void dump_job(job_item *ji, char *msg);
+static void dump_job(job_item *ji, const char *msg);
/* Imported subroutines */
#endif
}
-static void dump_job(job_item *ji, char *msg)
+static void dump_job(job_item *ji, const char *msg)
{
#ifdef SCHED_DEBUG
char dt[MAX_TIME_LENGTH];
#include "dird.h"
/* For ua_cmds.c */
-char *list_pool = "SELECT * FROM Pool WHERE PoolId=%u";
+const char *list_pool = "SELECT * FROM Pool WHERE PoolId=%u";
/* ====== ua_prune.c */
-char *cnt_File = "SELECT count(*) FROM File WHERE JobId=%u";
-char *del_File = "DELETE FROM File WHERE JobId=%u";
-char *upd_Purged = "UPDATE Job Set PurgedFiles=1 WHERE JobId=%u";
-char *cnt_DelCand = "SELECT count(*) FROM DelCandidates";
-char *del_Job = "DELETE FROM Job WHERE JobId=%u";
-char *del_JobMedia = "DELETE FROM JobMedia WHERE JobId=%u";
-char *cnt_JobMedia = "SELECT count(*) FROM JobMedia WHERE MediaId=%u";
-char *sel_JobMedia = "SELECT JobId FROM JobMedia WHERE MediaId=%u";
+const char *cnt_File = "SELECT count(*) FROM File WHERE JobId=%u";
+const char *del_File = "DELETE FROM File WHERE JobId=%u";
+const char *upd_Purged = "UPDATE Job Set PurgedFiles=1 WHERE JobId=%u";
+const char *cnt_DelCand = "SELECT count(*) FROM DelCandidates";
+const char *del_Job = "DELETE FROM Job WHERE JobId=%u";
+const char *del_JobMedia = "DELETE FROM JobMedia WHERE JobId=%u";
+const char *cnt_JobMedia = "SELECT count(*) FROM JobMedia WHERE MediaId=%u";
+const char *sel_JobMedia = "SELECT JobId FROM JobMedia WHERE MediaId=%u";
/* Select JobIds for File deletion. */
-char *select_job =
+const char *select_job =
"SELECT JobId from Job "
"WHERE JobTDate<%s "
"AND ClientId=%u "
"AND PurgedFiles=0";
/* Delete temp tables and indexes */
-char *drop_deltabs[] = {
+const char *drop_deltabs[] = {
"DROP TABLE DelCandidates",
"DROP INDEX DelInx1",
NULL};
/* List of SQL commands to create temp table and indicies */
-char *create_deltabs[] = {
+const char *create_deltabs[] = {
"CREATE TABLE DelCandidates ("
#ifdef HAVE_MYSQL
"JobId INTEGER UNSIGNED NOT NULL, "
/* Fill candidates table with all Jobs subject to being deleted.
* This is used for pruning Jobs (first the files, then the Jobs).
*/
-char *insert_delcand =
+const char *insert_delcand =
"INSERT INTO DelCandidates "
"SELECT JobId,PurgedFiles,FileSetId,JobFiles,JobStatus FROM Job "
"WHERE Type='%c' "
* At the same time, we select "orphanned" jobs
* (i.e. no files, ...) for deletion.
*/
-char *select_backup_del =
+const char *select_backup_del =
"SELECT DelCandidates.JobId "
"FROM Job,DelCandidates "
"WHERE (JobTDate<%s AND ((DelCandidates.JobFiles=0) OR "
* more recent InitCatalog -- i.e. are not the only InitCatalog
* This is the list of Jobs to delete for a Verify Job.
*/
-char *select_verify_del =
+const char *select_verify_del =
"SELECT DelCandidates.JobId "
"FROM Job,DelCandidates "
"WHERE Job.JobTDate>%s "
/* Select Jobs from the DelCandidates table.
* This is the list of Jobs to delete for a Restore Job.
*/
-char *select_restore_del =
+const char *select_restore_del =
"SELECT DelCandidates.JobId "
"FROM Job,DelCandidates "
"WHERE Job.JobTDate>%s "
/* ======= ua_restore.c */
/* List last 20 Jobs */
-char *uar_list_jobs =
+const char *uar_list_jobs =
"SELECT JobId,Client.Name as Client,StartTime,Level as "
"JobLevel,JobFiles,JobBytes "
"FROM Client,Job WHERE Client.ClientId=Job.ClientId AND JobStatus='T' "
#ifdef HAVE_MYSQL
/* MYSQL IS NOT STANDARD SQL !!!!! */
/* List Jobs where a particular file is saved */
-char *uar_file =
+const char *uar_file =
"SELECT Job.JobId as JobId, Client.Name as Client, "
"CONCAT(Path.Path,Filename.Name) as Name, "
"StartTime,Type as JobType,JobFiles,JobBytes "
"AND Filename.Name='%s' LIMIT 20";
#else
/* List Jobs where a particular file is saved */
-char *uar_file =
+const char *uar_file =
"SELECT Job.JobId as JobId, Client.Name as Client, "
"Path.Path||Filename.Name as Name, "
"StartTime,Type as JobType,JobFiles,JobBytes "
* Find all files for a particular JobId and insert them into
* the tree during a restore.
*/
-char *uar_sel_files =
+const char *uar_sel_files =
"SELECT Path.Path,Filename.Name,FileIndex,JobId,LStat "
"FROM File,Filename,Path "
"WHERE File.JobId=%u AND Filename.FilenameId=File.FilenameId "
"AND Path.PathId=File.PathId";
-char *uar_del_temp = "DROP TABLE temp";
-char *uar_del_temp1 = "DROP TABLE temp1";
+const char *uar_del_temp = "DROP TABLE temp";
+const char *uar_del_temp1 = "DROP TABLE temp1";
-char *uar_create_temp =
+const char *uar_create_temp =
"CREATE TABLE temp ("
#ifdef HAVE_POSTGRESQL
"JobId INTEGER NOT NULL,"
"VolSessionTime INTEGER UNSIGNED)";
#endif
-char *uar_create_temp1 =
+const char *uar_create_temp1 =
"CREATE TABLE temp1 ("
#ifdef HAVE_POSTGRESQL
"JobId INTEGER NOT NULL,"
"JobTDate BIGINT UNSIGNED)";
#endif
-char *uar_last_full =
+const char *uar_last_full =
"INSERT INTO temp1 SELECT Job.JobId,JobTdate "
"FROM Client,Job,JobMedia,Media,FileSet WHERE Client.ClientId=%u "
"AND Job.ClientId=%u "
"%s"
"ORDER BY Job.JobTDate DESC LIMIT 1";
-char *uar_full =
+const char *uar_full =
"INSERT INTO temp SELECT Job.JobId,Job.JobTDate,"
" Job.ClientId,Job.Level,Job.JobFiles,"
" StartTime,VolumeName,JobMedia.StartFile,VolSessionId,VolSessionTime "
"AND JobMedia.JobId=Job.JobId "
"AND JobMedia.MediaId=Media.MediaId";
-char *uar_dif =
+const char *uar_dif =
"INSERT INTO temp SELECT Job.JobId,Job.JobTDate,Job.ClientId,"
"Job.Level,Job.JobFiles,Job.StartTime,Media.VolumeName,JobMedia.StartFile,"
"Job.VolSessionId,Job.VolSessionTime "
"%s"
"ORDER BY Job.JobTDate DESC LIMIT 1";
-char *uar_inc =
+const char *uar_inc =
"INSERT INTO temp SELECT Job.JobId,Job.JobTDate,Job.ClientId,"
"Job.Level,Job.JobFiles,Job.StartTime,Media.VolumeName,JobMedia.StartFile,"
"Job.VolSessionId,Job.VolSessionTime "
"AND FileSet.FileSet='%s' "
"%s";
-char *uar_list_temp =
+const char *uar_list_temp =
"SELECT JobId,Level,JobFiles,StartTime,VolumeName,StartFile,"
"VolSessionId,VolSessionTime FROM temp "
"ORDER BY StartTime ASC";
-char *uar_sel_jobid_temp = "SELECT JobId FROM temp";
+const char *uar_sel_jobid_temp = "SELECT JobId FROM temp";
-char *uar_sel_all_temp1 = "SELECT * FROM temp1";
+const char *uar_sel_all_temp1 = "SELECT * FROM temp1";
-char *uar_sel_all_temp = "SELECT * FROM temp";
+const char *uar_sel_all_temp = "SELECT * FROM temp";
/* Select FileSet names for this Client */
-char *uar_sel_fileset =
+const char *uar_sel_fileset =
"SELECT DISTINCT FileSet.FileSet FROM Job,"
"Client,FileSet WHERE Job.FileSetId=FileSet.FileSetId "
"AND Job.ClientId=%u AND Client.ClientId=%u "
"ORDER BY FileSet.FileSet";
/* Find MediaType used by this Job */
-char *uar_mediatype =
+const char *uar_mediatype =
"SELECT MediaType FROM JobMedia,Media WHERE JobMedia.JobId=%u "
"AND JobMedia.MediaId=Media.MediaId";
* Find JobId, FileIndex for a given path/file and date
* for use when inserting individual files into the tree.
*/
-char *uar_jobid_fileindex =
+const char *uar_jobid_fileindex =
"SELECT Job.JobId, File.FileIndex FROM Job,File,Path,Filename,Client "
"WHERE Job.JobId=File.JobId "
"AND Job.StartTime<'%s' "
extern char *list_pool;
/* Imported functions */
-extern int status_cmd(UAContext *ua, char *cmd);
-extern int list_cmd(UAContext *ua, char *cmd);
-extern int llist_cmd(UAContext *ua, char *cmd);
-extern int show_cmd(UAContext *ua, char *cmd);
-extern int messagescmd(UAContext *ua, char *cmd);
-extern int autodisplay_cmd(UAContext *ua, char *cmd);
-extern int gui_cmd(UAContext *ua, char *cmd);
-extern int sqlquerycmd(UAContext *ua, char *cmd);
-extern int querycmd(UAContext *ua, char *cmd);
-extern int run_cmd(UAContext *ua, char *cmd);
-extern int retentioncmd(UAContext *ua, char *cmd);
-extern int prunecmd(UAContext *ua, char *cmd);
-extern int purgecmd(UAContext *ua, char *cmd);
-extern int restore_cmd(UAContext *ua, char *cmd);
-extern int label_cmd(UAContext *ua, char *cmd);
-extern int relabel_cmd(UAContext *ua, char *cmd);
+extern int status_cmd(UAContext *ua, const char *cmd);
+extern int list_cmd(UAContext *ua, const char *cmd);
+extern int llist_cmd(UAContext *ua, const char *cmd);
+extern int show_cmd(UAContext *ua, const char *cmd);
+extern int messagescmd(UAContext *ua, const char *cmd);
+extern int autodisplay_cmd(UAContext *ua, const char *cmd);
+extern int gui_cmd(UAContext *ua, const char *cmd);
+extern int sqlquerycmd(UAContext *ua, const char *cmd);
+extern int querycmd(UAContext *ua, const char *cmd);
+extern int run_cmd(UAContext *ua, const char *cmd);
+extern int retentioncmd(UAContext *ua, const char *cmd);
+extern int prunecmd(UAContext *ua, const char *cmd);
+extern int purgecmd(UAContext *ua, const char *cmd);
+extern int restore_cmd(UAContext *ua, const char *cmd);
+extern int label_cmd(UAContext *ua, const char *cmd);
+extern int relabel_cmd(UAContext *ua, const char *cmd);
extern int update_slots(UAContext *ua); /* ua_label.c */
/* Forward referenced functions */
-static int add_cmd(UAContext *ua, char *cmd);
-static int create_cmd(UAContext *ua, char *cmd);
-static int cancel_cmd(UAContext *ua, char *cmd);
-static int setdebug_cmd(UAContext *ua, char *cmd);
-static int trace_cmd(UAContext *ua, char *cmd);
-static int var_cmd(UAContext *ua, char *cmd);
-static int estimate_cmd(UAContext *ua, char *cmd);
-static int help_cmd(UAContext *ua, char *cmd);
-static int delete_cmd(UAContext *ua, char *cmd);
-static int use_cmd(UAContext *ua, char *cmd), unmount_cmd(UAContext *ua, char *cmd);
-static int version_cmd(UAContext *ua, char *cmd), automount_cmd(UAContext *ua, char *cmd);
-static int time_cmd(UAContext *ua, char *cmd);
-static int reload_cmd(UAContext *ua, char *cmd);
+static int add_cmd(UAContext *ua, const char *cmd);
+static int create_cmd(UAContext *ua, const char *cmd);
+static int cancel_cmd(UAContext *ua, const char *cmd);
+static int setdebug_cmd(UAContext *ua, const char *cmd);
+static int trace_cmd(UAContext *ua, const char *cmd);
+static int var_cmd(UAContext *ua, const char *cmd);
+static int estimate_cmd(UAContext *ua, const char *cmd);
+static int help_cmd(UAContext *ua, const char *cmd);
+static int delete_cmd(UAContext *ua, const char *cmd);
+static int use_cmd(UAContext *ua, const char *cmd);
+static int unmount_cmd(UAContext *ua, const char *cmd);
+static int version_cmd(UAContext *ua, const char *cmd);
+static int automount_cmd(UAContext *ua, const char *cmd);
+static int time_cmd(UAContext *ua, const char *cmd);
+static int reload_cmd(UAContext *ua, const char *cmd);
static int update_volume(UAContext *ua);
static int update_pool(UAContext *ua);
static int delete_volume(UAContext *ua);
static int delete_pool(UAContext *ua);
static int delete_job(UAContext *ua);
-static int mount_cmd(UAContext *ua, char *cmd);
-static int release_cmd(UAContext *ua, char *cmd);
-static int update_cmd(UAContext *ua, char *cmd);
-static int wait_cmd(UAContext *ua, char *cmd);
-static int setip_cmd(UAContext *ua, char *cmd);
+static int mount_cmd(UAContext *ua, const char *cmd);
+static int release_cmd(UAContext *ua, const char *cmd);
+static int update_cmd(UAContext *ua, const char *cmd);
+static int wait_cmd(UAContext *ua, const char *cmd);
+static int setip_cmd(UAContext *ua, const char *cmd);
-int quit_cmd(UAContext *ua, char *cmd);
+int quit_cmd(UAContext *ua, const char *cmd);
-struct cmdstruct { char *key; int (*func)(UAContext *ua, char *cmd); char *help; };
+struct cmdstruct { const char *key; int (*func)(UAContext *ua, const char *cmd); const char *help; };
static struct cmdstruct commands[] = {
{ N_("add"), add_cmd, _("add media to a pool")},
{ N_("autodisplay"), autodisplay_cmd, _("autodisplay [on/off] -- console messages")},
/*
* Execute a command from the UA
*/
-int do_a_command(UAContext *ua, char *cmd)
+int do_a_command(UAContext *ua, const char *cmd)
{
unsigned int i;
int len, stat;
/*
* Add Volumes to an existing Pool
*/
-static int add_cmd(UAContext *ua, char *cmd)
+static int add_cmd(UAContext *ua, const char *cmd)
{
POOL_DBR pr;
MEDIA_DBR mr;
* automount on
* automount off
*/
-int automount_cmd(UAContext *ua, char *cmd)
+int automount_cmd(UAContext *ua, const char *cmd)
{
char *onoff;
/*
* Cancel a job
*/
-static int cancel_cmd(UAContext *ua, char *cmd)
+static int cancel_cmd(UAContext *ua, const char *cmd)
{
int i, ret;
int njobs = 0;
* Create a Pool Record in the database.
* It is always created from the Resource record.
*/
-static int create_cmd(UAContext *ua, char *cmd)
+static int create_cmd(UAContext *ua, const char *cmd)
{
POOL *pool;
* if the Console name is the same as the Client name
* and the Console can access the client.
*/
-static int setip_cmd(UAContext *ua, char *cmd)
+static int setip_cmd(UAContext *ua, const char *cmd)
{
CLIENT *client;
if (!ua->cons || !acl_access_ok(ua, Client_ACL, ua->cons->hdr.name)) {
* update slots [scan=...]
* updates autochanger slots
*/
-static int update_cmd(UAContext *ua, char *cmd)
+static int update_cmd(UAContext *ua, const char *cmd)
{
- static char *kw[] = {
+ static const char *kw[] = {
N_("media"), /* 0 */
N_("volume"), /* 1 */
N_("pool"), /* 2 */
return 1;
}
-static void update_volstatus(UAContext *ua, char *val, MEDIA_DBR *mr)
+static void update_volstatus(UAContext *ua, const char *val, MEDIA_DBR *mr)
{
POOLMEM *query = get_pool_memory(PM_MESSAGE);
- char *kw[] = {
+ const char *kw[] = {
"Append",
"Archive",
"Disabled",
POOLMEM *query;
char ed1[30];
bool done = false;
- char *kw[] = {
+ const char *kw[] = {
N_("VolStatus"), /* 0 */
N_("VolRetention"), /* 1 */
N_("VolUse"), /* 2 */
/*
* setdebug level=nn all trace=1/0
*/
-static int setdebug_cmd(UAContext *ua, char *cmd)
+static int setdebug_cmd(UAContext *ua, const char *cmd)
{
STORE *store;
CLIENT *client;
/*
* Turn debug tracing to file on/off
*/
-static int trace_cmd(UAContext *ua, char *cmd)
+static int trace_cmd(UAContext *ua, const char *cmd)
{
char *onoff;
}
-static int var_cmd(UAContext *ua, char *cmd)
+static int var_cmd(UAContext *ua, const char *cmd)
{
POOLMEM *val = get_pool_memory(PM_FNAME);
char *var;
return 1;
}
-static int estimate_cmd(UAContext *ua, char *cmd)
+static int estimate_cmd(UAContext *ua, const char *cmd)
{
JOB *job = NULL;
CLIENT *client = NULL;
/*
* print time
*/
-static int time_cmd(UAContext *ua, char *cmd)
+static int time_cmd(UAContext *ua, const char *cmd)
{
char sdt[50];
time_t ttime = time(NULL);
*/
extern void reload_config(int sig);
-static int reload_cmd(UAContext *ua, char *cmd)
+static int reload_cmd(UAContext *ua, const char *cmd)
{
reload_config(1);
return 1;
* delete volume pool=<pool-name> volume=<name>
* delete job jobid=xxx
*/
-static int delete_cmd(UAContext *ua, char *cmd)
+static int delete_cmd(UAContext *ua, const char *cmd)
{
- static char *keywords[] = {
+ static const char *keywords[] = {
N_("volume"),
N_("pool"),
N_("job"),
}
-static void do_mount_cmd(UAContext *ua, char *command)
+static void do_mount_cmd(UAContext *ua, const char *command)
{
STORE *store;
BSOCK *sd;
/*
* mount [storage | device] <name>
*/
-static int mount_cmd(UAContext *ua, char *cmd)
+static int mount_cmd(UAContext *ua, const char *cmd)
{
do_mount_cmd(ua, "mount"); /* mount */
return 1;
/*
* unmount [storage | device] <name>
*/
-static int unmount_cmd(UAContext *ua, char *cmd)
+static int unmount_cmd(UAContext *ua, const char *cmd)
{
do_mount_cmd(ua, "unmount"); /* unmount */
return 1;
/*
* release [storage | device] <name>
*/
-static int release_cmd(UAContext *ua, char *cmd)
+static int release_cmd(UAContext *ua, const char *cmd)
{
do_mount_cmd(ua, "release"); /* release */
return 1;
* Switch databases
* use catalog=<name>
*/
-static int use_cmd(UAContext *ua, char *cmd)
+static int use_cmd(UAContext *ua, const char *cmd)
{
CAT *oldcatalog, *catalog;
return 1;
}
-int quit_cmd(UAContext *ua, char *cmd)
+int quit_cmd(UAContext *ua, const char *cmd)
{
ua->quit = TRUE;
return 1;
/*
* Wait until no job is running
*/
-int wait_cmd(UAContext *ua, char *cmd)
+int wait_cmd(UAContext *ua, const char *cmd)
{
JCR *jcr;
bmicrosleep(0, 200000); /* let job actually start */
}
-static int help_cmd(UAContext *ua, char *cmd)
+static int help_cmd(UAContext *ua, const char *cmd)
{
unsigned int i;
return 1;
}
-static int version_cmd(UAContext *ua, char *cmd)
+static int version_cmd(UAContext *ua, const char *cmd)
{
bsendmsg(ua, "%s Version: " VERSION " (" BDATE ")\n", my_name);
return 1;
extern char my_name[];
/* Imported functions */
-extern int qmessagescmd(UAContext *ua, char *cmd);
-extern int quit_cmd(UAContext *ua, char *cmd);
+extern int qmessagescmd(UAContext *ua, const char *cmd);
+extern int quit_cmd(UAContext *ua, const char *cmd);
/* Forward referenced functions */
-static int diecmd(UAContext *ua, char *cmd);
-static int jobscmd(UAContext *ua, char *cmd);
-static int filesetscmd(UAContext *ua, char *cmd);
-static int clientscmd(UAContext *ua, char *cmd);
-static int msgscmd(UAContext *ua, char *cmd);
-static int poolscmd(UAContext *ua, char *cmd);
-static int storagecmd(UAContext *ua, char *cmd);
-static int defaultscmd(UAContext *ua, char *cmd);
-static int typescmd(UAContext *ua, char *cmd);
-static int levelscmd(UAContext *ua, char *cmd);
-
-struct cmdstruct { char *key; int (*func)(UAContext *ua, char *cmd); char *help; };
+static int diecmd(UAContext *ua, const char *cmd);
+static int jobscmd(UAContext *ua, const char *cmd);
+static int filesetscmd(UAContext *ua, const char *cmd);
+static int clientscmd(UAContext *ua, const char *cmd);
+static int msgscmd(UAContext *ua, const char *cmd);
+static int poolscmd(UAContext *ua, const char *cmd);
+static int storagecmd(UAContext *ua, const char *cmd);
+static int defaultscmd(UAContext *ua, const char *cmd);
+static int typescmd(UAContext *ua, const char *cmd);
+static int levelscmd(UAContext *ua, const char *cmd);
+
+struct cmdstruct { const char *key; int (*func)(UAContext *ua, const char *cmd); const char *help; };
static struct cmdstruct commands[] = {
{ N_(".die"), diecmd, NULL},
{ N_(".jobs"), jobscmd, NULL},
/*
* Execute a command from the UA
*/
-int do_a_dot_command(UAContext *ua, char *cmd)
+int do_a_dot_command(UAContext *ua, const char *cmd)
{
int i;
int len, stat;
/*
* Create segmentation fault
*/
-static int diecmd(UAContext *ua, char *cmd)
+static int diecmd(UAContext *ua, const char *cmd)
{
JCR *jcr = NULL;
int a;
return 0;
}
-static int jobscmd(UAContext *ua, char *cmd)
+static int jobscmd(UAContext *ua, const char *cmd)
{
JOB *job = NULL;
LockRes();
return 1;
}
-static int filesetscmd(UAContext *ua, char *cmd)
+static int filesetscmd(UAContext *ua, const char *cmd)
{
FILESET *fs = NULL;
LockRes();
return 1;
}
-static int clientscmd(UAContext *ua, char *cmd)
+static int clientscmd(UAContext *ua, const char *cmd)
{
CLIENT *client = NULL;
LockRes();
return 1;
}
-static int msgscmd(UAContext *ua, char *cmd)
+static int msgscmd(UAContext *ua, const char *cmd)
{
MSGS *msgs = NULL;
LockRes();
return 1;
}
-static int poolscmd(UAContext *ua, char *cmd)
+static int poolscmd(UAContext *ua, const char *cmd)
{
POOL *pool = NULL;
LockRes();
return 1;
}
-static int storagecmd(UAContext *ua, char *cmd)
+static int storagecmd(UAContext *ua, const char *cmd)
{
STORE *store = NULL;
LockRes();
}
-static int typescmd(UAContext *ua, char *cmd)
+static int typescmd(UAContext *ua, const char *cmd)
{
bsendmsg(ua, "Backup\n");
bsendmsg(ua, "Restore\n");
return 1;
}
-static int levelscmd(UAContext *ua, char *cmd)
+static int levelscmd(UAContext *ua, const char *cmd)
{
bsendmsg(ua, "Incremental\n");
bsendmsg(ua, "Full\n");
/*
* Return default values for a job
*/
-static int defaultscmd(UAContext *ua, char *cmd)
+static int defaultscmd(UAContext *ua, const char *cmd)
{
JOB *job;
if (ua->argc == 2 && strcmp(ua->argk[1], "job") == 0) {
/* Exported functions */
-int get_cmd(UAContext *ua, char *prompt)
+int get_cmd(UAContext *ua, const char *prompt)
{
BSOCK *sock = ua->UA_sock;
int stat;
* Returns: 0 if failure
* 1 if success => value in ua->pint32_val
*/
-int get_pint(UAContext *ua, char *prompt)
+int get_pint(UAContext *ua, const char *prompt)
{
double dval;
ua->pint32_val = 0;
* 1 if success => ua->pint32_val == 1 for yes
* ua->pint32_val == 0 for no
*/
-int get_yesno(UAContext *ua, char *prompt)
+int get_yesno(UAContext *ua, const char *prompt)
{
int len;
/* Forward referenced functions */
-static int do_label(UAContext *ua, char *cmd, int relabel);
+static int do_label(UAContext *ua, const char *cmd, int relabel);
static void label_from_barcodes(UAContext *ua);
static int send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr,
POOL_DBR *pr, int relabel, bool media_record_exits);
*
* label storage=xxx volume=vvv
*/
-int label_cmd(UAContext *ua, char *cmd)
+int label_cmd(UAContext *ua, const char *cmd)
{
return do_label(ua, cmd, 0); /* standard label */
}
-int relabel_cmd(UAContext *ua, char *cmd)
+int relabel_cmd(UAContext *ua, const char *cmd)
{
return do_label(ua, cmd, 1); /* relabel tape */
}
static bool get_user_slot_list(UAContext *ua, char *slot_list, int num_slots)
{
int i;
- char *msg;
+ const char *msg;
for (int i=0; i<num_slots; i++) {
slot_list[i] = 0;
/*
* Common routine for both label and relabel
*/
-static int do_label(UAContext *ua, char *cmd, int relabel)
+static int do_label(UAContext *ua, const char *cmd, int relabel)
{
STORE *store;
BSOCK *sd;
int ok = FALSE;
int i;
bool media_record_exists = false;
- static char *barcode_keyword[] = {
+ static const char *barcode_keyword[] = {
"barcode",
"barcodes",
NULL};
* Check if the Volume name has legal characters
* If ua is non-NULL send the message
*/
-bool is_volume_name_legal(UAContext *ua, char *name)
+bool is_volume_name_legal(UAContext *ua, const char *name)
{
int len;
- char *p;
- char *accept = ":.-_";
+ const char *p;
+ const char *accept = ":.-_";
/* Restrict the characters permitted in the Volume name */
for (p=name; *p; p++) {
/* Imported functions */
/* Forward referenced functions */
-static int do_list_cmd(UAContext *ua, char *cmd, e_list_type llist);
+static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist);
/*
* Turn auto display of console messages on/off
*/
-int autodisplay_cmd(UAContext *ua, char *cmd)
+int autodisplay_cmd(UAContext *ua, const char *cmd)
{
- static char *kw[] = {
+ static const char *kw[] = {
N_("on"),
N_("off"),
NULL};
/*
* Turn gui processing on/off
*/
-int gui_cmd(UAContext *ua, char *cmd)
+int gui_cmd(UAContext *ua, const char *cmd)
{
- static char *kw[] = {
+ static const char *kw[] = {
N_("on"),
N_("off"),
NULL};
-struct showstruct {char *res_name; int type;};
+struct showstruct {const char *res_name; int type;};
static struct showstruct reses[] = {
{N_("directors"), R_DIRECTOR},
{N_("clients"), R_CLIENT},
* show <resource-keyword-name>=<name> e.g. show director=HeadMan
*
*/
-int show_cmd(UAContext *ua, char *cmd)
+int show_cmd(UAContext *ua, const char *cmd)
{
int i, j, type, len;
int recurse;
*/
/* Do long or full listing */
-int llist_cmd(UAContext *ua, char *cmd)
+int llist_cmd(UAContext *ua, const char *cmd)
{
return do_list_cmd(ua, cmd, VERT_LIST);
}
/* Do short or summary listing */
-int list_cmd(UAContext *ua, char *cmd)
+int list_cmd(UAContext *ua, const char *cmd)
{
return do_list_cmd(ua, cmd, HORZ_LIST);
}
-static int do_list_cmd(UAContext *ua, char *cmd, e_list_type llist)
+static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
{
POOLMEM *VolumeName;
int jobid, n;
Vw(con_lock);
}
-void do_messages(UAContext *ua, char *cmd)
+void do_messages(UAContext *ua, const char *cmd)
{
char msg[2000];
int mlen;
}
-int qmessagescmd(UAContext *ua, char *cmd)
+int qmessagescmd(UAContext *ua, const char *cmd)
{
if (console_msg_pending && ua->auto_display_messages) {
do_messages(ua, cmd);
return 1;
}
-int messagescmd(UAContext *ua, char *cmd)
+int messagescmd(UAContext *ua, const char *cmd)
{
if (console_msg_pending) {
do_messages(ua, cmd);
/*
* Callback routine for "printing" database file listing
*/
-void prtit(void *ctx, char *msg)
+void prtit(void *ctx, const char *msg)
{
UAContext *ua = (UAContext *)ctx;
* agent, so we are being called from Bacula core. In
* that case direct the messages to the Job.
*/
-void bsendmsg(void *ctx, char *fmt, ...)
+void bsendmsg(void *ctx, const char *fmt, ...)
{
va_list arg_ptr;
UAContext *ua = (UAContext *)ctx;
* prune jobs (from) client=xxx
* prune volume=xxx
*/
-int prunecmd(UAContext *ua, char *cmd)
+int prunecmd(UAContext *ua, const char *cmd)
{
CLIENT *client;
POOL_DBR pr;
MEDIA_DBR mr;
int kw;
- static char *keywords[] = {
+ static const char *keywords[] = {
N_("Files"),
N_("Jobs"),
N_("Volume"),
#define MAX_DEL_LIST_LEN 1000000
-static char *select_jobsfiles_from_client =
+static const char *select_jobsfiles_from_client =
"SELECT JobId FROM Job "
"WHERE ClientId=%d "
"AND PurgedFiles=0";
-static char *select_jobs_from_client =
+static const char *select_jobs_from_client =
"SELECT JobId, PurgedFiles FROM Job "
"WHERE ClientId=%d";
*
* N.B. Not all above is implemented yet.
*/
-int purgecmd(UAContext *ua, char *cmd)
+int purgecmd(UAContext *ua, const char *cmd)
{
int i;
CLIENT *client;
MEDIA_DBR mr;
JOB_DBR jr;
- static char *keywords[] = {
+ static const char *keywords[] = {
N_("files"),
N_("jobs"),
N_("volume"),
NULL};
- static char *files_keywords[] = {
+ static const char *files_keywords[] = {
N_("Job"),
N_("JobId"),
N_("Client"),
N_("Volume"),
NULL};
- static char *jobs_keywords[] = {
+ static const char *jobs_keywords[] = {
N_("Client"),
N_("Volume"),
NULL};
* SQL statement possibly terminated by ;
* :next query prompt
*/
-int querycmd(UAContext *ua, char *cmd)
+int querycmd(UAContext *ua, const char *cmd)
{
FILE *fd = NULL;
POOLMEM *query = get_pool_memory(PM_MESSAGE);
/*
* Get general SQL query for Catalog
*/
-int sqlquerycmd(UAContext *ua, char *cmd)
+int sqlquerycmd(UAContext *ua, const char *cmd)
{
POOLMEM *query = get_pool_memory(PM_MESSAGE);
int len;
- char *msg;
+ const char *msg;
if (!open_db(ua)) {
free_pool_memory(query);
/* Imported functions */
-extern int run_cmd(UAContext *ua, char *cmd);
+extern int run_cmd(UAContext *ua, const char *cmd);
extern void print_bsr(UAContext *ua, RBSR *bsr);
/* Imported variables */
* Restore files
*
*/
-int restore_cmd(UAContext *ua, char *cmd)
+int restore_cmd(UAContext *ua, const char *cmd)
{
RESTORE_CTX rx; /* restore context */
JOB *job;
JOB_DBR jr;
bool done = false;
int i, j;
- char *list[] = {
+ const char *list[] = {
"List last 20 Jobs run",
"List Jobs where a given File is saved",
"Enter list of comma separated JobIds to select",
"Cancel",
NULL };
- char *kw[] = {
+ const char *kw[] = {
"jobid", /* 0 */
"current", /* 1 */
"before", /* 2 */
TREE_CTX tree;
JobId_t JobId, last_JobId;
char *p;
- char *nofname = "";
+ char empty = '\0';
+ char *nofname;
bool OK = true;
+ nofname = ∅
memset(&tree, 0, sizeof(TREE_CTX));
/*
* Build the directory tree containing JobIds user selected
* run <job-name> jobid=nn
*
*/
-int run_cmd(UAContext *ua, char *cmd)
+int run_cmd(UAContext *ua, const char *cmd)
{
JCR *jcr;
char *job_name, *level_name, *jid, *store_name, *pool_name;
- char *where, *fileset_name, *client_name, *bootstrap, *replace;
+ char *where, *fileset_name, *client_name, *bootstrap;
+ const char *replace;
char *when, *verify_job_name;
int Priority = 0;
int i, j, opt, files = 0;
CLIENT *client = NULL;
FILESET *fileset = NULL;
POOL *pool = NULL;
- static char *kw[] = { /* command line arguments */
+ static const char *kw[] = { /* command line arguments */
N_("job"), /* Used in a switch() */
N_("jobid"), /* 1 */
N_("client"), /* 2 */
bstrutime(dt, sizeof(dt), jcr->sched_time),
jcr->JobPriority);
} else { /* JT_VERIFY */
- char *Name;
+ const char *Name;
if (jcr->job->verify_job) {
Name = jcr->job->verify_job->hdr.name;
} else {
/*
* Confirm a retention period
*/
-int confirm_retention(UAContext *ua, utime_t *ret, char *msg)
+int confirm_retention(UAContext *ua, utime_t *ret, const char *msg)
{
char ed1[30];
* Returns: -1 if not found
* index into list (base 0) on success
*/
-int find_arg_keyword(UAContext *ua, char **list)
+int find_arg_keyword(UAContext *ua, const char **list)
{
for (int i=1; i<ua->argc; i++) {
for(int j=0; list[j]; j++) {
* Returns: argk index (always gt 0)
* -1 if not found
*/
-int find_arg(UAContext *ua, char *keyword)
+int find_arg(UAContext *ua, const char *keyword)
{
for (int i=1; i<ua->argc; i++) {
if (strcasecmp(keyword, ua->argk[i]) == 0) {
* Returns: -1 if not found or no value
* list index (base 0) on success
*/
-int find_arg_with_value(UAContext *ua, char *keyword)
+int find_arg_with_value(UAContext *ua, const char *keyword)
{
for (int i=1; i<ua->argc; i++) {
if (strcasecmp(keyword, ua->argk[i]) == 0) {
* Returns: -1 on failure
* index into list (base 0) on success
*/
-int do_keyword_prompt(UAContext *ua, char *msg, char **list)
+int do_keyword_prompt(UAContext *ua, const char *msg, const char **list)
{
int i;
start_prompt(ua, _("You have the following choices:\n"));
/*
* Implement unique set of prompts
*/
-void start_prompt(UAContext *ua, char *msg)
+void start_prompt(UAContext *ua, const char *msg)
{
if (ua->max_prompts == 0) {
ua->max_prompts = 10;
/*
* Add to prompts -- keeping them unique
*/
-void add_prompt(UAContext *ua, char *prompt)
+void add_prompt(UAContext *ua, const char *prompt)
{
int i;
if (ua->num_prompts == ua->max_prompts) {
* index base 0 on success, and choice
* is copied to prompt if not NULL
*/
-int do_prompt(UAContext *ua, char *automsg, char *msg, char *prompt, int max_prompt)
+int do_prompt(UAContext *ua, const char *automsg, const char *msg, char *prompt, int max_prompt)
{
int i, item;
char pmsg[MAXSTRING];
* Create a Job Control Record for a control "job",
* filling in all the appropriate fields.
*/
-JCR *new_control_jcr(char *base_name, int job_type)
+JCR *new_control_jcr(const char *base_name, int job_type)
{
JCR *jcr;
jcr = new_jcr(sizeof(JCR), dird_free_jcr);
static void list_terminated_jobs(UAContext *ua);
static void do_storage_status(UAContext *ua, STORE *store);
static void do_client_status(UAContext *ua, CLIENT *client);
-static void do_director_status(UAContext *ua, char *cmd);
-static void do_all_status(UAContext *ua, char *cmd);
+static void do_director_status(UAContext *ua);
+static void do_all_status(UAContext *ua);
/*
* status command
*/
-int status_cmd(UAContext *ua, char *cmd)
+int status_cmd(UAContext *ua, const char *cmd)
{
STORE *store;
CLIENT *client;
for (i=1; i<ua->argc; i++) {
if (strcasecmp(ua->argk[i], _("all")) == 0) {
- do_all_status(ua, cmd);
+ do_all_status(ua);
return 1;
} else if (strcasecmp(ua->argk[i], _("dir")) == 0 ||
strcasecmp(ua->argk[i], _("director")) == 0) {
- do_director_status(ua, cmd);
+ do_director_status(ua);
return 1;
} else if (strcasecmp(ua->argk[i], _("client")) == 0) {
client = get_client_resource(ua);
}
/* If no args, ask for status type */
if (ua->argc == 1) {
+ char prmt[MAX_NAME_LENGTH];
+
start_prompt(ua, _("Status available for:\n"));
add_prompt(ua, _("Director"));
add_prompt(ua, _("Storage"));
add_prompt(ua, _("Client"));
add_prompt(ua, _("All"));
Dmsg0(20, "do_prompt: select daemon\n");
- if ((item=do_prompt(ua, "", _("Select daemon type for status"), cmd, MAX_NAME_LENGTH)) < 0) {
+ if ((item=do_prompt(ua, "", _("Select daemon type for status"), prmt, sizeof(prmt))) < 0) {
return 1;
}
Dmsg1(20, "item=%d\n", item);
switch (item) {
case 0: /* Director */
- do_director_status(ua, cmd);
+ do_director_status(ua);
break;
case 1:
store = select_storage_resource(ua);
}
break;
case 3:
- do_all_status(ua, cmd);
+ do_all_status(ua);
break;
default:
break;
return 1;
}
-static void do_all_status(UAContext *ua, char *cmd)
+static void do_all_status(UAContext *ua)
{
STORE *store, **unique_store;
CLIENT *client, **unique_client;
int i, j;
bool found;
- do_director_status(ua, cmd);
+ do_director_status(ua);
/* Count Storage items */
LockRes();
}
-static void do_director_status(UAContext *ua, char *cmd)
+static void do_director_status(UAContext *ua)
{
char dt[MAX_TIME_LENGTH];
static void prt_runtime(UAContext *ua, JOB *job, int level, time_t runtime, POOL *pool)
{
char dt[MAX_TIME_LENGTH];
- char *level_ptr;
+ const char *level_ptr;
bool ok = false;
bool close_db = false;
JCR *jcr = ua->jcr;
{
JCR *jcr;
int njobs = 0;
- char *msg;
+ const char *msg;
+ char *emsg; /* edited message */
char dt[MAX_TIME_LENGTH];
char level[10];
bool pool_mem = false;
msg = _("has been canceled");
break;
case JS_WaitFD:
- msg = (char *) get_pool_memory(PM_FNAME);
- Mmsg(&msg, _("is waiting on Client %s"), jcr->client->hdr.name);
+ emsg = (char *) get_pool_memory(PM_FNAME);
+ Mmsg(&emsg, _("is waiting on Client %s"), jcr->client->hdr.name);
pool_mem = true;
+ msg = emsg;
break;
case JS_WaitSD:
- msg = (char *) get_pool_memory(PM_FNAME);
- Mmsg(&msg, _("is waiting on Storage %s"), jcr->store->hdr.name);
+ emsg = (char *) get_pool_memory(PM_FNAME);
+ Mmsg(&emsg, _("is waiting on Storage %s"), jcr->store->hdr.name);
pool_mem = true;
+ msg = emsg;
break;
case JS_WaitStoreRes:
msg = _("is waiting on max Storage jobs");
break;
default:
- msg = (char *) get_pool_memory(PM_FNAME);
- Mmsg(&msg, _("is in unknown state %c"), jcr->JobStatus);
+ emsg = (char *) get_pool_memory(PM_FNAME);
+ Mmsg(&emsg, _("is in unknown state %c"), jcr->JobStatus);
pool_mem = true;
+ msg = emsg;
break;
}
/*
switch (jcr->SDJobStatus) {
case JS_WaitMount:
if (pool_mem) {
- free_pool_memory(msg);
+ free_pool_memory(emsg);
pool_mem = false;
}
msg = _("is waiting for a mount request");
break;
case JS_WaitMedia:
if (pool_mem) {
- free_pool_memory(msg);
+ free_pool_memory(emsg);
pool_mem = false;
}
msg = _("is waiting for an appendable Volume");
break;
case JS_WaitFD:
if (!pool_mem) {
- msg = (char *) get_pool_memory(PM_FNAME);
+ emsg = (char *) get_pool_memory(PM_FNAME);
pool_mem = true;
}
- Mmsg(&msg, _("is waiting for Client %s to connect to Storage %s"),
+ Mmsg(&emsg, _("is waiting for Client %s to connect to Storage %s"),
jcr->client->hdr.name, jcr->store->hdr.name);
+ msg = emsg;
break;
}
switch (jcr->JobType) {
msg);
if (pool_mem) {
- free_pool_memory(msg);
+ free_pool_memory(emsg);
pool_mem = false;
}
free_locked_jcr(jcr);
bsendmsg(ua, _("========================================================================\n"));
foreach_dlist(je, last_jobs) {
char JobName[MAX_NAME_LENGTH];
- char *termstat;
+ const char *termstat;
bstrftime_nc(dt, sizeof(dt), je->end_time);
switch (je->JobType) {
static int donecmd(UAContext *ua, TREE_CTX *tree);
-struct cmdstruct { char *key; int (*func)(UAContext *ua, TREE_CTX *tree); char *help; };
+struct cmdstruct { const char *key; int (*func)(UAContext *ua, TREE_CTX *tree); const char *help; };
static struct cmdstruct commands[] = {
{ N_("cd"), cdcmd, _("change current directory")},
{ N_("count"), countcmd, _("count marked files in and below the cd")},
for (int i=1; i < ua->argc; i++) {
for (TREE_NODE *node=first_tree_node(tree->root); node; node=next_tree_node(node)) {
if (fnmatch(ua->argk[i], node->fname, 0) == 0) {
- char *tag;
+ const char *tag;
tree_getpath(node, cwd, sizeof(cwd));
if (node->extract) {
tag = "*";
}
for (node = tree->node->child; node; node=node->sibling) {
if (ua->argc == 1 || fnmatch(ua->argk[1], node->fname, 0) == 0) {
- char *tag;
+ const char *tag;
if (node->extract) {
tag = "*";
} else if (node->extract_dir) {
for (node = node->child; node; node=node->sibling) {
if ((ua->argc == 1 || fnmatch(ua->argk[1], node->fname, 0) == 0) &&
(node->extract || node->extract_dir)) {
- char *tag;
+ const char *tag;
if (node->extract) {
tag = "*";
} else if (node->extract_dir) {
/*
* This is actually the long form used for "dir"
*/
-static void ls_output(char *buf, char *fname, char *tag, struct stat *statp)
+static void ls_output(char *buf, const char *fname, const char *tag, struct stat *statp)
{
- char *p, *f;
+ char *p;
+ const char *f;
char ec1[30];
int n;
return 1;
}
for (node = tree->node->child; node; node=node->sibling) {
- char *tag;
+ const char *tag;
if (ua->argc == 1 || fnmatch(ua->argk[1], node->fname, 0) == 0) {
if (node->extract) {
tag = "*";
*/
int do_verify(JCR *jcr)
{
- char *level, *Name;
+ const char *level, *Name;
BSOCK *fd;
JOB_DBR jr, verify_jr;
JobId_t verify_jobid = 0;
char sdt[50], edt[50];
char ec1[30];
char term_code[100], fd_term_msg[100], sd_term_msg[100];
- char *term_msg;
+ const char *term_msg;
int msg_type;
JobId_t JobId;
- char *Name;
+ const char *Name;
// Dmsg1(100, "Enter verify_cleanup() TermCod=%d\n", TermCode);
/* Dump contents of resource */
-void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ...), void *sock)
+void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock)
{
URES *res = (URES *)reshdr;
int recurse = 1;
/* Exported functions */
struct s_cmds {
- char *cmd;
+ const char *cmd;
int (*func)(JCR *);
};
FILE *bs;
char buf[2000];
BSOCK *sd = jcr->store_bsock;
- char *bootstrap = "bootstrap\n";
+ const char *bootstrap = "bootstrap\n";
int stat = 0;
Dmsg1(400, "send_bootstrap_file: %s\n", jcr->RestoreBootstrap);
/* Forward referenced functions */
static void list_terminated_jobs(void sendit(const char *msg, int len, void *sarg), void *arg);
static void bsock_sendit(const char *msg, int len, void *arg);
-static char *level_to_str(int level);
+static const char *level_to_str(int level);
#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
sendit(msg, strlen(msg), arg);
foreach_dlist(je, last_jobs) {
char JobName[MAX_NAME_LENGTH];
- char *termstat;
+ const char *termstat;
char buf[1000];
bstrftime_nc(dt, sizeof(dt), je->end_time);
/*
* Convert Job Level into a string
*/
-static char *level_to_str(int level)
+static const char *level_to_str(int level)
{
- char *str;
+ const char *str;
switch (level) {
case L_BASE:
char *bac_status(int stat)
{
JCR *njcr;
- char *termstat = _("Bacula Idle");
+ const char *termstat = _("Bacula Idle");
struct s_last_job *job;
bacstat = 0;
/*
* Add a filename to list of included files
*/
-void add_fname_to_include_list(FF_PKT *ff, int prefixed, char *fname)
+void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname)
{
int len, j;
struct s_included_file *inc;
char *p;
+ const char *rp;
len = strlen(fname);
/* prefixed = preceded with options */
if (prefixed) {
- for (p=fname; *p && *p != ' '; p++) {
- switch (*p) {
+ for (rp=fname; *rp && *rp != ' '; rp++) {
+ switch (*rp) {
case 'a': /* alway replace */
case '0': /* no option */
break;
break;
case 'V': /* verify options */
/* Copy Verify Options */
- for (j=0; *p && *p != ':'; p++) {
- inc->VerifyOpts[j] = *p;
+ for (j=0; *rp && *rp != ':'; rp++) {
+ inc->VerifyOpts[j] = *rp;
if (j < (int)sizeof(inc->VerifyOpts) - 1) {
j++;
}
break;
case 'Z': /* gzip compression */
inc->options |= FO_GZIP;
- inc->level = *++p - '0';
+ inc->level = *++rp - '0';
Dmsg1(200, "Compression level=%d\n", inc->level);
break;
default:
- Emsg1(M_ERROR, 0, "Unknown include/exclude option: %c\n", *p);
+ Emsg1(M_ERROR, 0, "Unknown include/exclude option: %c\n", *rp);
break;
}
}
/* Skip past space(s) */
- for ( ; *p == ' '; p++)
+ for ( ; *rp == ' '; rp++)
{}
} else {
- p = fname;
+ rp = fname;
}
- strcpy(inc->fname, p);
+ strcpy(inc->fname, rp);
p = inc->fname;
len = strlen(p);
/* Zap trailing slashes. */
* We add an exclude name to either the exclude path
* list or the exclude filename list.
*/
-void add_fname_to_exclude_list(FF_PKT *ff, char *fname)
+void add_fname_to_exclude_list(FF_PKT *ff, const char *fname)
{
int len;
struct s_excluded_file *exc, **list;
* file is included possibly with wild-cards.
*/
-int file_is_included(FF_PKT *ff, char *file)
+int file_is_included(FF_PKT *ff, const char *file)
{
struct s_included_file *inc = ff->included_files_list;
int len;
* Determine if the file is excluded or not.
*/
static int
-file_in_excluded_list(struct s_excluded_file *exc, char *file)
+file_in_excluded_list(struct s_excluded_file *exc, const char *file)
{
if (exc == NULL) {
Dmsg0(900, "exc is NULL\n");
* of an excluded directory.
*/
-int file_is_excluded(FF_PKT *ff, char *file)
+int file_is_excluded(FF_PKT *ff, const char *file)
{
- char *p;
+ const char *p;
if (win32_client && file[1] == ':') {
file += 2;
/* From match.c */
void init_include_exclude_files(FF_PKT *ff);
void term_include_exclude_files(FF_PKT *ff);
-void add_fname_to_include_list(FF_PKT *ff, int prefixed, char *fname);
-void add_fname_to_exclude_list(FF_PKT *ff, char *fname);
-int file_is_excluded(FF_PKT *ff, char *file);
-int file_is_included(FF_PKT *ff, char *file);
+void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname);
+void add_fname_to_exclude_list(FF_PKT *ff, const char *fname);
+int file_is_excluded(FF_PKT *ff, const char *file);
+int file_is_included(FF_PKT *ff, const char *file);
struct s_included_file *get_next_included_file(FF_PKT *ff,
struct s_included_file *inc);
}
-static char *get_combo_text(GtkWidget *dialog, char *combo_name)
+static char *get_combo_text(GtkWidget *dialog, const char *combo_name)
{
GtkWidget *combo;
combo = lookup_widget(dialog, combo_name);
return (char *)gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
}
-static char *get_entry_text(GtkWidget *dialog, char *entry_name)
+static char *get_entry_text(GtkWidget *dialog, const char *entry_name)
{
GtkWidget *entry;
entry = lookup_widget(dialog, entry_name);
return (char *)gtk_entry_get_text(GTK_ENTRY(entry));
}
-static char *get_spin_text(GtkWidget *dialog, char *spin_name)
+static char *get_spin_text(GtkWidget *dialog, const char *spin_name)
{
GtkSpinButton *spin;
spin = (GtkSpinButton *)lookup_widget(dialog, spin_name);
int no_signals = TRUE;
int test_config = FALSE;
int gargc = 1;
- char *gargv[2] = {"gnome-console", NULL};
+ const char *gargv[2] = {"gnome-console", NULL};
CONFONTRES *con_font;
init_stack_dump();
}
-static GList *get_and_fill_combo(GtkWidget *dialog, char *combo_name, char *cmd)
+static GList *get_and_fill_combo(GtkWidget *dialog, const char *combo_name, const char *cm)
{
GtkWidget *combo;
GList *options;
return options;
}
-static void fill_combo(GtkWidget *dialog, char *combo_name, GList *options)
+static void fill_combo(GtkWidget *dialog, const char *combo_name, GList *options)
{
GtkWidget *combo;
return 1;
}
-void write_director(gchar *msg)
+void write_director(const gchar *msg)
{
if (UA_sock) {
at_prompt = false;
gtk_text_iter_set_offset(&iter, len);
}
-void set_textf(char *fmt, ...)
+void set_textf(const char *fmt, ...)
{
va_list arg_ptr;
char buf[1000];
set_text(buf, len);
}
-void set_text(char *buf, int len)
+void set_text(const char *buf, int len)
{
GtkTextBuffer *textbuf;
GtkTextIter iter;
set_scroll_bar_to_end();
}
-void set_statusf(char *fmt, ...)
+void set_statusf(const char *fmt, ...)
{
va_list arg_ptr;
char buf[1000];
// set_scroll_bar_to_end();
}
-void set_status(char *buf)
+void set_status(const char *buf)
{
gtk_label_set_text(GTK_LABEL(status1), buf);
// set_scroll_bar_to_end();
#define OK 1
#define CANCEL 0
-void set_textf(char *fmt, ...);
-void set_text(char *buf, int len);
-void set_status(char *buf);
+void set_textf(const char *fmt, ...);
+void set_text(const char *buf, int len);
+void set_status(const char *buf);
void set_status_ready();
-void set_statusf(char *fmt, ...);
+void set_statusf(const char *fmt, ...);
int connect_to_director(gpointer data);
int disconnect_from_director(gpointer data);
void start_director_reader(gpointer data);
void stop_director_reader(gpointer data);
-void write_director(gchar *msg);
+void write_director(const gchar *msg);
void read_director(gpointer data, gint fd, GdkInputCondition condition);
void set_restore_dialog_defaults();
void select_restore_files();
/* Dump contents of resource */
-void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ...), void *sock)
+void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock)
{
URES *res = (URES *)reshdr;
int recurse = 1;
enum {
R_DIRECTOR = 1001,
R_CONSOLE,
- R_CONSOLE_FONT,
+ R_CONSOLE_FONT
};
#define R_FIRST R_DIRECTOR
#include "restore.h"
extern BSOCK *UA_sock;
-void write_director(gchar *msg);
+void write_director(const gchar *msg);
void start_director_reader(gpointer data);
void stop_director_reader(gpointer data);
/* Forward referenced subroutines */
-void FillDirectory(char *path, Window *window);
+void FillDirectory(const char *path, Window *window);
Window *new_window();
static void click_column_cb(GtkCList *item, gint column, Window *restore);
static void select_row_cb(GtkCList *item, gint row, gint column,
*/
void select_restore_setup()
{
- gchar *title[NUM_COLUMNS] = {"Mark", "File", "Mode", "User", "Group", "Size", "Date"};
+ const gchar *title[NUM_COLUMNS] = {"Mark", "File", "Mode", "User", "Group", "Size", "Date"};
restore_file_selection = create_restore_file_selection();
if (!restore_file_selection) {
"blank.xpm");
#endif
- restore->list = (GtkCList *)gtk_clist_new_with_titles(NUM_COLUMNS, title);
+ /* XXX: Stupid gtk_clist_set_selection_mode() has incorrect declaration of the title argument */
+ /* XXX: Workaround by typecast... peter@ifm.liu.se */
+
+ restore->list = (GtkCList *)gtk_clist_new_with_titles(NUM_COLUMNS, (gchar **) title);
gtk_clist_set_selection_mode(restore->list, GTK_SELECTION_EXTENDED);
gtk_clist_set_sort_column(restore->list, FILE_COLUMN);
gtk_clist_set_auto_sort(restore->list, true);
/*
* Fill the CList box with files at path
*/
-void FillDirectory(char *path, Window *restore)
+void FillDirectory(const char *path, Window *restore)
{
char pathbuf[MAXSTRING];
char modes[20], user[20], group[20], size[20], date[30];
* Convert a network "signal" code into
* human readable ASCII.
*/
-char *bnet_sig_to_ascii(BSOCK *bs)
+const char *bnet_sig_to_ascii(BSOCK *bs)
{
static char buf[30];
switch (bs->msglen) {
* This probably should be done in net_open
*/
BSOCK *
-init_bsock(JCR *jcr, int sockfd, const char *who, char *host, int port,
+init_bsock(JCR *jcr, int sockfd, const char *who, const char *host, int port,
struct sockaddr_in *client_addr)
{
BSOCK *bsock = (BSOCK *)malloc(sizeof(BSOCK));
struct in_addr bind_ip; /* address to bind to */
int tlog;
int turnon = 1;
- char *caller;
+ const char *caller;
#ifdef HAVE_LIBWRAP
struct request_info request;
#endif
if (strcmp(mp_chr(bs->msg), "1000 OK auth\n") == 0) {
return 1;
}
- Dmsg1(100, "PW: %s\n", password);
+ Dmsg1(100, "Bad response: %s\n", bs->msg);
bmicrosleep(5, 0);
return 0;
}
num_items++;
}
+/*
+ * Returns: item if item inserted
+ * other_item if same value already exists (item not inserted)
+ */
+void *dlist::binary_insert(void *item, int compare(void *item1, void *item2))
+{
+ int comp;
+ int low, high, cur;
+ void *cur_item;
+
+ if (num_items == 0) {
+ //Dmsg0(000, "Append first.\n");
+ append(item);
+ return item;
+ }
+ if (num_items == 1) {
+ comp = compare(item, first());
+ if (comp < 0) {
+ insert_before(item, first());
+ //Dmsg0(000, "Insert before first.\n");
+ return item;
+ } else if (comp > 0) {
+ insert_after(item, first());
+ //Dmsg0(000, "Insert after first.\n");
+ return item;
+ } else {
+ //Dmsg0(000, "Same as first.\n");
+ return first();
+ }
+ }
+ /* Check against last item */
+ comp = compare(item, last());
+ if (comp > 0) {
+ append(item);
+ //Dmsg0(000, "Appended item.\n");
+ return item;
+ } else if (comp == 0) {
+ //Dmsg0(000, "Same as last.\n");
+ return last();
+ }
+ /* Check against first item */
+ comp = compare(item, first());
+ if (comp < 0) {
+ insert_before(item, first());
+ //Dmsg0(000, "Inserted item before.\n");
+ return item;
+ } else if (comp == 0) {
+ //Dmsg0(000, "Same as first.\n");
+ return first();
+ }
+ if (num_items == 2) {
+ insert_after(item, first());
+ //Dmsg0(000, "Inserted item after.\n");
+ return item;
+ }
+ low = 1;
+ high = num_items;
+ cur = 1;
+ cur_item = first();
+ while (low < high) {
+ int nxt;
+ nxt = (low + high) / 2;
+ while (nxt > cur) {
+ cur_item = next(cur_item);
+ cur++;
+ }
+ while (nxt < cur) {
+ cur_item = prev(cur_item);
+ cur--;
+ }
+ //Dmsg1(000, "Compare item to %d\n", cur);
+ comp = compare(item, cur_item);
+ //Dmsg2(000, "Compare item to %d = %d\n", cur, comp);
+ if (comp < 0) {
+ high = cur;
+ //Dmsg2(000, "set high; low=%d high=%d\n", low, high);
+ } else if (comp > 0) {
+ low = cur + 1;
+ //Dmsg2(000, "set low; low=%d high=%d\n", low, high);
+ } else {
+ //Dmsg1(000, "Same as item %d\n", cur);
+ return cur_item;
+ }
+ }
+ if (high == cur) {
+ insert_before(item, cur_item);
+ //Dmsg1(000, "Insert before item %d\n", cur);
+ } else {
+ insert_after(item, cur_item);
+ //Dmsg1(000, "Insert after item %d\n", cur);
+ }
+ return item;
+}
+
void dlist::remove(void *item)
{
dlink link;
};
+static int my_compare(void *item1, void *item2)
+{
+ MYJCR *jcr1, *jcr2;
+ int comp;
+ jcr1 = (MYJCR *)item1;
+ jcr2 = (MYJCR *)item2;
+ comp = strcmp(jcr1->buf, jcr2->buf);
+ //Dmsg3(000, "compare=%d: %s to %s\n", comp, jcr1->buf, jcr2->buf);
+ return comp;
+}
+
int main()
{
char buf[30];
dlist *jcr_chain;
MYJCR *jcr = NULL;
+ MYJCR *jcr1;
MYJCR *save_jcr = NULL;
MYJCR *next_jcr;
delete jcr_chain;
+
+ /* Now do a binary insert for the list */
+ jcr_chain = new dlist(jcr, &jcr->link);
+#define CNT 26
+ printf("append %d items\n", CNT*CNT*CNT);
+ strcpy(buf, "ZZZ");
+ int count = 0;
+ for (int i=0; i<CNT; i++) {
+ for (int j=0; j<CNT; j++) {
+ for (int k=0; k<CNT; k++) {
+ count++;
+ if ((count & 0x3FF) == 0) {
+ Dmsg1(000, "At %d\n", count);
+ }
+ jcr = (MYJCR *)malloc(sizeof(MYJCR));
+ jcr->buf = bstrdup(buf);
+ jcr1 = (MYJCR *)jcr_chain->binary_insert(jcr, my_compare);
+ if (jcr != jcr1) {
+ Dmsg2(000, "Insert of %s vs %s failed.\n", jcr->buf, jcr1->buf);
+ }
+ buf[1]--;
+ }
+ buf[1] = 'Z';
+ buf[2]--;
+ }
+ buf[2] = 'Z';
+ buf[0]--;
+ }
+
+ printf("Print sorted list.\n");
+ foreach_dlist (jcr, jcr_chain) {
+ printf("Dlist item = %s\n", jcr->buf);
+ free(jcr->buf);
+ }
+
+ delete jcr_chain;
+
+
sm_dump(false);
}
#ifdef the_old_way
#define foreach_dlist(var, list) \
- for((var)=NULL; (((void *)(var))=(list)->next(var)); )
+ for((var)=NULL; (((void *)(var))=(list)->next(var)); )
#endif
struct dlink {
void append(void *item);
void insert_before(void *item, void *where);
void insert_after(void *item, void *where);
+ void *dlist::binary_insert(void *item, int compare(void *item1, void *item2));
void remove(void *item);
bool empty();
- int size();
+ int size();
void *next(void *item);
void *prev(void *item);
void destroy();
void operator delete(void *);
};
-/*
+/*
* This allows us to do explicit initialization,
* allowing us to mix C++ classes inside malloc'ed
* C structures. Define before called in constructor.
#ifdef DEBUG
-static char *pool_name(int pool)
+static const char *pool_name(int pool)
{
- static char *name[] = {"NoPool", "NAME ", "FNAME ", "MSG ", "EMSG "};
+ static const char *name[] = {"NoPool", "NAME ", "FNAME ", "MSG ", "EMSG "};
static char buf[30];
if (pool >= 0 && pool <= PM_MAX) {
* This is where we define "Globals" because all the
* daemons include this file.
*/
-char *working_directory = NULL; /* working directory path stored here */
+const char *working_directory = NULL; /* working directory path stored here */
int verbose = 0; /* increase User messages */
int debug_level = 0; /* debug level */
time_t daemon_start_time = 0; /* Daemon start time */
/* Initialize so that the console (User Agent) can
* receive messages -- stored in a file.
*/
-void init_console_msg(char *wd)
+void init_console_msg(const char *wd)
{
int fd;
static BPIPE *open_mail_pipe(JCR *jcr, POOLMEM **cmd, DEST *d)
{
BPIPE *bpipe;
-
- if (d->mail_cmd && jcr) {
+ int use_bsmtp = (d->mail_cmd && jcr);
+
+ if (use_bsmtp) {
*cmd = edit_job_codes(jcr, *cmd, d->mail_cmd, d->where);
} else {
+#if 1
+ Mmsg(cmd, "/usr/lib/sendmail -F Bacula %s", d->where);
+#else
Mmsg(cmd, "mail -s \"Bacula Message\" %s", d->where);
+#endif
}
fflush(stdout);
if (!(bpipe = open_bpipe(*cmd, 120, "rw"))) {
Jmsg(jcr, M_ERROR, 0, "open mail pipe %s failed: ERR=%s\n",
*cmd, strerror(errno));
- }
+ }
+
+#if 1
+ if (!use_bsmtp) {
+ fprintf(bpipe->wfd, "Subject: Bacula Message\r\n\r\n");
+ }
+#endif
+
return bpipe;
}
/* visual studio passes the whole path to the file as well
* which makes for very long lines
*/
- char *f = strrchr(file, '\\');
+ const char *f = strrchr(file, '\\');
if (f) file = f + 1;
len = bsnprintf(buf, sizeof(buf), "%s: %s:%d ", my_name, file, line);
} else {
extern int debug_level;
extern int verbose;
extern char my_name[];
-extern char *working_directory;
+extern const char *working_directory;
extern time_t daemon_start_time;
extern char catalog_db[];
/* Simply print a message */
-static void prtmsg(void *sock, char *fmt, ...)
+static void prtmsg(void *sock, const char *fmt, ...)
{
va_list arg_ptr;
RES *GetNextRes(int rcode, RES *res);
void b_LockRes(const char *file, int line);
void b_UnlockRes(const char *file, int line);
-void dump_resource(int type, RES *res, void sendmsg(void *sock, char *fmt, ...), void *sock);
+void dump_resource(int type, RES *res, void sendmsg(void *sock, const char *fmt, ...), void *sock);
void free_resource(RES *res, int type);
void init_resource(int type, RES_ITEM *item);
void save_resource(int type, RES_ITEM *item, int pass);
int max_retry_time, const char *name, char *host, char *service,
int port, int verbose);
void bnet_close (BSOCK *bsock);
-BSOCK * init_bsock (JCR *jcr, int sockfd, const char *who, char *ip,
+BSOCK * init_bsock (JCR *jcr, int sockfd, const char *who, const char *ip,
int port, struct sockaddr_in *client_addr);
BSOCK * dup_bsock (BSOCK *bsock);
void term_bsock (BSOCK *bsock);
char * bnet_strerror (BSOCK *bsock);
-char * bnet_sig_to_ascii (BSOCK *bsock);
+const char *bnet_sig_to_ascii (BSOCK *bsock);
int bnet_wait_data (BSOCK *bsock, int sec);
int bnet_wait_data_intr (BSOCK *bsock, int sec);
int bnet_despool_to_bsock (BSOCK *bsock, void update(ssize_t size), ssize_t size);
void rem_msg_dest (MSGS *msg, int dest, int type, char *where);
void Jmsg (JCR *jcr, int type, int level, const char *fmt, ...);
void dispatch_message (JCR *jcr, int type, int level, char *buf);
-void init_console_msg (char *wd);
+void init_console_msg (const char *wd);
void free_msgs_res (MSGS *msgs);
void dequeue_messages (JCR *jcr);
void set_trace (int trace_flag);
void strip_trailing_slashes (char *dir);
bool skip_spaces (char **msg);
bool skip_nonspaces (char **msg);
-int fstrsch (char *a, char *b);
+int fstrsch (const char *a, const char *b);
char *next_arg(char **s);
int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc,
char **argk, char **argv, int max_args);
int pm_strcat (POOLMEM **pm, const char *str);
int pm_strcpy (POOLMEM **pm, const char *str);
int run_program (char *prog, int wait, POOLMEM *results);
-char * job_type_to_str (int type);
-char * job_status_to_str (int stat);
-char * job_level_to_str (int level);
+const char * job_type_to_str (int type);
+const char * job_status_to_str (int stat);
+const char * job_level_to_str (int level);
void make_session_key (char *key, char *seed, int mode);
POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to);
void set_working_directory(char *wd);
/* folded search for string - case insensitive */
int
-fstrsch(char *a, char *b) /* folded case search */
+fstrsch(const char *a, const char *b) /* folded case search */
{
- register char *s1,*s2;
- register char c1, c2;
+ const char *s1,*s2;
+ char c1, c2;
s1=a;
s2=b;
*ptr += sizeof(float64_t);
}
-int serial_string(uint8_t * const ptr, char * const str)
+void serial_string(uint8_t * * const ptr, const char * const str)
{
- int len = strlen((const char *) str) + 1;
- memcpy(ptr, str, len);
- return len;
+ int len = strlen(str) + 1;
+
+ memcpy(*ptr, str, len);
+ *ptr += len;
}
return v;
}
-int unserial_string(uint8_t * const ptr, char * const str)
+void unserial_string(uint8_t * * const ptr, char * const str)
{
- int len = strlen((char *)ptr) + 1;
- memcpy(str, ptr, len);
- return len;
+ int len = strlen((char *) *ptr) + 1;
+ memcpy(str, (char *) *ptr, len);
+ *ptr += len;
}
extern void serial_uint64(uint8_t * * const ptr, const uint64_t v);
extern void serial_btime(uint8_t * * const ptr, const btime_t v);
extern void serial_float64(uint8_t * * const ptr, const float64_t v);
-extern int serial_string(uint8_t * const ptr, char * const str);
+extern void serial_string(uint8_t * * const ptr, const char * const str);
+
extern int16_t unserial_int16(uint8_t * * const ptr);
extern uint16_t unserial_uint16(uint8_t * * const ptr);
extern int32_t unserial_int32(uint8_t * * const ptr);
extern uint64_t unserial_uint64(uint8_t * * const ptr);
extern btime_t unserial_btime(uint8_t * * const ptr);
extern float64_t unserial_float64(uint8_t * * const ptr);
-extern int unserial_string(uint8_t * const ptr, char * const str);
+extern void unserial_string(uint8_t * * const ptr, char * const str);
/*
#define ser_buffer(x) ser_bytes((x), (sizeof (x)))
/* Binary string not requiring serialization */
-#define ser_string(x) ser_ptr += serial_string(ser_ptr, (x))
+#define ser_string(x) serial_string(&ser_ptr, (x))
/* Unserialisation */
#define unser_buffer(x) unser_bytes((x), (sizeof (x)))
/* Binary string not requiring serialization */
-#define unser_string(x) ser_ptr += unserial_string(ser_ptr, (x))
+#define unser_string(x) unserial_string(&ser_ptr, (x))
#endif /* __SERIAL_H_ */
*/
void jobstatus_to_ascii(int JobStatus, char *msg, int maxlen)
{
- char *jobstat;
+ const char *jobstat;
char buf[100];
switch (JobStatus) {
/*
* Convert Job Termination Status into a string
*/
-char *job_status_to_str(int stat)
+const char *job_status_to_str(int stat)
{
- char *str;
+ const char *str;
switch (stat) {
case JS_Terminated:
/*
* Convert Job Type into a string
*/
-char *job_type_to_str(int type)
+const char *job_type_to_str(int type)
{
- char *str;
+ const char *str;
switch (type) {
case JT_BACKUP:
/*
* Convert Job Level into a string
*/
-char *job_level_to_str(int level)
+const char *job_level_to_str(int level)
{
- char *str;
+ const char *str;
switch (level) {
case L_BASE:
POOLMEM *cmd;
BPIPE *bpipe;
char line[MAXSTRING];
- char *shellcmd;
+ const char *shellcmd;
/* Check if any meta characters are present */
len = strlen(meta);
{
/* sufficient integer buffer: <available-bits> x log_10(2) + safety */
char ibuf[((sizeof(int)*8)/3)+10];
- char *cp;
+ const char *cp;
char c;
int d;
int n;
};
/* translate a return code into its corresponding descriptive text */
-char *var_strerror(var_t *var, var_rc_t rc)
+const char *var_strerror(var_t *var, var_rc_t rc)
{
- char *str;
+ const char *str;
rc = (var_rc_t)(0 - rc);
if (rc < 0 || rc >= (int)sizeof(var_errors) / (int)sizeof(char *)) {
str = "unknown error";
char index_open; /* default: '[' */
char index_close; /* default: ']' */
char index_mark; /* default: '#' */
- char *name_chars; /* default: "a-zA-Z0-9_" */
+ const char *name_chars; /* default: "a-zA-Z0-9_" */
} var_syntax_t;
typedef var_rc_t (*var_cb_value_t)(
var_rc_t var_expand (var_t *var, const char *src_ptr, int src_len, char **dst_ptr, int *dst_len, int force_expand);
var_rc_t var_formatv (var_t *var, char **dst_ptr, int force_expand, const char *fmt, va_list ap);
var_rc_t var_format (var_t *var, char **dst_ptr, int force_expand, const char *fmt, ...);
-char *var_strerror (var_t *var, var_rc_t rc);
+const char *var_strerror (var_t *var, var_rc_t rc);
#endif /* __VAR_H__ */
int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev)
{
int stat = 0;
- char *msg;
+ const char *msg;
Dmsg0(130, "enter dir_ask_sysop_to_mount_volume\n");
if (!jcr->VolumeName[0]) {
#include "stored.h" /* pull in Storage Deamon headers */
/* Forward referenced functions */
-char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd);
+char *edit_device_codes(JCR *jcr, char *omsg, const char *imsg, const char *cmd);
static int get_autochanger_loaded_slot(JCR *jcr);
* cmd = command string (load, unload, ...)
*
*/
-char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd)
+char *edit_device_codes(JCR *jcr, char *omsg, const char *imsg, const char *cmd)
{
- char *p;
+ const char *p;
const char *str;
char add[20];
static JCR *in_jcr; /* input jcr */
static JCR *out_jcr; /* output jcr */
static BSR *bsr = NULL;
-static char *wd = "/tmp";
+static const char *wd = "/tmp";
static int list_records = 0;
static uint32_t records = 0;
static uint32_t jobs = 0;
* Dump the block header, then walk through
* the block printing out the record headers.
*/
-void dump_block(DEV_BLOCK *b, char *msg)
+void dump_block(DEV_BLOCK *b, const char *msg)
{
ser_declare;
char *p;
rec->Stream == STREAM_UNIX_ATTRIBUTES_EX) {
if (verbose > 1) {
- char *rtype = "Attributes";
+ const char *rtype = "Attributes";
Pmsg5(-1, "%s Record: VolSessionId=%d VolSessionTime=%d JobId=%d DataLen=%d\n",
rtype, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len);
}
static void get_session_record(DEVICE *dev, DEV_RECORD *rec, SESSION_LABEL *sessrec)
{
- char *rtype;
+ const char *rtype;
memset(sessrec, 0, sizeof(sessrec));
switch (rec->FileIndex) {
case PRE_LABEL:
static time_t lasttime = 0;
-static char *db_name = "bacula";
-static char *db_user = "bacula";
-static char *db_password = "";
-static char *db_host = NULL;
-static char *wd = NULL;
+static const char *db_name = "bacula";
+static const char *db_user = "bacula";
+static const char *db_password = "";
+static const char *db_host = NULL;
+static const char *wd = NULL;
static int update_db = 0;
static int update_vol_info = 0;
static int list_records = 0;
Pmsg1(000, _("Updated Job termination record for new JobId=%u\n"), jr->JobId);
}
if (verbose > 1) {
- char *term_msg;
+ const char *term_msg;
static char term_code[70];
char sdt[50], edt[50];
char ec1[30], ec2[30], ec3[30];
/* External subroutines */
extern void free_config_resources();
-extern char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd);
+extern char *edit_device_codes(JCR *jcr, char *omsg, const char *imsg, const char *cmd);
/* Exported variables */
int quit = 0;
static bool compare_blocks(DEV_BLOCK *last_block, DEV_BLOCK *block);
static int my_mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
static void scan_blocks();
-static void set_volume_name(char *VolName, int volnum);
+static void set_volume_name(const char *VolName, int volnum);
static void rawfill_cmd();
static void bfill_cmd();
static bool open_the_device();
static uint32_t BlockNumber = 0;
static bool simple = true;
-static char *VolumeName = NULL;
+static const char *VolumeName = NULL;
static int vol_num = 0;
static JCR *jcr = NULL;
static void usage();
static void terminate_btape(int sig);
-int get_cmd(char *prompt);
+int get_cmd(const char *prompt);
/*********************************************************************
}
-struct cmdstruct { char *key; void (*func)(); char *help; };
+struct cmdstruct { const char *key; void (*func)(); const char *help; };
static struct cmdstruct commands[] = {
{"autochanger", autochangercmd, "test autochanger"},
{"bsf", bsfcmd, "backspace file"},
* to have correct backspacing, etc.
*/
int
-get_cmd(char *prompt)
+get_cmd(const char *prompt)
{
int i = 0;
int ch;
return 1; /* next volume mounted */
}
-static void set_volume_name(char *VolName, int volnum)
+static void set_volume_name(const char *VolName, int volnum)
{
DCR *dcr = jcr->dcr;
VolumeName = VolName;
* cmd = command string (load, unload, ...)
*
*/
-static char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd)
+static char *edit_device_codes(JCR *jcr, char *omsg, const char *imsg, const char *cmd)
{
char *p;
const char *str;
* Setup a "daemon" JCR for the various standalone
* tools (e.g. bls, bextract, bscan, ...)
*/
-JCR *setup_jcr(char *name, char *device, BSR *bsr, char *VolumeName)
+JCR *setup_jcr(const char *name, const char *device, BSR *bsr, const char *VolumeName)
{
JCR *jcr = new_jcr(sizeof(JCR), my_free_jcr);
jcr->VolSessionId = 1;
void
clrerror_dev(DEVICE *dev, int func)
{
- char *msg = NULL;
+ const char *msg = NULL;
dev->dev_errno = errno; /* save errno */
if (errno == EIO) {
* must wait. The no_wait_id thread is out obtaining a new volume
* and preparing the label.
*/
-void _lock_device(char *file, int line, DEVICE *dev)
+void _lock_device(const char *file, int line, DEVICE *dev)
{
int stat;
Dmsg3(500, "lock %d from %s:%d\n", dev->dev_blocked, file, line);
return stat;
}
-void _unlock_device(char *file, int line, DEVICE *dev)
+void _unlock_device(const char *file, int line, DEVICE *dev)
{
Dmsg2(500, "unlock from %s:%d\n", file, line);
V(dev->mutex);
* the current thread can do slip through the lock_device()
* calls without blocking.
*/
-void _block_device(char *file, int line, DEVICE *dev, int state)
+void _block_device(const char *file, int line, DEVICE *dev, int state)
{
Dmsg3(500, "block set %d from %s:%d\n", state, file, line);
ASSERT(dev->dev_blocked == BST_NOT_BLOCKED);
/*
* Unblock the device, and wake up anyone who went to sleep.
*/
-void _unblock_device(char *file, int line, DEVICE *dev)
+void _unblock_device(const char *file, int line, DEVICE *dev)
{
Dmsg3(500, "unblock %d from %s:%d\n", dev->dev_blocked, file, line);
ASSERT(dev->dev_blocked);
* Enter with device locked and blocked
* Exit with device unlocked and blocked by us.
*/
-void _steal_device_lock(char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state)
+void _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state)
{
Dmsg4(500, "steal lock. old=%d new=%d from %s:%d\n", dev->dev_blocked, state,
file, line);
* Enter with device blocked by us but not locked
* Exit with device locked, and blocked by previous owner
*/
-void _give_back_device_lock(char *file, int line, DEVICE *dev, bsteal_lock_t *hold)
+void _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold)
{
Dmsg4(500, "return lock. old=%d new=%d from %s:%d\n",
dev->dev_blocked, hold->dev_blocked, file, line);
int Slot, int relabel);
struct s_cmds {
- char *cmd;
+ const char *cmd;
int (*func)(JCR *jcr);
};
static int bootstrap_cmd(JCR *jcr);
struct s_cmds {
- char *cmd;
+ const char *cmd;
int (*func)(JCR *jcr);
};
* Returns: 0 on error
* 1 on success
*/
-void create_volume_label(DEVICE *dev, char *VolName, char *PoolName)
+void create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName)
{
DEVRES *device = (DEVRES *)dev->device;
*
* This routine should be used only when labeling a blank tape.
*/
-int write_volume_label_to_dev(JCR *jcr, DEVRES *device, char *VolName, char *PoolName)
+int write_volume_label_to_dev(JCR *jcr, DEVRES *device, const char *VolName, const char *PoolName)
{
DEVICE *dev = device->dev;
DEV_RECORD rec;
{
int dbl = debug_level;
uint32_t File;
- char *LabelType, buf[30];
+ const char *LabelType;
+ char buf[30];
struct tm tm;
struct date_time dt;
}
-static void dump_session_label(DEV_RECORD *rec, char *type)
+static void dump_session_label(DEV_RECORD *rec, const char *type)
{
int dbl;
struct date_time dt;
void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose)
{
- char *type;
+ const char *type;
int dbl;
dbl = debug_level;
static bool is_positioning_ok(BSR *bsr);
struct kw_items {
- char *name;
+ const char *name;
ITEM_HANDLER *handler;
};
int authenticate_filed(JCR *jcr);
/* From block.c */
-void dump_block(DEV_BLOCK *b, char *msg);
+void dump_block(DEV_BLOCK *b, const char *msg);
DEV_BLOCK *new_block(DEVICE *dev);
DEV_BLOCK *dup_block(DEV_BLOCK *eblock);
void init_block_write(DEV_BLOCK *block);
int read_block_from_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, bool check_block_numbers);
/* From butil.c -- utilities for SD tool programs */
-void print_ls_output(char *fname, char *link, int type, struct stat *statp);
-JCR *setup_jcr(char *name, char *device, BSR *bsr, char *VolumeName);
+void print_ls_output(const char *fname, const char *link, int type, struct stat *statp);
+JCR *setup_jcr(const char *name, const char * device, BSR *bsr, const char *VolumeName);
DEVICE *setup_to_access_device(JCR *jcr, int read_access);
void display_tape_error_status(JCR *jcr, DEVICE *dev);
DEVRES *find_device_res(char *device_name, int read_access);
int open_device(JCR *jcr, DEVICE *dev);
int first_open_device(DEVICE *dev);
int fixup_device_block_write_error(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
-void _lock_device(char *file, int line, DEVICE *dev);
-void _unlock_device(char *file, int line, DEVICE *dev);
-void _block_device(char *file, int line, DEVICE *dev, int state);
-void _unblock_device(char *file, int line, DEVICE *dev);
-void _steal_device_lock(char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state);
-void _give_back_device_lock(char *file, int line, DEVICE *dev, bsteal_lock_t *hold);
+void _lock_device(const char *file, int line, DEVICE *dev);
+void _unlock_device(const char *file, int line, DEVICE *dev);
+void _block_device(const char *file, int line, DEVICE *dev, int state);
+void _unblock_device(const char *file, int line, DEVICE *dev);
+void _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state);
+void _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold);
void set_new_volume_parameters(JCR *jcr, DEVICE *dev);
void set_new_file_parameters(JCR *jcr, DEVICE *dev);
int device_is_unmounted(DEVICE *dev);
/* From label.c */
int read_dev_volume_label(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
void create_session_label(JCR *jcr, DEV_RECORD *rec, int label);
-void create_volume_label(DEVICE *dev, char *VolName, char *PoolName);
-int write_volume_label_to_dev(JCR *jcr, DEVRES *device, char *VolName, char *PoolName);
+void create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName);
+int write_volume_label_to_dev(JCR *jcr, DEVRES *device, const char *VolName, const char *PoolName);
int write_session_label(JCR *jcr, DEV_BLOCK *block, int label);
int write_volume_label_to_block(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
void dump_volume_label(DEVICE *dev);
void create_vol_list(JCR *jcr);
/* From record.c */
-char *FI_to_ascii(int fi);
-char *stream_to_ascii(int stream, int fi);
+const char *FI_to_ascii(int fi);
+const char *stream_to_ascii(int stream, int fi);
int write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
int can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
int read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec);
static void handle_session_record(DEVICE *dev, DEV_RECORD *rec, SESSION_LABEL *sessrec)
{
- char *rtype;
+ const char *rtype;
char buf[100];
+
memset(sessrec, 0, sizeof(sessrec));
switch (rec->FileIndex) {
case PRE_LABEL:
* record as a Label, otherwise it is simply
* the FileIndex of the current file.
*/
-char *FI_to_ascii(int fi)
+const char *FI_to_ascii(int fi)
{
static char buf[20];
if (fi >= 0) {
* dealing with a Label, hence the
* stream is the JobId.
*/
-char *stream_to_ascii(int stream, int fi)
+const char *stream_to_ascii(int stream, int fi)
{
static char buf[20];
if (fi < 0) {
static void make_unique_data_spool_filename(JCR *jcr, POOLMEM **name)
{
- char *dir;
+ const char *dir;
if (jcr->dcr->dev->device->spool_directory) {
dir = jcr->dcr->dev->device->spool_directory;
} else {
static void send_blocked_status(JCR *jcr, DEVICE *dev);
static void list_terminated_jobs(void *arg);
static void list_running_jobs(BSOCK *user);
-static void sendit(char *msg, int len, void *arg);
-static char *level_to_str(int level);
+static void sendit(const char *msg, int len, void *arg);
+static const char *level_to_str(int level);
/*
char dt[MAX_TIME_LENGTH], b1[30], b2[30];
char level[10];
struct s_last_job *je;
- char *msg;
+ const char *msg;
if (last_jobs->size() == 0) {
msg = _("No Terminated Jobs.\n");
sendit(msg, strlen(msg), arg);
foreach_dlist(je, last_jobs) {
char JobName[MAX_NAME_LENGTH];
- char *termstat;
+ const char *termstat;
char buf[1000];
bstrftime_nc(dt, sizeof(dt), je->end_time);
/*
* Convert Job Level into a string
*/
-static char *level_to_str(int level)
+static const char *level_to_str(int level)
{
- char *str;
+ const char *str;
switch (level) {
case L_BASE:
/*
* Send to Director
*/
-static void sendit(char *msg, int len, void *arg)
+static void sendit(const char *msg, int len, void *arg)
{
BSOCK *user = (BSOCK *)arg;
/* Dump contents of resource */
-void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ...), void *sock)
+void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock)
{
URES *res = (URES *)reshdr;
char buf[MAXSTRING];
static char *cc_addr = NULL;
static char *subject = NULL;
static char *err_addr = NULL;
-static char *mailhost = NULL;
+static const char *mailhost = NULL;
static char *reply_addr = NULL;
static int mailport = 25;
static char my_hostname[MAXSTRING];
/*
* say something to server and check the response
*/
-static void chat(char *fmt, ...)
+static void chat(const char *fmt, ...)
{
va_list ap;
#define MAX_ID_LIST_LEN 1000000
/* Forward referenced functions */
-static int make_id_list(char *query, ID_LIST *id_list);
-static int delete_id_list(char *query, ID_LIST *id_list);
-static int make_name_list(char *query, NAME_LIST *name_list);
+static int make_id_list(const char *query, ID_LIST *id_list);
+static int delete_id_list(const char *query, ID_LIST *id_list);
+static int make_name_list(const char *query, NAME_LIST *name_list);
static void print_name_list(NAME_LIST *name_list);
static void free_name_list(NAME_LIST *name_list);
-static char *get_cmd(char *prompt);
+static char *get_cmd(const char *prompt);
static void eliminate_duplicate_filenames();
static void eliminate_duplicate_paths();
static void eliminate_orphaned_jobmedia_records();
static void repair_bad_paths();
static void repair_bad_filenames();
static void do_interactive_mode();
-static int yes_no(char *prompt);
+static int yes_no(const char *prompt);
static void usage()
int main (int argc, char *argv[])
{
int ch;
- char *user, *password, *db_name, *dbhost;
+ const char *user, *password, *db_name, *dbhost;
char *configfile = NULL;
char *catalogname = NULL;
static void do_interactive_mode()
{
bool quit = false;
- char *cmd;
+ const char *cmd;
printf("Hello, this is the database check/correct program.\n\
Modify database is %s. Verbose is %s.\n\
/*
* Construct record id list
*/
-static int make_id_list(char *query, ID_LIST *id_list)
+static int make_id_list(const char *query, ID_LIST *id_list)
{
id_list->num_ids = 0;
id_list->num_del = 0;
/*
* Delete all entries in the list
*/
-static int delete_id_list(char *query, ID_LIST *id_list)
+static int delete_id_list(const char *query, ID_LIST *id_list)
{
for (int i=0; i < id_list->num_ids; i++) {
sprintf(buf, query, id_list->Id[i]);
/*
* Construct name list
*/
-static int make_name_list(char *query, NAME_LIST *name_list)
+static int make_name_list(const char *query, NAME_LIST *name_list)
{
name_list->num_ids = 0;
name_list->num_del = 0;
static void eliminate_duplicate_filenames()
{
- char *query;
+ const char *query;
char esc_name[5000];
printf("Checking for duplicate Filename entries.\n");
static void eliminate_duplicate_paths()
{
- char *query;
+ const char *query;
char esc_name[5000];
printf(_("Checking for duplicate Path entries.\n"));
static void eliminate_orphaned_jobmedia_records()
{
- char *query;
+ const char *query;
printf("Checking for orphaned JobMedia entries.\n");
query = "SELECT JobMedia.JobMediaId,Job.JobId FROM JobMedia "
static void eliminate_orphaned_file_records()
{
- char *query;
+ const char *query;
printf("Checking for orphaned File entries. This may take some time!\n");
query = "SELECT File.FileId,Job.JobId FROM File "
static void eliminate_orphaned_path_records()
{
- char *query;
+ const char *query;
printf("Checking for orphaned Path entries. This may take some time!\n");
query = "SELECT Path.PathId,File.PathId FROM Path "
static void eliminate_orphaned_filename_records()
{
- char *query;
+ const char *query;
printf("Checking for orphaned Filename entries. This may take some time!\n");
query = "SELECT Filename.FilenameId,File.FilenameId FROM Filename "
static void eliminate_orphaned_fileset_records()
{
- char *query;
+ const char *query;
printf("Checking for orphaned FileSet entries. This takes some time!\n");
query = "SELECT FileSet.FileSetId,Job.FileSetId FROM FileSet "
static void repair_bad_filenames()
{
- char *query;
+ const char *query;
int i;
printf("Checking for Filenames with a trailing slash\n");
static void repair_bad_paths()
{
- char *query;
+ const char *query;
int i;
printf("Checking for Paths without a trailing slash\n");
/*
* Gen next input command from the terminal
*/
-static char *get_cmd(char *prompt)
+static char *get_cmd(const char *prompt)
{
static char cmd[1000];
return cmd;
}
-static int yes_no(char *prompt)
+static int yes_no(const char *prompt)
{
char *cmd;
cmd = get_cmd(prompt);
/* */
#undef VERSION
-#define VERSION "1.34.4"
+#define VERSION "1.35.0"
#define VSTRING "1"
-#define BDATE "12 June 2004"
-#define LSMDATE "12Jun04"
+#define BDATE "14 June 2004"
+#define LSMDATE "14Jun04"
/* Debug flags */
#undef DEBUG
/* Dump contents of resource */
-void dump_resource(int type, RES *reshdr, void sendit(void *sock, char *fmt, ...), void *sock)
+void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock)
{
URES *res = (URES *)reshdr;
int recurse = 1;