Exemple #1
0
/*
 * 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 = @INT64@ */
      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 ;
}
Exemple #2
0
/* 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 = @INT64@ */
      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 ;
}