DATASOURCE

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.

Members

GENERIC
A structure used only by the SMS API for extracting the type of datasource, so that the particular datasource used does not need to be explicitly implied.
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;
SQL_CONNECT_PARAMS
A structure used to store the information used to connect to an SMS database on a Microsoft SQL Server.
typedef struct _SQL_CONNECT_PARAMS {
    DATASOURCE_TYPE ds;
    char *pszServer;
    char *pszUserName;
    char *pszPasswd;
    char *pszDbName;
    char *pszKey;
    PDECRYPTFUNC pFunc;
} SQL_CONNECT_PARAMS;
ds
Points to a string that specifies the datasource type of the SMS database.
pszServer
Points to a string that specifies the name of the SQL Server containing the SMS database.
pszUserName
Points to a string that specifies the login identifier used to connect to the SQL Server.
pszPasswd
Points to a string that specifies the password for the login identifier.
pszDbName
Points to a string that specifies the database name of the SMS site database.
pszKey
Points to a string that specifies the decryption key if the login identifier and password are encrypted.
pFunc
Points to a decryption function. PDECRYPTFUNC is a prototype for a decryption function.

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);

Example

//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      = "";
 

See Also

SmsDataSourceConnect, SmsDataSourceDisconnect