src/dird/ua_cmds.c
static int delete_client(UAContext *ua)
{
   CLIENT *client;
   CLIENT_DBR  cr;
   char buf[200];
   db_list_ctx lst;

   memset(&cr, 0, sizeof(cr));

   if (!get_client_dbr(ua, &cr, 0)) {
      return 1;
   }

   client = (CLIENT*) GetResWithName(R_CLIENT, cr.Name);

   if (client) {
      ua->error_msg(_("Unable to delete Client \"%s\", the resource is still defined in the configuration.\n"), cr.Name);
      return 1;
   }

   if (!db_get_client_jobids(ua->jcr, ua->db, &cr, &lst)) {
      ua->error_msg(_("Can't list jobs on this client\n"));
      return 1;
   }

   if (find_arg(ua, "yes") > 0) {
      ua->pint32_val = 1;

   } else {
      if (lst.count  == 0) {
         bsnprintf(buf, sizeof(buf), _("Are you sure you want to delete Client \"%s\? (yes/no): "), cr.Name);
      } else {
         bsnprintf(buf, sizeof(buf), _("Are you sure you want to delete Client \"%s\" and purge %d job(s)? (yes/no): "), cr.Name, lst.count);
      }
      if (!get_yesno(ua, buf)) {
         return 1;
      }
   }

   if (ua->pint32_val) {
      if (lst.count) {
         ua->send_msg(_("Purging %d job(s).\n"), lst.count);
         purge_jobs_from_catalog(ua, lst.list);
      }
      ua->send_msg(_("Deleting client \"%s\".\n"), cr.Name);
      db_delete_client_record(ua->jcr, ua->db, &cr);
   }
   return 1;
}
/*
 * Delete a client record from the database
 */
Delete a client record from the database
Delete a client record from the database
static int delete_client(UAContext *ua)
{
   CLIENT *client;
   CLIENT_DBR  cr;
   char buf[200];
   db_list_ctx lst;
   memset(&cr, 0, sizeof(cr));
   if (!get_client_dbr(ua, &cr, 0)) {
      return 1;
   }
   client = (CLIENT*) GetResWithName(R_CLIENT, cr.Name);
   if (client) {
      ua->error_msg(_("Unable to delete Client \"%s\", the resource is still defined in the configuration.\n"), cr.Name);
      return 1;
   }
   if (!db_get_client_jobids(ua->jcr, ua->db, &cr, &lst)) {
      ua->error_msg(_("Can't list jobs on this client\n"));
      return 1;
   }
   if (find_arg(ua, "yes") > 0) {
      ua->pint32_val = 1;
   } else {
      if (lst.count  == 0) {
         bsnprintf(buf, sizeof(buf), _("Are you sure you want to delete Client \"%s\? (yes/no): "), cr.Name);
      } else {
         bsnprintf(buf, sizeof(buf), _("Are you sure you want to delete Client \"%s\" and purge %d job(s)? (yes/no): "), cr.Name, lst.count);
      }
      if (!get_yesno(ua, buf)) {
         return 1;
      }
   }
   if (ua->pint32_val) {
      if (lst.count) {
         ua->send_msg(_("Purging %d job(s).\n"), lst.count);
         purge_jobs_from_catalog(ua, lst.list);
      }
      ua->send_msg(_("Deleting client \"%s\".\n"), cr.Name);
      db_delete_client_record(ua->jcr, ua->db, &cr);
   }
   return 1;
}
static int delete_client ( UAContext * ua ) { CLIENT * client ; CLIENT_DBR cr ; char buf [ 200 ] ; db_list_ctx lst ; memset ( & cr , 0 , sizeof ( cr ) ) ; if ( ! get_client_dbr ( ua , & cr , 0 ) ) { return 1 ; } client = ( CLIENT * ) GetResWithName ( R_CLIENT , cr . Name ) ; if ( client ) { ua -> error_msg ( _ ( " \" \" \n " ) , cr . Name ) ; return 1 ; } if ( ! db_get_client_jobids ( ua -> jcr , ua -> db , & cr , & lst ) ) { ua -> error_msg ( _ ( " \n " ) ) ; return 1 ; } if ( find_arg ( ua , " " ) > 0 ) { ua -> pint32_val = 1 ; } else { if ( lst . count == 0 ) { bsnprintf ( buf , sizeof ( buf ) , _ ( " \" \? " ) , cr . Name ) ; } else { bsnprintf ( buf , sizeof ( buf ) , _ ( " \" \" " ) , cr . Name , lst . count ) ; } if ( ! get_yesno ( ua , buf ) ) { return 1 ; } } if ( ua -> pint32_val ) { if ( lst . count ) { ua -> send_msg ( _ ( " \n " ) , lst . count ) ; purge_jobs_from_catalog ( ua , lst . list ) ; } ua -> send_msg ( _ ( " \" \" \n " ) , cr . Name ) ; db_delete_client_record ( ua -> jcr , ua -> db , & cr ) ; } return 1 ; }
Delete a client record from the database
Delete a client record from the database