static void CopyOutbound(OUTBOUND *pOutbounds, USERDATAOPT *pUserdata, char *pchFileName, char *OutboundPath) { FTNADDRESS Address; memset(pOutbounds, 0, sizeof(OUTBOUND)*MAX_ADDRESSES); /* Pfad konstruieren */ if (OutboundPath[0] && OutboundPath[1] == ':') { /* kompletter Pfad */ strcpy(pOutbounds[0].outbound, OutboundPath); } else { /* Teilpfad */ CopyPath(pOutbounds[0].outbound, pchFileName); strcat(pOutbounds[0].outbound, "\\"); strcat(pOutbounds[0].outbound, OutboundPath); } StringToNetAddr(pUserdata->address[0], &Address, NULL); pOutbounds[0].zonenum = Address.usZone; return; }
static void AddNetmailArea(AREADEFOPT *pAreaDef, char *pchFileName, char *NetmailPath, USERDATAOPT *pUserData, PAREALIST pRetList) { memset(pAreaDef, 0, sizeof(AREADEFOPT)); if (NetmailPath[0] && NetmailPath[1] == ':') strncpy(pAreaDef->pathfile, NetmailPath, LEN_PATHNAME); else { CopyPath(pAreaDef->pathfile, pchFileName); strcat(pAreaDef->pathfile, "\\"); strcat(pAreaDef->pathfile, NetmailPath); pAreaDef->ulTempFlags = AREAFLAG_NOREMAP; } strcpy(pAreaDef->areatag, "NETMAIL"); strcpy(pAreaDef->areadesc, "Netmail"); strcpy(pAreaDef->username, pUserData->username[0]); strcpy(pAreaDef->address, pUserData->address[0]); pAreaDef->areatype = AREATYPE_NET; pAreaDef->areaformat = AREAFORMAT_FTS; pAreaDef->ulAreaOpt = AREAOPT_FROMCFG; pAreaDef->ulDefAttrib = ATTRIB_PRIVATE; AM_AddArea(pRetList, pAreaDef, ADDAREA_TAIL | ADDAREA_UNIQUE); return; }
static lt_dlhandle LoadLib( const char* szFileName, const char* const szExtensions[]) { lt_dlhandle hMod = 0; char szFull[MAX_PATH]; const char* szExt; unsigned iExtension; unsigned iCur; unsigned iEnd = CopyPath(szFileName, szFull, _countof(szFull), 0); if (iEnd == 0) { s_dwLastError = ERROR_INVALID_PARAMETER; goto Done; } for (iExtension = 0; !hMod && szExtensions[iExtension]; iExtension++) { szExt = szExtensions[iExtension]; for (iCur = 0; szExt[iCur] && iEnd + iCur < _countof(szFull); iCur++) { szFull[iEnd + iCur] = szExt[iCur]; } if (iEnd + iCur >= _countof(szFull)) { s_dwLastError = ERROR_BUFFER_OVERFLOW; goto Done; } else { szFull[iEnd + iCur] = 0; } hMod = (lt_dlhandle)LoadLibraryA(szFull); } s_dwLastError = hMod ? 0 : GetLastError(); Done: return hMod; }
/* T1_CopyOutline(): Copy an outline physically. Returns a pointer to the path or NULL */ T1_OUTLINE *T1_CopyOutline( T1_OUTLINE *path) { return( (T1_OUTLINE *) CopyPath( (struct segment *)path)); }
int lt_dlforeachfile( const char *szSearchPath, int (*pfCallback)(const char *szFileName, lt_ptr pData), lt_ptr pData) { char szExePath[MAX_PATH]; char szOnePath[MAX_PATH]; int cErrors = 0; unsigned iSearchPath = 0; unsigned iOnePath; unsigned iExePath = 0; unsigned cchCopied; HANDLE hFind; WIN32_FIND_DATAA data; szExePath[0] = 0; if (pfCallback == 0) { s_dwLastError = ERROR_INVALID_PARAMETER; cErrors++; goto Done; } if (szSearchPath != 0) { while (1) { while (szSearchPath[iSearchPath] == LT_PATHSEP_CHAR) { iSearchPath++; } if (szSearchPath[iSearchPath] == 0) { s_dwLastError = 0; break; } if (szSearchPath[iSearchPath] == '.' && (szSearchPath[iSearchPath + 1] == '\\' || szSearchPath[iSearchPath + 1] == '/')) { if (szExePath[0] == 0) { iExePath = GetModuleFileNameA(0, szExePath, _countof(szExePath)); if (iExePath == 0) { s_dwLastError = GetLastError(); cErrors++; goto Done; } else if (iExePath == _countof(szExePath)) { s_dwLastError = ERROR_BUFFER_OVERFLOW; cErrors++; goto Done; } while (iExePath > 0 && szExePath[iExePath - 1] != '\\') { iExePath--; } if (iExePath > 0) { iExePath--; } szExePath[iExePath] = 0; } strcpy(szOnePath, szExePath); iOnePath = iExePath; iSearchPath++; } else { iOnePath = 0; } cchCopied = CopyPath( szSearchPath + iSearchPath, szOnePath + iOnePath, _countof(szOnePath) - iOnePath, LT_PATHSEP_CHAR); iSearchPath += cchCopied; iOnePath += cchCopied; if (0 < iOnePath && iOnePath + 1 < _countof(szOnePath) && szOnePath[iOnePath - 1] != '\\') { szOnePath[iOnePath++] = '\\'; } if (iOnePath + 1 >= _countof(szOnePath)) { s_dwLastError = ERROR_BUFFER_OVERFLOW; cErrors++; goto Done; } szOnePath[iOnePath++] = '*'; szOnePath[iOnePath] = 0; hFind = FindFirstFileA(szOnePath, &data); while (hFind != INVALID_HANDLE_VALUE) { if (0 == (data.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE | FILE_ATTRIBUTE_OFFLINE))) { cErrors = pfCallback(data.cFileName, pData); if (cErrors) { s_dwLastError = ERROR_CANCELLED; FindClose(hFind); goto Done; } } if (!FindNextFileA(hFind, &data)) { s_dwLastError = ERROR_SUCCESS; FindClose(hFind); hFind = INVALID_HANDLE_VALUE; } } } } Done: return cErrors; }
static int ReadTmBbs(char *pchFileName, char *TmBbsName, char *NetmailPath, USERDATAOPT *pUserData, PDRIVEREMAP pDriveRemap, PAREALIST pRetList, PDESCLIST pDescList) { char pchBBSName[LEN_USERNAME+1]; FILE *pfBBS; AREADEFOPT Area; if (NetmailPath[0]) AddNetmailArea(&Area, pchFileName, NetmailPath, pUserData, pRetList); if (TmBbsName[0] && TmBbsName[1] == ':') { /* voller Name */ strcpy(pchBBSName, TmBbsName); MSG_RemapDrive(pchBBSName, pDriveRemap); } else { /* Teil-Name */ CopyPath(pchBBSName, pchFileName); strcat(pchBBSName, "\\"); strcat(pchBBSName, TmBbsName); } pfBBS = fopen(pchBBSName, "r"); if (pfBBS) { char zeile[200]; char *pchTemp; while (!feof(pfBBS)) { if (fgets(zeile, sizeof(zeile), pfBBS)) { StripWhitespace(zeile); if (zeile[0] && zeile[0] != '@') { BOOL bNotValid = FALSE; memset(&Area, 0, sizeof(Area)); Area.areaformat = AREAFORMAT_FTS; /* Default */ Area.areatype = AREATYPE_ECHO; /* Default */ strcpy(Area.username, pUserData->username[0]); strcpy(Area.address, pUserData->address[0]); Area.ulAreaOpt = AREAOPT_FROMCFG; /* Pfad ermitteln */ pchTemp = strtok(zeile, " \t"); if (pchTemp) { if (pchTemp[0] && pchTemp[1] == ':') /* voller Pfad */ strncpy(Area.pathfile, pchTemp, LEN_PATHNAME); else { /* relativer pfad */ CopyPath(Area.pathfile, pchFileName); strcat(Area.pathfile, "\\"); strcat(Area.pathfile, pchTemp); Area.ulTempFlags = AREAFLAG_NOREMAP; } RemoveBackslash(Area.pathfile); if (pchTemp = strtok(NULL, " \t")) { PDESCLIST pDesc = pDescList; strncpy(Area.areatag, pchTemp, LEN_AREATAG); /* Description suchen */ while (pDesc && stricmp(pDesc->pchAreaTag, pchTemp)) pDesc = pDesc->next; if (pDesc) strcpy(Area.areadesc, pDesc->pchDesc); else strncpy(Area.areadesc, pchTemp, LEN_AREADESC); while (pchTemp = strtok(NULL, " \t")) { if (!stricmp(pchTemp, "JAM")) Area.areaformat = AREAFORMAT_JAM; else if (!stricmp(pchTemp, "HOLD")) Area.areatype = AREATYPE_LOCAL; else if (!stricmp(pchTemp, "QWK")) { bNotValid = TRUE; break; } } if (!bNotValid) AM_AddArea(pRetList, &Area, ADDAREA_TAIL | ADDAREA_UNIQUE); } } } } else if (ferror(pfBBS)) { fclose(pfBBS); return CFGFILE_READ; } } fclose(pfBBS); return CFGFILE_OK; } else return CFGFILE_OPEN; }