Imported Upstream version 3.3.2
[debian/amanda] / perl / Amanda / Util.swg
index 2043b44122b87fddc0dcbae06cb76c9a0d88131d..43c4a99fc7cdf6e7360d3e24ffdc05512e15b2f4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, 2009, 2010 Zmanda, Inc.  All Rights Reserved.
+ * Copyright (c) 2007-2012 Zmanda, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 as published
@@ -209,6 +209,21 @@ sub skip_quoted_string {
     return ($quoted_string, $remainder);
 }
 
+sub split_quoted_string_friendly {
+    my $str = shift;
+    my @result;
+
+    chomp $str;
+    $str =~ s/^\s+//;
+    while ($str) {
+       (my $elt, $str) = skip_quoted_string($str);
+       push @result, unquote_string($elt);
+       $str =~ s/^\s+// if $str;
+    }
+
+    return @result;
+}
+
 %}
 
 amglue_export_ok(slurp);
@@ -300,8 +315,10 @@ sub safe_overwrite_file {
 
        for (iter = $1; *iter; iter++) {
            $result = sv_2mortal(newSVpv(*iter, 0));
+           g_free(*iter);
            argvi++;
        }
+       g_free($1);
     }
 }
 
@@ -323,14 +340,19 @@ char *perl_hexdecode_string(const char *str) {
 %}
 amglue_export_tag(encoding, hexencode hexdecode);
 
+%newobject sanitise_filename;
 char *sanitise_filename(char *inp);
+%newobject quote_string;
 char *quote_string(char *);
+%newobject unquote_string;
 char *unquote_string(char *);
 GPtrArray *expand_braced_alternates(char *);
 %newobject collapse_braced_alternates;
 char *collapse_braced_alternates(GPtrArray *source);
+%newobject split_quoted_strings;
 gchar **split_quoted_strings(const gchar *string);
-amglue_export_tag(quoting, quote_string unquote_string skip_quoted_string sanitise_filename split_quoted_strings);
+amglue_export_tag(quoting, quote_string unquote_string skip_quoted_string
+               sanitise_filename split_quoted_strings split_quoted_strings_friendly);
 amglue_export_tag(alternates, expand_braced_alternates collapse_braced_alternates);
 
 %perlcode %{
@@ -427,6 +449,7 @@ set_blocking(int fd, gboolean blocking)
 
 typedef struct file_lock {
     %extend {
+       %newobject file_lock;
        file_lock(const char *filename) {
            return file_lock_new(filename);
        }
@@ -436,7 +459,10 @@ typedef struct file_lock {
        }
 
        int lock();
+       int lock_wr();
+       int lock_rd();
        int unlock();
+       int locked();
 
        %typemap(in) (const char *data, size_t len) {
            $1 = SvPV($input, $2);
@@ -614,6 +640,16 @@ sub unmarshal_tapespec {
 
 %}
 
+amglue_export_ok(
+    match_host match_disk match_datestamp match_level
+);
+
+gboolean match_host(char *pat, char *value);
+gboolean match_disk(char *pat, char *value);
+gboolean match_datestamp(char *pat, char *value);
+gboolean match_level(char *pat, char *value);
+
+
 /* -------------------------------------------------------------------------
  * Functions below this line are only meant to be called within this module;
  * do not call them externally. */