Main Page   Namespace List   Class Hierarchy   Data Structures   File List   Namespace Members   Data Fields   Globals   Related Pages  

LibSrlMt.cpp

Go to the documentation of this file.
00001 /*
00002  * LibSrlMt.cpp
00003  *
00004  * Copyright 2003, MobileSpear Inc. (www.mobilespear.com). All rights reserved.
00005  * Copyright 2003, David Resnick. All rights reserved.
00006  *
00007  * See the file doc\license.txt for the terms of usage and distribution.
00008  */
00009 
00010 #define __USING_DEF_FILE__
00011 #include <srllib.h>
00012 
00013 #include <bogotel/libBogoTel.h>
00014 #include <bogotel/BgtErrors.h>
00015 
00016 long g_lLastErrDevHndl = -1;
00017 long g_lLastErr = 0;
00018 char g_szLastErrMsg[100];
00019 
00020 long __cdecl sr_setparm(long ddd, long parmid, void* valuep) 
00021 {
00022     HANDLE handle = NULL;
00023     g_lLastErrDevHndl = ddd;
00024 
00025     if (ddd != SRL_DEVICE) {
00026         g_lLastErr = ESR_NOTIMP;
00027         strcpy(g_szLastErrMsg, "The device handle may only be SRL_DEVICE");
00028         return -1;
00029     }
00030 
00031     switch (parmid) {
00032     case SR_WIN32INFO: {
00033         LPSRLWIN32INFO pSrlwin32info = reinterpret_cast<LPSRLWIN32INFO>(valuep);
00034         if (pSrlwin32info->dwHandleType != SR_RESETEVENT) {
00035             g_lLastErr = ESR_NOTIMP;
00036             strcpy(g_szLastErrMsg, "The handle type may only be SR_RESETEVENT");
00037             return -1;
00038         }
00039         if (pSrlwin32info->ObjectHandle == NULL) {
00040             g_lLastErr = ESR_MODE;
00041             strcpy(g_szLastErrMsg, "The event handle was NULL.");
00042             return -1;
00043         }
00044         handle = pSrlwin32info->ObjectHandle;
00045         break;
00046     }
00047     case SR_MODELTYPE:
00048     case SR_MODEID: {
00049         int mode = (*reinterpret_cast<int*>(valuep));
00050         if (mode != (SR_POLLMODE | SR_STASYNC)) {
00051             g_lLastErr = ESR_MODE;
00052             strcpy(g_szLastErrMsg, "Invalid valuep for parmid of SR_MODEID.");
00053             return -1;
00054         }
00055     }
00056         break;
00057     default:
00058         g_lLastErr = ESR_NOTIMP;
00059         strcpy(g_szLastErrMsg, "Invalid parmid used.");
00060         return -1;
00061     }
00062 
00063     if (bogotel::sr_setparm(parmid, handle) != bogotel::resultSUCCESS) {
00064         g_lLastErr = ESR_MODE;
00065         strcpy(g_szLastErrMsg, "bogotel::sr_setparm() failed.");
00066         return -1;
00067     } else {
00068         return 0;
00069     }
00070 }
00071 
00072 char * __cdecl ATDV_ERRMSGP(long ddd) 
00073 { 
00074     if (ddd != g_lLastErrDevHndl) {
00075         strcpy(g_szLastErrMsg, "Unknown device");
00076     }
00077     return g_szLastErrMsg;
00078 }
00079 
00080 long __cdecl ATDV_LASTERR(long ddd)
00081 {
00082     if (ddd != g_lLastErrDevHndl) {
00083         g_lLastErr = AT_FAILURE;
00084     }
00085     return g_lLastErr;
00086 }
00087 
00088 long __cdecl sr_waitevt(long tmout) 
00089 { 
00090     long lRemaining;
00091     bogotel::sr_waitevt(tmout, &lRemaining);
00092     return lRemaining;
00093 }
00094 
00095 void * __cdecl sr_getevtdatap(...) 
00096 { 
00097     void *pData;
00098     int rc;
00099     unsigned long evt_handle = 0;
00100     if ((rc = bogotel::sr_getevtdatap(evt_handle, &pData)) != bogotel::resultSUCCESS) {
00101         return NULL;
00102     }
00103     return pData;
00104 }
00105 
00106 long __cdecl sr_getevtlen(...) 
00107 { 
00108     int rc;
00109     long lLen;
00110     unsigned long evt_handle = 0;
00111     if ((rc = bogotel::sr_getevtlen(evt_handle, &lLen)) != bogotel::resultSUCCESS) {
00112         return -1;
00113     }
00114     return lLen;
00115 }
00116 
00117 long __cdecl sr_getevtdev(...) 
00118 { 
00119     long lHandle;
00120     int rc;
00121     unsigned long evt_handle = 0;
00122     if ((rc = bogotel::sr_getevtdev(evt_handle, &lHandle)) != bogotel::resultSUCCESS) {
00123         return -1;
00124     }
00125     return lHandle;
00126 }
00127 
00128 long __cdecl sr_getevttype(...) 
00129 { 
00130     int rc;
00131     long lType;
00132     unsigned long evt_handle = 0;
00133     if ((rc = bogotel::sr_getevttype(evt_handle, &lType)) != bogotel::resultSUCCESS) {
00134         return -1;
00135     }
00136     return lType;
00137 }
00138 
00139 long __cdecl sr_enbhdlr(long dev, unsigned long event_type,
00140                        long (*hdlr)(unsigned long parm)) 
00141 { 
00142     if (bogotel::sr_enbhdlr(dev, event_type, hdlr) != bogotel::resultSUCCESS) {
00143         return -1;
00144     }
00145     return 0;
00146 }
00147 
00148 long __cdecl sr_dishdlr(long dev, unsigned long event_type,
00149                        long (*hdlr)(unsigned long parm)) 
00150 { 
00151     if (bogotel::sr_dishdlr(dev, event_type, hdlr) != bogotel::resultSUCCESS) {
00152         return -1;
00153     }
00154     return 0;
00155 }
00156 
00157 long __cdecl sr_putevt(long dev, unsigned long event_type, long len, void *pData, long err) 
00158 { 
00159     if (bogotel::sr_putevt(dev, event_type, len, pData, err) != bogotel::resultSUCCESS) {
00160         return -1;
00161     }
00162     return 0;
00163 }
00164 
00165 long __cdecl sr_waitevtEx(long *handlep, int count, long tmout, long *evthp) { return 0; }
00166 
00167 char * __cdecl ATDV_NAMEP(long ddd) { return NULL; }
00168 long __cdecl sr_hold(void) { return 0; }
00169 long __cdecl sr_release(void) { return 0; }
00170 

Generated on Tue Aug 12 12:41:29 2003 for bogotel by doxygen 1.3. Hosted by SourceForge.net Logo