Project

General

Profile

« Previous | Next » 

Revision 2581

Added by stephane almost 14 years ago

UTILS_G
- GBase : miscellaneous functions

View differences:

gbase.depend
1
# depslib dependency file v1.0
2
1299610787 source:x:\utils_g\src\scol_gbase.c
3
	"../include/scol_gbase.h"
4

  
5
1299610799 x:\utils_g\include\scol_gbase.h
6
	"main.h"
7
	<glib/gstdio.h>
8

  
9
1298417439 x:\utils_g\include\main.h
10
	<stdio.h>
11
	<stdlib.h>
12
	<string.h>
13
	<math.h>
14
	<libgen.h>
15
	<glib.h>
16
	<windows.h>
17
	"scol_plugin_win.h"
18
	"scol_plugin_lin.h"
19
	"macros.h"
20

  
21
1250305080 c:\mingw\include\stdio.h
22
	<_mingw.h>
23
	<stddef.h>
24
	<stdarg.h>
25
	<sys/types.h>
26

  
27
1250305074 c:\mingw\include\_mingw.h
28

  
29
1250305082 c:\mingw\include\sys\types.h
30
	<_mingw.h>
31
	<stddef.h>
32

  
33
1250305080 c:\mingw\include\stdlib.h
34
	<_mingw.h>
35
	<stddef.h>
36

  
37
1250305080 c:\mingw\include\string.h
38
	<_mingw.h>
39
	<stddef.h>
40

  
41
1250305078 c:\mingw\include\math.h
42
	<_mingw.h>
43

  
44
1250305078 c:\mingw\include\libgen.h
45
	<_mingw.h>
46

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

  
111
1293381427 c:\mingw\include\glib-2.0\glib\galloca.h
112
	<glib/gtypes.h>
113
	<alloca.h>
114
	<malloc.h>
115

  
116
1293381427 c:\mingw\include\glib-2.0\glib\gtypes.h
117
	<glibconfig.h>
118
	<glib/gmacros.h>
119

  
120
1293381426 c:\mingw\lib\glib-2.0\include\glibconfig.h
121
	<glib/gmacros.h>
122
	<limits.h>
123
	<float.h>
124

  
125
1293381427 c:\mingw\include\glib-2.0\glib\gmacros.h
126
	<stddef.h>
127

  
128
1250305078 c:\mingw\include\limits.h
129
	<_mingw.h>
130

  
131
1250305076 c:\mingw\include\float.h
132
	<_mingw.h>
133

  
134
1250305078 c:\mingw\include\malloc.h
135
	<_mingw.h>
136
	<stdlib.h>
137

  
138
1293381427 c:\mingw\include\glib-2.0\glib\garray.h
139
	<glib/gtypes.h>
140

  
141
1293381427 c:\mingw\include\glib-2.0\glib\gasyncqueue.h
142
	<glib/gthread.h>
143

  
144
1293381427 c:\mingw\include\glib-2.0\glib\gthread.h
145
	<glib/gerror.h>
146
	<glib/gutils.h>
147
	<glib/gatomic.h>
148

  
149
1293381427 c:\mingw\include\glib-2.0\glib\gerror.h
150
	<stdarg.h>
151
	<glib/gquark.h>
152

  
153
1293381427 c:\mingw\include\glib-2.0\glib\gquark.h
154
	<glib/gtypes.h>
155

  
156
1293381427 c:\mingw\include\glib-2.0\glib\gutils.h
157
	<glib/gtypes.h>
158
	<stdarg.h>
159

  
160
1293381427 c:\mingw\include\glib-2.0\glib\gatomic.h
161
	<glib/gtypes.h>
162

  
163
1293381427 c:\mingw\include\glib-2.0\glib\gbacktrace.h
164
	<glib/gtypes.h>
165
	<signal.h>
166

  
167
1250305080 c:\mingw\include\signal.h
168
	<_mingw.h>
169

  
170
1293381427 c:\mingw\include\glib-2.0\glib\gbase64.h
171
	<glib/gtypes.h>
172

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

  
176
1293381427 c:\mingw\include\glib-2.0\glib\gbookmarkfile.h
177
	<glib/gerror.h>
178
	<time.h>
179

  
180
1250305080 c:\mingw\include\time.h
181
	<_mingw.h>
182
	<stddef.h>
183

  
184
1293381427 c:\mingw\include\glib-2.0\glib\gcache.h
185
	<glib/glist.h>
186

  
187
1293381427 c:\mingw\include\glib-2.0\glib\glist.h
188
	<glib/gmem.h>
189

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

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

  
197
1293381427 c:\mingw\include\glib-2.0\glib\gchecksum.h
198
	<glib/gtypes.h>
199

  
200
1293381427 c:\mingw\include\glib-2.0\glib\gcompletion.h
201
	<glib/glist.h>
202

  
203
1293381427 c:\mingw\include\glib-2.0\glib\gconvert.h
204
	<glib/gerror.h>
205

  
206
1293381427 c:\mingw\include\glib-2.0\glib\gdataset.h
207
	<glib/gquark.h>
208

  
209
1293381427 c:\mingw\include\glib-2.0\glib\gdate.h
210
	<time.h>
211
	<glib/gtypes.h>
212
	<glib/gquark.h>
213

  
214
1293381427 c:\mingw\include\glib-2.0\glib\gdatetime.h
215
	<glib/gtimezone.h>
216

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

  
220
1293381427 c:\mingw\include\glib-2.0\glib\gdir.h
221
	<glib/gerror.h>
222

  
223
1293381427 c:\mingw\include\glib-2.0\glib\gfileutils.h
224
	<glib/gerror.h>
225

  
226
1293381427 c:\mingw\include\glib-2.0\glib\ghash.h
227
	<glib/gtypes.h>
228
	<glib/glist.h>
229

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

  
233
1293381427 c:\mingw\include\glib-2.0\glib\ghostutils.h
234
	<glib/gtypes.h>
235

  
236
1293381427 c:\mingw\include\glib-2.0\glib\giochannel.h
237
	<glib/gconvert.h>
238
	<glib/gmain.h>
239
	<glib/gstring.h>
240

  
241
1293381427 c:\mingw\include\glib-2.0\glib\gmain.h
242
	<glib/gpoll.h>
243
	<glib/gslist.h>
244
	<glib/gthread.h>
245

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

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

  
252
1293381427 c:\mingw\include\glib-2.0\glib\gstring.h
253
	<glib/gtypes.h>
254
	<glib/gunicode.h>
255
	<glib/gutils.h>
256

  
257
1293381427 c:\mingw\include\glib-2.0\glib\gunicode.h
258
	<glib/gerror.h>
259
	<glib/gtypes.h>
260

  
261
1293381427 c:\mingw\include\glib-2.0\glib\gkeyfile.h
262
	<glib/gerror.h>
263

  
264
1293381427 c:\mingw\include\glib-2.0\glib\gmappedfile.h
265
	<glib/gerror.h>
266

  
267
1293381427 c:\mingw\include\glib-2.0\glib\gmarkup.h
268
	<stdarg.h>
269
	<glib/gerror.h>
270
	<glib/gslist.h>
271

  
272
1293381427 c:\mingw\include\glib-2.0\glib\gmessages.h
273
	<stdarg.h>
274
	<glib/gtypes.h>
275
	<glib/gmacros.h>
276

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

  
280
1293381427 c:\mingw\include\glib-2.0\glib\goption.h
281
	<glib/gerror.h>
282
	<glib/gquark.h>
283

  
284
1293381427 c:\mingw\include\glib-2.0\glib\gpattern.h
285
	<glib/gtypes.h>
286

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

  
290
1293381427 c:\mingw\include\glib-2.0\glib\gqsort.h
291
	<glib/gtypes.h>
292

  
293
1293381427 c:\mingw\include\glib-2.0\glib\gqueue.h
294
	<glib/glist.h>
295

  
296
1293381427 c:\mingw\include\glib-2.0\glib\grand.h
297
	<glib/gtypes.h>
298

  
299
1293381427 c:\mingw\include\glib-2.0\glib\grel.h
300
	<glib/gtypes.h>
301

  
302
1293381427 c:\mingw\include\glib-2.0\glib\gregex.h
303
	<glib/gerror.h>
304
	<glib/gstring.h>
305

  
306
1293381427 c:\mingw\include\glib-2.0\glib\gscanner.h
307
	<glib/gdataset.h>
308
	<glib/ghash.h>
309

  
310
1293381427 c:\mingw\include\glib-2.0\glib\gsequence.h
311
	<glib/gtypes.h>
312

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

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

  
319
1293381427 c:\mingw\include\glib-2.0\glib\gstrfuncs.h
320
	<stdarg.h>
321
	<glib/gmacros.h>
322
	<glib/gtypes.h>
323

  
324
1293381427 c:\mingw\include\glib-2.0\glib\gtestutils.h
325
	<glib/gmessages.h>
326
	<glib/gstring.h>
327
	<glib/gerror.h>
328
	<glib/gslist.h>
329

  
330
1293381427 c:\mingw\include\glib-2.0\glib\gthreadpool.h
331
	<glib/gthread.h>
332

  
333
1293381427 c:\mingw\include\glib-2.0\glib\gtimer.h
334
	<glib/gtypes.h>
335

  
336
1293381427 c:\mingw\include\glib-2.0\glib\gtree.h
337
	<glib/gnode.h>
338

  
339
1293381427 c:\mingw\include\glib-2.0\glib\gurifuncs.h
340
	<glib/gtypes.h>
341

  
342
1293381427 c:\mingw\include\glib-2.0\glib\gvarianttype.h
343
	<glib/gmessages.h>
344
	<glib/gtypes.h>
345

  
346
1293381427 c:\mingw\include\glib-2.0\glib\gvariant.h
347
	<glib/gvarianttype.h>
348
	<glib/gstring.h>
349

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

  
353
1228530732 c:\mingw\include\windows.h
354
	<winresrc.h>
355
	<stdarg.h>
356
	<windef.h>
357
	<wincon.h>
358
	<winbase.h>
359
	<wingdi.h>
360
	<winuser.h>
361
	<winnls.h>
362
	<winver.h>
363
	<winnetwk.h>
364
	<winreg.h>
365
	<winsvc.h>
366
	<cderr.h>
367
	<dde.h>
368
	<ddeml.h>
369
	<dlgs.h>
370
	<imm.h>
371
	<lzexpand.h>
372
	<mmsystem.h>
373
	<nb30.h>
374
	<rpc.h>
375
	<shellapi.h>
376
	<winperf.h>
377
	<commdlg.h>
378
	<winspool.h>
379
	<winsock2.h>
380
	<winsock.h>
381
	<ole2.h>
382

  
383
1228530732 c:\mingw\include\winresrc.h
384
	<winuser.h>
385
	<winnt.h>
386
	<winver.h>
387
	<dde.h>
388
	<dlgs.h>
389
	<commctrl.h>
390

  
391
1228530734 c:\mingw\include\winuser.h
392

  
393
1228530732 c:\mingw\include\winnt.h
394
	<winerror.h>
395
	<string.h>
396
	<basetsd.h>
397
	<pshpack4.h>
398
	<poppack.h>
399

  
400
1228530732 c:\mingw\include\winerror.h
401

  
402
1228530712 c:\mingw\include\basetsd.h
403

  
404
1228530724 c:\mingw\include\pshpack4.h
405

  
406
1228530724 c:\mingw\include\poppack.h
407

  
408
1228530734 c:\mingw\include\winver.h
409

  
410
1228530714 c:\mingw\include\dde.h
411

  
412
1228530714 c:\mingw\include\dlgs.h
413

  
414
1228530714 c:\mingw\include\commctrl.h
415
	<prsht.h>
416

  
417
1228530724 c:\mingw\include\prsht.h
418

  
419
1228530732 c:\mingw\include\windef.h
420
	<winnt.h>
421

  
422
1228530732 c:\mingw\include\wincon.h
423

  
424
1228530730 c:\mingw\include\winbase.h
425

  
426
1228530732 c:\mingw\include\wingdi.h
427

  
428
1228530732 c:\mingw\include\winnls.h
429

  
430
1228530732 c:\mingw\include\winnetwk.h
431

  
432
1228530732 c:\mingw\include\winreg.h
433

  
434
1228530734 c:\mingw\include\winsvc.h
435

  
436
1228530712 c:\mingw\include\cderr.h
437

  
438
1228530714 c:\mingw\include\ddeml.h
439

  
440
1228530716 c:\mingw\include\imm.h
441

  
442
1228530720 c:\mingw\include\lzexpand.h
443

  
444
1228530722 c:\mingw\include\mmsystem.h
445

  
446
1228530722 c:\mingw\include\nb30.h
447

  
448
1228530726 c:\mingw\include\rpc.h
449
	<windows.h>
450
	<rpcdce.h>
451
	<rpcnsi.h>
452
	<rpcnterr.h>
453
	<winerror.h>
454
	<excpt.h>
455

  
456
1228530726 c:\mingw\include\rpcdce.h
457
	<basetyps.h>
458
	<rpcdcep.h>
459

  
460
1228530712 c:\mingw\include\basetyps.h
461

  
462
1228530728 c:\mingw\include\rpcdcep.h
463

  
464
1228530728 c:\mingw\include\rpcnsi.h
465

  
466
1228530728 c:\mingw\include\rpcnterr.h
467

  
468
1250305076 c:\mingw\include\excpt.h
469
	<_mingw.h>
470
	<windef.h>
471

  
472
1228530728 c:\mingw\include\shellapi.h
473
	<pshpack2.h>
474
	<poppack.h>
475

  
476
1228530724 c:\mingw\include\pshpack2.h
477

  
478
1228530732 c:\mingw\include\winperf.h
479

  
480
1228530714 c:\mingw\include\commdlg.h
481
	<unknwn.h>
482
	<prsht.h>
483

  
484
1228530730 c:\mingw\include\unknwn.h
485
	<windows.h>
486
	<objfwd.h>
487
	<wtypes.h>
488

  
489
1228530724 c:\mingw\include\objfwd.h
490
	<basetyps.h>
491

  
492
1228530734 c:\mingw\include\wtypes.h
493
	<rpc.h>
494
	<rpcndr.h>
495

  
496
1228530728 c:\mingw\include\rpcndr.h
497
	<rpcnsip.h>
498
	<objfwd.h>
499

  
500
1228530728 c:\mingw\include\rpcnsip.h
501

  
502
1228530734 c:\mingw\include\winspool.h
503

  
504
1228530734 c:\mingw\include\winsock2.h
505
	<windows.h>
506

  
507
1228530732 c:\mingw\include\winsock.h
508
	<windows.h>
509
	<mswsock.h>
510

  
511
1228530722 c:\mingw\include\mswsock.h
512

  
513
1228530724 c:\mingw\include\ole2.h
514
	<winerror.h>
515
	<objbase.h>
516
	<olectlid.h>
517
	<oleauto.h>
518
	<oleidl.h>
519

  
520
1228530724 c:\mingw\include\objbase.h
521
	<rpc.h>
522
	<rpcndr.h>
523
	<stdlib.h>
524
	<basetyps.h>
525
	<wtypes.h>
526
	<unknwn.h>
527
	<objidl.h>
528
	<cguid.h>
529

  
530
1228530724 c:\mingw\include\objidl.h
531
	<objfwd.h>
532

  
533
1228530712 c:\mingw\include\cguid.h
534

  
535
1228530724 c:\mingw\include\olectlid.h
536

  
537
1228530724 c:\mingw\include\oleauto.h
538
	<oaidl.h>
539

  
540
1228530722 c:\mingw\include\oaidl.h
541
	<windows.h>
542
	<ole2.h>
543

  
544
1228530724 c:\mingw\include\oleidl.h
545
	<objfwd.h>
546

  
547
1297894138 x:\utils_g\include\scol_plugin_win.h
548
	<windows.h>
549
	<stdio.h>
550
	<stdlib.h>
551

  
552
1296481042 x:\utils_g\include\scol_plugin_lin.h
553
	<stdio.h>
554
	<stdlib.h>
555

  
556
1298486475 x:\utils_g\include\macros.h
557

  
558
1293381427 c:\mingw\include\glib-2.0\glib\gstdio.h
559
	<glib/gprintf.h>
560
	<sys/stat.h>
561

  
562
1293381427 c:\mingw\include\glib-2.0\glib\gprintf.h
563
	<glib.h>
564
	<stdio.h>
565
	<stdarg.h>
566

  
567
1250305082 c:\mingw\include\sys\stat.h
568
	<_mingw.h>
569
	<stddef.h>
570
	<sys/types.h>
571

  
include/scol_gbase.h
1
/*
2
This source file is part of Scol
3
For the latest info, see http://www.scolring.org
4

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

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

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

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

  
21
For others informations, please contact us from http://www.scolring.org/
22
*/
23

  
24
#ifndef __SCOL_GBASE_H__
25
#define __SCOL_GBASE_H__
26

  
27
#include "main.h"
28
#include <glib/gstdio.h>
29

  
30
#define GBASE_PKG_NB        13
31

  
32

  
33
#endif  /* __SCOL_GBASE_H__ */
gbase.cbp
1
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2
<CodeBlocks_project_file>
3
	<FileVersion major="1" minor="6" />
4
	<Project>
5
		<Option title="gbase" />
6
		<Option pch_mode="2" />
7
		<Option compiler="gcc" />
8
		<Build>
9
			<Target title="Debug">
10
				<Option output="bin\Debug\gbase" prefix_auto="1" extension_auto="1" />
11
				<Option object_output="obj\Debug\" />
12
				<Option type="3" />
13
				<Option compiler="gcc" />
14
				<Option createDefFile="1" />
15
				<Option createStaticLib="1" />
16
				<Compiler>
17
					<Add option="-O2" />
18
					<Add option="-Wshadow" />
19
					<Add option="-Winit-self" />
20
					<Add option="-Wredundant-decls" />
21
					<Add option="-Wcast-align" />
22
					<Add option="-Wundef" />
23
					<Add option="-Wfloat-equal" />
24
					<Add option="-Winline" />
25
					<Add option="-Wunreachable-code" />
26
					<Add option="-Wmissing-declarations" />
27
					<Add option="-Wswitch-enum" />
28
					<Add option="-Wswitch-default" />
29
					<Add option="-pedantic" />
30
					<Add option="-Wextra" />
31
					<Add option="-Wall" />
32
					<Add option="-g" />
33
				</Compiler>
34
				<Linker>
35
					<Add option="-s" />
36
				</Linker>
37
			</Target>
38
			<Target title="Release">
39
				<Option output="bin\gbase" prefix_auto="1" extension_auto="1" />
40
				<Option object_output="obj\Release\" />
41
				<Option type="3" />
42
				<Option compiler="gcc" />
43
				<Option createDefFile="1" />
44
				<Option createStaticLib="1" />
45
				<Compiler>
46
					<Add option="-O2" />
47
				</Compiler>
48
				<Linker>
49
					<Add option="-s" />
50
				</Linker>
51
			</Target>
52
		</Build>
53
		<Compiler>
54
			<Add option="-O1" />
55
			<Add option="-Wshadow" />
56
			<Add option="-Winit-self" />
57
			<Add option="-Wredundant-decls" />
58
			<Add option="-Wcast-align" />
59
			<Add option="-Wundef" />
60
			<Add option="-Wfloat-equal" />
61
			<Add option="-Winline" />
62
			<Add option="-Wunreachable-code" />
63
			<Add option="-Wswitch-enum" />
64
			<Add option="-Wswitch-default" />
65
			<Add option="-pedantic" />
66
			<Add option="-Wextra" />
67
			<Add option="-Wall" />
68
			<Add option="-mms-bitfields" />
69
			<Add directory="$(#gtk.include)" />
70
			<Add directory="$(#gtk.include)\gtk-2.0" />
71
			<Add directory="$(#gtk.include)\cairo" />
72
			<Add directory="$(#gtk.include)\gdk" />
73
			<Add directory="$(#gtk.include)\glib-2.0" />
74
			<Add directory="$(#gtk.lib)\glib-2.0\include" />
75
			<Add directory="$(#gtk.include)\pango-1.0" />
76
			<Add directory="$(#gtk.lib)\gtk-2.0\include" />
77
			<Add directory="$(#gtk.include)\atk-1.0" />
78
		</Compiler>
79
		<Linker>
80
			<Add library="gtk-win32-2.0" />
81
			<Add library="gobject-2.0" />
82
			<Add library="glib-2.0" />
83
			<Add directory="$(#gtk.lib)" />
84
		</Linker>
85
		<Unit filename="include\macros.h" />
86
		<Unit filename="include\main.h" />
87
		<Unit filename="include\scol_gbase.h" />
88
		<Unit filename="include\scol_plugin_lin.h" />
89
		<Unit filename="include\scol_plugin_win.h" />
90
		<Unit filename="src\scol_gbase.c">
91
			<Option compilerVar="CC" />
92
		</Unit>
93
		<Extensions>
94
			<code_completion />
95
			<debugger />
96
		</Extensions>
97
	</Project>
98
</CodeBlocks_project_file>
src/scol_gbase.c
1
/*
2
This source file is part of Scol
3
For the latest info, see http://www.scolring.org
4

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

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

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

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

  
21
For others informations, please contact us from http://www.scolring.org/
22
*/
23

  
24
#include "../include/scol_gbase.h"
25

  
26
#if ((defined _WIN32) || (defined __WIN32__))
27
cbmachine ww;
28
#endif
29
mmachine  mm;
30

  
31

  
32
/**
33
 * \brief _gbaseUserName : Returns the user (or real) name
34
 *
35
 * fun [] S
36
 *
37
 * \param : nothing
38
 * \return S : this name
39
 */
40
int SCOL_gbaseUserName (mmachine m)
41
{
42
    const gchar * name;
43

  
44
    name = g_get_user_name ();
45
    if (name == NULL)
46
        name = g_get_real_name ();
47

  
48
    if (name == NULL)
49
    {
50
        Mpushstrbloc (m, "unknown");
51
        return 0;
52
    }
53
    Mpushstrbloc (m, (char *) name);
54
    return 0;
55
}
56

  
57
/**
58
 * \brief _gBaseHostName : Returns the host name
59
 *
60
 * fun [] S
61
 *
62
 * \param : nothing
63
 * \return S : this name
64
 */
65
int SCOL_gBaseHostName (mmachine m)
66
{
67
    const gchar * name;
68

  
69
    name = g_get_host_name ();
70
    if (name == NULL)
71
    {
72
        Mpushstrbloc (m, "unknown");
73
        return 0;
74
    }
75
    Mpushstrbloc (m, (char *) name);
76
    return 0;
77
}
78

  
79
/**
80
 * \brief _gBaseDirCur : Returns the current directory (by default on MS Windows "C:\Program Files\Scol Voyager")
81
 *
82
 * fun [] S
83
 *
84
 * \param : nothing
85
 * \return S : this directory
86
 */
87
int SCOL_gBaseDirCur (mmachine m)
88
{
89
    const gchar * name;
90

  
91
    name = g_get_current_dir ();
92
    if (name == NULL)
93
    {
94
        Mpushstrbloc (m, "unknown");
95
        return 0;
96
    }
97
    Mpushstrbloc (m, (char *) name);
98
    return 0;
99
}
100

  
101
/**
102
 * \brief _gBasePathAbsolute : Returns 1 if the given file_name is an absolute file name.
103
 *
104
 * fun [S] I
105
 *
106
 * \param S : any path
107
 * \return I : 1 if TRUE,otherwise 0
108
 */
109
 int SCOL_gBasePathAbsolute (mmachine m)
110
 {
111
    int mpath;
112
    gboolean value;
113

  
114
    mpath = MMpull (m);
115
    if (mpath == NIL)
116
    {
117
        MMpush (m, NIL);
118
        return 0;
119
    }
120

  
121
    value = g_path_is_absolute (MMstartstr (m, MTOP (mpath)));
122
    MMpush (m, ITOM (value));
123
    return 0;
124
 }
125

  
126
/**
127
 * \brief _gBasePathBase : Returns the last component of the filename
128
 *
129
 * fun [S] S
130
 *
131
 * \param S : any path
132
 * \return S : this last component
133
 */
134
int SCOL_gBasePathBase (mmachine m)
135
{
136
    int mpath;
137
    gchar *base;
138

  
139
    mpath = MMpull (m);
140
    if (mpath == NIL)
141
    {
142
        MMpush (m, NIL);
143
        return 0;
144
    }
145
    base = g_path_get_basename (MMstartstr (m, MTOP (mpath)));
146
    Mpushstrbloc (m, base);
147
    g_free (base);
148
    return 0;
149
}
150

  
151
/**
152
 * \brief _gBasePathDir : Returns the directory components of a file name.
153
 *
154
 * fun [S] S
155
 *
156
 * \param S : any path
157
 * \return S : this directory
158
 */
159
int SCOL_gBasePathDir (mmachine m)
160
{
161
    int mpath;
162
    gchar *dir;
163

  
164
    mpath = MMpull (m);
165
    if (mpath == NIL)
166
    {
167
        MMpush (m, NIL);
168
        return 0;
169
    }
170
    dir = g_path_get_dirname (MMstartstr (m, MTOP (mpath)));
171
    Mpushstrbloc (m, dir);
172
    g_free (dir);
173
    return 0;
174
}
175

  
176
/**
177
 * \brief _gBasePathBuild : Creates a filename from a list of elements using the correct separator for filenames.
178
 *
179
 * fun [[S r1] I] S
180
 *
181
 * \param [S r1] : a list of elements (typically, a list of directory : a :: b :: c :: file.ext)
182
 * \param I : 1 : OS separator, otherwise Scol separator (/)
183
 * \return S : the filename
184
 */
185
int SCOL_gBasePathBuild (mmachine m)
186
{
187
    int mlist, mflag;
188
    int size = 0, i = 0;
189
    gchar **list;
190
    gchar *fn;
191

  
192
    mflag = MTOI (MMpull (m));
193
    mlist = MMget (m, 0);
194
    if (mlist == NIL)
195
    {
196
        MMpush (m, NIL);
197
        return 0;
198
    }
199
    mlist = MTOP (mlist);
200

  
201
    while (mlist != NIL)
202
    {
203
        size++;
204
        mlist = MMfetch (m, mlist, 1)>>1;
205
    }
206

  
207
    list = g_new0 (gchar*, size + 2);
208
    mlist = MTOP (MMpull (m));
209
    for (; i < size; i++)
210
    {
211
        list[i] = MMstartstr (m, MTOP (MMfetch (m, mlist, 0)));
212
        mlist = MTOP (MMfetch (m, mlist, 1));
213
    }
214

  
215
    if (mflag == 1)
216
        fn = g_build_filenamev (list);
217
    else
218
        fn = g_build_pathv ("/", list);
219
    Mpushstrbloc (m, fn);
220
    g_free (list);
221
    g_free (fn);
222
    return 0;
223
}
224

  
225
/**
226
 * \brief _gBaseStringUTF8 : Converts a string in the current locale into a UTF-8 string or reverse.
227
 *
228
 * fun [S I] S
229
 *
230
 * \param S : any string
231
 * \param I : 1 to UTF8, 0 to current locale
232
 * \return : the new string
233
 */
234
int SCOL_gBaseStringUTF8 (mmachine m)
235
{
236
    int mstring, mflag;
237
    gchar *string;
238

  
239
    mflag = MMpull (m);
240
    mstring = MMpull (m);
241

  
242
    if (mstring == NIL)
243
    {
244
        MMpush (m, NIL);
245
        return 0;
246
    }
247
    if (mflag)
248
        string = SCOLUTF8 (MMstartstr (m, MTOP (mstring)), -1);
249
    else
250
        string = UTF8SCOL (MMstartstr (m, MTOP (mstring)), -1);
251
    Mpushstrbloc (m, string);
252
    g_free (string);
253
    return 0;
254
}
255

  
256
/**
257
 * \brief _gbaseChecksumS : Computes the checksum of a string.
258
 *
259
 * fun [S I] S
260
 *
261
 * \param S : any string
262
 * \param I : the hashing algorithm to use : 0 -> MD5 (default), 1 -> SHA-1, 2 -> SHA-256
263
 * \return S : the checksum as an hexadecimal string.
264
 */
265
int SCOL_gbaseChecksumS (mmachine m)
266
{
267
    int mstring, mtype;
268
    GChecksumType type = G_CHECKSUM_MD5;
269
    gchar *string;
270

  
271
    mtype = MTOI (MMpull (m));
272
    mstring = MMpull (m);
273

  
274
    if (mstring == NIL)
275
    {
276
        MMpush (m, NIL);
277
        return 0;
278
    }
279
    mstring = MTOP (mstring);
280

  
281
    if (mtype == 1)
282
        type = G_CHECKSUM_SHA1;
283
    else if (mtype == 2)
284
        type = G_CHECKSUM_SHA256;
285

  
286
    string = g_compute_checksum_for_string (type, MMstartstr (m, mstring), -1);
287
    Mpushstrbloc (m, string);
288
    g_free (string);
289
    return 0;
290
}
291

  
292
/**
293
 * \brief _gbaseChecksumP : Computes the checksum of a file.
294
 *
295
 * fun [P I] S
296
 *
297
 * \param S : any file (read referenced only)
298
 * \param I : the hashing algorithm to use : 0 -> MD5 (default), 1 -> SHA-1, 2 -> SHA-256
299
 * \return S : the checksum as an hexadecimal string.
300
 */
301
int SCOL_gbaseChecksumP (mmachine m)
302
{
303
    /* #define SCSP_MAX_SIZE G_MAXUINT-1 */ /* i'm stupid ! */
304
    #define SCSP_MAX_SIZE 1024*32   /* 32 ko / each loop */
305
    int mfile, mtype;
306
    guchar data[SCSP_MAX_SIZE];
307
    gsize size = 0;
308
    GChecksumType type = G_CHECKSUM_MD5;
309
    GChecksum *cs;
310
    const gchar *string;
311
    FILE *file;
312

  
313
    mtype = MTOI (MMpull (m));
314
    mfile = MMpull (m);
315

  
316
    if (mfile == NIL)
317
    {
318
        MMpush (m, NIL);
319
        return 0;
320
    }
321
    mfile = MTOP (mfile);
322

  
323
    file = fopen (MMstartstr (m, mfile), "rb");
324
    if (file == NULL)
325
    {
326
        MMpush (m, NIL);
327
        return 0;
328
    }
329

  
330
    if (mtype == 1)
331
        type = G_CHECKSUM_SHA1;
332
    else if (mtype == 2)
333
        type = G_CHECKSUM_SHA256;
334

  
335
    cs = g_checksum_new (type);
336
    do
337
    {
338
        size = fread((void *) data, sizeof (guchar), SCSP_MAX_SIZE, file);
339
        g_checksum_update (cs, data, size);
340
    }
341
    while (size == SCSP_MAX_SIZE);
342
    fclose (file);
343

  
344
    string = g_checksum_get_string (cs);
345
    Mpushstrbloc (m, (char *) string);
346
    g_checksum_free (cs);
347
    return 0;
348
}
349

  
350
/**
351
 * \brief _gbaseSleep : Pauses the current thread for the given number of milliseconds.
352
 *
353
 * fun [I] I
354
 *
355
 * \param I : the number of milliseconds
356
 * \return I : 0 if success, nil if error
357
 */
358
int SCOL_gbaseSleep (mmachine m)
359
{
360
    int msleep;
361

  
362
    msleep = MTOI (MMpull (m));
363
    if (msleep <= 0)
364
    {
365
        MMpush (m, NIL);
366
        return 0;
367
    }
368

  
369
    g_usleep (1000*msleep);
370
    MMpush (m, ITOM (0));
371
    return 0;
372
}
373

  
374
/**
375
 * \brief _gbaseFileStat : it should not be used, at this time
376
 *
377
 * fun [P] [I I I I]
378
 *
379
 * \param P : a filename (read reference only)
380
 * \return [I I I I] : size, last access, last modification, last state changed
381
 */
382
int SCOL_gbaseFileStat (mmachine m)
383
{
384
    int mfile;
385
    int result;
386
    GStatBuf *s = NULL;
387

  
388
    mfile = MMpull(m);
389
    if (mfile == NIL)
390
    {
391
        MMpush (m, NIL);
392
        return 0;
393
    }
394
    mfile = MTOP (mfile);
395

  
396
    result = g_stat (MMstartstr (m, mfile), s);
397
    if (result != 0)
398
    {
399
        MMpush (m, NIL);
400
        return 0;
401
    }
402
    MMpush (m, ITOM (s->st_size));
403
    MMpush (m, ITOM (s->st_atime));
404
    MMpush (m, ITOM (s->st_mtime));
405
    MMpush (m, ITOM (s->st_ctime));
406
    MMpush (m, ITOM (4));
407
    MBdeftab (m);
408

  
409
    return 0;
410
}
411

  
412
/**
413
 * \brief _gbaseIsIp : Tests if a string is a form of an IPv4 or IPv6 address (like "123.210.012.231").
414
 * fun [S] I
415
 * \param S : any string
416
 * \return I : 1 if TRUE, 0 if FALSE
417
 */
418
int SCOL_gbaseIsIp (mmachine m)
419
{
420
    int ms;
421

  
422
    ms = MMpull (m);
423
    if (ms == NIL)
424
    {
425
        MMpush (m, NIL);
426
        return 0;
427
    }
428
    MMpush (m, ITOM (g_hostname_is_ip_address (MMstartstr (m, MTOP (ms)))));
429
    return 0;
430
}
431

  
432

  
433

  
434

  
435

  
436

  
437
/* API d?finitions : */
438

  
439
char* gbase_name[GBASE_PKG_NB]=
440
{
441
    "_gbaseUserName",
442
    "_gBaseHostName",
443
    "_gBaseDirCur",
444
    "_gBasePathAbsolute",
445
    "_gBasePathBase",
446
    "_gBasePathDir",
447
    "_gBasePathBuild",
448
    "_gBaseStringUTF8",
449
    "_gbaseChecksumS",
450
    "_gbaseChecksumP",
451
    "_gbaseSleep",
452
    "_gbaseFileStat",
453
    "_gbaseIsIp"
454
};
455

  
456
int (*gbase_fun[GBASE_PKG_NB])(mmachine m)=
457
{
458
    SCOL_gbaseUserName,
459
    SCOL_gBaseHostName,
460
    SCOL_gBaseDirCur,
461
    SCOL_gBasePathAbsolute,
462
    SCOL_gBasePathBase,
463
    SCOL_gBasePathDir,
464
    SCOL_gBasePathBuild,
465
    SCOL_gBaseStringUTF8,
466
    SCOL_gbaseChecksumS,
467
    SCOL_gbaseChecksumP,
468
    SCOL_gbaseSleep,
469
    SCOL_gbaseFileStat,
470
    SCOL_gbaseIsIp
471
};
472

  
473
int gbase_narg[GBASE_PKG_NB]=
474
{
475
    0,      /* SCOL_gbaseUserName */
476
    0,      /* SCOL_gBaseHostName */
477
    0,      /* SCOL_gBaseDirCur */
478
    1,      /* SCOL_gBasePathAbsolute */
479
    1,      /* SCOL_gBasePathBase */
480
    1,      /* SCOL_gBasePathDir */
481
    2,      /* SCOL_gBasePathBuild */
482
    2,       /* SCOL_gBaseStringUTF8 */
483
    2,       /* SCOL_gbaseChecksumS */
484
    2,       /* SCOL_gbaseChecksumP */
485
    1,       /* SCOL_gbaseSleep */
486
    1,       /* SCOL_gbaseFileStat */
487
    1       /* SCOL_gbaseIsIp */
488
};
489

  
490
char* gbase_type[GBASE_PKG_NB]=
491
{
492
    "fun [] S",                     /* SCOL_gbaseUserName */
493
    "fun [] S",                     /* SCOL_gBaseHostName */
494
    "fun [] S",                     /* SCOL_gBaseDirCur */
495
    "fun [S] I",                    /* SCOL_gBasePathAbsolute */
496
    "fun [S] S",                    /* SCOL_gBasePathBase */
497
    "fun [S] S",                    /* SCOL_gBasePathDir */
498
    "fun [[S r1] I] S",             /* SCOL_gBasePathBuild */
499
    "fun [S I] S",                  /* SCOL_gBaseStringUTF8 */
500
    "fun [S I] S",                  /* SCOL_gbaseChecksumS */
501
    "fun [P I] S",                  /* SCOL_gbaseChecksumS */
502
    "fun [I] I",                    /* SCOL_gbaseSleep */
503
    "fun [P] [I I I I]",            /* SCOL_gbaseFileStat */
504
    "fun [S] I"                    /* SCOL_gbaseIsIp */
505
};
506

  
507
int SCOLinitGbaseClass (mmachine m)
508
{
509
    int k;
510

  
511
    MMechostr (0, "SCOLinitGbaseClass : entering\n");
512

  
513
    k = PKhardpak (m, "GBaseEngine", GBASE_PKG_NB, gbase_name, gbase_fun, gbase_narg, gbase_type);
514
    return k;
515
}
516

  
517

  
518
/**
519
 * \brief Load and free the regular expression library
520
 * Plateforms supported : MS Windows and GNU / Linux
521
 */
522

  
523
int GBaseRelease ()
524
{
525
    MMechostr (0, "\nGBASE library released !\n");
526
    return 0;
527
}
528

  
529
#if ((defined _WIN32) || (defined __WIN32__))
530

  
531
__declspec (dllexport) int SCOLloadGBASE (mmachine m, cbmachine w)
532
{
533
    int k = 0;
534
    ww = w;
535
    mm = m;
536

  
537
    MMechostr (MSKDEBUG, "\nGBASE library loading .... !\n");
538
    SCOLinitplugin (w);
539
    if ((k = SCOLinitGbaseClass (m))) return k;
540
    MMechostr(MSKDEBUG, "\nGBASE library loaded !\n");
541
    return k;
542
}
543

  
544
__declspec (dllexport) int SCOLfreeGBASE ()
545
{
546
    GBaseRelease ();
547
    return 0;
548
}
549

  
550

  
551

  
552

  
553

  
554
/* Version GNU / Linux */
555
#elif ((defined linux) || (defined __linux))
556

  
557
int SCOLloadGBASE (mmachine m)
558
{
559
    int k = 0;
560
    mm = m;
561

  
562
    MMechostr (MSKDEBUG, "\nGBASE library loading !\n");
563
    if ((k = SCOLinitGbaseClass (m))) return k;
564
    MMechostr (MSKDEBUG, "\nGBASE library loaded !\n");
565

  
566
    return k;
567
}
568

  
569
int SCOLfreeGBASE ()
570
{
571
    GBaseRelease ();
572
    return 0;
573
}
574

  
575
#else
576
#error no platform supported
577
#endif
578

  
bin/libgbase.dll.def
1
EXPORTS
2
    SCOLfreeGBASE @1
3
    SCOLloadGBASE @2
gbase.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="2418" topLine="52" />
6
	</File>
7
	<File name="include\main.h" open="0" top="0" tabpos="0">
8
		<Cursor position="0" topLine="11" />
9
	</File>
10
	<File name="include\scol_gbase.h" open="1" top="1" tabpos="2">
11
		<Cursor position="1106" topLine="2" />
12
	</File>
13
	<File name="src\scol_gbase.c" open="1" top="0" tabpos="1">
14
		<Cursor position="10030" topLine="422" />
15
	</File>
16
</CodeBlocks_layout_file>

Also available in: Unified diff