]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/scan.c
Change copyright as per agreement with FSFE
[bacula/bacula] / bacula / src / lib / scan.c
index 4e9aadc15258c9c20f007d8b5be36fb812ceade0..c29e82ba036608ba99d1eb4d5eaf444a0ab0a154 100644 (file)
@@ -1,29 +1,20 @@
 /*
-   Bacula® - The Network Backup Solution
-
-   Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
-
-   The main author of Bacula is Kern Sibbald, with contributions from
-   many others, a complete list can be found in the file AUTHORS.
-   This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version three of the GNU Affero General Public
-   License as published by the Free Software Foundation and included
-   in the file LICENSE.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU Affero General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-   Bacula® is a registered trademark of Kern Sibbald.
-   The licensor of Bacula is the Free Software Foundation Europe
-   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
-   Switzerland, email:ftf@fsfeurope.org.
+   Bacula(R) - The Network Backup Solution
+
+   Copyright (C) 2000-2016 Kern Sibbald
+
+   The original author of Bacula is Kern Sibbald, with contributions
+   from many others, a complete list can be found in the file AUTHORS.
+
+   You may use this file and others of this release according to the
+   license defined in the LICENSE file, which includes the Affero General
+   Public License, v3.0 ("AGPLv3") and some additional permissions and
+   terms pursuant to its AGPLv3 Section 7.
+
+   This notice must be preserved when any source code is 
+   conveyed and/or propagated.
+
+   Bacula(R) is a registered trademark of Kern Sibbald.
 */
 /*
  *   scan.c -- scanning routines for Bacula
  *
  */
 
+
 #include "bacula.h"
 #include "jcr.h"
 #include "findlib/find.h"
 
-/*
- * Strip leading space from command line arguments
- */
+/* Strip leading space from command line arguments */
 void strip_leading_space(char *str)
 {
    char *p = str;
-
    while (B_ISSPACE(*p)) {
       p++;
    }
@@ -51,49 +40,35 @@ void strip_leading_space(char *str)
    }
 }
 
-/*
- * Strip any trailing junk from the command
- */
+
+/* Strip any trailing junk from the command */
 void strip_trailing_junk(char *cmd)
 {
    char *p;
 
-   /*
-    * Strip trailing junk from command
-    */
-   p = cmd + strlen(cmd) - 1;
-   while ((p >= cmd) && (*p == '\n' || *p == '\r' || B_ISSPACE(*p))) {
+   /* strip trailing junk from command */
+   p = cmd - 1 + strlen(cmd);
+   while ((p >= cmd) && (B_ISSPACE(*p) || *p == '\n' || *p == '\r')) {
       *p-- = 0;
-   }
+   } 
 }
 
-/*
- * Strip any trailing newline characters from the string
- */
+/* Strip any trailing newline characters from the string */
 void strip_trailing_newline(char *cmd)
 {
    char *p;
-
-   p = cmd + strlen(cmd) - 1;
-   while ((p >= cmd) && (*p == '\n' || *p == '\r')) {
-      *p-- = 0;
-   }
+   p = cmd - 1 + strlen(cmd);
+   while ((p >= cmd) && (*p == '\n' || *p == '\r')) *p-- = 0;
 }
 
-/*
- * Strip any trailing slashes from a directory path
- */
+/* Strip any trailing slashes from a directory path */
 void strip_trailing_slashes(char *dir)
 {
    char *p;
 
-   /*
-    * Strip trailing slashes
-    */
-   p = dir + strlen(dir) - 1;
-   while (p >= dir && IsPathSeparator(*p)) {
-      *p-- = 0;
-   }
+   /* strip trailing slashes */
+   p = dir -1 + strlen(dir);
+   while (p >= dir && IsPathSeparator(*p)) *p-- = 0;
 }
 
 /*
@@ -135,10 +110,9 @@ bool skip_nonspaces(char **msg)
    return *p ? true : false;
 }
 
-/*
- * Folded search for string - case insensitive
- */
-int fstrsch(const char *a, const char *b)   /* folded case search */
+/* folded search for string - case insensitive */
+int
+fstrsch(const char *a, const char *b)   /* folded case search */
 {
    const char *s1,*s2;
    char c1, c2;
@@ -165,6 +139,7 @@ int fstrsch(const char *a, const char *b)   /* folded case search */
    return 1;
 }
 
+
 /*
  * Return next argument from command line.  Note, this
  *   routine is destructive because it stored 0 at the end
@@ -172,13 +147,13 @@ int fstrsch(const char *a, const char *b)   /* folded case search */
  * Called with pointer to pointer to command line. This
  *   pointer is updated to point to the remainder of the
  *   command line.
- * 
+ *
  * Returns pointer to next argument -- don't store the result
  *   in the pointer you passed as an argument ...
  *   The next argument is terminated by a space unless within
  *   quotes. Double quote characters (unless preceded by a \) are
  *   stripped.
- *   
+ *
  */
 char *next_arg(char **s)
 {
@@ -264,14 +239,14 @@ int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc,
  * This routine parses the input command line.
  *   It makes a copy in args, then builds an
  *   argc, argk, but no argv (values).
- *   This routine is useful for scanning command lines where the data 
+ *   This routine is useful for scanning command lines where the data
  *   is a filename and no keywords are expected.  If we scan a filename
  *   for keywords, any = in the filename will be interpreted as the
  *   end of a keyword, and this is not good.
  *
  *  argc = count of arguments
  *  argk[i] = argument keyword (part preceding =)
- *  argv[i] = NULL                         
+ *  argv[i] = NULL
  *
  *  example:  arg1 arg2=abc arg3=
  *
@@ -292,9 +267,7 @@ int parse_args_only(POOLMEM *cmd, POOLMEM **args, int *argc,
    strip_trailing_junk(*args);
    p = *args;
    *argc = 0;
-   /*
-    * Pick up all arguments
-    */
+   /* Pick up all arguments */
    while (*argc < max_args) {
       n = next_arg(&p);
       if (*n) {
@@ -307,13 +280,14 @@ int parse_args_only(POOLMEM *cmd, POOLMEM **args, int *argc,
    return 1;
 }
 
+
 /*
  * Given a full filename, split it into its path
  *  and filename parts. They are returned in pool memory
  *  in the arguments provided.
  */
 void split_path_and_filename(const char *fname, POOLMEM **path, int *pnl,
-                             POOLMEM **file, int *fnl)
+        POOLMEM **file, int *fnl)
 {
    const char *f;
    int slen;
@@ -363,6 +337,10 @@ void split_path_and_filename(const char *fname, POOLMEM **path, int *pnl,
 
 /*
  * Extremely simple sscanf. Handles only %(u,d,ld,qd,qu,lu,lld,llu,c,nns)
+ *
+ * Note, BIG is the default maximum length when no length
+ *   has been specified for %s. If it is not big enough, then
+ *   simply add a length such as %10000s.
  */
 const int BIG = 1000;
 int bsscanf(const char *buf, const char *fmt, ...)