int xtapi_init(char *appname, int *numdevs) { LONG retval; BOOL reinit; if (TapiObj.hObj) return XTAPI_SUCCESS; TapiObj.hWnd = GetLibraryWindow(); reinit = TRUE; // Allow for reinitialization while (1) { retval = lineInitialize(&TapiObj.hObj, GetWindowInstance(TapiObj.hWnd), tapi_callback, appname, &TapiObj.num_devs); if (!retval) { break; } else if (retval == LINEERR_REINIT) { if (reinit) { timer_delay(0x50000); // delay 5 seconds reinit = FALSE; } else { return XTAPI_APPCONFLICT; // another app is using tapi resources we need } } else if (retval == LINEERR_NODEVICE) { return XTAPI_NODEVICES; // should tell user to install a modem } else return XTAPI_GENERAL_ERR; } *numdevs = (int)TapiObj.num_devs; TapiDev.valid = FALSE; return XTAPI_SUCCESS; }
/* * Initialize TAPI. All we here is see if we can init and figure out how * many TAPI lines are on the system. We may not be able to work with * all of the lines on the system. Which lines we can use is determined * when we call lineOpen. */ long InitTapi(unsigned long * dwNumLines) { long lRet = -1; char szDebug[256]; g_hTAPI = NULL; lRet = lineInitialize(&g_hTAPI, g_hinstDLL, LineCallBackProc, "TAPIProcess", dwNumLines); wsprintf(szDebug,"lineInit returned %d with %u lines",lRet,*dwNumLines ); if(lRet == 0) debugString(4,"InitTapi",szDebug,_where()); else debugString(0,"InitTapi",szDebug,_where()); return lRet; }