- Figure out how to use ssh or stunnel to protect Bacula communications.
For 1.31 release:
+- Look at ALL higher level routines that call block.c to be sure
+ they don't expect something in errmsg.
+- Fix Verify VolumeToCatalog to use BSRs -- it is broken.
- Use switch() in backup.c and restore.c in FD instead of giant if statement.
+- Replace do_shell_expansion() with bpipe code.
- Investigate doing RAW backup of Win32 partition.
- Add JobName= to VerifyToCatalog so that all verifies can be done at the end.
- Add thread specific data to hold the jcr -- send error messages from
int Mmsg(char **msgbuf, char *fmt,...);
+struct JCR;
void d_msg(char *file, int line, int level, char *fmt,...);
void e_msg(char *file, int line, int type, int level, char *fmt,...);
-void j_msg(char *file, int line, void *vjcr, int type, int level, char *fmt,...);
+void j_msg(char *file, int line, JCR *jcr, int type, int level, char *fmt,...);
int m_msg(char *file, int line, char **msgbuf, char *fmt,...);
* never have errors, or it is really fatal.
*/
B_DB *
-db_init_database(void *jcr, char *db_name, char *db_user, char *db_password,
+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 *mdb;
* which are returned in the errmsg
*/
int
-db_open_database(void *jcr, B_DB *mdb)
+db_open_database(JCR *jcr, B_DB *mdb)
{
int errstat;
}
void
-db_close_database(void *jcr, B_DB *mdb)
+db_close_database(JCR *jcr, B_DB *mdb)
{
P(mutex);
mdb->ref_count--;
* For MySQL, NULL causes the auto-increment value
* to be updated.
*/
-int db_next_index(void *jcr, B_DB *mdb, char *table, char *index)
+int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index)
{
strcpy(index, "NULL");
return 1;
/* Database prototypes */
/* sql.c */
-B_DB *db_init_database(void *jcr, char *db_name, char *db_user, char *db_password,
+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);
-int db_open_database(void *jcr, B_DB *db);
-void db_close_database(void *jcr, B_DB *db);
+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 get_sql_record_max(void *jcr, B_DB *mdb);
-int db_next_index(void *jcr, B_DB *mdb, char *table, char *index);
+int get_sql_record_max(JCR *jcr, 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 check_tables_version(void *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_start_transaction(void *jcr, B_DB *mdb);
-void db_end_transaction(void *jcr, B_DB *mdb);
+void db_start_transaction(JCR *jcr, B_DB *mdb);
+void db_end_transaction(JCR *jcr, B_DB *mdb);
/* create.c */
-int db_create_file_attributes_record(void *jcr, B_DB *mdb, ATTR_DBR *ar);
-int db_create_job_record(void *jcr, B_DB *db, JOB_DBR *jr);
-int db_create_media_record(void *jcr, B_DB *db, MEDIA_DBR *media_dbr);
-int db_create_client_record(void *jcr, B_DB *db, CLIENT_DBR *cr);
-int db_create_fileset_record(void *jcr, B_DB *db, FILESET_DBR *fsr);
-int db_create_pool_record(void *jcr, B_DB *db, POOL_DBR *pool_dbr);
-int db_create_jobmedia_record(void *jcr, B_DB *mdb, JOBMEDIA_DBR *jr);
+int db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
+int db_create_job_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
+int db_create_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *media_dbr);
+int db_create_client_record(JCR *jcr, B_DB *db, CLIENT_DBR *cr);
+int db_create_fileset_record(JCR *jcr, B_DB *db, FILESET_DBR *fsr);
+int db_create_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr);
+int db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jr);
/* delete.c */
-int db_delete_pool_record(void *jcr, B_DB *db, POOL_DBR *pool_dbr);
-int db_delete_media_record(void *jcr, B_DB *mdb, MEDIA_DBR *mr);
+int db_delete_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pool_dbr);
+int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
/* find.c */
-int db_find_job_start_time(void *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime);
-int db_find_last_jobid(void *jcr, B_DB *mdb, JOB_DBR *jr);
-int db_find_next_volume(void *jcr, B_DB *mdb, int index, MEDIA_DBR *mr);
+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, JOB_DBR *jr);
+int db_find_next_volume(JCR *jcr, B_DB *mdb, int index, MEDIA_DBR *mr);
/* get.c */
-int db_get_pool_record(void *jcr, B_DB *db, POOL_DBR *pdbr);
-int db_get_client_record(void *jcr, B_DB *mdb, CLIENT_DBR *cr);
-int db_get_job_record(void *jcr, B_DB *mdb, JOB_DBR *jr);
-int db_get_job_volume_names(void *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **VolumeNames);
-int db_get_file_attributes_record(void *jcr, B_DB *mdb, char *fname, FILE_DBR *fdbr);
-int db_get_fileset_record(void *jcr, B_DB *mdb, FILESET_DBR *fsr);
-int db_get_media_record(void *jcr, B_DB *mdb, MEDIA_DBR *mr);
-int db_get_num_media_records(void *jcr, B_DB *mdb);
-int db_get_num_pool_records(void *jcr, B_DB *mdb);
-int db_get_pool_ids(void *jcr, B_DB *mdb, int *num_ids, uint32_t **ids);
-int db_get_client_ids(void *jcr, B_DB *mdb, int *num_ids, uint32_t **ids);
-int db_get_media_ids(void *jcr, B_DB *mdb, int *num_ids, uint32_t **ids);
-int db_get_job_volume_parameters(void *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS **VolParams);
-int db_get_client_record(void *jcr, B_DB *mdb, CLIENT_DBR *cdbr);
+int db_get_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pdbr);
+int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr);
+int db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr);
+int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **VolumeNames);
+int db_get_file_attributes_record(JCR *jcr, B_DB *mdb, char *fname, FILE_DBR *fdbr);
+int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr);
+int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr);
+int db_get_num_media_records(JCR *jcr, B_DB *mdb);
+int db_get_num_pool_records(JCR *jcr, B_DB *mdb);
+int db_get_pool_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t **ids);
+int db_get_client_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t **ids);
+int db_get_media_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t **ids);
+int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS **VolParams);
+int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr);
/* list.c */
-void db_list_pool_records(void *jcr, B_DB *db, DB_LIST_HANDLER sendit, void *ctx, int full);
-void db_list_job_records(void *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void *ctx, int full);
-void db_list_job_totals(void *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void *ctx);
-void db_list_files_for_job(void *jcr, B_DB *db, uint32_t jobid, DB_LIST_HANDLER sendit, void *ctx);
-void db_list_media_records(void *jcr, B_DB *mdb, MEDIA_DBR *mdbr, DB_LIST_HANDLER *sendit, void *ctx, int full);
-void db_list_jobmedia_records(void *jcr, B_DB *mdb, uint32_t JobId, DB_LIST_HANDLER *sendit, void *ctx, int full);
-int db_list_sql_query(void *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, void *ctx, int verbose, int full);
-void db_list_client_records(void *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, int full);
+void db_list_pool_records(JCR *jcr, B_DB *db, DB_LIST_HANDLER sendit, void *ctx, int full);
+void db_list_job_records(JCR *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void *ctx, int full);
+void db_list_job_totals(JCR *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit, void *ctx);
+void db_list_files_for_job(JCR *jcr, B_DB *db, uint32_t jobid, DB_LIST_HANDLER sendit, void *ctx);
+void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, DB_LIST_HANDLER *sendit, void *ctx, int full);
+void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId, DB_LIST_HANDLER *sendit, void *ctx, int full);
+int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, void *ctx, int verbose, int full);
+void db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, int full);
/* update.c */
-int db_update_job_start_record(void *jcr, B_DB *db, JOB_DBR *jr);
-int db_update_job_end_record(void *jcr, B_DB *db, JOB_DBR *jr);
-int db_update_client_record(void *jcr, B_DB *mdb, CLIENT_DBR *cr);
-int db_update_pool_record(void *jcr, B_DB *db, POOL_DBR *pr);
-int db_update_media_record(void *jcr, B_DB *db, MEDIA_DBR *mr);
-int db_add_SIG_to_file_record(void *jcr, B_DB *mdb, FileId_t FileId, char *SIG, int type);
-int db_mark_file_record(void *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId);
+int db_update_job_start_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
+int db_update_job_end_record(JCR *jcr, B_DB *db, JOB_DBR *jr);
+int db_update_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr);
+int db_update_pool_record(JCR *jcr, B_DB *db, POOL_DBR *pr);
+int db_update_media_record(JCR *jcr, B_DB *db, MEDIA_DBR *mr);
+int db_add_SIG_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *SIG, int type);
+int db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId);
#endif /* __SQL_PROTOS_H */
*/
/* Check that the tables correspond to the version we want */
-int check_tables_version(void *jcr, B_DB *mdb)
+int check_tables_version(JCR *jcr, B_DB *mdb)
{
uint32_t version;
char *query = "SELECT VersionId FROM Version";
/* Utility routine for queries. The database MUST be locked before calling here. */
int
-QueryDB(char *file, int line, void *jcr, B_DB *mdb, char *cmd)
+QueryDB(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, void *jcr, B_DB *mdb, char *cmd)
+InsertDB(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, void *jcr, B_DB *mdb, char *cmd)
+UpdateDB(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, void *jcr, B_DB *mdb, char *cmd)
+DeleteDB(char *file, int line, JCR *jcr, B_DB *mdb, char *cmd)
{
if (sql_query(mdb, cmd)) {
* Returns: -1 on failure
* count on success
*/
-int get_sql_record_max(void *jcr, B_DB *mdb)
+int get_sql_record_max(JCR *jcr, B_DB *mdb)
{
SQL_ROW row;
int stat = 0;
* much more efficient. Usually started when inserting
* file attributes.
*/
-void db_start_transaction(void *jcr, B_DB *mdb)
+void db_start_transaction(JCR *jcr, B_DB *mdb)
{
#ifdef xAVE_SQLITE
db_lock(mdb);
}
-void db_end_transaction(void *jcr, B_DB *mdb)
+void db_end_transaction(JCR *jcr, B_DB *mdb)
{
#ifdef xAVE_SQLITE
db_lock(mdb);
* and filename parts. They are returned in pool memory
* in the mdb structure.
*/
-void split_path_and_filename(void *jcr, B_DB *mdb, char *fname)
+void split_path_and_filename(JCR *jcr, B_DB *mdb, char *fname)
{
char *p, *f;
*/
/* Forward referenced subroutines */
-static int db_create_file_record(void *jcr, B_DB *mdb, ATTR_DBR *ar);
-static int db_create_filename_record(void *jcr, B_DB *mdb, ATTR_DBR *ar);
-static int db_create_path_record(void *jcr, B_DB *mdb, ATTR_DBR *ar);
+static int db_create_file_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
+static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
+static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
/* Imported subroutines */
extern void print_dashes(B_DB *mdb);
extern void print_result(B_DB *mdb);
-extern int QueryDB(char *file, int line, void *jcr, B_DB *db, char *select_cmd);
-extern int InsertDB(char *file, int line, void *jcr, B_DB *db, char *select_cmd);
-extern void split_path_and_filename(void *jcr, B_DB *mdb, char *fname);
+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 void split_path_and_filename(JCR *jcr, B_DB *mdb, char *fname);
/* Create a new record for the Job
* 1 on success
*/
int
-db_create_job_record(void *jcr, B_DB *mdb, JOB_DBR *jr)
+db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
{
char dt[MAX_TIME_LENGTH];
time_t stime;
* 1 on success
*/
int
-db_create_jobmedia_record(void *jcr, B_DB *mdb, JOBMEDIA_DBR *jm)
+db_create_jobmedia_record(JCR *jcr, B_DB *mdb, JOBMEDIA_DBR *jm)
{
int stat;
* 1 on success
*/
int
-db_create_pool_record(void *jcr, B_DB *mdb, POOL_DBR *pr)
+db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
{
int stat;
char ed1[30], ed2[30], ed3[50];
* 1 on success
*/
int
-db_create_media_record(void *jcr, B_DB *mdb, MEDIA_DBR *mr)
+db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
{
int stat;
char ed1[30], ed2[30], ed3[30], ed4[30];
* Returns: 0 on failure
* 1 on success with id in cr->ClientId
*/
-int db_create_client_record(void *jcr, B_DB *mdb, CLIENT_DBR *cr)
+int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
{
SQL_ROW row;
int stat;
* Returns: 0 on failure
* 1 on success with FileSetId in record
*/
-int db_create_fileset_record(void *jcr, B_DB *mdb, FILESET_DBR *fsr)
+int db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
{
SQL_ROW row;
int stat;
* how many times it occurs. This is this subroutine, we separate
* the file and the path and create three database records.
*/
-int db_create_file_attributes_record(void *jcr, B_DB *mdb, ATTR_DBR *ar)
+int db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
{
Dmsg1(100, "Fname=%s\n", ar->fname);
* This is the master File entry containing the attributes.
* The filename and path records have already been created.
*/
-static int db_create_file_record(void *jcr, B_DB *mdb, ATTR_DBR *ar)
+static int db_create_file_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
{
int stat;
}
/* Create a Unique record for the Path -- no duplicates */
-static int db_create_path_record(void *jcr, B_DB *mdb, ATTR_DBR *ar)
+static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
{
SQL_ROW row;
int stat;
}
/* Create a Unique record for the filename -- no duplicates */
-static int db_create_filename_record(void *jcr, B_DB *mdb, ATTR_DBR *ar)
+static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
{
SQL_ROW row;
/* Imported subroutines */
extern void print_dashes(B_DB *mdb);
extern void print_result(B_DB *mdb);
-extern int QueryDB(char *file, int line, void *jcr, B_DB *db, char *select_cmd);
-extern int DeleteDB(char *file, int line, void *jcr, B_DB *db, char *delete_cmd);
+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);
/*
* Delete Pool record, must also delete all associated
* NumVols = number of Media records deleted
*/
int
-db_delete_pool_record(void *jcr, B_DB *mdb, POOL_DBR *pr)
+db_delete_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
{
SQL_ROW row;
/* Delete Media record and all records that
* are associated with it.
*/
-int db_delete_media_record(void *jcr, B_DB *mdb, MEDIA_DBR *mr)
+int db_delete_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
{
db_lock(mdb);
if (mr->MediaId == 0 && !db_get_media_record(jcr, mdb, mr)) {
* media record itself. But the media status
* is changed to "Purged".
*/
-int db_purge_media_record(void *jcr, B_DB *mdb, MEDIA_DBR *mr)
+int db_purge_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
{
db_lock(mdb);
if (mr->MediaId == 0 && !db_get_media_record(jcr, mdb, mr)) {
/* Imported subroutines */
extern void print_result(B_DB *mdb);
-extern int QueryDB(char *file, int line, void *jcr, B_DB *db, char *select_cmd);
+extern int QueryDB(char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
/*
* Find job start time. Used to find last full save
* 1 on success, jr is unchanged, but stime is set
*/
int
-db_find_job_start_time(void *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime)
+db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime)
{
SQL_ROW row;
int JobId;
* 0 on failure
*/
int
-db_find_last_jobid(void *jcr, B_DB *mdb, JOB_DBR *jr)
+db_find_last_jobid(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
{
SQL_ROW row;
* numrows on success
*/
int
-db_find_next_volume(void *jcr, B_DB *mdb, int item, MEDIA_DBR *mr)
+db_find_next_volume(JCR *jcr, B_DB *mdb, int item, MEDIA_DBR *mr)
{
SQL_ROW row;
int numrows;
*/
/* Forward referenced functions */
-static int db_get_file_record(void *jcr, B_DB *mdb, FILE_DBR *fdbr);
-static int db_get_filename_record(void *jcr, B_DB *mdb);
-static int db_get_path_record(void *jcr, B_DB *mdb);
+static int db_get_file_record(JCR *jcr, B_DB *mdb, FILE_DBR *fdbr);
+static int db_get_filename_record(JCR *jcr, B_DB *mdb);
+static int db_get_path_record(JCR *jcr, B_DB *mdb);
/* Imported subroutines */
extern void print_result(B_DB *mdb);
-extern int QueryDB(char *file, int line, void *jcr, B_DB *db, char *select_cmd);
-extern void split_path_and_filename(void *jcr, B_DB *mdb, char *fname);
+extern int QueryDB(char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
+extern void split_path_and_filename(JCR *jcr, B_DB *mdb, char *fname);
* Returns: 0 on failure
* 1 on success with the File record in FILE_DBR
*/
-int db_get_file_attributes_record(void *jcr, B_DB *mdb, char *fname, FILE_DBR *fdbr)
+int db_get_file_attributes_record(JCR *jcr, B_DB *mdb, char *fname, FILE_DBR *fdbr)
{
int stat;
Dmsg1(20, "Enter get_file_from_catalog fname=%s \n", fname);
* "normal" if a new file is found during Verify.
*/
static
-int db_get_file_record(void *jcr, B_DB *mdb, FILE_DBR *fdbr)
+int db_get_file_record(JCR *jcr, B_DB *mdb, FILE_DBR *fdbr)
{
SQL_ROW row;
int stat = 0;
*
* DO NOT use Jmsg in this routine (see notes for get_file_record)
*/
-static int db_get_filename_record(void *jcr, B_DB *mdb)
+static int db_get_filename_record(JCR *jcr, B_DB *mdb)
{
SQL_ROW row;
int FilenameId = 0;
*
* DO NOT use Jmsg in this routine (see notes for get_file_record)
*/
-static int db_get_path_record(void *jcr, B_DB *mdb)
+static int db_get_path_record(JCR *jcr, B_DB *mdb)
{
SQL_ROW row;
uint32_t PathId = 0;
* Returns: 0 on failure
* 1 on success
*/
-int db_get_job_record(void *jcr, B_DB *mdb, JOB_DBR *jr)
+int db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
{
SQL_ROW row;
*
* Returns: number of volumes on success
*/
-int db_get_job_volume_names(void *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **VolumeNames)
+int db_get_job_volume_names(JCR *jcr, B_DB *mdb, uint32_t JobId, POOLMEM **VolumeNames)
{
SQL_ROW row;
int stat = 0;
*
* Returns: number of volumes on success
*/
-int db_get_job_volume_parameters(void *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS **VolParams)
+int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, uint32_t JobId, VOL_PARAMS **VolParams)
{
SQL_ROW row;
int stat = 0;
* Returns: -1 on failure
* number on success
*/
-int db_get_num_pool_records(void *jcr, B_DB *mdb)
+int db_get_num_pool_records(JCR *jcr, B_DB *mdb)
{
int stat = 0;
* Returns 0: on failure
* 1: on success
*/
-int db_get_pool_ids(void *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[])
+int db_get_pool_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[])
{
SQL_ROW row;
int stat = 0;
* Returns 0: on failure
* 1: on success
*/
-int db_get_client_ids(void *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[])
+int db_get_client_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[])
{
SQL_ROW row;
int stat = 0;
* Returns: 0 on failure
* id on success
*/
-int db_get_pool_record(void *jcr, B_DB *mdb, POOL_DBR *pdbr)
+int db_get_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pdbr)
{
SQL_ROW row;
int stat = 0;
* Returns: 0 on failure
* 1 on success
*/
-int db_get_client_record(void *jcr, B_DB *mdb, CLIENT_DBR *cdbr)
+int db_get_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cdbr)
{
SQL_ROW row;
int stat = 0;
* Returns: 0 on failure
* id on success
*/
-int db_get_fileset_record(void *jcr, B_DB *mdb, FILESET_DBR *fsr)
+int db_get_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
{
SQL_ROW row;
int stat = 0;
* Returns: -1 on failure
* number on success
*/
-int db_get_num_media_records(void *jcr, B_DB *mdb)
+int db_get_num_media_records(JCR *jcr, B_DB *mdb)
{
int stat = 0;
* Returns 0: on failure
* 1: on success
*/
-int db_get_media_ids(void *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[])
+int db_get_media_ids(JCR *jcr, B_DB *mdb, int *num_ids, uint32_t *ids[])
{
SQL_ROW row;
int stat = 0;
* Returns: 0 on failure
* id on success
*/
-int db_get_media_record(void *jcr, B_DB *mdb, MEDIA_DBR *mr)
+int db_get_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
{
SQL_ROW row;
int stat = 0;
/* Imported subroutines */
extern void list_result(B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, int full_list);
-extern int QueryDB(char *file, int line, void *jcr, B_DB *db, char *select_cmd);
+extern int QueryDB(char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
/*
* Submit general SQL query
*/
-int db_list_sql_query(void *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit,
+int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit,
void *ctx, int verbose, int full)
{
db_lock(mdb);
}
void
-db_list_pool_records(void *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, int full)
+db_list_pool_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, int full)
{
db_lock(mdb);
if (full) {
}
void
-db_list_client_records(void *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, int full)
+db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, int full)
{
db_lock(mdb);
if (full) {
* otherwise, list the Volumes in the Pool specified by PoolId
*/
void
-db_list_media_records(void *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
+db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr,
DB_LIST_HANDLER *sendit, void *ctx, int full)
{
db_lock(mdb);
db_unlock(mdb);
}
-void db_list_jobmedia_records(void *jcr, B_DB *mdb, uint32_t JobId,
+void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
DB_LIST_HANDLER *sendit, void *ctx, int full)
{
db_lock(mdb);
* only the job with the specified id.
*/
void
-db_list_job_records(void *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit,
+db_list_job_records(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit,
void *ctx, int full)
{
db_lock(mdb);
*
*/
void
-db_list_job_totals(void *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, void *ctx)
+db_list_job_totals(JCR *jcr, B_DB *mdb, JOB_DBR *jr, DB_LIST_HANDLER *sendit, void *ctx)
{
db_lock(mdb);
void
-db_list_files_for_job(void *jcr, B_DB *mdb, uint32_t jobid, DB_LIST_HANDLER *sendit, void *ctx)
+db_list_files_for_job(JCR *jcr, B_DB *mdb, uint32_t jobid, DB_LIST_HANDLER *sendit, void *ctx)
{
db_lock(mdb);
/* Imported subroutines */
extern void print_result(B_DB *mdb);
-extern int UpdateDB(char *file, int line, void *jcr, B_DB *db, char *update_cmd);
+extern int UpdateDB(char *file, int line, JCR *jcr, B_DB *db, char *update_cmd);
/* -----------------------------------------------------------------------
*
*/
/* Update the attributes record by adding the MD5 signature */
int
-db_add_SIG_to_file_record(void *jcr, B_DB *mdb, FileId_t FileId, char *SIG,
+db_add_SIG_to_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, char *SIG,
int type)
{
int stat;
/* Mark the file record as being visited during database
* verify compare. Stuff JobId into MarkedId field
*/
-int db_mark_file_record(void *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId)
+int db_mark_file_record(JCR *jcr, B_DB *mdb, FileId_t FileId, JobId_t JobId)
{
int stat;
* 1 on success
*/
int
-db_update_job_start_record(void *jcr, B_DB *mdb, JOB_DBR *jr)
+db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
{
char dt[MAX_TIME_LENGTH];
time_t stime;
* 1 on success
*/
int
-db_update_job_end_record(void *jcr, B_DB *mdb, JOB_DBR *jr)
+db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
{
char dt[MAX_TIME_LENGTH];
time_t ttime;
int
-db_update_client_record(void *jcr, B_DB *mdb, CLIENT_DBR *cr)
+db_update_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
{
int stat;
char ed1[50], ed2[50];
int
-db_update_pool_record(void *jcr, B_DB *mdb, POOL_DBR *pr)
+db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
{
int stat;
char ed1[50], ed2[50], ed3[50];
* numrows on success
*/
int
-db_update_media_record(void *jcr, B_DB *mdb, MEDIA_DBR *mr)
+db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
{
char dt[MAX_TIME_LENGTH];
time_t ttime;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-int QueryDB(char *file, int line, void *jcr, B_DB *db, char *select_cmd);
+int QueryDB(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(void *jcr, char *db_name, char *db_user, char *db_password,
+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 *mdb;
* which are returned in the errmsg
*/
int
-db_open_database(void *jcr, B_DB *mdb)
+db_open_database(JCR *jcr, B_DB *mdb)
{
char *db_name;
int len;
}
void
-db_close_database(void *jcr, B_DB *mdb)
+db_close_database(JCR *jcr, B_DB *mdb)
{
P(mutex);
mdb->ref_count--;
* Return the next unique index (auto-increment) for
* the given table. Return 0 on error.
*/
-int db_next_index(void *jcr, B_DB *mdb, char *table, char *index)
+int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index)
{
SQL_ROW row;
parse_config(configfile);
if (!check_resources()) {
- Jmsg(NULL, M_ERROR_TERM, 0, "Please correct configuration file: %s\n", configfile);
+ Jmsg((JCR *)NULL, M_ERROR_TERM, 0, _("Please correct configuration file: %s\n"), configfile);
}
if (test_config) {
jcr->last_fname[0] = 0;
jcr->client_name = get_memory(strlen(my_name) + 1);
pm_strcpy(&jcr->client_name, my_name);
- dir->jcr = (void *)jcr;
+ dir->jcr = jcr;
get_backup_privileges(NULL, 1 /* ignore_errors */);
/**********FIXME******* add command handler error code */
/* Forward referenced subroutines */
static
-int set_win32_attributes(void *jcr, char *fname, char *ofile, char *lname,
+int set_win32_attributes(JCR *jcr, char *fname, char *ofile, char *lname,
int type, int stream, struct stat *statp,
char *attribsEx, BFILE *ofd);
void unix_name_to_win32(POOLMEM **win32_name, char *name);
-void win_error(void *jcr, char *prefix, POOLMEM *ofile);
+void win_error(JCR *jcr, char *prefix, POOLMEM *ofile);
HANDLE bget_handle(BFILE *bfd);
#endif
* Returns: 1 on success
* 0 on failure
*/
-int set_attributes(void *jcr, char *fname, char *ofile, char *lname,
+int set_attributes(JCR *jcr, char *fname, char *ofile, char *lname,
int type, int stream, struct stat *statp,
char *attribsEx, BFILE *ofd)
{
* If you have a Unix system with extended attributes (e.g.
* ACLs for Solaris, do it here.
*/
-int encode_attribsEx(void *jcr, char *attribsEx, FF_PKT *ff_pkt)
+int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt)
{
*attribsEx = 0; /* no extended attributes */
return STREAM_UNIX_ATTRIBUTES;
#ifdef HAVE_CYGWIN
-int encode_attribsEx(void *jcr, char *attribsEx, FF_PKT *ff_pkt)
+int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt)
{
char *p = attribsEx;
WIN32_FILE_ATTRIBUTE_DATA atts;
* 0 on failure
*/
static
-int set_win32_attributes(void *jcr, char *fname, char *ofile, char *lname,
+int set_win32_attributes(JCR *jcr, char *fname, char *ofile, char *lname,
int type, int stream, struct stat *statp,
char *attribsEx, BFILE *ofd)
{
return 1;
}
-void win_error(void *vjcr, char *prefix, POOLMEM *win32_ofile)
+void win_error(JCR *jcr, char *prefix, POOLMEM *win32_ofile)
{
- JCR *jcr = (JCR *)vjcr;
DWORD lerror = GetLastError();
LPTSTR msg;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
LocalFree(msg);
}
-void win_error(void *vjcr, char *prefix, DWORD lerror)
+void win_error(JCR *jcr, char *prefix, DWORD lerror)
{
- JCR *jcr = (JCR *)vjcr;
LPTSTR msg;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
FORMAT_MESSAGE_FROM_SYSTEM,
#define O_CTG 0
#endif
-static int separate_path_and_file(void *jcr, char *fname, char *ofile);
+static int separate_path_and_file(JCR *jcr, char *fname, char *ofile);
static int path_already_seen(char *path, int pnl);
* files.
*
*/
-int create_file(void *jcr, char *fname, char *ofile, char *lname,
+int create_file(JCR *jcr, char *fname, char *ofile, char *lname,
int type, int stream, struct stat *statp,
char *attribsEx, BFILE *ofd, int replace)
{
* 0 no path
* -1 filename is zero length
*/
-static int separate_path_and_file(void *jcr, char *fname, char *ofile)
+static int separate_path_and_file(JCR *jcr, char *fname, char *ofile)
{
char *f, *p;
int fnl, pnl;
(indicating success) and will set *CREATED_DIR_P to zero. */
static int
-make_dir(void *jcr, const char *dir, const char *dirpath, mode_t mode, int *created_dir_p)
+make_dir(JCR *jcr, const char *dir, const char *dirpath, mode_t mode, int *created_dir_p)
{
int fail = 0;
int created_dir;
int
make_path(
- void *jcr,
+ JCR *jcr,
const char *argpath,
int mode,
int parent_mode,
/* from attribs.c */
void encode_stat (char *buf, struct stat *statp, uint32_t LinkFI);
void decode_stat (char *buf, struct stat *statp, uint32_t *LinkFI);
-int encode_attribsEx (void *jcr, char *attribsEx, FF_PKT *ff_pkt);
-int set_attributes(void *jcr, char *fname, char *ofile, char *lname,
+int encode_attribsEx (JCR *jcr, char *attribsEx, FF_PKT *ff_pkt);
+int set_attributes(JCR *jcr, char *fname, char *ofile, char *lname,
int type, int stream, struct stat *statp,
char *attribsEx, BFILE *ofd);
/* from create_file.c */
-int create_file(void *jcr, char *fname, char *ofile, char *lname,
+int create_file(JCR *jcr, char *fname, char *ofile, char *lname,
int type, int stream, struct stat *statp,
char *attribsEx, BFILE *ofd, int replace);
/* From get_priv.c */
-int get_backup_privileges(void *jcr, int ignore_errors);
+int get_backup_privileges(JCR *jcr, int ignore_errors);
/* from makepath.c */
-int make_path(void *jcr, const char *argpath, int mode,
+int make_path(JCR *jcr, const char *argpath, int mode,
int parent_mode, uid_t owner, gid_t group,
int preserve_existing, char *verbose_fmt_string);
jcr->JobStatus == JS_FatalError)
-typedef void (JCR_free_HANDLER)(struct s_jcr *jcr);
+struct JCR;
+typedef void (JCR_free_HANDLER)(JCR *jcr);
/* Job Control Record (JCR) */
-struct s_jcr {
+struct JCR {
/* Global part of JCR common to all daemons */
- struct s_jcr *next;
- struct s_jcr *prev;
+ JCR *next;
+ JCR *prev;
pthread_t my_thread_id; /* id of thread controlling jcr */
pthread_mutex_t mutex; /* jcr mutex */
BSOCK *dir_bsock; /* Director bsock or NULL if we are him */
#ifdef STORAGE_DAEMON
/* Storage Daemon specific part of JCR */
- struct s_jcr *next_dev; /* next JCR attached to device */
- struct s_jcr *prev_dev; /* previous JCR attached to device */
+ JCR *next_dev; /* next JCR attached to device */
+ JCR *prev_dev; /* previous JCR attached to device */
pthread_cond_t job_start_wait; /* Wait for FD to start Job */
int type;
DEVRES *device; /* device to use */
extern struct s_last_job last_job;
-#undef JCR
-typedef struct s_jcr JCR;
-
/* The following routines are found in lib/jcr.c */
extern JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr);
* Convert a hostname or dotted IP address into
* a s_addr. We handle only IPv4.
*/
-static uint32_t *bget_host_ip(void *jcr, char *host)
+static uint32_t *bget_host_ip(JCR *jcr, char *host)
{
struct in_addr inaddr;
uint32_t *addr_list; /* this really should be struct in_addr */
* ***FIXME*** implement service from /etc/services
*/
static BSOCK *
-bnet_open(void *jcr, char *name, char *host, char *service, int port, int *fatal)
+bnet_open(JCR *jcr, char *name, char *host, char *service, int port, int *fatal)
{
int sockfd;
struct sockaddr_in tcp_serv_addr; /* socket information */
* Try to connect to host for max_retry_time at retry_time intervals.
*/
BSOCK *
-bnet_connect(void *vjcr, int retry_interval, int max_retry_time, char *name,
+bnet_connect(JCR *jcr, int retry_interval, int max_retry_time, char *name,
char *host, char *service, int port, int verbose)
{
int i;
BSOCK *bsock;
- JCR *jcr = (JCR *)vjcr;
int fatal = 0;
for (i=0; (bsock = bnet_open(jcr, name, host, service, port, &fatal)) == NULL; i -= retry_interval) {
* This probably should be done in net_open
*/
BSOCK *
-init_bsock(void *jcr, int sockfd, char *who, char *host, int port)
+init_bsock(JCR *jcr, int sockfd, char *who, char *host, int port)
{
BSOCK *bsock = (BSOCK *)malloc(sizeof(BSOCK));
memset(bsock, 0, sizeof(BSOCK));
struct s_bsock *next; /* next BSOCK if duped */
int spool; /* set for spooling */
FILE *spool_fd; /* spooling file */
- void *jcr; /* jcr or NULL for error msgs */
+ JCR *jcr; /* jcr or NULL for error msgs */
} BSOCK;
/* Signal definitions for use in bnet_sig() */
* non-NULL -> initialize jcr using Message resource
*/
void
-init_msg(void *vjcr, MSGS *msg)
+init_msg(JCR *jcr, MSGS *msg)
{
DEST *d, *dnew, *temp_chain = NULL;
- JCR *jcr = (JCR *)vjcr;
/*
* If msg is NULL, initialize global chain for STDOUT and syslog
jcr->Job, fd);
}
-int open_spool_file(void *vjcr, BSOCK *bs)
+int open_spool_file(JCR *jcr, BSOCK *bs)
{
POOLMEM *name = get_pool_memory(PM_MESSAGE);
- JCR *jcr = (JCR *)vjcr;
make_unique_spool_filename(jcr, &name, bs->fd);
bs->spool_fd = fopen(name, "w+");
return 1;
}
-int close_spool_file(void *vjcr, BSOCK *bs)
+int close_spool_file(JCR *jcr, BSOCK *bs)
{
POOLMEM *name = get_pool_memory(PM_MESSAGE);
- JCR *jcr = (JCR *)vjcr;
make_unique_spool_filename(jcr, &name, bs->fd);
fclose(bs->spool_fd);
* Close the messages for this Messages resource, which means to close
* any open files, and dispatch any pending email messages.
*/
-void close_msg(void *vjcr)
+void close_msg(JCR *jcr)
{
MSGS *msgs;
- JCR *jcr = (JCR *)vjcr;
DEST *d;
BPIPE *bpipe;
POOLMEM *cmd, *line;
/*
* Handle sending the message to the appropriate place
*/
-void dispatch_message(void *vjcr, int type, int level, char *msg)
+void dispatch_message(JCR *jcr, int type, int level, char *msg)
{
DEST *d;
char dt[MAX_TIME_LENGTH];
POOLMEM *mcmd;
- JCR *jcr = (JCR *) vjcr;
int len;
MSGS *msgs;
BPIPE *bpipe;
*
*/
void
-Jmsg(void *vjcr, int type, int level, char *fmt,...)
+Jmsg(JCR *jcr, int type, int level, char *fmt,...)
{
char rbuf[5000];
va_list arg_ptr;
int len;
- JCR *jcr = (JCR *)vjcr;
MSGS *msgs;
char *job;
* If we come here, prefix the message with the file:line-number,
* then pass it on to the normal Jmsg routine.
*/
-void j_msg(char *file, int line, void *jcr, int type, int level, char *fmt,...)
+void j_msg(char *file, int line, JCR *jcr, int type, int level, char *fmt,...)
{
va_list arg_ptr;
int i, len, maxlen;
#include "bits.h"
-#undef M_DEBUG
-#undef M_ABORT
-#undef M_FATAL
-#undef M_ERROR
-#undef M_WARNING
-#undef M_INFO
-#undef M_MOUNT
-#undef M_ERROR_TERM
-#undef M_TERM
-#undef M_RESTORED
+#undef M_DEBUG
+#undef M_ABORT
+#undef M_FATAL
+#undef M_ERROR
+#undef M_WARNING
+#undef M_INFO
+#undef M_MOUNT
+#undef M_ERROR_TERM
+#undef M_TERM
+#undef M_RESTORED
/*
* Most of these message levels are more or less obvious.
* and here are some of the details of where I am trying to
* head (in the process of changing the code) as of 15 June 2002.
*
- * M_ABORT Bacula immediately aborts and tries to produce a traceback
- * This is for really serious errors like segmentation fault.
+ * M_ABORT Bacula immediately aborts and tries to produce a traceback
+ * This is for really serious errors like segmentation fault.
* M_ERROR_TERM Bacula immediately terminates but no dump. This is for
* "obvious" serious errors like daemon already running or
- * cannot open critical file, ... where a dump is not wanted.
- * M_TERM Bacula daemon shutting down because of request (SIGTERM).
+ * cannot open critical file, ... where a dump is not wanted.
+ * M_TERM Bacula daemon shutting down because of request (SIGTERM).
*
* The remaining apply to Jobs rather than the daemon.
*
- * M_FATAL Bacula detected a fatal Job error. The Job will be killed,
- * but Bacula continues running.
- * M_ERROR Bacula detected a Job error. The Job will continue running
- * but the termination status will be error.
- * M_WARNING Job warning message.
- * M_INFO Job information message.
+ * M_FATAL Bacula detected a fatal Job error. The Job will be killed,
+ * but Bacula continues running.
+ * M_ERROR Bacula detected a Job error. The Job will continue running
+ * but the termination status will be error.
+ * M_WARNING Job warning message.
+ * M_INFO Job information message.
*
- * M_RESTORED An ls -l of each restored file.
+ * M_RESTORED An ls -l of each restored file.
*
*/
-#define M_DEBUG 1 /* debug message */
-#define M_ABORT 2 /* MUST abort immediately */
-#define M_FATAL 3 /* Fatal error, stopping job */
-#define M_ERROR 4 /* Error, but recoverable */
-#define M_WARNING 5 /* Warning message */
-#define M_INFO 6 /* Informational message */
-#define M_SAVED 7 /* Info on saved file */
-#define M_NOTSAVED 8 /* Info on notsaved file */
-#define M_SKIPPED 9 /* File skipped by option setting */
-#define M_MOUNT 10 /* Mount requests */
-#define M_ERROR_TERM 11 /* Error termination request (no dump) */
-#define M_TERM 12 /* Terminating daemon */
-#define M_RESTORED 13 /* ls -l of restored files */
+#define M_DEBUG 1 /* debug message */
+#define M_ABORT 2 /* MUST abort immediately */
+#define M_FATAL 3 /* Fatal error, stopping job */
+#define M_ERROR 4 /* Error, but recoverable */
+#define M_WARNING 5 /* Warning message */
+#define M_INFO 6 /* Informational message */
+#define M_SAVED 7 /* Info on saved file */
+#define M_NOTSAVED 8 /* Info on notsaved file */
+#define M_SKIPPED 9 /* File skipped by option setting */
+#define M_MOUNT 10 /* Mount requests */
+#define M_ERROR_TERM 11 /* Error termination request (no dump) */
+#define M_TERM 12 /* Terminating daemon */
+#define M_RESTORED 13 /* ls -l of restored files */
-#define M_MAX M_RESTORED /* keep this updated ! */
+#define M_MAX M_RESTORED /* keep this updated ! */
/* Define message destination structure */
/* *** FIXME **** where should be extended to handle multiple values */
typedef struct s_dest {
struct s_dest *next;
- int dest_code; /* destination (one of the MD_ codes) */
- int max_len; /* max mail line length */
- FILE *fd; /* file descriptor */
+ int dest_code; /* destination (one of the MD_ codes) */
+ int max_len; /* max mail line length */
+ FILE *fd; /* file descriptor */
char msg_types[nbytes_for_bits(M_MAX+1)]; /* message type mask */
- char *where; /* filename/program name */
- char *mail_cmd; /* mail command */
- POOLMEM *mail_filename; /* unique mail filename */
+ char *where; /* filename/program name */
+ char *mail_cmd; /* mail command */
+ POOLMEM *mail_filename; /* unique mail filename */
} DEST;
/* Message Destination values for dest field of DEST */
-#define MD_SYSLOG 1 /* send msg to syslog */
-#define MD_MAIL 2 /* email group of messages */
-#define MD_FILE 3 /* write messages to a file */
-#define MD_APPEND 4 /* append messages to a file */
-#define MD_STDOUT 5 /* print messages */
-#define MD_STDERR 6 /* print messages to stderr */
-#define MD_DIRECTOR 7 /* send message to the Director */
-#define MD_OPERATOR 8 /* email a single message to the operator */
-#define MD_CONSOLE 9 /* send msg to UserAgent or console */
-#define MD_MAIL_ON_ERROR 10 /* email messages if job errors */
+#define MD_SYSLOG 1 /* send msg to syslog */
+#define MD_MAIL 2 /* email group of messages */
+#define MD_FILE 3 /* write messages to a file */
+#define MD_APPEND 4 /* append messages to a file */
+#define MD_STDOUT 5 /* print messages */
+#define MD_STDERR 6 /* print messages to stderr */
+#define MD_DIRECTOR 7 /* send message to the Director */
+#define MD_OPERATOR 8 /* email a single message to the operator */
+#define MD_CONSOLE 9 /* send msg to UserAgent or console */
+#define MD_MAIL_ON_ERROR 10 /* email messages if job errors */
void d_msg(char *file, int line, int level, char *fmt,...);
void e_msg(char *file, int line, int type, int level, char *fmt,...);
-void Jmsg(void *vjcr, int type, int level, char *fmt,...);
+void Jmsg(JCR *jcr, int type, int level, char *fmt,...);
extern int debug_level;
extern int verbose;
*/
+struct JCR;
+
/* base64.c */
-void base64_init (void);
-int to_base64 (intmax_t value, char *where);
-int from_base64 (intmax_t *value, char *where);
-int bin_to_base64 (char *buf, char *bin, int len);
+void base64_init (void);
+int to_base64 (intmax_t value, char *where);
+int from_base64 (intmax_t *value, char *where);
+int bin_to_base64 (char *buf, char *bin, int len);
/* bmisc.c */
-char *bstrncpy (char *dest, const char *src, int maxlen);
-char *bstrncat (char *dest, const char *src, int maxlen);
-void *b_malloc (char *file, int line, size_t size);
+char *bstrncpy (char *dest, const char *src, int maxlen);
+char *bstrncat (char *dest, const char *src, int maxlen);
+void *b_malloc (char *file, int line, size_t size);
#ifndef DEBUG
-void *bmalloc (size_t size);
+void *bmalloc (size_t size);
#endif
-void *brealloc (void *buf, size_t size);
-void *bcalloc (size_t size1, size_t size2);
-int bsnprintf (char *str, size_t size, const char *format, ...);
-int bvsnprintf (char *str, size_t size, const char *format, va_list ap);
-int pool_sprintf (char *pool_buf, char *fmt, ...);
-void create_pid_file (char *dir, char *progname, int port);
-int delete_pid_file (char *dir, char *progname, int port);
-void drop (char *uid, char *gid);
-int bmicrosleep (time_t sec, long msec);
+void *brealloc (void *buf, size_t size);
+void *bcalloc (size_t size1, size_t size2);
+int bsnprintf (char *str, size_t size, const char *format, ...);
+int bvsnprintf (char *str, size_t size, const char *format, va_list ap);
+int pool_sprintf (char *pool_buf, char *fmt, ...);
+void create_pid_file (char *dir, char *progname, int port);
+int delete_pid_file (char *dir, char *progname, int port);
+void drop (char *uid, char *gid);
+int bmicrosleep (time_t sec, long msec);
#ifndef HAVE_STRTOLL
long long int strtoll(const char *ptr, char **endptr, int base);
#endif
/* bnet.c */
-int32_t bnet_recv (BSOCK *bsock);
-int bnet_send (BSOCK *bsock);
-int bnet_fsend (BSOCK *bs, char *fmt, ...);
-int bnet_set_buffer_size (BSOCK *bs, uint32_t size, int rw);
-int bnet_sig (BSOCK *bs, int sig);
-int bnet_ssl_server (BSOCK *bsock, char *password, int ssl_need, int ssl_has);
-int bnet_ssl_client (BSOCK *bsock, char *password, int ssl_need);
-BSOCK * bnet_connect (void *jcr, int retry_interval,
- int max_retry_time, char *name, char *host, char *service,
- int port, int verbose);
-void bnet_close (BSOCK *bsock);
-BSOCK * init_bsock (void *jcr, int sockfd, char *who, char *ip, int port);
-BSOCK * dup_bsock (BSOCK *bsock);
-void term_bsock (BSOCK *bsock);
-char * bnet_strerror (BSOCK *bsock);
-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 (BSOCK *bsock);
-int is_bnet_stop (BSOCK *bsock);
-int is_bnet_error (BSOCK *bsock);
-void bnet_suppress_error_messages(BSOCK *bsock, int flag);
+int32_t bnet_recv (BSOCK *bsock);
+int bnet_send (BSOCK *bsock);
+int bnet_fsend (BSOCK *bs, char *fmt, ...);
+int bnet_set_buffer_size (BSOCK *bs, uint32_t size, int rw);
+int bnet_sig (BSOCK *bs, int sig);
+int bnet_ssl_server (BSOCK *bsock, char *password, int ssl_need, int ssl_has);
+int bnet_ssl_client (BSOCK *bsock, char *password, int ssl_need);
+BSOCK * bnet_connect (JCR *jcr, int retry_interval,
+ int max_retry_time, char *name, char *host, char *service,
+ int port, int verbose);
+void bnet_close (BSOCK *bsock);
+BSOCK * init_bsock (JCR *jcr, int sockfd, char *who, char *ip, int port);
+BSOCK * dup_bsock (BSOCK *bsock);
+void term_bsock (BSOCK *bsock);
+char * bnet_strerror (BSOCK *bsock);
+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 (BSOCK *bsock);
+int is_bnet_stop (BSOCK *bsock);
+int is_bnet_error (BSOCK *bsock);
+void bnet_suppress_error_messages(BSOCK *bsock, int flag);
/* bget_msg.c */
-int bget_msg(BSOCK *sock);
+int bget_msg(BSOCK *sock);
/* cram-md5.c */
int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need);
int cram_md5_auth(BSOCK *bs, char *password, int ssl_need);
void hmac_md5(uint8_t* text, int text_len, uint8_t* key,
- int key_len, uint8_t *hmac);
+ int key_len, uint8_t *hmac);
/* crc32.c */
+
uint32_t bcrc32(uint8_t *buf, int len);
/* daemon.c */
-void daemon_start ();
+void daemon_start ();
/* edit.c */
-uint64_t str_to_uint64(char *str);
-int64_t str_to_int64(char *str);
-char * edit_uint64_with_commas (uint64_t val, char *buf);
-char * add_commas (char *val, char *buf);
-char * edit_uint64 (uint64_t val, char *buf);
-int duration_to_utime (char *str, utime_t *value);
-int size_to_uint64(char *str, int str_len, uint64_t *rtn_value);
-char *edit_utime (utime_t val, char *buf);
-int is_a_number (const char *num);
-int is_an_integer (const char *n);
+uint64_t str_to_uint64(char *str);
+int64_t str_to_int64(char *str);
+char * edit_uint64_with_commas (uint64_t val, char *buf);
+char * add_commas (char *val, char *buf);
+char * edit_uint64 (uint64_t val, char *buf);
+int duration_to_utime (char *str, utime_t *value);
+int size_to_uint64(char *str, int str_len, uint64_t *rtn_value);
+char *edit_utime (utime_t val, char *buf);
+int is_a_number (const char *num);
+int is_an_integer (const char *n);
/* lex.c */
-LEX * lex_close_file (LEX *lf);
-LEX * lex_open_file (LEX *lf, char *fname, LEX_ERROR_HANDLER *scan_error);
-int lex_get_char (LEX *lf);
-void lex_unget_char (LEX *lf);
-char * lex_tok_to_str (int token);
-int lex_get_token (LEX *lf, int expect);
+LEX * lex_close_file (LEX *lf);
+LEX * lex_open_file (LEX *lf, char *fname, LEX_ERROR_HANDLER *scan_error);
+int lex_get_char (LEX *lf);
+void lex_unget_char (LEX *lf);
+char * lex_tok_to_str (int token);
+int lex_get_token (LEX *lf, int expect);
/* message.c */
-void my_name_is (int argc, char *argv[], char *name);
-void init_msg (void *jcr, MSGS *msg);
-void term_msg (void);
-void close_msg (void *jcr);
-void add_msg_dest (MSGS *msg, int dest, int type, char *where, char *dest_code);
-void rem_msg_dest (MSGS *msg, int dest, int type, char *where);
-void Jmsg (void *jcr, int type, int level, char *fmt, ...);
-void dispatch_message (void *jcr, int type, int level, char *buf);
-void init_console_msg (char *wd);
-void free_msgs_res (MSGS *msgs);
-int open_spool_file (void *jcr, BSOCK *bs);
-int close_spool_file (void *vjcr, BSOCK *bs);
+void my_name_is (int argc, char *argv[], char *name);
+void init_msg (JCR *jcr, MSGS *msg);
+void term_msg (void);
+void close_msg (JCR *jcr);
+void add_msg_dest (MSGS *msg, int dest, int type, char *where, char *dest_code);
+void rem_msg_dest (MSGS *msg, int dest, int type, char *where);
+void Jmsg (JCR *jcr, int type, int level, char *fmt, ...);
+void dispatch_message (JCR *jcr, int type, int level, char *buf);
+void init_console_msg (char *wd);
+void free_msgs_res (MSGS *msgs);
+int open_spool_file (JCR *jcr, BSOCK *bs);
+int close_spool_file (JCR *jcr, BSOCK *bs);
/* bnet_server.c */
-void bnet_thread_server(char *bind_addr, int port, int max_clients, workq_t *client_wq,
- void *handle_client_request(void *bsock));
-void bnet_server (int port, void handle_client_request(BSOCK *bsock));
-int net_connect (int port);
-BSOCK * bnet_bind (int port);
-BSOCK * bnet_accept (BSOCK *bsock, char *who);
+void bnet_thread_server(char *bind_addr, int port, int max_clients, workq_t *client_wq,
+ void *handle_client_request(void *bsock));
+void bnet_server (int port, void handle_client_request(BSOCK *bsock));
+int net_connect (int port);
+BSOCK * bnet_bind (int port);
+BSOCK * bnet_accept (BSOCK *bsock, char *who);
/* signal.c */
-void init_signals (void terminate(int sig));
-void init_stack_dump (void);
+void init_signals (void terminate(int sig));
+void init_stack_dump (void);
/* util.c */
-void lcase (char *str);
-void bash_spaces (char *str);
-void unbash_spaces (char *str);
-void strip_trailing_junk (char *str);
-void strip_trailing_slashes (char *dir);
-int skip_spaces (char **msg);
-int skip_nonspaces (char **msg);
-int fstrsch (char *a, char *b);
-char * encode_time (time_t time, char *buf);
-char * encode_mode (mode_t mode, char *buf);
-int do_shell_expansion (char *name, int name_len);
-int is_buf_zero (char *buf, int len);
-void jobstatus_to_ascii (int JobStatus, char *msg, int maxlen);
-void pm_strcat (POOLMEM **pm, char *str);
-void pm_strcpy (POOLMEM **pm, 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);
-void makeSessionKey (char *key, char *seed, int mode);
-BPIPE * open_bpipe(char *prog, int wait, char *mode);
-int close_wpipe(BPIPE *bpipe);
-int close_bpipe(BPIPE *bpipe);
-POOLMEM *edit_job_codes(void *jcr, char *omsg, char *imsg, char *to);
-void parse_command_args(POOLMEM *cmd, POOLMEM *args, int *argc,
- char **argk, char **argv);
-char *next_arg(char **s);
-void set_working_directory(char *wd);
+void lcase (char *str);
+void bash_spaces (char *str);
+void unbash_spaces (char *str);
+void strip_trailing_junk (char *str);
+void strip_trailing_slashes (char *dir);
+int skip_spaces (char **msg);
+int skip_nonspaces (char **msg);
+int fstrsch (char *a, char *b);
+char * encode_time (time_t time, char *buf);
+char * encode_mode (mode_t mode, char *buf);
+int do_shell_expansion (char *name, int name_len);
+int is_buf_zero (char *buf, int len);
+void jobstatus_to_ascii (int JobStatus, char *msg, int maxlen);
+void pm_strcat (POOLMEM **pm, char *str);
+void pm_strcpy (POOLMEM **pm, 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);
+void makeSessionKey (char *key, char *seed, int mode);
+BPIPE * open_bpipe(char *prog, int wait, char *mode);
+int close_wpipe(BPIPE *bpipe);
+int close_bpipe(BPIPE *bpipe);
+POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, char *to);
+void parse_command_args(POOLMEM *cmd, POOLMEM *args, int *argc,
+ char **argk, char **argv);
+char *next_arg(char **s);
+void set_working_directory(char *wd);
/* watchdog.c */
int start_watchdog(void);
* to = recepients list
*
*/
-POOLMEM *edit_job_codes(void *mjcr, char *omsg, char *imsg, char *to)
+POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, char *to)
{
char *p, *str;
char add[20];
- JCR *jcr = (JCR *)mjcr;
*omsg = 0;
Dmsg1(200, "edit_job_codes: %s\n", imsg);
/* dump_block(block, "before write"); */
if (dev->state & ST_WEOT) {
Dmsg0(100, "return write_block_to_dev with ST_WEOT\n");
- Jmsg(&dev->errmsg, M_FATAL, 0, _("Cannot write block. Device at EOM.\n"));
+ Jmsg(jcr, M_FATAL, 0, _("Cannot write block. Device at EOM.\n"));
return 0;
}
wlen = block->binbuf;
dev->state |= ST_WEOT;
Dmsg0(10, "==== Output bytes Triggered medium max capacity.\n");
if (hit_max1) {
- Jmsg(&dev->errmsg, M_INFO, 0, _("Max. Volume capacity %s exceeded on device %s.\n"),
+ Jmsg(jcr, M_INFO, 0, _("Max. Volume capacity %s exceeded on device %s.\n"),
edit_uint64(dev->max_volume_size, ed1), dev->dev_name);
} else {
- Jmsg(&dev->errmsg, M_INFO, 0, _("Max. Volume capacity %s exceeded on device %s.\n"),
+ Jmsg(jcr, M_INFO, 0, _("Max. Volume capacity %s exceeded on device %s.\n"),
edit_uint64(dev->VolCatInfo.VolCatMaxBytes, ed1), dev->dev_name);
}
block->failed_write = TRUE;
wlen, stat, dev->dev_errno, strerror(dev->dev_errno));
if (stat == -1) {
- Jmsg2(&dev->errmsg, M_ERROR, 0, _("Write error on device %s. ERR=%s.\n"),
+ Jmsg2(jcr, M_ERROR, 0, _("Write error on device %s. ERR=%s.\n"),
dev->dev_name, strerror(dev->dev_errno));
} else {
- Jmsg3(&dev->errmsg, M_INFO, 0, _("End of media on device %s. Write of %u bytes got %d.\n"),
+ Jmsg3(jcr, M_INFO, 0, _("End of media on device %s. Write of %u bytes got %d.\n"),
dev->dev_name, wlen, stat);
}
block->failed_write = TRUE;
char ec1[30];
- fd->jcr = (void *)jcr;
- dir->jcr = (void *)jcr;
+ fd->jcr = jcr;
+ dir->jcr = jcr;
Dmsg1(120, "Start run Job=%s\n", jcr->Job);
bnet_fsend(dir, Job_start, jcr->Job);
jcr->start_time = time(NULL);
}
jcr->file_bsock = fd;
- jcr->file_bsock->jcr = (void *)jcr;
+ jcr->file_bsock->jcr = jcr;
Dmsg1(110, "Found Job %s\n", job_name);
* Cancel Job if too many label errors
* => we are in a loop
*/
- if (jcr->label_errors > 100) {
- set_jcr_job_status(jcr, JS_ErrorTerminated);
+ if (jcr->label_errors++ > 100) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->errmsg);
}
return jcr->label_status = VOL_NAME_ERROR;
* Cancel Job if too many label errors
* => we are in a loop
*/
- if (jcr->label_errors > 100) {
- set_jcr_job_status(jcr, JS_ErrorTerminated);
+ if (jcr->label_errors++ > 100) {
Jmsg(jcr, M_FATAL, 0, "%s", jcr->errmsg);
}
return jcr->label_status = VOL_NAME_ERROR;