src/console/console_conf.c
bool save_resource(CONFIG *config, int type, RES_ITEM *items, int pass)
{
   int rindex = type - r_first;
   int i, size;
   int error = 0;

   /*
    * Ensure that all required items are present
    */
   for (i=0; items[i].name; i++) {
      if (items[i].flags & ITEM_REQUIRED) {
         if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) {
            Mmsg(config->m_errmsg, _("\"%s\" directive is required in \"%s\" resource, but not found.\n"),
                 items[i].name, resources[rindex].name);
            return false;
         }
      }
   }

   /* During pass 2, we looked up pointers to all the resources
    * referrenced in the current resource, , now we
    * must copy their address from the static record to the allocated
    * record.
    */
   if (pass == 2) {
      switch (type) {
         /* Resources not containing a resource */
         case R_CONSOLE:
         case R_DIRECTOR:
            break;

         default:
            Emsg1(M_ERROR, 0, _("Unknown resource type %d\n"), type);
            error = 1;
            break;
      }
      /* Note, the resoure name was already saved during pass 1,
       * so here, we can just release it.
       */
      if (res_all.res_dir.hdr.name) {
         free(res_all.res_dir.hdr.name);
         res_all.res_dir.hdr.name = NULL;
      }
      if (res_all.res_dir.hdr.desc) {
         free(res_all.res_dir.hdr.desc);
         res_all.res_dir.hdr.desc = NULL;
      }
      return true;
   }

   /* The following code is only executed during pass 1 */
   switch (type) {
   case R_CONSOLE:
      size = sizeof(CONRES);
      break;
   case R_DIRECTOR:
      size = sizeof(DIRRES);
      break;
   default:
      printf(_("Unknown resource type %d\n"), type);
      error = 1;
      size = 1;
      break;
   }
   /* Common */
   if (!error) {
      if (!config->insert_res(rindex, size)) {
         return false;
      }
   }
   return true;
}
/* Save the new resource by chaining it into the head list for
 * the resource. If this is pass 2, we update any resource
 * pointers (currently only in the Job resource).
 */
Save the new resource by chaining it into the head list for
the resource. If this is pass 2, we update any resource
pointers (currently only in the Job resource).
Save the new resource by chaining it into the head list for the resource . If this is pass 2 we update any resource pointers ( currently only in the Job resource ) .
bool save_resource(CONFIG *config, int type, RES_ITEM *items, int pass)
{
   int rindex = type - r_first;
   int i, size;
   int error = 0;
   for (i=0; items[i].name; i++) {
      if (items[i].flags & ITEM_REQUIRED) {
         if (!bit_is_set(i, res_all.res_dir.hdr.item_present)) {
            Mmsg(config->m_errmsg, _("\"%s\" directive is required in \"%s\" resource, but not found.\n"),
                 items[i].name, resources[rindex].name);
            return false;
         }
      }
   }
   if (pass == 2) {
      switch (type) {
         case R_CONSOLE:
         case R_DIRECTOR:
            break;
         default:
            Emsg1(M_ERROR, 0, _("Unknown resource type %d\n"), type);
            error = 1;
            break;
      }
      if (res_all.res_dir.hdr.name) {
         free(res_all.res_dir.hdr.name);
         res_all.res_dir.hdr.name = NULL;
      }
      if (res_all.res_dir.hdr.desc) {
         free(res_all.res_dir.hdr.desc);
         res_all.res_dir.hdr.desc = NULL;
      }
      return true;
   }
   switch (type) {
   case R_CONSOLE:
      size = sizeof(CONRES);
      break;
   case R_DIRECTOR:
      size = sizeof(DIRRES);
      break;
   default:
      printf(_("Unknown resource type %d\n"), type);
      error = 1;
      size = 1;
      break;
   }
   if (!error) {
      if (!config->insert_res(rindex, size)) {
         return false;
      }
   }
   return true;
}
bool save_resource ( CONFIG * config , int type , RES_ITEM * items , int pass ) { int rindex = type - r_first ; int i , size ; int error = 0 ; for ( i = 0 ; items [ i ] . name ; i ++ ) { if ( items [ i ] . flags & ITEM_REQUIRED ) { if ( ! bit_is_set ( i , res_all . res_dir . hdr . item_present ) ) { Mmsg ( config -> m_errmsg , _ ( " \" \" \" \" \n " ) , items [ i ] . name , resources [ rindex ] . name ) ; return false ; } } } if ( pass == 2 ) { switch ( type ) { case R_CONSOLE : case R_DIRECTOR : break ; default : Emsg1 ( M_ERROR , 0 , _ ( " \n " ) , type ) ; error = 1 ; break ; } if ( res_all . res_dir . hdr . name ) { free ( res_all . res_dir . hdr . name ) ; res_all . res_dir . hdr . name = NULL ; } if ( res_all . res_dir . hdr . desc ) { free ( res_all . res_dir . hdr . desc ) ; res_all . res_dir . hdr . desc = NULL ; } return true ; } switch ( type ) { case R_CONSOLE : size = sizeof ( CONRES ) ; break ; case R_DIRECTOR : size = sizeof ( DIRRES ) ; break ; default : printf ( _ ( " \n " ) , type ) ; error = 1 ; size = 1 ; break ; } if ( ! error ) { if ( ! config -> insert_res ( rindex , size ) ) { return false ; } } return true ; }
Save the new resource by chaining it into the head list for
 the resource.
Save the new resource by chaining it into the head list for the resource .
/*
    * Ensure that all required items are present
    */ /* During pass 2, we looked up pointers to all the resources
    * referrenced in the current resource, , now we
    * must copy their address from the static record to the allocated
    * record.
    */ /* Resources not containing a resource */ /* Note, the resoure name was already saved during pass 1,
       * so here, we can just release it.
       */ /* The following code is only executed during pass 1 */ /* Common */