本文整理汇总了C++中Mmsg函数的典型用法代码示例。如果您正苦于以下问题:C++ Mmsg函数的具体用法?C++ Mmsg怎么用?C++ Mmsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Mmsg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: list_volumes
/*
* List Volumes -- this should be moved to status.c
*/
void list_volumes(void sendit(const char *msg, int len, void *sarg), void *arg)
{
VOLRES *vol;
POOL_MEM msg(PM_MESSAGE);
int len;
lock_volumes();
foreach_dlist(vol, vol_list) {
DEVICE *dev = vol->dev;
if (dev) {
len = Mmsg(msg, "%s on device %s\n", vol->vol_name, dev->print_name());
sendit(msg.c_str(), len, arg);
len = Mmsg(msg, " Reader=%d writers=%d devres=%d volinuse=%d\n",
dev->can_read()?1:0, dev->num_writers, dev->num_reserved(),
vol->is_in_use());
sendit(msg.c_str(), len, arg);
} else {
len = Mmsg(msg, "%s no device. volinuse= %d\n", vol->vol_name,
vol->is_in_use());
sendit(msg.c_str(), len, arg);
}
}
示例2: mark_row
static void mark_row(int row, bool mark)
{
char *file;
int len;
char new_mark[10];
gtk_clist_get_text(restore->list, row, FILE_COLUMN, &file);
if (mark) {
bstrncpy(new_mark, "x", sizeof(new_mark));
len = Mmsg(&restore->buf, "mark %s", file);
} else {
bstrncpy(new_mark, " ", sizeof(new_mark));
len = Mmsg(&restore->buf, "unmark %s", file);
}
gtk_clist_set_text(restore->list, row, CHECK_COLUMN, new_mark);
/* strip trailing slash from directory name */
while (len > 1 && restore->buf[len-1] == '/') {
restore->buf[len-1] = 0;
}
write_director(restore->buf);
discard_to_prompt();
}
示例3: db_list_base_files_for_job
void db_list_base_files_for_job(JCR *jcr, B_DB *mdb, JobId_t jobid, OUTPUT_FORMATTER *sendit)
{
char ed1[50];
LIST_CTX lctx(jcr, mdb, sendit, NF_LIST);
db_lock(mdb);
/*
* Stupid MySQL is NON-STANDARD !
*/
if (db_get_type_index(mdb) == SQL_TYPE_MYSQL) {
Mmsg(mdb->cmd, "SELECT CONCAT(Path.Path,Filename.Name) AS Filename "
"FROM BaseFiles, File, Filename, Path "
"WHERE BaseFiles.JobId=%s AND BaseFiles.BaseJobId = File.JobId "
"AND BaseFiles.FileId = File.FileId "
"AND Filename.FilenameId=File.FilenameId "
"AND Path.PathId=File.PathId",
edit_int64(jobid, ed1));
} else {
Mmsg(mdb->cmd, "SELECT Path.Path||Filename.Name AS Filename "
"FROM BaseFiles, File, Filename, Path "
"WHERE BaseFiles.JobId=%s AND BaseFiles.BaseJobId = File.JobId "
"AND BaseFiles.FileId = File.FileId "
"AND Filename.FilenameId=File.FilenameId "
"AND Path.PathId=File.PathId",
edit_int64(jobid, ed1));
}
sendit->array_start("files");
if (!db_big_sql_query(mdb, mdb->cmd, list_result, &lctx)) {
goto bail_out;
}
sendit->array_end("files");
sql_free_result(mdb);
bail_out:
db_unlock(mdb);
}
示例4: db_update_job_end_record
/*
* Update the Job record at end of Job
*
* Returns: 0 on failure
* 1 on success
*/
int
db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
{
char dt[MAX_TIME_LENGTH];
char rdt[MAX_TIME_LENGTH];
time_t ttime;
struct tm tm;
int stat;
char ed1[30], ed2[30], ed3[50], ed4[50];
btime_t JobTDate;
char PriorJobId[50];
if (jr->PriorJobId) {
bstrncpy(PriorJobId, edit_int64(jr->PriorJobId, ed1), sizeof(PriorJobId));
} else {
bstrncpy(PriorJobId, "0", sizeof(PriorJobId));
}
ttime = jr->EndTime;
(void)localtime_r(&ttime, &tm);
strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm);
if (jr->RealEndTime == 0) {
jr->RealEndTime = jr->EndTime;
}
ttime = jr->RealEndTime;
(void)localtime_r(&ttime, &tm);
strftime(rdt, sizeof(rdt), "%Y-%m-%d %H:%M:%S", &tm);
JobTDate = ttime;
db_lock(mdb);
Mmsg(mdb->cmd,
"UPDATE Job SET JobStatus='%c',EndTime='%s',"
"ClientId=%u,JobBytes=%s,ReadBytes=%s,JobFiles=%u,JobErrors=%u,VolSessionId=%u,"
"VolSessionTime=%u,PoolId=%u,FileSetId=%u,JobTDate=%s,"
"RealEndTime='%s',PriorJobId=%s,HasBase=%u,PurgedFiles=%u WHERE JobId=%s",
(char)(jr->JobStatus), dt, jr->ClientId, edit_uint64(jr->JobBytes, ed1),
edit_uint64(jr->ReadBytes, ed4),
jr->JobFiles, jr->JobErrors, jr->VolSessionId, jr->VolSessionTime,
jr->PoolId, jr->FileSetId, edit_uint64(JobTDate, ed2),
rdt, PriorJobId, jr->HasBase, jr->PurgedFiles,
edit_int64(jr->JobId, ed3));
stat = UPDATE_DB(jcr, mdb, mdb->cmd);
db_unlock(mdb);
return stat;
}
示例5: do_mount
/*
* (Un)mount the device (for tape devices)
*/
static bool do_mount(DCR *dcr, int mount, int dotimeout)
{
DEVRES *device = dcr->dev->device;
POOL_MEM ocmd(PM_FNAME);
POOLMEM *results;
char *icmd;
int status, tries;
berrno be;
Dsm_check(200);
if (mount) {
icmd = device->mount_command;
} else {
icmd = device->unmount_command;
}
dcr->dev->edit_mount_codes(ocmd, icmd);
Dmsg2(100, "do_mount: cmd=%s mounted=%d\n", ocmd.c_str(), dcr->dev->is_mounted());
if (dotimeout) {
/* Try at most 10 times to (un)mount the device. This should perhaps be configurable. */
tries = 10;
} else {
tries = 1;
}
results = get_memory(4000);
/* If busy retry each second */
Dmsg1(100, "do_mount run_prog=%s\n", ocmd.c_str());
while ((status = run_program_full_output(ocmd.c_str(), dcr->dev->max_open_wait / 2, results)) != 0) {
if (tries-- > 0) {
continue;
}
Dmsg5(100, "Device %s cannot be %smounted. stat=%d result=%s ERR=%s\n", dcr->dev->print_name(),
(mount ? "" : "un"), status, results, be.bstrerror(status));
Mmsg(dcr->dev->errmsg, _("Device %s cannot be %smounted. ERR=%s\n"),
dcr->dev->print_name(), (mount ? "" : "un"), be.bstrerror(status));
free_pool_memory(results);
Dmsg0(200, "============ mount=0\n");
Dsm_check(200);
return false;
}
free_pool_memory(results);
Dmsg1(200, "============ mount=%d\n", mount);
return true;
}
示例6: db_update_pool_record
bool db_update_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
{
bool retval;
char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50], ed6[50];
char esc[MAX_ESCAPE_NAME_LENGTH];
db_lock(mdb);
mdb->db_escape_string(jcr, esc, pr->LabelFormat, strlen(pr->LabelFormat));
Mmsg(mdb->cmd, "SELECT count(*) from Media WHERE PoolId=%s",
edit_int64(pr->PoolId, ed4));
pr->NumVols = get_sql_record_max(jcr, mdb);
Dmsg1(400, "NumVols=%d\n", pr->NumVols);
Mmsg(mdb->cmd,
"UPDATE Pool SET NumVols=%u,MaxVols=%u,UseOnce=%d,UseCatalog=%d,"
"AcceptAnyVolume=%d,VolRetention='%s',VolUseDuration='%s',"
"MaxVolJobs=%u,MaxVolFiles=%u,MaxVolBytes=%s,Recycle=%d,"
"AutoPrune=%d,LabelType=%d,LabelFormat='%s',RecyclePoolId=%s,"
"ScratchPoolId=%s,ActionOnPurge=%d,MinBlockSize=%d,MaxBlockSize=%d WHERE PoolId=%s",
pr->NumVols, pr->MaxVols, pr->UseOnce, pr->UseCatalog,
pr->AcceptAnyVolume, edit_uint64(pr->VolRetention, ed1),
edit_uint64(pr->VolUseDuration, ed2),
pr->MaxVolJobs, pr->MaxVolFiles,
edit_uint64(pr->MaxVolBytes, ed3),
pr->Recycle, pr->AutoPrune, pr->LabelType,
esc, edit_int64(pr->RecyclePoolId,ed5),
edit_int64(pr->ScratchPoolId,ed6),
pr->ActionOnPurge,
pr->MinBlocksize,
pr->MaxBlocksize,
ed4);
retval = UPDATE_DB(jcr, mdb, mdb->cmd);
db_unlock(mdb);
return retval;
}
示例7: db_list_joblog_records
void db_list_joblog_records(JCR *jcr, B_DB *mdb, uint32_t JobId,
OUTPUT_FORMATTER *sendit, e_list_type type)
{
char ed1[50];
if (JobId <= 0) {
return;
}
db_lock(mdb);
if (type == VERT_LIST) {
Mmsg(mdb->cmd, "SELECT Time, LogText FROM Log "
"WHERE Log.JobId=%s ORDER BY Log.LogId", edit_int64(JobId, ed1));
} else {
Mmsg(mdb->cmd, "SELECT Time, LogText FROM Log "
"WHERE Log.JobId=%s ORDER BY Log.LogId", edit_int64(JobId, ed1));
/*
* When something else then a vertical list is requested set the list type
* to RAW_LIST e.g. non formated raw data as that makes the only sense for
* the logtext output. The logtext already has things like \n etc in it
* so we should just dump the raw content out for the best visible output.
*/
type = RAW_LIST;
}
if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
goto bail_out;
}
sendit->array_start("joblog");
list_result(jcr, mdb, sendit, type);
sendit->array_end("joblog");
sql_free_result(mdb);
bail_out:
db_unlock(mdb);
}
示例8: Mmsg
/* Dump the item table format to a text file (used by plugin) */
int ConfigFile::serialize(POOLMEM **buf)
{
int len;
POOLMEM *tmp;
if (!items) {
**buf = 0;
return 0;
}
len = Mmsg(buf, "# Plugin configuration file\n# Version %d\n", version);
tmp = get_pool_memory(PM_MESSAGE);
for (int i = 0; items[i].name; i++) {
if (items[i].comment) {
Mmsg(tmp, "OptPrompt=%s\n", items[i].comment);
pm_strcat(buf, tmp);
}
if (items[i].default_value) {
Mmsg(tmp, "OptDefault=%s\n", items[i].default_value);
pm_strcat(buf, tmp);
}
if (items[i].required) {
Mmsg(tmp, "OptRequired=yes\n");
pm_strcat(buf, tmp);
}
/* variable = @[email protected] */
Mmsg(tmp, "%s=%s\n\n",
items[i].name, ini_get_store_code(items[i].handler));
len = pm_strcat(buf, tmp);
}
free_pool_memory(tmp);
return len ;
}
示例9: db_update_counter_record
/*
* Update Counters record
* Returns: 0 on failure
* 1 on success
*/
int db_update_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr)
{
char esc[MAX_ESCAPE_NAME_LENGTH];
db_lock(mdb);
mdb->db_escape_string(jcr, esc, cr->Counter, strlen(cr->Counter));
Mmsg(mdb->cmd,
"UPDATE Counters SET Counters.MinValue=%d,Counters.MaxValue=%d,CurrentValue=%d,"
"WrapCounter='%s' WHERE Counter='%s'",
cr->MinValue, cr->MaxValue, cr->CurrentValue,
cr->WrapCounter, esc);
int stat = UPDATE_DB(jcr, mdb, mdb->cmd);
db_unlock(mdb);
return stat;
}
示例10: db_find_last_job_start_time
/*
* Find the last job start time for the specified JobLevel
*
* StartTime is returned in stime
*
* Returns: false on failure
* true on success, jr is unchanged, but stime is set
*/
bool
db_find_last_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime, int JobLevel)
{
SQL_ROW row;
char ed1[50], ed2[50];
db_lock(mdb);
pm_strcpy(stime, "0000-00-00 00:00:00"); /* default */
Mmsg(mdb->cmd,
"SELECT StartTime FROM Job WHERE JobStatus IN ('T','W') AND Type='%c' AND "
"Level='%c' AND Name='%s' AND ClientId=%s AND FileSetId=%s "
"ORDER BY StartTime DESC LIMIT 1",
jr->JobType, JobLevel, jr->Name,
edit_int64(jr->ClientId, ed1), edit_int64(jr->FileSetId, ed2));
if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
Mmsg2(&mdb->errmsg, _("Query error for start time request: ERR=%s\nCMD=%s\n"),
sql_strerror(mdb), mdb->cmd);
goto bail_out;
}
if ((row = sql_fetch_row(mdb)) == NULL) {
sql_free_result(mdb);
Mmsg(mdb->errmsg, _("No prior Full backup Job record found.\n"));
goto bail_out;
}
Dmsg1(100, "Got start time: %s\n", row[0]);
pm_strcpy(stime, row[0]);
sql_free_result(mdb);
db_unlock(mdb);
return true;
bail_out:
db_unlock(mdb);
return false;
}
示例11: tmp
/*
* Dump the item table format to a text file (used by plugin)
*/
int ConfigFile::serialize(POOL_MEM *buf)
{
int len;
POOL_MEM tmp(PM_MESSAGE);
if (!items) {
char *p;
p = buf->c_str();
p[0] = '\0';
return 0;
}
len = Mmsg(buf, "# Plugin configuration file\n# Version %d\n", version);
for (int i = 0; items[i].name; i++) {
if (items[i].comment) {
Mmsg(tmp, "OptPrompt=%s\n", items[i].comment);
pm_strcat(buf, tmp.c_str());
}
if (items[i].default_value) {
Mmsg(tmp, "OptDefault=%s\n", items[i].default_value);
pm_strcat(buf, tmp.c_str());
}
if (items[i].required) {
Mmsg(tmp, "OptRequired=yes\n");
pm_strcat(buf, tmp.c_str());
}
/* variable = @[email protected] */
Mmsg(tmp, "%s=%s\n\n",
items[i].name, ini_get_store_code(items[i].type));
len = pm_strcat(buf, tmp.c_str());
}
return len ;
}
示例12: read_state_file
/*
* Open and read the state file for the daemon
*/
void read_state_file(char *dir, const char *progname, int port)
{
int sfd;
ssize_t status;
bool ok = false;
POOLMEM *fname = get_pool_memory(PM_FNAME);
struct s_state_hdr hdr;
int hdr_size = sizeof(hdr);
Mmsg(&fname, "%s/%s.%d.state", dir, progname, port);
/* If file exists, see what we have */
// Dmsg1(10, "O_BINARY=%d\n", O_BINARY);
if ((sfd = open(fname, O_RDONLY|O_BINARY)) < 0) {
berrno be;
Dmsg3(010, "Could not open state file. sfd=%d size=%d: ERR=%s\n",
sfd, sizeof(hdr), be.bstrerror());
goto bail_out;
}
if ((status = read(sfd, &hdr, hdr_size)) != hdr_size) {
berrno be;
Dmsg4(010, "Could not read state file. sfd=%d status=%d size=%d: ERR=%s\n",
sfd, (int)status, hdr_size, be.bstrerror());
goto bail_out;
}
if (hdr.version != state_hdr.version) {
Dmsg2(010, "Bad hdr version. Wanted %d got %d\n",
state_hdr.version, hdr.version);
goto bail_out;
}
hdr.id[13] = 0;
if (!bstrcmp(hdr.id, state_hdr.id)) {
Dmsg0(000, "State file header id invalid.\n");
goto bail_out;
}
// Dmsg1(010, "Read header of %d bytes.\n", sizeof(hdr));
if (!read_last_jobs_list(sfd, hdr.last_jobs_addr)) {
goto bail_out;
}
ok = true;
bail_out:
if (sfd >= 0) {
close(sfd);
}
if (!ok) {
unlink(fname);
}
free_pool_memory(fname);
}
示例13: set_files_to_restore
/*
* See in the tree with selected files what files were selected to be restored.
*/
static inline int set_files_to_restore(JCR *jcr, struct ndm_job_param *job, int32_t FileIndex,
const char *restore_prefix, const char *ndmp_filesystem)
{
int len;
int cnt = 0;
TREE_NODE *node, *parent;
POOL_MEM restore_pathname, tmp;
node = first_tree_node(jcr->restore_tree_root);
while (node) {
/*
* See if this is the wanted FileIndex and the user asked to extract it.
*/
if (node->FileIndex == FileIndex && node->extract) {
pm_strcpy(restore_pathname, node->fname);
/*
* Walk up the parent until we hit the head of the list.
*/
for (parent = node->parent; parent; parent = parent->parent) {
pm_strcpy(tmp, restore_pathname.c_str());
Mmsg(restore_pathname, "%s/%s", parent->fname, tmp.c_str());
}
/*
* We only want to restore the non pseudo NDMP names e.g. not the full backup stream name.
*/
if (!bstrncmp(restore_pathname.c_str(), "/@NDMP/", 7)) {
/*
* See if we need to strip the prefix from the filename.
*/
len = strlen(ndmp_filesystem);
if (bstrncmp(restore_pathname.c_str(), ndmp_filesystem, len)) {
add_to_namelist(job, restore_pathname.c_str() + len, restore_prefix,
(char *)"", (char *)"", NDMP_INVALID_U_QUAD);
} else {
add_to_namelist(job, restore_pathname.c_str(), restore_prefix,
(char *)"", (char *)"", NDMP_INVALID_U_QUAD);
}
cnt++;
}
}
node = next_tree_node(node);
}
return cnt;
}
示例14: db_update_counter_record
/*
* Update Counters record
* Returns: false on failure
* true on success
*/
bool db_update_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr)
{
bool retval;
char esc[MAX_ESCAPE_NAME_LENGTH];
db_lock(mdb);
mdb->db_escape_string(jcr, esc, cr->Counter, strlen(cr->Counter));
Mmsg(mdb->cmd,
update_counter_values[mdb->db_get_type_index()],
cr->MinValue, cr->MaxValue, cr->CurrentValue,
cr->WrapCounter, esc);
retval = UPDATE_DB(jcr, mdb, mdb->cmd);
db_unlock(mdb);
return retval;
}
示例15: db_update_stats
/*
* Update Long term statistics with all jobs that were run before
* age seconds
*/
int db_update_stats(JCR *jcr, B_DB *mdb, utime_t age)
{
char ed1[30];
int rows;
utime_t now = (utime_t)time(NULL);
edit_uint64(now - age, ed1);
db_lock(mdb);
Mmsg(mdb->cmd, fill_jobhisto, ed1);
QUERY_DB(jcr, mdb, mdb->cmd); /* TODO: get a message ? */
rows = sql_affected_rows(mdb);
db_unlock(mdb);
return rows;
}