alsa.audio: move handling of XRUN when writting to the slave task
[AROS.git] / tools / flexcat / src / readprefs.c
blob2d7ab76a18d33f99ef42be1168b99fdc2aa8dbf6
1 /*
2 * $Id$
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.
23 #include "flexcat.h"
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
28 description. */
29 int Fill = FALSE; /* If translation of given string
30 is missing or empty, write
31 string descriptor from #?.cd
32 file instead. */
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
44 #?.c(d|t) files ? */
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
54 to be used */
57 char prefs_sddir[MAXPATHLEN] = "\0";
59 /// ReadPrefs
61 /* Fill in options from preferences file. */
63 char ReadPrefs(void)
65 char result = FALSE;
67 #ifdef AMIGA
69 #define MAX_PREFS_LEN 512
70 #define FLEXCAT_PREFS "flexcat.prefs"
72 enum
74 SDDIR,
75 MSG_NEW,
76 CODESET,
77 WARNCTGAPS,
78 NOOPTIM,
79 FILL,
80 FLUSH,
81 NOBEEP,
82 QUIET,
83 NOLANGTOLOWER,
84 NOBUFFEREDIO,
85 MODIFIED,
86 COPYMSGNEW,
87 OLDMSGNEW,
88 NOAUTODATE,
89 NOSPACES,
90 ARGS_COUNT
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 };
95 char *prefs;
96 struct RDArgs *rda;
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);
104 strcat(prefs, "\n");
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)
115 if(Results[SDDIR])
116 strlcpy(prefs_sddir, (char *)Results[SDDIR], MAXPATHLEN);
118 if(Results[MSG_NEW])
119 strlcpy(Msg_New, (char *)Results[MSG_NEW], MAX_NEW_STR_LEN);
121 if(Results[CODESET])
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]);
137 FreeArgs(rdargs);
139 result = TRUE;
141 else
143 fputs(MSG_ERR_BADPREFS, stderr);
144 fputs(template, stderr);
145 fputs("\n", stderr);
146 DisplayBeep(NULL);
148 FreeDosObject(DOS_RDARGS, rda);
150 else
152 fputs("Error processing prefs.\n" \
153 "Can't AllocDosObject()\n", stderr);
155 free(prefs);
158 #endif
160 return(result);