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