本文整理汇总了C++中ConfigFile::dump_string方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigFile::dump_string方法的具体用法?C++ ConfigFile::dump_string怎么用?C++ ConfigFile::dump_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::dump_string方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handlePluginEvent
/*
* Handle an event that was generated in Bareos
*/
static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value)
{
struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext;
restore_object_pkt *rop;
if (!p_ctx) {
return bRC_Error;
}
// char *name;
switch (event->eventType) {
case bEventJobStart:
Dmsg(ctx, dbglvl, "test-plugin-fd: JobStart=%s\n", (char *)value);
break;
case bEventEndFileSet:
/*
* End of Dir FileSet commands, now we can add excludes
*/
bfuncs->NewOptions(ctx);
bfuncs->AddWild(ctx, "*.c", ' ');
bfuncs->AddWild(ctx, "*.cpp", ' ');
bfuncs->AddOptions(ctx, "ei"); /* exclude, ignore case */
bfuncs->AddExclude(ctx, "/home/user/bareos/regress/README");
break;
case bEventRestoreObject: {
FILE *fp;
POOLMEM *q;
char *working;
static int _nb = 0;
printf("Plugin RestoreObject\n");
if (!value) {
Dmsg(ctx, dbglvl, "test-plugin-fd: End restore objects\n");
break;
}
rop = (restore_object_pkt *)value;
Dmsg(ctx, dbglvl, "Get RestoreObject len=%d JobId=%d oname=%s type=%d data=%.127s\n",
rop->object_len, rop->JobId, rop->object_name, rop->object_type, rop->object);
q = get_pool_memory(PM_FNAME);
bfuncs->getBareosValue(ctx, bVarWorkingDir, &working);
Mmsg(q, "%s/restore.%d", working, _nb++);
if ((fp = fopen(q, "w")) != NULL) {
fwrite(rop->object, rop->object_len, 1, fp);
fclose(fp);
}
free_pool_memory(q);
if (!strcmp(rop->object_name, INI_RESTORE_OBJECT_NAME)) {
ConfigFile ini;
if (!ini.dump_string(rop->object, rop->object_len)) {
break;
}
ini.register_items(test_items, sizeof(struct ini_items));
if (ini.parse(ini.out_fname)) {
Jmsg(ctx, M_INFO, "string1 = %s\n", ini.items[0].val.strval);
} else {
Jmsg(ctx, M_ERROR, "Can't parse config\n");
}
}
break;
}
case bEventEstimateCommand:
/* Fall-through wanted */
case bEventBackupCommand: {
/*
* Plugin command e.g. plugin = <plugin-name>:<name-space>:read command:write command
*/
char *p;
Dmsg(ctx, dbglvl, "test-plugin-fd: pluginEvent cmd=%s\n", (char *)value);
p_ctx->cmd = bstrdup((char *)value);
p = strchr(p_ctx->cmd, ':');
if (!p) {
Jmsg(ctx, M_FATAL, "Plugin terminator not found: %s\n", (char *)value);
Dmsg(ctx, dbglvl, "Plugin terminator not found: %s\n", (char *)value);
return bRC_Error;
}
*p++ = 0; /* terminate plugin */
p_ctx->fname = p;
p = strchr(p, ':');
if (!p) {
Jmsg(ctx, M_FATAL, "File terminator not found: %s\n", (char *)value);
Dmsg(ctx, dbglvl, "File terminator not found: %s\n", (char *)value);
return bRC_Error;
}
*p++ = 0; /* terminate file */
p_ctx->reader = p;
p = strchr(p, ':');
if (!p) {
Jmsg(ctx, M_FATAL, "Reader terminator not found: %s\n", (char *)value);
Dmsg(ctx, dbglvl, "Reader terminator not found: %s\n", (char *)value);
return bRC_Error;
}
*p++ = 0; /* terminate reader string */
//.........这里部分代码省略.........