2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
9 /*********************************************************************************************/
15 #include <aros/macros.h>
18 #include <aros/debug.h>
20 #include <proto/exec.h>
21 #include <proto/iffparse.h>
22 #include <proto/dos.h>
27 /*********************************************************************************************/
29 #define PREFS_PATH_ENVARC "ENVARC:Iconbar.prefs"
30 #define PREFS_PATH_ENV "ENV:Iconbar.prefs"
32 /*********************************************************************************************/
34 struct BIBPrefs bibprefs
;
36 /*********************************************************************************************/
38 static BOOL
Prefs_Load(STRPTR from
)
42 BPTR fh
= Open(from
, MODE_OLDFILE
);
45 retval
= Prefs_ImportFH(fh
);
52 /*********************************************************************************************/
54 BOOL
Prefs_ImportFH(BPTR fh
)
64 while ((FGets(fh
, buffer
, sizeof(buffer
))) != NULL
)
66 slen
= strlen(buffer
);
67 if (buffer
[slen
- 1] == '\n')
72 if (strncmp(buffer
, "BOING_PREFS", 11 ) != 0)
74 D(bug("[IconBarPrefs] %s: is not BOING BAR configuration file!\n"));
81 if (buffer
[0] == ';' )
84 strcpy(bibprefs
.docks
[dock
].name
, &buffer
[1]);
86 D(bug("[IconBarPrefs] %s buffer\n", &buffer
[1]));
90 strcpy(bibprefs
.docks
[dock
].programs
[program
], buffer
);
91 D(bug("[IconBarPrefs] data set %d / %d - %s\n", dock
, program
, bibprefs
.docks
[dock
].programs
[program
]));
100 for (i
= 0; (i
< BIB_MAX_DOCKS
) && (bibprefs
.docks
[i
].name
[0] != '\0'); i
++)
102 bug("Dock %s\n", bibprefs
.docks
[i
].name
);
104 for (j
= 0; (j
< BIB_MAX_PROGRAMS
) && (bibprefs
.docks
[i
].programs
[j
][0] != 0); j
++)
106 bug(" App %s\n", bibprefs
.docks
[i
].programs
[j
]);
114 /*********************************************************************************************/
116 BOOL
Prefs_ExportFH(BPTR fh
)
121 FPuts(fh
, "BOING_PREFS\n");
123 for (i
= 0; (i
< BIB_MAX_DOCKS
) && (bibprefs
.docks
[i
].name
[0] != '\0'); i
++)
126 FPuts(fh
, bibprefs
.docks
[i
].name
);
129 for (j
= 0; (j
< BIB_MAX_PROGRAMS
) && (bibprefs
.docks
[i
].programs
[j
][0] != 0); j
++)
131 FPuts(fh
, bibprefs
.docks
[i
].programs
[j
]);
139 /*********************************************************************************************/
141 BOOL
Prefs_HandleArgs(STRPTR from
, BOOL use
, BOOL save
)
147 if (!Prefs_Load(from
))
149 ShowMessage("Can't read from input file");
155 if (!Prefs_Load(PREFS_PATH_ENV
))
157 if (!Prefs_Load(PREFS_PATH_ENVARC
))
161 "Can't read from file " PREFS_PATH_ENVARC
162 ".\nUsing default values."
171 fh
= Open(PREFS_PATH_ENV
, MODE_NEWFILE
);
179 ShowMessage("Cant' open " PREFS_PATH_ENV
" for writing.");
184 fh
= Open(PREFS_PATH_ENVARC
, MODE_NEWFILE
);
192 ShowMessage("Cant' open " PREFS_PATH_ENVARC
" for writing.");
198 /*********************************************************************************************/
200 BOOL
Prefs_Default(VOID
)
202 D(bug("[IconBarPrefs] Prefs_Default\n"));
204 memset(&bibprefs
, 0, sizeof bibprefs
);