Project

General

Profile

« Previous | Next » 

Revision 2579

Added by stephane almost 14 years ago

UTILS_G
- New : GKeyFile
Complete api to read/write to the key files

View differences:

include/scol_plugin_win.h
1
/*! \file scol.h
2
*	\brief Scol plugin definition API
1
/*! \file scol_plugin_win.h
2
*	\brief Scol plugin definition API (MS Windows)
3 3
*   \author Sylvain HUET
4 4
*/
5 5

  
include/scol_plugin_lin.h
1
/*! \file scol_plugin_linux.h
2
*	\brief Scol plugin definition API (GNU / Linux)
3
*   \author Sylvain HUET
4
*/
1 5
/*
2 6
        SCOLPLUGIN.H . 1996-99 . Sylvain HUET
3 7

  
include/macros.h
1
/*! \file macros.h
2
*	\brief usefull Scol macros
3
*   \author Sylvain HUET, Stephane Bisaro
4
*/
1 5
/*
2 6
This source file is part of Scol
3 7
For the latest info, see http://www.scolring.org
include/scol_glib_keyfile.h
1
/*! \file scol_glib_keyfile.h
2
*	\brief header keyfile functions
3
*   \author Stephane Bisaro
4
*/
5

  
6
/*
7
This source file is part of Scol
8
For the latest info, see http://www.scolring.org
9

  
10
Copyright (c) 2010 Stephane Bisaro, aka Iri <iri@irizone.net>
11

  
12
This program is free software; you can redistribute it and/or modify it under
13
the terms of the GNU Lesser General Public License as published by the Free Software
14
Foundation; either version 2 of the License, or (at your option) any later
15
version.
16

  
17
This program is distributed in the hope that it will be useful, but WITHOUT
18
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
20

  
21
You should have received a copy of the GNU Lesser General Public License along with
22
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
24
http://www.gnu.org/copyleft/lesser.txt
25

  
26
For others informations, please contact us from http://www.scolring.org/
27
*/
28

  
29
#ifndef __SCOL_GLIB_INI_H__
30
#define __SCOL_GLIB_INI_H__
31

  
32
#include "main.h"
33
#include <glib/gstdio.h>
34

  
35
/* comment if  you 'd a 2.26 or + */
36
#define GLIB_224
37

  
38
#define GKEYFILE_PKG_NB         31
39
#define GKEYFILE_RFL_NB         0
40
#define OBJGKEYFILE_HANDLE      0
41

  
42

  
43

  
44
int ObjKeyFile;
45
/* internals functions */
46
int scol_g_key_file_read (GKeyFile *ini, mmachine m);
47

  
48

  
49
#endif  /* __SCOL_GLIB_INI_H__ */
keyfile.layout
1
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2
<CodeBlocks_layout_file>
3
	<ActiveTarget name="Release" />
4
	<File name="include\macros.h" open="1" top="0" tabpos="4">
5
		<Cursor position="2261" topLine="41" />
6
	</File>
7
	<File name="include\scol_glib_keyfile.h" open="1" top="0" tabpos="3">
8
		<Cursor position="1172" topLine="0" />
9
	</File>
10
	<File name="src\scol_glib_keyfile.c" open="1" top="1" tabpos="2">
11
		<Cursor position="2072" topLine="28" />
12
	</File>
13
</CodeBlocks_layout_file>
pcre.layout
1 1
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2 2
<CodeBlocks_layout_file>
3 3
	<ActiveTarget name="Release" />
4
	<File name="include\scol_glib_pregex.h" open="1" top="0" tabpos="1">
5
		<Cursor position="1425" topLine="24" />
4
	<File name="include\macros.h" open="0" top="0" tabpos="0">
5
		<Cursor position="2418" topLine="30" />
6 6
	</File>
7
	<File name="src\scol_glib_pregex.c" open="1" top="1" tabpos="2">
8
		<Cursor position="2719" topLine="96" />
7
	<File name="include\scol_glib_pregex.h" open="1" top="0" tabpos="2">
8
		<Cursor position="1422" topLine="61" />
9 9
	</File>
10
	<File name="src\scol_glib_pregex.c" open="1" top="1" tabpos="1">
11
		<Cursor position="14156" topLine="481" />
12
	</File>
10 13
</CodeBlocks_layout_file>
keyfile.depend
1
# depslib dependency file v1.0
2
1299624866 source:x:\utils_g\src\scol_glib_ini.c
3
	"../include/scol_glib_ini.h"
4

  
5
1299624866 e/scol_glib_ini.h"
6

  
7
1299625022 x:\utils_g\include\scol_glib_ini.h
8
	"main.h"
9
	<glib/gstdio.h>
10

  
11
1299710062 io.h>
12

  
13
1298417439 x:\utils_g\include\main.h
14
	<stdio.h>
15
	<stdlib.h>
16
	<string.h>
17
	<math.h>
18
	<libgen.h>
19
	<glib.h>
20
	<windows.h>
21
	"scol_plugin_win.h"
22
	"scol_plugin_lin.h"
23
	"macros.h"
24

  
25
1228530722 
26

  
27
1250305080 c:\mingw\include\stdio.h
28
	<_mingw.h>
29
	<stddef.h>
30
	<stdarg.h>
31
	<sys/types.h>
32

  
33
1250305082 .h>
34

  
35
1250305074 c:\mingw\include\_mingw.h
36

  
37
1250305082 c:\mingw\include\sys\types.h
38
	<_mingw.h>
39
	<stddef.h>
40

  
41
1250305080 c:\mingw\include\stdlib.h
42
	<_mingw.h>
43
	<stddef.h>
44

  
45
1250305080 c:\mingw\include\string.h
46
	<_mingw.h>
47
	<stddef.h>
48

  
49
1250305078 c:\mingw\include\math.h
50
	<_mingw.h>
51

  
52
1250305078 c:\mingw\include\libgen.h
53
	<_mingw.h>
54

  
55
1293381426 c:\mingw\include\glib-2.0\glib.h
56
	<glib/galloca.h>
57
	<glib/garray.h>
58
	<glib/gasyncqueue.h>
59
	<glib/gatomic.h>
60
	<glib/gbacktrace.h>
61
	<glib/gbase64.h>
62
	<glib/gbitlock.h>
63
	<glib/gbookmarkfile.h>
64
	<glib/gcache.h>
65
	<glib/gchecksum.h>
66
	<glib/gcompletion.h>
67
	<glib/gconvert.h>
68
	<glib/gdataset.h>
69
	<glib/gdate.h>
70
	<glib/gdatetime.h>
71
	<glib/gdir.h>
72
	<glib/gerror.h>
73
	<glib/gfileutils.h>
74
	<glib/ghash.h>
75
	<glib/ghook.h>
76
	<glib/ghostutils.h>
77
	<glib/giochannel.h>
78
	<glib/gkeyfile.h>
79
	<glib/glist.h>
80
	<glib/gmacros.h>
81
	<glib/gmain.h>
82
	<glib/gmappedfile.h>
83
	<glib/gmarkup.h>
84
	<glib/gmem.h>
85
	<glib/gmessages.h>
86
	<glib/gnode.h>
87
	<glib/goption.h>
88
	<glib/gpattern.h>
89
	<glib/gpoll.h>
90
	<glib/gprimes.h>
91
	<glib/gqsort.h>
92
	<glib/gquark.h>
93
	<glib/gqueue.h>
94
	<glib/grand.h>
95
	<glib/grel.h>
96
	<glib/gregex.h>
97
	<glib/gscanner.h>
98
	<glib/gsequence.h>
99
	<glib/gshell.h>
100
	<glib/gslice.h>
101
	<glib/gslist.h>
102
	<glib/gspawn.h>
103
	<glib/gstrfuncs.h>
104
	<glib/gstring.h>
105
	<glib/gtestutils.h>
106
	<glib/gthread.h>
107
	<glib/gthreadpool.h>
108
	<glib/gtimer.h>
109
	<glib/gtimezone.h>
110
	<glib/gtree.h>
111
	<glib/gtypes.h>
112
	<glib/gunicode.h>
113
	<glib/gurifuncs.h>
114
	<glib/gutils.h>
115
	<glib/gvarianttype.h>
116
	<glib/gvariant.h>
117
	<glib/gwin32.h>
118

  
119
1293381426 32.h>
120

  
121
1293381427 c:\mingw\include\glib-2.0\glib\galloca.h
122
	<glib/gtypes.h>
123
	<alloca.h>
124
	<malloc.h>
125

  
126
1293381427 c:\mingw\include\glib-2.0\glib\gtypes.h
127
	<glibconfig.h>
128
	<glib/gmacros.h>
129

  
130
1293381427 ros.h>
131

  
132
1293381426 c:\mingw\lib\glib-2.0\include\glibconfig.h
133
	<glib/gmacros.h>
134
	<limits.h>
135
	<float.h>
136

  
137
1293381427 c:\mingw\include\glib-2.0\glib\gmacros.h
138
	<stddef.h>
139

  
140
1250305078 c:\mingw\include\limits.h
141
	<_mingw.h>
142

  
143
1250305076 c:\mingw\include\float.h
144
	<_mingw.h>
145

  
146
1250305078 c:\mingw\include\malloc.h
147
	<_mingw.h>
148
	<stdlib.h>
149

  
150
1293381427 c:\mingw\include\glib-2.0\glib\garray.h
151
	<glib/gtypes.h>
152

  
153
1293381427 es.h>
154

  
155
1293381427 c:\mingw\include\glib-2.0\glib\gasyncqueue.h
156
	<glib/gthread.h>
157

  
158
1293381427 ead.h>
159

  
160
1293381427 c:\mingw\include\glib-2.0\glib\gthread.h
161
	<glib/gerror.h>
162
	<glib/gutils.h>
163
	<glib/gatomic.h>
164

  
165
1293381427 mic.h>
166

  
167
1293381427 c:\mingw\include\glib-2.0\glib\gerror.h
168
	<stdarg.h>
169
	<glib/gquark.h>
170

  
171
1293381427 rk.h>
172

  
173
1293381427 c:\mingw\include\glib-2.0\glib\gquark.h
174
	<glib/gtypes.h>
175

  
176
1293381427 c:\mingw\include\glib-2.0\glib\gutils.h
177
	<glib/gtypes.h>
178
	<stdarg.h>
179

  
180
1293381427 c:\mingw\include\glib-2.0\glib\gatomic.h
181
	<glib/gtypes.h>
182

  
183
1293381427 c:\mingw\include\glib-2.0\glib\gbacktrace.h
184
	<glib/gtypes.h>
185
	<signal.h>
186

  
187
1250305080 c:\mingw\include\signal.h
188
	<_mingw.h>
189

  
190
1293381427 c:\mingw\include\glib-2.0\glib\gbase64.h
191
	<glib/gtypes.h>
192

  
193
1293381427 c:\mingw\include\glib-2.0\glib\gbitlock.h
194
	<glib/gtypes.h>
195

  
196
1293381427 c:\mingw\include\glib-2.0\glib\gbookmarkfile.h
197
	<glib/gerror.h>
198
	<time.h>
199

  
200
1250305080 c:\mingw\include\time.h
201
	<_mingw.h>
202
	<stddef.h>
203

  
204
1293381427 c:\mingw\include\glib-2.0\glib\gcache.h
205
	<glib/glist.h>
206

  
207
1293381427 t.h>
208

  
209
1293381427 c:\mingw\include\glib-2.0\glib\glist.h
210
	<glib/gmem.h>
211

  
212
1293381427 c:\mingw\include\glib-2.0\glib\gmem.h
213
	<glib/gslice.h>
214
	<glib/gtypes.h>
215

  
216
1293381427 c:\mingw\include\glib-2.0\glib\gslice.h
217
	<glib/gtypes.h>
218

  
219
1293381427 c:\mingw\include\glib-2.0\glib\gchecksum.h
220
	<glib/gtypes.h>
221

  
222
1293381427 c:\mingw\include\glib-2.0\glib\gcompletion.h
223
	<glib/glist.h>
224

  
225
1293381427 c:\mingw\include\glib-2.0\glib\gconvert.h
226
	<glib/gerror.h>
227

  
228
1293381427 or.h>
229

  
230
1293381427 c:\mingw\include\glib-2.0\glib\gdataset.h
231
	<glib/gquark.h>
232

  
233
1293381427 c:\mingw\include\glib-2.0\glib\gdate.h
234
	<time.h>
235
	<glib/gtypes.h>
236
	<glib/gquark.h>
237

  
238
1293381427 c:\mingw\include\glib-2.0\glib\gdatetime.h
239
	<glib/gtimezone.h>
240

  
241
1293381427 ezone.h>
242

  
243
1293381427 c:\mingw\include\glib-2.0\glib\gtimezone.h
244
	<glib/gtypes.h>
245

  
246
1293381427 c:\mingw\include\glib-2.0\glib\gdir.h
247
	<glib/gerror.h>
248

  
249
1293381427 c:\mingw\include\glib-2.0\glib\gfileutils.h
250
	<glib/gerror.h>
251

  
252
1293381427 c:\mingw\include\glib-2.0\glib\ghash.h
253
	<glib/gtypes.h>
254
	<glib/glist.h>
255

  
256
1293381427 c:\mingw\include\glib-2.0\glib\ghook.h
257
	<glib/gmem.h>
258

  
259
1293381427 c:\mingw\include\glib-2.0\glib\ghostutils.h
260
	<glib/gtypes.h>
261

  
262
1293381427 c:\mingw\include\glib-2.0\glib\giochannel.h
263
	<glib/gconvert.h>
264
	<glib/gmain.h>
265
	<glib/gstring.h>
266

  
267
1293381427 ing.h>
268

  
269
1293381427 c:\mingw\include\glib-2.0\glib\gmain.h
270
	<glib/gpoll.h>
271
	<glib/gslist.h>
272
	<glib/gthread.h>
273

  
274
1293381427 c:\mingw\include\glib-2.0\glib\gpoll.h
275
	<glib/gtypes.h>
276

  
277
1293381427 c:\mingw\include\glib-2.0\glib\gslist.h
278
	<glib/gmem.h>
279

  
280
1293381427 c:\mingw\include\glib-2.0\glib\gstring.h
281
	<glib/gtypes.h>
282
	<glib/gunicode.h>
283
	<glib/gutils.h>
284

  
285
1293381427 ls.h>
286

  
287
1293381427 c:\mingw\include\glib-2.0\glib\gunicode.h
288
	<glib/gerror.h>
289
	<glib/gtypes.h>
290

  
291
1293381427 c:\mingw\include\glib-2.0\glib\gkeyfile.h
292
	<glib/gerror.h>
293

  
294
1293381427 c:\mingw\include\glib-2.0\glib\gmappedfile.h
295
	<glib/gerror.h>
296

  
297
1293381427 c:\mingw\include\glib-2.0\glib\gmarkup.h
298
	<stdarg.h>
299
	<glib/gerror.h>
300
	<glib/gslist.h>
301

  
302
1293381427 st.h>
303

  
304
1293381427 c:\mingw\include\glib-2.0\glib\gmessages.h
305
	<stdarg.h>
306
	<glib/gtypes.h>
307
	<glib/gmacros.h>
308

  
309
1293381427 c:\mingw\include\glib-2.0\glib\gnode.h
310
	<glib/gmem.h>
311

  
312
1293381427 c:\mingw\include\glib-2.0\glib\goption.h
313
	<glib/gerror.h>
314
	<glib/gquark.h>
315

  
316
1293381427 c:\mingw\include\glib-2.0\glib\gpattern.h
317
	<glib/gtypes.h>
318

  
319
1293381427 c:\mingw\include\glib-2.0\glib\gprimes.h
320
	<glib/gtypes.h>
321

  
322
1293381427 c:\mingw\include\glib-2.0\glib\gqsort.h
323
	<glib/gtypes.h>
324

  
325
1293381427 c:\mingw\include\glib-2.0\glib\gqueue.h
326
	<glib/glist.h>
327

  
328
1293381427 c:\mingw\include\glib-2.0\glib\grand.h
329
	<glib/gtypes.h>
330

  
331
1293381427 c:\mingw\include\glib-2.0\glib\grel.h
332
	<glib/gtypes.h>
333

  
334
1293381427 c:\mingw\include\glib-2.0\glib\gregex.h
335
	<glib/gerror.h>
336
	<glib/gstring.h>
337

  
338
1293381427 c:\mingw\include\glib-2.0\glib\gscanner.h
339
	<glib/gdataset.h>
340
	<glib/ghash.h>
341

  
342
1293381427 h.h>
343

  
344
1293381427 c:\mingw\include\glib-2.0\glib\gsequence.h
345
	<glib/gtypes.h>
346

  
347
1293381427 c:\mingw\include\glib-2.0\glib\gshell.h
348
	<glib/gerror.h>
349

  
350
1293381427 c:\mingw\include\glib-2.0\glib\gspawn.h
351
	<glib/gerror.h>
352

  
353
1293381427 c:\mingw\include\glib-2.0\glib\gstrfuncs.h
354
	<stdarg.h>
355
	<glib/gmacros.h>
356
	<glib/gtypes.h>
357

  
358
1293381427 c:\mingw\include\glib-2.0\glib\gtestutils.h
359
	<glib/gmessages.h>
360
	<glib/gstring.h>
361
	<glib/gerror.h>
362
	<glib/gslist.h>
363

  
364
1293381427 c:\mingw\include\glib-2.0\glib\gthreadpool.h
365
	<glib/gthread.h>
366

  
367
1293381427 c:\mingw\include\glib-2.0\glib\gtimer.h
368
	<glib/gtypes.h>
369

  
370
1293381427 c:\mingw\include\glib-2.0\glib\gtree.h
371
	<glib/gnode.h>
372

  
373
1293381427 e.h>
374

  
375
1293381427 c:\mingw\include\glib-2.0\glib\gurifuncs.h
376
	<glib/gtypes.h>
377

  
378
1293381427 c:\mingw\include\glib-2.0\glib\gvarianttype.h
379
	<glib/gmessages.h>
380
	<glib/gtypes.h>
381

  
382
1293381427 c:\mingw\include\glib-2.0\glib\gvariant.h
383
	<glib/gvarianttype.h>
384
	<glib/gstring.h>
385

  
386
1293381427 c:\mingw\include\glib-2.0\glib\gwin32.h
387
	<glib/gtypes.h>
388

  
389
1228530732 c:\mingw\include\windows.h
390
	<winresrc.h>
391
	<stdarg.h>
392
	<windef.h>
393
	<wincon.h>
394
	<winbase.h>
395
	<wingdi.h>
396
	<winuser.h>
397
	<winnls.h>
398
	<winver.h>
399
	<winnetwk.h>
400
	<winreg.h>
401
	<winsvc.h>
402
	<cderr.h>
403
	<dde.h>
404
	<ddeml.h>
405
	<dlgs.h>
406
	<imm.h>
407
	<lzexpand.h>
408
	<mmsystem.h>
409
	<nb30.h>
410
	<rpc.h>
411
	<shellapi.h>
412
	<winperf.h>
413
	<commdlg.h>
414
	<winspool.h>
415
	<winsock2.h>
416
	<winsock.h>
417
	<ole2.h>
418

  
419
1228530732 c:\mingw\include\winresrc.h
420
	<winuser.h>
421
	<winnt.h>
422
	<winver.h>
423
	<dde.h>
424
	<dlgs.h>
425
	<commctrl.h>
426

  
427
1293381427 h>
428

  
429
1228530734 c:\mingw\include\winuser.h
430

  
431
1228530732 c:\mingw\include\winnt.h
432
	<winerror.h>
433
	<string.h>
434
	<basetsd.h>
435
	<pshpack4.h>
436
	<poppack.h>
437

  
438
1228530732 >
439

  
440
1228530732 c:\mingw\include\winerror.h
441

  
442
1228530712 c:\mingw\include\basetsd.h
443

  
444
1228530724 c:\mingw\include\pshpack4.h
445

  
446
1228530724 c:\mingw\include\poppack.h
447

  
448
1228530734 c:\mingw\include\winver.h
449

  
450
1228530714 c:\mingw\include\dde.h
451

  
452
1228530714 c:\mingw\include\dlgs.h
453

  
454
1228530714 c:\mingw\include\commctrl.h
455
	<prsht.h>
456

  
457
1228530724 c:\mingw\include\prsht.h
458

  
459
1228530732 c:\mingw\include\windef.h
460
	<winnt.h>
461

  
462
1228530732 c:\mingw\include\wincon.h
463

  
464
1228530730 c:\mingw\include\winbase.h
465

  
466
1228530732 c:\mingw\include\wingdi.h
467

  
468
1228530732 c:\mingw\include\winnls.h
469

  
470
1228530732 c:\mingw\include\winnetwk.h
471

  
472
1228530732 c:\mingw\include\winreg.h
473

  
474
1228530734 c:\mingw\include\winsvc.h
475

  
476
1228530712 c:\mingw\include\cderr.h
477

  
478
1228530714 c:\mingw\include\ddeml.h
479

  
480
1228530716 c:\mingw\include\imm.h
481

  
482
1228530720 c:\mingw\include\lzexpand.h
483

  
484
1228530722 c:\mingw\include\mmsystem.h
485

  
486
1228530722 c:\mingw\include\nb30.h
487

  
488
1228530726 c:\mingw\include\rpc.h
489
	<windows.h>
490
	<rpcdce.h>
491
	<rpcnsi.h>
492
	<rpcnterr.h>
493
	<winerror.h>
494
	<excpt.h>
495

  
496
1228530726 c:\mingw\include\rpcdce.h
497
	<basetyps.h>
498
	<rpcdcep.h>
499

  
500
1228530712 c:\mingw\include\basetyps.h
501

  
502
1228530728 c:\mingw\include\rpcdcep.h
503

  
504
1228530728 c:\mingw\include\rpcnsi.h
505

  
506
1228530728 c:\mingw\include\rpcnterr.h
507

  
508
1250305076 c:\mingw\include\excpt.h
509
	<_mingw.h>
510
	<windef.h>
511

  
512
1228530728 c:\mingw\include\shellapi.h
513
	<pshpack2.h>
514
	<poppack.h>
515

  
516
1228530724 c:\mingw\include\pshpack2.h
517

  
518
1228530732 c:\mingw\include\winperf.h
519

  
520
1228530714 c:\mingw\include\commdlg.h
521
	<unknwn.h>
522
	<prsht.h>
523

  
524
1228530730 c:\mingw\include\unknwn.h
525
	<windows.h>
526
	<objfwd.h>
527
	<wtypes.h>
528

  
529
1228530724 c:\mingw\include\objfwd.h
530
	<basetyps.h>
531

  
532
1228530734 c:\mingw\include\wtypes.h
533
	<rpc.h>
534
	<rpcndr.h>
535

  
536
1228530728 c:\mingw\include\rpcndr.h
537
	<rpcnsip.h>
538
	<objfwd.h>
539

  
540
1228530728 c:\mingw\include\rpcnsip.h
541

  
542
1228530734 c:\mingw\include\winspool.h
543

  
544
1228530734 c:\mingw\include\winsock2.h
545
	<windows.h>
546

  
547
1228530732 c:\mingw\include\winsock.h
548
	<windows.h>
549
	<mswsock.h>
550

  
551
1228530722 c:\mingw\include\mswsock.h
552

  
553
1228530724 c:\mingw\include\ole2.h
554
	<winerror.h>
555
	<objbase.h>
556
	<olectlid.h>
557
	<oleauto.h>
558
	<oleidl.h>
559

  
560
1228530724 c:\mingw\include\objbase.h
561
	<rpc.h>
562
	<rpcndr.h>
563
	<stdlib.h>
564
	<basetyps.h>
565
	<wtypes.h>
566
	<unknwn.h>
567
	<objidl.h>
568
	<cguid.h>
569

  
570
1228530724 c:\mingw\include\objidl.h
571
	<objfwd.h>
572

  
573
1228530712 c:\mingw\include\cguid.h
574

  
575
1228530724 c:\mingw\include\olectlid.h
576

  
577
1228530724 c:\mingw\include\oleauto.h
578
	<oaidl.h>
579

  
580
1228530722 c:\mingw\include\oaidl.h
581
	<windows.h>
582
	<ole2.h>
583

  
584
1228530724 c:\mingw\include\oleidl.h
585
	<objfwd.h>
586

  
587
1299757380 x:\utils_g\include\scol_plugin_win.h
588
	<windows.h>
589
	<stdio.h>
590
	<stdlib.h>
591

  
592
1299757369 x:\utils_g\include\scol_plugin_lin.h
593
	<stdio.h>
594
	<stdlib.h>
595

  
596
1299757512 x:\utils_g\include\macros.h
597

  
598
1293381427 c:\mingw\include\glib-2.0\glib\gstdio.h
599
	<glib/gprintf.h>
600
	<sys/stat.h>
601

  
602
1293381427 c:\mingw\include\glib-2.0\glib\gprintf.h
603
	<glib.h>
604
	<stdio.h>
605
	<stdarg.h>
606

  
607
1250305082 c:\mingw\include\sys\stat.h
608
	<_mingw.h>
609
	<stddef.h>
610
	<sys/types.h>
611

  
612
1299761247 source:x:\utils_g\src\scol_glib_keyfile.c
613
	"../include/scol_glib_keyfile.h"
614

  
615
1299710064 e/scol_glib_keyfile.h"
616

  
617
1299761255 x:\utils_g\include\scol_glib_keyfile.h
618
	"main.h"
619
	<glib/gstdio.h>
620

  
621
1299756261 source:/home/iri/Works/xp/utils_g/src/scol_glib_keyfile.c
622
	"../include/scol_glib_keyfile.h"
623

  
624
1299755949 /home/iri/Works/xp/utils_g/include/scol_glib_keyfile.h
625
	"main.h"
626
	<glib/gstdio.h>
627

  
628
1298417439 /home/iri/Works/xp/utils_g/include/main.h
629
	<stdio.h>
630
	<stdlib.h>
631
	<string.h>
632
	<math.h>
633
	<libgen.h>
634
	<glib.h>
635
	<windows.h>
636
	"scol_plugin_win.h"
637
	"scol_plugin_lin.h"
638
	"macros.h"
639

  
640
1273400331 /usr/include/glib-2.0/glib.h
641
	<glib/galloca.h>
642
	<glib/garray.h>
643
	<glib/gasyncqueue.h>
644
	<glib/gatomic.h>
645
	<glib/gbacktrace.h>
646
	<glib/gbase64.h>
647
	<glib/gbitlock.h>
648
	<glib/gbookmarkfile.h>
649
	<glib/gcache.h>
650
	<glib/gchecksum.h>
651
	<glib/gcompletion.h>
652
	<glib/gconvert.h>
653
	<glib/gdataset.h>
654
	<glib/gdate.h>
655
	<glib/gdir.h>
656
	<glib/gerror.h>
657
	<glib/gfileutils.h>
658
	<glib/ghash.h>
659
	<glib/ghook.h>
660
	<glib/ghostutils.h>
661
	<glib/giochannel.h>
662
	<glib/gkeyfile.h>
663
	<glib/glist.h>
664
	<glib/gmacros.h>
665
	<glib/gmain.h>
666
	<glib/gmappedfile.h>
667
	<glib/gmarkup.h>
668
	<glib/gmem.h>
669
	<glib/gmessages.h>
670
	<glib/gnode.h>
671
	<glib/goption.h>
672
	<glib/gpattern.h>
673
	<glib/gpoll.h>
674
	<glib/gprimes.h>
675
	<glib/gqsort.h>
676
	<glib/gquark.h>
677
	<glib/gqueue.h>
678
	<glib/grand.h>
679
	<glib/grel.h>
680
	<glib/gregex.h>
681
	<glib/gscanner.h>
682
	<glib/gsequence.h>
683
	<glib/gshell.h>
684
	<glib/gslice.h>
685
	<glib/gslist.h>
686
	<glib/gspawn.h>
687
	<glib/gstrfuncs.h>
688
	<glib/gstring.h>
689
	<glib/gtestutils.h>
690
	<glib/gthread.h>
691
	<glib/gthreadpool.h>
692
	<glib/gtimer.h>
693
	<glib/gtree.h>
694
	<glib/gtypes.h>
695
	<glib/gunicode.h>
696
	<glib/gurifuncs.h>
697
	<glib/gutils.h>
698
	<glib/gvarianttype.h>
699
	<glib/gvariant.h>
700
	<glib/gwin32.h>
701

  
702
1273400331 /usr/include/glib-2.0/glib/galloca.h
703
	<glib/gtypes.h>
704
	<alloca.h>
705
	<malloc.h>
706

  
707
1273400331 /usr/include/glib-2.0/glib/gtypes.h
708
	<glibconfig.h>
709
	<glib/gmacros.h>
710

  
711
1273400330 /usr/lib/glib-2.0/include/glibconfig.h
712
	<glib/gmacros.h>
713
	<limits.h>
714
	<float.h>
715

  
716
1273400331 /usr/include/glib-2.0/glib/gmacros.h
717
	<stddef.h>
718

  
719
1273400331 /usr/include/glib-2.0/glib/garray.h
720
	<glib/gtypes.h>
721

  
722
1273400331 /usr/include/glib-2.0/glib/gasyncqueue.h
723
	<glib/gthread.h>
724

  
725
1273400331 /usr/include/glib-2.0/glib/gthread.h
726
	<glib/gerror.h>
727
	<glib/gtypes.h>
728
	<glib/gutils.h>
729
	<glib/gatomic.h>
730

  
731
1273400331 /usr/include/glib-2.0/glib/gerror.h
732
	<stdarg.h>
733
	<glib/gquark.h>
734

  
735
1273400331 /usr/include/glib-2.0/glib/gquark.h
736
	<glib/gtypes.h>
737

  
738
1273400331 /usr/include/glib-2.0/glib/gutils.h
739
	<glib/gtypes.h>
740
	<stdarg.h>
741

  
742
1273400331 /usr/include/glib-2.0/glib/gatomic.h
743
	<glib/gtypes.h>
744

  
745
1273400331 /usr/include/glib-2.0/glib/gbacktrace.h
746
	<glib/gtypes.h>
747
	<signal.h>
748

  
749
1273400331 /usr/include/glib-2.0/glib/gbase64.h
750
	<glib/gtypes.h>
751

  
752
1273400331 /usr/include/glib-2.0/glib/gbitlock.h
753
	<glib/gtypes.h>
754

  
755
1273400331 /usr/include/glib-2.0/glib/gbookmarkfile.h
756
	<glib/gerror.h>
757
	<time.h>
758

  
759
1273400331 /usr/include/glib-2.0/glib/gcache.h
760
	<glib/glist.h>
761

  
762
1273400331 /usr/include/glib-2.0/glib/glist.h
763
	<glib/gmem.h>
764

  
765
1273400331 /usr/include/glib-2.0/glib/gmem.h
766
	<glib/gslice.h>
767
	<glib/gtypes.h>
768

  
769
1273400331 /usr/include/glib-2.0/glib/gslice.h
770
	<glib/gtypes.h>
771

  
772
1273400331 /usr/include/glib-2.0/glib/gchecksum.h
773
	<glib/gtypes.h>
774

  
775
1273400331 /usr/include/glib-2.0/glib/gcompletion.h
776
	<glib/glist.h>
777

  
778
1273400331 /usr/include/glib-2.0/glib/gconvert.h
779
	<glib/gerror.h>
780

  
781
1273400331 /usr/include/glib-2.0/glib/gdataset.h
782
	<glib/gquark.h>
783

  
784
1273400331 /usr/include/glib-2.0/glib/gdate.h
785
	<time.h>
786
	<glib/gtypes.h>
787
	<glib/gquark.h>
788

  
789
1273400331 /usr/include/glib-2.0/glib/gdir.h
790
	<glib/gerror.h>
791

  
792
1273400331 /usr/include/glib-2.0/glib/gfileutils.h
793
	<glib/gerror.h>
794

  
795
1273400331 /usr/include/glib-2.0/glib/ghash.h
796
	<glib/gtypes.h>
797
	<glib/glist.h>
798

  
799
1273400331 /usr/include/glib-2.0/glib/ghook.h
800
	<glib/gmem.h>
801

  
802
1273400331 /usr/include/glib-2.0/glib/ghostutils.h
803
	<glib/gtypes.h>
804

  
805
1273400331 /usr/include/glib-2.0/glib/giochannel.h
806
	<glib/gconvert.h>
807
	<glib/gmain.h>
808
	<glib/gstring.h>
809

  
810
1273400331 /usr/include/glib-2.0/glib/gmain.h
811
	<glib/gpoll.h>
812
	<glib/gslist.h>
813
	<glib/gthread.h>
814

  
815
1273400331 /usr/include/glib-2.0/glib/gpoll.h
816
	<glib/gtypes.h>
817

  
818
1273400331 /usr/include/glib-2.0/glib/gslist.h
819
	<glib/gmem.h>
820

  
821
1273400331 /usr/include/glib-2.0/glib/gstring.h
822
	<glib/gtypes.h>
823
	<glib/gunicode.h>
824
	<glib/gutils.h>
825

  
826
1273400331 /usr/include/glib-2.0/glib/gunicode.h
827
	<glib/gerror.h>
828
	<glib/gtypes.h>
829

  
830
1273400331 /usr/include/glib-2.0/glib/gkeyfile.h
831
	<glib/gerror.h>
832

  
833
1273400331 /usr/include/glib-2.0/glib/gmappedfile.h
834
	<glib/gerror.h>
835

  
836
1273400331 /usr/include/glib-2.0/glib/gmarkup.h
837
	<stdarg.h>
838
	<glib/gerror.h>
839
	<glib/gslist.h>
840

  
841
1273400331 /usr/include/glib-2.0/glib/gmessages.h
842
	<stdarg.h>
843
	<glib/gtypes.h>
844
	<glib/gmacros.h>
845

  
846
1273400331 /usr/include/glib-2.0/glib/gnode.h
847
	<glib/gmem.h>
848

  
849
1273400331 /usr/include/glib-2.0/glib/goption.h
850
	<glib/gerror.h>
851
	<glib/gquark.h>
852

  
853
1273400331 /usr/include/glib-2.0/glib/gpattern.h
854
	<glib/gtypes.h>
855

  
856
1273400331 /usr/include/glib-2.0/glib/gprimes.h
857
	<glib/gtypes.h>
858

  
859
1273400331 /usr/include/glib-2.0/glib/gqsort.h
860
	<glib/gtypes.h>
861

  
862
1273400331 /usr/include/glib-2.0/glib/gqueue.h
863
	<glib/glist.h>
864

  
865
1273400331 /usr/include/glib-2.0/glib/grand.h
866
	<glib/gtypes.h>
867

  
868
1273400331 /usr/include/glib-2.0/glib/grel.h
869
	<glib/gtypes.h>
870

  
871
1273400331 /usr/include/glib-2.0/glib/gregex.h
872
	<glib/gerror.h>
873
	<glib/gstring.h>
874

  
875
1273400331 /usr/include/glib-2.0/glib/gscanner.h
876
	<glib/gdataset.h>
877
	<glib/ghash.h>
878

  
879
1273400331 /usr/include/glib-2.0/glib/gsequence.h
880
	<glib/gtypes.h>
881

  
882
1273400331 /usr/include/glib-2.0/glib/gshell.h
883
	<glib/gerror.h>
884

  
885
1273400331 /usr/include/glib-2.0/glib/gspawn.h
886
	<glib/gerror.h>
887

  
888
1273400331 /usr/include/glib-2.0/glib/gstrfuncs.h
889
	<stdarg.h>
890
	<glib/gmacros.h>
891
	<glib/gtypes.h>
892

  
893
1273400331 /usr/include/glib-2.0/glib/gtestutils.h
894
	<glib/gmessages.h>
895
	<glib/gstring.h>
896
	<glib/gtypes.h>
897
	<glib/gerror.h>
898
	<glib/gslist.h>
899

  
900
1273400331 /usr/include/glib-2.0/glib/gthreadpool.h
901
	<glib/gthread.h>
902

  
903
1273400331 /usr/include/glib-2.0/glib/gtimer.h
904
	<glib/gtypes.h>
905

  
906
1273400331 /usr/include/glib-2.0/glib/gtree.h
907
	<glib/gnode.h>
908

  
909
1273400331 /usr/include/glib-2.0/glib/gurifuncs.h
910
	<glib/gtypes.h>
911

  
912
1273400331 /usr/include/glib-2.0/glib/gvarianttype.h
913
	<glib/gmessages.h>
914
	<glib/gtypes.h>
915

  
916
1273400331 /usr/include/glib-2.0/glib/gvariant.h
917
	<glib/gvarianttype.h>
918
	<glib/gstring.h>
919

  
920
1273400331 /usr/include/glib-2.0/glib/gwin32.h
921
	<glib/gtypes.h>
922

  
923
1297894138 /home/iri/Works/xp/utils_g/include/scol_plugin_win.h
924
	<windows.h>
925
	<stdio.h>
926
	<stdlib.h>
927

  
928
1296481042 /home/iri/Works/xp/utils_g/include/scol_plugin_lin.h
929
	<stdio.h>
930
	<stdlib.h>
931

  
932
1298486475 /home/iri/Works/xp/utils_g/include/macros.h
933

  
934
1273400331 /usr/include/glib-2.0/glib/gstdio.h
935
	<glib/gprintf.h>
936
	<sys/stat.h>
937

  
938
1273400331 /usr/include/glib-2.0/glib/gprintf.h
939
	<glib.h>
940
	<stdio.h>
941
	<stdarg.h>
942

  
pcre.depend
294 294
1293381427 c:\mingw\include\glib-2.0\glib\gwin32.h
295 295
	<glib/gtypes.h>
296 296

  
297
1298498356 source:x:\utils_g\src\scol_glib_pregex.c
297
1298579809 source:x:\utils_g\src\scol_glib_pregex.c
298 298
	"../include/scol_glib_pregex.h"
299 299

  
300
1298498380 x:\utils_g\include\scol_glib_pregex.h
300
1298579825 x:\utils_g\include\scol_glib_pregex.h
301 301
	<stdio.h>
302 302
	<stdlib.h>
303 303
	<string.h>
src/scol_glib_keyfile.c
1
/*! \file scol_glib_keyfile.c
2
*	\brief all functions of this API
3
*   \author Stephane Bisaro
4
*/
5
/*
6
This source file is part of Scol
7
For the latest info, see http://www.scolring.org
8

  
9
Copyright (c) 2010 Stephane Bisaro, aka Iri <iri@irizone.net>
10

  
11
This program is free software; you can redistribute it and/or modify it under
12
the terms of the GNU Lesser General Public License as published by the Free Software
13
Foundation; either version 2 of the License, or (at your option) any later
14
version.
15

  
16
This program is distributed in the hope that it will be useful, but WITHOUT
17
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
19

  
20
You should have received a copy of the GNU Lesser General Public License along with
21
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
23
http://www.gnu.org/copyleft/lesser.txt
24

  
25
For others informations, please contact us from http://www.scolring.org/
26
*/
27

  
28
#include "../include/scol_glib_keyfile.h"
29

  
30
#if ((defined _WIN32) || (defined __WIN32__))
31
cbmachine ww;
32
#endif
33
mmachine  mm;
34

  
35

  
36
/**
37
 * \brief GKF_VALUE_RAW : I : flag used to load a key file. The raw value associated with key under group.
38
 * The value can be escaped string
39
 */
40
int GKF_VALUE_RAW (mmachine m) { return MMpush (m, ITOM (1)); }
41
/**
42
 * \brief GKF_VALUE_STRING : I : flag used to load a key file. The string value associated with key under group.
43
 * Unlike GKF_VALUE_RAW, any escaped sequence are unescaped
44
 */
45
int GKF_VALUE_STRING (mmachine m) { return MMpush (m, ITOM (2)); }
46
/**
47
 * \brief GKF_VALUE_INTEGER : Not implemented yet
48
 */
49
int GKF_VALUE_INTEGER (mmachine m) { return MMpush (m, ITOM (3)); }
50
/**
51
 * \brief GKF_VALUE_INTEGER64 : Not implemented yet
52
 */
53
int GKF_VALUE_INTEGER64 (mmachine m) { return MMpush (m, ITOM (4)); }
54
/**
55
 * \brief GKF_VALUE_UINTEGER64 : Not implemented yet
56
 */
57
int GKF_VALUE_UINTEGER64 (mmachine m) { return MMpush (m, ITOM (5)); }
58
/**
59
 * \brief GKF_VALUE_DOUBLE : Not implemented yet
60
 */
61
int GKF_VALUE_DOUBLE (mmachine m) { return MMpush (m, ITOM (6)); }
62
/**
63
 * \brief GKF_VALUE_BOOLEAN : Not implemented yet
64
 */
65
int GKF_VALUE_BOOLEAN (mmachine m) { return MMpush (m, ITOM (7)); }
66

  
67

  
68
/**
69
 * \brief _gkeyFileReadP : read a key file
70
 * fun [P S] [[S [[S S] r1]] r1]
71
 *
72
 * \param P : any file (read reference only)
73
 * \param S : the list seperator, or nil (default ";")
74
 * \return [[S [[S S] r1]] r1] : the list of datas : group names and for each group name, a list of tuple [key value]
75
 */
76
int SCOL_gkeyFileReadP (mmachine m)
77
{
78
    int mfile, msep;
79
    gboolean b;
80
    GKeyFile *ini;
81
    GError *err = NULL;
82

  
83
    msep = MTOP (MMpull (m));
84
    mfile = MMpull (m);
85
    if (mfile == NIL)
86
    {
87
        MMpush (m, NIL);
88
        return 0;
89
    }
90

  
91
    ini = g_key_file_new ();
92
    if (msep != NIL)
93
        g_key_file_set_list_separator (ini, (MMstart (m, msep))[0]);
94
    b = g_key_file_load_from_file (ini, MMstartstr (m, MTOP (mfile)), G_KEY_FILE_NONE, &err);
95
    if (!b)
96
    {
97
        MMechostr (0, "SCOL_gkeyFileReadP load error : %d .:. %s\n", err->code, err->message);
98
        g_error_free (err);
99
        MMpush (m, NIL);
100
        return 0;
101
    }
102
    g_key_file_free (ini);
103
    return scol_g_key_file_read (ini, m);
104
}
105

  
106

  
107

  
108

  
109

  
110

  
111

  
112

  
113
/* ========================================================================= */
114

  
115

  
116
/** \private
117
 * internal function : get groups names
118
 */
119
int scol_g_key_file_get_groups (mmachine m, int flag)
120
{
121
    int mini;
122
    int i = 0;
123
    gsize len = 0;
124
    GKeyFile *ini;
125
    gchar **groups;
126

  
127
    mini = MMpull (m);
128
    if (mini == NIL)
129
    {
130
        MMechostr (0, "scol_g_key_file_get_groups error : object is nil\n");
131
        MMpush (m, NIL);
132
        return 0;
133
    }
134

  
135
    ini = (GKeyFile*) MMfetch (m, MTOP (mini), OBJGKEYFILE_HANDLE);
136
    groups = g_key_file_get_groups (ini, &len);
137
    if (flag)
138
        MMpush (m, ITOM ((int) len));   /* I */
139
    else
140
    {
141
        for (i = 0; i < (int) len; i++)
142
            Mpushstrbloc (m, groups[i]);
143
        MMpush (m, NIL);
144
        for (i = 0; i < (int) len; i++)
145
        {
146
            MMpush (m, ITOM (2));
147
            MBdeftab (m);
148
        }                               /* [S r1] */
149
    }
150
    g_strfreev (groups);
151
    return 0;
152
}
153
/** \private
154
 * internal function : return a list of the entire content ( [[S [[S S] r1]] r1] )
155
 */
156
int scol_g_key_file_read (GKeyFile *ini, mmachine m)
157
{
158
    int i, j;
159
    gsize ngroups, nkeys;
160
    gchar **groups;
161

  
162
    groups = g_key_file_get_groups (ini, &ngroups);
163
    for (i = 0; i < (int) ngroups; i++)
164
    {
165
        gchar **keys;
166

  
167
        Mpushstrbloc (m, groups[i]);    /* S */
168

  
169
        keys = g_key_file_get_keys (ini, groups[i], &nkeys, NULL);
170
        for (j = 0; j < (int) nkeys; j++)
171
        {
172
            gchar *value;
173

  
174
            value = g_key_file_get_value (ini, groups[i], keys[j], NULL);
175
            Mpushstrbloc (m, keys[j]);
176
            Mpushstrbloc (m, value);
177
            MMpush (m, ITOM (2));
178
            MBdeftab (m);               /* [S S] */
179
            g_free (value);
180
        }
181
        g_strfreev (keys);
182
        MMpush (m, NIL);
183
        for (j = 0; j < (int) nkeys; j++)
184
        {
185
            MMpush (m, ITOM (2));
186
            MBdeftab (m);
187
        }                               /* [[S S] r1] */
188
        MMpush (m, ITOM (2));
189
        MBdeftab (m);                   /* [S [[S S] r1]] */
190
    }
191
    g_strfreev (groups);
192
    MMpush (m, NIL);
193
    for (i = 0; i < (int) ngroups; i++)
194
    {
195
        MMpush (m, ITOM (2));
196
        MBdeftab (m);
197
    }                                   /* [[S [[S S] r1]] r1] */
198
    return 0;
199
}
200

  
201
/** \private
202
 * internal function : load a file or data
203
 */
204
int scol_g_key_file_load (mmachine m, int typ)
205
{
206
    int mchannel, mfile, msep, mflag;
207
    int initab;
208
    gboolean b;
209
    GKeyFileFlags flag = G_KEY_FILE_NONE;
210
    GKeyFile *ini;
211
    GError *err = NULL;
212

  
213
    mflag = MTOI (MMpull (m));
214
    msep = MTOP (MMpull (m));
215
    mfile = MMpull (m);
216
    mchannel = MMget (m, 0);
217

  
218
    if (mchannel == NIL)
219
    {
220
        MMechostr (0, "scol_g_key_file_load error : channel is nil\n");
221
        MMpush (m, NIL);
222
        return 0;
223
    }
224
    if (mfile == NIL)
225
    {
226
        MMechostr (0, "scol_g_key_file_load error : file is nil\n");
227
        MMpush (m, NIL);
228
        return 0;
229
    }
230

  
231
    ini = g_key_file_new ();
232
    if (msep != NIL)
233
        g_key_file_set_list_separator (ini, (MMstart (m, msep))[0]);
234

  
235
    if (mflag == 1)
236
        flag = G_KEY_FILE_KEEP_COMMENTS;
237
    else if (mflag == 2)
238
        flag = G_KEY_FILE_KEEP_TRANSLATIONS;
239
    else if (mflag == 3)
240
        flag = G_KEY_FILE_KEEP_TRANSLATIONS|G_KEY_FILE_KEEP_COMMENTS;
241

  
242
    if (typ)
243
        b = g_key_file_load_from_data (ini, MMstartstr (m, MTOP (mfile)), MMsizestr (m, MTOP (mfile)), flag, &err);
244
    else
245
        b = g_key_file_load_from_file (ini, MMstartstr (m, MTOP (mfile)), flag, &err);
246
    if ((!b) || (err != NULL))
247
    {
248
        MMechostr (0, "scol_g_key_file_load error : loading is failed -> %s\n", err->message);
249
        g_error_free (err);
250
        MMpush (m, NIL);
251
        return 0;
252
    }
253

  
254
    initab = MMmalloc (m, sizeof (ini) + 1, TYPETAB);
255
    if (initab == NIL)
256
    {
257
        MMechostr (0, "scol_g_key_file_load error : not enough memory\n");
258
        MMpull (m);
259
        MMpush (m, NIL);
260
        g_key_file_free (ini);
261
        return 0;
262
    }
263
    MMstore (m, initab, OBJGKEYFILE_HANDLE, (int) ini);
264
    MMpush (m, PTOM (initab));
265
    OBJcreate (m, ObjKeyFile, (int) ini, -1, -1);
266
    return 0;
267
}
268

  
269
/**
270
 * \brief _gkeyFileLoadP : Loads a key file from any valid file
271
 *
272
 * fun [Chn P S I] ObjKeyFile
273
 *
274
 * \param Chn : the channel
275
 * \param P : any read referenced file
276
 * \param S : the list separator or nil (default ";"). One character only (if more, they are ignored)
277
 * \param I : flag :
278
 *      0 -> No flags, default behaviour
279
 *      1 -> Use this flag if you plan to write the (possibly modified) contents of the key file back to a file;
280
 *      otherwise all comments will be lost when the key file is written back.
281
 *      2 -> Use this flag if you plan to write the (possibly modified) contents of the key file back to a file;
282
 *      otherwise only the translations for the current language will be written back.
283
 *      3 -> 1 and 2
284
 * \return ObjKeyFile : the new object, or nil if error
285
 *
286
 * Importante note : if you want get/set any localized key, be sure set the flag to 2 (or 3) !
287
 */
288
int SCOL_gkeyFileLoadP (mmachine m)
289
{
290
    return scol_g_key_file_load (m, 0);
291
}
292

  
293
/**
294
 * \brief _gkeyFileLoadS : Loads a key file from any valid data
295
 *
296
 * fun [Chn P S I] ObjKeyFile
297
 *
298
 * \param Chn : the channel
299
 * \param S : any valid content
300
 * \param S : the list separator or nil (default ";"). One character only (if more, they are ignored)
301
 * \param I : flag :
302
 *      0 -> No flags, default behaviour
303
 *      1 -> Use this flag if you plan to write the (possibly modified) contents of the key file back to a file;
304
 *      otherwise all comments will be lost when the key file is written back.
305
 *      2 -> Use this flag if you plan to write the (possibly modified) contents of the key file back to a file;
306
 *      otherwise only the translations for the current language will be written back.
307
 *      3 -> 1 and 2
308
 * \return ObjKeyFile : the new object, or nil if error
309
 */
310
int SCOL_gkeyFileLoadS (mmachine m)
311
{
312
    return scol_g_key_file_load (m, 1);
313
}
314

  
315

  
316
/**
317
 * \brief _gkeyFileSave : save a keyfile to a filename
318
 *
319
 * fun [ObjKeyFile W] I
320
 *
321
 * \param ObjKeyFile : a valid object
322
 * \param W : a Scol write referenced filename
323
 * \return I : 0 if success or nil if error (see log message)
324
 */
325
int SCOL_gkeyFileSave (mmachine m)
326
{
327
    int mini, mwfile;
328
    gboolean b;
329
    GKeyFile *ini;
330
    gchar *content, *wfile;
331
    gsize len = 0;
332
    GError *err = NULL;
333

  
334
    mwfile = MMpull (m);
335
    mini = MMpull (m);
336

  
337
    if ((mini == NIL) || (mwfile == NIL))
338
    {
339
        MMechostr (0, "SCOL_gkeyFileSave error : bad(s) argument(s) !\n");
340
        MMpush (m, NIL);
341
        return 0;
342
    }
343

  
344
    ini = (GKeyFile*) MMfetch (m, MTOP (mini), OBJGKEYFILE_HANDLE);
345
    wfile = MMstartstr (m, MTOP (mwfile));
346
    content = g_key_file_to_data (ini, &len, &err);
347
    if ((content == NULL) || (err != NULL))
348
    {
349
        MMechostr (0, "SCOL_gkeyFileSave error : %d ->  %s !\n", err->code, err->message);
350
        g_error_free (err);
351
        MMpush (m, NIL);
352
        return 0;
353
    }
354
    b = g_file_set_contents (wfile, content, len, &err);
355
    if ((!b) || (err != NULL))
356
    {
357
        MMechostr (0, "SCOL_gkeyFileSave error : %d ->  %s !\n", err->code, err->message);
358
        g_error_free (err);
359
        MMpush (m, NIL);
360
        return 0;
361
    }
362
    g_free (content);
363
    MMpush (m, ITOM (0));
364
    return 0;
365
}
366

  
367
/**
368
 *\brief _gkeyFileDestroy : Destroys an object
369
 *
370
 * \param ObjKeyFile
371
 * \return I : O or nil if error
372
 */
373
int SCOL_gkeyFileDestroy (mmachine m)
374
{
375
    int mini;
376
    GKeyFile *ini;
377

  
378
    mini = MMpull (m);
379
    if (mini == NIL)
380
    {
381
        MMechostr (0, "SCOL_gkeyFileDestroy error : object is nil\n");
382
        MMpush (m, NIL);
383
        return 0;
384
    }
385

  
386
    ini = (GKeyFile*) MMfetch (m, MTOP (mini), OBJGKEYFILE_HANDLE);
387
    g_key_file_free (ini);
388
    OBJdelTM (m, ObjKeyFile, mini);
389
    MMpush (m, 0);
390

  
391
    return 0;
392
}
393

  
394
/**
395
 * \brief _gkeyFileGetContent : Returns the content of key file
396
 *
397
 * fun [ObjKeyFile] [S I]
398
 *
399
 * \param ObjKeyFile : any valid object
400
 * \return [S I] : a tuple : the content and its length or nil if error
401
 */
402
int SCOL_gkeyFileGetContent (mmachine m)
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff