%s not $s
[samba.git] / source3 / client / clitar.c
index aade8fcb6ff7881d14f039e33b03f5ebfee52ba2..fd43d37abb133156cde1e6645d669d28f5c68720 100644 (file)
@@ -71,6 +71,7 @@ stack dir_stack = {NULL, 0}; /* Want an empty stack */
 #define SEPARATORS " \t\n\r"
 extern int DEBUGLEVEL;
 extern struct cli_state *cli;
+extern FILE *dbf;
 
 /* These defines are for the do_setrattr routine, to indicate
  * setting and reseting of file attributes in the function call */
@@ -599,9 +600,8 @@ static int padit(char *buf, int bufsize, int padsize)
 static void do_setrattr(char *name, uint16 attr, int set)
 {
        uint16 oldattr;
-       time_t t;
 
-       if (!cli_getatr(cli, name, &oldattr, NULL, &t)) return;
+       if (!cli_getatr(cli, name, &oldattr, NULL, NULL)) return;
 
        if (set == ATTRSET) {
                attr |= oldattr;
@@ -609,7 +609,7 @@ static void do_setrattr(char *name, uint16 attr, int set)
                attr = oldattr & ~attr;
        }
 
-       if (!cli_setatr(cli, name, attr, t)) {
+       if (!cli_setatr(cli, name, attr, 0)) {
                DEBUG(1,("setatr failed: %s\n", cli_errstr(cli)));
        }
 }
@@ -848,7 +848,8 @@ static void do_tar(file_info *finfo)
       }
       ntarf++;  /* Make sure we have a file on there */
       safe_strcpy(mtar_mask,cur_dir, sizeof(pstring));
-      safe_strcat(mtar_mask,"*.*", sizeof(pstring));
+      safe_strcat(mtar_mask,"*", sizeof(pstring));
+      DEBUG(5, ("Doing list with mtar_mask: %s\n", mtar_mask));
       do_list(mtar_mask, attribute, do_tar, False, True);
       safe_strcpy(cur_dir,saved_curdir, sizeof(pstring));
     }
@@ -970,7 +971,7 @@ static int skip_file(int skipsize)
 static int get_file(file_info2 finfo)
 {
   int fsize = finfo.size;
-  int fnum, pos = 0, dsize = 0, rsize = 0, bpos = 0;
+  int fnum = -1, pos = 0, dsize = 0, rsize = 0, bpos = 0;
 
   DEBUG(5, ("get_file: file: %s, size %i\n", finfo.name, fsize));
 
@@ -1354,7 +1355,7 @@ void cmd_setmode(void)
 
   if (!next_token(NULL,buf,NULL,sizeof(buf)))
     {
-      DEBUG(0, ("setmode <filename> <perm=[+|-]rsha>\n"));
+      DEBUG(0, ("setmode <filename> <[+|-]rsha>\n"));
       return;
     }
 
@@ -1385,13 +1386,13 @@ void cmd_setmode(void)
 
   if (attra[ATTRSET]==0 && attra[ATTRRESET]==0)
     {
-      DEBUG(0, ("setmode <filename> <perm=[+|-]rsha>\n"));
+      DEBUG(0, ("setmode <filename> <[+|-]rsha>\n"));
       return;
     }
 
   DEBUG(2, ("\nperm set %d %d\n", attra[ATTRSET], attra[ATTRRESET]));
-  (void) do_setrattr(fname, attra[ATTRSET], ATTRSET);
-  (void) do_setrattr(fname, attra[ATTRRESET], ATTRRESET);
+  do_setrattr(fname, attra[ATTRSET], ATTRSET);
+  do_setrattr(fname, attra[ATTRRESET], ATTRRESET);
 }
 
 /****************************************************************************
@@ -1462,18 +1463,21 @@ int process_tar(void)
          safe_strcpy(cur_dir, tarmac, sizeof(pstring));
          *(strrchr(cur_dir, '\\')+1)='\0';
 
+         DEBUG(5, ("process_tar, do_list with tarmac: %s\n", tarmac));
          do_list(tarmac,attribute,do_tar, False, True);
          safe_strcpy(cur_dir,saved_dir, sizeof(pstring));
        } else {
          safe_strcpy(tarmac, cur_dir, sizeof(pstring));
          safe_strcat(tarmac, cliplist[i], sizeof(pstring));
+         DEBUG(5, ("process_tar, do_list with tarmac: %s\n", tarmac));
          do_list(tarmac,attribute,do_tar, False, True);
        }
       }
     } else {
       pstring mask;
       safe_strcpy(mask,cur_dir, sizeof(pstring));
-      safe_strcat(mask,"\\*.*", sizeof(pstring));
+      DEBUG(5, ("process_tar, do_list with mask: %s\n", mask));
+      safe_strcat(mask,"\\*", sizeof(pstring));
       do_list(mask,attribute,do_tar,False, True);
     }
     
@@ -1540,7 +1544,7 @@ static int read_inclusion_file(char *filename)
 
   clipn = 0;
   buf[MAXPATHLEN] = '\0'; /* guarantee null-termination */
-  if ((inclusion = fopen(filename, "r")) == NULL) {
+  if ((inclusion = sys_fopen(filename, "r")) == NULL) {
     /* XXX It would be better to include a reason for failure, but without
      * autoconf, it's hard to use strerror, sys_errlist, etc.
      */
@@ -1815,6 +1819,12 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind)
   if (Optind>=argc || !strcmp(argv[Optind], "-")) {
     /* Sets tar handle to either 0 or 1, as appropriate */
     tarhandle=(tar_type=='c');
+    /*
+     * Make sure that dbf points to stderr if we are using stdout for 
+     * tar output
+    */
+    if (tarhandle == 1) 
+      dbf = stderr;
   } else {
     if (tar_type=='c' && (dry_run || strcmp(argv[Optind], "/dev/null")==0))
       {
@@ -1824,8 +1834,8 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind)
        }
        tarhandle=-1;
       } else
-    if ((tar_type=='x' && (tarhandle = open(argv[Optind], O_RDONLY)) == -1)
-       || (tar_type=='c' && (tarhandle=creat(argv[Optind], 0644)) < 0))
+    if ((tar_type=='x' && (tarhandle = sys_open(argv[Optind], O_RDONLY, 0)) == -1)
+       || (tar_type=='c' && (tarhandle=sys_creat(argv[Optind], 0644)) < 0))
       {
        DEBUG(0,("Error opening local file %s - %s\n",
                 argv[Optind], strerror(errno)));