|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef WIN32
|
|
Toshihiro Shimizu |
890ddd |
#pragma warning(disable : 4996)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <stdio.h></stdio.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <string.h></string.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h></assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "ttwain_state.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttwain_error.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "ttwain_util.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef __cplusplus
|
|
Toshihiro Shimizu |
890ddd |
extern "C" {
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static char Msg_out[1024];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define HUMAN_MESSAGES
|
|
Toshihiro Shimizu |
890ddd |
#ifdef HUMAN_MESSAGES
|
|
Toshihiro Shimizu |
890ddd |
const char *RC_msg[] =
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
"SUCCESS",
|
|
Toshihiro Shimizu |
890ddd |
"FAILURE",
|
|
Toshihiro Shimizu |
890ddd |
"CHECK STATUS ('tried hard')",
|
|
Toshihiro Shimizu |
890ddd |
"CANCEL",
|
|
Toshihiro Shimizu |
890ddd |
"DS EVENT",
|
|
Toshihiro Shimizu |
890ddd |
"NOT DSEVENT",
|
|
Toshihiro Shimizu |
890ddd |
"TRANSFER DONE",
|
|
Toshihiro Shimizu |
890ddd |
"END OF LIST",
|
|
Toshihiro Shimizu |
890ddd |
"INFO NOT SUPPORTED",
|
|
Toshihiro Shimizu |
890ddd |
"DATA NOT AVAILABLE"};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const char *CC_msg[] =
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
"SUCCESS",
|
|
Toshihiro Shimizu |
890ddd |
"FAILURE DUE TO UNKNOWN CAUSES",
|
|
Toshihiro Shimizu |
890ddd |
"LOW MEMORY",
|
|
Toshihiro Shimizu |
890ddd |
"NO DATA SOURCE",
|
|
Toshihiro Shimizu |
890ddd |
"DS IS CONNECTED TO MAX POSSIBLE APPS",
|
|
Toshihiro Shimizu |
890ddd |
"OPERATION ERROR, DS/DSM REPORTED ERROR",
|
|
Toshihiro Shimizu |
890ddd |
"UNKNOWN CAPABILITY",
|
|
Toshihiro Shimizu |
890ddd |
"undefined",
|
|
Toshihiro Shimizu |
890ddd |
"undefined",
|
|
Toshihiro Shimizu |
890ddd |
"UNRECOGNIZED TRIPLET",
|
|
Toshihiro Shimizu |
890ddd |
"DATA PARAMETER OUT OF RANGE",
|
|
Toshihiro Shimizu |
890ddd |
"TRIPLET OUT OF SEQUENCE",
|
|
Toshihiro Shimizu |
890ddd |
"UNKNOWN DESTINATION APP/SRC IN DSM_ESNTRY",
|
|
Toshihiro Shimizu |
890ddd |
"CAP NOT SUPPORTED BY SOURCE",
|
|
Toshihiro Shimizu |
890ddd |
"OPERATION NOT SUPPORTED BY CAP",
|
|
Toshihiro Shimizu |
890ddd |
"CAP HAS DEPENDANCY ON OTHER CAP",
|
|
Toshihiro Shimizu |
890ddd |
"FILE SYSTEM OPERATION IS DENIED (FILE IS PROTECTED)",
|
|
Toshihiro Shimizu |
890ddd |
"OPERATION FAILED BECAUSE FILE ALREADY EXISTS",
|
|
Toshihiro Shimizu |
890ddd |
"FILE NOT FOUND",
|
|
Toshihiro Shimizu |
890ddd |
"OPERATION FAILED BECAUSE DIRECTORY IS NOT EMPTY",
|
|
Toshihiro Shimizu |
890ddd |
"THE FEEDER IS JAMMED",
|
|
Toshihiro Shimizu |
890ddd |
"THE FEEDER DETECTED MULTIPLE PAGES",
|
|
Toshihiro Shimizu |
890ddd |
"ERROR WRITING THE FILE (MEANT FOR THINGS LIKE DISK FULL CONDITIONS)",
|
|
Toshihiro Shimizu |
890ddd |
"THE DEVICE WENT OFFLINE PRIOR TO OR DURING THIS OPERATION"};
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
const char *RC_msg[] =
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
"TWRC_SUCCESS",
|
|
Toshihiro Shimizu |
890ddd |
"TWRC_FAILURE",
|
|
Toshihiro Shimizu |
890ddd |
"TWRC_CHECKSTATUS ('tried hard')",
|
|
Toshihiro Shimizu |
890ddd |
"TWRC_CANCEL",
|
|
Toshihiro Shimizu |
890ddd |
"TWRC_DSEVENT",
|
|
Toshihiro Shimizu |
890ddd |
"TWRC_NOTDSEVENT",
|
|
Toshihiro Shimizu |
890ddd |
"TWRC_XFERDONE",
|
|
Toshihiro Shimizu |
890ddd |
"TWRC_ENDOFLIST",
|
|
Toshihiro Shimizu |
890ddd |
"TWRC_INFONOTSUPPORTED",
|
|
Toshihiro Shimizu |
890ddd |
"TWRC_DATANOTAVAILABLE"};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const char *CC_msg[] =
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_SUCCESS",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_BUMMER (Failure due to unknown causes)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_LOWMEMORY",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_NODS (No Data Source)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_MAXCONNECTIONS (DS is connected to max possible apps)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_OPERATIONERROR (DS/DSM reported error, app shouldn't)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_BADCAP (Unknown capability)",
|
|
Toshihiro Shimizu |
890ddd |
"7 (undefined)",
|
|
Toshihiro Shimizu |
890ddd |
"8 (undefined)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_BADPROTOCOL (Unrecognized triplet)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_BADVALUE (Data parameter out of range)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_SEQERROR (Triplet out of sequence)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_BADDEST (Unknown dest. App/Src in DSM_Esntry)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_CAPUNSUPPORTED (Cap not supported by source)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_CAPBADOPERATION (Operation not supported by cap)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_CAPSEQERROR (Cap has dependancy on other cap)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_DENIED (File System operation is denied (file is protected))",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_FILEEXISTS (Operation failed because file already exists)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_FILENOTFOUND (File not found)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_NOTEMPTY (Operation failed because directory is not empty)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_PAPERJAM (The feeder is jammed)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_PAPERDOUBLEFEED (The feeder detected multiple pages)",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_FILEWRITEERROR (Error writing the file (meant for things like disk full conditions))",
|
|
Toshihiro Shimizu |
890ddd |
"TWCC_CHECKDEVICEONLINE (The device went offline prior to or during this operation)"};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
/*---------------------------------------------------------------------------*/
|
|
Toshihiro Shimizu |
890ddd |
void TTWAIN_RecordError(void)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
char tmp[1024];
|
|
Toshihiro Shimizu |
890ddd |
TTwainData.ErrRC = TTWAIN_GetResultCode();
|
|
Toshihiro Shimizu |
890ddd |
if ((TTwainData.ErrRC == TWRC_FAILURE) ||
|
|
Toshihiro Shimizu |
890ddd |
(TTwainData.ErrRC == TWRC_CHECKSTATUS))
|
|
Toshihiro Shimizu |
890ddd |
TTwainData.ErrCC = TTWAIN_GetConditionCode();
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
TTwainData.ErrCC = -1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
strcpy(Msg_out, "");
|
|
Toshihiro Shimizu |
890ddd |
if (TTwainData.ErrRC < (sizeof(RC_msg) / sizeof(RC_msg[0]))) {
|
|
Toshihiro Shimizu |
890ddd |
sprintf(Msg_out, "RC: %s(%d)", RC_msg[TTwainData.ErrRC], (int)TTwainData.ErrRC);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
sprintf(Msg_out, "RC: %s(%d)", "unknown", (int)TTwainData.ErrRC);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (TTwainData.ErrCC < (sizeof(CC_msg) / sizeof(CC_msg[0]))) {
|
|
Toshihiro Shimizu |
890ddd |
sprintf(tmp, "CC: %s(%d)", CC_msg[TTwainData.ErrCC], (int)TTwainData.ErrCC);
|
|
Toshihiro Shimizu |
890ddd |
strcat(Msg_out, tmp);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
sprintf(tmp, "CC: %s(%d)", "unknown", (int)TTwainData.ErrCC);
|
|
Toshihiro Shimizu |
890ddd |
strcat(Msg_out, tmp);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (TTwainData.ErrRC == TWRC_FAILURE && TTwainData.ErrCC == TWCC_OPERATIONERROR) {
|
|
Toshihiro Shimizu |
890ddd |
#ifdef WIN32
|
|
Toshihiro Shimizu |
890ddd |
OutputDebugString(Msg_out);
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TOONZDEBUG
|
|
Toshihiro Shimizu |
890ddd |
printf("%s\n", Msg_out);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/*---------------------------------------------------------------------------*/
|
|
Toshihiro Shimizu |
890ddd |
char *TTWAIN_GetLastError(TUINT32 *rc, TUINT32 *cc)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(rc && cc);
|
|
Toshihiro Shimizu |
890ddd |
*rc = TTwainData.ErrRC;
|
|
Toshihiro Shimizu |
890ddd |
*cc = TTwainData.ErrCC;
|
|
Toshihiro Shimizu |
890ddd |
return Msg_out;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/*---------------------------------------------------------------------------*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef __cplusplus
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#endif
|