diff --git a/mbcico/binkp.c b/mbcico/binkp.c index d9889753..6c685c8a 100644 --- a/mbcico/binkp.c +++ b/mbcico/binkp.c @@ -55,6 +55,9 @@ #include "config.h" +#define BNKCHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@&=+%$-_.!()#|" + + static char rbuf[2048]; void binkp_send_data(char *, int); @@ -200,6 +203,33 @@ int resync(off_t off) +/* + * Translate filename to binkd filename + */ +char *unix2binkd(char *fn) +{ + static char buf[PATH_MAX]; + char *p, *q; + + memset(&buf, 0, sizeof(buf)); + p = fn; + q = buf; + + while (*p) { + if (strspn(p, (char *)BNKCHARS)) { + *q++ = *p; *q = '\0'; + } else { + sprintf(q, "\\%2x", *p); + } + p++; + } + *q = '\0'; + + return buf; +} + + + /* * Transmit data frame */ @@ -797,6 +827,7 @@ void fill_binkp_list(binkp_list **bll, file_list *fal, off_t offs) (*tmpl)->offset = offs; (*tmpl)->size = tstat.st_size; (*tmpl)->date = tstat.st_mtime; + Syslog('b', "fill_binkp_list %s => %s", fal->remote, unix2binkd(fal->remote)); }