这篇教程C++ Dmsg函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中Dmsg函数的典型用法代码示例。如果您正苦于以下问题:C++ Dmsg函数的具体用法?C++ Dmsg怎么用?C++ Dmsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了Dmsg函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: handleJobEnd/* * At end of job report how inflate/deflate ratio was. */static bRC handleJobEnd(bpContext *ctx){ struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext; if (!p_ctx) { goto bail_out; } if (p_ctx->inflate_bytes_in) { Dmsg(ctx, dbglvl, "autoxflate-sd.c: inflate ratio: %lld/%lld = %0.2f%%/n" , p_ctx->inflate_bytes_out, p_ctx->inflate_bytes_in, (p_ctx->inflate_bytes_out * 100.0 / p_ctx->inflate_bytes_in)); Jmsg(ctx, M_INFO, _("autoxflate-sd.c: inflate ratio: %0.2f%%/n"), (p_ctx->inflate_bytes_out * 100.0 / p_ctx->inflate_bytes_in)); } if (p_ctx->deflate_bytes_in) { Dmsg(ctx, dbglvl, "autoxflate-sd.c: deflate ratio: %lld/%lld = %0.2f%%/n", p_ctx->deflate_bytes_out, p_ctx->deflate_bytes_in, (p_ctx->deflate_bytes_out * 100.0 / p_ctx->deflate_bytes_in)); Jmsg(ctx, M_INFO, _("autoxflate-sd.c: deflate ratio: %0.2f%%/n"), (p_ctx->deflate_bytes_out * 100.0 / p_ctx->deflate_bytes_in)); }bail_out: return bRC_OK;}
开发者ID:debfx,项目名称:bareos,代码行数:31,
示例2: plugin_has_all_argumentsstatic bRC plugin_has_all_arguments(bpContext *ctx){ bRC retval = bRC_OK; plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (!p_ctx) { retval = bRC_Error; } if (!p_ctx->fname) { Jmsg(ctx, M_FATAL, _("bpipe-fd: Plugin File argument not specified./n")); Dmsg(ctx, dbglvl, "bpipe-fd: Plugin File argument not specified./n"); retval = bRC_Error; } if (!p_ctx->reader) { Jmsg(ctx, M_FATAL, _("bpipe-fd: Plugin Reader argument not specified./n")); Dmsg(ctx, dbglvl, "bpipe-fd: Plugin Reader argument not specified./n"); retval = bRC_Error; } if (!p_ctx->writer) { Jmsg(ctx, M_FATAL, _("bpipe-fd: Plugin Writer argument not specified./n")); Dmsg(ctx, dbglvl, "bpipe-fd: Plugin Writer argument not specified./n"); retval = bRC_Error; } return retval;}
开发者ID:dl5rcw,项目名称:bareos,代码行数:29,
示例3: startBackupFile/* * Start the backup of a specific file */static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp){ time_t now; POOL_MEM fname(PM_NAME); char dt[MAX_TIME_LENGTH]; plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (!p_ctx) { return bRC_Error; } /* * If no explicit instance name given use the DEFAULT_INSTANCE. */ if (!p_ctx->instance) { p_ctx->instance = bstrdup(DEFAULT_INSTANCE); } /* * If no explicit server address given use the DEFAULT_SERVER_ADDRESS. */ if (!p_ctx->server_address) { p_ctx->server_address = bstrdup(DEFAULT_SERVER_ADDRESS); } now = time(NULL); switch (p_ctx->backup_level) { case L_FULL: Mmsg(fname, "/@MSSQL/%s/%s/db-full", p_ctx->instance, p_ctx->database); break; case L_DIFFERENTIAL: Mmsg(fname, "/@MSSQL/%s/%s/db-diff", p_ctx->instance, p_ctx->database); break; case L_INCREMENTAL: bstrutime(dt, sizeof(dt), now); Mmsg(fname, "/@MSSQL/%s/%s/log-%s", p_ctx->instance, p_ctx->database, dt); break; default: Jmsg(ctx, M_FATAL, "Unsuported backup level (%c)./n", p_ctx->backup_level); Dmsg(ctx, dbglvl, "Unsuported backup level (%c)./n", p_ctx->backup_level); return bRC_Error; } p_ctx->filename = bstrdup(fname.c_str()); Dmsg(ctx, dbglvl, "startBackupFile: Generated filename %s/n", p_ctx->filename); sp->fname = p_ctx->filename; sp->type = FT_REG; sp->statp.st_mode = S_IFREG | S_IREAD | S_IWRITE | S_IEXEC; sp->statp.st_ctime = now; sp->statp.st_mtime = now; sp->statp.st_atime = now; sp->statp.st_size = 0; sp->statp.st_blksize = DEFAULT_BLOCKSIZE; sp->statp.st_blocks = 1; return bRC_OK;}
开发者ID:karcaw,项目名称:bareos-contrib,代码行数:61,
示例4: tear_down_vdi_device/* * End of I/O tear down the VDI and check if everything did go to plan. */static inline bool tear_down_vdi_device(bpContext *ctx, struct io_pkt *io){ HRESULT hr = NOERROR; VDC_Command *cmd; plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; Dmsg(ctx, dbglvl, "mssqlvdi-fd: entering tear_down_vdi_device/n"); /* * Check if the VDI device is closed. */ if (p_ctx->VDIDevice) { hr = p_ctx->VDIDevice->GetCommand(VDI_WAIT_TIMEOUT , &cmd); if (hr != VD_E_CLOSE) { Jmsg(ctx, M_ERROR, "Abnormal termination, VDIDevice not closed."); Dmsg(ctx, dbglvl, "Abnormal termination, VDIDevice not closed."); goto bail_out; } } /* * Close and release the VDIDevice and VDIDeviceSet. */ close_vdi_deviceset(p_ctx); /* * See if there is any error to report from the ADO layer. */ if (p_ctx->AdoThreadStarted) { if (adoReportError(ctx)) { goto bail_out; } } io->status = 0; io->io_errno = 0; io->lerror = 0; io->win32 = false; Dmsg(ctx, dbglvl, "mssqlvdi-fd: leaving tear_down_vdi_device/n"); return true;bail_out: /* * Report any COM errors. */ comReportError(ctx, hr); Dmsg(ctx, dbglvl, "mssqlvdi-fd: leaving tear_down_vdi_device/n"); return false;}
开发者ID:janstadler,项目名称:bareos,代码行数:56,
示例5: handlePluginEvent/* * Handle an event that was generated in Bareos */static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value){ bRC retval = bRC_OK; struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext; if (!p_ctx) { return bRC_Error; } switch (event->eventType) { case bEventJobStart: Dmsg(ctx, dbglvl, "bpipe-fd: JobStart=%s/n", (char *)value); break; case bEventRestoreCommand: /* * Fall-through wanted */ case bEventBackupCommand: /* * Fall-through wanted */ case bEventEstimateCommand: /* * Fall-through wanted */ case bEventPluginCommand: retval = parse_plugin_definition(ctx, value); break; case bEventNewPluginOptions: /* * Free any previous value. */ if (p_ctx->plugin_options) { free(p_ctx->plugin_options); p_ctx->plugin_options = NULL; } retval = parse_plugin_definition(ctx, value); /* * Save that we got a plugin override. */ p_ctx->plugin_options = bstrdup((char *)value); break; default: Jmsg(ctx, M_FATAL, "bpipe-fd: unknown event=%d/n", event->eventType); Dmsg(ctx, dbglvl, "bpipe-fd: unknown event=%d/n", event->eventType); retval = bRC_Error; break; } return retval;}
开发者ID:dl5rcw,项目名称:bareos,代码行数:56,
示例6: freePlugin/* * Free a plugin instance, i.e. release our private storage */static bRC freePlugin(bpContext *ctx){ plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (!p_ctx) { return bRC_Error; } Dmsg(ctx, dbglvl, "rados-fd: entering freePlugin/n"); if (p_ctx->snap_id) { rados_ioctx_snap_remove(p_ctx->ioctx, p_ctx->rados_snapshotname); p_ctx->snap_id = 0; } if (p_ctx->cluster_initialized) { rados_shutdown(p_ctx->cluster); p_ctx->cluster_initialized = false; } free_pool_memory(p_ctx->next_filename); if (p_ctx->rados_snapshotname) { free(p_ctx->rados_snapshotname); }#if defined(HAVE_RADOS_NAMESPACES) && defined(LIBRADOS_ALL_NSPACES) if (p_ctx->rados_namespace) { free(p_ctx->rados_namespace); }#endif if (p_ctx->rados_poolname) { free(p_ctx->rados_poolname); } if (p_ctx->rados_conffile) { free(p_ctx->rados_conffile); } if (p_ctx->plugin_options) { free(p_ctx->plugin_options); } free(p_ctx); p_ctx = NULL; Dmsg(ctx, dbglvl, "rados-fd: leaving freePlugin/n"); return bRC_OK;}
开发者ID:karcaw,项目名称:bareos-contrib,代码行数:53,
示例7: end_restore_job/* * See if we need to do any postprocessing after the restore. */static bRC end_restore_job(bpContext *ctx, void *value){ bRC retval = bRC_OK; plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (!p_ctx) { return bRC_Error; } Dmsg(ctx, dbglvl, "cephfs-fd: entering end_restore_job/n"); Dmsg(ctx, dbglvl, "cephfs-fd: leaving end_restore_job/n"); return retval;}
开发者ID:debfx,项目名称:bareos,代码行数:18,
示例8: newPlugin/* * The following entry points are accessed through the function * pointers we supplied to Bareos. Each plugin type (dir, fd, sd) * has its own set of entry points that the plugin must define. * * Create a new instance of the plugin i.e. allocate our private storage */static bRC newPlugin(bpContext *ctx){ int JobId = 0; struct plugin_ctx *p_ctx; bfuncs->getBareosValue(ctx, bsdVarJobId, (void *)&JobId); Dmsg(ctx, dbglvl, "autoxflate-sd: newPlugin JobId=%d/n", JobId); p_ctx = (struct plugin_ctx *)malloc(sizeof(struct plugin_ctx)); if (!p_ctx) { return bRC_Error; } memset(p_ctx, 0, sizeof(struct plugin_ctx)); ctx->pContext = (void *)p_ctx; /* set our context pointer */ /* * Only register plugin events we are interested in. * * bsdEventJobEnd - SD Job finished. * bsdEventSetupRecordTranslation - Setup the buffers for doing record translation. * bsdEventReadRecordTranslation - Perform read-side record translation. * bsdEventWriteRecordTranslation - Perform write-side record translantion. */ bfuncs->registerBareosEvents(ctx, 4, bsdEventJobEnd, bsdEventSetupRecordTranslation, bsdEventReadRecordTranslation, bsdEventWriteRecordTranslation); return bRC_OK;}
开发者ID:debfx,项目名称:bareos,代码行数:40,
示例9: PySequence_Fast/* * Callback function which is exposed as a part of the additional methods which allow * a Python plugin to issue a Register Event to register additional events it wants * to receive. */static PyObject *PyBareosRegisterEvents(PyObject *self, PyObject *args){ int len, event; bpContext *ctx; PyObject *pyCtx, *pyEvents, *pySeq, *pyEvent; if (!PyArg_ParseTuple(args, "OO:BareosRegisterEvents", &pyCtx, &pyEvents)) { return NULL; } pySeq = PySequence_Fast(pyEvents, "Expected a sequence of events"); if (!pySeq) { return NULL; } len = PySequence_Fast_GET_SIZE(pySeq); ctx = PyGetbpContext(pyCtx); for (int i = 0; i < len; i++) { pyEvent = PySequence_Fast_GET_ITEM(pySeq, i); event = PyInt_AsLong(pyEvent); if (event >= bDirEventJobStart && event <= bDirEventGetScratch) { Dmsg(ctx, dbglvl, "PyBareosRegisterEvents: registering event %d/n", event); bfuncs->registerBareosEvents(ctx, 1, event); } } Py_DECREF(pySeq); Py_INCREF(Py_None); return Py_None;}
开发者ID:bitroniq,项目名称:bareos,代码行数:38,
示例10: startBackupFile/* * Start the backup of a specific file */static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp){ delta_test *self = get_self(ctx); if (!self) { return bRC_Error; } time_t now = time(NULL); sp->fname = (char *)"/delta.txt"; sp->type = FT_REG; sp->statp.st_mode = 0700 | S_IFREG; sp->statp.st_ctime = now; sp->statp.st_mtime = now; sp->statp.st_atime = now; sp->statp.st_size = -1; sp->statp.st_blksize = 4096; sp->statp.st_blocks = 1; if (self->level == 'I' || self->level == 'D') { bRC state = bfuncs->checkChanges(ctx, sp); /* Should always be bRC_OK */ sp->type = (state == bRC_Seen)? FT_NOCHG : FT_REG; sp->flags |= (FO_DELTA|FO_OFFSETS); self->delta = sp->delta_seq + 1; } pm_strcpy(self->fname, files[self->delta % nb_files]); Dmsg(ctx, dbglvl, "delta-test-fd: delta_seq=%i delta=%i fname=%s/n", sp->delta_seq, self->delta, self->fname);// Dmsg(ctx, dbglvl, "delta-test-fd: startBackupFile/n"); return bRC_OK;}
开发者ID:anarexia,项目名称:bacula,代码行数:32,
示例11: set_ado_connect_string/* * Create a connection string for connecting to the master database. */static void set_ado_connect_string(bpContext *ctx){ POOL_MEM ado_connect_string(PM_NAME); plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (bstrcasecmp(p_ctx->instance, DEFAULT_INSTANCE)) { pm_strcpy(ado_connect_string, "Provider=SQLOLEDB.1;Data Source=localhost;Initial Catalog=master"); } else { Mmsg(ado_connect_string, "Provider=SQLOLEDB.1;Data Source=localhost//%s;Initial Catalog=master", p_ctx->instance); } /* * See if we need to use a username/password or a trusted connection. */ if (p_ctx->username && p_ctx->password) { POOL_MEM temp(PM_NAME); Mmsg(temp, ";User Id=%s;Password=%s;", p_ctx->username, p_ctx->password); pm_strcat(ado_connect_string, temp.c_str()); } else { pm_strcat(ado_connect_string, ";Integrated Security=SSPI;"); } Dmsg(ctx, dbglvl, "set_ado_connect_string: ADO Connect String '%s'/n", ado_connect_string.c_str()); if (p_ctx->ado_connect_string) { free(p_ctx->ado_connect_string); } p_ctx->ado_connect_string = bstrdup(ado_connect_string.c_str());}
开发者ID:janstadler,项目名称:bareos,代码行数:37,
示例12: freePlugin/* * Free a plugin instance, i.e. release our private storage */static bRC freePlugin(bpContext *ctx){ plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (!p_ctx) { return bRC_Error; } Dmsg(ctx, dbglvl, "cephfs-fd: entering freePlugin/n"); if (p_ctx->path_list) { free_path_list(p_ctx->path_list); p_ctx->path_list = NULL; } if (p_ctx->dir_stack) { p_ctx->dir_stack->destroy(); delete p_ctx->dir_stack; } if (p_ctx->cmount) { ceph_shutdown(p_ctx->cmount); p_ctx->cmount = NULL; } free_pool_memory(p_ctx->xattr_list); free_pool_memory(p_ctx->link_target); free_pool_memory(p_ctx->next_filename); free_pool_memory(p_ctx->cwd); if (p_ctx->conffile) { free(p_ctx->conffile); } if (p_ctx->plugin_options) { free(p_ctx->plugin_options); } free(p_ctx); p_ctx = NULL; Dmsg(ctx, dbglvl, "cephfs-fd: leaving freePlugin/n"); return bRC_OK;}
开发者ID:debfx,项目名称:bareos,代码行数:47,
示例13: pluginIO/* * Bareos is calling us to do the actual I/O */static bRC pluginIO(bpContext *ctx, struct io_pkt *io){ DWORD completionCode = ERROR_BAD_ENVIRONMENT; plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (!p_ctx) { return bRC_Error; } switch(io->func) { case IO_OPEN: if (!setup_vdi_device(ctx, io)) { goto bail_out; } break; case IO_READ: case IO_WRITE: if (!p_ctx->VDIDevice) { return bRC_Error; } if (!perform_vdi_io(ctx, io, &completionCode)) { goto bail_out; } break; case IO_CLOSE: if (!tear_down_vdi_device(ctx, io)) { goto bail_out; } break; case IO_SEEK: Jmsg(ctx, M_ERROR, "Illegal Seek request on VDIDevice."); Dmsg(ctx, dbglvl, "Illegal Seek request on VDIDevice."); goto bail_out; } return bRC_OK;bail_out: /* * Report any ADO errors. */ adoReportError(ctx); /* * Generic error handling. */ close_vdi_deviceset(p_ctx); io->io_errno = completionCode; io->lerror = completionCode; io->win32 = true; io->status = -1; return bRC_Error;}
开发者ID:janstadler,项目名称:bareos,代码行数:58,
示例14: freePlugin/* * Free a plugin instance, i.e. release our private storage */static bRC freePlugin(bpContext *ctx){ int JobId = 0; struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext; bfuncs->getBareosValue(ctx, bsdVarJobId, (void *)&JobId); Dmsg(ctx, dbglvl, "autoxflate-sd: freePlugin JobId=%d/n", JobId); if (!p_ctx) { Dmsg(ctx, dbglvl, "autoxflate-sd: freePlugin JobId=%d/n", JobId); return bRC_Error; } if (p_ctx) { free(p_ctx); } ctx->pContext = NULL; return bRC_OK;}
开发者ID:debfx,项目名称:bareos,代码行数:23,
示例15: perform_ado_backup/* * Generate a valid connect string and the backup command we should execute * in the seperate database controling thread. */static inline void perform_ado_backup(bpContext *ctx){ plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; POOL_MEM ado_connect_string(PM_NAME), ado_query(PM_NAME); POOLMEM *vdsname; /* * If no explicit instance name given usedthe DEFAULT_INSTANCE name. */ if (!p_ctx->instance) { p_ctx->instance = bstrdup(DEFAULT_INSTANCE); } set_ado_connect_string(ctx); vdsname = get_pool_memory(PM_NAME); wchar_2_UTF8(&vdsname, p_ctx->vdsname); switch (p_ctx->backup_level) { case L_INCREMENTAL: Mmsg(ado_query, "BACKUP LOG %s TO VIRTUAL_DEVICE='%s' WITH BLOCKSIZE=%d, BUFFERCOUNT=%d, MAXTRANSFERSIZE=%d", p_ctx->database, vdsname, DEFAULT_BLOCKSIZE, DEFAULT_BUFFERS, DEFAULT_BLOCKSIZE); break; case L_DIFFERENTIAL: Mmsg(ado_query, "BACKUP DATABASE %s TO VIRTUAL_DEVICE='%s' WITH DIFFERENTIAL, BLOCKSIZE=%d, BUFFERCOUNT=%d, MAXTRANSFERSIZE=%d", p_ctx->database, vdsname, DEFAULT_BLOCKSIZE, DEFAULT_BUFFERS, DEFAULT_BLOCKSIZE); break; default: Mmsg(ado_query, "BACKUP DATABASE %s TO VIRTUAL_DEVICE='%s' WITH BLOCKSIZE=%d, BUFFERCOUNT=%d, MAXTRANSFERSIZE=%d", p_ctx->database, vdsname, DEFAULT_BLOCKSIZE, DEFAULT_BUFFERS, DEFAULT_BLOCKSIZE); break; } Dmsg(ctx, dbglvl, "perform_ado_backup: ADO Query '%s'/n", ado_query.c_str()); p_ctx->ado_query = bstrdup(ado_query.c_str()); free_pool_memory(vdsname);}
开发者ID:karcaw,项目名称:bareos-contrib,代码行数:58,
示例16: end_restore_job/* * See if we need to do any postprocessing after the restore. */static bRC end_restore_job(bpContext *ctx, void *value){ bRC retval = bRC_OK; plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (!p_ctx) { return bRC_Error; } Dmsg(ctx, dbglvl, "mssqlvdi-fd: entering end_restore_job/n"); if (p_ctx->RecoverAfterRestore) { if (!perform_ado_recover(ctx)) { retval = bRC_Error; } } Dmsg(ctx, dbglvl, "mssqlvdi-fd: leaving end_restore_job/n"); return retval;}
开发者ID:janstadler,项目名称:bareos,代码行数:24,
示例17: handlePluginEvent/* * Handle an event that was generated in Bareos */static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value){ bRC retval; plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (!p_ctx) { return bRC_Error; } switch (event->eventType) { case bEventLevel: p_ctx->backup_level = (int64_t)value; retval = bRC_OK; break; case bEventRestoreCommand: /* * Fall-through wanted */ case bEventBackupCommand: /* * Fall-through wanted */ case bEventPluginCommand: retval = parse_plugin_definition(ctx, value); break; case bEventNewPluginOptions: /* * Free any previous value. */ if (p_ctx->plugin_options) { free(p_ctx->plugin_options); p_ctx->plugin_options = NULL; } retval = parse_plugin_definition(ctx, value); /* * Save that we got a plugin override. */ p_ctx->plugin_options = bstrdup((char *)value); break; case bEventEndRestoreJob: retval = end_restore_job(ctx, value); break; default: Jmsg(ctx, M_FATAL, "mssqlvdi-fd: unknown event=%d/n", event->eventType); Dmsg(ctx, dbglvl, "mssqlvdi-fd: unknown event=%d/n", event->eventType); retval = bRC_Error; break; } return retval;}
开发者ID:karcaw,项目名称:bareos-contrib,代码行数:56,
示例18: adoReportError/* * Print errors (when available) collected by adoThreadSetError function. */static bool adoReportError(bpContext *ctx){ plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (p_ctx->ado_errorstr) { Jmsg(ctx, M_FATAL, "%s/n", p_ctx->ado_errorstr); Dmsg(ctx, dbglvl, "%s/n", p_ctx->ado_errorstr); free(p_ctx->ado_errorstr); p_ctx->ado_errorstr = NULL; return true; } return false;}
开发者ID:janstadler,项目名称:bareos,代码行数:19,
示例19: PyErrorHandler/* * Handle a Python error. * * Python equivalent: * * import traceback, sys * return "".join(traceback.format_exception(sys.exc_type, * sys.exc_value, sys.exc_traceback)) */static void PyErrorHandler(bpContext *ctx, int msgtype){ PyObject *type, *value, *traceback; PyObject *tracebackModule; char *error_string; PyErr_Fetch(&type, &value, &traceback); tracebackModule = PyImport_ImportModule("traceback"); if (tracebackModule != NULL) { PyObject *tbList, *emptyString, *strRetval; tbList = PyObject_CallMethod(tracebackModule, (char *)"format_exception", (char *)"OOO", type, value == NULL ? Py_None : value, traceback == NULL ? Py_None : traceback); emptyString = PyString_FromString(""); strRetval = PyObject_CallMethod(emptyString, (char *)"join", (char *)"O", tbList); error_string = bstrdup(PyString_AsString(strRetval)); Py_DECREF(tbList); Py_DECREF(emptyString); Py_DECREF(strRetval); Py_DECREF(tracebackModule); } else { error_string = bstrdup("Unable to import traceback module."); } Py_DECREF(type); Py_XDECREF(value); Py_XDECREF(traceback); Dmsg(ctx, dbglvl, "%s/n", error_string); if (msgtype) { Jmsg(ctx, msgtype, "%s/n", error_string); } free(error_string);}
开发者ID:bitroniq,项目名称:bareos,代码行数:54,
示例20: handlePluginEvent/* * Handle an event that was generated in Bareos */static bRC handlePluginEvent(bpContext *ctx, bsdEvent *event, void *value){ switch (event->eventType) { case bsdEventSetupRecordTranslation: return setup_record_translation(ctx, value); case bsdEventReadRecordTranslation: return handle_read_translation(ctx, value); case bsdEventWriteRecordTranslation: return handle_write_translation(ctx, value); case bsdEventJobEnd: return handleJobEnd(ctx); default: Dmsg(ctx, dbglvl, "autoxflate-sd: Unknown event %d/n", event->eventType); return bRC_Error; } return bRC_OK;}
开发者ID:debfx,项目名称:bareos,代码行数:21,
示例21: PyGetbpContext/* * Callback function which is exposed as a part of the additional methods which allow * a Python plugin to issue debug messages using the Bareos debug message facility. */static PyObject *PyBareosDebugMessage(PyObject *self, PyObject *args){ int level; char *dbgmsg = NULL; bpContext *ctx; PyObject *pyCtx; if (!PyArg_ParseTuple(args, "Oi|z:BareosDebugMessage", &pyCtx, &level, &dbgmsg)) { return NULL; } if (dbgmsg) { ctx = PyGetbpContext(pyCtx); Dmsg(ctx, level, dbgmsg); } Py_INCREF(Py_None); return Py_None;}
开发者ID:bitroniq,项目名称:bareos,代码行数:23,
示例22: PyParsePluginDefinition/* * Any plugin options which are passed in are dispatched here to a Python method and it * can parse the plugin options. This function is also called after PyLoadModule() has * loaded the Python module and made sure things are operational. */static bRC PyParsePluginDefinition(bpContext *ctx, void *value){ bRC retval = bRC_Error; struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext; PyObject *pFunc; /* * Lookup the parse_plugin_definition() function in the python module. */ pFunc = PyDict_GetItemString(p_ctx->pDict, "parse_plugin_definition"); /* Borrowed reference */ if (pFunc && PyCallable_Check(pFunc)) { PyObject *pPluginDefinition, *pRetVal; pPluginDefinition = PyString_FromString((char *)value); if (!pPluginDefinition) { goto bail_out; } pRetVal = PyObject_CallFunctionObjArgs(pFunc, p_ctx->bpContext, pPluginDefinition, NULL); Py_DECREF(pPluginDefinition); if (!pRetVal) { goto bail_out; } else { retval = conv_python_retval(pRetVal); Py_DECREF(pRetVal); } return retval; } else { Dmsg(ctx, dbglvl, "Failed to find function named parse_plugin_definition()/n"); return bRC_Error; }bail_out: if (PyErr_Occurred()) { PyErrorHandler(ctx, M_FATAL); } return retval;}
开发者ID:Akheon23,项目名称:bareos,代码行数:47,
示例23: switch/* * Callback function which is exposed as a part of the additional methods which allow * a Python plugin to set certain internal values of the current Job. */static PyObject *PyBareosSetValue(PyObject *self, PyObject *args){ int var; bpContext *ctx = NULL; PyObject *pyCtx, *pyValue; if (!PyArg_ParseTuple(args, "OiO:BareosSetValue", &pyCtx, &var, &pyValue)) { return NULL; } switch (var) { case bwDirVarVolumeName: { char *value; ctx = PyGetbpContext(pyCtx); value = PyString_AsString(pyValue); if (value) { bfuncs->setBareosValue(ctx, (bwDirVariable)var, value); } break; } case bwDirVarPriority: case bwDirVarJobLevel: { int value; ctx = PyGetbpContext(pyCtx); value = PyInt_AsLong(pyValue); if (value >= 0) { bfuncs->setBareosValue(ctx, (bwDirVariable)var, &value); } break; } default: ctx = PyGetbpContext(pyCtx); Dmsg(ctx, dbglvl, "PyBareosSetValue: Unknown variable requested %d/n", var); break; } Py_INCREF(Py_None); return Py_None;}
开发者ID:bitroniq,项目名称:bareos,代码行数:46,
示例24: PyHandlePluginEventstatic bRC PyHandlePluginEvent(bpContext *ctx, bDirEvent *event, void *value){ bRC retval = bRC_Error; plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; PyObject *pFunc; /* * Lookup the handle_plugin_event() function in the python module. */ pFunc = PyDict_GetItemString(p_ctx->pDict, "handle_plugin_event"); /* Borrowed reference */ if (pFunc && PyCallable_Check(pFunc)) { PyObject *pEventType, *pRetVal; pEventType = PyInt_FromLong(event->eventType); pRetVal = PyObject_CallFunctionObjArgs(pFunc, p_ctx->bpContext, pEventType, NULL); Py_DECREF(pEventType); if (!pRetVal) { goto bail_out; } else { retval = conv_python_retval(pRetVal); Py_DECREF(pRetVal); } } else { Dmsg(ctx, dbglvl, "Failed to find function named handle_plugin_event()/n"); } return retval;bail_out: if (PyErr_Occurred()) { PyErrorHandler(ctx, M_FATAL); } return retval;}
开发者ID:bitroniq,项目名称:bareos,代码行数:38,
示例25: PyLoadModule/* * Initial load of the Python module. * * Based on the parsed plugin options we set some prerequisits like the * module path and the module to load. We also load the dictionary used * for looking up the Python methods. */static bRC PyLoadModule(bpContext *ctx){ char *value; bRC retval = bRC_Error; struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext; PyObject *sysPath, *mPath, *pName, *pFunc, *module; /* * Extend the Python search path with the defoned plugin_directory. */ if (bfuncs->getBareosValue(NULL, bDirVarPluginDir, &value) == bRC_OK) { sysPath = PySys_GetObject((char *)"path"); mPath = PyString_FromString(value); PyList_Append(sysPath, mPath); Py_DECREF(mPath); } /* * Make our callback methods available for Python. */ module = Py_InitModule("bareosdir", BareosDIRMethods); Dmsg(ctx, dbglvl, "Trying to load module with name bareos-dir/n"); pName = PyString_FromString("bareos-dir"); p_ctx->pModule = PyImport_Import(pName); Py_DECREF(pName); if (!p_ctx->pModule) { Dmsg(ctx, dbglvl, "Failed to load module with name bareos-dir/n"); goto bail_out; } Dmsg(ctx, dbglvl, "Sucessfully loaded module with name bareos-dir/n"); /* * Get the Python dictionary for lookups in the Python namespace. */ p_ctx->pDict = PyModule_GetDict(p_ctx->pModule); /* Borrowed reference */ /* * Encode the bpContext so a Python method can pass it in on calling back. */ p_ctx->bpContext = PyCreatebpContext(ctx); /* * Lookup the load_bareos_plugin() function in the python module. */ pFunc = PyDict_GetItemString(p_ctx->pDict, "load_bareos_plugin"); /* Borrowed reference */ if (pFunc && PyCallable_Check(pFunc)) { PyObject *pRetVal; pRetVal = PyObject_CallFunctionObjArgs(pFunc, p_ctx->bpContext, NULL); if (!pRetVal) { goto bail_out; } else { retval = conv_python_retval(pRetVal); Py_DECREF(pRetVal); } } else { Dmsg(ctx, dbglvl, "Failed to find function named load_bareos_plugins()/n"); goto bail_out; } return retval;bail_out: if (PyErr_Occurred()) { PyErrorHandler(ctx, M_FATAL); } return retval;}
开发者ID:bitroniq,项目名称:bareos,代码行数:84,
示例26: pluginIO/* * Bareos is calling us to do the actual I/O */static bRC pluginIO(bpContext *ctx, struct io_pkt *io){ int io_count; plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (!p_ctx) { return bRC_Error; } switch(io->func) { case IO_OPEN: p_ctx->offset = 0; io->status = 0; io->io_errno = 0; break; case IO_READ: io_count = rados_read(p_ctx->ioctx, p_ctx->object_name, io->buf, io->count, p_ctx->offset); if (io_count >= 0) { p_ctx->offset += io_count; io->status = io_count; io->io_errno = 0; } else { io->io_errno = -io_count; goto bail_out; } break; case IO_WRITE: io_count = rados_write(p_ctx->ioctx, p_ctx->object_name, io->buf, io->count, p_ctx->offset);#if LIBRADOS_VERSION_CODE <= 17408 if (io_count >= 0) { p_ctx->offset += io_count; io->status = io_count;#else if (io_count == 0) { p_ctx->offset += io->count; io->status = io->count;#endif io->io_errno = 0; } else { io->io_errno = -io_count; goto bail_out; } break; case IO_CLOSE: p_ctx->offset = 0; io->status = 0; io->io_errno = 0; break; case IO_SEEK: Jmsg(ctx, M_ERROR, "Illegal Seek request on rados device."); Dmsg(ctx, dbglvl, "Illegal Seek request on rados device."); io->io_errno = EINVAL; goto bail_out; } return bRC_OK;bail_out: io->lerror = 0; io->win32 = false; io->status = -1; return bRC_Error;}/* * See if we need to do any postprocessing after the restore. */static bRC end_restore_job(bpContext *ctx, void *value){ bRC retval = bRC_OK; plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (!p_ctx) { return bRC_Error; } Dmsg(ctx, dbglvl, "rados-fd: entering end_restore_job/n"); Dmsg(ctx, dbglvl, "rados-fd: leaving end_restore_job/n"); return retval;}
开发者ID:karcaw,项目名称:bareos-contrib,代码行数:86,
示例27: parse_plugin_definition/* * Parse the plugin definition passed in. * * The definition is in this form: * * rados: */static bRC parse_plugin_definition(bpContext *ctx, void *value){ int i; bool keep_existing; char *plugin_definition, *bp, *argument, *argument_value; plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (!p_ctx || !value) { return bRC_Error; } keep_existing = (p_ctx->plugin_options) ? true : false; /* * Parse the plugin definition. * Make a private copy of the whole string. */ plugin_definition = bstrdup((char *)value); bp = strchr(plugin_definition, ':'); if (!bp) { Jmsg(ctx, M_FATAL, "Illegal plugin definition %s/n", plugin_definition); Dmsg(ctx, dbglvl, "Illegal plugin definition %s/n", plugin_definition); goto bail_out; } /* * Skip the first ':' */ bp++; while (bp) { if (strlen(bp) == 0) { break; } /* * Each argument is in the form: * <argument> = <argument_value> * * So we setup the right pointers here, argument to the beginning * of the argument, argument_value to the beginning of the argument_value. */ argument = bp; argument_value = strchr(bp, '='); if (!argument_value) { Jmsg(ctx, M_FATAL, "Illegal argument %s without value/n", argument); Dmsg(ctx, dbglvl, "Illegal argument %s without value/n", argument); goto bail_out; } *argument_value++ = '/0'; /* * See if there are more arguments and setup for the next run. */ bp = argument_value; do { bp = strchr(bp, ':'); if (bp) { if (*(bp - 1) != '//') { *bp++ = '/0'; break; } else { bp++; } } } while (bp); for (i = 0; plugin_arguments[i].name; i++) { if (bstrcasecmp(argument, plugin_arguments[i].name)) { char **str_destination = NULL; switch (plugin_arguments[i].type) { case argument_conffile: str_destination = &p_ctx->rados_conffile; break; case argument_poolname: str_destination = &p_ctx->rados_poolname; break;#if defined(HAVE_RADOS_NAMESPACES) && defined(LIBRADOS_ALL_NSPACES) case argument_namespace: str_destination = &p_ctx->rados_namespace; break;#endif case argument_snapshotname: str_destination = &p_ctx->rados_snapshotname; break; default: break; } /* * Keep the first value, ignore any next setting. *///.........这里部分代码省略.........
开发者ID:karcaw,项目名称:bareos-contrib,代码行数:101,
示例28: parse_plugin_definition/* * Parse the plugin definition passed in. * * The definition is in this form: * * python:module_path=<path>:module_name=<python_module_name>:... */static bRC parse_plugin_definition(bpContext *ctx, void *value, POOL_MEM &plugin_options){ bool found; int i, cnt; POOL_MEM plugin_definition(PM_FNAME); char *bp, *argument, *argument_value; plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (!value) { return bRC_Error; } /* * Parse the plugin definition. * Make a private copy of the whole string. */ pm_strcpy(plugin_definition, (char *)value); bp = strchr(plugin_definition.c_str(), ':'); if (!bp) { Jmsg(ctx, M_FATAL, "Illegal plugin definition %s/n", plugin_definition.c_str()); Dmsg(ctx, dbglvl, "Illegal plugin definition %s/n", plugin_definition.c_str()); goto bail_out; } /* * Skip the first ':' */ bp++; cnt = 0; while (bp) { if (strlen(bp) == 0) { break; } /* * Each argument is in the form: * <argument> = <argument_value> * * So we setup the right pointers here, argument to the beginning * of the argument, argument_value to the beginning of the argument_value. */ argument = bp; argument_value = strchr(bp, '='); if (!argument_value) { Jmsg(ctx, M_FATAL, "Illegal argument %s without value/n", argument); Dmsg(ctx, dbglvl, "Illegal argument %s without value/n", argument); goto bail_out; } *argument_value++ = '/0'; /* * See if there are more arguments and setup for the next run. */ bp = argument_value; do { bp = strchr(bp, ':'); if (bp) { if (*(bp - 1) != '//') { *bp++ = '/0'; break; } else { bp++; } } } while (bp); found = false; for (i = 0; plugin_arguments[i].name; i++) { if (bstrcasecmp(argument, plugin_arguments[i].name)) { int64_t *int_destination = NULL; char **str_destination = NULL; bool *bool_destination = NULL; switch (plugin_arguments[i].type) { case argument_instance: int_destination = &p_ctx->instance; break; case argument_module_path: str_destination = &p_ctx->module_path; break; case argument_module_name: str_destination = &p_ctx->module_name; break; default: break; } if (int_destination) { *int_destination = parse_integer(argument_value); }//.........这里部分代码省略.........
开发者ID:Akheon23,项目名称:bareos,代码行数:101,
示例29: PyLoadModule/* * Initial load of the Python module. * * Based on the parsed plugin options we set some prerequisits like the * module path and the module to load. We also load the dictionary used * for looking up the Python methods. */static bRC PyLoadModule(bpContext *ctx, void *value){ bRC retval = bRC_Error; struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext; PyObject *sysPath, *mPath, *pName, *pFunc; /* * See if we already setup the python search path. */ if (!p_ctx->python_path_set) { /* * Extend the Python search path with the given module_path. */ if (p_ctx->module_path) { sysPath = PySys_GetObject((char *)"path"); mPath = PyString_FromString(p_ctx->module_path); PyList_Append(sysPath, mPath); Py_DECREF(mPath); p_ctx->python_path_set = true; } } /* * See if we already setup the module structure. */ if (!p_ctx->pInstance) { /* * Make our callback methods available for Python. */ p_ctx->pInstance = Py_InitModule("bareossd", BareosSDMethods); } /* * Try to load the Python module by name. */ if (p_ctx->module_name) { Dmsg(ctx, dbglvl, "Trying to load module with name %s/n", p_ctx->module_name); pName = PyString_FromString(p_ctx->module_name); p_ctx->pModule = PyImport_Import(pName); Py_DECREF(pName); if (!p_ctx->pModule) { Dmsg(ctx, dbglvl, "Failed to load module with name %s/n", p_ctx->module_name); goto bail_out; } Dmsg(ctx, dbglvl, "Successfully loaded module with name %s/n", p_ctx->module_name); /* * Get the Python dictionary for lookups in the Python namespace. */ p_ctx->pDict = PyModule_GetDict(p_ctx->pModule); /* Borrowed reference */ /* * Encode the bpContext so a Python method can pass it in on calling back. */ p_ctx->bpContext = PyCreatebpContext(ctx); /* * Lookup the load_bareos_plugin() function in the python module. */ pFunc = PyDict_GetItemString(p_ctx->pDict, "load_bareos_plugin"); /* Borrowed reference */ if (pFunc && PyCallable_Check(pFunc)) { PyObject *pPluginDefinition, *pRetVal; pPluginDefinition = PyString_FromString((char *)value); if (!pPluginDefinition) { goto bail_out; } pRetVal = PyObject_CallFunctionObjArgs(pFunc, p_ctx->bpContext, pPluginDefinition, NULL); Py_DECREF(pPluginDefinition); if (!pRetVal) { goto bail_out; } else { retval = conv_python_retval(pRetVal); Py_DECREF(pRetVal); } } else { Dmsg(ctx, dbglvl, "Failed to find function named load_bareos_plugins()/n"); goto bail_out; } /* * Keep track we successfully loaded. */ p_ctx->python_loaded = true; }//.........这里部分代码省略.........
开发者ID:Akheon23,项目名称:bareos,代码行数:101,
注:本文中的Dmsg函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ Dmsg2函数代码示例 C++ DllUnregisterServer函数代码示例 |