]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/util.c
This commit was manufactured by cvs2svn to create tag
[bacula/bacula] / bacula / src / lib / util.c
index 32f9d0afabfcec6d95b068c836477e819c469531..a7c634b55b68e6302f57a77022e1a3dda6ad7018 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *   util.c  miscellaneous utility subroutines for Bacula
- * 
+ *
  *    Kern Sibbald, MM
  *
  *   Version $Id$
@@ -75,7 +75,7 @@ void lcase(char *str)
    }
 }
 
-/* Convert spaces to non-space character. 
+/* Convert spaces to non-space character.
  * This makes scanf of fields containing spaces easier.
  */
 void
@@ -88,7 +88,7 @@ bash_spaces(char *str)
    }
 }
 
-/* Convert spaces to non-space character. 
+/* Convert spaces to non-space character.
  * This makes scanf of fields containing spaces easier.
  */
 void
@@ -109,7 +109,7 @@ unbash_spaces(char *str)
 {
    while (*str) {
      if (*str == 0x1)
-        *str = ' ';
+       *str = ' ';
      str++;
    }
 }
@@ -121,7 +121,7 @@ unbash_spaces(POOL_MEM &pm)
    char *str = pm.c_str();
    while (*str) {
      if (*str == 0x1)
-        *str = ' ';
+       *str = ' ';
      str++;
    }
 }
@@ -240,7 +240,7 @@ void jobstatus_to_ascii(int JobStatus, char *msg, int maxlen)
       if (JobStatus == 0) {
         buf[0] = 0;
       } else {
-         bsnprintf(buf, sizeof(buf), _("Unknown Job termination status=%d"), JobStatus);
+        bsnprintf(buf, sizeof(buf), _("Unknown Job termination status=%d"), JobStatus);
       }
       jobstat = buf;
       break;
@@ -251,7 +251,7 @@ void jobstatus_to_ascii(int JobStatus, char *msg, int maxlen)
 /*
  * Convert Job Termination Status into a string
  */
-const char *job_status_to_str(int stat) 
+const char *job_status_to_str(int stat)
 {
    const char *str;
 
@@ -283,7 +283,7 @@ const char *job_status_to_str(int stat)
 /*
  * Convert Job Type into a string
  */
-const char *job_type_to_str(int type) 
+const char *job_type_to_str(int type)
 {
    const char *str;
 
@@ -310,7 +310,7 @@ const char *job_type_to_str(int type)
 /*
  * Convert Job Level into a string
  */
-const char *job_level_to_str(int level) 
+const char *job_level_to_str(int level)
 {
    const char *str;
 
@@ -361,25 +361,25 @@ const char *job_level_to_str(int level)
 
 char *encode_mode(mode_t mode, char *buf)
 {
-  char *cp = buf;  
+  char *cp = buf;
 
   *cp++ = S_ISDIR(mode) ? 'd' : S_ISBLK(mode)  ? 'b' : S_ISCHR(mode)  ? 'c' :
-          S_ISLNK(mode) ? 'l' : S_ISFIFO(mode) ? 'f' : S_ISSOCK(mode) ? 's' : '-';
+         S_ISLNK(mode) ? 'l' : S_ISFIFO(mode) ? 'f' : S_ISSOCK(mode) ? 's' : '-';
   *cp++ = mode & S_IRUSR ? 'r' : '-';
   *cp++ = mode & S_IWUSR ? 'w' : '-';
   *cp++ = (mode & S_ISUID
-               ? (mode & S_IXUSR ? 's' : 'S')
-               : (mode & S_IXUSR ? 'x' : '-'));
+              ? (mode & S_IXUSR ? 's' : 'S')
+              : (mode & S_IXUSR ? 'x' : '-'));
   *cp++ = mode & S_IRGRP ? 'r' : '-';
   *cp++ = mode & S_IWGRP ? 'w' : '-';
   *cp++ = (mode & S_ISGID
-               ? (mode & S_IXGRP ? 's' : 'S')
-               : (mode & S_IXGRP ? 'x' : '-'));
+              ? (mode & S_IXGRP ? 's' : 'S')
+              : (mode & S_IXGRP ? 'x' : '-'));
   *cp++ = mode & S_IROTH ? 'r' : '-';
   *cp++ = mode & S_IWOTH ? 'w' : '-';
   *cp++ = (mode & S_ISVTX
-               ? (mode & S_IXOTH ? 't' : 'T')
-               : (mode & S_IXOTH ? 'x' : '-'));
+              ? (mode & S_IXOTH ? 't' : 'T')
+              : (mode & S_IXOTH ? 'x' : '-'));
   *cp = '\0';
   return cp;
 }
@@ -407,7 +407,7 @@ int do_shell_expansion(char *name, int name_len)
       cmd =  get_pool_memory(PM_FNAME);
       /* look for shell */
       if ((shellcmd = getenv("SHELL")) == NULL) {
-         shellcmd = "/bin/sh";
+        shellcmd = "/bin/sh";
       }
       pm_strcpy(&cmd, shellcmd);
       pm_strcat(&cmd, " -c \"echo ");
@@ -419,7 +419,7 @@ int do_shell_expansion(char *name, int name_len)
         fgets(line, sizeof(line), bpipe->rfd);
         strip_trailing_junk(line);
         stat = close_bpipe(bpipe);
-         Dmsg2(400, "stat=%d got: %s\n", stat, line);
+        Dmsg2(400, "stat=%d got: %s\n", stat, line);
       } else {
         stat = 1;                    /* error */
       }
@@ -454,7 +454,7 @@ void make_session_key(char *key, char *seed, int mode)
      /* The following creates a seed for the session key generator
        based on a collection of volatile and environment-specific
        information unlikely to be vulnerable (as a whole) to an
-        exhaustive search attack.  If one of these items isn't
+       exhaustive search attack.  If one of these items isn't
        available on your machine, replace it with something
        equivalent or, if you like, just delete it. */
 
@@ -492,7 +492,7 @@ void make_session_key(char *key, char *seed, int mode)
           key[k++] = Rad16(rb & 0xF);
 #undef Rad16
           if (j & 1) {
-              key[k++] = '-';
+             key[k++] = '-';
           }
        }
        key[--k] = 0;
@@ -522,10 +522,10 @@ void make_session_key(char *key, char *seed, int mode)
  *
  *  omsg = edited output message
  *  imsg = input string containing edit codes (%x)
- *  to = recepients list 
+ *  to = recepients list
  *
  */
-POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to)   
+POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to)
 {
    char *p, *q;
    const char *str;
@@ -538,88 +538,85 @@ POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to)
    for (p=imsg; *p; p++) {
       if (*p == '%') {
         switch (*++p) {
-         case '%':
-            str = "%";
+        case '%':
+           str = "%";
            break;
-         case 'c':
+        case 'c':
            if (jcr) {
               str = jcr->client_name;
            } else {
-               str = "*none*";
-           }
-           if (!str) {
-               str = "";
+              str = "*none*";
            }
            break;
-         case 'd':
-            str = my_name;            /* Director's name */
+        case 'd':
+           str = my_name;            /* Director's name */
            break;
-         case 'e':
+        case 'e':
            if (jcr) {
-              str = job_status_to_str(jcr->JobStatus); 
-           } else { 
-               str = "*none*";
+              str = job_status_to_str(jcr->JobStatus);
+           } else {
+              str = "*none*";
            }
            break;
-         case 'i':
+        case 'i':
            if (jcr) {
-               bsnprintf(add, sizeof(add), "%d", jcr->JobId);
+              bsnprintf(add, sizeof(add), "%d", jcr->JobId);
               str = add;
            } else {
-               str = "*none*";
+              str = "*none*";
            }
            break;
-         case 'j':                    /* Job name */
+        case 'j':                    /* Job name */
            if (jcr) {
               str = jcr->Job;
            } else {
-               str = "*none*";
+              str = "*none*";
            }
            break;
-         case 'l':
+        case 'l':
            if (jcr) {
               str = job_level_to_str(jcr->JobLevel);
            } else {
-               str = "*none*";
+              str = "*none*";
            }
            break;
-         case 'n':
+        case 'n':
             if (jcr) {
                bstrncpy(name, jcr->Job, sizeof(name));
                /* There are three periods after the Job name */
                for (i=0; i<3; i++) {
-                   if ((q=strrchr(name, '.')) != NULL) {
+                  if ((q=strrchr(name, '.')) != NULL) {
                       *q = 0;
                   }
                }
                str = name;
             } else {
-                str = "*none*";
+               str = "*none*";
             }
             break;
-         case 'r':
+        case 'r':
            str = to;
            break;
-         case 't':
+        case 't':
            if (jcr) {
               str = job_type_to_str(jcr->JobType);
            } else {
-               str = "*none*";
+              str = "*none*";
            }
            break;
-         case 'v':
+        case 'v':
            if (jcr) {
               if (jcr->VolumeName && jcr->VolumeName[0]) {
                  str = jcr->VolumeName;
               } else {
-                  str = "";
+                 str = "";
               }
            } else {
-               str = "*none*";
+              str = "*none*";
            }
            break;
         default:
-            add[0] = '%';
+           add[0] = '%';
            add[1] = *p;
            add[2] = 0;
            str = add;
@@ -639,7 +636,7 @@ POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to)
 
 void set_working_directory(char *wd)
 {
-   struct stat stat_buf; 
+   struct stat stat_buf;
 
    if (wd == NULL) {
       Emsg0(M_ERROR_TERM, 0, _("Working directory not defined. Cannot continue.\n"));