void Split(const wchar_t* content, const wchar_t* string, wchar_t** first, wchar_t** second) { if (wcslen(content) > wcslen(string)) { wchar_t* p = StrStr(content, string); if (p == NULL) return; DWORD length = p - content; if (length > 0) { *first = new wchar_t[length + 1]; wmemset(*first, 0, length + 1); StrNCat(*first, content, length + 1); } p += wcslen(string); length = wcslen(content) - (p - content); if (length > 0) { *second = new wchar_t[length + 1]; wmemset(*second, 0, length + 1); StrNCat(*second, p, length + 1); } } }
Char* AdjustNote(Int16 iconNumber, Char* note) { extern Char gAppErrStr[]; Char *p, *q; noteTempBuffer[0] = 0; if (!note) { // 지금 가지고 있는 게 없을 경우 StrPrintF(noteTempBuffer, "ICON: %d\n#AN\n", iconNumber); } else { // note field에 내용이 있는 경우 if ( (p= StrStr(note, "#AN\n")) ) { // AN string을 가지고 있는 경우 if (iconNumber < 0) { // 있는 ICON: 을 제거 q = StrStr(note, "ICON:"); if (q == note) { q = StrStr(p, "\n"); StrNCopy(noteTempBuffer, q+1, 4096); } else { StrNCopy(noteTempBuffer, note, q-note); q = StrStr(q, "\n"); StrNCat(noteTempBuffer, q+1, 4096); } } else { // 있는 ICON: 변경 q = StrStr(note, "ICON:"); if (q) { StrNCopy(noteTempBuffer, note, q-note); q = StrStr(q, "\n") + 1; } else { StrNCopy(noteTempBuffer, note, p-note); q = p; } StrPrintF(gAppErrStr, "ICON: %d\n", iconNumber); StrNCat(noteTempBuffer, gAppErrStr, 4096); StrNCat(noteTempBuffer, q, 4096); } } else { StrPrintF(noteTempBuffer, "ICON: %d\n#AN\n", iconNumber); StrNCat(noteTempBuffer, note, 4096); } } return noteTempBuffer; }
NLM_EXTERN Nlm_CharPtr LIBCALL Nlm_StringNCpy_0 (char FAR *to, const char FAR *from, size_t max) { if (to != NULL && max > 0) to[0] = '\0'; if (from != NULL) StrNCat(to, from, max - 1); return to; }
void PrvPrepareDescriptionText(FlickrPrefs& prefs) { if (prefs.registered) return; StrNCopy(prefs.description, "Sent from ", prefs.maxDescriptionLength); PrvFillDeviceName(prefs.description, prefs.maxDescriptionLength); StrNCat(prefs.description," using ArsLexis InfoMan (" INFOMAN_WWW_LINK ").", prefs.maxDescriptionLength); prefs.description[prefs.maxDescriptionLength] = chrNull; return; }
static void PrvFillBuffer(char* buffer, UInt16 length, const char* text1, const char* text2) { UInt16 len1 = StrLen(text1); UInt16 len2 = StrLen(text2); buffer[length - 1] =chrNull; StrNCopy(buffer, text1, length - 1); StrNCat(buffer, text2, length - 1); if (len1 + len2 > length - 1) buffer[length - 2] = chrEllipsis; }
void SplitTitle(const wchar_t* content, wchar_t** title) { wchar_t* t1 = NULL; wchar_t* t2 = NULL; Split(content, L" ", &t1, &t2); DWORD length = 0; if (t1 != NULL && t2 != NULL) { length = wcslen(t2); *title = new wchar_t[length + 1]; wmemset(*title, 0, length + 1); StrNCat(*title, t2, length + 1); SAFE_DELETE_ARRAY(t1); SAFE_DELETE_ARRAY(t2); return; } if (t1 != NULL) { length = wcslen(t1); *title = new wchar_t[length + 1]; wmemset(*title, 0, length + 1); StrNCat(*title, t1, length + 1); SAFE_DELETE_ARRAY(t1); SAFE_DELETE_ARRAY(t2); return; } if (t2 != NULL) { length = wcslen(t2); *title = new wchar_t[length + 1]; wmemset(*title, 0, length + 1); StrNCat(*title, t2, length + 1); SAFE_DELETE_ARRAY(t1); SAFE_DELETE_ARRAY(t2); return; } }
extern Err vfsVolumeGetLabel(UInt16 volRefNum, Char *labelP, UInt16 bufLen) { axxPacCardInfo cardinfo; Int32 ret; /* If the label was already retrieved, return it directly */ if ( StrLen( label ) != 0 ) { StrNCopy( labelP, label, min( bufLen, 32 ) ); return errNone; } ret = axxPacGetCardInfo(LibRef, &cardinfo); if ( ret == 0 ) { StrNCopy(labelP, cardinfo.vendor_name, min(bufLen, 16)); StrNCat (labelP, cardinfo.device_name, bufLen) ; /* Keep the value for faster future accesses */ StrNCat (label, labelP, min(bufLen, 32)); return errNone; } else { return vfsErrVolumeBadRef; } }
void SplitTag(const char* filename, wchar_t** title, wchar_t** artist) { wchar_t* name = GetFileName(filename); if (name == NULL) return; wchar_t* p = name + wcslen(name); while (p > name) { if (*p == '.') { wmemset(p, 0, 1); break; } else p--; } wchar_t* t = NULL; wchar_t* a = NULL; Split(name, L"-", &t, &a); SAFE_DELETE_ARRAY(name); DWORD length = 0; if (a != NULL) { length = wcslen(a); *artist = new wchar_t[length + 1]; wmemset(*artist, 0, length + 1); StrNCat(*artist, a, length + 1); SAFE_DELETE_ARRAY(a); } if (t != NULL) { SplitTitle(t, title); SAFE_DELETE_ARRAY(t); } }
NLM_EXTERN Nlm_CharPtr LIBCALL Nlm_StringNCat (char FAR *to, const char FAR *from, size_t max) { return (to && from) ? StrNCat (to, from, max) : to; }
Boolean Ln2SlFormHandleEvent(EventPtr e) { Boolean handled = false; DateType dt = {0, 0}; FormPtr frm = FrmGetFormPtr(Ln2SlForm); switch (e->eType) { case frmOpenEvent: if(gbVgaExists) VgaFormModify(frm, vgaFormModify160To240); DateSecondsToDate(TimGetSeconds(), &dt); DateToAsciiLong(dt.month, dt.day, dt.year + 1904, gPrefdfmts, gAppErrStr); SetFieldTextFromStr(Ln2SlFormInput, gAppErrStr); FrmDrawForm(frm); handled = true; break; case ctlSelectEvent: switch(e->data.ctlSelect.controlID) { case Ln2SlFormOk: FrmReturnToForm(0); handled = true; break; case Ln2SlFormConvert: { HappyDaysFlag dummy; Int16 year, month, day; Char* input; int ret; input = FldGetTextPtr(GetObjectPointer(frm, Ln2SlFormInput)); if ((ret = AnalysisHappyDays(input, &dummy, &year, &month, &day))) { int syear, smonth, sday; int leapyes = CtlGetValue(GetObjectPointer(frm, Ln2SlFormInputLeap)); ret = lunarL2S(lunarRefNum, year, month, day, leapyes, &syear, &smonth, &sday); if (ret == errNone) { Char temp[15]; SysCopyStringResource(temp, DayOfWeek(smonth, sday, syear) + SunString); DateToAsciiLong(smonth, sday, syear, gPrefdfmts, gAppErrStr); StrNCat(gAppErrStr, " [", AppErrStrLen); StrNCat(gAppErrStr, temp, AppErrStrLen); StrNCat(gAppErrStr, "]", AppErrStrLen); FldDrawField(SetFieldTextFromStr(Ln2SlFormResult, gAppErrStr)); } else DisplayInvalidDateErrorString(Ln2SlFormResult); } else { DisplayInvalidDateErrorString(Ln2SlFormResult); } handled = true; break; } default: break; } break; case menuEvent: handled = TextMenuHandleEvent(e->data.menu.itemID, Ln2SlFormInput); break; default: break; } return handled; }
static void PrvFillDeviceName(char* buffer, UInt16 length) { UInt32 vendor = 0, device = 0; FtrGet(sysFtrCreator, sysFtrNumOEMCompanyID, &vendor); FtrGet(sysFtrCreator, sysFtrNumOEMDeviceID, &device); const char* vendorText = "Unknown"; const char* deviceText = NULL; // TODO: update vendor/devices list (can't use array because of globals) switch (vendor) { case 'hspr': vendorText = ""; switch (device) { case 0xb: deviceText = "Treo 180"; break; case 0xd: deviceText = "Treo 270"; break; case 0xe: deviceText = "Treo 300"; break; case 'H101': deviceText = "Treo 600"; break; case 'H201': deviceText = "Treo 600 Simulator"; break; case 'H102': deviceText = "Treo 650"; break; case 'H202': deviceText = "Treo 650 Simulator"; break; } break; case 'sony': vendorText = "Sony"; switch (device) { case 'mdna': deviceText = "PEG-T615C"; break; case 'prmr': deviceText = "PEG-UX50"; break; case 'atom': deviceText = "PEG-TH55"; break; case 'mdrd': deviceText = "PEG-NX80V"; break; case 'tldo': deviceText = "PEG-NX73V"; break; case 'vrna': deviceText = "PEG-TG50"; break; case 'crdb': deviceText = "PEG-NX60 or NX70V"; break; case 'mcnd': deviceText = "PEG-SJ33"; break; case 'glps': deviceText = "PEG-SJ22"; break; case 'goku': deviceText = "PEG-TJ35"; break; case 'luke': deviceText = "PEG-TJ37"; break; case 'ystn': deviceText = "PEG-N610C"; break; } break; case 'palm': case 'Palm': vendorText = ""; switch (device) { case 'hbbs': deviceText = "Palm m130"; break; case 'ecty': deviceText = "Palm m505"; break; case 'lith': deviceText = "Palm m515"; break; case 'Zpth': deviceText = "Zire 71"; break; case 'MT64': deviceText = "Tungsten C"; break; case 'atc1': deviceText = "Tungsten W"; break; case 'Cct1': deviceText = "Tungsten E"; break; case 'Frg1': deviceText = "Tungsten T"; break; case 'Frg2': deviceText = "Tungsten T2"; break; case 'Arz1': deviceText = "Tungsten T3"; break; case 'Zir4': deviceText = "Tungsten E2"; break; case 'TnT5': deviceText = "Tungsten T5"; break; case 'Cubs': deviceText = "Zire"; break; case 'Zi21': deviceText = "Zire 21"; break; case 'Zi22': deviceText = "Zire 31"; break; case 'Zi72': deviceText = "Zire 72"; break; case 'TunX': deviceText = "LifeDrive"; break; } break; case 'psys': vendorText = "Palm OS Simulator"; break; } StrNCat(buffer, vendorText, length); if (NULL != deviceText) { if (0 != StrLen(vendorText)) StrNCat(buffer, " ", length); StrNCat(buffer, deviceText, length); } }
int compare_VMSEntryInfo_structs(VMSEntryInfo * entry1, VMSEntryInfo * entry2) { int i, status; char date1[16], date2[16], time1[8], time2[8], month[4]; switch (HTfileSortMethod) { case FILE_BY_SIZE: /* both equal or both 0 */ if (entry1->size == entry2->size) return (strcasecomp(entry1->filename, entry2->filename)); else if (entry1->size > entry2->size) return (1); else return (-1); case FILE_BY_TYPE: if (entry1->type && entry2->type) { status = strcasecomp(entry1->type, entry2->type); if (status) return (status); /* else fall to filename comparison */ } return (strcasecomp(entry1->filename, entry2->filename)); case FILE_BY_DATE: if (entry1->date && entry2->date) { /* * Make sure we have the correct length. - FM */ if (strlen(entry1->date) != 12 || strlen(entry2->date) != 12) { return (strcasecomp(entry1->filename, entry2->filename)); } /* * Set up for sorting in reverse * chronological order. - FM */ if (entry1->date[7] != ' ') { strcpy(date1, "9999"); strcpy(time1, (char *) &entry1->date[7]); } else { strcpy(date1, (char *) &entry1->date[8]); strcpy(time1, "00:00"); } LYStrNCpy(month, entry1->date, 3); for (i = 0; i < 12; i++) { if (!strcasecomp(month, months[i])) { break; } } i++; sprintf(month, "%02d", i); strcat(date1, month); StrNCat(date1, (char *) &entry1->date[4], 2); date1[8] = '\0'; if (date1[6] == ' ') { date1[6] = '0'; } strcat(date1, time1); if (entry2->date[7] != ' ') { strcpy(date2, "9999"); strcpy(time2, (char *) &entry2->date[7]); } else { strcpy(date2, (char *) &entry2->date[8]); strcpy(time2, "00:00"); } LYStrNCpy(month, entry2->date, 3); for (i = 0; i < 12; i++) { if (!strcasecomp(month, months[i])) { break; } } i++; sprintf(month, "%02d", i); strcat(date2, month); StrNCat(date2, (char *) &entry2->date[4], 2); date2[8] = '\0'; if (date2[6] == ' ') { date2[6] = '0'; } strcat(date2, time2); /* * Do the comparison. - FM */ status = strcasecomp(date2, date1); if (status) return (status); /* else fall to filename comparison */ } return (strcasecomp(entry1->filename, entry2->filename)); case FILE_BY_NAME: default: return (strcmp(entry1->filename, entry2->filename)); } }
SSL* SSLMakeSession(SYS_SOCKET SockFD, int iTimeOut, int iIsServerCtx) { char szSessionId[256]; SYS_INET_ADDR addrInfo; const char* pszServerId = "Xmail_Server"; const char* pszClientId = "Xmail_Client"; const char* pszId = NULL; SSL_CTX* pSSLCtx = NULL; SSL* pSSLSession = NULL; ZeroData(addrInfo); SysGetPeerInfo(SockFD, addrInfo); SysInetNToA(addrInfo, szSessionId, sizeof(szSessionId)); /* [i_a] */ if(iSSLInit) { if(iIsServerCtx) { pSSLCtx = pSSLSrvCtx; pszId = pszServerId; } else { pSSLCtx = pSSLCliCtx; pszId = pszClientId; } StrNCat(szSessionId, pszId, CStringSize(szSessionId) - strlen(szSessionId)); pSSLSession = SSL_new(pSSLCtx); if(pSSLSession != NULL) { #ifdef DEBUG_SSL SSL_set_msg_callback(pSSLSession, msg_cb); #endif #if SSLEAY_VERSION_NUMBER >= 0x0922 SSL_set_session_id_context(pSSLSession, (const unsigned char*)&szSessionId, (unsigned int)strlen(szSessionId)); #endif BIO_set_tcp_ndelay(SockFD, 1); /* [i_a] */ SSL_set_fd(pSSLSession, SockFD); if(iIsServerCtx) { SSL_set_accept_state(pSSLSession); } else { SSL_set_connect_state(pSSLSession); } time_t tTimeOut = time(NULL) + iTimeOut; for(;;) { int iResult; if(iIsServerCtx) { iResult = SSL_accept(pSSLSession); } else { iResult = SSL_connect(pSSLSession); } iResult = SSL_get_error(pSSLSession, iResult); switch(iResult) { case SSL_ERROR_NONE: break; case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_WRITE: case SSL_ERROR_WANT_X509_LOOKUP: if(time(NULL) < tTimeOut) { SysMsSleep(1); continue; } default: SSL_free(pSSLSession); pSSLSession = NULL; } break; } } } return (pSSLSession); }
CDROM* GetCDROM() { CDROM* first = NULL; CDROM* last = NULL; wchar_t* name = L"²¥·Å¹âÅÌ(&G)"; HMENU menu = GetMenu(main_wnd.hWnd); HMENU sub = GetSubMenu(menu, 0); MENUITEMINFO item = {0}; item.fMask = MIIM_STRING | MIIM_ID | MIIM_SUBMENU; item.fType = MFT_STRING; item.fState = MFS_ENABLED; item.cbSize = sizeof(MENUITEMINFO); item.cch = wcslen(name); item.dwTypeData = name; item.hSubMenu = CreateMenu(); InsertMenuItem(sub, 1, TRUE, &item); DWORD n = GetLogicalDriveStrings(0, NULL); if (n > 0) { wchar_t* buffer = new wchar_t[n]; DWORD len = GetLogicalDriveStrings(n, buffer); wchar_t* ptr = buffer; DWORD i = 0; while (len > 0) { UINT type = GetDriveType(ptr); if (type == DRIVE_CDROM) { wchar_t driver[16] = {0}; StrCat(driver, L"\\\\.\\"); StrNCat(driver, ptr, 3); name = CDROMName(driver); if (name != NULL) { StrTrim(name, L" "); CDROM* cdrom = new CDROM(); ZeroMemory(cdrom, sizeof(CDROM)); StrNCat(cdrom->letter, ptr, 3); StrCat(cdrom->driver, driver); DWORD length = wcslen(name) + 16; cdrom->name = new wchar_t[length]; wmemset(cdrom->name, 0, length); StrCat(cdrom->name, L"["); StrCat(cdrom->name, cdrom->letter); StrCat(cdrom->name, L"] "); StrCat(cdrom->name, name); SAFE_DELETE_ARRAY(name); cdrom->msgId = WM_USER + WM_CDROM + i; cdrom->next = NULL; i++; if (first == NULL) { first = cdrom; last = cdrom; } else { last->next = cdrom; last = cdrom; } MENUITEMINFO child = {0}; child.fMask = MIIM_STRING | MIIM_ID; child.fType = MFT_STRING; child.fState = MFS_ENABLED; child.cbSize = sizeof(MENUITEMINFO); child.cch = wcslen(cdrom->name); child.dwTypeData = cdrom->name; child.wID = cdrom->msgId; InsertMenuItem(item.hSubMenu, 0, FALSE, &child); } } ptr += 4; len -= 4; } SAFE_DELETE_ARRAY(buffer); } return first; }