// Convert the internal zipname to a ISO compatible name to show to the user // via the callback and then in the message event. If dosify is true then the // name was converted to be OEM compatible and that is not what we want to // see. v1.55 changed the local OutFileName to the global fnamebuf; the stack // was partly overwritten in case a DLLprintf call followed afterwards. char *Oem2Iso(char *InFileName, struct Globals *pG) { if (pG->dosify) { int NameLen = lstrlen(InFileName); pG->fnamebuf[NameLen] = '\0'; OemToCharBuff(InFileName, pG->fnamebuf, NameLen); return pG->fnamebuf; } return InFileName; }
// Tim Kosse's LogMessage void LogMessage(const char *pStr, BOOL bOEM) { LVITEM item={0}; int nItemCount; if (!g_hwndList) return; //if (!lstrlen(pStr)) return; if (bOEM == TRUE) OemToCharBuff(pStr, (char *)pStr, lstrlen(pStr)); nItemCount=SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0); item.mask=LVIF_TEXT; item.pszText=(char *)pStr; item.cchTextMax=0; item.iItem=nItemCount; ListView_InsertItem(g_hwndList, &item); ListView_EnsureVisible(g_hwndList, item.iItem, 0); }
int Ask(const char *AskStr) { const int MaxItems=10; char Item[MaxItems][40]; int ItemKeyPos[MaxItems],NumItems=0; for (const char *NextItem=AskStr;NextItem!=NULL;NextItem=strchr(NextItem+1,'_')) { char *CurItem=Item[NumItems]; strncpyz(CurItem,NextItem+1,ASIZE(Item[0])); char *EndItem=strchr(CurItem,'_'); if (EndItem!=NULL) *EndItem=0; int KeyPos=0,CurKey; while ((CurKey=CurItem[KeyPos])!=0) { bool Found=false; for (int I=0;I<NumItems && !Found;I++) if (loctoupper(Item[I][ItemKeyPos[I]])==loctoupper(CurKey)) Found=true; if (!Found && CurKey!=' ') break; KeyPos++; } ItemKeyPos[NumItems]=KeyPos; NumItems++; } for (int I=0;I<NumItems;I++) { eprintf(I==0 ? (NumItems>4 ? "\n":" "):", "); int KeyPos=ItemKeyPos[I]; for (int J=0;J<KeyPos;J++) eprintf("%c",Item[I][J]); eprintf("[%c]%s",Item[I][KeyPos],&Item[I][KeyPos+1]); } eprintf(" "); int Ch=GetKey(); #if defined(_WIN_32) OemToCharBuff((LPCSTR)&Ch,(LPTSTR)&Ch,1); #endif Ch=loctoupper(Ch); for (int I=0;I<NumItems;I++) if (Ch==Item[I][ItemKeyPos[I]]) return(I+1); return(0); }
int GetCharTable(int i, struct CharTableSet *cts) { if (i>1) return Info.CharTable(i-2,(char *)cts,sizeof(struct CharTableSet)); else { for (int j=0; j<256; j++) cts->DecodeTable[j] = cts->EncodeTable[j] = (unsigned char) j; if (i == 1) { OemToCharBuff((const CHAR *)cts->DecodeTable,(CHAR *)cts->EncodeTable,256); CharToOemBuff((const CHAR *)cts->DecodeTable,(CHAR *)cts->DecodeTable,256); lstrcpy(cts->TableName,GetMsg(MWinText)); } else lstrcpy(cts->TableName,GetMsg(MDosText)); } return i; }
int winansi_read(int fd, void *buf, size_t count) { int rv; rv = read(fd, buf, count); if (!isatty(fd)) return rv; init(); if (!console_in) return rv; if ( rv > 0 ) { OemToCharBuff(buf, buf, rv); } return rv; }
unsigned long __stdcall systemexec_thread(void * pParam) { PS_ITEM* psi = (PS_ITEM*)pParam; char buf[4096]; wchar_t msg[4096 + 1]; // +1 for '\0' DWORD nr = 1; while (ReadFile(psi->m_hRead, buf, sizeof(buf), &nr, NULL) && nr > 0) { OemToCharBuff(buf, msg, nr); msg[nr] = L'\0'; EnterCriticalSection(&secSystemExec); tintin_puts2(msg); LeaveCriticalSection(&secSystemExec); } CloseHandle(psi->m_hRead); systemlist_delete(psi->m_dwPID); delete psi; return 0; }
int winansi_getc(FILE *stream) { int rv; rv = getc(stream); if (!isatty(fileno(stream))) return rv; init(); if (!console_in) return rv; if ( rv != EOF ) { unsigned char c = (unsigned char)rv; char *s = (char *)&c; OemToCharBuff(s, s, 1); rv = (int)c; } return rv; }
/////////////////////////////////////////////////////////////////////////////// // Export eines Objektes HRESULT CArcViewLayer::ExportData ( GSTRUCT *pGS, MFELD *pMF, LPCSTR pcUIdent, CArcViewLayerAttributes *pMap) { OBJECTTYPE rgType = GetType(); int iShapeId = -1; int iObjTyp = pGS -> Typ; _ASSERTE(rgType == ObjType2OBJECTTYPE(pGS -> Typ, true)); // Objekttyp muß stimmen // Geometrie erzeugen if (OBJECTTYPE_Area == rgType) { // Anzahl der Konturen feststellen und Konturfeld zusammenbauen int iKCnt = 1; vector<int> Cnts(1); int iCurr = 0; Cnts[0] = 0; for (int i = 0; 0 != pGS -> cnt[i]; ++i) { if (i > 0) Cnts.push_back(iCurr); iCurr += pGS -> cnt[i]; } iKCnt = i; _ASSERTE(iKCnt > 0 && iKCnt == Cnts.size()); // Objekt erzeugen CArcViewObject Obj(SHPCreateObject(m_nShapeType, -1, iKCnt, Cnts.begin(), NULL, pGS -> GSize, pGS -> x, pGS -> y, NULL, NULL)); iShapeId = SHPWriteObject(m_hSHP, -1, Obj); } else { // Objekt erzeugen CArcViewObject Obj(SHPCreateSimpleObject(m_nShapeType, pGS -> GSize, pGS -> x, pGS -> y, NULL)); iShapeId = SHPWriteObject(m_hSHP, -1, Obj); } if (iShapeId == -1) return E_FAIL; // Attribute sicherstellen (bei TRiAS-Datenquellen jedesmal) if (!HasFields() || DEX_GetTRiASDataSourceEx(DEX_GetObjectsProject(pGS -> Id))) { // sämtliche Attribute dieses Layers durchgehen und ggf. erzeugen for (CArcViewLayerAttributes::iterator it = pMap -> begin(); it != pMap -> end(); ++it) { // Feld in Datei erzeugen int iField = -1; CArcViewAttribute &rAttr = (*it).second; LPCSTR pcName = rAttr.GetName(); if (OBJECTTYPE_Text != m_rgType && !strcmp (pcName, g_cbLabelText)) continue; // Labeltext nur für Textobjekte if (FAILED(FieldExists (pcName, rAttr.GetTyp(), &iField))) { RETURN_FAILED_HRESULT(AddField(pcName, rAttr.GetTyp(), rAttr.GetLen(), rAttr.GetDecimals(), &iField)); } _ASSERTE(-1 != iField); // mehrerer Objekttypen eines Idents haben identischen Satz von Attributen _ASSERTE(-1 == (*it).second.GetField(iObjTyp) || (*it).second.GetField(iObjTyp) == iField || DEX_GetTRiASDataSourceEx(DEX_GetObjectsProject(pGS -> Id))); // Feldnummer beim Attribut speichern (*it).second.SetField(iField, iObjTyp); } // Textlabel für Textobjekte if (OBJECTTYPE_Text == m_rgType) { pair<CArcViewLayerAttributes::iterator, bool> p = pMap -> insert (CArcViewLayerAttributes::value_type (-1, CArcViewAttribute(g_cbLabelText, 'a', _MAX_PATH))); if (p.second) { int iField = -1; it = p.first; if (FAILED(FieldExists (g_cbLabelText, FTString, &iField))) { RETURN_FAILED_HRESULT(AddField(g_cbLabelText, FTString, _MAX_PATH, 0, &iField)); } _ASSERTE(-1 != iField); (*it).second.SetField(iField, iObjTyp); } } SetHasFields(); } // Attributwerte schreiben if (NULL != pMF) { // nur, wenn mindestens ein Attribut ausgegeben werden soll for (MFELD *pMFT = pMF; 0 != pMFT -> MCode; ++pMFT) { if (NULL != pMap) { CArcViewLayerAttributes::iterator it = pMap -> find (pMFT -> MCode); _ASSERTE(it != pMap -> end()); // Attribut sollte (jetzt) existieren if (it != pMap -> end()) { // Feld muß bereits erzeugt worden sein und Typ muß mit DBF übereinstimmen int iField = (*it).second.GetField(iObjTyp); _ASSERTE(-1 != iField); _ASSERTE((*it).second.GetTyp() == DBFGetFieldInfo (m_hDBF, iField, NULL, NULL, NULL)); // Wert je nach Typ in die Datenbank schreiben switch ((*it).second.GetTyp()) { case FTString: { char cbBuffer[_MAX_PATH] = { '\0' }; if (NULL != pMFT -> MText) OemToCharBuff(pMFT -> MText, cbBuffer, min(MAX_DBASEFIELD_LEN, strlen(pMFT -> MText))+1); // '\0' mit konvertieren DBFWriteStringAttribute(m_hDBF, iShapeId, iField, cbBuffer); } break; case FTInteger: DBFWriteIntegerAttribute(m_hDBF, iShapeId, iField, (NULL != pMFT -> MText) ? atol(pMFT -> MText) : 0); break; case FTDouble: DBFWriteDoubleAttribute(m_hDBF, iShapeId, iField, (NULL != pMFT -> MText) ? atof(pMFT -> MText) : 0.0); break; } } } else { _ASSERTE(NULL != pMap); // eigentlich sollte eine Map da sein // keine Map, also erstmal leeren Datensatz schreiben int iCnt = DBFGetFieldCount(m_hDBF); for (int i = 0; i < iCnt; ++i) { switch (DBFGetFieldInfo(m_hDBF, i, NULL, NULL, NULL)) { case FTString: DBFWriteStringAttribute(m_hDBF, iShapeId, i, g_cbNil); break; case FTInteger: DBFWriteIntegerAttribute(m_hDBF, iShapeId, i, 0); break; case FTDouble: DBFWriteDoubleAttribute(m_hDBF, iShapeId, i, 0.0); break; } } } } } return S_OK; }
int LIsUpper (unsigned Ch) { unsigned char c = Ch; OemToCharBuff ((char *) &c, (char *) &c, 1); return IsCharUpper (c); }
int LIsAlphanum (unsigned Ch) { unsigned char c = Ch; OemToCharBuff ((char *) &c, (char *) &c, 1); return IsCharAlphaNumeric (c); }
FarString FarString::ToANSI() const { FarString result (fData->fText, Length()); OemToCharBuff (fData->fText, result.GetBuffer(), Length()); return result; }