Date: Wed, 28 Jun 2000 18:53:58 +0200 From: Brad Knowles <blk@skynet.be> To: FreeBSD-STABLE Mailing List <freebsd-stable@freebsd.org> Cc: Jens A Nilsson <jnilsson@ludd.luth.se> Subject: regcomp(3) acting weird? Message-ID: <v0422080bb57fdaa5baf2@[195.238.1.121]>
next in thread | raw e-mail | index | archive | help
Folks,
I'm trying to use spegla 1.1p4 to mirror a particular site, and
up until now I've not had any trouble. However, now I want to skip a
particular subdirectory, and regcomp(3) looks to me like it's acting
really weird. I would normally take this issue up just with the
author, but it seems to me that the problem is with regcomp(3) and
not spegla, so I figured I'd ask here as well.
Here's the section of code (as it originally looked) that is
calling regcomp(3):
/* init the sp_skip struct */
struct sp_skip *
sps_init(const char *arg)
{
size_t len;
int cflags;
struct sp_skip *sps;
len = strlen(arg);
if ((sps = calloc((size_t)1, sizeof(*sps) + len + 1)) == NULL)
return NULL;
/* LINTED save us from one calloc */
sps->sps_name = (char *)(sps + 1);
(void) strcpy(sps->sps_name, arg);
cflags = 0;
cflags |= REG_EXTENDED; /* extended RE's */
cflags |= REG_NOSUB; /* only report match or no match */
sps->sps_reg_errno = regcomp(&sps->sps_reg, sps->sps_name, cflags);
if (sps->sps_reg_errno != 0) {
free(sps);
return NULL;
}
return sps;
}
Here is the configuration file I'm using:
version = 1.1
minfree = 102400
loglevel = 10
localdir = /home/ftp/mirror/interplay
dodelete = yes
remotedir = /pub
skip = ^/movies
username = anonymous
password = ftp@skynet.be
host = ftp.interplay.com
timeout = 120
retries = 300 # busy ftp server and lots of files.
# Takes lots of hours to complete
# and don't want to quit when we are
# almost finished.
retrytime = 120 # if network goes down don't consume
# all retries to fast.
logfile = /var/log/ftpd/interplay.log
lockfile = /var/run/interplay.lock
However, spegla dies while trying to parse it:
$ /usr/local/bin/spegla -f /usr/local/etc/spegla/interplay.conf
spegla: sps_init: Undefined error: 0
The section of spegla.c that is calling this routine is:
/* ARGSUSED */
static void
add_param_sps(int option, const char *arg, struct cl_sps_que **q)
{
struct sp_skip *sps;
option = 0; /* quiet gcc */
if (*q == NULL && ((*q = cl_sps_init()) == NULL))
e_err(1, "cl_sps_init");
if ((sps = sps_init(arg)) == NULL)
e_err(1, "sps_init");
if (sps_error(sps))
e_errx(1, "sps_init: %s", sps_strerror(sps));
(void) cl_sps_push(*q, sps);
}
However, looking at this problem further, it appears that the
error number regcomp(3) is returning is not *remotely* anywhere close
to any of the standard REG_* error codes. I put in some stupid
fprintf commands, and found the following values being set after the
call to regcomp(3):
sps->sps_name = ^/movies
(int) &sps->sps_reg = 135192588
(int) &sps->sps_reg.re_endp = 135192596
sps->sps_reg_errno = 135196672
These are the definitions I can find for REG_* in /usr/include/regex.h:
#define REG_BASIC 0000
#define REG_EXTENDED 0001
#define REG_ICASE 0002
#define REG_NOSUB 0004
#define REG_NEWLINE 0010
#define REG_NOSPEC 0020
#define REG_PEND 0040
#define REG_DUMP 0200
#define REG_NOMATCH 1
#define REG_BADPAT 2
#define REG_ECOLLATE 3
#define REG_ECTYPE 4
#define REG_EESCAPE 5
#define REG_ESUBREG 6
#define REG_EBRACK 7
#define REG_EPAREN 8
#define REG_EBRACE 9
#define REG_BADBR 10
#define REG_ERANGE 11
#define REG_ESPACE 12
#define REG_BADRPT 13
#define REG_EMPTY 14
#define REG_ASSERT 15
#define REG_INVARG 16
#define REG_ATOI 255 /* convert name to number (!) */
#define REG_ITOA 0400 /* convert number to name (!) */
#define REG_NOTBOL 00001
#define REG_NOTEOL 00002
#define REG_STARTEND 00004
#define REG_TRACE 00400 /* tracing of execution */
#define REG_LARGE 01000 /* force large representation */
#define REG_BACKR 02000 /* force use of backref code */
But none of these numbers looks remotely like what
sps->sps_reg_errno is being set to!
I'm completely and totally stumped. I've gotten to the point
where it looks like regcomp(3) is doing something totally whacked-out
in response to the input, but I can't figure out how to proceed from
here.
Any and all assistance would be appreciated!
--
These are my opinions -- not to be taken as official Skynet policy
======================================================================
Brad Knowles, <blk@skynet.be> || Belgacom Skynet SA/NV
Systems Architect, Mail/News/FTP/Proxy Admin || Rue Colonel Bourg, 124
Phone/Fax: +32-2-706.13.11/12.49 || B-1140 Brussels
http://www.skynet.be || Belgium
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?v0422080bb57fdaa5baf2>
