static cell_t SQL_GetDriver(IPluginContext *pContext, const cell_t *params) { char *name; pContext->LocalToString(params[1], &name); IDBDriver *driver = NULL; if (name[0] == '\0') { driver = g_DBMan.GetDefaultDriver(); } else { driver = g_DBMan.FindOrLoadDriver(name); } return (driver != NULL) ? driver->GetHandle() : BAD_HANDLE; }
static cell_t SQL_ReadDriver(IPluginContext *pContext, const cell_t *params) { IDatabase *db1=NULL; HandleError err; if ((err = g_DBMan.ReadHandle(params[1], DBHandle_Database, (void **)&db1)) != HandleError_None) { return pContext->ThrowNativeError("Invalid database Handle 1/%x (error: %d)", params[1], err); } IDBDriver *driver = db1->GetDriver(); pContext->StringToLocalUTF8(params[2], params[3], driver->GetIdentifier(), NULL); return driver->GetHandle(); }