summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sharpe <sharpe@samba.org>1998-05-08 13:51:17 +0000
committerRichard Sharpe <sharpe@samba.org>1998-05-08 13:51:17 +0000
commitbb8706f4076ca1e0ba11b62014ebfc85a357e931 (patch)
tree9ca1c9d6911cc793b7b01a12d8c051a0234e6820
parent965148c5f266a6b0d26739d02e0c830709785c3b (diff)
downloadsamba-bb8706f4076ca1e0ba11b62014ebfc85a357e931.tar.gz
samba-bb8706f4076ca1e0ba11b62014ebfc85a357e931.tar.bz2
samba-bb8706f4076ca1e0ba11b62014ebfc85a357e931.zip
Se-submitting clitar.c/
I now only have one warning in my code which is the result of some code I have started working on but am not yet using in the code, along with a warning that is caused by one of the include files (a nested comment). I used -Wall -Wshadow -Wstrict-prototypes (This used to be commit 7b98fd5b69282320af700833c2d2720c42a382d8)
-rw-r--r--source3/client/clitar.c486
-rw-r--r--source3/include/includes.h8
2 files changed, 436 insertions, 58 deletions
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index 32731200b0..c0325c37e5 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -27,13 +27,44 @@
directory creation times
3. tar now accepts both UNIX path names and DOS path names. I prefer
those lovely /'s to those UGLY \'s :-)
+ 4. the files to exclude can be specified as a regular expression by adding
+ an r flag to the other tar flags. Eg:
+ -TcrX file.tar "*.(obj|exe)"
+
+ will skip all .obj and .exe files
*/
#include "includes.h"
#include "clitar.h"
-#include <regex.h>
+
+typedef struct file_info_struct file_info2;
+
+struct file_info_struct
+{
+ int size;
+ int mode;
+ int uid;
+ int gid;
+ /* These times are normally kept in GMT */
+ time_t mtime;
+ time_t atime;
+ time_t ctime;
+ char *name; /* This is dynamically allocate */
+
+ file_info2 *next, *prev; /* Used in the stack ... */
+
+};
+
+typedef struct
+{
+ file_info2 *top;
+ int items;
+
+} stack;
+
+stack dir_stack = {NULL, 0}; /* Want an empty stack */
extern BOOL recurse;
@@ -60,6 +91,11 @@ BOOL tar_inc=False;
BOOL tar_reset=False;
/* Include / exclude mode (true=include, false=exclude) */
BOOL tar_excl=True;
+/* use regular expressions for search on file names */
+BOOL tar_re_search=False;
+#ifdef HAVE_REGEX_H
+regex_t *preg;
+#endif
/* Dump files with System attribute */
BOOL tar_system=False;
/* Dump files with Hidden attribute */
@@ -86,18 +122,87 @@ int tarhandle;
static void writetarheader(int f, char *aname, int size, time_t mtime,
char *amode, unsigned char ftype);
-
-/* Forward references. */
+static void do_atar(char *rname,char *lname,file_info *finfo1);
+static void do_tar(file_info *finfo);
+static void oct_it(long value, int ndgs, char *p);
static void fixtarname(char *tptr, char *fp, int l);
static int dotarbuf(int f, char *b, int n);
-static void oct_it (long value, int ndgs, char *p);
+static void dozerobuf(int f, int n);
+static void dotareof(int f);
+static void initarbuf(void);
+static int do_setrattr(char *fname, int attr, int setit);
+
+/* restore functions */
+static long readtarheader(union hblock *hb, file_info2 *finfo, char *prefix);
static long unoct(char *p, int ndgs);
+static void do_tarput(void);
static void unfixtarname(char *tptr, char *fp, int l);
/*
* tar specific utitlities
*/
+/*
+ * Stack routines, push_dir, pop_dir, top_dir_name
+ */
+
+static BOOL push_dir(stack *tar_dir_stack, file_info2 *dir)
+{
+ dir -> next = tar_dir_stack -> top;
+ dir -> prev = NULL;
+ tar_dir_stack -> items++;
+ tar_dir_stack -> top = dir;
+ return(True);
+
+}
+
+static file_info2 *pop_dir(stack *tar_dir_stack)
+{
+ file_info2 *ptr;
+
+ ptr = tar_dir_stack -> top;
+ if (tar_dir_stack -> top != NULL) {
+
+ tar_dir_stack -> top = tar_dir_stack -> top -> next;
+ tar_dir_stack -> items--;
+
+ }
+
+ return ptr;
+
+}
+
+static char *top_dir_name(stack *tar_dir_stack)
+{
+
+ return(tar_dir_stack -> top != NULL?tar_dir_stack -> top -> name:NULL);
+
+}
+
+static BOOL sub_dir(char *dir1, char *dir2)
+{
+
+ return(True);
+
+}
+
+/* Create a string of size size+1 (for the null) */
+static char * string_create_s(int size)
+{
+ char *tmp;
+
+ tmp = (char *)malloc(size+1);
+
+ if (tmp == NULL) {
+
+ DEBUG(0, ("Out of memory in string_create_s\n"));
+
+ }
+
+ return(tmp);
+
+}
+
/****************************************************************************
Write a tar header to buffer
****************************************************************************/
@@ -108,7 +213,7 @@ static void writetarheader(int f, char *aname, int size, time_t mtime,
int i, chk, l;
char *jp;
- DEBUG(5, ("WriteTarHdr, Type = %c, Name = %s\n", ftype, aname));
+ DEBUG(5, ("WriteTarHdr, Type = %c, Size= %i, Name = %s\n", ftype, size, aname));
memset(hb.dummy, 0, sizeof(hb.dummy));
@@ -125,6 +230,7 @@ static void writetarheader(int f, char *aname, int size, time_t mtime,
memset(b, 0, l+TBLOCK+100);
fixtarname(b, aname, l+1);
i = strlen(b)+1;
+ DEBUG(5, ("File name in tar file: %s, size=%i, \n", b, strlen(b)));
dotarbuf(f, b, TBLOCK*(((i-1)/TBLOCK)+1));
free(b);
}
@@ -158,7 +264,7 @@ static void writetarheader(int f, char *aname, int size, time_t mtime,
/****************************************************************************
Read a tar header into a hblock structure, and validate
***************************************************************************/
-static long readtarheader(union hblock *hb, file_info *finfo, char *prefix)
+static long readtarheader(union hblock *hb, file_info2 *finfo, char *prefix)
{
long chk, fchk;
int i;
@@ -192,6 +298,13 @@ static long readtarheader(union hblock *hb, file_info *finfo, char *prefix)
return -1;
}
+ if ((finfo->name = string_create_s(strlen(prefix) + strlen(hb -> dbuf.name) + 3)) == NULL) {
+
+ DEBUG(0, ("Out of space creating file_info2 for %s\n", hb -> dbuf.name));
+ return(-1);
+
+ }
+
strcpy(finfo->name, prefix);
/* use l + 1 to do the null too; do prefix - prefcnt to zap leading slash */
@@ -298,7 +411,7 @@ static void dozerobuf(int f, int n)
/****************************************************************************
Malloc tape buffer
****************************************************************************/
-static void initarbuf(void)
+static void initarbuf()
{
/* initialize tar buffer */
tbufsiz=blocksize*TBLOCK;
@@ -447,6 +560,8 @@ static int do_setrtime(char *fname, int mtime)
char *inbuf, *outbuf, *p;
char *name;
+ DEBUG(5, ("Setting time on: %s, fnlen=%i.\n", fname, strlen(fname)));
+
name = (char *)malloc(strlen(fname) + 1 + 1);
if (name == NULL) {
@@ -600,7 +715,7 @@ static int do_setrattr(char *fname, int attr, int setit)
/****************************************************************************
Create a file on a share
***************************************************************************/
-static BOOL smbcreat(file_info finfo, int *fnum, char *inbuf, char *outbuf)
+static BOOL smbcreat(file_info2 finfo, int *fnum, char *inbuf, char *outbuf)
{
char *p;
/* *must* be called with buffer ready malloc'ed */
@@ -680,7 +795,7 @@ static BOOL smbwrite(int fnum, int n, int low, int high, int left,
/****************************************************************************
Close a file on a share
***************************************************************************/
-static BOOL smbshut(file_info finfo, int fnum, char *inbuf, char *outbuf)
+static BOOL smbshut(file_info2 finfo, int fnum, char *inbuf, char *outbuf)
{
/* *must* be called with buffer ready malloc'ed */
@@ -775,11 +890,21 @@ static BOOL ensurepath(char *fname, char *inbuf, char *outbuf)
/* *must* be called with buffer ready malloc'ed */
/* ensures path exists */
- pstring partpath, ffname;
+ char *partpath, *ffname;
char *p=fname, *basehack;
DEBUG(5, ( "Ensurepath called with: %s\n", fname));
+ partpath = string_create_s(strlen(fname));
+ ffname = string_create_s(strlen(fname));
+
+ if ((partpath == NULL) || (ffname == NULL)){
+
+ DEBUG(0, ("Out of memory in ensurepath: %s\n", fname));
+ return(False);
+
+ }
+
*partpath = 0;
/* fname copied to ffname so can strtok */
@@ -821,7 +946,7 @@ int padit(char *buf, int bufsize, int padsize)
int berr= 0;
int bytestowrite;
- DEBUG(0, ("Padding with %d zeros\n", padsize));
+ DEBUG(5, ("Padding with %d zeros\n", padsize));
memset(buf, 0, bufsize);
while( !berr && padsize > 0 ) {
bytestowrite= MIN(bufsize, padsize);
@@ -965,7 +1090,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
datalen = 0;
}
- DEBUG(2,("getting file %s of size %d bytes as a tar file %s",
+ DEBUG(3,("getting file %s of size %d bytes as a tar file %s",
finfo.name,
finfo.size,
lname));
@@ -1230,7 +1355,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
get_total_size += finfo.size;
/* Thanks to Carel-Jan Engel (ease@mail.wirehub.nl) for this one */
- DEBUG(2,("(%g kb/s) (average %g kb/s)\n",
+ DEBUG(3,("(%g kb/s) (average %g kb/s)\n",
finfo.size / MAX(0.001, (1.024*this_time)),
get_total_size / MAX(0.001, (1.024*get_total_time_ms))));
if (tar_noisy)
@@ -1265,7 +1390,14 @@ static void do_tar(file_info *finfo)
strcat(exclaim, "\\");
strcat(exclaim, finfo->name);
- if (clipfind(cliplist, clipn, exclaim)) {
+ DEBUG(5, ("...tar_re_search: %d\n", tar_re_search));
+
+ if ((!tar_re_search && clipfind(cliplist, clipn, exclaim)) ||
+#ifdef HAVE_REGEX_H
+ (tar_re_search && !regexec(preg, exclaim, 0, NULL, 0))) {
+#else
+ (tar_re_search && mask_match(exclaim, cliplist[0], True, False))) {
+#endif
DEBUG(3,("Skipping file %s\n", exclaim));
return;
}
@@ -1345,9 +1477,197 @@ static void unfixtarname(char *tptr, char *fp, int l)
}
}
-static void do_tarput(void)
+/****************************************************************************
+Move to the next block in the buffer, which may mean read in another set of
+blocks.
+****************************************************************************/
+static int next_block(char *ltarbuf, char *bufferp, int bufsiz)
{
- file_info finfo;
+ int bufread, total = 0;
+
+ if (bufferp >= (ltarbuf + bufsiz)) {
+
+ for (bufread = read(tarhandle, ltarbuf, bufsiz); total < bufsiz; total += bufread) {
+
+ if (bufread <= 0) { /* An error, return false */
+ return (total > 0 ? -2 : bufread);
+ }
+
+ }
+
+ bufferp = ltarbuf;
+
+ }
+ else {
+
+ bufferp += TBLOCK;
+
+ }
+
+ return(0);
+
+}
+
+static int skip_file(int skip)
+{
+
+ return(0);
+}
+
+static int get_file(file_info2 finfo)
+{
+
+ return(0);
+
+}
+
+static int get_dir(file_info2 finfo)
+{
+
+ return(0);
+
+}
+
+static char * get_longfilename(file_info2 finfo)
+{
+
+ return(NULL);
+
+}
+
+static char * bufferp;
+
+static void do_tarput2(void)
+{
+ file_info2 finfo, *finfo2;
+ struct timeval tp_start;
+ char *inbuf, *outbuf, *longfilename = NULL;
+ int skip = False;
+
+ GetTimeOfDay(&tp_start);
+
+ bufferp = tarbuf + tbufsiz; /* init this to force first read */
+
+ if (push_dir(&dir_stack, &finfo)) {
+
+ finfo2 = pop_dir(&dir_stack);
+ inbuf = top_dir_name(&dir_stack); /* FIXME */
+ if (sub_dir(inbuf, finfo2 -> name)){
+
+ DEBUG(0, (""));
+
+ }
+ }
+
+ inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
+ outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
+
+ if (!inbuf || !outbuf) {
+
+ DEBUG(0, ("Out of memory during allocate of inbuf and outbuf!\n"));
+ return;
+
+ }
+
+ if (next_block(tarbuf, bufferp, tbufsiz) <= 0) {
+
+ DEBUG(0, ("Empty file or short tar file: %s\n", strerror(errno)));
+
+ }
+
+ /* Now read through those files ... */
+
+ while (True) {
+
+ switch (readtarheader((union hblock *) bufferp, &finfo, cur_dir)) {
+
+ case -2: /* Hmm, not good, but not fatal */
+ DEBUG(0, ("Skipping %s...\n", finfo.name));
+ if ((next_block(tarbuf, bufferp, tbufsiz) <= 0) &&
+ !skip_file(finfo.size)) {
+
+ DEBUG(0, ("Short file, bailing out...\n"));
+ free(inbuf); free(outbuf);
+ continue;
+
+ }
+
+ break;
+
+ case -1:
+ DEBUG(0, ("abandoning restore, -1 from read tar header\n"));
+ free(inbuf); free(outbuf);
+ return;
+
+ case 0: /* chksum is zero - looks like an EOF */
+ DEBUG(0, ("total of %d tar files restored to share\n", ntarf));
+ free(inbuf); free(outbuf);
+ return; /* Hmmm, bad here ... */
+
+ default:
+ break;
+
+ }
+
+ /* Now, do we have a long file name? */
+
+ if (longfilename != NULL) {
+ if (strlen(longfilename) < sizeof(finfo.name)) { /* if we have space */
+
+ strncpy(finfo.name, longfilename, sizeof(finfo.name) - 1);
+ free(longfilename);
+ longfilename = NULL;
+
+ }
+ else {
+
+ DEBUG(0, ("filename: %s too long, skipping\n", strlen(longfilename)));
+ skip = True;
+
+ }
+ }
+
+ /* Well, now we have a header, process the file ... */
+
+ /* Should we skip the file? */
+
+ if (skip) {
+
+ skip_file(finfo.size);
+ continue;
+
+ }
+
+ /* We only get this far if we should process the file */
+
+ switch (((union hblock *)bufferp) -> dbuf.linkflag) {
+
+ case '0': /* Should use symbolic names--FIXME */
+ get_file(finfo);
+ break;
+
+ case '5':
+ get_dir(finfo);
+ break;
+
+ case 'L':
+ longfilename = get_longfilename(finfo);
+ break;
+
+ default:
+ skip_file(finfo.size); /* Don't handle these yet */
+ break;
+
+ }
+
+ }
+
+
+}
+
+static void do_tarput()
+{
+ file_info2 finfo;
int nread=0, bufread;
char *inbuf,*outbuf, *longname = NULL;
int fsize=0;
@@ -1355,6 +1675,8 @@ static void do_tarput(void)
struct timeval tp_start;
BOOL tskip=False; /* We'll take each file as it comes */
+ finfo.name = NULL; /* No name in here ... */
+
GetTimeOfDay(&tp_start);
inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
@@ -1372,7 +1694,7 @@ static void do_tarput(void)
/* These should be the only reads in clitar.c */
while ((bufread=read(tarhandle, tarbuf, tbufsiz))>0) {
- char *bufferp, *endofbuffer;
+ char *buffer_p, *endofbuffer;
int chunk;
/* Code to handle a short read.
@@ -1394,13 +1716,13 @@ static void do_tarput(void)
if (lread<=0) break;
}
- bufferp=tarbuf;
+ buffer_p=tarbuf;
endofbuffer=tarbuf+bufread;
if (tskip) {
if (fsize<bufread) {
tskip=False;
- bufferp+=fsize;
+ buffer_p+=fsize;
fsize=0;
} else {
if (fsize==bufread) tskip=False;
@@ -1415,18 +1737,25 @@ static void do_tarput(void)
int next_header = 1; /* Want at least one header */
while (next_header)
{
- if (bufferp >= endofbuffer) {
+ if (buffer_p >= endofbuffer) {
bufread = read(tarhandle, tarbuf, tbufsiz);
- bufferp = tarbuf;
+ buffer_p = tarbuf;
}
next_header = 0; /* Don't want the next one ... */
- switch (readtarheader((union hblock *) bufferp, &finfo, cur_dir))
+
+ if (finfo.name != NULL) { /* Free the space */
+
+ free(finfo.name);
+ finfo.name = NULL;
+
+ }
+ switch (readtarheader((union hblock *) buffer_p, &finfo, cur_dir))
{
case -2: /* something dodgy but not fatal about this */
DEBUG(0, ("skipping %s...\n", finfo.name));
- bufferp+=TBLOCK; /* header - like a link */
+ buffer_p+=TBLOCK; /* header - like a link */
continue;
case -1:
DEBUG(0, ("abandoning restore, -1 from readtarheader\n"));
@@ -1451,7 +1780,10 @@ static void do_tarput(void)
if (longname != NULL) {
- strncpy(finfo.name, longname, sizeof(pstring) - 1);
+ free(finfo.name); /* Free the name in the finfo */
+ finfo.name = string_create_s(strlen(longname) + 2);
+ strncpy(finfo.name, longname, strlen(longname) + 1);
+ DEBUG(5, ("Long name = \"%s\", filename=\"%s\"\n", longname, finfo.name));
free(longname);
longname = NULL;
@@ -1460,12 +1792,13 @@ static void do_tarput(void)
/* Check if a long-link. We do this before the clip checking
because clip-checking should clip on real name - RJS */
- if (((union hblock *)bufferp) -> dbuf.linkflag == 'L') {
+ if (((union hblock *)buffer_p) -> dbuf.linkflag == 'L') {
/* Skip this header, but pick up length, get the name and
fix the name and skip the name. Hmmm, what about end of
buffer??? */
+ DEBUG(5, ("Buffer size = %i\n", finfo.size + strlen(cur_dir) +1));
longname = malloc(finfo.size + strlen(cur_dir) + 1);
if (longname == NULL) {
@@ -1476,44 +1809,50 @@ static void do_tarput(void)
return;
}
- bufferp += TBLOCK; /* Skip that longlink header */
+ buffer_p += TBLOCK; /* Skip that longlink header */
/* This needs restructuring ... */
- if (bufferp >= endofbuffer) {
+ if (buffer_p >= endofbuffer) {
bufread = read(tarhandle, tarbuf, tbufsiz);
- bufferp = tarbuf;
+ buffer_p = tarbuf;
}
- strncpy(longname, cur_dir, strlen(cur_dir));
- unfixtarname(longname+strlen(cur_dir), bufferp, finfo.size);
+ strncpy(longname, cur_dir, strlen(cur_dir) + 1);
+ unfixtarname(longname+strlen(cur_dir), buffer_p, finfo.size);
+ DEBUG(5, ("UnfixedName: %s, buffer: %s\n", longname, buffer_p));
/* Next rounds up to next TBLOCK and takes care of us being right
on a TBLOCK boundary */
- bufferp += (((finfo.size - 1)/TBLOCK)+1)*TBLOCK;
+ buffer_p += (((finfo.size - 1)/TBLOCK)+1)*TBLOCK;
next_header = 1; /* Force read of next header */
}
}
tskip=clipn
- && (clipfind(cliplist, clipn, finfo.name) ^ tar_excl);
+ && ((!tar_re_search && clipfind(cliplist, clipn, finfo.name) ^ tar_excl)
+#ifdef HAVE_REGEX_H
+ || (tar_re_search && !regexec(preg, finfo.name, 0, NULL, 0)));
+#else
+ || (tar_re_search && mask_match(finfo.name, cliplist[0], True, False)));
+#endif
if (tskip) {
- bufferp+=TBLOCK;
+ buffer_p+=TBLOCK;
if (finfo.mode & aDIR)
continue;
else if ((fsize=finfo.size) % TBLOCK) {
fsize+=TBLOCK-(fsize%TBLOCK);
}
- if (fsize<endofbuffer-bufferp) {
- bufferp+=fsize;
+ if (fsize<endofbuffer-buffer_p) {
+ buffer_p+=fsize;
fsize=0;
continue;
} else {
- fsize-=endofbuffer-bufferp;
+ fsize-=endofbuffer-buffer_p;
break;
}
}
@@ -1522,9 +1861,10 @@ static void do_tarput(void)
if (finfo.mode & aDIR)
{
+
+ DEBUG(5, ("Creating directory: %s\n", finfo.name));
+
if (!ensurepath(finfo.name, inbuf, outbuf))
-/* if (!smbchkpath(finfo.name, inbuf, outbuf)
- && !smbmkdir(finfo.name, inbuf, outbuf))*/
{
DEBUG(0, ("abandoning restore, problems ensuring path\n"));
free(inbuf); free(outbuf);
@@ -1534,7 +1874,7 @@ static void do_tarput(void)
{
/* Now we update the creation date ... */
- DEBUG(5, ("Updating creation date on %s\n", finfo.name));
+ DEBUG(0, ("Updating creation date on %s\n", finfo.name));
if (!do_setrtime(finfo.name, finfo.mtime)) {
@@ -1544,7 +1884,7 @@ static void do_tarput(void)
}
ntarf++;
- bufferp+=TBLOCK;
+ buffer_p+=TBLOCK;
continue;
}
}
@@ -1562,22 +1902,22 @@ static void do_tarput(void)
DEBUG(0 ,("restore tar file %s of size %d bytes\n",
finfo.name,finfo.size));
- if (!finfo.size) {
+ /* if (!finfo.size) {
if (!smbshut(finfo, fnum, inbuf, outbuf)){
DEBUG(0, ("Error closing remote file of length 0: %s\n", finfo.name));
free(inbuf);free(outbuf);
return;
}
- }
+ } */
nread=0;
- if ((bufferp+=TBLOCK) >= endofbuffer) break;
+ if ((buffer_p+=TBLOCK) >= endofbuffer) break;
} /* if (!fsize) */
/* write out the file in chunk sized chunks - don't
* go past end of buffer though */
- chunk=(fsize-nread < endofbuffer - bufferp)
- ? fsize - nread : endofbuffer - bufferp;
+ chunk=(fsize-nread < endofbuffer - buffer_p)
+ ? fsize - nread : endofbuffer - buffer_p;
while (chunk > 0) {
int minichunk=MIN(chunk, max_xmit-200);
@@ -1587,7 +1927,7 @@ static void do_tarput(void)
nread, /* offset low */
0, /* offset high - not implemented */
fsize-nread, /* left - only hint to server */
- bufferp,
+ buffer_p,
inbuf,
outbuf))
{
@@ -1597,7 +1937,7 @@ static void do_tarput(void)
}
DEBUG(5, ("chunk writing fname=%s fnum=%d nread=%d minichunk=%d chunk=%d size=%d\n", finfo.name, fnum, nread, minichunk, chunk, fsize));
- bufferp+=minichunk; nread+=minichunk;
+ buffer_p+=minichunk; nread+=minichunk;
chunk-=minichunk;
}
@@ -1609,13 +1949,14 @@ static void do_tarput(void)
free(inbuf);free(outbuf);
return;
}
- if (fsize % TBLOCK) bufferp+=TBLOCK - (fsize % TBLOCK);
- DEBUG(5, ("bufferp is now %d (psn=%d)\n",
- (long) bufferp, (long)(bufferp - tarbuf)));
+ if (fsize % TBLOCK) buffer_p+=TBLOCK - (fsize % TBLOCK);
+ DEBUG(5, ("buffer_p is now %d (psn=%d)\n",
+ (long) buffer_p, (long)(buffer_p - tarbuf)));
ntarf++;
fsize=0;
+
}
- } while (bufferp < endofbuffer);
+ } while (buffer_p < endofbuffer);
}
DEBUG(0, ("premature eof on tar file ?\n"));
@@ -1780,7 +2121,12 @@ int process_tar(char *inbuf, char *outbuf)
initarbuf();
switch(tar_type) {
case 'x':
+
+#ifdef 0
+ do_tarput2();
+#else
do_tarput();
+#endif
free(tarbuf);
close(tarhandle);
break;
@@ -1791,7 +2137,7 @@ int process_tar(char *inbuf, char *outbuf)
pstring tarmac;
for (i=0; i<clipn; i++) {
- DEBUG(0,("arg %d = %s\n", i, cliplist[i]));
+ DEBUG(5,("arg %d = %s\n", i, cliplist[i]));
if (*(cliplist[i]+strlen(cliplist[i])-1)=='\\') {
*(cliplist[i]+strlen(cliplist[i])-1)='\0';
@@ -1932,6 +2278,10 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind)
}
tar_clipfl='X';
break;
+ case 'r':
+ DEBUG(0, ("tar_re_search set\n"));
+ tar_re_search = True;
+ break;
default:
DEBUG(0,("Unknown tar option\n"));
return 0;
@@ -1943,7 +2293,8 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind)
}
tar_excl=tar_clipfl!='X';
- if (Optind+1<argc) {
+
+ if (Optind+1<argc && !tar_re_search) { /* For backwards compatibility */
char *tmpstr;
char **tmplist;
int clipcount;
@@ -1977,6 +2328,35 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind)
}
cliplist = tmplist;
}
+
+ if (Optind+1<argc && tar_re_search) { /* Doing regular expression seaches */
+#ifdef HAVE_REGEX_H
+ int errcode;
+
+ if ((preg = (regex_t *)malloc(65536)) == NULL) {
+
+ DEBUG(0, ("Could not allocate buffer for regular expression search\n"));
+ return;
+
+ }
+
+ if (errcode = regcomp(preg, argv[Optind + 1], REG_EXTENDED)) {
+ char errstr[1024];
+ size_t errlen;
+
+ errlen = regerror(errcode, preg, errstr, sizeof(errstr) - 1);
+
+ DEBUG(0, ("Could not compile pattern buffer for re search: %s\n%s\n", argv[Optind + 1], errstr));
+ return;
+
+ }
+#endif
+
+ clipn=argc-Optind-1;
+ cliplist=argv+Optind+1;
+
+ }
+
if (Optind>=argc || !strcmp(argv[Optind], "-")) {
/* Sets tar handle to either 0 or 1, as appropriate */
tarhandle=(tar_type=='c');
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 859603c29f..e5076c6f39 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -205,6 +205,9 @@
#include <syslog.h>
#endif
+#ifdef HAVE_REGEX_H
+#include <regex.h>
+#endif
/***************************************************************************
@@ -1212,11 +1215,6 @@ extern char *sys_errlist[];
#define MAXCODEPAGELINES 256
#endif
-#ifdef USE_LDAP
-#include "lber.h"
-#include "ldap.h"
-#endif
-
/***** automatically generated prototypes *****/
#include "proto.h"