]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/sellist.h
Fix get_basename() -- rewrite
[bacula/bacula] / bacula / src / lib / sellist.h
index 99365bdda8edd25842813c5b8455d1e175c856f4..b87e39c23c9e85d9d3bf1c2a9b1c8910647065bc 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula(R) - The Network Backup Solution
 
-   Copyright (C) 2011-2011 Free Software Foundation Europe e.V.
+   Copyright (C) 2011-2012 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.
@@ -41,7 +41,7 @@
 
 
 class sellist : public SMARTALLOC {
-   char *errmsg;
+   const char *errmsg;
    char *p, *e, *h;
    char esave, hsave;
    int64_t beg, end;
@@ -54,8 +54,12 @@ public:
    bool set_string(char *string, bool scan);
    int64_t first();
    int64_t next();
-   int size() const;
-   char *get_errmsg();
+   void begin();
+   /* size() valid only if scan enabled on string */
+   int size() const { return num_items; };
+   char *get_list() { return str; };
+   /* if errmsg == NULL, no error */
+   const char *get_errmsg() { return errmsg; };
 };
 
 /*
@@ -66,7 +70,8 @@ inline sellist::sellist()
    num_items = 0;
    max = 99999;
    str = NULL;
-   e = errmsg = NULL;
+   e = NULL;
+   errmsg = NULL;
 }   
 
 /*
@@ -81,31 +86,23 @@ inline sellist::~sellist()
 }
 
 /*
- * Return list size, but only if scan enabled on string
- */
-inline int sellist::size() const
-{
-   return num_items;
-}
-
-/*
- * Return error message or NULL if none
+ * Returns first item
+ *   error if returns -1 and errmsg set
+ *   end of items if returns -1 and errmsg NULL
  */
-inline char *sellist::get_errmsg()
+inline int64_t sellist::first()
 {
-   return errmsg;
+   begin();
+   return next();
 }
 
 /*
- * Returns first item
- *   error if returns -1 and errmsg set
- *   end of items if returns -1 and errmsg NULL
+ * Reset to walk list from beginning
  */
-inline int64_t sellist::first()
+inline void sellist::begin()
 {
    e = str;
    end = 0;
    beg = 1;
    errmsg = NULL;
-   return next();
 }