/* Monetra v5.x C API (c) 2005 by Main Street Softworks, Inc. This API is being released to the public domain to be modified and used in any manor the holder of this code sees fit. For any questions please contact support@mainstreetsoftworks.com */ #ifndef __MONETRA_H__ #define __MONETRA_H__ #ifdef _WIN32 #include "libmonetra_w32config.h" #else #include "libmonetra_config.h" #endif #define LIBMONETRA_VERSION 050200 #ifdef _WIN32 #ifdef LIBMONETRA_INTERNAL #define M_EXPORT __declspec(dllexport) #else /* !LIBMONETRA_INTERNAL */ #define M_EXPORT __declspec(dllimport) #endif /* !LIBMONETRA_INTERNAL */ #else /* !WIN32 */ #define M_EXPORT #endif /* !WIN32 */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include "libmonetra_compat.h" #define M_Safe(a) (a==NULL?"":a) #define M_isdigit(a) ((a >= '0' && a <= '9')?1:0) /* Define libmonetra types */ #ifdef HAVE_STDINT_H #include typedef int64_t M_int64; typedef uint64_t M_uint64; typedef int32_t M_int32; typedef uint32_t M_uint32; typedef uintptr_t M_uintptr; #else /* NO STDINT.H */ #ifdef _WIN32 typedef unsigned __int64 M_uint64; typedef signed __int64 M_int64; typedef signed int M_int32; typedef unsigned int M_uint32; typedef unsigned long M_uintptr; #else /* !WIN32 */ #ifdef NO_LONG_LONG typedef unsigned long M_uint64; typedef signed long M_int64; #else /* ! NO_LONG_LONG */ typedef unsigned long long M_uint64; typedef signed long long M_int64; #endif /* NO_LONG_LONG */ typedef signed int M_int32; typedef unsigned int M_uint32; typedef unsigned long M_uintptr; #endif /* _WIN32 */ #endif /* HAVE_STDINT_H */ /* Mac OS X 10.2 does not support atoll() but 10.3 does, * since we compile on 10.3, but need to support 10.2, * disable ATOLL hard for __APPLE__ */ #if defined(NO_ATOLL) || defined(__APPLE__) #if defined(NO_STRTOLL) M_int64 M_atoint64(const char *string); #define M_atoll(a) M_atoint64(a) #else /* STRTOLL does exist */ #define M_atoll(a) strtoll(a, NULL, 10); #endif /* NO_STRTOLL */ #else /* ATOLL does exist and we're !APPLE */ #define M_atoll(a) atoll(a) #endif /* Transaction States */ #define M_UNUSED 0 #define M_NEW 100 #define M_PENDING 1 #define M_DONE 2 /* Transaction Results */ #ifdef M_ERROR #undef M_ERROR #endif #define M_ERROR -1 #define M_FAIL 0 #define M_SUCCESS 1 #define M_AUTH 2 #define M_DENY 3 #define M_CALL 4 #define M_DUPL 5 #define M_PKUP 6 #define M_RETRY 7 #define M_SETUP 8 #define M_TIMEOUT 9 // AVS/CVV2 response codes #define M_GOOD 1 #define M_BAD 0 #define M_STREET 2 #define M_ZIP 3 #define M_UNKNOWN -1 /* SSL retries */ #ifndef M_SSL_RETRIES #define M_SSL_RETRIES 5 #endif typedef void * M_CONN; /* BASE ROUTINES */ M_EXPORT int M_InitEngine(const char *location); M_EXPORT void M_DestroyEngine(); M_EXPORT void M_InitConn(M_CONN *myconn); M_EXPORT int M_SetBlocking(M_CONN *myconn, int tf); M_EXPORT int M_SetLogging(M_CONN *myconn, int level); M_EXPORT int M_SetTimeout(M_CONN *myconn, long timeout); M_EXPORT int M_SetDropFile(M_CONN *myconn, const char *df_location); M_EXPORT int M_SetIP(M_CONN *myconn, const char *host, unsigned short port); M_EXPORT int M_SetSSL(M_CONN *myconn, const char *host, unsigned short port); M_EXPORT int M_SetSSL_CAfile(M_CONN *myconn, const char *path); M_EXPORT int M_SetSSL_Files(M_CONN *myconn, const char *sslkeyfile, const char *sslcertfile); M_EXPORT void M_VerifyConnection(M_CONN *myconn, int tf); M_EXPORT void M_VerifySSLCert(M_CONN *myconn, int tf); M_EXPORT int M_ValidateIdentifier(M_CONN * myconn, int tf); M_EXPORT int M_Connect(M_CONN *myconn); M_EXPORT void M_MaxConnTimeout(M_CONN *myconn, int maxtime); M_EXPORT const char *M_ConnectionError(M_CONN *myconn); M_EXPORT void M_DestroyConn(M_CONN *myconn); M_EXPORT int M_Monitor(M_CONN *myconn); M_EXPORT int M_TransactionsSent(M_CONN *myconn); #define M_DeleteResponse(a, b) M_DeleteTrans(a, b) M_EXPORT void M_DeleteTrans(M_CONN *myconn, M_uintptr identifier); M_EXPORT M_uintptr M_TransNew(M_CONN *myconn); M_EXPORT int M_TransKeyVal (M_CONN * myconn, M_uintptr identifier, const char *key, const char *value); /* DEPRECATE M_TransParam !! */ M_EXPORT int M_TransParam(M_CONN *myconn, M_uintptr identifier, int key, ...); M_EXPORT int M_TransSend(M_CONN *myconn, M_uintptr identifier); M_EXPORT const char *M_ResponseParam(M_CONN *myconn, M_uintptr identifier, const char *key); M_EXPORT char **M_ResponseKeys(M_CONN *myconn, M_uintptr identifier, int *num_keys); M_EXPORT const char *M_ResponseKeys_index(char **keys, int num_keys, int index); M_EXPORT int M_FreeResponseKeys(char **keys, int num_keys); /* Response Checking Routines */ M_EXPORT int M_ReturnStatus(M_CONN *myconn, M_uintptr identifier); M_EXPORT int M_ReturnCode(M_CONN *myconn, M_uintptr identifier); M_EXPORT long M_TransactionItem(M_CONN *myconn, M_uintptr identifier); M_EXPORT long M_TransactionBatch(M_CONN *myconn, M_uintptr identifier); M_EXPORT M_int64 M_TransactionID(M_CONN *myconn, M_uintptr identifier); M_EXPORT const char *M_TransactionAuth(M_CONN *myconn, M_uintptr identifier); M_EXPORT const char *M_TransactionText(M_CONN *myconn, M_uintptr identifier); M_EXPORT int M_TransactionAVS(M_CONN *myconn, M_uintptr identifier); M_EXPORT int M_TransactionCV(M_CONN *myconn, M_uintptr identifier); M_EXPORT long M_TransInQueue(M_CONN *myconn); M_EXPORT int M_CheckStatus(M_CONN *myconn, M_uintptr identifier); M_EXPORT long M_CompleteAuthorizations(M_CONN *myconn, M_uintptr **listings); M_EXPORT M_uintptr M_CompleteAuthorizations_index(M_uintptr *listings, int num_listings, int index); M_EXPORT int M_FreeCompleteAuthorizations(M_uintptr *listings, int num_listings); M_EXPORT char *M_EscapeTransaction(const char *trans); M_EXPORT char *M_UnscapeTransaction(const char *trans); /* Comma Delimited Routines */ M_EXPORT int M_IsCommaDelimited(M_CONN *myconn, M_uintptr identifier); M_EXPORT int M_ParseCommaDelimited(M_CONN *myconn, M_uintptr identifier); M_EXPORT const char *M_GetCommaDelimited(M_CONN *myconn, M_uintptr identifier); M_EXPORT const char *M_GetCell(M_CONN *myconn, M_uintptr identifier, const char *column, long row); M_EXPORT const char *M_GetCellByNum(M_CONN *myconn, M_uintptr identifier, int column, long row); M_EXPORT int M_NumColumns(M_CONN *myconn, M_uintptr identifier); M_EXPORT long M_NumRows(M_CONN *myconn, M_uintptr identifier); M_EXPORT const char *M_GetHeader(M_CONN *myconn, M_uintptr identifier, int column_num); M_EXPORT int M_uwait(unsigned long length); /* TEXT RESPONSE CONVERSIONS */ M_EXPORT const char *M_TEXT_Code(int code); M_EXPORT const char *M_TEXT_AVS(int code); M_EXPORT const char *M_TEXT_CV(int code); /* generate digest of SSL certificate for use in client-cert restrictions */ M_EXPORT char *M_SSLCert_gen_hash(const char *filename); typedef void *(* M_Register_Mutex)(void); typedef int (* M_Mutex_Lock)(void *); typedef int (* M_Mutex_Unlock)(void *); typedef int (* M_Unregister_Mutex)(void *); M_EXPORT int M_Register_mutexinit(M_CONN *myconn, M_Register_Mutex reg); M_EXPORT int M_Register_mutexdestroy(M_CONN *myconn, M_Unregister_Mutex reg); M_EXPORT int M_Register_mutexlock(M_CONN *myconn, M_Mutex_Lock reg); M_EXPORT int M_Register_mutexunlock(M_CONN *myconn, M_Mutex_Unlock reg); M_EXPORT int M_EnableThreadSafety(M_CONN *myconn); #include "libmonetra_legacy.h" #include "libmonetra_defines.h" #ifdef __cplusplus } #endif /* __cplusplus */ #endif