4 * Copyright(C) 1993-1999 by Jochen Wiedmann and Marcin Orlowski
5 * Copyright(C) 2002-2010 by the FlexCat Open Source Team
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or(at
10 * your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 int WarnCTGaps
= FALSE
; /* Warn for missing symbols in CT file. */
26 int NoOptim
= FALSE
; /* Put string into catalog even
27 if translation is equal to
29 int Fill
= FALSE
; /* If translation of given string
30 is missing or empty, write
31 string descriptor from #?.cd
33 int DoExpunge
= FALSE
; /* If TRUE, FlexCat will do an AVAIL
34 FLUSH-alike call after saving the catalog. */
35 int NoBeep
= FALSE
; /* If TRUE, FlexCat won't call
36 DisplayBeep() any longer. */
37 int Quiet
= FALSE
; /* Forces FlexCat to shut up. */
38 int LANGToLower
= TRUE
; /* Shall we do ToLower() on lang's name ?
39 Some #?.language drivers seem to be
40 broken, so we provide a workaround. */
41 int NoBufferedIO
= FALSE
; /* Shall we do buffered I/O ? */
42 int Modified
= FALSE
; /* Shall we write the catalog ONLY
43 if #?.catalog is newer than
45 char Msg_New
[MAX_NEW_STR_LEN
] = "***NEW***"; /* New strings in updated #?.ct */
46 int CopyNEWs
= FALSE
; /* Shall we write the Msg_New into new strings ? */
47 char Old_Msg_New
[MAX_NEW_STR_LEN
] = "; ***NEW***"; /* Old new string(above) used in old
48 CT file. Now we look if it's present
49 and copy it into new CT if the user
50 upgrades(flexcat CD CT newctfile CT */
51 char DestCodeset
[MAX_NEW_STR_LEN
] = ""; /* To which codeset should we convert to
52 If empty then this signals that FlexCat
53 should automatically find out which codeset
57 char prefs_sddir
[MAXPATHLEN
] = "\0";
61 /* Fill in options from preferences file. */
69 #define MAX_PREFS_LEN 512
70 #define FLEXCAT_PREFS "flexcat.prefs"
93 const char template[] = "SDDIR/K,MSG_NEW/K,CODESET/K,WARNCTGAPS/S,NOOPTIM/S,FILL/S,FLUSH/S,NOBEEP/S,QUIET/S,NOLANGTOLOWER/S,NOBUFFEREDIO/S,MODIFIED/S,COPYMSGNEW/S,OLDMSGNEW/K,NOAUTODATE/S,NOSPACES/S";
94 SIPTR Results
[ARGS_COUNT
] = { 0 };
97 struct RDArgs
*rdargs
;
99 if((prefs
= malloc(2048)) != NULL
)
101 if(GetVar(FLEXCAT_PREFS
, prefs
, 80, 0) != -1)
103 prefs
= realloc(prefs
, strlen(prefs
) + 1);
106 if((rda
= AllocDosObject(DOS_RDARGS
, TAG_DONE
)) != NULL
)
108 rda
->RDA_Source
.CS_Buffer
= prefs
;
109 rda
->RDA_Source
.CS_Length
= strlen(prefs
);
110 rda
->RDA_Source
.CS_CurChr
= 0;
111 rda
->RDA_Flags
|= RDAF_NOPROMPT
;
113 if((rdargs
= ReadArgs(template, Results
, rda
)) != NULL
)
116 strlcpy(prefs_sddir
, (char *)Results
[SDDIR
], MAXPATHLEN
);
119 strlcpy(Msg_New
, (char *)Results
[MSG_NEW
], MAX_NEW_STR_LEN
);
122 strlcpy(DestCodeset
, (char *)Results
[CODESET
], MAX_NEW_STR_LEN
);
124 WarnCTGaps
= Results
[WARNCTGAPS
];
125 NoOptim
= Results
[NOOPTIM
];
126 Fill
= Results
[FILL
];
127 DoExpunge
= Results
[FLUSH
];
128 NoBeep
= Results
[NOBEEP
];
129 Quiet
= Results
[QUIET
];
130 LANGToLower
= !Results
[NOLANGTOLOWER
];
131 Modified
= Results
[MODIFIED
];
132 NoBufferedIO
= Results
[NOBUFFEREDIO
];
133 CopyNEWs
= Results
[COPYMSGNEW
];
134 if(Results
[OLDMSGNEW
])
135 snprintf(Old_Msg_New
, sizeof(Old_Msg_New
), "; %s", (char *)Results
[OLDMSGNEW
]);
143 fputs(MSG_ERR_BADPREFS
, stderr
);
144 fputs(template, stderr
);
148 FreeDosObject(DOS_RDARGS
, rda
);
152 fputs("Error processing prefs.\n" \
153 "Can't AllocDosObject()\n", stderr
);