本文整理汇总了C++中db_set_s函数的典型用法代码示例。如果您正苦于以下问题:C++ db_set_s函数的具体用法?C++ db_set_s怎么用?C++ db_set_s使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_set_s函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetInSessionOrder
void SetInSessionOrder(MCONTACT hContact,int mode,int count,unsigned int ordernum)
{
int iOrder=0;
char szTemp[3]={'\0'};
if (ordernum < 10)
mir_snprintf(szTemp, SIZEOF(szTemp), "%u%u", 0, ordernum);
else
mir_snprintf(szTemp, SIZEOF(szTemp), "%u", ordernum);
if (mode == 0) {
DBVARIANT dbv;
if (!db_get_s(hContact, MODNAME, "LastSessionsOrder", &dbv) && dbv.pszVal) {
dbv.pszVal[count*2]=szTemp[0];
dbv.pszVal[count*2+1]=szTemp[1];
db_set_s(hContact, MODNAME, "LastSessionsOrder", dbv.pszVal);
db_free(&dbv);
}
}
else if (mode == 1) {
DBVARIANT dbv;
if (!db_get_s(hContact, MODNAME, "UserSessionsOrder", &dbv) && dbv.pszVal) {
dbv.pszVal[count*2]=szTemp[0];
dbv.pszVal[count*2+1]=szTemp[1];
db_set_s(hContact, MODNAME, "UserSessionsOrder", dbv.pszVal);
db_free(&dbv);
}
}
}
示例2: RemoveSessionMark
void RemoveSessionMark(MCONTACT hContact,int mode,int marknum)
{
unsigned int i=1;
char temp_1[1]={'\0'},temp_2[1]={'\0'};
char szDst[256]={'\0'};
DBVARIANT dbv;
if (mode == 0) {
if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv) && dbv.pszVal) {
for (i=marknum;i<ses_limit;i++)
dbv.pszVal[i] = dbv.pszVal[i+1];
for (i=ses_limit;i<10;i++)
dbv.pszVal[i] = '0';
db_set_s(hContact, MODNAME, "LastSessionsMarks", dbv.pszVal);
db_free(&dbv);
}
}
else if (mode == 1) {
if (!db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv) && dbv.pszVal) {
for (i=marknum;i < ses_limit; i++)
dbv.pszVal[i] = dbv.pszVal[i+1];
db_set_s(hContact, MODNAME, "UserSessionsMarks", dbv.pszVal);
db_free(&dbv);
}
}
}
示例3: token
void CDropbox::RequestAccountInfo()
{
MCONTACT hContact = CDropbox::GetDefaultContact();
ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
GetAccountInfoRequest request(token);
NLHR_PTR response(request.Send(hNetlibConnection));
HandleHttpResponseError(response);
JSONNode root = JSONNode::parse(response->pData);
if (root.empty())
return;
JSONNode referral_link = root.at("referral_link");
if (!referral_link.empty())
db_set_s(hContact, MODULE, "Homepage", referral_link.as_string().c_str());
JSONNode display_name = root.at("display_name");
if (!display_name.empty())
{
ptrT display_name(mir_utf8decodeT(display_name.as_string().c_str()));
TCHAR *sep = _tcsrchr(display_name, _T(' '));
if (sep)
{
db_set_ts(hContact, MODULE, "LastName", sep + 1);
display_name[mir_tstrlen(display_name) - mir_tstrlen(sep)] = '\0';
db_set_ts(hContact, MODULE, "FirstName", display_name);
}
else
{
db_set_ts(hContact, MODULE, "FirstName", display_name);
db_unset(hContact, MODULE, "LastName");
}
}
JSONNode country = root.at("country");
if (!country.empty())
{
std::string isocode = country.as_string();
if (isocode.empty())
db_unset(hContact, MODULE, "Country");
else
{
char *country = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode.c_str(), 0);
db_set_s(hContact, MODULE, "Country", country);
}
}
JSONNode quota_info = root.at("quota_info");
if (!quota_info.empty())
{
db_set_dw(hContact, MODULE, "SharedQuota", quota_info.at("shared").as_int());
db_set_dw(hContact, MODULE, "NormalQuota", quota_info.at("normal").as_int());
db_set_dw(hContact, MODULE, "TotalQuota", quota_info.at("quota").as_int());
}
}
示例4: DlgProcContactInfo
INT_PTR CALLBACK DlgProcContactInfo(HWND hwnd, UINT msg, WPARAM, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwnd);
{
MCONTACT hContact = (MCONTACT)((PROPSHEETPAGE*)lParam)->lParam;
char name[2048];
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)hContact);
if (db_get_static(hContact, MODNAME, "Name", name, _countof(name)))
break;
SetDlgItemTextA(hwnd, IDC_DISPLAY_NAME, name);
if (db_get_static(hContact, MODNAME, "ToolTip", name, _countof(name)))
break;
SetDlgItemTextA(hwnd, IDC_TOOLTIP, name);
}
return TRUE;
case WM_COMMAND:
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
return TRUE;
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (GetWindowTextLength(GetDlgItem(hwnd, IDC_DISPLAY_NAME))) {
char text[512];
GetDlgItemTextA(hwnd, IDC_DISPLAY_NAME, text, _countof(text));
db_set_s(hContact, MODNAME, "Name", text);
WriteSetting(hContact, MODNAME, "Name", MODNAME, "Nick");
}
else {
db_unset(hContact, MODNAME, "Name");
db_unset(hContact, MODNAME, "Nick");
}
if (GetWindowTextLength(GetDlgItem(hwnd, IDC_TOOLTIP))) {
char text[2048];
GetDlgItemTextA(hwnd, IDC_TOOLTIP, text, _countof(text));
db_set_s(hContact, MODNAME, "ToolTip", text);
WriteSetting(hContact, MODNAME, "ToolTip", "UserInfo", "MyNotes");
}
else {
db_unset(hContact, MODNAME, "ToolTip");
db_unset(hContact, "UserInfo", "MyNotes");
}
}
return TRUE;
}
break;
}
return FALSE;
}
示例5: token
void CDropbox::RequestAccountInfo()
{
MCONTACT hContact = CDropbox::GetDefaultContact();
ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
GetAccountInfoRequest request(token);
NLHR_PTR response(request.Send(hNetlibConnection));
HandleHttpResponseError(response);
JSONNode root = JSONNode::parse(response->pData);
if (root.empty())
return;
JSONNode referral_link = root.at("referral_link");
if (!referral_link.empty())
db_set_s(hContact, MODULE, "Homepage", referral_link.as_string().c_str());
JSONNode display_name = root.at("display_name");
if (!display_name.empty())
{
CMString tszDisplayName(display_name.as_mstring());
int pos = tszDisplayName.ReverseFind(' ');
if (pos != -1)
{
db_set_ts(hContact, MODULE, "LastName", tszDisplayName.Mid(pos+1));
db_set_ts(hContact, MODULE, "FirstName", tszDisplayName.Left(pos));
}
else
{
db_set_ts(hContact, MODULE, "FirstName", tszDisplayName);
db_unset(hContact, MODULE, "LastName");
}
}
JSONNode country = root.at("country");
if (!country.empty())
{
std::string isocode = country.as_string();
if (isocode.empty())
db_unset(hContact, MODULE, "Country");
else
{
char *szCountry = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode.c_str(), 0);
db_set_s(hContact, MODULE, "Country", szCountry);
}
}
JSONNode quota_info = root.at("quota_info");
if (!quota_info.empty())
{
db_set_dw(hContact, MODULE, "SharedQuota", quota_info.at("shared").as_int());
db_set_dw(hContact, MODULE, "NormalQuota", quota_info.at("normal").as_int());
db_set_dw(hContact, MODULE, "TotalQuota", quota_info.at("quota").as_int());
}
}
示例6: AddInSessionOrder
void AddInSessionOrder(MCONTACT hContact, int mode, int ordernum, int writemode)
{
char szFormNumBuf[100];
mir_snprintf(szFormNumBuf, "%02u", ordernum);
if (mode == 0) {
ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsMarks"));
if (szValue) {
int len = (int)mir_strlen(szValue);
if (!len)
len = 20;
char *temp2 = (char*)_alloca(len - 1);
strncpy(temp2, szValue, len - 2);
temp2[len - 2] = '\0';
char *temp = (char*)_alloca(len + 1);
mir_snprintf(temp, len + 1, "%02u%s", ordernum, temp2);
for (int i = (g_ses_limit * 2); i < 20; i++)
temp[i] = '0';
db_set_s(hContact, MODNAME, "LastSessionsOrder", temp);
}
else if (writemode == 1) {
mir_snprintf(szFormNumBuf, "%02u%s", ordernum, "000000000000000000");
db_set_s(hContact, MODNAME, "LastSessionsOrder", szFormNumBuf);
}
}
else if (mode == 1) {
ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsOrder"));
if (szValue) {
char *pszBuffer;
if (mir_strlen(szValue) < (g_ses_count * 2)) {
pszBuffer = (char*)mir_alloc((g_ses_count * 2) + 1);
memset(pszBuffer, 0, ((g_ses_count * 2) + 1));
mir_strcpy(pszBuffer, szValue);
}
else pszBuffer = mir_strdup(szValue);
int len = (int)mir_strlen(pszBuffer);
len = (len == 0) ? 20 : len + 2;
char *temp = (char*)_alloca(len + 1);
mir_snprintf(temp, len + 1, "%02u%s", ordernum, szValue);
db_set_s(hContact, MODNAME, "UserSessionsOrder", temp);
mir_free(pszBuffer);
}
else if (writemode == 1)
db_set_s(hContact, MODNAME, "UserSessionsOrder", szFormNumBuf);
else
db_set_s(hContact, MODNAME, "UserSessionsOrder", "00");
}
}
示例7: token
void CDropbox::RequestAccountInfo(void *p)
{
CDropbox *self = (CDropbox*)p;
MCONTACT hContact = self->GetDefaultContact();
ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
GetCurrentAccountRequest request(token);
NLHR_PTR response(request.Send(self->hNetlibConnection));
HandleJsonResponseError(response);
JSONNode root = JSONNode::parse(response->pData);
if (root.empty())
return;
JSONNode referral_link = root.at("referral_link");
if (!referral_link.empty())
db_set_s(hContact, MODULE, "Homepage", referral_link.as_string().c_str());
JSONNode email = root.at("email");
if (!email.empty())
db_set_s(hContact, MODULE, "e-mail", email.as_string().c_str());
JSONNode name = root.at("name");
if (!name.empty()) {
db_set_utf(hContact, MODULE, "FirstName", name.at("given_name").as_string().c_str());
db_set_utf(hContact, MODULE, "LastName", name.at("surname").as_string().c_str());
}
JSONNode country = root.at("country");
if (!country.empty()) {
std::string isocode = country.as_string();
if (isocode.empty())
db_unset(hContact, MODULE, "Country");
else {
char *szCountry = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode.c_str(), 0);
db_set_s(hContact, MODULE, "Country", szCountry);
}
}
/*JSONNode quota_info = root.at("quota_info");
if (!quota_info.empty()) {
ULONG lTotalQuota = quota_info.at("quota").as_int();
ULONG lNormalQuota = quota_info.at("normal").as_int();
ULONG lSharedQuota = quota_info.at("shared").as_int();
db_set_dw(hContact, MODULE, "SharedQuota", lSharedQuota);
db_set_dw(hContact, MODULE, "NormalQuota", lNormalQuota);
db_set_dw(hContact, MODULE, "TotalQuota", lTotalQuota);
db_set_s(hContact, "CList", "StatusMsg", CMStringA(FORMAT, Translate("Free %ld of %ld MB"), (lTotalQuota - lNormalQuota) / (1024 * 1024), lTotalQuota / (1024 * 1024)));
}*/
}
示例8: SaveInitialDir
/**
* name: SaveInitialDir
* desc: save the last vCard directory from database
* pszInitialDir - buffer to store the initial dir to (size must be MAX_PATH)
* return: nothing
**/
static void SaveInitialDir(LPSTR pszInitialDir)
{
CHAR szRelative[MAX_PATH];
LPSTR p;
if (p = mir_strrchr(pszInitialDir, '\\')) {
*p = 0;
if ( PathToRelative(pszInitialDir, szRelative))
db_set_s(0, MODNAME, "vCardPath", szRelative);
else
db_set_s(0, MODNAME, "vCardPath", pszInitialDir);
*p = '\\';
}
}
示例9: AddSessionMark
void AddSessionMark(MCONTACT hContact, int mode, char bit)
{
DBVARIANT dbv;
unsigned int i;
char temp_1[1]={'\0'},temp_2[1]={'\0'};
char szDst[256]={'\0'};
char* pszBuffer=NULL;
if (mode == 0) {
if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv) && dbv.pszVal) {
temp_1[0]=dbv.pszVal[0];
for (i=0; i < ses_limit; i++) {
temp_2[0]=dbv.pszVal[i+1];
dbv.pszVal[i+1]=temp_1[0];
temp_1[0]=temp_2[0];
}
for (i=ses_limit; i < 10; i++)
dbv.pszVal[i]='0';
dbv.pszVal[0]=bit;
db_set_s(hContact, MODNAME, "LastSessionsMarks", dbv.pszVal);
db_free(&dbv);
}
else if (bit == '1') db_set_s(hContact, MODNAME, "LastSessionsMarks", "10000000000");
}
else if (mode == 1) {
if (!db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv) && dbv.pszVal) {
if (strlen(dbv.pszVal)<g_ses_count) {
pszBuffer = (char*)mir_alloc(g_ses_count+1);
ZeroMemory(pszBuffer,g_ses_count+1);
strcpy(pszBuffer,dbv.pszVal);
}
else pszBuffer = mir_strdup(dbv.pszVal);
db_free(&dbv);
temp_1[0]=pszBuffer[0];
for (i=0;i<g_ses_count;i++) {
temp_2[0]=pszBuffer[i+1];
pszBuffer[i+1]=temp_1[0];
temp_1[0]=temp_2[0];
}
pszBuffer[0]=bit;
db_set_s(hContact, MODNAME, "UserSessionsMarks", pszBuffer);
mir_free(pszBuffer);
}
else if (bit == '1')
db_set_s(hContact, MODNAME, "UserSessionsMarks", "10000000000");
else
db_set_s(hContact, MODNAME, "UserSessionsMarks", "00000000000");
}
}
示例10: TlenIqResultAuth
void TlenIqResultAuth(TlenProtocol *proto, XmlNode *iqNode)
{
char *type;
// RECVED: authentication result
// ACTION: if successfully logged in, continue by requesting roster list and set my initial status
if ((type=TlenXmlGetAttrValue(iqNode, "type")) == NULL) return;
if (!strcmp(type, "result")) {
DBVARIANT dbv;
if (db_get(NULL, proto->m_szModuleName, "Nick", &dbv))
db_set_s(NULL, proto->m_szModuleName, "Nick", proto->threadData->username);
else
db_free(&dbv);
// iqId = TlenSerialNext();
// TlenIqAdd(iqId, IQ_PROC_NONE, TlenIqResultGetRoster);
// TlenSend(info, "<iq type='get' id='"TLEN_IQID"%d'><query xmlns='jabber:iq:roster'/></iq>", iqId);
TlenSend(proto, "<iq type='get' id='GetRoster'><query xmlns='jabber:iq:roster'/></iq>");
TlenSend(proto, "<iq to='tcfg' type='get' id='TcfgGetAfterLoggedIn'></iq>");
}
// What to do if password error? etc...
else if (!strcmp(type, "error")) {
char text[128];
TlenSend(proto, "</s>");
mir_snprintf(text, sizeof(text), Translate("Authentication failed for %[email protected]%s."), proto->threadData->username, proto->threadData->server);
MessageBoxA(NULL, text, Translate("Tlen Authentication"), MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);
ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD);
proto->threadData = NULL; // To disallow auto reconnect
}
}
示例11: write_ping_address
void write_ping_address(PINGADDRESS &i)
{
char buff[16];
mir_snprintf(buff, "PING_DEST_%d", i.index);
if (i.item_id == 0) {
i.item_id = NextID++;
db_set_dw(0, PLUG, "NextID", NextID);
}
db_set_dw(0, buff, "Id", i.item_id);
db_set_ts(0, buff, "Address", i.pszName);
db_set_ts(0, buff, "Label", i.pszLabel);
db_set_w(0, buff, "Status", i.status);
db_set_dw(0, buff, "Port", i.port);
db_set_s(0, buff, "Proto", i.pszProto);
if (mir_tstrlen(i.pszCommand))
db_set_ts(0, buff, "Command", i.pszCommand);
else
db_unset(0, buff, "Command");
if (mir_tstrlen(i.pszParams))
db_set_ts(0, buff, "CommandParams", i.pszParams);
else
db_unset(0, buff, "CommandParams");
db_set_w(0, buff, "SetStatus", i.set_status);
db_set_w(0, buff, "GetStatus", i.get_status);
db_set_w(0, buff, "Index", i.index);
}
示例12: SiteDeleted
int SiteDeleted(WPARAM wParam, LPARAM)
{
MCONTACT hContact = wParam;
if (mir_strcmp(GetContactProto(hContact), MODULENAME))
return 0;
ptrT contactName( db_get_tsa(hContact, MODULENAME, PRESERVE_NAME_KEY));
// TEST GET NAME FOR CACHE
TCHAR cachepath[MAX_PATH], cachedirectorypath[MAX_PATH], newcachepath[MAX_PATH + 50];
GetModuleFileName(hInst, cachepath, _countof(cachepath));
TCHAR *cacheend = _tcsrchr(cachepath, '\\');
cacheend++;
*cacheend = '\0';
mir_sntprintf(cachedirectorypath, _T("%s")_T(MODULENAME)_T("cache\\"), cachepath);
CreateDirectory(cachedirectorypath, NULL);
mir_sntprintf(newcachepath, _T("%s")_T(MODULENAME)_T("cache\\%s.txt"), cachepath, contactName);
// file exists?
if ( _taccess(newcachepath, 0) != -1) {
FILE *pcachefile = _tfopen(newcachepath, _T("r"));
if (pcachefile != NULL) {
fclose(pcachefile);
DeleteFile(newcachepath);
db_set_s(hContact, MODULENAME, CACHE_FILE_KEY, "");
}
}
return 0;
}
示例13: Convert
static BOOL Convert(MCONTACT hContact, char* module, char* setting, int value, int toType) // 0 = byte, 1 = word, 2 = dword, 3 = string
{
int Result = 1;
char temp[64];
switch (toType) {
case 0:
if (value > 0xFF)
Result = 0;
else
db_set_b(hContact, module, setting, (BYTE)value);
break;
case 1:
if (value > 0xFFFF)
Result = 0;
else
db_set_w(hContact, module, setting, (WORD)value);
break;
case 2:
db_set_dw(hContact, module, setting, (DWORD)value);
break;
case 3:
db_unset(hContact, module, setting);
db_set_s(hContact, module, setting, itoa(value, temp, 10));
break;
}
return Result;
}
示例14: db_get_sa
ROWCELL *cppInitModernRow(ROWCELL ** tabAccess)
{
int fsize;
int seq = 0;
ROWCELL * RowRoot = NULL;
FILE * hFile;
int i=0;
if (!db_get_b(NULL,"ModernData","UseAdvancedRowLayout",SETTING_ROW_ADVANCEDLAYOUT_DEFAULT)) return NULL;
tmplbuf = NULL;
if ( db_get_b(NULL,"ModernData","UseAdvancedRowLayout",SETTING_ROW_ADVANCEDLAYOUT_DEFAULT) == 1)
tmplbuf = db_get_sa(NULL,"ModernData","RowTemplate");
if (tmplbuf) {
rowParse(RowRoot, RowRoot, tmplbuf, i, seq,tabAccess);
mir_free(tmplbuf);
return RowRoot;
}
if (hFile = fopen("template.txt", "rb"))
{
fsize = _filelength(_fileno(hFile));
tmplbuf = (char*)malloc(fsize+1);
ZeroMemory(tmplbuf, fsize+1);
for (i=0; i < fsize; i++) tmplbuf[i] = getc(hFile);
tmplbuf[i] = 0;
i=0;
rowParse(RowRoot, RowRoot, tmplbuf, i, seq,tabAccess);
db_set_s(NULL,"ModernData","RowTemplate",tmplbuf);
free(tmplbuf);
fclose(hFile);
return RowRoot;
}
return NULL;
}
示例15: db_set_s
/**
* name: CLineBuffer::DBWriteTokenFirst
* desc: scans for the first <delim> in the _pVal member and writes all characters
* that come before the first <delim> to database
* param: hContact - handle to the contact to write the setting to
* pszModule - destination module
* pszSetting - destination setting for the value
* delim - the deliminer which delimins the string
*
* return: 0 if successful, 1 otherwise
**/
int CLineBuffer::DBWriteTokenFirst(MCONTACT hContact, const CHAR* pszModule, const CHAR* pszSetting, const CHAR delim)
{
PBYTE here;
int iRet = 1;
_pTok = _pVal;
if (_pTok && *_pTok) {
for (here = _pTok;; here++) {
if (*here == 0 || *here == '\n' || *here == delim) {
if (here - _pTok > 0) {
CHAR c = *here;
*here = 0;
iRet = db_set_s(hContact, pszModule, pszSetting, (LPSTR)_pTok);
*here = c;
}
_pTok = (*here == 0 || *here == '\n') ? NULL : ++here;
break;
}
}
}
if (iRet) iRet = db_unset(hContact, pszModule, pszSetting);
return iRet;
}