Archive-Chm
view release on metacpan or search on metacpan
_set_errmsg(obj, "Could not open target archive.");
return 1;
}
chm->is_open = 1;
if (set_verbose("Archive::Chm", -1))
fprintf(_set_logfile(NULL), "Opened %s\n\n", get_name(obj));
}
return 0;
}
=head2 Control Methods
Methods for module control. It should be noted that the error flag is never reset by the module and should be manually reset after it has been checked. Archive::Chm only sets the error flag when an error occurs.
=cut
=head3 err
$chmobj->err($code);
Gets the current error code if $code = -1, otherwise sets it to $code.
=cut
int err(SV* obj, int error)
{
ChmFile* chm = (ChmFile*)SvIV(SvRV(obj));
if (error != -1)
chm->error = error;
return chm->error;
}
=head3 errmsg
$chmobj->errmsg();
Gets the string containing the error message corresponding to the last error encountered.
=cut
char* errmsg(SV* obj)
{
ChmFile* chm = (ChmFile*)SvIV(SvRV(obj));
return chm->errmsg;
}
/********************************************************************************
* *
* SIMULATED STATIC MEMBERS WITH GETTERS/SETTERS *
* *
********************************************************************************/
/*-------------------------------------------------------------------------------
// Function used to encapsulate the "global" outfile needed for the extract-
// callback function. It can set the outfile or get it (if the parameter is NULL).
// This function is needed so that we don't make outfile global and cause problems
// with multithreading (i.e. polluting the namespace).
//------------------------------------------------------------------------------*/
static FILE* _set_outfile(FILE *newfile)
{
static FILE* out = NULL;
if (newfile)
out = newfile;
return out;
}
/*-------------------------------------------------------------------------------
// Another function similar to _set_outfile. This one is used to get/set the
// log file used to output the result of operations.
//------------------------------------------------------------------------------*/
static FILE* _set_logfile(char *filename)
{
static FILE* log = NULL;
if (!log)
log = stdout;
//if we wanted to set the logfile, do it
if (filename)
{
//if we had another logfile open, close it
if (log && log != stdout)
fclose(log);
//we can set the logging to stdout, also used as a finishing routine
if (!strcmp(filename, "stdout"))
return log = stdout;
//now open the new logfile and if we are verbose, note the change
if ((log = fopen(filename, "a")) == NULL)
{
fprintf(stderr, "Error opening logfile %s.\n", filename);
fprintf(stderr, "Log is reset to stdout.\n");
log = stdout;
}
else
if (set_verbose("Archive::Chm", -1))
fprintf(log, "Succesfully switched to new logfile %s.\n\n", filename);
}
return log;
}
=head3 set_logfile
$chmobj->set_logfile($log_filename);
$log_filename = $chmobj->set_logfile();
Method used to get/set the logfile of the module. Notable that this is actually a static data member and as such common for all the Archive::Chm objects.
=cut
char* set_logfile(char* class, char* filename)
{
static char* logfile_name = NULL;
( run in 1.633 second using v1.01-cache-2.11-cpan-bbb979687b5 )