--- Convert-UUlib/UUlib.xs 2002/03/31 20:19:09 1.4 +++ Convert-UUlib/UUlib.xs 2003/11/06 13:33:40 1.9 @@ -7,14 +7,14 @@ #include "uulib/uuint.h" static int -not_here(char *s) +not_here (char *s) { - croak("%s not implemented on this architecture", s); + croak("%s not implemented", s); return -1; } static int -constant(char *name) +constant (char *name) { errno = 0; switch (*name) { @@ -43,25 +43,26 @@ if (strEQ(name, "MSG_PANIC")) return UUMSG_PANIC; if (strEQ(name, "MSG_WARNING")) return UUMSG_WARNING; case 'O': + if (strEQ(name, "OPT_VERSION")) return UUOPT_VERSION; + if (strEQ(name, "OPT_FAST")) return UUOPT_FAST; + if (strEQ(name, "OPT_DUMBNESS")) return UUOPT_DUMBNESS; if (strEQ(name, "OPT_BRACKPOL")) return UUOPT_BRACKPOL; - if (strEQ(name, "OPT_DEBUG")) return UUOPT_DEBUG; + if (strEQ(name, "OPT_VERBOSE")) return UUOPT_VERBOSE; if (strEQ(name, "OPT_DESPERATE")) return UUOPT_DESPERATE; - if (strEQ(name, "OPT_DUMBNESS")) return UUOPT_DUMBNESS; - if (strEQ(name, "OPT_ENCEXT")) return UUOPT_ENCEXT; - if (strEQ(name, "OPT_ERRNO")) return UUOPT_ERRNO; - if (strEQ(name, "OPT_FAST")) return UUOPT_FAST; - if (strEQ(name, "OPT_IGNMODE")) return UUOPT_IGNMODE; if (strEQ(name, "OPT_IGNREPLY")) return UUOPT_IGNREPLY; if (strEQ(name, "OPT_OVERWRITE")) return UUOPT_OVERWRITE; - if (strEQ(name, "OPT_PREAMB")) return UUOPT_PREAMB; - if (strEQ(name, "OPT_PROGRESS")) return UUOPT_PROGRESS; if (strEQ(name, "OPT_SAVEPATH")) return UUOPT_SAVEPATH; - if (strEQ(name, "OPT_TINYB64")) return UUOPT_TINYB64; + if (strEQ(name, "OPT_IGNMODE")) return UUOPT_IGNMODE; + if (strEQ(name, "OPT_DEBUG")) return UUOPT_DEBUG; + if (strEQ(name, "OPT_ERRNO")) return UUOPT_ERRNO; + if (strEQ(name, "OPT_PROGRESS")) return UUOPT_PROGRESS; if (strEQ(name, "OPT_USETEXT")) return UUOPT_USETEXT; - if (strEQ(name, "OPT_VERBOSE")) return UUOPT_VERBOSE; - if (strEQ(name, "OPT_VERSION")) return UUOPT_VERSION; + if (strEQ(name, "OPT_PREAMB")) return UUOPT_PREAMB; + if (strEQ(name, "OPT_TINYB64")) return UUOPT_TINYB64; + if (strEQ(name, "OPT_ENCEXT")) return UUOPT_ENCEXT; if (strEQ(name, "OPT_REMOVE")) return UUOPT_REMOVE; if (strEQ(name, "OPT_MOREMIME")) return UUOPT_MOREMIME; + if (strEQ(name, "OPT_DOTDOT")) return UUOPT_DOTDOT; case 'R': if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL; if (strEQ(name, "RET_CONT")) return UURET_CONT; @@ -74,7 +75,7 @@ if (strEQ(name, "RET_OK")) return UURET_OK; if (strEQ(name, "RET_UNSUP")) return UURET_UNSUP; case 'B': - if (strEQ(name, "B64ENCODED")) return B64ENCODED; + if (strEQ(name, "B64_ENCODED")) return B64ENCODED; if (strEQ(name, "BH_ENCODED")) return BH_ENCODED; case 'P': if (strEQ(name, "PT_ENCODED")) return PT_ENCODED; @@ -91,7 +92,8 @@ return 0; } -static void uu_msg_callback (void *cb, char *msg, int level) +static void +uu_msg_callback (void *cb, char *msg, int level) { dSP; @@ -104,7 +106,8 @@ PUTBACK; FREETMPS; LEAVE; } -static int uu_busy_callback (void *cb, uuprogress *uup) +static int +uu_busy_callback (void *cb, uuprogress *uup) { dSP; int count; @@ -131,7 +134,8 @@ return retval; } -static char *uu_fnamefilter_callback (void *cb, char *fname) +static char * +uu_fnamefilter_callback (void *cb, char *fname) { dSP; int count; @@ -153,7 +157,8 @@ return str; } -static int uu_file_callback (void *cb, char *id, char *fname, int retrieve) +static int +uu_file_callback (void *cb, char *id, char *fname, int retrieve) { dSP; int count; @@ -181,11 +186,58 @@ return retval; } -static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv; +static char * +uu_filename_callback (void *cb, char *subject, char *filename) +{ + dSP; + int count; + SV *retval; + STRLEN dc; + + ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,3); + + PUSHs(sv_2mortal(newSVpv(subject, 0))); + PUSHs(filename ? sv_2mortal(newSVpv(filename, 0)) : &PL_sv_undef); + + PUTBACK; count = perl_call_sv ((SV *)cb, G_ARRAY); SPAGAIN; + + if (count > 1) + croak ("filenamecallback perl callback returned more than one argument"); + + if (count) + { + _FP_free (filename); + + retval = POPs; + + if (SvOK (retval)) + { + STRLEN len; + char *fn = SvPV (retval, len); + + filename = malloc (len + 1); + + if (filename) + { + memcpy (filename, fn, len); + filename[len] = 0; + } + } + else + filename = 0; + } + + PUTBACK; FREETMPS; LEAVE; + + return filename; +} + +static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv; #define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL -static int uu_info_file(void *cb, char *info) +static int +uu_info_file (void *cb, char *info) { dSP; int count; @@ -228,12 +280,12 @@ PROTOTYPES: ENABLE int -constant(name) +constant (name) char * name void -UUInitialize() +UUInitialize () CODE: if (!uu_initialized) { @@ -246,7 +298,7 @@ } void -UUCleanUp() +UUCleanUp () CODE: if (uu_initialized) UUCleanUp (); @@ -254,7 +306,7 @@ uu_initialized = 0; SV * -UUGetOption(opt) +UUGetOption (opt) int opt CODE: { @@ -276,7 +328,7 @@ RETVAL int -UUSetOption(opt,val) +UUSetOption (opt, val) int opt SV * val CODE: @@ -292,40 +344,46 @@ RETVAL char * -UUstrerror(errcode) +UUstrerror (errcode) int errcode void -UUSetMsgCallback(func=0) +UUSetMsgCallback (func = 0) SV * func CODE: UUSetMsgCallback (FUNC_CB(uu_msg)); void -UUSetBusyCallback(func=0,msecs=1000) +UUSetBusyCallback (func = 0,msecs = 1000) SV * func long msecs CODE: UUSetBusyCallback (FUNC_CB(uu_busy), msecs); void -UUSetFileCallback(func=0) +UUSetFileCallback (func = 0) SV * func CODE: UUSetFileCallback (FUNC_CB(uu_file)); void -UUSetFNameFilter(func=0) +UUSetFNameFilter (func = 0) SV * func CODE: UUSetFNameFilter (FUNC_CB(uu_fnamefilter)); +void +UUSetFileNameCallback (func = 0) + SV * func + CODE: + UUSetFileNameCallback (FUNC_CB(uu_filename)); + char * -UUFNameFilter(fname) +UUFNameFilter (fname) char * fname void -UULoadFile(fname,id=0,delflag=0) +UULoadFile (fname, id = 0, delflag = 0, int partno = -1) char * fname char * id int delflag @@ -333,13 +391,13 @@ { int count; - XPUSHs(sv_2mortal(newSViv(UULoadFile (fname, id, delflag, &count)))); + XPUSHs(sv_2mortal(newSViv(UULoadFile (fname, id, delflag, partno, &count)))); if (GIMME_V == G_ARRAY) XPUSHs(sv_2mortal(newSViv(count))); } int -UUSmerge(pass) +UUSmerge (pass) int pass int @@ -419,45 +477,51 @@ int isemail uulist * -UUGetFileListItem(num) +UUGetFileListItem (num) int num +MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item + int -UURenameFile(item,newname) +rename (item, newname) uulist *item char * newname - ALIAS: - Convert::UUlib::Item::rename = 1 + CODE: + RETVAL = UURenameFile (item, newname); + OUTPUT: + RETVAL int -UUDecodeToTemp(item) +decode_temp (item) uulist *item - ALIAS: - Convert::UUlib::Item::decode_temp = 1 + CODE: + RETVAL = UUDecodeToTemp (item); + OUTPUT: + RETVAL int -UURemoveTemp(item) +remove_temp (item) uulist *item - ALIAS: - Convert::UUlib::Item::remove_temp = 1 + CODE: + RETVAL = UURemoveTemp (item); + OUTPUT: + RETVAL int -UUDecodeFile(item,target=0) +decode (item, target = 0) uulist *item char * target - ALIAS: - Convert::UUlib::Item::decode = 1 + CODE: + RETVAL = UUDecodeFile (item, target); + OUTPUT: + RETVAL void -UUInfoFile(item,func) +info (item, func) uulist *item SV * func CODE: - UUInfoFile(item,(void *)func,uu_info_file); - ALIAS: - Convert::UUlib::Item::info = 1 - -MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item + UUInfoFile (item,(void *)func, uu_info_file); short state(li) @@ -495,7 +559,7 @@ RETVAL char * -filename(li,newfilename=0) +filename (li, newfilename = 0) uulist *li char * newfilename CODE: @@ -509,7 +573,7 @@ RETVAL char * -subfname(li) +subfname (li) uulist *li CODE: RETVAL = li->subfname; @@ -517,7 +581,7 @@ RETVAL char * -mimeid(li) +mimeid (li) uulist *li CODE: RETVAL = li->mimeid; @@ -525,7 +589,7 @@ RETVAL char * -mimetype(li) +mimetype (li) uulist *li CODE: RETVAL = li->mimetype; @@ -533,17 +597,17 @@ RETVAL char * -binfile(li) +binfile (li) uulist *li CODE: RETVAL = li->binfile; OUTPUT: RETVAL -# functions accessing internal data(!) +# methods accessing internal data(!) void -parts(li) +parts (li) uulist *li PPCODE: { @@ -577,8 +641,9 @@ } BOOT: -uu_msg_sv = newSVsv(&PL_sv_undef); -uu_busy_sv = newSVsv(&PL_sv_undef); -uu_file_sv = newSVsv(&PL_sv_undef); -uu_fnamefilter_sv = newSVsv(&PL_sv_undef); + uu_msg_sv = newSVsv(&PL_sv_undef); + uu_busy_sv = newSVsv(&PL_sv_undef); + uu_file_sv = newSVsv(&PL_sv_undef); + uu_fnamefilter_sv = newSVsv(&PL_sv_undef); + uu_filename_sv = newSVsv(&PL_sv_undef);