src/dird/ua_output.c
int show_cmd(UAContext *ua, const char *cmd)
{
   int i, j, type, len;
   int recurse;
   char *res_name;
   RES_HEAD *reshead = NULL;
   RES *res = NULL;

   Dmsg1(20, "show: %s\n", ua->UA_sock->msg);


   LockRes();
   for (i=1; i<ua->argc; i++) {
      if (strcasecmp(ua->argk[i], NT_("disabled")) == 0) {
         show_disabled_jobs(ua);
         goto bail_out;
      }

      res = NULL;
      reshead = NULL;
      type = 0;

      res_name = ua->argk[i];
      if (!ua->argv[i]) {             /* was a name given? */
         /* No name, dump all resources of specified type */
         recurse = 1;
         len = strlen(res_name);
         for (j=0; reses[j].res_name; j++) {
            if (strncasecmp(res_name, reses[j].res_name, len) == 0) {
               type = reses[j].type;
               if (type > 0) {
                  reshead = res_head[type-r_first];
               } else {
                  reshead = NULL;
               }
               break;
            }
         }

      } else {
         /* Dump a single resource with specified name */
         recurse = 0;
         len = strlen(res_name);
         for (j=0; reses[j].res_name; j++) {
            if (strncasecmp(res_name, reses[j].res_name, len) == 0) {
               type = reses[j].type;
               res = (RES *)GetResWithName(type, ua->argv[i]);
               if (!res) {
                  type = -3;
               }
               break;
            }
         }
      }

      switch (type) {
      /* All resources */
      case -1:
         for (j=r_first; j<=r_last; j++) {
            /* Skip R_DEVICE since it is really not used or updated */
            if (j != R_DEVICE) {
               dump_each_resource(j, bsendmsg, ua);
            }
         }
         break;
      /* Help */
      case -2:
         ua->send_msg(_("Keywords for the show command are:\n"));
         for (j=0; reses[j].res_name; j++) {
            ua->error_msg("%s\n", reses[j].res_name);
         }
         goto bail_out;
      /* Resource not found */
      case -3:
         ua->error_msg(_("%s resource %s not found.\n"), res_name, ua->argv[i]);
         goto bail_out;
      /* Resource not found */
      case 0:
         ua->error_msg(_("Resource %s not found\n"), res_name);
         goto bail_out;
      /* Dump a specific type */
      default:
         if (res) {             /* keyword and argument, ie: show job=name */
            dump_resource(recurse?type:-type, res, bsendmsg, ua);

         } else if (reshead) {  /* keyword only, ie: show job */
            dump_each_resource(-type, bsendmsg, ua);
         }
         break;
      }
   }
bail_out:
   UnlockRes();
   return 1;
}
/*
 *  Displays Resources
 *
 *  show all
 *  show <resource-keyword-name>  e.g. show directors
 *  show <resource-keyword-name>=<name> e.g. show director=HeadMan
 *  show disabled    shows disabled jobs
 *
 */
Displays Resources
show all
show   e.g. show directors
show = e.g. show director=HeadMan
show disabled    shows disabled jobs
Displays Resources show all show e . g . show directors show = e . g . show director = HeadMan show disabled shows disabled jobs
int show_cmd(UAContext *ua, const char *cmd)
{
   int i, j, type, len;
   int recurse;
   char *res_name;
   RES_HEAD *reshead = NULL;
   RES *res = NULL;
   Dmsg1(20, "show: %s\n", ua->UA_sock->msg);
   LockRes();
   for (i=1; i<ua->argc; i++) {
      if (strcasecmp(ua->argk[i], NT_("disabled")) == 0) {
         show_disabled_jobs(ua);
         goto bail_out;
      }
      res = NULL;
      reshead = NULL;
      type = 0;
      res_name = ua->argk[i];
      if (!ua->argv[i]) {             
         recurse = 1;
         len = strlen(res_name);
         for (j=0; reses[j].res_name; j++) {
            if (strncasecmp(res_name, reses[j].res_name, len) == 0) {
               type = reses[j].type;
               if (type > 0) {
                  reshead = res_head[type-r_first];
               } else {
                  reshead = NULL;
               }
               break;
            }
         }
      } else {
         recurse = 0;
         len = strlen(res_name);
         for (j=0; reses[j].res_name; j++) {
            if (strncasecmp(res_name, reses[j].res_name, len) == 0) {
               type = reses[j].type;
               res = (RES *)GetResWithName(type, ua->argv[i]);
               if (!res) {
                  type = -3;
               }
               break;
            }
         }
      }
      switch (type) {
      case -1:
         for (j=r_first; j<=r_last; j++) {
            if (j != R_DEVICE) {
               dump_each_resource(j, bsendmsg, ua);
            }
         }
         break;
      case -2:
         ua->send_msg(_("Keywords for the show command are:\n"));
         for (j=0; reses[j].res_name; j++) {
            ua->error_msg("%s\n", reses[j].res_name);
         }
         goto bail_out;
      case -3:
         ua->error_msg(_("%s resource %s not found.\n"), res_name, ua->argv[i]);
         goto bail_out;
      case 0:
         ua->error_msg(_("Resource %s not found\n"), res_name);
         goto bail_out;
      default:
         if (res) {             
            dump_resource(recurse?type:-type, res, bsendmsg, ua);
         } else if (reshead) {  
            dump_each_resource(-type, bsendmsg, ua);
         }
         break;
      }
   }
bail_out:
   UnlockRes();
   return 1;
}
int show_cmd ( UAContext * ua , const char * cmd ) { int i , j , type , len ; int recurse ; char * res_name ; RES_HEAD * reshead = NULL ; RES * res = NULL ; Dmsg1 ( 20 , " \n " , ua -> UA_sock -> msg ) ; LockRes ( ) ; for ( i = 1 ; i < ua -> argc ; i ++ ) { if ( strcasecmp ( ua -> argk [ i ] , NT_ ( " " ) ) == 0 ) { show_disabled_jobs ( ua ) ; goto bail_out ; } res = NULL ; reshead = NULL ; type = 0 ; res_name = ua -> argk [ i ] ; if ( ! ua -> argv [ i ] ) { recurse = 1 ; len = strlen ( res_name ) ; for ( j = 0 ; reses [ j ] . res_name ; j ++ ) { if ( strncasecmp ( res_name , reses [ j ] . res_name , len ) == 0 ) { type = reses [ j ] . type ; if ( type > 0 ) { reshead = res_head [ type - r_first ] ; } else { reshead = NULL ; } break ; } } } else { recurse = 0 ; len = strlen ( res_name ) ; for ( j = 0 ; reses [ j ] . res_name ; j ++ ) { if ( strncasecmp ( res_name , reses [ j ] . res_name , len ) == 0 ) { type = reses [ j ] . type ; res = ( RES * ) GetResWithName ( type , ua -> argv [ i ] ) ; if ( ! res ) { type = -3 ; } break ; } } } switch ( type ) { case -1 : for ( j = r_first ; j <= r_last ; j ++ ) { if ( j != R_DEVICE ) { dump_each_resource ( j , bsendmsg , ua ) ; } } break ; case -2 : ua -> send_msg ( _ ( " \n " ) ) ; for ( j = 0 ; reses [ j ] . res_name ; j ++ ) { ua -> error_msg ( " \n " , reses [ j ] . res_name ) ; } goto bail_out ; case -3 : ua -> error_msg ( _ ( " \n " ) , res_name , ua -> argv [ i ] ) ; goto bail_out ; case 0 : ua -> error_msg ( _ ( " \n " ) , res_name ) ; goto bail_out ; default : if ( res ) { dump_resource ( recurse ? type : - type , res , bsendmsg , ua ) ; } else if ( reshead ) { dump_each_resource ( - type , bsendmsg , ua ) ; } break ; } } bail_out : UnlockRes ( ) ; return 1 ; }
Displays Resources
  show all
  show <resource-keyword-name>  e.g.
Displays Resources show all show <resource - keyword - name > e . g .
/* was a name given? */ /* No name, dump all resources of specified type */ /* Dump a single resource with specified name */ /* All resources */ /* Skip R_DEVICE since it is really not used or updated */ /* Help */ /* Resource not found */ /* Resource not found */ /* Dump a specific type */ /* keyword and argument, ie: show job=name */ /* keyword only, ie: show job */