home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / fsrc1241.zip / init.c < prev    next >
C/C++ Source or Header  |  1999-01-16  |  147KB  |  4,471 lines

  1. /*---------------------------------------------------------------------------+
  2.  | Titel: INIT.C                                                             |
  3.  +-----------------------------------------+---------------------------------+
  4.  | Erstellt von: Michael Hohner            | Am: 19.06.93                    |
  5.  +-----------------------------------------+---------------------------------+
  6.  | System: OS/2 2.x                                                          |
  7.  +---------------------------------------------------------------------------+
  8.  | Beschreibung:                                                             |
  9.  |                                                                           |
  10.  |  Initialisierung von Fleet Street,                                        |
  11.  |  Area-Informationen                                                       |
  12.  |                                                                           |
  13.  +---------------------------------------------------------------------------+
  14.  | Moegl. Verbesserungen:                                                    |
  15.  |                                                                           |
  16.  |                                                                           |
  17.  +---------------------------------------------------------------------------+
  18.  | Bemerkungen:                                                              |
  19.  +---------------------------------------------------------------------------*/
  20.  
  21. /*----------------------------- Header-Dateien ------------------------------*/
  22. #pragma strings(readonly)
  23.  
  24. #define INCL_BASE
  25. #define INCL_PM
  26. #define INCL_GPI
  27. #define INCL_SPLDOSPRINT
  28. #include <os2.h>
  29. #include <string.h>
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include "main.h"
  33. #include "resids.h"
  34. #include "dialogids.h"
  35. #include "structs.h"
  36. #include "msgheader.h"
  37. #include "areaman\areaman.h"
  38. #include "areaman\folderman.h"
  39. #include "init.h"
  40. #include "utility.h"
  41. #include "msglist.h"
  42. #include "handlemsg\handlemsg.h"
  43. #include "ccmanage.h"
  44. #include "finddlg.h"
  45. #include "markmanage.h"
  46. #include "nlbrowser.h"
  47.  
  48. #include "cfgfile_interface.h"
  49.  
  50. #include "nickmanage.h"
  51. #include "echomanager.h"
  52. #include "templatedlg.h"
  53. #include "printsetup.h"
  54. #include "toolbarconfig.h"
  55. #include "request_manage.h"
  56. #include "dump\expt.h"
  57.  
  58. /*--------------------------------- Defines ---------------------------------*/
  59.  
  60. #define INIFILENAME      "FLTSTRT.INI"
  61. #define CCFILENAME       "CCLISTS.INI"
  62. #define AREAFILENAME     "AREAS.INI"
  63. #define DOMAINFILENAME   "DOMAINS.INI"
  64. #define TEMPLATEFILENAME "TEMPL.INI"
  65. #define SCRIPTFILENAME   "SCRIPTS.INI"
  66. #define NICKFILENAME     "NICKN.INI"
  67. #define FOLDERFILENAME   "FOLDERS.INI"
  68.  
  69. #define RGB_GREY      0x00cccccc
  70. #define RGB_DARKBLUE  0x00000080
  71. #define RGB_DARKGREEN 0x00008000
  72. #define SMA_FONT      "8.Helv"
  73. #define MID_FONT      "10.Helv"
  74. #define VIEW_FONT      "10.System Proportional"
  75. #define VIEW_FONT_MONO "10.System Monospaced"
  76. #define MAXLEN_STRING  1024
  77.  
  78. #define PROGVERSION "FleetStreet"
  79. #define INIVERSION  "0.680"
  80.  
  81. /* Alte Strukturen zum Konvertieren */
  82. #define O_INIVERSION13 "0.660"
  83. #define O_INIVERSION14 "0.661"
  84. #define O_INIVERSION15 "0.662"
  85. #define O_INIVERSION16 "0.670"
  86. #define O_INIVERSION17 "0.675"
  87. #define O_INIVERSION18 "0.676"
  88. #define O_INIVERSION19 "0.677"
  89. #define O_INIVERSION20 "0.678"
  90. #define O_INIVERSION21 "0.679"
  91. #define O_PROGVERSION  "Fleet Street 0.2b"
  92.  
  93. /*---------------------------- Globale Variablen ----------------------------*/
  94. extern AREALIST arealiste;
  95. extern USERDATAOPT userdaten;
  96. DIRTYFLAGS dirtyflags;
  97. extern HMODULE hmodLang;
  98.  
  99. static char pchIniPath[LEN_PATHNAME+1]="";
  100. PCFGDLL pCfgDLLs;
  101.  
  102. #pragma pack(1)
  103. typedef struct
  104. {
  105.    char usertag[LEN_USERNAME+1];
  106.    char username[LEN_USERNAME+1];
  107.    char address[LEN_5DADDRESS+1];
  108.    char subjectline[LEN_SUBJECT+1];
  109.    char firstline[LEN_FIRSTLINE+1];
  110.    UINT  private    :1;
  111.    UINT  crash      :1;
  112.    UINT  kill       :1;
  113.    UINT  attach     :1;
  114.    UINT  notemplate :1;
  115.    UINT  request    :1;
  116. } BOOKADDRESSOPT;
  117.  
  118. typedef struct
  119. {
  120.    char areatag[LEN_AREATAG+1];
  121.    char areadesc[LEN_AREADESC+1];
  122.    char address[LEN_5DADDRESS+1];
  123.    char username[LEN_USERNAME+1];
  124.    char pathfile[LEN_PATHNAME+1];
  125.    ULONG ulTemplateID;
  126.    SHORT areatype;
  127.    UINT  isechoarea      :1; /* Echo oder Net */
  128.    UINT  isexcluded      :1; /* exclude from reading */
  129.    UINT  isfromcfg       :1; /* stammt aus SQUISH.CFG */
  130.    UINT  islocal         :1; /* ist eine lokale Area */
  131.    UINT  defaultprivate  :1; /* Default-Message-Attribute */
  132.    UINT  defaultcrash    :1;
  133.    UINT  defaulthold     :1;
  134.    UINT  defaultkillsent :1;
  135.    UINT  separator       :1; /* Trennlinie */
  136.    UINT  eightbitascii   :1; /* Sonderzeichen erlaubt ? */
  137.    UINT  res1            :1; /* Reserved 1 */
  138. } OLD_AREADEFOPT;
  139. #pragma pack()
  140.  
  141. /*--------------------------- Funktionsprototypen ---------------------------*/
  142.  
  143. static int QueryIniDir(char *pchPath);
  144. int ReadIntlSetting(void);
  145. static ULONG ReadIniProfile(HAB hab);
  146. static ULONG InitAreas(HAB hab, char *CfgFileName, ULONG ReadCfg, ULONG ulCfgType);
  147. static ULONG ReadIniAreas(HAB hab);
  148. static void ImportNamesAndAddresses(USERDATAOPT *pSrc, USERDATAOPT *pDest);
  149. static int ReadIniUser(HINI inifile);
  150. static int SaveIniUser(HINI inifile);
  151. static int ReadIniNick(HAB hab);
  152. static int SaveIniNick(HAB hab);
  153. static int ReadIniWinPos(HINI inifile);
  154. static int SaveIniWinPos(HINI inifile);
  155. static int ReadIniWinCol(HINI inifile);
  156. static int SaveIniWinCol(HINI inifile);
  157. static int ReadIniFonts(HINI inifile);
  158. static int SaveIniFonts(HINI inifile);
  159. static int ReadIniPaths(HINI inifile);
  160. static int SaveIniPaths(HINI inifile);
  161. static int ReadIniMisc(HINI inifile);
  162. static int SaveIniMisc(HINI inifile);
  163. static int ReadIniMacros(HINI inifile);
  164. static int SaveIniMacros(HINI inifile);
  165. static int ReadIniGeneral(HINI inifile);
  166. static int SaveIniGeneral(HINI inifile);
  167. static int ReadIniNodelist(HINI inifile);
  168. static int SaveIniNodelist(HINI inifile);
  169. static int ReadIniEchotoss(HINI inifile);
  170. static int SaveIniEchotoss(HINI inifile);
  171. static int ReadIniDomains(HAB hab);
  172. static int SaveIniDomains(HAB hab);
  173. static int ReadIniCCLists(HAB hab);
  174. static int SaveIniCCLists(HAB hab);
  175. static int ReadIniCCEntries(HINI ccini, char *pchApp, PCCLIST pList);
  176. static int SaveIniCCEntries(HINI ccini, char *pchApp, PCCLIST pList);
  177. static int ReadIniThreadopt(HINI inifile);
  178. static int SaveIniThreadopt(HINI inifile);
  179. static int ReadIniLookup(HINI inifile);
  180. static int SaveIniLookup(HINI inifile);
  181. static int ReadIniResults(HINI inifile);
  182. static int SaveIniResults(HINI inifile);
  183. static int ReadIniRequest(HINI inifile);
  184. static int SaveIniRequest(HINI inifile);
  185. static int ReadIniAreaList(HINI inifile);
  186. static int SaveIniAreaList(HINI inifile);
  187. static int ReadIniMsgList(HINI inifile);
  188. static int SaveIniMsgList(HINI inifile);
  189. static int SaveIniRemap(HINI inifile);
  190. static int ReadIniRemap(HINI inifile);
  191. static int SaveIniHooks(HINI inifile);
  192. static int ReadIniHooks(HINI inifile);
  193. static int SaveIniScripts(HAB hab);
  194. static int ReadIniScripts(HAB hab);
  195.  
  196. static int ConvertProfile(HINI inifile, PCHAR pchThisVersion, HAB hab);
  197. static void CopyAreaData(AREADEFLIST *zeiger, AREADEFOPT *Area);
  198.  
  199. static int ReadIniTemplates(HAB hab);
  200. static int LoadEmptyTemplate(TEMPLATELIST *pTemplateList);
  201. static int SaveIniTemplates(HAB hab);
  202. static int ReadIniFind(HINI inifile);
  203. static int SaveIniFind(HINI inifile);
  204. static int ReadIniBrowse(HINI inifile);
  205. static int SaveIniBrowse(HINI inifile);
  206. static int ReadIniExport(HINI inifile);
  207. static int SaveIniExport(HINI inifile);
  208. static int ReadIniToolbar(HINI inifile);
  209. static int SaveIniToolbar(HINI inifile);
  210. static int ReadIniEchoman(HINI inifile);
  211. static int SaveIniEchoman(HINI inifile);
  212. static int ReadIniSearch(HINI inifile);
  213. static int SaveIniSearch(HINI inifile);
  214. static int ReadIniPrintSetup(HINI inifile);
  215. static int SaveIniPrintSetup(HINI inifile);
  216.  
  217. static int ReadIniFolders(HAB hab);
  218. static int SaveIniFolders(HAB hab);
  219. static int AddDefaultFolder(PFOLDERANCHOR pFolderAnchor);
  220.  
  221. static BOOL HaveAddress(char *pchAddress);
  222.  
  223.  
  224. /* Stub-Funktionen */
  225. static BOOL QueryProfileData(HINI hini, PSZ pszApp, PSZ pszKey, PVOID pBuffer, PULONG pulBufferMax);
  226. static LONG QueryProfileInt(HINI hini, PSZ pszApp, PSZ pszKey, LONG lDefault);
  227. static BOOL QueryProfileSize(HINI hini, PSZ pszApp, PSZ pszKey, PULONG pDataLen);
  228. static ULONG QueryProfileString(HINI hini, PSZ pszApp, PSZ pszKey, PSZ pszDefault, PVOID pBuffer,
  229.                                 ULONG cchBufferMax);
  230. static BOOL WriteProfileData(HINI hini, PSZ pszApp, PSZ pszKey, PVOID pBuffer, ULONG cchBufferMax);
  231. static BOOL WriteProfileString(HINI hini, PSZ pszApp, PSZ pszKey, PSZ pszData);
  232. static BOOL WriteProfileInt(HINI hini, PSZ pszApp, PSZ pszKey, LONG lData);
  233.  
  234. /* Fehler */
  235. static ULONG ProfileErrorMessage(HWND hwndOwner, ULONG ErrorType);
  236. static ULONG CFGFileErrorMessage(HWND hwndOwner, ULONG ErrorType);
  237. static ULONG CFGDLLErrorMessage(HWND hwndOwner, ULONG ErrorType);
  238.  
  239. /*------------------------------ ReadIniThread ------------------------------*/
  240. /* Thread-Funktion, die die INIs liesst. Beim Ende wird eine Ende-Message    */
  241. /* mit dem Ergebnis an die Queue gepostet (Thread-Parameter).                */
  242. /*---------------------------------------------------------------------------*/
  243.  
  244. void _Optlink ReadIniThread(void *phev)
  245. {
  246.    extern PATHNAMES pathnames;
  247.    extern int CurrentStatus;
  248.    extern MISCOPTIONS miscoptions;
  249.    extern ULONG ProfileError;
  250.    extern MARKERLIST MarkerList;
  251.    HAB hab;
  252.  
  253.    INSTALLEXPT("ReadINI");
  254.  
  255.    hab = WinInitialize(0);
  256.  
  257.    QueryIniDir(pchIniPath);
  258.  
  259.    pCfgDLLs = CFG_ReadFormatList();
  260.  
  261.    if (!(ProfileError=ReadIniProfile(hab)))
  262.    {
  263.       if (userdaten.address[0][0] && userdaten.username[0][0])
  264.          CurrentStatus=PROGSTATUS_READING;
  265.  
  266.       /* Areas lesen */
  267.       if (miscoptions.readcfg && pathnames.squishcfg[0])
  268.          ProfileError = InitAreas(hab, pathnames.squishcfg,
  269.                         READCFG_BOTH, miscoptions.ulCfgType);
  270.       else
  271.          ProfileError = InitAreas(hab, pathnames.squishcfg,
  272.                         READCFG_INI, miscoptions.ulCfgType);
  273.  
  274.       CheckMarkerAreas(&MarkerList);
  275.    }
  276.  
  277.    DosPostEventSem(*((PHEV)phev));
  278.  
  279.    WinTerminate(hab);
  280.  
  281.    DEINSTALLEXPT;
  282.  
  283.    return;
  284. }
  285.  
  286. static int QueryIniDir(char *pchPath)
  287. {
  288.    ULONG ulDrive, ulMap;
  289.    char pchTemp[LEN_PATHNAME+1];
  290.    ULONG ulLen = LEN_PATHNAME+1;
  291.  
  292.    if (!pchPath[0])
  293.    {
  294.       strcpy(pchPath, "C:\\");
  295.       DosQueryCurrentDisk(&ulDrive, &ulMap);
  296.       *pchPath = (char) ulDrive + '@';
  297.  
  298.       DosQueryCurrentDir(0, pchTemp, &ulLen);
  299.       strcat(pchPath, pchTemp);
  300.       strcat(pchPath, "\\");
  301.    }
  302.  
  303.    return 0;
  304. }
  305.  
  306. int ParseArgs(int argc, char **argv)
  307. {
  308.    int i;
  309.    int len;
  310.  
  311.    for (i=1; i<argc; i++)
  312.       if (argv[i][0] == '-')
  313.          switch(argv[i][1])
  314.          {
  315.             case 'c':
  316.             case 'C':
  317.                strcpy(pchIniPath, &argv[i][2]);
  318.                len = strlen(pchIniPath);
  319.                if (len && pchIniPath[len-1] != '\\')
  320.                   strcat(pchIniPath, "\\");
  321.                break;
  322.  
  323.             default:
  324.                return 1;
  325.          }
  326.  
  327.    return 0;
  328. }
  329.  
  330.  
  331. /*------------------------------ InitAreas ----------------------------------*/
  332. /* InitAreas, liesst Area-Informationen aus der SQUISH.CFG und aus dem       */
  333. /* INI-File, baut die Area-Liste auf.                                        */
  334. /* Rueckgabewerte: LSB SHORT: Fehlercode des CFG-Files                       */
  335. /*                 MSB SHORT: Fehlercode des INI-Files                       */
  336. /*---------------------------------------------------------------------------*/
  337.  
  338. static ULONG InitAreas(HAB hab, char *CfgFileName, ULONG ReadCfg, ULONG ulCfgType)
  339. {
  340.    ULONG RetValue=0;
  341.    extern DRIVEREMAP driveremap;
  342.    extern OUTBOUND outbound[MAX_ADDRESSES];
  343.    PCFGDLL pFormatDLL;
  344.    USERDATAOPT CfgUser;
  345.  
  346.    if (ReadCfg & READCFG_CFG)
  347.    {
  348.       pFormatDLL = CFG_FindFormat(pCfgDLLs, ulCfgType, NULL);
  349.  
  350.       if (pFormatDLL)
  351.       {
  352.          LOADEDCFGDLL LoadedDLL;
  353.  
  354.          if (!(RetValue = CFG_LoadDLL(pFormatDLL->pchDLLName, &LoadedDLL)))
  355.          {
  356.             memset(&CfgUser, 0, sizeof(CfgUser));
  357.             strcpy(CfgUser.username[0], userdaten.username[0]);
  358.  
  359.             RetValue = LoadedDLL.ReadCfgFile(CfgFileName, &CfgUser, outbound, &arealiste, &driveremap, READCFG_ALL);
  360.  
  361.             if (RetValue)
  362.                RetValue = CFGFILEERROR(RetValue);
  363.  
  364.             DosFreeModule(LoadedDLL.hmodCfgDLL);
  365.  
  366.             ImportNamesAndAddresses(&CfgUser, &userdaten);
  367.          }
  368.          else
  369.             return CFGDLLERROR(RetValue);
  370.       }
  371.       else
  372.          return CFGDLLERROR(LOADCFGDLL_UNSUPPFORMAT);
  373.  
  374.    }
  375.  
  376.    if (!RetValue && (ReadCfg & READCFG_INI))
  377.       RetValue = ReadIniAreas(hab);
  378.  
  379.    return RetValue;
  380. }
  381.  
  382. static void ImportNamesAndAddresses(USERDATAOPT *pSrc, USERDATAOPT *pDest)
  383. {
  384.    int i=0;
  385.    int j;
  386.  
  387.    /* Namen */
  388.    while (i < MAX_USERNAMES && pSrc->username[i][0])
  389.    {
  390.       j=0;
  391.  
  392.       while (j < MAX_USERNAMES &&
  393.              pDest->username[j][0] &&
  394.              strcmp(pSrc->username[i], pDest->username[j]))
  395.          j++;
  396.  
  397.       if (j < MAX_USERNAMES && !pDest->username[j][0])
  398.          strcpy(pDest->username[j], pSrc->username[i]);
  399.  
  400.       i++;
  401.    }
  402.  
  403.    /* Adressen */
  404.    i=0;
  405.    while (i < MAX_ADDRESSES && pSrc->address[i][0])
  406.    {
  407.       j=0;
  408.  
  409.       while (j < MAX_ADDRESSES &&
  410.              pDest->address[j][0] &&
  411.              strcmp(pSrc->address[i], pDest->address[j]))
  412.          j++;
  413.  
  414.       if (j < MAX_ADDRESSES && !pDest->address[j][0])
  415.          strcpy(pDest->address[j], pSrc->address[i]);
  416.  
  417.       i++;
  418.    }
  419.  
  420.    /* Origin */
  421.    if (!pDest->defaultorigin[0])
  422.       strcpy(pDest->defaultorigin, pSrc->defaultorigin);
  423.  
  424.    return;
  425. }
  426.  
  427. /*----------------------------- ReReadAreas ---------------------------------*/
  428. /* Liesst die Areas bei einem SQUISH.CFG-Wechsel neu ein.                    */
  429. /* Rueckgabewerte: 0 kein Fehler                                             */
  430. /*                 1 Fehler beim Einlesen                                    */
  431. /*                 2 Areas nicht eindeutig                                   */
  432. /*---------------------------------------------------------------------------*/
  433.  
  434. ULONG ReReadAreas(HAB hab, char *CfgFileName, ULONG ulCfgType)
  435. {
  436.    AREADEFLIST *zeiger=NULL;
  437.    AREADEFLIST *zeiger2=NULL;
  438.    AREALIST saveareas;
  439.    AREALIST privareas;
  440.    AREADEFLIST *pPriv;
  441.    ULONG rc;
  442.  
  443.    /* alte Areas retten */
  444.    saveareas=arealiste;
  445.  
  446.    memset(&arealiste, 0, sizeof(arealiste));
  447.    if (rc= InitAreas(hab, CfgFileName, READCFG_CFG, ulCfgType))
  448.    {
  449.       /* Fehler beim Einlesen */
  450.       AM_DeleteAllAreas(&arealiste);
  451.       arealiste=saveareas;
  452.       return rc;
  453.    }
  454.    else
  455.    {
  456.       /* ohne Fehler */
  457.       privareas=saveareas;
  458.  
  459.       /* private areas suchen */
  460.       pPriv = privareas.pFirstArea;
  461.       while(pPriv && (pPriv->areadata.ulAreaOpt & AREAOPT_FROMCFG))
  462.          pPriv=pPriv->next;
  463.       privareas.pFirstArea = pPriv;
  464.  
  465.       if (pPriv)
  466.       {
  467.          /* Duplikate suchen */
  468.          zeiger=arealiste.pFirstArea;
  469.          while (zeiger)
  470.          {
  471.             if (AM_FindArea(&privareas, zeiger->areadata.areatag))
  472.             {
  473.                /* Area doppelt */
  474.                AM_DeleteAllAreas(&arealiste);
  475.                arealiste=saveareas;
  476.  
  477.                return INIERROR(INIFILE_DUPAREAS);
  478.             }
  479.             zeiger=zeiger->next;
  480.          }
  481.       }
  482.  
  483.       /* ohne Fehler */
  484.       /* Areadaten abgleichen */
  485.       zeiger=arealiste.pFirstArea;
  486.       while(zeiger)
  487.       {
  488.          zeiger2=AM_FindArea(&saveareas, zeiger->areadata.areatag);
  489.          if (zeiger2)
  490.          {
  491.             /* alte Daten übernehmen */
  492.             strcpy(zeiger->areadata.areadesc, zeiger2->areadata.areadesc);
  493.             strcpy(zeiger->areadata.username, zeiger2->areadata.username);
  494.             zeiger->areadata.ulTemplateID= zeiger2->areadata.ulTemplateID;
  495.             zeiger->areadata.ulFolderID= zeiger2->areadata.ulFolderID;
  496.             zeiger->areadata.ulAreaOpt &= AREAOPT_FROMCFG;
  497.             zeiger->areadata.ulAreaOpt |= (zeiger2->areadata.ulAreaOpt & ~AREAOPT_FROMCFG);
  498.             zeiger->areadata.ulDefAttrib= zeiger2->areadata.ulDefAttrib;
  499.             zeiger->areadata.ulTempFlags= zeiger2->areadata.ulTempFlags;
  500.             zeiger->areadata.areaformat= zeiger2->areadata.areaformat;
  501.             zeiger->areadata.areatype= zeiger2->areadata.areatype;
  502.  
  503.             zeiger->dirty=TRUE;
  504.             zeiger->flWork= WORK_NOTHING;
  505.             zeiger->bLocked= FALSE;
  506.          }
  507.          zeiger=zeiger->next;
  508.       }
  509.  
  510.       /* alte CFG-Areas loeschen */
  511.       while (saveareas.pFirstArea)
  512.       {
  513.          zeiger=saveareas.pFirstArea;
  514.  
  515.          while(zeiger && !(zeiger->areadata.ulAreaOpt & AREAOPT_FROMCFG))
  516.             zeiger = zeiger->next;
  517.          if (zeiger)
  518.             AM_DeleteAreaDirect(&saveareas, zeiger);
  519.          else
  520.             break;
  521.       }
  522.  
  523.       /* alte Liste anhaengen */
  524.       AM_MergeAreas(&arealiste, &saveareas);
  525.  
  526.       arealiste.bDirty = TRUE;
  527.  
  528.       return INIERROR(INIFILE_OK);
  529.    }
  530. }
  531.  
  532. /*------------------------------ ReadIniAreas -------------------------------*/
  533. /* Liesst die Areainformationen aus dem INI-File, fuegt evtl. die Areas hinzu*/
  534. /*---------------------------------------------------------------------------*/
  535.  
  536. static ULONG ReadIniAreas(HAB hab)
  537. {
  538.    HINI inifile;
  539.    char *pchKeys;             /* alle Keys */
  540.    ULONG ulKeysLen;           /* Platz fuer die Keys */
  541.    char *pchCurrentKey;       /* Aktueller Key */
  542.    AREADEFLIST *zeiger;       /* Hilfszeiger */
  543.    AREADEFOPT Area;
  544.    ULONG ulDataLen;
  545.    char pchIniFile[LEN_PATHNAME+1];
  546.    BOOL bMarkDirty = FALSE;
  547.    extern FOLDERANCHOR FolderAnchor;
  548.  
  549.    strcpy(pchIniFile, pchIniPath);
  550.    strcat(pchIniFile, AREAFILENAME);
  551.  
  552.    if (!(inifile=PrfOpenProfile(hab, pchIniFile)))
  553.       return INIERROR(INIFILE_OPEN);
  554.  
  555.    if (!QueryProfileSize(inifile, NULL, NULL, &ulKeysLen) || (ulKeysLen==0))
  556.    {
  557.       PrfCloseProfile(inifile);
  558.       return 0; /* INIERROR(INIFILE_OPEN); nicht ausgeben, da auch
  559.                                            bei leerem File */
  560.    }
  561.  
  562.    pchKeys=malloc(ulKeysLen);
  563.  
  564.    if (!QueryProfileData(inifile, NULL, NULL, pchKeys, &ulKeysLen))
  565.    {
  566.       free(pchKeys);
  567.       PrfCloseProfile(inifile);
  568.       return INIERROR(INIFILE_OPEN);
  569.    }
  570.  
  571.    pchCurrentKey=pchKeys;
  572.  
  573.    while (*pchCurrentKey)
  574.    {
  575.       /* Areadaten lesen */
  576.       memset(&Area, 0, sizeof(Area));
  577.  
  578.       strcpy(Area.areatag, pchCurrentKey);
  579.       QueryProfileString(inifile, pchCurrentKey, "Desc", NULL, Area.areadesc, LEN_AREADESC+1);
  580.       QueryProfileString(inifile, pchCurrentKey, "Name", NULL, Area.username, LEN_USERNAME+1);
  581.  
  582.       ulDataLen=sizeof(ULONG);
  583.       QueryProfileData(inifile, pchCurrentKey, "Template", &Area.ulTemplateID, &ulDataLen);
  584.  
  585.       ulDataLen=sizeof(ULONG);
  586.       QueryProfileData(inifile, pchCurrentKey, "Options", &Area.ulAreaOpt, &ulDataLen);
  587.       ulDataLen=sizeof(ULONG);
  588.       QueryProfileData(inifile, pchCurrentKey, "Attrib", &Area.ulDefAttrib, &ulDataLen);
  589.  
  590.       QueryProfileString(inifile, pchCurrentKey, "Address", NULL, Area.address, LEN_5DADDRESS+1);
  591.  
  592.       Area.ulFolderID = QueryProfileInt(inifile, pchCurrentKey, "Folder", 0);
  593.  
  594.       if (!FM_FindFolder(&FolderAnchor, Area.ulFolderID))
  595.          /* folder gibt's nicht mehr, in den root-Folder */
  596.          Area.ulFolderID = 0;
  597.  
  598.       if (!(Area.ulAreaOpt & AREAOPT_FROMCFG))
  599.       {
  600.          ulDataLen=sizeof(USHORT);
  601.          QueryProfileData(inifile, pchCurrentKey, "Format", &Area.areaformat, &ulDataLen);
  602.          ulDataLen=sizeof(Area.areatype);
  603.          Area.areatype = AREATYPE_LOCAL;
  604.          QueryProfileData(inifile, pchCurrentKey, "Type", &Area.areatype, &ulDataLen);
  605.          QueryProfileString(inifile, pchCurrentKey, "Path", NULL, Area.pathfile, LEN_PATHNAME+1);
  606.       }
  607.  
  608.       /* prüfen ob Adresse noch im Setup */
  609.       if (!HaveAddress(Area.address))
  610.       {
  611.          /* nicht mehr da, Default nehmen */
  612.          strcpy(Area.address, userdaten.address[0]);
  613.          bMarkDirty = TRUE;
  614.       }
  615.       else
  616.          bMarkDirty = FALSE;
  617.  
  618.       /* Area suchen */
  619.       zeiger=AM_FindArea(&arealiste, Area.areatag);
  620.  
  621.       if (zeiger)
  622.       {
  623.          /* Area gefunden */
  624.          /* Daten uebernehmen */
  625.          CopyAreaData(zeiger, &Area);
  626.          if (bMarkDirty)
  627.             zeiger->dirty = TRUE;
  628.       }
  629.       else
  630.       {
  631.          /* Area nicht gefunden */
  632.          if (!(Area.ulAreaOpt & AREAOPT_FROMCFG))     /* Eintrag aus alter CFG, verwerfen */
  633.          {
  634.             /* Eintrag hinzufuegen */
  635.             AM_AddArea(&arealiste, &Area, ADDAREA_TAIL | (bMarkDirty ? ADDAREA_MARKDIRTY : 0));
  636.          }
  637.       }
  638.       /* Naechsten Key suchen */
  639.       while (*pchCurrentKey)
  640.          pchCurrentKey++;
  641.       pchCurrentKey++;
  642.    }
  643.    free(pchKeys);
  644.    PrfCloseProfile(inifile);
  645.  
  646.    return 0;
  647. }
  648.  
  649. static BOOL HaveAddress(char *pchAddress)
  650. {
  651.    int i=0;
  652.  
  653.    while (i<MAX_ADDRESSES &&
  654.           strcmp(userdaten.address[i], pchAddress))
  655.       i++;
  656.    if (i<MAX_ADDRESSES)
  657.       return TRUE;
  658.    else
  659.       return FALSE;
  660. }
  661.  
  662. /*------------------------------ CopyAreaData -------------------------------*/
  663. /* Kopiert die Area-Informationen in ein Listenelement                       */
  664. /*---------------------------------------------------------------------------*/
  665.  
  666. static  void CopyAreaData(AREADEFLIST *zeiger, AREADEFOPT *Area)
  667. {
  668.    strcpy(zeiger->areadata.areadesc, Area->areadesc);
  669.    strcpy(zeiger->areadata.username, Area->username);
  670.    if (Area->address[0])
  671.       strcpy(zeiger->areadata.address, Area->address);
  672.    zeiger->areadata.ulTemplateID=Area->ulTemplateID;
  673.    zeiger->areadata.ulFolderID=Area->ulFolderID;
  674.    zeiger->areadata.ulAreaOpt &= AREAOPT_FROMCFG;
  675.    zeiger->areadata.ulAreaOpt |= (Area->ulAreaOpt & ~AREAOPT_FROMCFG);
  676.    zeiger->areadata.ulDefAttrib=Area->ulDefAttrib;
  677.    zeiger->areadata.ulTempFlags=Area->ulTempFlags;
  678.  
  679.    return;
  680. }
  681.  
  682. /*------------------------------ SaveIniAreas -------------------------------*/
  683. /* Speichert die Areainformationen in dem INI-File                           */
  684. /*---------------------------------------------------------------------------*/
  685.  
  686. int SaveIniAreas(HAB hab)
  687. {
  688.    HINI inifile;
  689.    AREADEFLIST *zeiger;       /* Hilfszeiger */
  690.    char *pchKeys;             /* alle Keys */
  691.    ULONG ulKeysLen;           /* Platz fuer die Keys */
  692.    char *pchCurrentKey;       /* Aktueller Key */
  693.    char pchIniFile[LEN_PATHNAME+1];
  694.  
  695.    strcpy(pchIniFile, pchIniPath);
  696.    strcat(pchIniFile, AREAFILENAME);
  697.  
  698.    if (!(inifile=PrfOpenProfile(hab, pchIniFile)))
  699.       return 1;
  700.  
  701.    zeiger=arealiste.pFirstArea;
  702.  
  703.    while (zeiger)
  704.    {
  705.       if (zeiger->dirty)
  706.       {
  707.          WriteProfileString(inifile, zeiger->areadata.areatag, "Desc", zeiger->areadata.areadesc);
  708.          WriteProfileString(inifile, zeiger->areadata.areatag, "Name", zeiger->areadata.username);
  709.          WriteProfileData(inifile, zeiger->areadata.areatag, "Template", &(zeiger->areadata.ulTemplateID),
  710.                              sizeof(ULONG));
  711.          WriteProfileData(inifile, zeiger->areadata.areatag, "Options", &(zeiger->areadata.ulAreaOpt),
  712.                              sizeof(ULONG));
  713.          WriteProfileData(inifile, zeiger->areadata.areatag, "Attrib", &(zeiger->areadata.ulDefAttrib),
  714.                              sizeof(ULONG));
  715.          WriteProfileString(inifile, zeiger->areadata.areatag, "Address", zeiger->areadata.address);
  716.          if (zeiger->areadata.ulFolderID)
  717.             WriteProfileInt(inifile, zeiger->areadata.areatag, "Folder", zeiger->areadata.ulFolderID);
  718.          else
  719.             WriteProfileString(inifile, zeiger->areadata.areatag, "Folder", NULL);
  720.          if (!(zeiger->areadata.ulAreaOpt & AREAOPT_FROMCFG))
  721.          {
  722.             WriteProfileData(inifile, zeiger->areadata.areatag, "Format", &(zeiger->areadata.areaformat),
  723.                              sizeof(USHORT));
  724.             WriteProfileData(inifile, zeiger->areadata.areatag, "Type", &(zeiger->areadata.areatype),
  725.                              sizeof(zeiger->areadata.areatype));
  726.             WriteProfileString(inifile, zeiger->areadata.areatag, "Path", zeiger->areadata.pathfile);
  727.          }
  728.  
  729.          zeiger->dirty=FALSE;
  730.       }
  731.       zeiger=zeiger->next;
  732.    }
  733.  
  734.    /* ueberfluessige Areas im INI loeschen */
  735.    if (!QueryProfileSize(inifile, NULL, NULL, &ulKeysLen) || (ulKeysLen==0))
  736.    {
  737.       PrfCloseProfile(inifile);
  738.       return 1;
  739.    }
  740.  
  741.    pchKeys=malloc(ulKeysLen);
  742.  
  743.    if (!QueryProfileData(inifile, NULL, NULL, pchKeys, &ulKeysLen))
  744.    {
  745.       free(pchKeys);
  746.       PrfCloseProfile(inifile);
  747.       return 1;
  748.    }
  749.  
  750.    pchCurrentKey=pchKeys;
  751.  
  752.    while (*pchCurrentKey)
  753.    {
  754.       zeiger=arealiste.pFirstArea;
  755.  
  756.       /* Case-Sensitive suchen */
  757.       while (zeiger && strcmp(pchCurrentKey, zeiger->areadata.areatag))
  758.          zeiger = zeiger->next;
  759.       if (!zeiger)
  760.          WriteProfileData(inifile, pchCurrentKey, NULL, NULL, 0);
  761.  
  762.       while (*pchCurrentKey)
  763.          pchCurrentKey++;
  764.       pchCurrentKey++;
  765.    }
  766.    free(pchKeys);
  767.  
  768.    PrfCloseProfile(inifile);
  769.  
  770.    arealiste.bDirty = FALSE;
  771.  
  772.    return 0;
  773. }
  774.  
  775. /*------------------------------ ReadIniTemplates ---------------------------*/
  776. /* Liesst die Templates aus dem INI-File                                     */
  777. /*---------------------------------------------------------------------------*/
  778.  
  779. static  int ReadIniTemplates(HAB hab)
  780. {
  781.    extern TEMPLATELIST templatelist;
  782.    HINI inifile;
  783.    char *pchKeys;             /* alle Keys */
  784.    ULONG ulKeysLen;           /* Platz fuer die Keys */
  785.    char *pchCurrentKey;       /* Aktueller Key */
  786.    ULONG ulDataLen;
  787.    ULONG datalen;
  788.    PMSGTEMPLATE pNewTemplate, pTemplate=NULL;
  789.    char pchIniFile[LEN_PATHNAME+1];
  790.  
  791.    strcpy(pchIniFile, pchIniPath);
  792.    strcat(pchIniFile, TEMPLATEFILENAME);
  793.  
  794.    memset(&templatelist, 0, sizeof(TEMPLATELIST));
  795.  
  796.    if (!(inifile=PrfOpenProfile(hab, pchIniFile)))
  797.    {
  798.       LoadEmptyTemplate(&templatelist);
  799.       return 1;
  800.    }
  801.  
  802.    if (!QueryProfileSize(inifile, NULL, NULL, &ulKeysLen) || (ulKeysLen==0))
  803.    {
  804.       PrfCloseProfile(inifile);
  805.       LoadEmptyTemplate(&templatelist);
  806.       return 1;
  807.    }
  808.  
  809.    pchKeys=malloc(ulKeysLen);
  810.  
  811.    if (!QueryProfileData(inifile, NULL, NULL, pchKeys, &ulKeysLen))
  812.    {
  813.       free(pchKeys);
  814.       PrfCloseProfile(inifile);
  815.       LoadEmptyTemplate(&templatelist);
  816.       return 1;
  817.    }
  818.  
  819.    pchCurrentKey=pchKeys;
  820.  
  821.    while (*pchCurrentKey)
  822.    {
  823.       if (!strcmp(pchCurrentKey, "Pos"))
  824.       {
  825.          /* Folder-Position */
  826.          ulDataLen = sizeof(templatelist.FolderPos);
  827.          QueryProfileData(inifile, "Pos", "Pos", &templatelist.FolderPos, &ulDataLen);
  828.          ulDataLen = sizeof(templatelist.ulFlags);
  829.          QueryProfileData(inifile, "Pos", "Flags", &templatelist.ulFlags, &ulDataLen);
  830.       }
  831.       else
  832.       {
  833.          /* neues Template */
  834.          pNewTemplate = malloc(sizeof(MSGTEMPLATE));
  835.          memset(pNewTemplate, 0, sizeof(MSGTEMPLATE));
  836.  
  837.          /* hinten anhaengen */
  838.          if (pTemplate)
  839.          {
  840.             pTemplate->next = pNewTemplate;
  841.             pNewTemplate->prev = pTemplate;
  842.          }
  843.          else
  844.          {
  845.             /* erstes Template */
  846.             templatelist.pTemplates = pNewTemplate;
  847.          }
  848.          pTemplate = pNewTemplate;
  849.          templatelist.ulNumTemplates++;
  850.  
  851.          /* Key ist ID, umwandeln */
  852.          pNewTemplate->ulID = strtoul(pchCurrentKey, NULL, 10);
  853.  
  854.          /* restliche Daten */
  855.          datalen=sizeof(pNewTemplate->TPos);
  856.          if (!inifile || !QueryProfileData(inifile, pchCurrentKey, "Pos",
  857.                                               &pNewTemplate->TPos, &datalen))
  858.          {
  859.             memset(&pNewTemplate->TPos, 0, sizeof(pNewTemplate->TPos));
  860.             pNewTemplate->bDirty = TRUE;
  861.             templatelist.bDirty=TRUE;
  862.          }
  863.  
  864.          datalen=sizeof(pNewTemplate->quotelinelen);
  865.          if (!inifile || !QueryProfileData(inifile, pchCurrentKey, "Linelen",
  866.                                               &pNewTemplate->quotelinelen, &datalen))
  867.          {
  868.             pNewTemplate->quotelinelen=75;
  869.             pNewTemplate->bDirty = TRUE;
  870.             templatelist.bDirty=TRUE;
  871.          }
  872.  
  873.          datalen=sizeof(pNewTemplate->joinlen);
  874.          if (!inifile || !QueryProfileData(inifile, pchCurrentKey, "Joinlen",
  875.                                               &pNewTemplate->joinlen, &datalen))
  876.          {
  877.             pNewTemplate->joinlen=65;
  878.             pNewTemplate->bDirty = TRUE;
  879.             templatelist.bDirty=TRUE;
  880.          }
  881.  
  882.          datalen=sizeof(pNewTemplate->useinitials);
  883.          if (!inifile || !QueryProfileData(inifile, pchCurrentKey, "UseInitials",
  884.                                               &pNewTemplate->useinitials, &datalen))
  885.          {
  886.             pNewTemplate->useinitials=TRUE;
  887.             pNewTemplate->bDirty = TRUE;
  888.             templatelist.bDirty=TRUE;
  889.          }
  890.  
  891.          datalen=sizeof(pNewTemplate->forwardfirst);
  892.          if (!inifile || !QueryProfileData(inifile, pchCurrentKey, "ForwardOrder",
  893.                                               &pNewTemplate->forwardfirst, &datalen))
  894.          {
  895.             pNewTemplate->forwardfirst=FALSE;
  896.             pNewTemplate->bDirty = TRUE;
  897.             templatelist.bDirty=TRUE;
  898.          }
  899.  
  900.          datalen=sizeof(pNewTemplate->randomorigin);
  901.          if (!inifile || !QueryProfileData(inifile, pchCurrentKey, "Random",
  902.                                               &pNewTemplate->randomorigin, &datalen))
  903.          {
  904.             pNewTemplate->randomorigin=FALSE;
  905.             pNewTemplate->bDirty = TRUE;
  906.             templatelist.bDirty=TRUE;
  907.          }
  908.  
  909.          if (!inifile || !QueryProfileSize(inifile, pchCurrentKey, "Name", &datalen) ||
  910.              datalen==0)
  911.          {
  912.             datalen=MAXLEN_STRING;
  913.             pNewTemplate->TName=malloc(datalen);
  914.             LoadString(IDST_TPL_DEFNAME, datalen, pNewTemplate->TName);
  915.             pNewTemplate->bDirty = TRUE;
  916.             templatelist.bDirty=TRUE;
  917.          }
  918.          else
  919.          {
  920.             pNewTemplate->TName=malloc(datalen);
  921.             QueryProfileString(inifile, pchCurrentKey, "Name", NULL, pNewTemplate->TName,
  922.                                   datalen);
  923.          }
  924.  
  925.          if (!inifile || !QueryProfileSize(inifile, pchCurrentKey, "Header", &datalen) ||
  926.              datalen==0)
  927.          {
  928.             datalen=MAXLEN_STRING;
  929.             pNewTemplate->THeader=malloc(datalen);
  930.             LoadString(IDST_TPL_HEADER, datalen, pNewTemplate->THeader);
  931.             pNewTemplate->bDirty = TRUE;
  932.             templatelist.bDirty=TRUE;
  933.          }
  934.          else
  935.          {
  936.             pNewTemplate->THeader=malloc(datalen);
  937.             QueryProfileString(inifile, pchCurrentKey, "Header", NULL, pNewTemplate->THeader,
  938.                                   datalen);
  939.          }
  940.  
  941.          if (!inifile || !QueryProfileSize(inifile, pchCurrentKey, "Footer", &datalen) ||
  942.              datalen==0)
  943.          {
  944.             datalen=MAXLEN_STRING;
  945.             pNewTemplate->TFooter=malloc(datalen);
  946.             LoadString(IDST_TPL_FOOTER, datalen, pNewTemplate->TFooter);
  947.             pNewTemplate->bDirty = TRUE;
  948.             templatelist.bDirty=TRUE;
  949.          }
  950.          else
  951.          {
  952.             pNewTemplate->TFooter=malloc(datalen);
  953.             QueryProfileString(inifile, pchCurrentKey, "Footer", NULL, pNewTemplate->TFooter,
  954.                                   datalen);
  955.          }
  956.  
  957.          if (!inifile || !QueryProfileSize(inifile, pchCurrentKey, "Reply", &datalen) ||
  958.              datalen==0)
  959.          {
  960.             datalen=MAXLEN_STRING;
  961.             pNewTemplate->TReply=malloc(datalen);
  962.             LoadString(IDST_TPL_REPLY, datalen, pNewTemplate->TReply);
  963.             pNewTemplate->bDirty = TRUE;
  964.             templatelist.bDirty=TRUE;
  965.          }
  966.          else
  967.          {
  968.             pNewTemplate->TReply=malloc(datalen);
  969.             QueryProfileString(inifile, pchCurrentKey, "Reply", NULL, pNewTemplate->TReply,
  970.                                   datalen);
  971.          }
  972.  
  973.          if (!inifile || !QueryProfileSize(inifile, pchCurrentKey, "DArea", &datalen) ||
  974.              datalen==0)
  975.          {
  976.             datalen=MAXLEN_STRING;
  977.             pNewTemplate->TDArea=malloc(datalen);
  978.             LoadString(IDST_TPL_DAREA, datalen, pNewTemplate->TDArea);
  979.             pNewTemplate->bDirty = TRUE;
  980.             templatelist.bDirty=TRUE;
  981.          }
  982.          else
  983.          {
  984.             pNewTemplate->TDArea=malloc(datalen);
  985.             QueryProfileString(inifile, pchCurrentKey, "DArea", NULL, pNewTemplate->TDArea,
  986.                                   datalen);
  987.          }
  988.  
  989.          if (!inifile || !QueryProfileSize(inifile, pchCurrentKey, "Forward", &datalen) ||
  990.              datalen==0)
  991.          {
  992.             datalen=MAXLEN_STRING;
  993.             pNewTemplate->TForward=malloc(datalen);
  994.             LoadString(IDST_TPL_FORWARD, datalen, pNewTemplate->TForward);
  995.             pNewTemplate->bDirty = TRUE;
  996.             templatelist.bDirty=TRUE;
  997.          }
  998.          else
  999.          {
  1000.             pNewTemplate->TForward=malloc(datalen);
  1001.             QueryProfileString(inifile, pchCurrentKey, "Forward", NULL, pNewTemplate->TForward,
  1002.                                   datalen);
  1003.          }
  1004.  
  1005.          if (!inifile || !QueryProfileSize(inifile, pchCurrentKey, "ForwardFooter", &datalen) ||
  1006.              datalen==0)
  1007.          {
  1008.             datalen=MAXLEN_STRING;
  1009.             pNewTemplate->TForwardFooter=malloc(datalen);
  1010.             LoadString(IDST_TPL_FORWARDFOOTER, datalen, pNewTemplate->TForwardFooter);
  1011.             pNewTemplate->bDirty = TRUE;
  1012.             templatelist.bDirty=TRUE;
  1013.          }
  1014.          else
  1015.          {
  1016.             pNewTemplate->TForwardFooter=malloc(datalen);
  1017.             QueryProfileString(inifile, pchCurrentKey, "ForwardFooter", NULL, pNewTemplate->TForwardFooter,
  1018.                                   datalen);
  1019.          }
  1020.  
  1021.          if (!inifile || !QueryProfileSize(inifile, pchCurrentKey, "XPost", &datalen) ||
  1022.              datalen==0)
  1023.          {
  1024.             datalen=MAXLEN_STRING;
  1025.             pNewTemplate->TXPost=malloc(datalen);
  1026.             LoadString(IDST_TPL_XPOST, datalen, pNewTemplate->TXPost);
  1027.             pNewTemplate->bDirty = TRUE;
  1028.             templatelist.bDirty=TRUE;
  1029.          }
  1030.          else
  1031.          {
  1032.             pNewTemplate->TXPost=malloc(datalen);
  1033.             QueryProfileString(inifile, pchCurrentKey, "XPost", NULL, pNewTemplate->TXPost,
  1034.                                   datalen);
  1035.          }
  1036.  
  1037.          if (!inifile || !QueryProfileSize(inifile, pchCurrentKey, "CCopy", &datalen) ||
  1038.              datalen==0)
  1039.          {
  1040.             datalen=MAXLEN_STRING;
  1041.             pNewTemplate->TCCopy=malloc(datalen);
  1042.             LoadString(IDST_TPL_CCOPY, datalen, pNewTemplate->TCCopy);
  1043.             pNewTemplate->bDirty = TRUE;
  1044.             templatelist.bDirty=TRUE;
  1045.          }
  1046.          else
  1047.          {
  1048.             pNewTemplate->TCCopy=malloc(datalen);
  1049.             QueryProfileString(inifile, pchCurrentKey, "CCopy", NULL, pNewTemplate->TCCopy,
  1050.                                   datalen);
  1051.          }
  1052.  
  1053.          if (inifile)
  1054.          {
  1055.             QueryProfileString(inifile, pchCurrentKey, "Origin", "", pNewTemplate->TOrigin, LEN_ORIGIN+1);
  1056.             QueryProfileString(inifile, pchCurrentKey, "OriginFile", "", pNewTemplate->TOriginFile, LEN_PATHNAME+1);
  1057.             QueryProfileString(inifile, pchCurrentKey, "AllSyn", "", pNewTemplate->TAllSyn, LEN_USERNAME+1);
  1058.             datalen = sizeof(pNewTemplate->chQuoteChar);
  1059.             pNewTemplate->chQuoteChar = '>';
  1060.             QueryProfileData(inifile, pchCurrentKey, "QChar", &pNewTemplate->chQuoteChar, &datalen);
  1061.          }
  1062.       }
  1063.  
  1064.       /* Naechsten Key suchen */
  1065.       while (*pchCurrentKey)
  1066.          pchCurrentKey++;
  1067.       pchCurrentKey++;
  1068.    }
  1069.    if (!templatelist.pTemplates)
  1070.       LoadEmptyTemplate(&templatelist);
  1071.  
  1072.    free(pchKeys);
  1073.    PrfCloseProfile(inifile);
  1074.    return 0;
  1075. }
  1076.  
  1077. /*------------------------------ LoadEmptyTemplate --------------------------*/
  1078. /* Erzeugt das Default-Template an der Spitze mit den Daten aus den Resourcen */
  1079. /*---------------------------------------------------------------------------*/
  1080.  
  1081. static int LoadEmptyTemplate(TEMPLATELIST *pTemplateList)
  1082. {
  1083.    PMSGTEMPLATE pNewTemplate;
  1084.  
  1085.    /* neues Template */
  1086.    pNewTemplate = calloc(1, sizeof(MSGTEMPLATE));
  1087.  
  1088.    /* erstes Template */
  1089.    pTemplateList->pTemplates = pNewTemplate;
  1090.    pTemplateList->ulNumTemplates++;
  1091.    pTemplateList->bDirty = TRUE;
  1092.  
  1093.    /* Default setzen */
  1094.    LoadDefaultTemplate(pNewTemplate);
  1095.    pNewTemplate->ulID = 0;
  1096.  
  1097.    pNewTemplate->TName=malloc(MAXLEN_STRING);
  1098.    LoadString(IDST_TPL_DEFNAME, MAXLEN_STRING, pNewTemplate->TName);
  1099.  
  1100.    return 0;
  1101. }
  1102.  
  1103. /*------------------------------ SaveIniTemplates ---------------------------*/
  1104. /* Speichert die Templates in dem INI-File                                   */
  1105. /*---------------------------------------------------------------------------*/
  1106.  
  1107. static  int SaveIniTemplates(HAB hab)
  1108. {
  1109.    extern TEMPLATELIST templatelist;
  1110.    HINI inifile;
  1111.    char *pchKeys;             /* alle Keys */
  1112.    ULONG ulKeysLen;           /* Platz fuer die Keys */
  1113.    char *pchCurrentKey;       /* Aktueller Key */
  1114.    PMSGTEMPLATE pTemplate;
  1115.    char pchKey[20];
  1116.    char pchIniFile[LEN_PATHNAME+1];
  1117.  
  1118.    strcpy(pchIniFile, pchIniPath);
  1119.    strcat(pchIniFile, TEMPLATEFILENAME);
  1120.  
  1121.    if (!(inifile=PrfOpenProfile(hab, pchIniFile)))
  1122.       return 1;
  1123.  
  1124.    WriteProfileData(inifile, "Pos", "Pos", &(templatelist.FolderPos),
  1125.                        sizeof(templatelist.FolderPos));
  1126.    WriteProfileData(inifile, "Pos", "Flags", &(templatelist.ulFlags),
  1127.                        sizeof(templatelist.ulFlags));
  1128.  
  1129.    pTemplate = templatelist.pTemplates;
  1130.  
  1131.    while (pTemplate)
  1132.    {
  1133.       if (pTemplate->bDirty)
  1134.       {
  1135.          _itoa(pTemplate->ulID, pchKey, 10);
  1136.  
  1137.          WriteProfileData(inifile, pchKey, "Pos", &pTemplate->TPos,
  1138.                              sizeof(pTemplate->TPos));
  1139.          WriteProfileData(inifile, pchKey, "Linelen", &pTemplate->quotelinelen,
  1140.                              sizeof(pTemplate->quotelinelen));
  1141.          WriteProfileData(inifile, pchKey, "Joinlen", &pTemplate->joinlen,
  1142.                              sizeof(pTemplate->joinlen));
  1143.          WriteProfileData(inifile, pchKey, "UseInitials", &pTemplate->useinitials,
  1144.                              sizeof(pTemplate->useinitials));
  1145.          WriteProfileData(inifile, pchKey, "ForwardOrder", &pTemplate->forwardfirst,
  1146.                              sizeof(pTemplate->forwardfirst));
  1147.          WriteProfileData(inifile, pchKey, "Random", &pTemplate->randomorigin,
  1148.                              sizeof(pTemplate->randomorigin));
  1149.  
  1150.          if (pTemplate->TName)
  1151.             WriteProfileString(inifile, pchKey, "Name", pTemplate->TName);
  1152.          if (pTemplate->THeader)
  1153.             WriteProfileString(inifile, pchKey, "Header", pTemplate->THeader);
  1154.          if (pTemplate->TFooter)
  1155.             WriteProfileString(inifile, pchKey, "Footer", pTemplate->TFooter);
  1156.          if (pTemplate->TReply)
  1157.             WriteProfileString(inifile, pchKey, "Reply", pTemplate->TReply);
  1158.          if (pTemplate->TDArea)
  1159.             WriteProfileString(inifile, pchKey, "DArea", pTemplate->TDArea);
  1160.          if (pTemplate->TForward)
  1161.             WriteProfileString(inifile, pchKey, "Forward", pTemplate->TForward);
  1162.          if (pTemplate->TForwardFooter)
  1163.             WriteProfileString(inifile, pchKey, "ForwardFooter", pTemplate->TForwardFooter);
  1164.          if (pTemplate->TXPost)
  1165.             WriteProfileString(inifile, pchKey, "XPost", pTemplate->TXPost);
  1166.          if (pTemplate->TCCopy)
  1167.             WriteProfileString(inifile, pchKey, "CCopy", pTemplate->TCCopy);
  1168.          WriteProfileString(inifile, pchKey, "Origin", pTemplate->TOrigin);
  1169.          WriteProfileString(inifile, pchKey, "OriginFile", pTemplate->TOriginFile);
  1170.          WriteProfileString(inifile, pchKey, "AllSyn", pTemplate->TAllSyn);
  1171.          WriteProfileData(inifile, pchKey, "QChar", &pTemplate->chQuoteChar,
  1172.                              sizeof(pTemplate->chQuoteChar));
  1173.  
  1174.          pTemplate->bDirty=FALSE;
  1175.       }
  1176.       pTemplate = pTemplate->next;
  1177.    }
  1178.  
  1179.    /* ueberfluessige Areas im INI loeschen */
  1180.    if (!QueryProfileSize(inifile, NULL, NULL, &ulKeysLen) || (ulKeysLen==0))
  1181.    {
  1182.       PrfCloseProfile(inifile);
  1183.       return 1;
  1184.    }
  1185.  
  1186.    pchKeys=malloc(ulKeysLen);
  1187.  
  1188.    if (!QueryProfileData(inifile, NULL, NULL, pchKeys, &ulKeysLen))
  1189.    {
  1190.       free(pchKeys);
  1191.       PrfCloseProfile(inifile);
  1192.       return 1;
  1193.    }
  1194.  
  1195.    pchCurrentKey=pchKeys;
  1196.  
  1197.    while (*pchCurrentKey)
  1198.    {
  1199.       if (strcmp(pchCurrentKey, "Pos"))
  1200.       {
  1201.          ULONG ulID;
  1202.          PMSGTEMPLATE pTemplate;
  1203.  
  1204.          ulID = strtoul(pchCurrentKey, NULL, 10);
  1205.          pTemplate = templatelist.pTemplates;
  1206.          while (pTemplate && pTemplate->ulID != ulID)
  1207.             pTemplate = pTemplate->next;
  1208.  
  1209.          if (!pTemplate)
  1210.             WriteProfileData(inifile, pchCurrentKey, NULL, NULL, 0);
  1211.       }
  1212.  
  1213.       while (*pchCurrentKey)
  1214.          pchCurrentKey++;
  1215.       pchCurrentKey++;
  1216.    }
  1217.    free(pchKeys);
  1218.  
  1219.    PrfCloseProfile(inifile);
  1220.    templatelist.bDirty = FALSE;
  1221.    return 0;
  1222. }
  1223.  
  1224.  
  1225.  
  1226. /*------------------------------ ReadIniProfile -----------------------------*/
  1227. /* Liesst alle Informationen aus dem Profile                                 */
  1228. /* Returnwerte: 0   alles OK                                                 */
  1229. /*              1   Fehler beim Oeffnen des Profile                          */
  1230. /*              2   neues Profile                                            */
  1231. /*              3   veraltetes Profile                                       */
  1232. /*---------------------------------------------------------------------------*/
  1233.  
  1234. static ULONG ReadIniProfile(HAB hab)
  1235. {
  1236.    extern MARKERLIST MarkerList;
  1237.    extern BOOL issecondinstance;
  1238.    HINI inifile=NULLHANDLE;
  1239.    ULONG retval=0;
  1240.    char pchIniFile[LEN_PATHNAME+1];
  1241.  
  1242.    strcpy(pchIniFile, pchIniPath);
  1243.    strcat(pchIniFile, INIFILENAME);
  1244.  
  1245.    inifile=PrfOpenProfile(hab, pchIniFile);
  1246.  
  1247.    if (inifile)
  1248.    {
  1249.       char chBuffer[50];
  1250.  
  1251.       QueryProfileString(inifile, "Version", "ProgVersion",
  1252.                             "", chBuffer, 50);
  1253.       if (strcmp(chBuffer, PROGVERSION) &&
  1254.           strcmp(chBuffer, O_PROGVERSION))
  1255.       {
  1256.          /* Neues Profile */
  1257.          PrfCloseProfile(inifile);
  1258.          inifile=NULLHANDLE;
  1259.          retval= INIERROR(INIFILE_NEW);
  1260.       }
  1261.  
  1262.       if (inifile)
  1263.       {
  1264.          QueryProfileString(inifile, "Version", "IniVersion",
  1265.                                "", chBuffer, 50);
  1266.          if (strcmp(chBuffer, INIVERSION))
  1267.          {
  1268.             /* veraltetes Profile */
  1269.             if (issecondinstance || ConvertProfile(inifile, chBuffer, hab))
  1270.             {
  1271.                PrfCloseProfile(inifile);
  1272.                inifile=NULLHANDLE;
  1273.                retval= INIERROR(INIFILE_VERSION);
  1274.             }
  1275.          }
  1276.       }
  1277.    }
  1278.    else
  1279.       retval= INIERROR(INIFILE_OPEN);
  1280.  
  1281.    memset(&dirtyflags, 0, sizeof(dirtyflags));
  1282.  
  1283.    ReadIniUser(inifile);
  1284.    ReadIniNick(hab);
  1285.    ReadIniWinPos(inifile);
  1286.    ReadIniWinCol(inifile);
  1287.    ReadIniFonts(inifile);
  1288.    ReadIniPaths(inifile);
  1289.    ReadIniMisc(inifile);
  1290.    ReadIniMacros(inifile);
  1291.    ReadIniGeneral(inifile);
  1292.    ReadIniNodelist(inifile);
  1293.    ReadIniTemplates(hab);
  1294.    ReadIniEchotoss(inifile);
  1295.    ReadIniDomains(hab);
  1296.    ReadIniThreadopt(inifile);
  1297.    ReadIniResults(inifile);
  1298.    ReadIniRequest(inifile);
  1299.    ReadIniLookup(inifile);
  1300.    ReadIniAreaList(inifile);
  1301.    ReadIniMsgList(inifile);
  1302.    ReadIniRemap(inifile);
  1303.    ReadIniHooks(inifile);
  1304.    ReadIniFind(inifile);
  1305.    ReadIniMarkers(inifile, &MarkerList);
  1306.    ReadIniBrowse(inifile);
  1307.    ReadIniExport(inifile);
  1308.    ReadIniToolbar(inifile);
  1309.    ReadIniEchoman(inifile);
  1310.    ReadIniSearch(inifile);
  1311.    ReadIniPrintSetup(inifile);
  1312.    ReadIniScripts(hab);
  1313.    ReadIniCCLists(hab);
  1314.    ReadIntlSetting();
  1315.    ReadIniFolders(hab);
  1316.  
  1317.    if (inifile)
  1318.      PrfCloseProfile(inifile);
  1319.    return retval;
  1320. }
  1321.  
  1322. void _Optlink SaveIniProfileThread(void *pParam)
  1323. {
  1324.    extern BOOL bProfileSaved;
  1325.    HAB SaveHab;
  1326.  
  1327.    INSTALLEXPT("SaveINI");
  1328.  
  1329.    SaveHab = WinInitialize(0);
  1330.  
  1331.    SaveIniProfile(SaveHab);
  1332.  
  1333.    if (arealiste.bDirty)
  1334.       SaveIniAreas(SaveHab);
  1335.    memset(&dirtyflags, 0, sizeof(DIRTYFLAGS));
  1336.  
  1337.    if (pParam)
  1338.    {
  1339.       bProfileSaved=TRUE;
  1340.       WinPostQueueMsg(*((PHMQ)pParam), WM_QUIT, NULL, NULL);
  1341.    }
  1342.    WinTerminate(SaveHab);
  1343.  
  1344.    DEINSTALLEXPT;
  1345.  
  1346.    return;
  1347. }
  1348.  
  1349. /*------------------------------ SaveIniProfile -----------------------------*/
  1350. /* Speichert alle Informationen im Profile                                   */
  1351. /*---------------------------------------------------------------------------*/
  1352.  
  1353. int SaveIniProfile(HAB hab)
  1354. {
  1355.    extern TEMPLATELIST templatelist;
  1356.    extern CCANCHOR ccanchor;
  1357.    extern SCRIPTLIST scriptlist;
  1358.    extern MARKERLIST MarkerList;
  1359.    extern BOOL bSaveResults;
  1360.    extern NICKNAMELIST NickNameList;
  1361.    extern ECHOMGROPT EchoMgrOpt;
  1362.    extern PRINTSETUP PrintSetup;
  1363.    extern TOOLBARCONFIG ToolbarConfig;
  1364.    extern REQUESTOPT requestoptions;
  1365.    extern FOLDERANCHOR FolderAnchor;
  1366.    HINI inifile=NULLHANDLE;
  1367.    char pchIniFile[LEN_PATHNAME+1];
  1368.  
  1369.    strcpy(pchIniFile, pchIniPath);
  1370.    strcat(pchIniFile, INIFILENAME);
  1371.  
  1372.    inifile=PrfOpenProfile(hab, pchIniFile);
  1373.  
  1374.    if (inifile)
  1375.    {
  1376.       if (dirtyflags.userdirty)
  1377.          SaveIniUser(inifile);
  1378.       if (NickNameList.bDirty)
  1379.          SaveIniNick(hab);
  1380.       if (FolderAnchor.bDirty)
  1381.          SaveIniFolders(hab);
  1382.       SaveIniWinPos(inifile);
  1383.       SaveIniWinCol(inifile);
  1384.       SaveIniFonts(inifile);
  1385.       SaveIniPaths(inifile);
  1386.       SaveIniMisc(inifile);
  1387.       if (dirtyflags.domainsdirty)
  1388.          SaveIniDomains(hab);
  1389.       if (dirtyflags.macrosdirty)
  1390.          SaveIniMacros(inifile);
  1391.       /*if (dirtyflags.optionsdirty)*/
  1392.          SaveIniGeneral(inifile);
  1393.       if (dirtyflags.nodedirty)
  1394.          SaveIniNodelist(inifile);
  1395.       if (templatelist.bDirty)
  1396.          SaveIniTemplates(hab);
  1397.       if (dirtyflags.echotossdirty)
  1398.          SaveIniEchotoss(inifile);
  1399.       if (ccanchor.bDirty)
  1400.          SaveIniCCLists(hab);
  1401.       if (dirtyflags.threadsdirty)
  1402.          SaveIniThreadopt(inifile);
  1403.       if (dirtyflags.lookupdirty)
  1404.          SaveIniLookup(inifile);
  1405.       if (dirtyflags.resultsdirty)
  1406.          SaveIniResults(inifile);
  1407.       if (requestoptions.bDirty || requestoptions.bListDirty)
  1408.          SaveIniRequest(inifile);
  1409.       if (dirtyflags.alsettingsdirty)
  1410.          SaveIniAreaList(inifile);
  1411.       if (dirtyflags.mlsettingsdirty)
  1412.          SaveIniMsgList(inifile);
  1413.       if (dirtyflags.remapdirty)
  1414.          SaveIniRemap(inifile);
  1415.       if (dirtyflags.hooksdirty)
  1416.          SaveIniHooks(inifile);
  1417.       if (dirtyflags.finddirty)
  1418.          SaveIniFind(inifile);
  1419.       if (scriptlist.bDirty)
  1420.          SaveIniScripts(hab);
  1421.       if (bSaveResults)
  1422.       {
  1423.          if (MarkerList.bDirty)
  1424.             SaveIniMarkers(inifile, &MarkerList);
  1425.       }
  1426.       else
  1427.          WriteProfileData(inifile, "Mark", NULL, NULL, 0);
  1428.       if (dirtyflags.browserdirty)
  1429.          SaveIniBrowse(inifile);
  1430.       if (dirtyflags.toolbardirty || ToolbarConfig.bDirty)
  1431.          SaveIniToolbar(inifile);
  1432.       SaveIniExport(inifile);
  1433.       if (EchoMgrOpt.bDirty)
  1434.          SaveIniEchoman(inifile);
  1435.       if (PrintSetup.bDirty)
  1436.          SaveIniPrintSetup(inifile);
  1437.       SaveIniSearch(inifile);
  1438.       WriteProfileString(inifile, "Version", "ProgVersion", PROGVERSION);
  1439.       WriteProfileString(inifile, "Version", "IniVersion", INIVERSION);
  1440.       PrfCloseProfile(inifile);
  1441.       return 0;
  1442.    }
  1443.    else
  1444.       return 1;
  1445. }
  1446.  
  1447. /*------------------------------ ReadIniUser  -------------------------------*/
  1448. /* Liesst die Userinformationen aus dem INI-File,                            */
  1449. /*---------------------------------------------------------------------------*/
  1450.  
  1451. static  int ReadIniUser(HINI inifile)
  1452. {
  1453.    ULONG datalen=0;
  1454.    int rc=0;
  1455.  
  1456.    datalen=sizeof(userdaten.username);
  1457.    memset(&(userdaten.username[0]), 0, sizeof(userdaten.username));
  1458.  
  1459.    if (!inifile || !QueryProfileData(inifile, "User", "Names",
  1460.                             &(userdaten.username[0]), &datalen))
  1461.    {
  1462.       /* Default-Werte */
  1463.       memset(&(userdaten.username[0]), 0, sizeof(userdaten.username));
  1464.       dirtyflags.userdirty=TRUE;
  1465.       rc=1;
  1466.    }
  1467.  
  1468.    datalen=sizeof(userdaten.address);
  1469.    memset(&(userdaten.address[0]), 0, sizeof(userdaten.address));
  1470.  
  1471.    if (!inifile || !QueryProfileData(inifile, "User", "Addresses",
  1472.                             &(userdaten.address[0]), &datalen))
  1473.    {
  1474.       /* Default-Werte */
  1475.       memset(&(userdaten.address[0]), 0, sizeof(userdaten.address));
  1476.       dirtyflags.userdirty=TRUE;
  1477.       rc=1;
  1478.    }
  1479.  
  1480.    memset(userdaten.defaultorigin, 0, sizeof(userdaten.defaultorigin));
  1481.  
  1482.    if (inifile)
  1483.       QueryProfileString(inifile, "User", "Origin", NULL, userdaten.defaultorigin,
  1484.                             sizeof(userdaten.defaultorigin));
  1485.  
  1486.    return rc;
  1487. }
  1488.  
  1489. /*------------------------------ SaveIniUser  -------------------------------*/
  1490. /* Schreibt die Userinformationen in das INI-File                            */
  1491. /*---------------------------------------------------------------------------*/
  1492.  
  1493. static  int SaveIniUser(HINI inifile)
  1494. {
  1495.    int i=0;
  1496.    int rc=0;
  1497.  
  1498.    if (!inifile)
  1499.       return 1;
  1500.  
  1501.    i=0;
  1502.    while(i<MAX_USERNAMES && userdaten.username[i][0])
  1503.       i++;
  1504.  
  1505.    if (i>0)
  1506.       if (!WriteProfileData(inifile, "User", "Names",
  1507.                             &(userdaten.username[0]), i*(LEN_USERNAME+1)))
  1508.          rc=1;
  1509.  
  1510.    i=0;
  1511.    while(i<MAX_ADDRESSES && userdaten.address[i][0])
  1512.       i++;
  1513.  
  1514.    if (i>0)
  1515.       if (!WriteProfileData(inifile, "User", "Addresses",
  1516.                             &(userdaten.address[0]), i*(LEN_5DADDRESS+1)))
  1517.          rc=1;
  1518.  
  1519.    if (!WriteProfileString(inifile, "User", "Origin", userdaten.defaultorigin))
  1520.       rc=1;
  1521.  
  1522.    return rc;
  1523. }
  1524.  
  1525. /*------------------------------ ReadIniNick  -------------------------------*/
  1526. /* Liesst die Nicknames aus dem INI-File                                     */
  1527. /*---------------------------------------------------------------------------*/
  1528.  
  1529. static int ReadIniNick(HAB hab)
  1530. {
  1531.    char *pchKeys;             /* alle Keys */
  1532.    ULONG ulKeysLen;           /* Platz fuer die Keys */
  1533.    char *pchCurrentKey;       /* Aktueller Key */
  1534.    extern NICKNAMELIST NickNameList;
  1535.    NICKNAME NickName;
  1536.    ULONG sizeNick;
  1537.    HINI hini;
  1538.    char pchIniFile[LEN_PATHNAME+1];
  1539.  
  1540.    strcpy(pchIniFile, pchIniPath);
  1541.    strcat(pchIniFile, NICKFILENAME);
  1542.  
  1543.    hini=PrfOpenProfile(hab, pchIniFile);
  1544.  
  1545.    if (hini)
  1546.    {
  1547.       if (!QueryProfileSize(hini, NULL, NULL, &ulKeysLen) || (ulKeysLen==0))
  1548.       {
  1549.          PrfCloseProfile(hini);
  1550.          return 1;
  1551.       }
  1552.  
  1553.       pchKeys=malloc(ulKeysLen);
  1554.  
  1555.       if (!QueryProfileData(hini, NULL, NULL, pchKeys, &ulKeysLen))
  1556.       {
  1557.          free(pchKeys);
  1558.          PrfCloseProfile(hini);
  1559.          return 1;
  1560.       }
  1561.  
  1562.       pchCurrentKey=pchKeys;
  1563.  
  1564.       while (pchCurrentKey[0])
  1565.       {
  1566.          if (pchCurrentKey[0] == '#')
  1567.          {
  1568.             /* Folder-Daten */
  1569.             sizeNick = sizeof(NickNameList.FolderPos);
  1570.             QueryProfileData(hini, pchCurrentKey, "Pos", &NickNameList.FolderPos, &sizeNick);
  1571.          }
  1572.          else
  1573.          {
  1574.             /* Nickname-Daten */
  1575.             memset(&NickName, 0, sizeof(NickName));
  1576.             strncpy(NickName.usertag, pchCurrentKey, LEN_USERNAME);
  1577.             strlwr(NickName.usertag);
  1578.             if (!FindNickname(&NickNameList, NickName.usertag, NULL))
  1579.             {
  1580.                QueryProfileString(hini, pchCurrentKey, "Name", "", NickName.username, sizeof(NickName.username));
  1581.                QueryProfileString(hini, pchCurrentKey, "Address", "", NickName.address, sizeof(NickName.address));
  1582.                QueryProfileString(hini, pchCurrentKey, "Subj", "", NickName.subjectline, sizeof(NickName.subjectline));
  1583.                QueryProfileString(hini, pchCurrentKey, "First", "", NickName.firstline, sizeof(NickName.firstline));
  1584.                NickName.ulAttrib = QueryProfileInt(hini, pchCurrentKey, "Attrib", 0);
  1585.                NickName.ulFlags = QueryProfileInt(hini, pchCurrentKey, "Flags", 0);
  1586.  
  1587.                ulKeysLen=0;
  1588.                if (QueryProfileSize(hini, pchCurrentKey, "Comment", &ulKeysLen) && ulKeysLen)
  1589.                {
  1590.                   NickName.pchComment = malloc(ulKeysLen);
  1591.                   QueryProfileString(hini, pchCurrentKey, "Comment", "", NickName.pchComment, ulKeysLen);
  1592.                }
  1593.  
  1594.                /* Hinzufuegen */
  1595.                AddNickname(&NickNameList, &NickName, FALSE);
  1596.                if (NickName.pchComment)
  1597.                   free(NickName.pchComment);
  1598.             }
  1599.          }
  1600.  
  1601.          /* Naechsten Key suchen */
  1602.          while (pchCurrentKey[0])
  1603.             pchCurrentKey++;
  1604.          pchCurrentKey++;
  1605.       }
  1606.       free(pchKeys);
  1607.       PrfCloseProfile(hini);
  1608.       return 0;
  1609.    }
  1610.    else
  1611.       return 1;
  1612. }
  1613.  
  1614. /*------------------------------ SaveIniNick  -------------------------------*/
  1615. /* Speichert die Nicknames in dem INI-File                                   */
  1616. /*---------------------------------------------------------------------------*/
  1617.  
  1618. static  int SaveIniNick(HAB hab)
  1619. {
  1620.    PNICKNAME pNick=NULL;
  1621.    extern NICKNAMELIST NickNameList;
  1622.    HINI hini;
  1623.    char pchIniFile[LEN_PATHNAME+1];
  1624.    char *pchKeys;             /* alle Keys */
  1625.    ULONG ulKeysLen;           /* Platz fuer die Keys */
  1626.    char *pchCurrentKey;       /* Aktueller Key */
  1627.  
  1628.    strcpy(pchIniFile, pchIniPath);
  1629.    strcat(pchIniFile, NICKFILENAME);
  1630.  
  1631.    hini=PrfOpenProfile(hab, pchIniFile);
  1632.  
  1633.    if (hini)
  1634.    {
  1635.       /* Globale Daten */
  1636.       WriteProfileData(hini, "#List", "Pos", &NickNameList.FolderPos, sizeof(NickNameList.FolderPos));
  1637.  
  1638.       /* Die Nicknames */
  1639.       while (pNick = FindNickname(&NickNameList, NULL, pNick))
  1640.       {
  1641.          if (pNick->bDirty)
  1642.          {
  1643.             if (pNick->username[0])
  1644.                WriteProfileString(hini, pNick->usertag, "Name", pNick->username);
  1645.             else
  1646.                WriteProfileString(hini, pNick->usertag, "Name", NULL);
  1647.             if (pNick->address[0])
  1648.                WriteProfileString(hini, pNick->usertag, "Address", pNick->address);
  1649.             else
  1650.                WriteProfileString(hini, pNick->usertag, "Address", NULL);
  1651.             if (pNick->subjectline[0])
  1652.                WriteProfileString(hini, pNick->usertag, "Subj", pNick->subjectline);
  1653.             else
  1654.                WriteProfileString(hini, pNick->usertag, "Subj", NULL);
  1655.             if (pNick->firstline[0])
  1656.                WriteProfileString(hini, pNick->usertag, "First", pNick->firstline);
  1657.             else
  1658.                WriteProfileString(hini, pNick->usertag, "First", NULL);
  1659.             if (pNick->ulAttrib)
  1660.                WriteProfileInt(hini, pNick->usertag, "Attrib", pNick->ulAttrib);
  1661.             else
  1662.                WriteProfileString(hini, pNick->usertag, "Attrib", NULL);
  1663.             if (pNick->ulFlags)
  1664.                WriteProfileInt(hini, pNick->usertag, "Flags", pNick->ulFlags);
  1665.             else
  1666.                WriteProfileString(hini, pNick->usertag, "Flags", NULL);
  1667.             WriteProfileString(hini, pNick->usertag, "Comment", pNick->pchComment);
  1668.  
  1669.             pNick->bDirty = FALSE;
  1670.          }
  1671.       }
  1672.       NickNameList.bDirty = FALSE;
  1673.  
  1674.       /* evtl. geloeschte Eintraege entfernen */
  1675.       if (!QueryProfileSize(hini, NULL, NULL, &ulKeysLen) || (ulKeysLen==0))
  1676.       {
  1677.          PrfCloseProfile(hini);
  1678.          return 1;
  1679.       }
  1680.  
  1681.       pchKeys=malloc(ulKeysLen);
  1682.  
  1683.       if (!QueryProfileData(hini, NULL, NULL, pchKeys, &ulKeysLen))
  1684.       {
  1685.          free(pchKeys);
  1686.          PrfCloseProfile(hini);
  1687.          return 1;
  1688.       }
  1689.  
  1690.       pchCurrentKey=pchKeys;
  1691.  
  1692.       while (pchCurrentKey[0])
  1693.       {
  1694.          if (pchCurrentKey[0] != '#' && !FindNicknameSens(&NickNameList, pchCurrentKey))
  1695.             WriteProfileData(hini, pchCurrentKey, NULL, NULL, 0);
  1696.  
  1697.          /* Naechsten Key suchen */
  1698.          while (pchCurrentKey[0])
  1699.             pchCurrentKey++;
  1700.          pchCurrentKey++;
  1701.       }
  1702.       free(pchKeys);
  1703.       PrfCloseProfile(hini);
  1704.  
  1705.       return 0;
  1706.    }
  1707.    else
  1708.       return 1;
  1709. }
  1710.  
  1711. /*------------------------------ ReadIniWinPos ------------------------------*/
  1712. /* Liesst die Fensterpositionen aus dem INI-File,                            */
  1713. /*---------------------------------------------------------------------------*/
  1714.  
  1715. static  int ReadIniWinPos(HINI inifile)
  1716. {
  1717.    extern WINDOWPOSITIONS windowpositions;
  1718.    ULONG datalen=0;
  1719.  
  1720.    datalen=sizeof(windowpositions);
  1721.    memset(&windowpositions, 0, datalen);
  1722.    if (!inifile || !QueryProfileData(inifile, "Positions", "Windowpos",
  1723.                             &windowpositions, &datalen))
  1724.    {
  1725.       /* Default-Werte */
  1726.       /* fl auf 0 setzen, d.h. keine gespeicherte Pos. anzeigen */
  1727.       memset(&windowpositions, 0, sizeof(windowpositions));
  1728.       return 1;
  1729.    }
  1730.    return 0;
  1731. }
  1732.  
  1733. /*------------------------------ SaveIniWinPos ------------------------------*/
  1734. /* Speichert die Fensterpositionen im INI-File                               */
  1735. /*---------------------------------------------------------------------------*/
  1736.  
  1737. static  int SaveIniWinPos(HINI inifile)
  1738. {
  1739.    extern WINDOWPOSITIONS windowpositions;
  1740.  
  1741.  
  1742.    if (!inifile || !WriteProfileData(inifile, "Positions", "Windowpos",
  1743.                             &windowpositions, sizeof(windowpositions)))
  1744.       return 1;
  1745.    else
  1746.       return 0;
  1747. }
  1748.  
  1749. /*------------------------------ ReadIniWinCol ------------------------------*/
  1750. /* Liesst die Farben aus dem INI-File                                        */
  1751. /*---------------------------------------------------------------------------*/
  1752.  
  1753. static  int ReadIniWinCol(HINI inifile)
  1754. {
  1755.    extern WINDOWCOLORS windowcolors;
  1756.    ULONG datalen=0;
  1757.    ULONG ulVer[2]={0,0};
  1758.  
  1759.    DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR, ulVer, sizeof(ulVer));
  1760.  
  1761.    /* Default-Werte */
  1762.    /* alle Farben schwarz */
  1763.    memset(&windowcolors, 0, sizeof(windowcolors));
  1764.  
  1765.    /* sonst andere Defaults */
  1766.    windowcolors.windowback=RGB_GREY;
  1767.    if (ulVer[0] > 2 || (ulVer[0]==2 && ulVer[1]>=11))
  1768.    {
  1769.       /* OS/2 2.11 verwendet RGB-Farben f. MLE */
  1770.       windowcolors.editback=RGB_WHITE;
  1771.       windowcolors.editfore=RGB_BLACK;
  1772.    }
  1773.    else
  1774.    {
  1775.       windowcolors.editback=CLR_WHITE;
  1776.       windowcolors.editfore=CLR_BLACK;
  1777.    }
  1778.    windowcolors.statusback=RGB_GREY;
  1779.    windowcolors.scriptback=RGB_WHITE;
  1780.    windowcolors.areatitlefore=RGB_RED;
  1781.    windowcolors.areatitleback=RGB_GREY;
  1782.    windowcolors.monitorfore=RGB_BLACK;
  1783.    windowcolors.monitorback=RGB_WHITE;
  1784.    windowcolors.fromback=RGB_GREY;
  1785.    windowcolors.fromadback=RGB_GREY;
  1786.    windowcolors.toback=RGB_GREY;
  1787.    windowcolors.toadback=RGB_GREY;
  1788.    windowcolors.fromtostaticfore=RGB_BLUE;
  1789.    windowcolors.fromtostaticback=RGB_GREY;
  1790.    windowcolors.subjback=RGB_GREY;
  1791.    windowcolors.attribback=RGB_GREY;
  1792.    windowcolors.msgtimeback=RGB_GREY;
  1793.    windowcolors.menuback=RGB_GREY;
  1794.    windowcolors.arealistback=RGB_WHITE;
  1795.    windowcolors.tplfolderback=RGB_WHITE;
  1796.    windowcolors.threadlistback=RGB_WHITE;
  1797.    windowcolors.ccfolderback=RGB_WHITE;
  1798.    windowcolors.ccfolderfore=RGB_BLACK;
  1799.    windowcolors.nicknamesback=RGB_WHITE;
  1800.    windowcolors.msginfoback=CLR_WHITE;
  1801.    windowcolors.msginfofore=CLR_BLACK;
  1802.    windowcolors.resultsback=RGB_WHITE;
  1803.    windowcolors.cccontentsback=RGB_WHITE;
  1804.    windowcolors.lookupback=RGB_WHITE;
  1805.    windowcolors.attachback=RGB_WHITE;
  1806.    windowcolors.viewerback=RGB_WHITE;
  1807.    windowcolors.viewerfore=RGB_BLACK;
  1808.    windowcolors.viewerquote=RGB_BLUE;
  1809.    windowcolors.viewertearline=RGB_RED;
  1810.    windowcolors.viewerorigin=RGB_DARKGREEN;
  1811.  
  1812.    datalen=sizeof(windowcolors);
  1813.    if (!inifile || !QueryProfileData(inifile, "Colors", "Windowcol",
  1814.                             &windowcolors, &datalen))
  1815.    {
  1816.       return 1;
  1817.    }
  1818.    return 0;
  1819. }
  1820.  
  1821. /*------------------------------ SaveIniWinCol ------------------------------*/
  1822. /* Speichert die Farben im INI-File                                          */
  1823. /*---------------------------------------------------------------------------*/
  1824.  
  1825. static int SaveIniWinCol(HINI inifile)
  1826. {
  1827.    extern WINDOWCOLORS windowcolors;
  1828.  
  1829.    if (!inifile || !WriteProfileData(inifile, "Colors", "Windowcol",
  1830.                             &windowcolors, sizeof(windowcolors)))
  1831.       return 1;
  1832.    else
  1833.       return 0;
  1834. }
  1835.  
  1836. /*------------------------------ ReadIniFonts  ------------------------------*/
  1837. /* Liesst die Fonts aus dem INI-File                                         */
  1838. /*---------------------------------------------------------------------------*/
  1839.  
  1840. static int ReadIniFonts(HINI inifile)
  1841. {
  1842.    extern WINDOWFONTS windowfonts;
  1843.    ULONG datalen=0;
  1844.  
  1845.    /* Default-Werte */
  1846.    /* Alle Fonts unveraendert */
  1847.    memset(&windowfonts, 0, sizeof(windowfonts));
  1848.  
  1849.    /* andere Fonts */
  1850.    strcpy(windowfonts.statusfont, SMA_FONT);
  1851.    strcpy(windowfonts.scriptfont, SMA_FONT);
  1852.    strcpy(windowfonts.datefont, SMA_FONT);
  1853.    strcpy(windowfonts.buttonfont, SMA_FONT);
  1854.    strcpy(windowfonts.arealistfont, SMA_FONT);
  1855.    strcpy(windowfonts.tplfolderfont, SMA_FONT);
  1856.    strcpy(windowfonts.threadlistfont, SMA_FONT);
  1857.    strcpy(windowfonts.findresultsfont, SMA_FONT);
  1858.    strcpy(windowfonts.ccfolderfont, SMA_FONT);
  1859.    strcpy(windowfonts.cclistfont, SMA_FONT);
  1860.    strcpy(windowfonts.lookupfont, SMA_FONT);
  1861.    strcpy(windowfonts.nicknamesfont, SMA_FONT);
  1862.    strcpy(windowfonts.attachfont, SMA_FONT);
  1863.    strcpy(windowfonts.viewerfont, VIEW_FONT);
  1864.    strcpy(windowfonts.viewermonofont, VIEW_FONT_MONO);
  1865.    strcpy(windowfonts.attribfont, SMA_FONT);
  1866.  
  1867.    datalen=sizeof(windowfonts);
  1868.    if (!inifile || !QueryProfileData(inifile, "Fonts", "Windowfonts",
  1869.                             &windowfonts, &datalen))
  1870.    {
  1871.       return 1;
  1872.    }
  1873.    return 0;
  1874. }
  1875.  
  1876. /*------------------------------ SaveIniFonts  ------------------------------*/
  1877. /* Speichert die Fonts im INI-File                                           */
  1878. /*---------------------------------------------------------------------------*/
  1879.  
  1880. static int SaveIniFonts(HINI inifile)
  1881. {
  1882.    extern WINDOWFONTS windowfonts;
  1883.  
  1884.    if (!inifile || !WriteProfileData(inifile, "Fonts", "Windowfonts",
  1885.                             &windowfonts, sizeof(windowfonts)))
  1886.       return 1;
  1887.    else
  1888.       return 0;
  1889. }
  1890.  
  1891. /*------------------------------ ReadIniPaths  ------------------------------*/
  1892. /* Liesst die Pfadnamen aus dem INI-File                                     */
  1893. /*---------------------------------------------------------------------------*/
  1894.  
  1895. static int ReadIniPaths(HINI inifile)
  1896. {
  1897.    extern PATHNAMES pathnames;
  1898.  
  1899.    memset(&pathnames, 0, sizeof(pathnames));
  1900.  
  1901.    if (!inifile)
  1902.       return 1;
  1903.  
  1904.    QueryProfileString(inifile, "Paths", "Import", "",
  1905.                          pathnames.lastimport, LEN_PATHNAME+1);
  1906.    QueryProfileString(inifile, "Paths", "Squish", "",
  1907.                          pathnames.squishcfg, LEN_PATHNAME+1);
  1908.  
  1909.    return 0;
  1910. }
  1911.  
  1912. /*------------------------------ SaveIniPaths  ------------------------------*/
  1913. /* Speichert die Paths im INI-File                                           */
  1914. /*---------------------------------------------------------------------------*/
  1915.  
  1916. static int SaveIniPaths(HINI inifile)
  1917. {
  1918.    extern PATHNAMES pathnames;
  1919.  
  1920.    if (!inifile)
  1921.       return 1;
  1922.  
  1923.    WriteProfileString(inifile, "Paths", "Import", pathnames.lastimport);
  1924.    WriteProfileString(inifile, "Paths", "Squish", pathnames.squishcfg);
  1925.  
  1926.    return 0;
  1927. }
  1928.  
  1929. /*------------------------------ ReadIniMisc   ------------------------------*/
  1930. /* Liesst die Misc-Options aus dem INI-File                                  */
  1931. /*---------------------------------------------------------------------------*/
  1932.  
  1933. static int ReadIniMisc(HINI inifile)
  1934. {
  1935.    extern MISCOPTIONS miscoptions;
  1936.    extern OPENWIN OpenWindows;
  1937.    ULONG datalen=0;
  1938.  
  1939.    memset(&miscoptions, 0, sizeof(miscoptions));
  1940.    datalen=sizeof(miscoptions);
  1941.    QueryProfileData(inifile, "Options", "Misc", &miscoptions, &datalen);
  1942.    OpenWindows.ulOpenWindows = QueryProfileInt(inifile, "Windows", "Open", 0);
  1943.    OpenWindows.ulForceOpen   = QueryProfileInt(inifile, "Windows", "FOpen", 0);
  1944.    OpenWindows.ulForceClose  = QueryProfileInt(inifile, "Windows", "FClose", 0);
  1945.  
  1946.    return 0;
  1947. }
  1948.  
  1949. /*------------------------------ SaveIniMisc   ------------------------------*/
  1950. /* Speichert die Misc-Options im INI-File                                    */
  1951. /*---------------------------------------------------------------------------*/
  1952.  
  1953. static int SaveIniMisc(HINI inifile)
  1954. {
  1955.    extern MISCOPTIONS miscoptions;
  1956.    extern OPENWIN OpenWindows;
  1957.  
  1958.    if (!inifile || !WriteProfileData(inifile, "Options", "Misc",
  1959.                             &miscoptions, sizeof(miscoptions)))
  1960.       return 1;
  1961.    else
  1962.    {
  1963.       WriteProfileInt(inifile, "Windows", "Open", OpenWindows.ulOpenWindows);
  1964.       WriteProfileInt(inifile, "Windows", "FOpen", OpenWindows.ulForceOpen);
  1965.       WriteProfileInt(inifile, "Windows", "FClose", OpenWindows.ulForceClose);
  1966.  
  1967.       return 0;
  1968.    }
  1969. }
  1970.  
  1971. /*------------------------------ ReadIniMacros ------------------------------*/
  1972. /* Liesst die Macros aus dem INI-File                                        */
  1973. /*---------------------------------------------------------------------------*/
  1974.  
  1975. static int ReadIniMacros(HINI inifile)
  1976. {
  1977.    extern MACROTABLEOPT macrotable;
  1978.    int i;
  1979.    char pchKey[10];
  1980.  
  1981.    memset(¯otable, 0, sizeof(macrotable));
  1982.  
  1983.    if (!inifile)
  1984.       return 1;
  1985.  
  1986.    for (i=0; i<11; i++)
  1987.    {
  1988.       sprintf(pchKey, "M%02d", i+1);
  1989.       QueryProfileString(inifile, "Macros", pchKey, "", macrotable.macrotext[i], LEN_MACRO+1);
  1990.    }
  1991.    return 0;
  1992. }
  1993.  
  1994. /*------------------------------ SaveIniMacros ------------------------------*/
  1995. /* Speichert die Macros im INI-File                                          */
  1996. /*---------------------------------------------------------------------------*/
  1997.  
  1998. static int SaveIniMacros(HINI inifile)
  1999. {
  2000.    extern MACROTABLEOPT macrotable;
  2001.    int i;
  2002.    char pchKey[10];
  2003.  
  2004.    if (!inifile)
  2005.       return 1;
  2006.  
  2007.    for (i=0; i<11; i++)
  2008.    {
  2009.       sprintf(pchKey, "M%02d", i+1);
  2010.       WriteProfileString(inifile, "Macros", pchKey, macrotable.macrotext[i]);
  2011.    }
  2012.  
  2013.    return 0;
  2014. }
  2015.  
  2016. /*------------------------------ ReadIniGeneral -----------------------------*/
  2017. /* Liesst die General-Optionen aus dem INI-File                              */
  2018. /*---------------------------------------------------------------------------*/
  2019.  
  2020. static int ReadIniGeneral(HINI inifile)
  2021. {
  2022.    extern GENERALOPT generaloptions;
  2023.    ULONG datalen=0;
  2024.    ULONG ulTime;
  2025.  
  2026.    DosQuerySysInfo(QSV_TIME_LOW, QSV_TIME_LOW, &ulTime, sizeof(ulTime));
  2027.  
  2028.    datalen=sizeof(generaloptions);
  2029.    memset(&generaloptions, 0, datalen);
  2030.  
  2031.    /* Default-Werte */
  2032.    generaloptions.safety=0xFFFFFFFF;
  2033.    generaloptions.uselastarea=TRUE;
  2034.    generaloptions.lTabSize=8;
  2035.    generaloptions.lMaxMsgLen=14;
  2036.    generaloptions.beeponpersonal=TRUE;
  2037.    generaloptions.ulInstallTime = ulTime;
  2038.  
  2039.    if (!inifile || !QueryProfileData(inifile, "Options", "General",
  2040.                             &generaloptions, &datalen))
  2041.    {
  2042.       dirtyflags.optionsdirty=TRUE;
  2043.       return 1;
  2044.    }
  2045.    if (generaloptions.lTabSize<1 || generaloptions.lTabSize>20)
  2046.       generaloptions.lTabSize=8;
  2047.    return 0;
  2048. }
  2049.  
  2050. /*------------------------------ SaveIniGeneral -----------------------------*/
  2051. /* Speichert die General-Optionen im INI-File                                */
  2052. /*---------------------------------------------------------------------------*/
  2053.  
  2054. static int SaveIniGeneral(HINI inifile)
  2055. {
  2056.    extern GENERALOPT generaloptions;
  2057.  
  2058.    if (!inifile || !WriteProfileData(inifile, "Options", "General",
  2059.                             &generaloptions, sizeof(generaloptions)))
  2060.       return 1;
  2061.    else
  2062.       return 0;
  2063. }
  2064.  
  2065. /*------------------------------ ReadIniNodelist ----------------------------*/
  2066. /* Liesst die Nodelist-Optionen aus dem INI-File                             */
  2067. /*---------------------------------------------------------------------------*/
  2068.  
  2069. static  int ReadIniNodelist(HINI inifile)
  2070. {
  2071.    extern NODELISTOPT nodelist;
  2072.    ULONG ulTypesLen=0;
  2073.    PCHAR pchModemTypes=NULL, pchCurrType=NULL;
  2074.  
  2075.    memset(&nodelist.modemtype, 0, sizeof(nodelist.modemtype));
  2076.  
  2077.    if (QueryProfileSize(inifile, "Nodelist", "Modem", &ulTypesLen) && ulTypesLen>0)
  2078.    {
  2079.       int iType=0;
  2080.  
  2081.       pchModemTypes=malloc(sizeof(nodelist.modemtype)+1);
  2082.       memset(pchModemTypes, 0, sizeof(nodelist.modemtype)+1);
  2083.       pchCurrType=pchModemTypes;
  2084.       QueryProfileData(inifile, "Nodelist", "Modem", pchModemTypes, &ulTypesLen);
  2085.  
  2086.       while(iType<MAX_MODEMTYPES)
  2087.       {
  2088.          strncpy(nodelist.modemtype[iType], pchCurrType, LEN_MODEMTYPE);
  2089.  
  2090.          while(*pchCurrType)
  2091.             pchCurrType++;
  2092.          pchCurrType++;
  2093.          iType++;
  2094.       }
  2095.       free(pchModemTypes);
  2096.    }
  2097.  
  2098.    if (QueryProfileSize(inifile, "Nodelist", "ModemB", &ulTypesLen) && ulTypesLen>0)
  2099.    {
  2100.       char *pchTemp;
  2101.       int iType;
  2102.  
  2103.       pchTemp = pchModemTypes = malloc(ulTypesLen);
  2104.       QueryProfileData(inifile, "Nodelist", "ModemB", pchModemTypes, &ulTypesLen);
  2105.  
  2106.       while(*pchTemp)
  2107.       {
  2108.          iType = (*pchTemp)-1;
  2109.  
  2110.          pchTemp++;
  2111.  
  2112.          strncpy(nodelist.bytetypes[iType], pchTemp, LEN_MODEMTYPE);
  2113.  
  2114.          while(*pchTemp)
  2115.             pchTemp++;
  2116.          pchTemp++;
  2117.       }
  2118.       free(pchModemTypes);
  2119.    }
  2120.  
  2121.  
  2122.    ulTypesLen=sizeof(nodelist.ulOptions);
  2123.  
  2124.    QueryProfileData(inifile, "Nodelist", "Options", &nodelist.ulOptions, &ulTypesLen);
  2125.  
  2126.    return 0;
  2127. }
  2128.  
  2129. /*------------------------------ SaveIniNodelist ----------------------------*/
  2130. /* Speichert die Nodelist-Optionen im INI-File                               */
  2131. /*---------------------------------------------------------------------------*/
  2132.  
  2133. static int SaveIniNodelist(HINI inifile)
  2134. {
  2135.    extern NODELISTOPT nodelist;
  2136.    PCHAR pchModemTypes=NULL, pchCurrType=NULL, pchTemp;
  2137.    int i;
  2138.    ULONG ulSize=0;
  2139.  
  2140.    pchModemTypes=malloc(sizeof(nodelist.modemtype)+1);
  2141.  
  2142.    memset(pchModemTypes, 0, sizeof(nodelist.modemtype)+1);
  2143.    pchCurrType=pchModemTypes;
  2144.  
  2145.    for (i=0; i<MAX_MODEMTYPES; i++)
  2146.    {
  2147.       strcpy(pchCurrType, nodelist.modemtype[i]);
  2148.       while(*pchCurrType)
  2149.          pchCurrType++;
  2150.       pchCurrType++;
  2151.    }
  2152.    *pchCurrType='\0';
  2153.  
  2154.    WriteProfileData(inifile, "Nodelist", "Modem", pchModemTypes,
  2155.                        pchCurrType-pchModemTypes+1);
  2156.  
  2157.    free(pchModemTypes);
  2158.  
  2159.    /* Byte-Type */
  2160.    for (i=0; i<255; i++)
  2161.       if (nodelist.bytetypes[i][0])
  2162.          ulSize += 2 + strlen(nodelist.bytetypes[i]);
  2163.  
  2164.    pchTemp = pchModemTypes = malloc(ulSize + 1);
  2165.  
  2166.    for (i=0; i<255; i++)
  2167.       if (nodelist.bytetypes[i][0])
  2168.       {
  2169.          *pchTemp = i+1;
  2170.          pchTemp++;
  2171.          strcpy(pchTemp, nodelist.bytetypes[i]);
  2172.          while (*pchTemp)
  2173.             pchTemp++;
  2174.          pchTemp++;
  2175.       }
  2176.    *pchTemp = 0;
  2177.  
  2178.    WriteProfileData(inifile, "Nodelist", "ModemB", pchModemTypes, ulSize+1);
  2179.  
  2180.    free(pchModemTypes);
  2181.  
  2182.    WriteProfileData(inifile, "Nodelist", "Options", &nodelist.ulOptions,
  2183.                     sizeof(nodelist.ulOptions));
  2184.  
  2185.    return 0;
  2186. }
  2187.  
  2188. /*------------------------------ ReadIniEchotoss ----------------------------*/
  2189. /* Liesst die Echotoss-Optionen aus dem INI-File                             */
  2190. /*---------------------------------------------------------------------------*/
  2191.  
  2192. static  int ReadIniEchotoss(HINI inifile)
  2193. {
  2194.    extern ECHOTOSSOPT echotossoptions;
  2195.    ULONG datalen=0;
  2196.    int rc=0;
  2197.  
  2198.    memset(&echotossoptions, 0, sizeof(echotossoptions));
  2199.  
  2200.    datalen=4;
  2201.    if (!inifile || !QueryProfileData(inifile, "Echotoss", "Options",
  2202.                             &echotossoptions.useechotoss, &datalen))
  2203.    {
  2204.       /* Default-Werte */
  2205.       echotossoptions.useechotoss=FALSE;
  2206.       dirtyflags.echotossdirty=TRUE;
  2207.       rc=1;
  2208.    }
  2209.  
  2210.    if (!inifile || !QueryProfileString(inifile, "Echotoss", "Pathname",
  2211.                             "", echotossoptions.pchEchoToss, LEN_PATHNAME+1))
  2212.    {
  2213.       /* Default-Werte */
  2214.       dirtyflags.echotossdirty=TRUE;
  2215.       rc=1;
  2216.    }
  2217.  
  2218.    return rc;
  2219. }
  2220.  
  2221. /*------------------------------ SaveIniEchotoss ----------------------------*/
  2222. /* Speichert die Echotoss-Optionen im INI-File                               */
  2223. /*---------------------------------------------------------------------------*/
  2224.  
  2225. static  int SaveIniEchotoss(HINI inifile)
  2226. {
  2227.    extern ECHOTOSSOPT echotossoptions;
  2228.  
  2229.    if (!inifile)
  2230.       return 1;
  2231.    if (!WriteProfileData(inifile, "Echotoss", "Options",
  2232.                             &echotossoptions.useechotoss, 4))
  2233.       return 1;
  2234.    if (!WriteProfileString(inifile, "Echotoss", "Pathname",
  2235.                               echotossoptions.pchEchoToss))
  2236.       return 1;
  2237.    else
  2238.       return 0;
  2239. }
  2240.  
  2241. /*------------------------------ ReadIniDomains  ----------------------------*/
  2242. /* Liesst die Domain-Optionen aus dem INI-File                               */
  2243. /*---------------------------------------------------------------------------*/
  2244.  
  2245. static  int ReadIniDomains(HAB hab)
  2246. {
  2247.    extern PDOMAINS domains;
  2248.    PDOMAINS pDomainData=NULL;
  2249.    HINI inifile;
  2250.    char *pchDomains=NULL, *pchCurrentDomain=NULL;
  2251.    ULONG ulKeysLen=0;
  2252.    char pchIniFile[LEN_PATHNAME+1];
  2253.  
  2254.    strcpy(pchIniFile, pchIniPath);
  2255.    strcat(pchIniFile, DOMAINFILENAME);
  2256.  
  2257.  
  2258.    if (!(inifile=PrfOpenProfile(hab, pchIniFile)))
  2259.       return 1;
  2260.  
  2261.    if (!QueryProfileSize(inifile, NULL, NULL, &ulKeysLen) || (ulKeysLen==0))
  2262.    {
  2263.       PrfCloseProfile(inifile);
  2264.       return 1;
  2265.    }
  2266.  
  2267.    pchDomains=malloc(ulKeysLen);
  2268.  
  2269.    if (!QueryProfileData(inifile, NULL, NULL, pchDomains, &ulKeysLen))
  2270.    {
  2271.       free(pchDomains);
  2272.       PrfCloseProfile(inifile);
  2273.       return 1;
  2274.    }
  2275.  
  2276.    pchCurrentDomain=pchDomains;
  2277.    domains=NULL;
  2278.  
  2279.    while (pchCurrentDomain[0])
  2280.    {
  2281.       /* Neuen Speicher anfordern */
  2282.       if (domains)
  2283.       {
  2284.          pDomainData->next=malloc(sizeof(DOMAINS));
  2285.          pDomainData=pDomainData->next;
  2286.          pDomainData->next=NULL;
  2287.       }
  2288.       else
  2289.       {
  2290.          domains=malloc(sizeof(DOMAINS));
  2291.          domains->next=NULL;
  2292.          pDomainData=domains;
  2293.       }
  2294.       memset(pDomainData, 0, sizeof(DOMAINS));
  2295.       /* Daten holen */
  2296.       strncpy(pDomainData->domainname, pchCurrentDomain, LEN_DOMAIN);
  2297.       QueryProfileString(inifile, pchCurrentDomain, "Index", "", pDomainData->indexfile, LEN_PATHNAME+1);
  2298.       QueryProfileString(inifile, pchCurrentDomain, "Data", "", pDomainData->nodelistfile, LEN_PATHNAME+1);
  2299.  
  2300.       while(*pchCurrentDomain)
  2301.          pchCurrentDomain++;
  2302.       pchCurrentDomain++;
  2303.    }
  2304.  
  2305.    free(pchDomains);
  2306.    PrfCloseProfile(inifile);
  2307.    return 0;
  2308. }
  2309.  
  2310. /*------------------------------ SaveIniDomains -----------------------------*/
  2311. /* Speichert die Domain-Optionen im INI-File                                 */
  2312. /*---------------------------------------------------------------------------*/
  2313.  
  2314. static  int SaveIniDomains(HAB hab)
  2315. {
  2316.    extern PDOMAINS domains;
  2317.    PDOMAINS pTemp;
  2318.    HINI inifile;
  2319.    char pchIniFile[LEN_PATHNAME+1];
  2320.  
  2321.    strcpy(pchIniFile, pchIniPath);
  2322.    strcat(pchIniFile, DOMAINFILENAME);
  2323.  
  2324.    pTemp=domains;
  2325.  
  2326.    if (DosDelete(pchIniFile)>2)
  2327.       return 1;
  2328.  
  2329.    if (!(inifile=PrfOpenProfile(hab, pchIniFile)))
  2330.       return 1;
  2331.  
  2332.    while(pTemp)
  2333.    {
  2334.       WriteProfileString(inifile, pTemp->domainname, "Index", pTemp->indexfile);
  2335.       WriteProfileString(inifile, pTemp->domainname, "Data", pTemp->nodelistfile);
  2336.  
  2337.       pTemp=pTemp->next;
  2338.    }
  2339.  
  2340.    PrfCloseProfile(inifile);
  2341.  
  2342.    return 0;
  2343. }
  2344.  
  2345. /*------------------------------ ReadIniThreadopt ---------------------------*/
  2346. /* Liesst die Settings fuer die Threadsliste ein                             */
  2347. /*---------------------------------------------------------------------------*/
  2348.  
  2349. static  int ReadIniThreadopt(HINI inifile)
  2350. {
  2351.    extern THREADLISTOPTIONS threadlistoptions;
  2352.    ULONG datalen=0;
  2353.  
  2354.    datalen=sizeof(threadlistoptions);
  2355.    memset(&threadlistoptions, 0, datalen);
  2356.    threadlistoptions.shownames=TRUE;
  2357.    threadlistoptions.compact=TRUE;
  2358.    threadlistoptions.dspmode=DSPTHREADS_UNREADONLY;
  2359.    threadlistoptions.keepinfront=FALSE;
  2360.    threadlistoptions.lBackClr = RGB_WHITE;
  2361.    threadlistoptions.lReadClr = RGB_BLACK;
  2362.    threadlistoptions.lUnreadClr = RGB_RED;
  2363.    threadlistoptions.lPersonalClr = RGB_BLUE;
  2364.    if (!inifile || !QueryProfileData(inifile, "Options", "Threadlist",
  2365.                               &threadlistoptions, &datalen))
  2366.    {
  2367.       /* Default-Werte */
  2368.       threadlistoptions.shownames=TRUE;
  2369.       threadlistoptions.dspmode=DSPTHREADS_UNREADONLY;
  2370.       threadlistoptions.keepinfront=FALSE;
  2371.       threadlistoptions.lBackClr = RGB_WHITE;
  2372.       threadlistoptions.lReadClr = RGB_BLACK;
  2373.       threadlistoptions.lUnreadClr = RGB_RED;
  2374.       threadlistoptions.lPersonalClr = RGB_BLUE;
  2375.       dirtyflags.threadsdirty=TRUE;
  2376.       return 1;
  2377.    }
  2378.    else
  2379.       return 0;
  2380. }
  2381.  
  2382. /*------------------------------ SaveIniThreadopt ---------------------------*/
  2383. /* Speichert die Settings fuer die Threadsliste                              */
  2384. /*---------------------------------------------------------------------------*/
  2385.  
  2386. static  int SaveIniThreadopt(HINI inifile)
  2387. {
  2388.    extern THREADLISTOPTIONS threadlistoptions;
  2389.  
  2390.    if (!inifile || !WriteProfileData(inifile, "Options", "Threadlist",
  2391.                               &threadlistoptions, sizeof(threadlistoptions)))
  2392.       return 1;
  2393.    else
  2394.       return 0;
  2395. }
  2396.  
  2397. /*------------------------------ ReadIniCCLists  ----------------------------*/
  2398. /* Liesst die CCList-Optionen aus dem INI-File                               */
  2399. /*---------------------------------------------------------------------------*/
  2400.  
  2401. static  int ReadIniCCLists(HAB hab)
  2402. {
  2403.    extern CCANCHOR ccanchor;
  2404.    HINI ccini=NULLHANDLE;
  2405.    PCCLIST pList;
  2406.    char *pchApps;
  2407.    char *pchCurrentApp;
  2408.    ULONG datalen=0;
  2409.    ULONG ulAppsLen=0;
  2410.    ULONG ulID;
  2411.    ULONG namelen;
  2412.    char *pchName;
  2413.    char pchIniFile[LEN_PATHNAME+1];
  2414.  
  2415.    strcpy(pchIniFile, pchIniPath);
  2416.    strcat(pchIniFile, CCFILENAME);
  2417.  
  2418.    memset(&ccanchor, 0, sizeof(CCANCHOR));
  2419.  
  2420.    if (!(ccini=PrfOpenProfile(hab, pchIniFile)))
  2421.       return 1;
  2422.  
  2423.    if (!QueryProfileSize(ccini, NULL, NULL, &ulAppsLen) || (ulAppsLen==0))
  2424.    {
  2425.       PrfCloseProfile(ccini);
  2426.       return 1;
  2427.    }
  2428.  
  2429.    pchApps=malloc(ulAppsLen);
  2430.  
  2431.    if (!QueryProfileData(ccini, NULL, NULL, pchApps, &ulAppsLen))
  2432.    {
  2433.       free(pchApps);
  2434.       PrfCloseProfile(ccini);
  2435.       return 1;
  2436.    }
  2437.  
  2438.    pchCurrentApp=pchApps;
  2439.  
  2440.    while (pchCurrentApp[0])
  2441.    {
  2442.       if (!strcmp(pchCurrentApp, "Folder"))
  2443.       {
  2444.          datalen = sizeof(ccanchor.FolderPos);
  2445.          QueryProfileData(ccini, "Folder", "Pos", &ccanchor.FolderPos, &datalen);
  2446.          datalen = sizeof(ccanchor.ulFlags);
  2447.          QueryProfileData(ccini, "Folder", "Flags", &ccanchor.ulFlags, &datalen);
  2448.       }
  2449.       else
  2450.       {
  2451.          /* ID holen */
  2452.          ulID = strtoul(pchCurrentApp, NULL, 10);
  2453.          if (ulID)
  2454.          {
  2455.             /* Name holen */
  2456.             QueryProfileSize(ccini, pchCurrentApp, "Name", &namelen);
  2457.             pchName = malloc(namelen+1);
  2458.             QueryProfileString(ccini, pchCurrentApp, "Name", "", pchName, namelen);
  2459.  
  2460.             /* neue CC-Liste anlegen */
  2461.             pList = AddCCList(&ccanchor, pchName);
  2462.             free(pchName);
  2463.  
  2464.             /* ID ueberschreiben */
  2465.             pList->ulListID = ulID;
  2466.  
  2467.             /* Daten lesen */
  2468.             datalen = sizeof(pList->ListPos);
  2469.             QueryProfileData(ccini, pchCurrentApp, "Pos", &pList->ListPos, &datalen);
  2470.  
  2471.             datalen=sizeof(pList->ulFlags);
  2472.             QueryProfileData(ccini, pchCurrentApp, "Flags", &pList->ulFlags, &datalen);
  2473.  
  2474.             /* jetzt alle Eintraege lesen */
  2475.             ReadIniCCEntries(ccini, pchCurrentApp, pList);
  2476.  
  2477.             /* Dirty-Flags zuruecksetzen */
  2478.             pList->bDirty = FALSE;
  2479.             ccanchor.bDirty = FALSE;
  2480.          }
  2481.       }
  2482.       /* Naechste App suchen */
  2483.       while (pchCurrentApp[0])
  2484.          pchCurrentApp++;
  2485.       pchCurrentApp++;
  2486.    }
  2487.    free(pchApps);
  2488.    PrfCloseProfile(ccini);
  2489.    return 0;
  2490. }
  2491.  
  2492. static  int ReadIniCCEntries(HINI ccini, char *pchApp, PCCLIST pList)
  2493. {
  2494.    extern CCANCHOR ccanchor;
  2495.    char *pchKeys=NULL;
  2496.    ULONG ulKeysLen=0, ulEntryLen=0;
  2497.    char *pchCurrentKey=NULL;
  2498.    char *pchEntry;
  2499.    char *pchTemp;
  2500.    PCCENTRY pNewEntry;
  2501.  
  2502.    QueryProfileSize(ccini, pchApp, NULL, &ulKeysLen);
  2503.  
  2504.    if (ulKeysLen == 0)
  2505.       return -1;
  2506.  
  2507.    pchKeys=malloc(ulKeysLen);
  2508.  
  2509.    if (!QueryProfileData(ccini, pchApp, NULL, pchKeys, &ulKeysLen))
  2510.    {
  2511.       free(pchKeys);
  2512.       return -1;
  2513.    }
  2514.  
  2515.    pchCurrentKey=pchKeys;
  2516.  
  2517.    while (*pchCurrentKey)
  2518.    {
  2519.       if (*pchCurrentKey == '#') /* Pos und Flags nicht lesen */
  2520.       {
  2521.          /* daten lesen */
  2522.          QueryProfileSize(ccini, pchApp, pchCurrentKey, &ulEntryLen);
  2523.          if (ulEntryLen)
  2524.          {
  2525.             pchEntry = malloc(ulEntryLen);
  2526.             memset(pchEntry, 0, ulEntryLen);
  2527.             QueryProfileData(ccini, pchApp, pchCurrentKey, pchEntry, &ulEntryLen);
  2528.  
  2529.             /* neuen Eintrag holen */
  2530.             pNewEntry = AddCCEntry(&ccanchor, pList, NULL);
  2531.  
  2532.             /* Daten uebernehmen */
  2533.             pchTemp = pchEntry;
  2534.             strncpy(pNewEntry->pchName, pchTemp, LEN_USERNAME);
  2535.             pchTemp = strchr(pchTemp, 0)+1;
  2536.             strncpy(pNewEntry->pchAddress, pchTemp, LEN_5DADDRESS);
  2537.             pchTemp = strchr(pchTemp, 0)+1;
  2538.             pNewEntry->ulFlags = strtoul(pchTemp, NULL, 16);
  2539.             pchTemp = strchr(pchTemp, 0)+1;
  2540.             if (pchTemp-pchEntry < ulEntryLen)
  2541.             {
  2542.                strncpy(pNewEntry->pchFirstLine, pchTemp, LEN_FIRSTLINE);
  2543.             }
  2544.  
  2545.             free(pchEntry);
  2546.          }
  2547.       }
  2548.       /* Naechsten Key suchen */
  2549.       while (pchCurrentKey[0])
  2550.          pchCurrentKey++;
  2551.       pchCurrentKey++;
  2552.    }
  2553.    return 0;
  2554. }
  2555.  
  2556. /*------------------------------ SaveIniCCLists -----------------------------*/
  2557. /* Speichert die CCList-Optionen im INI-File                                 */
  2558. /*---------------------------------------------------------------------------*/
  2559.  
  2560. static  int SaveIniCCLists(HAB hab)
  2561. {
  2562.    extern CCANCHOR ccanchor;
  2563.    HINI ccini=NULLHANDLE;
  2564.    PCCLIST pList;
  2565.    char pchBuf[15];
  2566.    char *pchKeys;
  2567.    ULONG ulKeysLen;
  2568.    char *pchCurrentKey;
  2569.    char pchIniFile[LEN_PATHNAME+1];
  2570.  
  2571.    strcpy(pchIniFile, pchIniPath);
  2572.    strcat(pchIniFile, CCFILENAME);
  2573.  
  2574.    if (!(ccini=PrfOpenProfile(hab, pchIniFile)))
  2575.       return 1;
  2576.  
  2577.    /* Position sichern */
  2578.    WriteProfileData(ccini, "Folder", "Pos", &ccanchor.FolderPos, sizeof(ccanchor.FolderPos));
  2579.    WriteProfileData(ccini, "Folder", "Flags", &ccanchor.ulFlags, sizeof(ccanchor.ulFlags));
  2580.  
  2581.    pList=ccanchor.pLists;
  2582.  
  2583.    while(pList)   /* Alle Listen */
  2584.    {
  2585.       if (pList->bDirty)
  2586.       {
  2587.          /* Alte Eintraege loeschen */
  2588.          _itoa(pList->ulListID, pchBuf, 10);
  2589.          WriteProfileData(ccini, pchBuf, NULL, NULL, 0);
  2590.  
  2591.          /* Position, Name und Optionen */
  2592.          WriteProfileData(ccini, pchBuf, "Pos", &pList->ListPos, sizeof(pList->ListPos));
  2593.          WriteProfileData(ccini, pchBuf, "Flags", &pList->ulFlags, sizeof(pList->ulFlags));
  2594.          WriteProfileString(ccini, pchBuf, "Name", pList->pchListName);
  2595.  
  2596.          /* Eintraege sichern */
  2597.          SaveIniCCEntries(ccini, pchBuf, pList);
  2598.  
  2599.          pList->bDirty = FALSE;
  2600.       }
  2601.       pList = pList->next;
  2602.    }
  2603.  
  2604.    /* alle anderen Listen loeschen */
  2605.    QueryProfileSize(ccini, NULL, NULL, &ulKeysLen);
  2606.  
  2607.    pchKeys=malloc(ulKeysLen);
  2608.  
  2609.    QueryProfileData(ccini, NULL, NULL, pchKeys, &ulKeysLen);
  2610.  
  2611.    pchCurrentKey=pchKeys;
  2612.  
  2613.    while (*pchCurrentKey)
  2614.    {
  2615.       if (strcmp(pchCurrentKey, "Folder"))
  2616.       {
  2617.          ULONG ulID;
  2618.  
  2619.          ulID = strtoul(pchCurrentKey, NULL, 10);
  2620.          if (!QueryCCList(&ccanchor, ulID))
  2621.             WriteProfileData(ccini, pchCurrentKey, NULL, NULL, 0);
  2622.       }
  2623.  
  2624.       while (*pchCurrentKey)
  2625.          pchCurrentKey++;
  2626.       pchCurrentKey++;
  2627.    }
  2628.    free(pchKeys);
  2629.  
  2630.    ccanchor.bDirty = FALSE;
  2631.    PrfCloseProfile(ccini);
  2632.    return 0;
  2633. }
  2634.  
  2635. static  int SaveIniCCEntries(HINI ccini, char *pchApp, PCCLIST pList)
  2636. {
  2637.    char pchKey[20] = "#";
  2638.    char pchData[LEN_USERNAME+1+LEN_5DADDRESS+LEN_FIRSTLINE+1+10];
  2639.    char *pchDst;
  2640.    ULONG count = 1;
  2641.    PCCENTRY pEntry;
  2642.  
  2643.    pEntry = pList->pEntries;
  2644.  
  2645.    while (pEntry)
  2646.    {
  2647.       _itoa(count, pchKey+1, 10);
  2648.       pchDst = pchData;
  2649.  
  2650.       strcpy(pchDst, pEntry->pchName);
  2651.       pchDst = strchr(pchDst, 0)+1;
  2652.       strcpy(pchDst, pEntry->pchAddress);
  2653.       pchDst = strchr(pchDst, 0)+1;
  2654.       _itoa(pEntry->ulFlags, pchDst, 16);
  2655.       pchDst = strchr(pchDst, 0)+1;
  2656.       strcpy(pchDst, pEntry->pchFirstLine);
  2657.       pchDst = strchr(pchDst, 0)+1;
  2658.  
  2659.       WriteProfileData(ccini, pchApp, pchKey, pchData, pchDst-pchData);
  2660.  
  2661.       count++;
  2662.       pEntry = pEntry->next;
  2663.    }
  2664.  
  2665.    return 0;
  2666. }
  2667.  
  2668. /*------------------------------ ReadIntlSetting ----------------------------*/
  2669. /* Liesst die Settings fuer die Zeitanzeige ein                              */
  2670. /*---------------------------------------------------------------------------*/
  2671.  
  2672. static  int ReadIntlSetting(void)
  2673. {
  2674.    extern INTLSETTING intlsetting;
  2675.    char charbuf[10];
  2676.  
  2677.    intlsetting.DMY=QueryProfileInt(HINI_USERPROFILE, "PM_National",
  2678.                                       "iDate", 1);
  2679.    QueryProfileString(HINI_USERPROFILE, "PM_National", "sDate",
  2680.                          ".", charbuf, 10);
  2681.    intlsetting.h24=(BOOL)QueryProfileInt(HINI_USERPROFILE, "PM_National",
  2682.                                             "iTime", 1);
  2683.    intlsetting.datesep=charbuf[0];
  2684.    QueryProfileString(HINI_USERPROFILE, "PM_National", "sTime",
  2685.                          ":", charbuf, 10);
  2686.    intlsetting.timesep=charbuf[0];
  2687.    if (!QueryProfileString(HINI_USERPROFILE, "PM_National", "s1159", NULL,
  2688.                          intlsetting.amtext, 3))
  2689.       strcpy(intlsetting.amtext, "am");
  2690.    if (!QueryProfileString(HINI_USERPROFILE, "PM_National", "s2359", NULL,
  2691.                          intlsetting.pmtext, 3))
  2692.       strcpy(intlsetting.pmtext, "pm");
  2693.    return 0;
  2694. }
  2695.  
  2696. /*------------------------------ ReadIniLookup ------------------------------*/
  2697. /* Liesst die Lookup-Optionen aus dem INI-File                               */
  2698. /*---------------------------------------------------------------------------*/
  2699.  
  2700. static  int ReadIniLookup(HINI inifile)
  2701. {
  2702.    extern LOOKUPOPTIONS lookupoptions;
  2703.    ULONG datalen=0;
  2704.  
  2705.    datalen=sizeof(lookupoptions);
  2706.    if (!inifile || !QueryProfileData(inifile, "Options", "Lookup",
  2707.                             &lookupoptions, &datalen))
  2708.    {
  2709.       /* Default-Werte */
  2710.       lookupoptions.bBrief=TRUE;
  2711.       lookupoptions.lSplitBar=150;
  2712.       dirtyflags.lookupdirty=TRUE;
  2713.       return 1;
  2714.    }
  2715.    return 0;
  2716. }
  2717.  
  2718. /*------------------------------ SaveIniLookup ------------------------------*/
  2719. /* Speichert die Lookup-Optionen im INI-File                                 */
  2720. /*---------------------------------------------------------------------------*/
  2721.  
  2722. static  int SaveIniLookup(HINI inifile)
  2723. {
  2724.    extern LOOKUPOPTIONS lookupoptions;
  2725.  
  2726.    if (!inifile || !WriteProfileData(inifile, "Options", "Lookup",
  2727.                             &lookupoptions, sizeof(lookupoptions)))
  2728.       return 1;
  2729.    else
  2730.       return 0;
  2731. }
  2732.  
  2733. /*------------------------------ ReadIniResults -----------------------------*/
  2734. /* Liesst die Result-Optionen aus dem INI-File                               */
  2735. /*---------------------------------------------------------------------------*/
  2736.  
  2737. static  int ReadIniResults(HINI inifile)
  2738. {
  2739.    extern RESULTSOPTIONS resultsoptions;
  2740.    ULONG datalen=0;
  2741.  
  2742.    datalen=sizeof(resultsoptions);
  2743.    memset(&resultsoptions, 0, datalen);
  2744.    if (!inifile || !QueryProfileData(inifile, "Options", "Results",
  2745.                             &resultsoptions, &datalen))
  2746.    {
  2747.       /* Default-Werte */
  2748.       resultsoptions.bScroll=TRUE;
  2749.       resultsoptions.lSplitBar=150;
  2750.       resultsoptions.keepinfront=FALSE;
  2751.       dirtyflags.resultsdirty=TRUE;
  2752.       return 1;
  2753.    }
  2754.    return 0;
  2755. }
  2756.  
  2757. /*------------------------------ SaveIniResults -----------------------------*/
  2758. /* Speichert die Result-Optionen im INI-File                                 */
  2759. /*---------------------------------------------------------------------------*/
  2760.  
  2761. static  int SaveIniResults(HINI inifile)
  2762. {
  2763.    extern RESULTSOPTIONS resultsoptions;
  2764.  
  2765.    if (!inifile || !WriteProfileData(inifile, "Options", "Results",
  2766.                             &resultsoptions, sizeof(resultsoptions)))
  2767.       return 1;
  2768.    else
  2769.       return 0;
  2770. }
  2771.  
  2772. /*------------------------------ ReadIniRequest -----------------------------*/
  2773. /* Liesst die Request-Optionen aus dem INI-File                              */
  2774. /*---------------------------------------------------------------------------*/
  2775.  
  2776. static  int ReadIniRequest(HINI inifile)
  2777. {
  2778.    extern REQUESTOPT requestoptions;
  2779.    ULONG datalen=0;
  2780.    ULONG keylen;
  2781.  
  2782.    datalen=sizeof(requestoptions);
  2783.    memset(&requestoptions, 0, datalen);
  2784.    requestoptions.ulAttrib = ATTRIB_LOCAL | ATTRIB_CRASH | ATTRIB_KILLSENT |
  2785.                              ATTRIB_FREQUEST;
  2786.    requestoptions.lListFore = RGB_BLACK;
  2787.    requestoptions.lListBack = RGB_WHITE;
  2788.    if (!inifile)
  2789.       return 1;
  2790.    QueryProfileString(inifile, "Request", "Area", "", requestoptions.pchDestArea,
  2791.                          LEN_AREATAG+1);
  2792.    datalen=sizeof(requestoptions.bDirectReq);
  2793.    QueryProfileData(inifile, "Request", "Direct", &requestoptions.bDirectReq,
  2794.                        &datalen);
  2795.    datalen=sizeof(requestoptions.ulAttrib);
  2796.    QueryProfileData(inifile, "Request", "Attrib", &requestoptions.ulAttrib,
  2797.                        &datalen);
  2798.    datalen=sizeof(requestoptions.ReqPos);
  2799.    QueryProfileData(inifile, "Request", "RPos", &requestoptions.ReqPos,
  2800.                        &datalen);
  2801.    datalen=sizeof(requestoptions.ListAddPos);
  2802.    QueryProfileData(inifile, "Request", "LPos", &requestoptions.ListAddPos,
  2803.                        &datalen);
  2804.    datalen=sizeof(requestoptions.FileAddPos);
  2805.    QueryProfileData(inifile, "Request", "FPos", &requestoptions.FileAddPos,
  2806.                        &datalen);
  2807.    datalen=sizeof(requestoptions.PasswdPos);
  2808.    QueryProfileData(inifile, "Request", "PPos", &requestoptions.PasswdPos,
  2809.                        &datalen);
  2810.    datalen=sizeof(requestoptions.SearchPos);
  2811.    QueryProfileData(inifile, "Request", "SPos", &requestoptions.SearchPos,
  2812.                        &datalen);
  2813.    datalen=sizeof(requestoptions.lListFore);
  2814.    QueryProfileData(inifile, "Request", "LFore", &requestoptions.lListFore,
  2815.                        &datalen);
  2816.    datalen=sizeof(requestoptions.lListBack);
  2817.    QueryProfileData(inifile, "Request", "LBack", &requestoptions.lListBack,
  2818.                        &datalen);
  2819.    QueryProfileString(inifile, "Request", "LFont", "8.Helv", requestoptions.pchListFont,
  2820.                       sizeof(requestoptions.pchListFont));
  2821.    QueryProfileString(inifile, "Request", "Search", "", requestoptions.pchLastSearch,
  2822.                       sizeof(requestoptions.pchLastSearch));
  2823.    datalen=sizeof(requestoptions.ulSearchFlags);
  2824.    QueryProfileData(inifile, "Request", "SearchF", &requestoptions.ulSearchFlags,
  2825.                     &datalen);
  2826.  
  2827.    /* Listen lesen */
  2828.    if (QueryProfileSize(inifile, "FileLists", NULL, &keylen) && keylen)
  2829.    {
  2830.       char *pchKeys, *pchCurrentKey;
  2831.  
  2832.       pchKeys = malloc(keylen);
  2833.  
  2834.       if (QueryProfileData(inifile, "FileLists", NULL, pchKeys, &keylen))
  2835.       {
  2836.          char pchVal[LEN_PATHNAME+1+LEN_5DADDRESS+1+LEN_LISTDESC+1];
  2837.          char *pchTemp;
  2838.          FILELIST FileList;
  2839.  
  2840.          pchCurrentKey = pchKeys;
  2841.  
  2842.          while (*pchCurrentKey)
  2843.          {
  2844.             if (*pchCurrentKey == '#')
  2845.             {
  2846.                datalen = sizeof(pchVal);
  2847.                QueryProfileData(inifile, "FileLists", pchCurrentKey, pchVal, &datalen);
  2848.  
  2849.                memset(&FileList, 0, sizeof(FileList));
  2850.  
  2851.                /* Daten kopieren */
  2852.                pchTemp = pchVal;
  2853.                strncpy(FileList.pchFileName, pchTemp, LEN_PATHNAME);
  2854.                pchTemp = strchr(pchTemp, '\0');
  2855.                pchTemp++;
  2856.                strncpy(FileList.pchAddress, pchTemp, LEN_5DADDRESS);
  2857.                pchTemp = strchr(pchTemp, '\0');
  2858.                pchTemp++;
  2859.                strncpy(FileList.pchDesc, pchTemp, LEN_LISTDESC);
  2860.  
  2861.                AddNewFileList(&requestoptions.pFirstList, &FileList, NULL);
  2862.             }
  2863.             while (*pchCurrentKey)
  2864.                pchCurrentKey++;
  2865.             pchCurrentKey++;
  2866.          }
  2867.       }
  2868.  
  2869.       free (pchKeys);
  2870.    }
  2871.  
  2872.    return 0;
  2873. }
  2874.  
  2875. /*------------------------------ SaveIniRequest -----------------------------*/
  2876. /* Speichert die Request-Optionen im INI-File                                */
  2877. /*---------------------------------------------------------------------------*/
  2878.  
  2879. static int SaveIniRequest(HINI inifile)
  2880. {
  2881.    extern REQUESTOPT requestoptions;
  2882.  
  2883.    if (!inifile)
  2884.       return 1;
  2885.  
  2886.    if (requestoptions.bDirty)
  2887.    {
  2888.       WriteProfileString(inifile, "Request", "Area", requestoptions.pchDestArea);
  2889.       WriteProfileData(inifile, "Request", "Direct", &requestoptions.bDirectReq,
  2890.                           sizeof(requestoptions.bDirectReq));
  2891.       WriteProfileData(inifile, "Request", "Attrib", &requestoptions.ulAttrib,
  2892.                           sizeof(requestoptions.ulAttrib));
  2893.       WriteProfileData(inifile, "Request", "RPos", &requestoptions.ReqPos,
  2894.                           sizeof(requestoptions.ReqPos));
  2895.       WriteProfileData(inifile, "Request", "LPos", &requestoptions.ListAddPos,
  2896.                           sizeof(requestoptions.ListAddPos));
  2897.       WriteProfileData(inifile, "Request", "FPos", &requestoptions.FileAddPos,
  2898.                           sizeof(requestoptions.FileAddPos));
  2899.       WriteProfileData(inifile, "Request", "PPos", &requestoptions.PasswdPos,
  2900.                           sizeof(requestoptions.PasswdPos));
  2901.       WriteProfileData(inifile, "Request", "SPos", &requestoptions.SearchPos,
  2902.                           sizeof(requestoptions.SearchPos));
  2903.       WriteProfileData(inifile, "Request", "LFore", &requestoptions.lListFore,
  2904.                           sizeof(requestoptions.lListFore));
  2905.       WriteProfileData(inifile, "Request", "LBack", &requestoptions.lListBack,
  2906.                           sizeof(requestoptions.lListBack));
  2907.       WriteProfileString(inifile, "Request", "LFont", requestoptions.pchListFont);
  2908.       WriteProfileString(inifile, "Request", "Search", requestoptions.pchLastSearch);
  2909.       WriteProfileData(inifile, "Request", "SearchF", &requestoptions.ulSearchFlags,
  2910.                           sizeof(requestoptions.ulSearchFlags));
  2911.  
  2912.       requestoptions.bDirty = FALSE;
  2913.    }
  2914.  
  2915.    if (requestoptions.bListDirty)
  2916.    {
  2917.       PFILELIST pTemp = requestoptions.pFirstList;
  2918.       int num=1;
  2919.       char pchKey[10]="#";
  2920.       char pchVal[LEN_PATHNAME+1+LEN_5DADDRESS+1+LEN_LISTDESC+1];
  2921.       char *pchTemp;
  2922.  
  2923.       /* alte Listen Loeschen */
  2924.       WriteProfileData(inifile, "FileLists", NULL, NULL, 0);
  2925.  
  2926.       /* Listen speichern */
  2927.       while (pTemp)
  2928.       {
  2929.          /* Value zusammenkopieren */
  2930.  
  2931.          pchTemp = pchVal;
  2932.          strcpy(pchTemp, pTemp->pchFileName);
  2933.          pchTemp = strchr(pchTemp, '\0');
  2934.          pchTemp++;
  2935.          strcpy(pchTemp, pTemp->pchAddress);
  2936.          pchTemp = strchr(pchTemp, '\0');
  2937.          pchTemp++;
  2938.          strcpy(pchTemp, pTemp->pchDesc);
  2939.          pchTemp = strchr(pchTemp, '\0');
  2940.          pchTemp++;
  2941.  
  2942.          /* Key erzeugen */
  2943.          _itoa(num, pchKey+1, 10);
  2944.  
  2945.          /* schreiben */
  2946.          WriteProfileData(inifile, "FileLists", pchKey, pchVal, pchTemp - pchVal);
  2947.  
  2948.          pTemp->bDirty = FALSE;
  2949.  
  2950.          pTemp = pTemp->next;
  2951.          num++;
  2952.       }
  2953.  
  2954.       requestoptions.bListDirty = FALSE;
  2955.    }
  2956.  
  2957.    return 0;
  2958. }
  2959.  
  2960. /*------------------------------ ReadIniAreaList ----------------------------*/
  2961. /* Liesst die Arealist-Optionen aus dem INI-File                             */
  2962. /*---------------------------------------------------------------------------*/
  2963.  
  2964. static  int ReadIniAreaList(HINI inifile)
  2965. {
  2966.    extern AREALISTOPTIONS arealistoptions;
  2967.    ULONG datalen=0;
  2968.  
  2969.    datalen=sizeof(arealistoptions);
  2970.    memset(&arealistoptions, 0, datalen);
  2971.  
  2972.    arealistoptions.lBackColor=RGB_WHITE;
  2973.    arealistoptions.lFolderBack=RGB_WHITE;
  2974.    arealistoptions.lNetAreaColor=RGB_BLACK;
  2975.    arealistoptions.lEchoAreaColor=RGB_BLACK;
  2976.    arealistoptions.lLocalAreaColor=RGB_BLACK;
  2977.    arealistoptions.lFolderFore=RGB_BLACK;
  2978.  
  2979.    if (!inifile || QueryProfileData(inifile, "Options", "Arealist",
  2980.                                        &arealistoptions,
  2981.                                        &datalen))
  2982.    {
  2983.       dirtyflags.alsettingsdirty=TRUE;
  2984.    }
  2985.  
  2986.    return 0;
  2987. }
  2988.  
  2989. /*------------------------------ SaveIniAreaList ----------------------------*/
  2990. /* Speichert die Arealist-Optionen im INI-File                               */
  2991. /*---------------------------------------------------------------------------*/
  2992.  
  2993. static  int SaveIniAreaList(HINI inifile)
  2994. {
  2995.    extern AREALISTOPTIONS arealistoptions;
  2996.  
  2997.    if (!inifile)
  2998.       return 1;
  2999.  
  3000.    WriteProfileData(inifile, "Options", "Arealist", &arealistoptions,
  3001.                        sizeof(arealistoptions));
  3002.    return 0;
  3003. }
  3004.  
  3005. /*------------------------------ ReadIniMsgList -----------------------------*/
  3006. /* Liesst die Messagelist-Optionen aus dem INI-File                          */
  3007. /*---------------------------------------------------------------------------*/
  3008.  
  3009. static  int ReadIniMsgList(HINI inifile)
  3010. {
  3011.    extern MSGLISTOPTIONS msglistoptions;
  3012.    ULONG datalen=0;
  3013.  
  3014.    datalen=sizeof(msglistoptions);
  3015.    memset(&msglistoptions, 0, datalen);
  3016.  
  3017.    msglistoptions.ulNrPercent   =  70;
  3018.    msglistoptions.ulFromPercent = 150;
  3019.    msglistoptions.ulToPercent   = 150;
  3020.    msglistoptions.ulSubjPercent = 350;
  3021.    msglistoptions.ulStampWrittenPercent = 140;
  3022.    msglistoptions.ulStampArrivedPercent = 140;
  3023.  
  3024.    msglistoptions.lBackClr   = RGB_WHITE;
  3025.    msglistoptions.lForeClr   = RGB_BLACK;
  3026.    msglistoptions.lUnreadClr = RGB_RED;
  3027.    msglistoptions.lFromClr   = RGB_RED;
  3028.    msglistoptions.lToClr     = RGB_RED;
  3029.  
  3030.    strcpy(msglistoptions.mlistfont, SMA_FONT);
  3031.  
  3032.    if (!inifile || QueryProfileData(inifile, "Options", "Msglist",
  3033.                                        &msglistoptions,
  3034.                                        &datalen))
  3035.    {
  3036.       dirtyflags.alsettingsdirty=TRUE;
  3037.    }
  3038.  
  3039.    return 0;
  3040. }
  3041.  
  3042. /*------------------------------ SaveIniMsgList -----------------------------*/
  3043. /* Speichert die Messagelist-Optionen im INI-File                            */
  3044. /*---------------------------------------------------------------------------*/
  3045.  
  3046. static  int SaveIniMsgList(HINI inifile)
  3047. {
  3048.    extern MSGLISTOPTIONS msglistoptions;
  3049.  
  3050.    if (!inifile)
  3051.       return 1;
  3052.  
  3053.    WriteProfileData(inifile, "Options", "Msglist", &msglistoptions,
  3054.                        sizeof(msglistoptions));
  3055.    return 0;
  3056. }
  3057.  
  3058. /*------------------------------ SaveIniRemap   -----------------------------*/
  3059. /* Speichert die Remap-Optionen im INI-File                                  */
  3060. /*---------------------------------------------------------------------------*/
  3061.  
  3062. static  int SaveIniRemap(HINI inifile)
  3063. {
  3064.    extern DRIVEREMAP driveremap;
  3065.  
  3066.    if (!inifile)
  3067.       return 1;
  3068.  
  3069.    WriteProfileString(inifile, "Options", "Remap",
  3070.                          driveremap.pchRemapString);
  3071.  
  3072.    return 0;
  3073. }
  3074.  
  3075. /*------------------------------ ReadIniRemap   -----------------------------*/
  3076. /* Laedt     die Remap-Optionen im INI-File                                  */
  3077. /*---------------------------------------------------------------------------*/
  3078.  
  3079. static  int ReadIniRemap(HINI inifile)
  3080. {
  3081.    extern DRIVEREMAP driveremap;
  3082.  
  3083.    /* Default belegen */
  3084.    strcpy(driveremap.pchRemapString, "CDEFGHIJKLMNOPQRSTUVWXYZ");
  3085.  
  3086.    if (!inifile)
  3087.       return 1;
  3088.  
  3089.    QueryProfileString(inifile, "Options", "Remap", "CDEFGHIJKLMNOPQRSTUVWXYZ",
  3090.                          driveremap.pchRemapString, 25);
  3091.  
  3092.    return 0;
  3093. }
  3094.  
  3095. /*------------------------------ SaveIniScripts -----------------------------*/
  3096. /* Speichert die Scripts im INI-File                                         */
  3097. /*---------------------------------------------------------------------------*/
  3098.  
  3099. static  int SaveIniScripts(HAB hab)
  3100. {
  3101.    extern SCRIPTLIST scriptlist;
  3102.    PRXSCRIPT pScript;
  3103.    HINI hini;
  3104.    char *pchApps, *pchCurrentApp;
  3105.    ULONG ulLen;
  3106.    char pchTemp[20]="#";
  3107.    ULONG ulID;
  3108.    char pchIniFile[LEN_PATHNAME+1];
  3109.  
  3110.    strcpy(pchIniFile, pchIniPath);
  3111.    strcat(pchIniFile, SCRIPTFILENAME);
  3112.  
  3113.  
  3114.    if (!(hini = PrfOpenProfile(hab, pchIniFile)))
  3115.    {
  3116.       return 1;
  3117.    }
  3118.  
  3119.    WriteProfileData(hini, "Folder", "Pos", &scriptlist.FolderPos, sizeof(WINPOS));
  3120.    WriteProfileData(hini, "Folder", "SPos", &scriptlist.FolderSettingsPos, sizeof(WINPOS));
  3121.    WriteProfileData(hini, "Folder", "Flags", &scriptlist.ulFlags, sizeof(ULONG));
  3122.  
  3123.    pScript = scriptlist.pScripts;
  3124.    while (pScript)
  3125.    {
  3126.       if (pScript->bDirty)
  3127.       {
  3128.          /* App-Name erzeugen */
  3129.          _itoa(pScript->ulScriptID, pchTemp+1, 10);
  3130.  
  3131.          WriteProfileData(hini, pchTemp, "SettP", &pScript->SettingsPos, sizeof(WINPOS));
  3132.          WriteProfileData(hini, pchTemp, "MonP",  &pScript->MonitorPos, sizeof(WINPOS));
  3133.  
  3134.          WriteProfileString(hini, pchTemp, "Name", pScript->pchScriptName);
  3135.          WriteProfileString(hini, pchTemp, "File", pScript->pchPathName);
  3136.  
  3137.          WriteProfileData(hini, pchTemp, "Flags",  &pScript->ulFlags, sizeof(ULONG));
  3138.  
  3139.          pScript->bDirty = FALSE;
  3140.       }
  3141.  
  3142.       pScript = pScript->next;
  3143.    }
  3144.  
  3145.    /* geloeschte Scripts pruefen */
  3146.    QueryProfileSize(hini, NULL, NULL, &ulLen);
  3147.  
  3148.    if (ulLen == 0)
  3149.       return 1;
  3150.  
  3151.    pchApps = malloc(ulLen);
  3152.  
  3153.    QueryProfileData(hini, NULL, NULL, pchApps, &ulLen);
  3154.  
  3155.    pchCurrentApp = pchApps;
  3156.    while (*pchCurrentApp)
  3157.    {
  3158.       if (*pchCurrentApp == '#')
  3159.       {
  3160.          /* ID ermitteln */
  3161.          ulID = strtoul(pchCurrentApp+1, NULL, 10);
  3162.  
  3163.          pScript = scriptlist.pScripts;
  3164.          while (pScript && pScript->ulScriptID != ulID)
  3165.             pScript = pScript->next;
  3166.  
  3167.          if (!pScript)
  3168.             WriteProfileData(hini, pchCurrentApp, NULL, NULL, 0);
  3169.       }
  3170.  
  3171.       while (*pchCurrentApp)
  3172.          pchCurrentApp++;
  3173.       pchCurrentApp++;
  3174.    }
  3175.  
  3176.    free(pchApps);
  3177.    PrfCloseProfile(hini);
  3178.  
  3179.    scriptlist.bDirty = FALSE;
  3180.  
  3181.    return 0;
  3182. }
  3183.  
  3184. /*------------------------------ ReadIniScripts -----------------------------*/
  3185. /* Laedt die Scripts aus dem INI-File                                        */
  3186. /*---------------------------------------------------------------------------*/
  3187.  
  3188. static int ReadIniScripts(HAB hab)
  3189. {
  3190.    extern SCRIPTLIST scriptlist;
  3191.    HINI hini;
  3192.    PRXSCRIPT pScript=NULL, pNewScript, pLastScript=NULL;
  3193.    char *pchApps, *pchCurrentApp;
  3194.    ULONG ulLen;
  3195.    char pchIniFile[LEN_PATHNAME+1];
  3196.  
  3197.    strcpy(pchIniFile, pchIniPath);
  3198.    strcat(pchIniFile, SCRIPTFILENAME);
  3199.  
  3200.    memset(&scriptlist, 0, sizeof(SCRIPTLIST));
  3201.  
  3202.    if (!(hini = PrfOpenProfile(hab, pchIniFile)))
  3203.    {
  3204.       return 1;
  3205.    }
  3206.  
  3207.    ulLen = sizeof(WINPOS);
  3208.    QueryProfileData(hini, "Folder", "Pos", &scriptlist.FolderPos, &ulLen);
  3209.    ulLen = sizeof(WINPOS);
  3210.    QueryProfileData(hini, "Folder", "SPos", &scriptlist.FolderSettingsPos, &ulLen);
  3211.    ulLen = sizeof(ULONG);
  3212.    QueryProfileData(hini, "Folder", "Flags", &scriptlist.ulFlags, &ulLen);
  3213.  
  3214.    QueryProfileSize(hini, NULL, NULL, &ulLen);
  3215.    if (ulLen == 0)
  3216.       return 1;
  3217.    pchApps = malloc(ulLen);
  3218.    QueryProfileData(hini, NULL, NULL, pchApps, &ulLen);
  3219.  
  3220.    pchCurrentApp = pchApps;
  3221.    while (*pchCurrentApp)
  3222.    {
  3223.       if (*pchCurrentApp == '#')
  3224.       {
  3225.          /* neues Script erzeugen */
  3226.          pNewScript = malloc(sizeof(RXSCRIPT));
  3227.          memset(pNewScript, 0, sizeof(RXSCRIPT));
  3228.  
  3229.          /* ID ermitteln */
  3230.          pNewScript->ulScriptID = strtoul(pchCurrentApp+1, NULL, 10);
  3231.  
  3232.          /* Einfuege-Position suchen */
  3233.          pScript = scriptlist.pScripts;
  3234.  
  3235.          while (pScript && pScript->ulScriptID < pNewScript->ulScriptID)
  3236.             pScript = pScript->next;
  3237.  
  3238.          if (pScript)
  3239.          {
  3240.             /* davor einhaengen */
  3241.             pNewScript->next = pScript;
  3242.             pNewScript->prev = pScript->prev;
  3243.  
  3244.             if (pScript->prev)
  3245.                pScript->prev->next = pNewScript;
  3246.             pScript->prev = pNewScript;
  3247.  
  3248.             if (scriptlist.pScripts == pScript) /* vor dem ersten, Anker anpassen */
  3249.                scriptlist.pScripts = pNewScript;
  3250.          }
  3251.          else
  3252.          {
  3253.             if (!scriptlist.pScripts) /* erstes Script ueberhaupt */
  3254.             {
  3255.                scriptlist.pScripts = pNewScript;
  3256.                pLastScript = pNewScript;
  3257.             }
  3258.             else
  3259.             {
  3260.                /* nicht gefunden, am Ende einhaengen */
  3261.                pLastScript->next = pNewScript;
  3262.                pNewScript->prev = pLastScript;
  3263.                pLastScript = pNewScript;
  3264.             }
  3265.          }
  3266.  
  3267.  
  3268.          scriptlist.ulNumScripts++;
  3269.  
  3270.          /* Pos lesen */
  3271.          ulLen = sizeof(WINPOS);
  3272.          QueryProfileData(hini, pchCurrentApp, "SettP", &pNewScript->SettingsPos, &ulLen);
  3273.          ulLen = sizeof(WINPOS);
  3274.          QueryProfileData(hini, pchCurrentApp, "MonP", &pNewScript->MonitorPos, &ulLen);
  3275.  
  3276.          /* Name lesen */
  3277.          QueryProfileSize(hini, pchCurrentApp, "Name", &ulLen);
  3278.  
  3279.          pNewScript->pchScriptName = malloc(ulLen+1);
  3280.          pNewScript->pchScriptName[0] = '\0';
  3281.  
  3282.          if (ulLen)
  3283.          {
  3284.             QueryProfileString(hini, pchCurrentApp, "Name", "", pNewScript->pchScriptName, ulLen+1);
  3285.          }
  3286.  
  3287.          /* Pfad lesen */
  3288.          QueryProfileString(hini, pchCurrentApp, "File", "", pNewScript->pchPathName, LEN_PATHNAME+1);
  3289.  
  3290.          /* Optionen */
  3291.          ulLen = sizeof(ULONG);
  3292.          QueryProfileData(hini, pchCurrentApp, "Flags", &pNewScript->ulFlags, &ulLen);
  3293.       }
  3294.  
  3295.       while (*pchCurrentApp)
  3296.          pchCurrentApp++;
  3297.       pchCurrentApp++;
  3298.    }
  3299.  
  3300.    free(pchApps);
  3301.    PrfCloseProfile(hini);
  3302.  
  3303.  
  3304.    return 0;
  3305. }
  3306.  
  3307. /*------------------------------ SaveIniHooks   -----------------------------*/
  3308. /* Speichert die Hook-Settings im INI-File                                   */
  3309. /*---------------------------------------------------------------------------*/
  3310.  
  3311. static  int SaveIniHooks(HINI inifile)
  3312. {
  3313.    extern REXXHOOKS rexxhooks;
  3314.  
  3315.    if (!inifile)
  3316.       return 1;
  3317.  
  3318.    WriteProfileData(inifile, "Options", "Hooks", &rexxhooks, sizeof(rexxhooks));
  3319.  
  3320.    return 0;
  3321. }
  3322.  
  3323. /*------------------------------ ReadIniHooks   -----------------------------*/
  3324. /* Laedt die Hook-Settings aus dem INI-File                                  */
  3325. /*---------------------------------------------------------------------------*/
  3326.  
  3327. static  int ReadIniHooks(HINI inifile)
  3328. {
  3329.    extern REXXHOOKS rexxhooks;
  3330.    ULONG ulLen;
  3331.  
  3332.    memset(&rexxhooks, 0, sizeof(rexxhooks));
  3333.  
  3334.    if (!inifile)
  3335.       return 1;
  3336.  
  3337.    ulLen = sizeof(rexxhooks);
  3338.    QueryProfileData(inifile, "Options", "Hooks", &rexxhooks, &ulLen);
  3339.  
  3340.    return 0;
  3341. }
  3342.  
  3343. /*------------------------------ ReadIniFind    -----------------------------*/
  3344. /* Laedt die Find-Settings aus dem INI-File                                  */
  3345. /*---------------------------------------------------------------------------*/
  3346.  
  3347. static int ReadIniFind(HINI inifile)
  3348. {
  3349.    extern FINDJOB FindJob;
  3350.    extern BOOL bSaveResults;
  3351.    ULONG datalen;
  3352.    char *pchBlock;
  3353.    char *pchSrc;
  3354.    int i=0;
  3355.  
  3356.    memset(&FindJob, 0, sizeof(FINDJOB));
  3357.    FindJob.ulWhere = FINDWHERE_FROM |
  3358.                      FINDWHERE_TO   |
  3359.                      FINDWHERE_SUBJ |
  3360.                      FINDWHERE_TEXT;
  3361.    FindJob.ulHow = FINDHOW_CASE;
  3362.    FindJob.ulWAreas = FINDAREAS_ECHO;
  3363.    bSaveResults = TRUE;
  3364.  
  3365.    if (!inifile)
  3366.       return 1;
  3367.  
  3368.    datalen=0;
  3369.    QueryProfileSize(inifile, "Find", "Text", &datalen);
  3370.    if (datalen)
  3371.    {
  3372.       pchBlock = calloc(datalen, 1);
  3373.       pchSrc = pchBlock;
  3374.  
  3375.       QueryProfileData(inifile, "Find", "Text", pchBlock, &datalen);
  3376.  
  3377.       while (i < NUM_BACKTEXTS)
  3378.       {
  3379.          strcpy(FindJob.pchBackTexts[i], pchSrc);
  3380.          pchSrc = strchr(pchSrc, 0);
  3381.          pchSrc++;
  3382.          i++;
  3383.       }
  3384.       free(pchBlock);
  3385.    }
  3386.  
  3387.    datalen=sizeof(FindJob.ulWhere);
  3388.    QueryProfileData(inifile, "Find", "Parts", &FindJob.ulWhere, &datalen);
  3389.    datalen=sizeof(FindJob.ulHow);
  3390.    QueryProfileData(inifile, "Find", "Method", &FindJob.ulHow, &datalen);
  3391.    datalen=sizeof(FindJob.ulWAreas);
  3392.    QueryProfileData(inifile, "Find", "Areas", &FindJob.ulWAreas, &datalen);
  3393.    FindJob.ulFuzzyLevel = QueryProfileInt(inifile, "Find", "Fuzz", 1);
  3394.  
  3395.    datalen=0;
  3396.    QueryProfileSize(inifile, "Find", "SelAreas", &datalen);
  3397.    if (datalen)
  3398.    {
  3399.       FindJob.pchAreas = calloc(1, datalen);
  3400.       QueryProfileString(inifile, "Find", "SelAreas", "", FindJob.pchAreas, datalen);
  3401.    }
  3402.  
  3403.    datalen=sizeof(FindJob.PersMailOpt);
  3404.    QueryProfileData(inifile, "Find", "PersMail", &FindJob.PersMailOpt, &datalen);
  3405.  
  3406.    datalen=sizeof(bSaveResults);
  3407.    QueryProfileData(inifile, "Find", "Save", &bSaveResults, &datalen);
  3408.  
  3409.    return 0;
  3410. }
  3411.  
  3412. /*------------------------------ SaveIniFind    -----------------------------*/
  3413. /* Speichert die Find-Settings im INI-File                                   */
  3414. /*---------------------------------------------------------------------------*/
  3415.  
  3416. static int SaveIniFind(HINI inifile)
  3417. {
  3418.    extern FINDJOB FindJob;
  3419.    extern BOOL bSaveResults;
  3420.    char *pchBlock;
  3421.    char *pchDest;
  3422.    int i=0;
  3423.  
  3424.    if (!inifile)
  3425.       return 1;
  3426.  
  3427.    pchBlock = malloc(sizeof(FindJob.pchBackTexts));
  3428.    pchDest = pchBlock;
  3429.  
  3430.    while (i< NUM_BACKTEXTS)
  3431.    {
  3432.       strcpy(pchDest, FindJob.pchBackTexts[i]);
  3433.       pchDest = strchr(pchDest, 0);
  3434.       pchDest++;
  3435.       i++;
  3436.    }
  3437.  
  3438.    WriteProfileData(inifile, "Find", "Text", pchBlock, pchDest - pchBlock);
  3439.    free(pchBlock);
  3440.  
  3441.    WriteProfileString(inifile, "Find", "SelAreas", FindJob.pchAreas);
  3442.    WriteProfileData(inifile, "Find", "Parts", &FindJob.ulWhere, sizeof(FindJob.ulWhere));
  3443.    WriteProfileData(inifile, "Find", "Method", &FindJob.ulHow, sizeof(FindJob.ulHow));
  3444.    WriteProfileData(inifile, "Find", "Areas", &FindJob.ulWAreas, sizeof(FindJob.ulWAreas));
  3445.    WriteProfileData(inifile, "Find", "PersMail", &FindJob.PersMailOpt, sizeof(FindJob.PersMailOpt));
  3446.    WriteProfileInt(inifile, "Find", "Fuzz", FindJob.ulFuzzyLevel);
  3447.    WriteProfileData(inifile, "Find", "Save", &bSaveResults, sizeof(bSaveResults));
  3448.  
  3449.    return 0;
  3450. }
  3451.  
  3452. static int ReadIniBrowse(HINI inifile)
  3453. {
  3454.    extern BROWSEROPTIONS BrowserOptions;
  3455.    ULONG datalen;
  3456.  
  3457.    memset(&BrowserOptions, 0, sizeof(BrowserOptions));
  3458.    BrowserOptions.lSplitbar = 150;
  3459.    BrowserOptions.bIcons    = TRUE;
  3460.  
  3461.    if (!inifile)
  3462.       return 1;
  3463.  
  3464.    datalen = sizeof(BrowserOptions.BrowserPos);
  3465.    QueryProfileData(inifile, "NLBrowse", "Pos", &BrowserOptions.BrowserPos, &datalen);
  3466.  
  3467.    BrowserOptions.ulLastMode = QueryProfileInt(inifile, "NLBrowse", "Mode", BROWSEMODE_NODE);
  3468.    BrowserOptions.lSplitbar  = QueryProfileInt(inifile, "NLBrowse", "Split", 150);
  3469.    BrowserOptions.bIcons     = QueryProfileInt(inifile, "NLBrowse", "Icons", 1);
  3470.    BrowserOptions.bNoPoints  = QueryProfileInt(inifile, "NLBrowse", "NoPoints", 0);
  3471.  
  3472.    QueryProfileString(inifile, "NLBrowse", "Domain", "", BrowserOptions.pchLastDomain, sizeof(BrowserOptions.pchLastDomain));
  3473.  
  3474.    return 0;
  3475. }
  3476.  
  3477. static int SaveIniBrowse(HINI inifile)
  3478. {
  3479.    extern BROWSEROPTIONS BrowserOptions;
  3480.  
  3481.    if (!inifile)
  3482.       return 1;
  3483.  
  3484.    if (!WriteProfileString(inifile, "NLBrowse", "Domain", BrowserOptions.pchLastDomain))
  3485.       DosBeep(100, 100);
  3486.  
  3487.    WriteProfileInt(inifile, "NLBrowse", "Mode", BrowserOptions.ulLastMode);
  3488.    WriteProfileInt(inifile, "NLBrowse", "Split", BrowserOptions.lSplitbar);
  3489.    WriteProfileInt(inifile, "NLBrowse", "Icons", BrowserOptions.bIcons);
  3490.    WriteProfileInt(inifile, "NLBrowse", "NoPoints", BrowserOptions.bNoPoints);
  3491.    WriteProfileData(inifile, "NLBrowse", "Pos", &BrowserOptions.BrowserPos, sizeof(BrowserOptions.BrowserPos));
  3492.  
  3493.    return 0;
  3494. }
  3495.  
  3496. static int SaveIniExport(HINI inifile)
  3497. {
  3498.    extern ULONG ulExportOptions;
  3499.    extern PATHNAMES pathnames;
  3500.  
  3501.    if (!inifile)
  3502.       return 1;
  3503.  
  3504.    WriteProfileInt(inifile, "Export", "Options", ulExportOptions);
  3505.    WriteProfileString(inifile, "Export", "Path", pathnames.lastexport);
  3506.  
  3507.    return 0;
  3508. }
  3509.  
  3510. static int ReadIniExport(HINI inifile)
  3511. {
  3512.    extern ULONG ulExportOptions;
  3513.    extern PATHNAMES pathnames;
  3514.  
  3515.    if (!inifile)
  3516.       return 1;
  3517.  
  3518.    ulExportOptions = QueryProfileInt(inifile, "Export", "Options", 0x01 | 0x02);
  3519.  
  3520.    QueryProfileString(inifile, "Export", "Path", "", pathnames.lastexport, LEN_PATHNAME+1);
  3521.  
  3522.    return 0;
  3523. }
  3524.  
  3525. static int ReadIniToolbar(HINI inifile)
  3526. {
  3527.    extern TOOLBAROPTIONS ToolbarOptions;
  3528.    extern TOOLBARCONFIG  ToolbarConfig;
  3529.    ULONG ulLen;
  3530.  
  3531.    if (!inifile)
  3532.    {
  3533.       LoadDefaultToolbar(&ToolbarConfig);
  3534.       return 1;
  3535.    }
  3536.  
  3537.    ToolbarOptions.ulToolbarPos = QueryProfileInt(inifile, "Toolbar", "Pos", 0);
  3538.    ToolbarOptions.bSmallToolbar = QueryProfileInt(inifile, "Toolbar", "Small", 0);
  3539.  
  3540.    ulLen = sizeof(WINPOS);
  3541.    QueryProfileData(inifile, "Toolbar", "CPos", &ToolbarConfig.SelectPos, &ulLen);
  3542.    ulLen = sizeof(LONG);
  3543.    ToolbarConfig.lLeftFore = RGB_BLACK;
  3544.    QueryProfileData(inifile, "Toolbar", "LFore", &ToolbarConfig.lLeftFore, &ulLen);
  3545.    ulLen = sizeof(LONG);
  3546.    ToolbarConfig.lRightFore = RGB_BLACK;
  3547.    QueryProfileData(inifile, "Toolbar", "RFore", &ToolbarConfig.lRightFore, &ulLen);
  3548.    ulLen = sizeof(LONG);
  3549.    ToolbarConfig.lLeftBack = RGB_WHITE;
  3550.    QueryProfileData(inifile, "Toolbar", "LBack", &ToolbarConfig.lLeftBack, &ulLen);
  3551.    ulLen = sizeof(LONG);
  3552.    ToolbarConfig.lRightBack = RGB_WHITE;
  3553.    QueryProfileData(inifile, "Toolbar", "RBack", &ToolbarConfig.lRightBack, &ulLen);
  3554.    QueryProfileString(inifile, "Toolbar", "LFont", "8.Helv", ToolbarConfig.pchLeftFont, sizeof(ToolbarConfig.pchLeftFont));
  3555.    QueryProfileString(inifile, "Toolbar", "RFont", "8.Helv", ToolbarConfig.pchRightFont, sizeof(ToolbarConfig.pchRightFont));
  3556.  
  3557.    if (!QueryProfileSize(inifile, "Toolbar", "Config", &ulLen))
  3558.       LoadDefaultToolbar(&ToolbarConfig);
  3559.    else
  3560.    {
  3561.       if (ulLen > 1)
  3562.       {
  3563.          ToolbarConfig.pButtons = malloc(ulLen);
  3564.          QueryProfileData(inifile, "Toolbar", "Config", ToolbarConfig.pButtons, &ulLen);
  3565.          ToolbarConfig.ulNumButtons = ulLen / sizeof(BUTTONCONFIG);
  3566.       }
  3567.       else
  3568.       {
  3569.          ToolbarConfig.pButtons = NULL;
  3570.          ToolbarConfig.ulNumButtons = 0;
  3571.       }
  3572.    }
  3573.  
  3574.    return 0;
  3575. }
  3576.  
  3577. static int SaveIniToolbar(HINI inifile)
  3578. {
  3579.    extern TOOLBAROPTIONS ToolbarOptions;
  3580.    extern TOOLBARCONFIG  ToolbarConfig;
  3581.    char pchBuffer[20];
  3582.  
  3583.    if (!inifile)
  3584.       return 1;
  3585.  
  3586.    if (dirtyflags.toolbardirty)
  3587.    {
  3588.       WriteProfileInt(inifile, "Toolbar", "Pos", ToolbarOptions.ulToolbarPos);
  3589.       WriteProfileInt(inifile, "Toolbar", "Small", ToolbarOptions.bSmallToolbar);
  3590.    }
  3591.  
  3592.    if (ToolbarConfig.bDirty)
  3593.    {
  3594.       WriteProfileData(inifile, "Toolbar", "CPos", &ToolbarConfig.SelectPos, sizeof(WINPOS));
  3595.       WriteProfileData(inifile, "Toolbar", "LFore", &ToolbarConfig.lLeftFore, sizeof(LONG));
  3596.       WriteProfileData(inifile, "Toolbar", "RFore", &ToolbarConfig.lRightFore, sizeof(LONG));
  3597.       WriteProfileData(inifile, "Toolbar", "LBack", &ToolbarConfig.lLeftBack, sizeof(LONG));
  3598.       WriteProfileData(inifile, "Toolbar", "RBack", &ToolbarConfig.lRightBack, sizeof(LONG));
  3599.       WriteProfileString(inifile, "Toolbar", "LFont", ToolbarConfig.pchLeftFont);
  3600.       WriteProfileString(inifile, "Toolbar", "RFont", ToolbarConfig.pchRightFont);
  3601.  
  3602.       if (ToolbarConfig.pButtons)
  3603.          WriteProfileData(inifile, "Toolbar", "Config", ToolbarConfig.pButtons, ToolbarConfig.ulNumButtons * sizeof(BUTTONCONFIG));
  3604.       else
  3605.       {
  3606.          pchBuffer[0]=0;
  3607.          WriteProfileData(inifile, "Toolbar", "Config", pchBuffer, 1);
  3608.       }
  3609.  
  3610.       ToolbarConfig.bDirty = FALSE;
  3611.    }
  3612.  
  3613.  
  3614.    return 0;
  3615. }
  3616.  
  3617. static int ReadIniEchoman(HINI inifile)
  3618. {
  3619.    extern ECHOMGROPT EchoMgrOpt;
  3620.    ULONG ulLen=0;
  3621.    PCHAR pchKeys, pchCurrentKey, pchEchoSeg;
  3622.    PCHAR pchData, pchTemp, pchBack;
  3623.    PUPLINK pUplink;
  3624.    long lUplink=0;
  3625.  
  3626.    EchoMgrOpt.lFolderBack = RGB_WHITE;
  3627.    strcpy(EchoMgrOpt.pchFolderFont, SMA_FONT);
  3628.  
  3629.    if (!inifile)
  3630.       return 1;
  3631.  
  3632.    /* Uplinks */
  3633.    if (QueryProfileSize(inifile, "Uplinks", NULL, &ulLen) && ulLen)
  3634.    {
  3635.       pchKeys = malloc(ulLen);
  3636.       QueryProfileData(inifile, "Uplinks", NULL, pchKeys, &ulLen);
  3637.       pchCurrentKey = pchKeys;
  3638.       pchData = malloc(0xffff);
  3639.       while (*pchCurrentKey)
  3640.       {
  3641.          if (*pchCurrentKey == '#') /* Uplink */
  3642.          {
  3643.             ulLen=0;
  3644.             if (QueryProfileSize(inifile, "Uplinks", pchCurrentKey, &ulLen) && ulLen)
  3645.             {
  3646.                pchTemp = pchData;
  3647.                QueryProfileData(inifile, "Uplinks", pchCurrentKey, pchData, &ulLen);
  3648.  
  3649.                /* Neuen Block */
  3650.                pUplink = calloc(1, sizeof(UPLINK));
  3651.                if (EchoMgrOpt.pUplinks)
  3652.                   EchoMgrOpt.pUplinksLast->next = pUplink;
  3653.                else
  3654.                   EchoMgrOpt.pUplinks = pUplink;
  3655.                pUplink->prev = EchoMgrOpt.pUplinksLast;
  3656.                EchoMgrOpt.pUplinksLast = pUplink;
  3657.  
  3658.                strcpy(pUplink->pchEchoMgrAddress, pchTemp);
  3659.                pchTemp = strchr(pchTemp, 0)+1;
  3660.                strcpy(pUplink->pchMyAddress, pchTemp);
  3661.                pchTemp = strchr(pchTemp, 0)+1;
  3662.                strcpy(pUplink->pchEchoMgrName, pchTemp);
  3663.                pchTemp = strchr(pchTemp, 0)+1;
  3664.                strcpy(pUplink->pchPassword, pchTemp);
  3665.  
  3666.                /* Echos zusammensuchen */
  3667.                lUplink = strtol(pchCurrentKey+1, NULL, 10);
  3668.                pchEchoSeg = pchKeys;
  3669.                while (*pchEchoSeg)
  3670.                {
  3671.                   if (*pchEchoSeg == '+' &&
  3672.                       strtol(pchEchoSeg+1, NULL, 10) == lUplink)
  3673.                   {
  3674.                      /* Echos anhaengen */
  3675.                      QueryProfileString(inifile, "Uplinks", pchEchoSeg, "", pchData, 0xffff);
  3676.                      ulLen = strlen(pchData)+1;
  3677.                      pchBack = pUplink->pchUplinkAreas;
  3678.                      if (pUplink->pchUplinkAreas)
  3679.                         ulLen += strlen(pUplink->pchUplinkAreas)+1;
  3680.                      pUplink->pchUplinkAreas = malloc(ulLen);
  3681.                      strcpy(pUplink->pchUplinkAreas, pchData);
  3682.                      if (pchBack)
  3683.                      {
  3684.                         strcat(pUplink->pchUplinkAreas, " ");
  3685.                         strcat(pUplink->pchUplinkAreas, pchBack);
  3686.                         free(pchBack);
  3687.                      }
  3688.  
  3689.                   }
  3690.                   while (*pchEchoSeg)
  3691.                      pchEchoSeg++;
  3692.                   pchEchoSeg++;
  3693.                }
  3694.             }
  3695.          }
  3696.          while (*pchCurrentKey)
  3697.             pchCurrentKey++;
  3698.          pchCurrentKey++;
  3699.       }
  3700.       free(pchData);
  3701.       free(pchKeys);
  3702.    }
  3703.  
  3704.    QueryProfileString(inifile, "EchoMan", "FFont", SMA_FONT, EchoMgrOpt.pchFolderFont, sizeof(EchoMgrOpt.pchFolderFont));
  3705.    QueryProfileString(inifile, "EchoMan", "DLL", "", EchoMgrOpt.pchDllName, sizeof(EchoMgrOpt.pchDllName));
  3706.    ulLen = sizeof(WINPOS);
  3707.    QueryProfileData(inifile, "EchoMan", "FPos", &EchoMgrOpt.FolderPos, &ulLen);
  3708.    QueryProfileData(inifile, "EchoMan", "SPos", &EchoMgrOpt.SettingsPos, &ulLen);
  3709.    ulLen = sizeof(LONG);
  3710.    QueryProfileData(inifile, "EchoMan", "FFore", &EchoMgrOpt.lFolderFore, &ulLen);
  3711.    ulLen = sizeof(LONG);
  3712.    QueryProfileData(inifile, "EchoMan", "FBack", &EchoMgrOpt.lFolderBack, &ulLen);
  3713.  
  3714.    if (QueryProfileSize(inifile, "EchoMan", "Param", &ulLen) && ulLen)
  3715.    {
  3716.       EchoMgrOpt.pDllParams = calloc(1, ulLen);
  3717.       EchoMgrOpt.ulParamLen = ulLen;
  3718.       QueryProfileData(inifile, "EchoMan", "Param", EchoMgrOpt.pDllParams, &ulLen);
  3719.    }
  3720.  
  3721.    return 0;
  3722. }
  3723.  
  3724. static int SaveIniEchoman(HINI inifile)
  3725. {
  3726.    extern ECHOMGROPT EchoMgrOpt;
  3727.    int iUpl=1, iEch;
  3728.    PUPLINK pUplink = EchoMgrOpt.pUplinks;
  3729.    char *pchBuffer, *pchTemp, *pchSrc, *pchLastSrc, *pchLastTemp;
  3730.    char pchNum[20]="#";
  3731.    char pchNumEchos[40];
  3732.  
  3733.    if (!inifile)
  3734.       return 1;
  3735.  
  3736.    WriteProfileData(inifile, "Uplinks", NULL, NULL, 0);
  3737.    pchBuffer = malloc(0xffff);
  3738.    while (pUplink)
  3739.    {
  3740.        /* Uplink-Daten */
  3741.        strcpy(pchBuffer, pUplink->pchEchoMgrAddress);
  3742.        pchTemp = strchr(pchBuffer, 0)+1;
  3743.        strcpy(pchTemp, pUplink->pchMyAddress);
  3744.        pchTemp = strchr(pchTemp, 0)+1;
  3745.        strcpy(pchTemp, pUplink->pchEchoMgrName);
  3746.        pchTemp = strchr(pchTemp, 0)+1;
  3747.        strcpy(pchTemp, pUplink->pchPassword);
  3748.        pchTemp = strchr(pchTemp, 0)+1;
  3749.  
  3750.        _itoa(iUpl, pchNum+1, 10);
  3751.        WriteProfileData(inifile, "Uplinks", pchNum, pchBuffer, pchTemp-pchBuffer);
  3752.  
  3753.        /* Echoliste */
  3754.        pchLastSrc = pchSrc = pUplink->pchUplinkAreas;
  3755.        iEch = 0;
  3756.  
  3757.        while (pchSrc && *pchSrc)
  3758.        {
  3759.           /* kopieren */
  3760.           pchLastTemp = pchTemp = pchBuffer;
  3761.           while (*pchSrc && (pchTemp - pchBuffer) < 0xfff0)
  3762.           {
  3763.              if (*pchSrc == ' ') /* Stelle merken */
  3764.              {
  3765.                 pchLastSrc = pchSrc;
  3766.                 pchLastTemp = pchTemp;
  3767.              }
  3768.              *pchTemp++ = *pchSrc++;
  3769.           }
  3770.           if (*pchSrc) /* Abbruch wg. Laenge */
  3771.           {
  3772.              /* wieder bei letztem Leerzeichen aufsetzen */
  3773.              pchSrc = pchLastSrc+1;
  3774.              pchTemp = pchLastTemp;
  3775.           }
  3776.           *pchTemp++ = 0;
  3777.           sprintf(pchNumEchos, "+%d %d", iUpl, ++iEch);
  3778.           WriteProfileData(inifile, "Uplinks", pchNumEchos, pchBuffer, pchTemp-pchBuffer);
  3779.        }
  3780.  
  3781.        iUpl++;
  3782.        pUplink = pUplink->next;
  3783.    }
  3784.    free(pchBuffer);
  3785.  
  3786.    if (EchoMgrOpt.pDllParams && EchoMgrOpt.ulParamLen)
  3787.       WriteProfileData(inifile, "EchoMan", "Param", EchoMgrOpt.pDllParams, EchoMgrOpt.ulParamLen);
  3788.    else
  3789.       WriteProfileData(inifile, "EchoMan", "Param", NULL, 0);
  3790.  
  3791.    WriteProfileString(inifile, "EchoMan", "FFont", EchoMgrOpt.pchFolderFont);
  3792.    WriteProfileString(inifile, "EchoMan", "DLL", EchoMgrOpt.pchDllName);
  3793.    WriteProfileData(inifile, "EchoMan", "FFore", &EchoMgrOpt.lFolderFore, sizeof(LONG));
  3794.    WriteProfileData(inifile, "EchoMan", "FBack", &EchoMgrOpt.lFolderBack, sizeof(LONG));
  3795.    WriteProfileData(inifile, "EchoMan", "FPos", &EchoMgrOpt.FolderPos, sizeof(WINPOS));
  3796.    WriteProfileData(inifile, "EchoMan", "SPos", &EchoMgrOpt.SettingsPos, sizeof(WINPOS));
  3797.  
  3798.    EchoMgrOpt.bDirty=FALSE;
  3799.  
  3800.    return 0;
  3801. }
  3802.  
  3803. static int ReadIniSearch(HINI inifile)
  3804. {
  3805.    extern SEARCHPAR SearchPar;
  3806.    ULONG ulLen;
  3807.  
  3808.    if (!inifile)
  3809.       return 1;
  3810.  
  3811.    ulLen = sizeof(SearchPar.DlgPos);
  3812.    QueryProfileData(inifile, "Search", "Pos", &SearchPar.DlgPos, &ulLen);
  3813.    ulLen = sizeof(SearchPar.ulSearchFlags);
  3814.    QueryProfileData(inifile, "Search", "Options", &SearchPar.ulSearchFlags, &ulLen);
  3815.  
  3816.    QueryProfileString(inifile, "Search", "Text", "", SearchPar.pchSearchText, sizeof(SearchPar.pchSearchText));
  3817.  
  3818.    return 0;
  3819. }
  3820.  
  3821. static int SaveIniSearch(HINI inifile)
  3822. {
  3823.    extern SEARCHPAR SearchPar;
  3824.  
  3825.    if (!inifile)
  3826.       return 1;
  3827.  
  3828.    WriteProfileData(inifile, "Search", "Pos", &SearchPar.DlgPos, sizeof(SearchPar.DlgPos));
  3829.    WriteProfileData(inifile, "Search", "Options", &SearchPar.ulSearchFlags, sizeof(SearchPar.ulSearchFlags));
  3830.    WriteProfileString(inifile, "Search", "Text", SearchPar.pchSearchText);
  3831.  
  3832.    return 0;
  3833. }
  3834.  
  3835. static int ReadIniPrintSetup(HINI inifile)
  3836. {
  3837.    extern PRINTSETUP PrintSetup;
  3838.    ULONG ulLen;
  3839.    UCHAR Borders[4]={20, 10, 5, 10};
  3840.  
  3841.    if (!inifile)
  3842.       return 1;
  3843.  
  3844.    QueryProfileString(inifile, "Print", "HeaderFont", "10.Courier", PrintSetup.pchHeaderFont, sizeof(PrintSetup.pchHeaderFont));
  3845.    QueryProfileString(inifile, "Print", "TextFont", "10.Courier", PrintSetup.pchTextFont, sizeof(PrintSetup.pchTextFont));
  3846.    QueryProfileString(inifile, "Print", "Queue", "", PrintSetup.szPreferredQueue, sizeof(PrintSetup.szPreferredQueue));
  3847.  
  3848.    ulLen = sizeof(PrintSetup.DlgPos);
  3849.    QueryProfileData(inifile, "Print", "Pos", &PrintSetup.DlgPos, &ulLen);
  3850.  
  3851.    ulLen = sizeof(PrintSetup.ulOutput);
  3852.    PrintSetup.ulOutput = OUTPUT_AREA | OUTPUT_ATTRIB | OUTPUT_DATE | OUTPUT_PAGENUM;
  3853.    QueryProfileData(inifile, "Print", "Output", &PrintSetup.ulOutput, &ulLen);
  3854.  
  3855.    ulLen = sizeof(Borders);
  3856.    QueryProfileData(inifile, "Print", "Borders", Borders, &ulLen);
  3857.    PrintSetup.lLeft   = Borders[0];
  3858.    PrintSetup.lRight  = Borders[1];
  3859.    PrintSetup.lTop    = Borders[2];
  3860.    PrintSetup.lBottom = Borders[3];
  3861.  
  3862.    ulLen=0;
  3863.    QueryProfileSize(inifile, "Print", "DData", &ulLen);
  3864.    if (ulLen)
  3865.    {
  3866.       PrintSetup.pDriverData = calloc(1, ulLen);
  3867.       QueryProfileData(inifile, "Print", "DData", PrintSetup.pDriverData, &ulLen);
  3868.    }
  3869.  
  3870.    return 0;
  3871. }
  3872.  
  3873. static int SaveIniPrintSetup(HINI inifile)
  3874. {
  3875.    extern PRINTSETUP PrintSetup;
  3876.    UCHAR Borders[4];
  3877.  
  3878.    if (!inifile)
  3879.       return 1;
  3880.  
  3881.    WriteProfileData(inifile, "Print", "Pos", &PrintSetup.DlgPos, sizeof(PrintSetup.DlgPos));
  3882.    WriteProfileData(inifile, "Print", "Output", &PrintSetup.ulOutput, sizeof(PrintSetup.ulOutput));
  3883.    Borders[0] = PrintSetup.lLeft;
  3884.    Borders[1] = PrintSetup.lRight;
  3885.    Borders[2] = PrintSetup.lTop;
  3886.    Borders[3] = PrintSetup.lBottom;
  3887.    WriteProfileData(inifile, "Print", "Borders", Borders, sizeof(Borders));
  3888.    if (PrintSetup.pDriverData)
  3889.       WriteProfileData(inifile, "Print", "DData", PrintSetup.pDriverData, PrintSetup.pDriverData->cb);
  3890.    else
  3891.       WriteProfileData(inifile, "Print", "DData", NULL, 0);
  3892.    WriteProfileString(inifile, "Print", "HeaderFont", PrintSetup.pchHeaderFont);
  3893.    WriteProfileString(inifile, "Print", "TextFont", PrintSetup.pchTextFont);
  3894.    WriteProfileString(inifile, "Print", "Queue", PrintSetup.szPreferredQueue);
  3895.  
  3896.    PrintSetup.bDirty = FALSE;
  3897.  
  3898.    return 0;
  3899. }
  3900.  
  3901.  
  3902. /*------------------------------ ConvertProfile  ----------------------------*/
  3903. /* Konvertiert ein Profile der vorherigen Version in ein neues               */
  3904. /* Rückgabewert: 0 altes Profile umgewandelt                                 */
  3905. /*               1 altes Profile unbekannt                                   */
  3906. /*---------------------------------------------------------------------------*/
  3907.  
  3908. static int ConvertProfile(HINI inifile, PCHAR pchThisVersion, HAB hab)
  3909. {
  3910.    BOOL converted=FALSE;
  3911.  
  3912.    if (!strcmp(pchThisVersion, O_INIVERSION13))
  3913.    {
  3914.       /* alte Marker-Items loeschen */
  3915.       WriteProfileData(inifile, "Mark", NULL, NULL, 0);
  3916.       converted = TRUE;
  3917.    }
  3918.    if (!strcmp(pchThisVersion, O_INIVERSION13) ||
  3919.        !strcmp(pchThisVersion, O_INIVERSION14))
  3920.    {
  3921.       /* Layout-Optionen loeschen */
  3922.       WriteProfileData(inifile, "Options", "Layout", NULL, 0);
  3923.       converted = TRUE;
  3924.    }
  3925.  
  3926.    if (!strcmp(pchThisVersion, O_INIVERSION13) ||
  3927.        !strcmp(pchThisVersion, O_INIVERSION14) ||
  3928.        !strcmp(pchThisVersion, O_INIVERSION15))
  3929.    {
  3930.       /* Nicknames in eigenes Ini */
  3931.       HINI hNewIni;
  3932.  
  3933.       if (hNewIni = PrfOpenProfile(hab, NICKFILENAME))
  3934.       {
  3935.          PCHAR pchKeys;
  3936.          ULONG ulKeysLen=0;
  3937.          PCHAR pchCurrentKey;
  3938.          BOOKADDRESSOPT OldNick;
  3939.          ULONG ulNewAttrib;
  3940.          ULONG ulNewFlags;
  3941.          ULONG ulReadSize;
  3942.  
  3943.          if (QueryProfileSize(inifile, "Nicknames", NULL, &ulKeysLen) && ulKeysLen)
  3944.          {
  3945.             pchKeys=malloc(ulKeysLen);
  3946.  
  3947.             if (QueryProfileData(inifile, "Nicknames", NULL, pchKeys, &ulKeysLen))
  3948.             {
  3949.                pchCurrentKey=pchKeys;
  3950.  
  3951.                while (*pchCurrentKey)
  3952.                {
  3953.                   ulReadSize = sizeof(OldNick);
  3954.                   QueryProfileData(inifile, "Nicknames", pchCurrentKey, &OldNick, &ulReadSize);
  3955.  
  3956.                   if (OldNick.username[0])
  3957.                      WriteProfileString(hNewIni, OldNick.usertag, "Name", OldNick.username);
  3958.                   if (OldNick.address[0])
  3959.                      WriteProfileString(hNewIni, OldNick.usertag, "Address", OldNick.address);
  3960.                   if (OldNick.subjectline[0])
  3961.                      WriteProfileString(hNewIni, OldNick.usertag, "Subj", OldNick.subjectline);
  3962.                   if (OldNick.firstline[0])
  3963.                      WriteProfileString(hNewIni, OldNick.usertag, "First", OldNick.firstline);
  3964.  
  3965.                   ulNewAttrib = 0;
  3966.                   if (OldNick.private)
  3967.                      ulNewAttrib |= ATTRIB_PRIVATE;
  3968.                   if (OldNick.crash)
  3969.                      ulNewAttrib |= ATTRIB_CRASH;
  3970.                   if (OldNick.kill)
  3971.                      ulNewAttrib |= ATTRIB_KILLSENT;
  3972.                   if (OldNick.attach)
  3973.                      ulNewAttrib |= ATTRIB_FILEATTACHED;
  3974.                   if (OldNick.request)
  3975.                      ulNewAttrib |= ATTRIB_FREQUEST;
  3976.  
  3977.                   if (ulNewAttrib)
  3978.                      WriteProfileInt(hNewIni, OldNick.usertag, "Attrib", ulNewAttrib);
  3979.  
  3980.                   ulNewFlags = 0;
  3981.                   if (OldNick.notemplate)
  3982.                      ulNewFlags |= NICKFLAG_NOTEMPLATE;
  3983.  
  3984.                   if (ulNewFlags)
  3985.                      WriteProfileInt(hNewIni, OldNick.usertag, "Flags", ulNewFlags);
  3986.  
  3987.                   /* Naechsten Key suchen */
  3988.                   while (*pchCurrentKey)
  3989.                      pchCurrentKey++;
  3990.                   pchCurrentKey++;
  3991.                }
  3992.                free(pchKeys);
  3993.                PrfCloseProfile(hNewIni);
  3994.             }
  3995.             else
  3996.             {
  3997.                free(pchKeys);
  3998.                PrfCloseProfile(hNewIni);
  3999.             }
  4000.  
  4001.          }
  4002.          /* Alte Nicknames loeschen */
  4003.          WriteProfileData(inifile, "Nicknames", NULL, NULL, 0);
  4004.  
  4005.          PrfCloseProfile(hNewIni);
  4006.       }
  4007.       converted = TRUE;
  4008.    }
  4009.  
  4010.    if (!strcmp(pchThisVersion, O_INIVERSION13) ||
  4011.        !strcmp(pchThisVersion, O_INIVERSION14) ||
  4012.        !strcmp(pchThisVersion, O_INIVERSION15) ||
  4013.        !strcmp(pchThisVersion, O_INIVERSION16))
  4014.    {
  4015.       /* Neue Area-Struktur */
  4016.       HINI AreasINI;
  4017.       ULONG ulKeysLen=0;
  4018.  
  4019.       if (AreasINI=PrfOpenProfile(hab, AREAFILENAME))
  4020.       {
  4021.          if (QueryProfileSize(AreasINI, NULL, NULL, &ulKeysLen) && ulKeysLen)
  4022.          {
  4023.             PCHAR pchKeys, pchCurrentKey;
  4024.  
  4025.             pchKeys=malloc(ulKeysLen);
  4026.  
  4027.             if (QueryProfileData(AreasINI, NULL, NULL, pchKeys, &ulKeysLen))
  4028.             {
  4029.                OLD_AREADEFOPT OldAreaOpt;
  4030.                USHORT usFormat;
  4031.                ULONG  ulAttrib;
  4032.                ULONG  ulOptions;
  4033.                ULONG  ulDataLen;
  4034.  
  4035.                pchCurrentKey=pchKeys;
  4036.  
  4037.                while (*pchCurrentKey)
  4038.                {
  4039.                   /* Alte Optionen lesen */
  4040.                   memset(&OldAreaOpt, 0, sizeof(OldAreaOpt));
  4041.  
  4042.                   ulDataLen=sizeof(SHORT)+2;
  4043.                   QueryProfileData(AreasINI, pchCurrentKey, "Options", &OldAreaOpt.areatype, &ulDataLen);
  4044.  
  4045.                   /* Optionen konvertieren */
  4046.                   usFormat = OldAreaOpt.areatype;
  4047.  
  4048.                   ulAttrib=0;
  4049.                   if (OldAreaOpt.defaultprivate)
  4050.                      ulAttrib |= ATTRIB_PRIVATE;
  4051.                   if (OldAreaOpt.defaultcrash)
  4052.                      ulAttrib |= ATTRIB_CRASH;
  4053.                   if (OldAreaOpt.defaultkillsent)
  4054.                      ulAttrib |= ATTRIB_KILLSENT;
  4055.                   if (OldAreaOpt.defaulthold)
  4056.                      ulAttrib |= ATTRIB_HOLD;
  4057.  
  4058.                   ulOptions=0;
  4059.                   if (OldAreaOpt.isfromcfg)
  4060.                      ulOptions |= AREAOPT_FROMCFG;
  4061.                   if (OldAreaOpt.separator)
  4062.                      ulOptions |= AREAOPT_SEPARATOR;
  4063.                   if (OldAreaOpt.eightbitascii)
  4064.                      ulOptions |= AREAOPT_HIGHASCII;
  4065.  
  4066.                   /* Optionen neu schreiben */
  4067.                   WriteProfileData(AreasINI, pchCurrentKey, "Format", &usFormat, sizeof(usFormat));
  4068.                   WriteProfileData(AreasINI, pchCurrentKey, "Attrib", &ulAttrib, sizeof(ulAttrib));
  4069.                   WriteProfileData(AreasINI, pchCurrentKey, "Options", &ulOptions, sizeof(ulOptions));
  4070.  
  4071.                   /* Naechsten Key suchen */
  4072.                   while (*pchCurrentKey)
  4073.                      pchCurrentKey++;
  4074.                   pchCurrentKey++;
  4075.                }
  4076.                free(pchKeys);
  4077.                PrfCloseProfile(AreasINI);
  4078.             }
  4079.             else
  4080.             {
  4081.                free(pchKeys);
  4082.                PrfCloseProfile(AreasINI);
  4083.             }
  4084.  
  4085.          }
  4086.          else
  4087.             PrfCloseProfile(AreasINI);
  4088.       }
  4089.  
  4090.       converted = TRUE;
  4091.    }
  4092.  
  4093.    if (!strcmp(pchThisVersion, O_INIVERSION13) ||
  4094.        !strcmp(pchThisVersion, O_INIVERSION14) ||
  4095.        !strcmp(pchThisVersion, O_INIVERSION15) ||
  4096.        !strcmp(pchThisVersion, O_INIVERSION16) ||
  4097.        !strcmp(pchThisVersion, O_INIVERSION17))
  4098.    {
  4099.       WriteProfileData(inifile, "Request", "Crash", NULL, 0);
  4100.  
  4101.       converted = TRUE;
  4102.    }
  4103.  
  4104.    if (!strcmp(pchThisVersion, O_INIVERSION13) ||
  4105.        !strcmp(pchThisVersion, O_INIVERSION14) ||
  4106.        !strcmp(pchThisVersion, O_INIVERSION15) ||
  4107.        !strcmp(pchThisVersion, O_INIVERSION16) ||
  4108.        !strcmp(pchThisVersion, O_INIVERSION17) ||
  4109.        !strcmp(pchThisVersion, O_INIVERSION18))
  4110.    {
  4111.       WriteProfileData(inifile, "Printer", NULL, NULL, 0);
  4112.       WriteProfileData(inifile, "Nodelist", "Options", NULL, 0);
  4113.  
  4114.       converted = TRUE;
  4115.    }
  4116.  
  4117.    if (!strcmp(pchThisVersion, O_INIVERSION13) ||
  4118.        !strcmp(pchThisVersion, O_INIVERSION14) ||
  4119.        !strcmp(pchThisVersion, O_INIVERSION15) ||
  4120.        !strcmp(pchThisVersion, O_INIVERSION16) ||
  4121.        !strcmp(pchThisVersion, O_INIVERSION17) ||
  4122.        !strcmp(pchThisVersion, O_INIVERSION18) ||
  4123.        !strcmp(pchThisVersion, O_INIVERSION19))
  4124.    {
  4125.       WriteProfileData(inifile, "Find", "Text", NULL, 0);
  4126.  
  4127.       converted = TRUE;
  4128.    }
  4129.  
  4130.    if (!strcmp(pchThisVersion, O_INIVERSION13) ||
  4131.        !strcmp(pchThisVersion, O_INIVERSION14) ||
  4132.        !strcmp(pchThisVersion, O_INIVERSION15) ||
  4133.        !strcmp(pchThisVersion, O_INIVERSION16) ||
  4134.        !strcmp(pchThisVersion, O_INIVERSION17) ||
  4135.        !strcmp(pchThisVersion, O_INIVERSION18) ||
  4136.        !strcmp(pchThisVersion, O_INIVERSION19) ||
  4137.        !strcmp(pchThisVersion, O_INIVERSION20) ||
  4138.        !strcmp(pchThisVersion, O_INIVERSION21))
  4139.    {
  4140.       WriteProfileData(inifile, "Options", "Msglist", NULL, 0);
  4141.  
  4142.       converted = TRUE;
  4143.    }
  4144.  
  4145.    if (converted)
  4146.       return 0;
  4147.    else
  4148.       return 1;
  4149. }
  4150.  
  4151. /* Stub-Funktionen */
  4152.  
  4153. static BOOL QueryProfileData(HINI hini, PSZ pszApp, PSZ pszKey, PVOID pBuffer, PULONG pulBufferMax)
  4154. {
  4155.    return PrfQueryProfileData(hini, pszApp, pszKey, pBuffer, pulBufferMax);
  4156. }
  4157.  
  4158. static LONG QueryProfileInt(HINI hini, PSZ pszApp, PSZ pszKey, LONG lDefault)
  4159. {
  4160.    char pchTemp[15];
  4161.    PrfQueryProfileString(hini, pszApp, pszKey, "", pchTemp, sizeof(pchTemp));
  4162.    if (pchTemp[0])
  4163.       return strtoul(pchTemp, NULL, 10);
  4164.    else
  4165.       return lDefault;
  4166. }
  4167.  
  4168. static BOOL QueryProfileSize(HINI hini, PSZ pszApp, PSZ pszKey, PULONG pDataLen)
  4169. {
  4170.    return PrfQueryProfileSize(hini, pszApp, pszKey, pDataLen);
  4171. }
  4172.  
  4173. static ULONG QueryProfileString(HINI hini, PSZ pszApp, PSZ pszKey, PSZ pszDefault, PVOID pBuffer,
  4174.                                 ULONG cchBufferMax)
  4175. {
  4176.    return PrfQueryProfileString(hini, pszApp, pszKey, pszDefault, pBuffer, cchBufferMax);
  4177. }
  4178.  
  4179. static BOOL WriteProfileData(HINI hini, PSZ pszApp, PSZ pszKey, PVOID pBuffer, ULONG cchBufferMax)
  4180. {
  4181.    return PrfWriteProfileData(hini, pszApp, pszKey, pBuffer, cchBufferMax);
  4182. }
  4183.  
  4184. static BOOL WriteProfileString(HINI hini, PSZ pszApp, PSZ pszKey, PSZ pszData)
  4185. {
  4186.    return PrfWriteProfileString(hini, pszApp, pszKey, pszData);
  4187. }
  4188.  
  4189. static BOOL WriteProfileInt(HINI hini, PSZ pszApp, PSZ pszKey, LONG lData)
  4190. {
  4191.    char pchTemp[15];
  4192.    _itoa(lData, pchTemp, 10);
  4193.    return PrfWriteProfileString(hini, pszApp, pszKey, pchTemp);
  4194. }
  4195.  
  4196. static ULONG CFGFileErrorMessage(HWND hwndOwner, ULONG ErrorType)
  4197. {
  4198.    char pchFormat[100]="";
  4199.    char pchAddText[100]="";
  4200.    char pchMessage[200]="";
  4201.  
  4202.    LoadString(IDST_MSG_INITBASE, sizeof(pchFormat), pchFormat);
  4203.    LoadString(IDST_MSG_INITBASE+ErrorType, sizeof(pchAddText), pchAddText);
  4204.    sprintf(pchMessage, pchFormat, pchAddText);
  4205.  
  4206.    return WinMessageBox(HWND_DESKTOP, hwndOwner, pchMessage, NULL, IDD_INITERROR,
  4207.                         MB_OKCANCEL | MB_HELP | MB_ERROR | MB_MOVEABLE);
  4208. }
  4209.  
  4210. static ULONG CFGDLLErrorMessage(HWND hwndOwner, ULONG ErrorType)
  4211. {
  4212.    char pchFormat[100]="";
  4213.    char pchAddText[100]="";
  4214.    char pchMessage[200]="";
  4215.  
  4216.    LoadString(IDST_MSG_CFGDLLBASE, sizeof(pchFormat), pchFormat);
  4217.    LoadString(IDST_MSG_CFGDLLBASE+ErrorType, sizeof(pchAddText), pchAddText);
  4218.    sprintf(pchMessage, pchFormat, pchAddText);
  4219.  
  4220.    return WinMessageBox(HWND_DESKTOP, hwndOwner, pchMessage, NULL, IDD_CFGDLLERROR,
  4221.                         MB_OKCANCEL | MB_HELP | MB_ERROR | MB_MOVEABLE);
  4222. }
  4223.  
  4224. static ULONG ProfileErrorMessage(HWND hwndOwner, ULONG ErrorType)
  4225. {
  4226.    switch(ErrorType)
  4227.    {
  4228.       case INIFILE_DUPAREAS: /* Areas doppelt */
  4229.          return MessageBox(hwndOwner, IDST_MSG_DUPAREAS, 0,
  4230.                            IDD_DUPAREAS, MB_OKCANCEL | MB_ERROR);
  4231.  
  4232.       case INIFILE_OPEN:
  4233.          return MessageBox(hwndOwner, IDST_MSG_ERRORINIFILE, 0,
  4234.                            IDD_ERRORINIFILE, MB_OKCANCEL | MB_ERROR);
  4235.  
  4236.       case INIFILE_NEW:
  4237.          return MessageBox(hwndOwner, IDST_MSG_NOINIFILE, 0,
  4238.                            IDD_NOINIFILE, MB_OKCANCEL | MB_ERROR);
  4239.  
  4240.       case INIFILE_VERSION:
  4241.          return MessageBox(hwndOwner, IDST_MSG_OLDINIFILE, 0,
  4242.                            IDD_OLDINIFILE, MB_OKCANCEL | MB_ERROR);
  4243.  
  4244.       default:
  4245.          return 0;
  4246.    }
  4247. }
  4248.  
  4249. ULONG HandleInitErrors(HWND hwndClient, ULONG ulError)
  4250. {
  4251.    switch(ERRORCLASS(ulError))
  4252.    {
  4253.       case ERRORCLASS_INI:
  4254.          return ProfileErrorMessage(hwndClient, ERRORCODE(ulError));
  4255.  
  4256.       case ERRORCLASS_CFGDLL:
  4257.          return CFGDLLErrorMessage(hwndClient, ERRORCODE(ulError));
  4258.  
  4259.       case ERRORCLASS_CFGFILE:
  4260.          return CFGFileErrorMessage(hwndClient, ERRORCODE(ulError));
  4261.  
  4262.       default:
  4263.          return MBID_CANCEL;
  4264.    }
  4265. }
  4266.  
  4267. static int ReadIniFolders(HAB hab)
  4268. {
  4269.    HINI inifile;
  4270.    char *pchKeys;             /* alle Keys */
  4271.    ULONG ulKeysLen;           /* Platz fuer die Keys */
  4272.    char *pchCurrentKey;       /* Aktueller Key */
  4273.    ULONG ulDataLen;
  4274.    char pchIniFile[LEN_PATHNAME+1];
  4275.    extern FOLDERANCHOR FolderAnchor;
  4276.    AREAFOLDER AreaFolder;
  4277.    LONG HighID=0;
  4278.  
  4279.    strcpy(pchIniFile, pchIniPath);
  4280.    strcat(pchIniFile, FOLDERFILENAME);
  4281.  
  4282.    if (!(inifile=PrfOpenProfile(hab, pchIniFile)))
  4283.    {
  4284.       AddDefaultFolder(&FolderAnchor);
  4285.       return 1;
  4286.    }
  4287.  
  4288.    if (!QueryProfileSize(inifile, NULL, NULL, &ulKeysLen) || (ulKeysLen==0))
  4289.    {
  4290.       PrfCloseProfile(inifile);
  4291.       AddDefaultFolder(&FolderAnchor);
  4292.  
  4293.       return 1;
  4294.    }
  4295.  
  4296.    pchKeys=malloc(ulKeysLen);
  4297.  
  4298.    if (!QueryProfileData(inifile, NULL, NULL, pchKeys, &ulKeysLen))
  4299.    {
  4300.       free(pchKeys);
  4301.       PrfCloseProfile(inifile);
  4302.       AddDefaultFolder(&FolderAnchor);
  4303.       return 1;
  4304.    }
  4305.  
  4306.    pchCurrentKey=pchKeys;
  4307.  
  4308.    while (*pchCurrentKey)
  4309.    {
  4310.       if (*pchCurrentKey == '#')
  4311.       {
  4312.          /* Folderdaten lesen */
  4313.          memset(&AreaFolder, 0, sizeof(AreaFolder));
  4314.  
  4315.          AreaFolder.FolderID = atoi(pchCurrentKey+1);
  4316.          if (AreaFolder.FolderID || *(pchCurrentKey+1) == '0')
  4317.          {
  4318.             AreaFolder.ParentFolder = QueryProfileInt(inifile, pchCurrentKey, "Parent", 0);
  4319.             AreaFolder.ulFlags = QueryProfileInt(inifile, pchCurrentKey, "Flags", 0);
  4320.             ulDataLen=0;
  4321.             QueryProfileSize(inifile, pchCurrentKey, "Title", &ulDataLen);
  4322.             if (ulDataLen)
  4323.             {
  4324.                AreaFolder.pchName = malloc(ulDataLen+1);
  4325.                QueryProfileString(inifile, pchCurrentKey, "Title", "noname", AreaFolder.pchName, ulDataLen+1);
  4326.             }
  4327.             else
  4328.                AreaFolder.pchName = strdup("noname");
  4329.  
  4330.             FM_AddFolder(&FolderAnchor, &AreaFolder, ADDFOLDER_TAIL);
  4331.             if (AreaFolder.FolderID > HighID)
  4332.                HighID = AreaFolder.FolderID;
  4333.          }
  4334.       }
  4335.       else
  4336.       {
  4337.          /* Folderliste */
  4338.          FolderAnchor.LastFolder = QueryProfileInt(inifile, pchCurrentKey, "Last", 0);
  4339.          FolderAnchor.HighID = QueryProfileInt(inifile, pchCurrentKey, "High", 0);
  4340.          FolderAnchor.ulFlags = QueryProfileInt(inifile, pchCurrentKey, "Flags", 0);
  4341.          FolderAnchor.lSplit = QueryProfileInt(inifile, pchCurrentKey, "Split", 50);
  4342.       }
  4343.       /* Naechsten Key suchen */
  4344.       while (*pchCurrentKey)
  4345.          pchCurrentKey++;
  4346.       pchCurrentKey++;
  4347.    }
  4348.    free(pchKeys);
  4349.    PrfCloseProfile(inifile);
  4350.  
  4351.    /* notfalls high-ID anpassen */
  4352.    if (FolderAnchor.HighID < HighID)
  4353.       FolderAnchor.HighID = HighID;
  4354.  
  4355.    return 0;
  4356. }
  4357.  
  4358. static int SaveIniFolders(HAB hab)
  4359. {
  4360.    HINI inifile;
  4361.    char *pchKeys;             /* alle Keys */
  4362.    ULONG ulKeysLen;           /* Platz fuer die Keys */
  4363.    char *pchCurrentKey;       /* Aktueller Key */
  4364.    char pchIniFile[LEN_PATHNAME+1];
  4365.    extern FOLDERANCHOR FolderAnchor;
  4366.    PAREAFOLDER pAreaFolder;
  4367.  
  4368.    strcpy(pchIniFile, pchIniPath);
  4369.    strcat(pchIniFile, FOLDERFILENAME);
  4370.  
  4371.    if (!(inifile=PrfOpenProfile(hab, pchIniFile)))
  4372.       return 1;
  4373.  
  4374.    pAreaFolder=FolderAnchor.pList;
  4375.  
  4376.    while (pAreaFolder)
  4377.    {
  4378.       if (pAreaFolder->bDirty)
  4379.       {
  4380.          char pchTemp[20]="#";
  4381.  
  4382.          _itoa(pAreaFolder->FolderID, pchTemp+1, 10);
  4383.  
  4384.          WriteProfileString(inifile, pchTemp, "Title", pAreaFolder->pchName);
  4385.          if (pAreaFolder->ParentFolder)
  4386.             WriteProfileInt(inifile, pchTemp, "Parent", pAreaFolder->ParentFolder);
  4387.          else
  4388.             WriteProfileString(inifile, pchTemp, "Parent", NULL);
  4389.          if (pAreaFolder->ulFlags)
  4390.             WriteProfileInt(inifile, pchTemp, "Flags", pAreaFolder->ulFlags);
  4391.          else
  4392.             WriteProfileString(inifile, pchTemp, "Flags", NULL);
  4393.  
  4394.          pAreaFolder->bDirty=FALSE;
  4395.       }
  4396.       pAreaFolder=pAreaFolder->next;
  4397.    }
  4398.  
  4399.    /* ueberfluessige Areas im INI loeschen */
  4400.    if (!QueryProfileSize(inifile, NULL, NULL, &ulKeysLen) || (ulKeysLen==0))
  4401.    {
  4402.       PrfCloseProfile(inifile);
  4403.       return 1;
  4404.    }
  4405.  
  4406.    pchKeys=malloc(ulKeysLen);
  4407.  
  4408.    if (!QueryProfileData(inifile, NULL, NULL, pchKeys, &ulKeysLen))
  4409.    {
  4410.       free(pchKeys);
  4411.       PrfCloseProfile(inifile);
  4412.       return 1;
  4413.    }
  4414.  
  4415.    pchCurrentKey=pchKeys;
  4416.  
  4417.    while (*pchCurrentKey)
  4418.    {
  4419.       if (*pchCurrentKey == '#')
  4420.       {
  4421.          LONG id;
  4422.  
  4423.          id = atoi(pchCurrentKey+1);
  4424.  
  4425.          if (!FM_FindFolder(&FolderAnchor, id))
  4426.             WriteProfileData(inifile, pchCurrentKey, NULL, NULL, 0);
  4427.       }
  4428.  
  4429.       while (*pchCurrentKey)
  4430.          pchCurrentKey++;
  4431.       pchCurrentKey++;
  4432.    }
  4433.    free(pchKeys);
  4434.  
  4435.    /* allgemeine Daten */
  4436.    WriteProfileInt(inifile, "Folder", "Last", FolderAnchor.LastFolder);
  4437.    WriteProfileInt(inifile, "Folder", "High", FolderAnchor.HighID);
  4438.    WriteProfileInt(inifile, "Folder", "Flags", FolderAnchor.ulFlags);
  4439.    WriteProfileInt(inifile, "Folder", "Split", FolderAnchor.lSplit);
  4440.  
  4441.    FolderAnchor.bDirty = FALSE;
  4442.  
  4443.    PrfCloseProfile(inifile);
  4444.  
  4445.    return 0;
  4446. }
  4447.  
  4448. static int AddDefaultFolder(PFOLDERANCHOR pFolderAnchor)
  4449. {
  4450.    AREAFOLDER Folder;
  4451.  
  4452.    memset(&Folder, 0, sizeof(Folder));
  4453.  
  4454.    Folder.ulFlags = FOLDER_AUTOSCAN;
  4455.    Folder.pchName = malloc(50);
  4456.    Folder.pchName[0] = 0;
  4457.    LoadString(IDST_AL_DEFAULT, 50, Folder.pchName);
  4458.  
  4459.    FM_AddFolder(pFolderAnchor, &Folder, ADDFOLDER_HEAD | ADDFOLDER_MARKDIRTY);
  4460.  
  4461.    return 0;
  4462. }
  4463.  
  4464. BOOL LogoDisplayEnabled(void)
  4465. {
  4466.    LONG lLogo = QueryProfileInt(HINI_USER, "PM_ControlPanel", "LogoDisplayTime", 1);
  4467.  
  4468.    return (BOOL) lLogo;
  4469. }
  4470. /*------------------------------ Modulende ----------------------------------*/
  4471.