]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_dotcmds.c
Add heap stats to Dir and SD -- eliminate #ifdefs
[bacula/bacula] / bacula / src / dird / ua_dotcmds.c
index 4f85e6e2efb8df3ade32f38512a0ef06a0524ee4..c6cc6120ac28641d05c99521af291770eeb619d9 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 /*
-   Copyright (C) 2002 Kern Sibbald and John Walker
+   Copyright (C) 2002-2004 Kern Sibbald and John Walker
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -41,22 +41,22 @@ extern struct s_res resources[];
 extern char my_name[];
 
 /* Imported functions */
-extern int qmessagescmd(UAContext *ua, char *cmd);
-extern int quitcmd(UAContext *ua, char *cmd);
+extern int qmessagescmd(UAContext *ua, const char *cmd);
+extern int quit_cmd(UAContext *ua, const char *cmd);
 
 /* Forward referenced functions */
-static int diecmd(UAContext *ua, char *cmd);
-static int jobscmd(UAContext *ua, char *cmd);
-static int filesetscmd(UAContext *ua, char *cmd);
-static int clientscmd(UAContext *ua, char *cmd);
-static int msgscmd(UAContext *ua, char *cmd);
-static int poolscmd(UAContext *ua, char *cmd);
-static int storagecmd(UAContext *ua, char *cmd);
-static int defaultscmd(UAContext *ua, char *cmd);
-static int typescmd(UAContext *ua, char *cmd);
-static int levelscmd(UAContext *ua, char *cmd);
-
-struct cmdstruct { char *key; int (*func)(UAContext *ua, char *cmd); char *help; }; 
+static int diecmd(UAContext *ua, const char *cmd);
+static int jobscmd(UAContext *ua, const char *cmd);
+static int filesetscmd(UAContext *ua, const char *cmd);
+static int clientscmd(UAContext *ua, const char *cmd);
+static int msgscmd(UAContext *ua, const char *cmd);
+static int poolscmd(UAContext *ua, const char *cmd);
+static int storagecmd(UAContext *ua, const char *cmd);
+static int defaultscmd(UAContext *ua, const char *cmd);
+static int typescmd(UAContext *ua, const char *cmd);
+static int levelscmd(UAContext *ua, const char *cmd);
+
+struct cmdstruct { const char *key; int (*func)(UAContext *ua, const char *cmd); const char *help; }; 
 static struct cmdstruct commands[] = {
  { N_(".die"),        diecmd,       NULL},
  { N_(".jobs"),       jobscmd,      NULL},
@@ -69,24 +69,23 @@ static struct cmdstruct commands[] = {
  { N_(".storage"),    storagecmd,   NULL},
  { N_(".defaults"),   defaultscmd,  NULL},
  { N_(".messages"),   qmessagescmd, NULL},
- { N_(".quit"),       quitcmd,      NULL},
- { N_(".exit"),       quitcmd,      NULL} 
+ { N_(".quit"),       quit_cmd,     NULL},
+ { N_(".exit"),       quit_cmd,     NULL} 
             };
 #define comsize (sizeof(commands)/sizeof(struct cmdstruct))
 
 /*
  * Execute a command from the UA
  */
-int do_a_dot_command(UAContext *ua, char *cmd)
+int do_a_dot_command(UAContext *ua, const char *cmd)
 {
-   unsigned int i;
+   int i;
    int len, stat;  
-   int found;
+   bool found = false;
 
-   found = 0;
    stat = 1;
 
-   Dmsg1(200, "Dot command: %s\n", ua->UA_sock->msg);
+   Dmsg1(400, "Dot command: %s\n", ua->UA_sock->msg);
    if (ua->argc == 0) {
       return 1;
    }
@@ -95,15 +94,15 @@ int do_a_dot_command(UAContext *ua, char *cmd)
    if (len == 1) {
       return 1;                      /* no op */
    }
-   for (i=0; i<comsize; i++) {    /* search for command */
+   for (i=0; i<(int)comsize; i++) {    /* search for command */
       if (strncasecmp(ua->argk[0],  _(commands[i].key), len) == 0) {
         stat = (*commands[i].func)(ua, cmd);   /* go execute command */
-        found = 1;
+        found = true;
         break;
       }
    }
    if (!found) {
-      strcat(ua->UA_sock->msg, _(": is an illegal command\n"));
+      pm_strcat(&ua->UA_sock->msg, _(": is an illegal command\n"));
       ua->UA_sock->msglen = strlen(ua->UA_sock->msg);
       bnet_send(ua->UA_sock);
    }
@@ -113,7 +112,7 @@ int do_a_dot_command(UAContext *ua, char *cmd)
 /*
  * Create segmentation fault 
  */
-static int diecmd(UAContext *ua, char *cmd)
+static int diecmd(UAContext *ua, const char *cmd)
 {
    JCR *jcr = NULL;
    int a;
@@ -124,7 +123,7 @@ static int diecmd(UAContext *ua, char *cmd)
    return 0;
 }
 
-static int jobscmd(UAContext *ua, char *cmd)
+static int jobscmd(UAContext *ua, const char *cmd)
 {
    JOB *job = NULL;
    LockRes();
@@ -135,7 +134,7 @@ static int jobscmd(UAContext *ua, char *cmd)
    return 1;
 }
 
-static int filesetscmd(UAContext *ua, char *cmd)
+static int filesetscmd(UAContext *ua, const char *cmd)
 {
    FILESET *fs = NULL;
    LockRes();
@@ -146,7 +145,7 @@ static int filesetscmd(UAContext *ua, char *cmd)
    return 1;
 }
 
-static int clientscmd(UAContext *ua, char *cmd)
+static int clientscmd(UAContext *ua, const char *cmd)
 {
    CLIENT *client = NULL;
    LockRes();
@@ -157,7 +156,7 @@ static int clientscmd(UAContext *ua, char *cmd)
    return 1;
 }
 
-static int msgscmd(UAContext *ua, char *cmd)
+static int msgscmd(UAContext *ua, const char *cmd)
 {
    MSGS *msgs = NULL;
    LockRes();
@@ -168,7 +167,7 @@ static int msgscmd(UAContext *ua, char *cmd)
    return 1;
 }
 
-static int poolscmd(UAContext *ua, char *cmd)
+static int poolscmd(UAContext *ua, const char *cmd)
 {
    POOL *pool = NULL;
    LockRes();
@@ -179,7 +178,7 @@ static int poolscmd(UAContext *ua, char *cmd)
    return 1;
 }
 
-static int storagecmd(UAContext *ua, char *cmd)
+static int storagecmd(UAContext *ua, const char *cmd)
 {
    STORE *store = NULL;
    LockRes();
@@ -191,7 +190,7 @@ static int storagecmd(UAContext *ua, char *cmd)
 }
 
 
-static int typescmd(UAContext *ua, char *cmd)
+static int typescmd(UAContext *ua, const char *cmd)
 {
    bsendmsg(ua, "Backup\n");
    bsendmsg(ua, "Restore\n");
@@ -200,7 +199,7 @@ static int typescmd(UAContext *ua, char *cmd)
    return 1;
 }
 
-static int levelscmd(UAContext *ua, char *cmd)
+static int levelscmd(UAContext *ua, const char *cmd)
 {
    bsendmsg(ua, "Incremental\n");
    bsendmsg(ua, "Full\n");
@@ -216,7 +215,7 @@ static int levelscmd(UAContext *ua, char *cmd)
 /*
  * Return default values for a job
  */
-static int defaultscmd(UAContext *ua, char *cmd)
+static int defaultscmd(UAContext *ua, const char *cmd)
 {
    JOB *job;      
    if (ua->argc == 2 && strcmp(ua->argk[1], "job") == 0) {