AMInt32 _AIMAuth_setSession(AIMAuth *pAuth, const AMChar *szSession) { AMInt32 iLen = 0; AMAssert(pAuth && szSession); iLen = AMStrlen(szSession); AMAssert(iLen); if(pAuth->szSession) { AMFree(pAuth->szSession); pAuth->szSession = AMNULL; } #if 1 //dynamic pAuth->szSession = szSession; #else pAuth->szSession = (AMChar *)AMMalloc(iLen + 1); if(!pAuth->szSession) return eAIM_RESULT_MALLOC_ERROR; AMStrcpy(pAuth->szSession, szSession); #endif pAuth->iStatus = eAUTH_SESSION; return eAIM_RESULT_OK; }
AMVoid IAccount_SetNameType(AIMAccount *pAcnt, const AMChar *szName, AMUInt32 uiNameLen, AIM_ACCOUNT_TYPE eType) { AMAssert(0 != pAcnt); AMAssert(0 != szName && eType>=0 && eType <= 8); if(pAcnt->szName) { AMFree(pAcnt->szName); pAcnt->szName = 0; } pAcnt->szName = AMMalloc(uiNameLen + 1); AMAssert(0 != pAcnt->szName); AMMemset(pAcnt->szName, 0, uiNameLen + 1); AMMemcpy(pAcnt->szName, szName, uiNameLen); pAcnt->eType = eType; if(pAcnt->szID) { AMFree(pAcnt->szID); pAcnt->szID = 0; } pAcnt->szID = AMMalloc(uiNameLen + ID_HEAD_LEN + 1); AMAssert(0 != pAcnt->szID); AMMemset(pAcnt->szID, 0, uiNameLen + ID_HEAD_LEN + 1); AMStrcpy(pAcnt->szID, szID_Head[eType]); AMMemcpy(pAcnt->szID + ID_HEAD_LEN, szName, uiNameLen); }
static AMChar *_genSession() { AMInt32 iGMTime = AMGetUpTime(AMNULL); AMChar *szSession = AMNULL; AMInt32 iUsed = 0, i = 0; szSession = (AMChar *)AMMalloc(LEN_SESSION + 1); if(!szSession) return AMNULL; AMMemset(szSession, 0, LEN_SESSION + 1); AMStrcpy(szSession, SESSION_PREFIX_AIM); iUsed = sizeof(SESSION_PREFIX_AIM) + _AIMItoa(iGMTime, szSession + sizeof(SESSION_PREFIX_AIM) - 1) -1; for(i=iUsed; i<LEN_SESSION; i++) szSession[i] = '0'; return szSession; }