本文整理汇总了C++中POOL_MEM::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ POOL_MEM::c_str方法的具体用法?C++ POOL_MEM::c_str怎么用?C++ POOL_MEM::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类POOL_MEM
的用法示例。
在下文中一共展示了POOL_MEM::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pm_strcpy
int pm_strcpy(POOLMEM *&pm, POOL_MEM &str)
{
int len = strlen(str.c_str()) + 1;
pm = check_pool_memory_size(pm, len);
memcpy(pm, str.c_str(), len);
return len - 1;
}
示例2: pm_strcat
int pm_strcat(POOLMEM *&pm, POOL_MEM &str)
{
int pmlen = strlen(pm);
int len = strlen(str.c_str()) + 1;
pm = check_pool_memory_size(pm, pmlen + len);
memcpy(pm+pmlen, str.c_str(), len);
return pmlen + len - 1;
}
示例3: edit_mount_codes
/*
* Edit codes into (Un)MountCommand, Write(First)PartCommand
* %% = %
* %a = archive device name
* %e = erase (set if cannot mount and first part)
* %n = part number
* %m = mount point
* %v = last part name
*
* omsg = edited output message
* imsg = input string containing edit codes (%x)
*
*/
void DEVICE::edit_mount_codes(POOL_MEM &omsg, const char *imsg)
{
const char *p;
const char *str;
char add[20];
POOL_MEM archive_name(PM_FNAME);
omsg.c_str()[0] = 0;
Dmsg1(800, "edit_mount_codes: %s\n", imsg);
for (p=imsg; *p; p++) {
if (*p == '%') {
switch (*++p) {
case '%':
str = "%";
break;
case 'a':
str = dev_name;
break;
case 'e':
if (num_dvd_parts == 0) {
if (truncating || blank_dvd) {
str = "2";
} else {
str = "1";
}
} else {
str = "0";
}
break;
case 'n':
bsnprintf(add, sizeof(add), "%d", part);
str = add;
break;
case 'm':
str = device->mount_point;
break;
default:
add[0] = '%';
add[1] = *p;
add[2] = 0;
str = add;
break;
}
} else {
add[0] = *p;
add[1] = 0;
str = add;
}
Dmsg1(1900, "add_str %s\n", str);
pm_strcat(omsg, (char *)str);
Dmsg1(1800, "omsg=%s\n", omsg.c_str());
}
}
示例4: get_path_of_new_resource
bool CONFIG::get_path_of_new_resource(POOL_MEM &path, POOL_MEM &extramsg, const char *component,
const char *resourcetype, const char *name,
bool error_if_exists, bool create_directories)
{
POOL_MEM rel_path(PM_FNAME);
POOL_MEM directory(PM_FNAME);
POOL_MEM resourcetype_lowercase(resourcetype);
resourcetype_lowercase.toLower();
if (!get_path_of_resource(path, component, resourcetype, name, false)) {
return false;
}
path_get_directory(directory, path);
if (create_directories) {
path_create(directory);
}
if (!path_exists(directory)) {
extramsg.bsprintf("Resource config directory \"%s\" does not exist.\n", directory.c_str());
return false;
}
/*
* Store name for temporary file in extramsg.
* Can be used, if result is true.
* Otherwise it contains an error message.
*/
extramsg.bsprintf("%s.tmp", path.c_str());
if (!error_if_exists) {
return true;
}
/*
* File should not exists, as it is going to be created.
*/
if (path_exists(path)) {
extramsg.bsprintf("Resource config file \"%s\" already exists.\n", path.c_str());
return false;
}
if (path_exists(extramsg)) {
extramsg.bsprintf("Temporary resource config file \"%s.tmp\" already exists.\n", path.c_str());
return false;
}
return true;
}
示例5: dump_resource
/*
* Dump contents of resource
*/
void dump_resource(int type, RES *reshdr,
void sendit(void *sock, const char *fmt, ...),
void *sock, bool hide_sensitive_data)
{
POOL_MEM buf;
URES *res = (URES *)reshdr;
BRSRES *resclass;
bool recurse = true;
if (res == NULL) {
sendit(sock, _("Warning: no \"%s\" resource (%d) defined.\n"), res_to_str(type), type);
return;
}
if (type < 0) { /* no recursion */
type = - type;
recurse = false;
}
switch (type) {
default:
resclass = (BRSRES *)reshdr;
resclass->print_config(buf);
break;
}
sendit(sock, "%s", buf.c_str());
if (recurse && res->res_dir.hdr.next) {
dump_resource(type, res->res_dir.hdr.next, sendit, sock, hide_sensitive_data);
}
}
示例6: json_finalize_result
void OUTPUT_FORMATTER::json_finalize_result(bool result)
{
POOL_MEM string;
json_t *msg_obj = json_object();
json_t *error_obj;
/*
* We mimic json-rpc result and error messages,
* To make it easier to implement real json-rpc later on.
*/
json_object_set(msg_obj, "jsonrpc", json_string("2.0"));
json_object_set(msg_obj, "id", json_null());
if (result) {
json_object_set(msg_obj, "result", result_array_json);
} else {
error_obj = json_object();
json_object_set_new(error_obj, "code", json_integer(1));
json_object_set_new(error_obj, "message", json_string("failed"));
json_object_set(error_obj, "data", result_array_json);
json_object_set_new(msg_obj, "error", error_obj);
}
string.bsprintf("%s\n", json_dumps(msg_obj, UA_JSON_FLAGS));
send_func(send_ctx, string.c_str());
json_array_clear(result_array_json);
json_object_clear(msg_obj);
}
示例7: add_file_and_part_name
static void add_file_and_part_name(DEVICE *dev, POOL_MEM &archive_name)
{
char partnumber[20];
if (!IsPathSeparator(archive_name.c_str()[strlen(archive_name.c_str())-1])) {
pm_strcat(archive_name, "/");
}
pm_strcat(archive_name, dev->getVolCatName());
/* if part > 1, append .# to the filename (where # is the part number) */
if (dev->part > 1) {
pm_strcat(archive_name, ".");
bsnprintf(partnumber, sizeof(partnumber), "%d", dev->part);
pm_strcat(archive_name, partnumber);
}
Dmsg2(400, "Exit add_file_part_name: arch=%s, part=%d\n",
archive_name.c_str(), dev->part);
}
示例8: configure_lex_error_handler
static void configure_lex_error_handler(const char *file, int line, LEX *lc, POOL_MEM &msg)
{
UAContext *ua;
lc->error_counter++;
if (lc->caller_ctx) {
ua = (UAContext *)(lc->caller_ctx);
ua->error_msg("configure error: %s\n", msg.c_str());
};
}
示例9: while
/* Convert spaces to non-space character.
* This makes scanf of fields containing spaces easier.
*/
void
bash_spaces(POOL_MEM &pm)
{
char *str = pm.c_str();
while (*str) {
if (*str == ' ')
*str = 0x1;
str++;
}
}
示例10: edit_mount_codes
/*
* Edit codes into (Un)MountCommand
* %% = %
* %a = archive device name
* %m = mount point
*
* omsg = edited output message
* imsg = input string containing edit codes (%x)
*
*/
void DEVICE::edit_mount_codes(POOL_MEM &omsg, const char *imsg)
{
const char *p;
const char *str;
char add[20];
POOL_MEM archive_name(PM_FNAME);
omsg.c_str()[0] = 0;
Dmsg1(800, "edit_mount_codes: %s\n", imsg);
for (p=imsg; *p; p++) {
if (*p == '%') {
switch (*++p) {
case '%':
str = "%";
break;
case 'a':
str = dev_name;
break;
case 'm':
str = device->mount_point;
break;
default:
add[0] = '%';
add[1] = *p;
add[2] = 0;
str = add;
break;
}
} else {
add[0] = *p;
add[1] = 0;
str = add;
}
Dmsg1(1900, "add_str %s\n", str);
pm_strcat(omsg, (char *)str);
Dmsg1(1800, "omsg=%s\n", omsg.c_str());
}
}
示例11:
static inline bool configure_create_resource_string(UAContext *ua, int first_parameter, RES_TABLE *res_table,
POOL_MEM &resourcename, POOL_MEM &resource)
{
resource.strcat(res_table->name);
resource.strcat(" {\n");
/*
* Is the name of the resource already given as value of the resource type?
* E.g. configure add client=newclient address=127.0.0.1 ...
* instead of configure add client name=newclient address=127.0.0.1 ...
*/
if (ua->argv[first_parameter - 1]) {
resourcename.strcat(ua->argv[first_parameter - 1]);
if (!config_add_directive(ua, res_table, "name", resourcename.c_str(), resource)) {
return false;
}
}
for (int i = first_parameter; i < ua->argc; i++) {
if (!ua->argv[i]) {
ua->error_msg("Missing value for directive \"%s\"\n", ua->argk[i]);
return false;
}
if (bstrcasecmp(ua->argk[i], "name")) {
resourcename.strcat(ua->argv[i]);
}
if (!config_add_directive(ua, res_table, ua->argk[i], ua->argv[i], resource)) {
return false;
}
}
resource.strcat("}\n");
if (strlen(resourcename.c_str()) <= 0) {
ua->error_msg("Resource \"%s\": missing name parameter.\n", res_table->name);
return false;
}
return true;
}
示例12: get_and_display_basejobs
/*
* Fill the rx->BaseJobIds and display the list
*/
static void get_and_display_basejobs(UAContext *ua, RESTORE_CTX *rx)
{
db_list_ctx jobids;
if (!db_get_used_base_jobids(ua->jcr, ua->db, rx->JobIds, &jobids)) {
ua->warning_msg("%s", db_strerror(ua->db));
}
if (jobids.count) {
POOL_MEM q;
Mmsg(q, uar_print_jobs, jobids.list);
ua->send_msg(_("The restore will use the following job(s) as Base\n"));
db_list_sql_query(ua->jcr, ua->db, q.c_str(), prtit, ua, 1, HORZ_LIST);
}
pm_strcpy(rx->BaseJobIds, jobids.list);
}
示例13: make_unique_restore_filename
static void make_unique_restore_filename(UAContext *ua, POOL_MEM &fname)
{
JCR *jcr = ua->jcr;
int i = find_arg_with_value(ua, "bootstrap");
if (i >= 0) {
Mmsg(fname, "%s", ua->argv[i]);
jcr->unlink_bsr = false;
} else {
P(mutex);
uniq++;
V(mutex);
Mmsg(fname, "%s/%s.restore.%u.bsr", working_directory, my_name, uniq);
jcr->unlink_bsr = true;
}
if (jcr->RestoreBootstrap) {
free(jcr->RestoreBootstrap);
}
jcr->RestoreBootstrap = bstrdup(fname.c_str());
}
示例14: send_accurate_current_files
/*
* Send current file list to FD
* DIR -> FD : accurate files=xxxx
* DIR -> FD : /path/to/file\0Lstat
* DIR -> FD : /path/to/dir/\0Lstat
* ...
* DIR -> FD : EOD
*/
bool send_accurate_current_files(JCR *jcr)
{
POOL_MEM buf;
if (!jcr->accurate || job_canceled(jcr) || jcr->get_JobLevel()==L_FULL) {
return true;
}
POOLMEM *jobids = get_pool_memory(PM_FNAME);
db_accurate_get_jobids(jcr, jcr->db, &jcr->jr, jobids);
if (*jobids == 0) {
free_pool_memory(jobids);
Jmsg(jcr, M_FATAL, 0, _("Cannot find previous jobids.\n"));
return false;
}
Jmsg(jcr, M_INFO, 0, _("Sending Accurate information.\n"));
/* to be able to allocate the right size for htable */
POOLMEM *nb = get_pool_memory(PM_FNAME);
*nb = 0; /* clear buffer */
Mmsg(buf, "SELECT sum(JobFiles) FROM Job WHERE JobId IN (%s)",jobids);
db_sql_query(jcr->db, buf.c_str(), db_get_int_handler, nb);
Dmsg2(200, "jobids=%s nb=%s\n", jobids, nb);
jcr->file_bsock->fsend("accurate files=%s\n", nb);
if (!db_open_batch_connexion(jcr, jcr->db)) {
Jmsg0(jcr, M_FATAL, 0, "Can't get dedicate sql connexion");
return false;
}
db_get_file_list(jcr, jcr->db_batch, jobids, accurate_list_handler, (void *)jcr);
/* TODO: close the batch connexion ? (can be used very soon) */
free_pool_memory(jobids);
free_pool_memory(nb);
jcr->file_bsock->signal(BNET_EOD);
return true;
}
示例15: list_result
/*
* If full_list is set, we list vertically, otherwise, we
* list on one line horizontally.
* Return number of rows
*/
int list_result(JCR *jcr, B_DB *mdb, OUTPUT_FORMATTER *send, e_list_type type)
{
SQL_FIELD *field;
SQL_ROW row;
int i, col_len, max_len = 0;
int num_fields;
char ewc[30];
POOL_MEM key;
POOL_MEM value;
Dmsg0(800, "list_result starts\n");
if (sql_num_rows(mdb) == 0) {
send->decoration(_("No results to list.\n"));
send->object_end("table");
return sql_num_rows(mdb);
}
num_fields = sql_num_fields(mdb);
switch (type) {
case NF_LIST:
case RAW_LIST:
/*
* No need to calculate things like column widths for
* unformated or raw output.
*/
break;
case HORZ_LIST:
case VERT_LIST:
Dmsg1(800, "list_result starts looking at %d fields\n", num_fields);
/*
* Determine column display widths
*/
sql_field_seek(mdb, 0);
for (i = 0; i < num_fields; i++) {
Dmsg1(800, "list_result processing field %d\n", i);
field = sql_fetch_field(mdb);
if (!field) {
break;
}
col_len = cstrlen(field->name);
if (type == VERT_LIST) {
if (col_len > max_len) {
max_len = col_len;
}
} else {
if (sql_field_is_numeric(mdb, field->type) && (int)field->max_length > 0) { /* fixup for commas */
field->max_length += (field->max_length - 1) / 3;
}
if (col_len < (int)field->max_length) {
col_len = field->max_length;
}
if (col_len < 4 && !sql_field_is_not_null(mdb, field->flags)) {
col_len = 4; /* 4 = length of the word "NULL" */
}
field->max_length = col_len; /* reset column info */
}
}
break;
}
Dmsg0(800, "list_result finished first loop\n");
switch (type) {
case NF_LIST:
case RAW_LIST:
Dmsg1(800, "list_result starts second loop looking at %d fields\n", num_fields);
while ((row = sql_fetch_row(mdb)) != NULL) {
send->object_start(row[0]);
sql_field_seek(mdb, 0);
for (i = 0; i < num_fields; i++) {
field = sql_fetch_field(mdb);
if (!field) {
break;
}
if (row[i] == NULL) {
value.bsprintf(" %s", "NULL");
} else {
value.bsprintf(" %s", row[i]);
}
send->object_key_value(field->name, value.c_str(), "%s");
}
if (type != RAW_LIST) {
send->decoration("\n");
}
send->object_end(row[0]);
}
break;
case HORZ_LIST:
Dmsg1(800, "list_result starts second loop looking at %d fields\n", num_fields);
list_dashes(mdb, send);
send->decoration("|");
sql_field_seek(mdb, 0);
for (i = 0; i < num_fields; i++) {
Dmsg1(800, "list_result looking at field %d\n", i);
field = sql_fetch_field(mdb);
//.........这里部分代码省略.........