DATASOURCE is a union of structures that specifies the site database to which your application needs to connect. The DATASOURCE union is used by the SmsDataSourceConnect function.
typedef union {
GENERIC type;
SQL_CONNECT_PARAMS sqlParams;
DIR_PARAMS dirParams;
} DATASOURCE;
Before calling SmsDataSourceConnect, your application must set the appropriate values for the members in the DATASOURCE structure. For Microsoft SQL Server, your application must set the server name, login identifier, password, database, public encryption key, and a pointer to a decryption function for the sqlParams structure within the DATASOURCE union.
Currently, SMS supports one database type: Microsoft SQL Server. However, the SMS API is designed to allow support of other types of databases in the future.
typedef struct _GENERIC {
DATASOURCE_TYPE ds;
} GENERIC;
The DATASOURCE_TYPE enumerated type currently supports only DB_SQL (DB_OTHER and DIRECTORY are not implemented):
typedef enum { DB_SQL, DB_OTHER, DIRECTORY } DATASOURCE_TYPE;
typedef struct _SQL_CONNECT_PARAMS {
DATASOURCE_TYPE ds;
char *pszServer;
char *pszUserName;
char *pszPasswd;
char *pszDbName;
char *pszKey;
PDECRYPTFUNC pFunc;
} SQL_CONNECT_PARAMS;
When the SmsDataSourceConnect function is called, the login identifier and password can be passed in encrypted form. If pFunc is NULL, no encryption function is called. If the decryption function pointer is not NULL, the function will attempt to call the specified function both for the login identifier and password.
Your application must supply the decryption function that returns the decrypted data in the first parameter:
typedef void (*PDECRYPTFUNC)(char *pszBuffer, char *pszDecryptMe, char *pszKey);
//Structure that specifies the site database to connect to.
DATASOURCE dsParams;
//Assign values to the structure
//The type of database
dsParams.sqlParams.ds = DB_SQL;
//SQL Server name
dsParams.sqlParams.pszServer = "Jonathan1";
//Login ID
dsParams.sqlParams.pszUserName = "sa";
//Password for Login ID
dsParams.sqlParams.pszPasswd = "britain";
//Name of the site database
dsParams.sqlParams.pszDbName = "SMS";
//Pointer to encryption function. No function is used in this example.
dsParams.sqlParams.pFunc = NULL;
//Encryption key. No encryption key is used in this example.
dsParams.sqlParams.pszKey = "";
SmsDataSourceConnect, SmsDataSourceDisconnect