Convert-UUlib
view release on metacpan or search on metacpan
use Convert::UUlib ':all';
sub namefilter {
my ($path) = @_;
$path=~s/^.*[\/\\]//;
$path
}
sub busycb {
my ($action, $curfile, $partno, $numparts, $percent, $fsize) = @_;
$_[0]=straction($action);
print "busy_callback(", (join ",",@_), ")\n";
0
}
SetOption OPT_RBUF, 128*1024;
SetOption OPT_WBUF, 1024*1024;
SetOption OPT_IGNMODE, 1;
SetOption OPT_IGNMODE, 1;
SetOption OPT_VERBOSE, 1;
# show the three ways you can set callback functions. I normally
# prefer the one with the sub inplace.
SetFNameFilter \&namefilter;
SetBusyCallback "busycb", 333;
SetMsgCallback sub {
my ($msg, $level) = @_;
print uc strmsglevel $_[1], ": $msg\n";
};
# the following non-trivial FileNameCallback takes care
# of some subject lines not detected properly by uulib:
SetFileNameCallback sub {
return unless $_[1]; # skip "Re:"-plies et al.
use Convert::UUlib ':all';
sub namefilter {
my ($path) = @_;
$path=~s/^.*[\/\\]//;
$path
}
sub busycb {
my ($action, $curfile, $partno, $numparts, $percent, $fsize) = @_;
$_[0]=straction($action);
print "busy_callback(", (join ",",@_), ")\n";
0
}
SetOption OPT_RBUF, 128*1024;
SetOption OPT_WBUF, 1024*1024;
SetOption OPT_IGNMODE, 1;
SetOption OPT_IGNMODE, 1;
SetOption OPT_VERBOSE, 1;
# show the three ways you can set callback functions. I normally
# prefer the one with the sub inplace.
SetFNameFilter \&namefilter;
SetBusyCallback "busycb", 333;
SetMsgCallback sub {
my ($msg, $level) = @_;
print uc strmsglevel $_[1], ": $msg\n";
};
# the following non-trivial FileNameCallback takes care
# of some subject lines not detected properly by uulib:
SetFileNameCallback sub {
return unless $_[1]; # skip "Re:"-plies et al.
PUSHs (sv_2mortal (newSVpv (msg, 0)));
PUSHs (sv_2mortal (newSViv (level)));
PUTBACK; (void) perl_call_sv ((SV *)cb, G_VOID|G_DISCARD); SPAGAIN;
PUTBACK; FREETMPS; LEAVE;
} TEMP_RELEASE;
}
static int
uu_busy_callback (void *cb, uuprogress *uup)
{
int retval;
TEMP_ACQUIRE {
dSP;
int count;
ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 6);
PUSHs (sv_2mortal (newSViv (uup->action)));
PUSHs (sv_2mortal (newSVpv (uup->curfile, 0)));
PUSHs (sv_2mortal (newSViv (uup->partno)));
PUSHs (sv_2mortal (newSViv (uup->numparts)));
PUSHs (sv_2mortal (newSViv (uup->fsize)));
PUSHs (sv_2mortal (newSViv (uup->percent)));
PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN;
if (count != 1)
croak ("busycallback perl callback returned more than one argument");
retval = POPi;
PUTBACK; FREETMPS; LEAVE;
} TEMP_RELEASE;
return retval;
}
: 0;
}
PUTBACK; FREETMPS; LEAVE;
} TEMP_RELEASE;
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)
{
int retval;
TEMP_ACQUIRE {
UUSetMsgCallback (func = 0)
SV * func
CODE:
UUSetMsgCallback (FUNC_CB (uu_msg));
void
UUSetBusyCallback (func = 0,msecs = 1000)
SV * func
long msecs
CODE:
UUSetBusyCallback (FUNC_CB (uu_busy), msecs);
void
UUSetFileCallback (func = 0)
SV * func
CODE:
UUSetFileCallback (FUNC_CB (uu_file));
void
UUSetFNameFilter (func = 0)
SV * func
const_iv (QP_ENCODED , QP_ENCODED)
const_iv (UU_ENCODED , UU_ENCODED)
const_iv (XX_ENCODED , XX_ENCODED)
const_iv (YENC_ENCODED , YENC_ENCODED)
};
for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--)
newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
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);
initialise ();
}
example-decoder view on Meta::CPAN
use Convert::UUlib ':all';
sub namefilter {
my ($path) = @_;
$path=~s/^.*[\/\\]//;
$path
}
sub busycb {
my ($action, $curfile, $partno, $numparts, $percent, $fsize) = @_;
$_[0]=straction($action);
print "busy_callback(", (join ",",@_), ")\n";
0
}
SetOption OPT_RBUF, 128*1024;
SetOption OPT_WBUF, 1024*1024;
SetOption OPT_IGNMODE, 1;
SetOption OPT_VERBOSE, 1;
SetOption OPT_DOTDOT, 1;
SetOption OPT_AUTOCHECK, 0;
# show the three ways you can set callback functions. I normally
# prefer the one with the sub inplace.
SetFNameFilter \&namefilter;
SetBusyCallback "busycb", 333;
SetMsgCallback sub {
my ($msg, $level) = @_;
print uc strmsglevel $_[1], ": $msg\n";
};
# the following non-trivial FileNameCallback takes care
# of some subject lines not detected properly by uulib:
SetFileNameCallback sub {
return unless $_[1]; # skip "Re:"-plies et al.
uulib/uulib.c view on Meta::CPAN
/*
* The Global List of Files
*/
uulist *UUGlobalFileList = NULL;
/*
* time values for BusyCallback. msecs is MILLIsecs here
*/
static long uu_busy_msecs = 0; /* call callback function each msecs */
static long uu_last_secs = 0; /* secs of last call to callback */
static long uu_last_usecs = 0; /* usecs of last call to callback */
/*
* progress information
*/
uuprogress progress;
/*
* Linked list of files we want to delete after decoding
*/
typedef struct _itbd {
char *fname;
struct _itbd *NEXT;
} itbd;
static itbd * ftodel = NULL;
/*
* for the busy poll
*/
unsigned long uuyctr;
/*
* Areas to allocate. Instead of using static memory areas, we malloc()
* the memory in UUInitialize() and release them in UUCleanUp to prevent
* blowing up of the binary size
* This is a table with the pointers to allocate and required sizes.
* They are guaranteed to be never NULL.
uulib/uulib.c view on Meta::CPAN
{
#ifdef HAVE_GETTIMEOFDAY
struct timeval tv;
long msecs;
if (uu_BusyCallback) {
(void) gettimeofday (&tv, NULL);
msecs = 1000*(tv.tv_sec-uu_last_secs)+(tv.tv_usec-uu_last_usecs)/1000;
if (uu_last_secs==0 || msecs > uu_busy_msecs) {
uu_last_secs = tv.tv_sec;
uu_last_usecs = tv.tv_usec;
return (*uu_BusyCallback) (uu_BusyCBArg, &progress);
}
}
#else
time_t now;
long msecs;
if (uu_BusyCallback) {
if (uu_busy_msecs <= 0) {
msecs = 1;
}
else {
now = time(NULL);
msecs = 1000 * (now - uu_last_secs);
}
if (uu_last_secs==0 || msecs > uu_busy_msecs) {
uu_last_secs = now;
uu_last_usecs = 0;
return (*uu_BusyCallback) (uu_BusyCBArg, &progress);
}
}
#endif
return 0;
}
uulib/uulib.c view on Meta::CPAN
return UURET_OK;
}
int UUEXPORT
UUSetBusyCallback (void *opaque,
int (*func) (void *, uuprogress *),
long msecs)
{
uu_BusyCallback = func;
uu_BusyCBArg = opaque;
uu_busy_msecs = msecs;
return UURET_OK;
}
int UUEXPORT
UUSetFileCallback (void *opaque,
int (*func) (void *, char *, char *, int))
{
uu_FileCallback = func;
uu_FileCBArg = opaque;
( run in 0.817 second using v1.01-cache-2.11-cpan-87723dcf8b7 )