src/stored/butil.c
static DEVRES *find_device_res(char *device_name, bool write_access)
{
   bool found = false;
   DEVRES *device;

   Dmsg0(900, "Enter find_device_res\n");
   LockRes();
   foreach_res(device, R_DEVICE) {
      Dmsg2(900, "Compare %s and %s\n", device->device_name, device_name);
      if (strcmp(device->device_name, device_name) == 0) {
         found = true;
         break;
      }
   }
   if (!found) {
      /* Search for name of Device resource rather than archive name */
      if (device_name[0] == '"') {
         int len = strlen(device_name);
         bstrncpy(device_name, device_name+1, len+1);
         len--;
         if (len > 0) {
            device_name[len-1] = 0;   /* zap trailing " */
         }
      }
      foreach_res(device, R_DEVICE) {
         Dmsg2(900, "Compare %s and %s\n", device->hdr.name, device_name);
         if (strcmp(device->hdr.name, device_name) == 0) {
            found = true;
            break;
         }
      }
   }
   UnlockRes();
   if (!found) {
      Pmsg2(0, _("Could not find device \"%s\" in config file %s.\n"), device_name,
            configfile);
      return NULL;
   }
   if (write_access) {
      Pmsg1(0, _("Using device: \"%s\" for writing.\n"), device_name);
   } else {
      Pmsg1(0, _("Using device: \"%s\" for reading.\n"), device_name);
   }
   return device;
}
/*
 * Search for device resource that corresponds to
 * device name on command line (or default).
 *
 * Returns: NULL on failure
 *          Device resource pointer on success
 */
Search for device resource that corresponds to
device name on command line (or default).

NULL on failure
Device resource pointer on success
Search for device resource that corresponds to device name on command line ( or default ) . NULL on failure Device resource pointer on success
static DEVRES *find_device_res(char *device_name, bool write_access)
{
   bool found = false;
   DEVRES *device;
   Dmsg0(900, "Enter find_device_res\n");
   LockRes();
   foreach_res(device, R_DEVICE) {
      Dmsg2(900, "Compare %s and %s\n", device->device_name, device_name);
      if (strcmp(device->device_name, device_name) == 0) {
         found = true;
         break;
      }
   }
   if (!found) {
      if (device_name[0] == '"') {
         int len = strlen(device_name);
         bstrncpy(device_name, device_name+1, len+1);
         len--;
         if (len > 0) {
            device_name[len-1] = 0;   
         }
      }
      foreach_res(device, R_DEVICE) {
         Dmsg2(900, "Compare %s and %s\n", device->hdr.name, device_name);
         if (strcmp(device->hdr.name, device_name) == 0) {
            found = true;
            break;
         }
      }
   }
   UnlockRes();
   if (!found) {
      Pmsg2(0, _("Could not find device \"%s\" in config file %s.\n"), device_name,
            configfile);
      return NULL;
   }
   if (write_access) {
      Pmsg1(0, _("Using device: \"%s\" for writing.\n"), device_name);
   } else {
      Pmsg1(0, _("Using device: \"%s\" for reading.\n"), device_name);
   }
   return device;
}
static DEVRES * find_device_res ( char * device_name , bool write_access ) { bool found = false ; DEVRES * device ; Dmsg0 ( 900 , " \n " ) ; LockRes ( ) ; foreach_res ( device , R_DEVICE ) { Dmsg2 ( 900 , " \n " , device -> device_name , device_name ) ; if ( strcmp ( device -> device_name , device_name ) == 0 ) { found = true ; break ; } } if ( ! found ) { if ( device_name [ 0 ] == ' ' ) { int len = strlen ( device_name ) ; bstrncpy ( device_name , device_name + 1 , len + 1 ) ; len -- ; if ( len > 0 ) { device_name [ len - 1 ] = 0 ; } } foreach_res ( device , R_DEVICE ) { Dmsg2 ( 900 , " \n " , device -> hdr . name , device_name ) ; if ( strcmp ( device -> hdr . name , device_name ) == 0 ) { found = true ; break ; } } } UnlockRes ( ) ; if ( ! found ) { Pmsg2 ( 0 , _ ( " \" \" \n " ) , device_name , configfile ) ; return NULL ; } if ( write_access ) { Pmsg1 ( 0 , _ ( " \" \" \n " ) , device_name ) ; } else { Pmsg1 ( 0 , _ ( " \" \" \n " ) , device_name ) ; } return device ; }
Search for device resource that corresponds to
 device name on command line (or default).
Search for device resource that corresponds to device name on command line ( or default ) .
/* Search for name of Device resource rather than archive name */ /* zap trailing " */