1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
|
/***************************************************************************
files.h - define file related functions
-------------------
begin : Sat Nov 10 2001
copyright : (C) 2001 by Keith Isdale
email : k_isdale@tpg.com.au
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef FILES_H
#define FILES_H
#ifndef BUILD_DOCS
#include "search.h"
#include "arraylist.h"
#endif
#ifdef USE_KDE_DOCS
/**
* Provide a file support
*
* @short file support
*
* @author Keith Isdale <k_isdale@tpg.com.au>
*/
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h> /* need chdir function */
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern FILE *terminalIO;
#define XSLDBG_XML_NAMESPACE \
(const xmlChar *) "http://xsldbg.sourceforge.net/namespace"
typedef struct _entityInfo entityInfo;
typedef entityInfo *entityInfoPtr;
struct _entityInfo {
xmlChar *SystemID;
xmlChar *PublicID;
};
/* how many lines do we print before pausing when
* performing "more" on a UTF-8 file. See function filesMoreFile */
#define FILES_NO_LINES 20
/* Define the types of file names that we are intested in when creating
* search results */
#ifndef USE_KDOC
typedef enum {
FILES_SEARCHINPUT,
FILES_SEARCHXSL,
FILES_SEARCHRESULT
} FilesSearchFileNameEnum;
#else
/* keep kdoc happy */
enum FilesSearchFileNameEnum {
FILES_SEARCHINPUT,
FILES_SEARCHXSL,
FILES_SEACHRESULT
};
#endif
/*-----------------------------------------------------------
General function for working with files
-----------------------------------------------------------*/
#ifdef USE_GNOME_DOCS
/**
* filesEntityRef :
* @ent : Is valid as provided by libxslt
* @firstNode : Is valid
* @lastNode : Is Valid
*
* Fixes the nodes from firstNode to lastNode so that debugging can occur
*/
#else
#ifdef USE_KDE_DOCS
/**
* Fixes the nodes from firstNode to lastNode so that debugging can occur
*
* @param uri Is valid as provided by libxslt
* @param firstNode Is valid
* @param lastNode Is Valid
*/
#endif
#endif
void filesEntityRef(xmlEntityPtr ent, xmlNodePtr firstNode,
xmlNodePtr lastNode);
#ifdef USE_GNOME_DOCS
/**
* filesEntityList:
*
* Return the list entity names used for documents loaded
*
* Returns The list entity names used for documents loaded
*/
#else
#ifdef USE_KDE_DOCS
/**
* Return the list entity names used for documents loaded
*
* @returns The list entity names used for documents loaded
*/
#endif
#endif
arrayListPtr filesEntityList(void);
#ifdef USE_GNOME_DOCS
/**
* filesSetBaseUri:
* @node : Is valid and has a doc parent
* @uri : Is Valid
*
* Set the base uri for this node. Function is used when xml file
* has external entities in its DTD
*
* Returns 1 if successful,
* 0 otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Set the base uri for this node. Function is used when xml file
* has external entities in its DTD
*
* @param node Is valid and has a doc parent
* @param uri Is Valid
*
* @returns 1 if successful,
* 0 otherwise
*/
#endif
#endif
int filesSetBaseUri(xmlNodePtr node, const xmlChar * uri);
#ifdef USE_GNOME_DOCS
/**
* filesGetBaseUri:
* @node : Is valid and has a doc parent
*
* Get a copy of the base uri for this node. Function is most usefull
* used when xml file has external entities in its DTD
*
* Returns the a copy of the base uri for this node,
* NULL otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Get a copy of the base uri for this node. Function is most usefull
* used when xml file has external entities in its DTD
*
* @param node : Is valid and has a doc parent
*
* @returns The a copy of the base uri for this node,
* NULL otherwise
*/
#endif
#endif
xmlChar *filesGetBaseUri(xmlNodePtr node);
#ifdef USE_GNOME_DOCS
/**
* filesTempFileName:
* @fleNumber : Number of temp file required
* where @fileNumber is
* 0 : file name used by cat command
* 1 : file name used by profiling output
*
* Return the name of tempfile requirested
*
* This is a platform specific interface
*
* Returns The name of temp file to be used for temporary results if sucessful,
* NULL otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Return the name of tempfile requested.
* @param fleNumber : Number of temp file required
* where @p fileNumber is
* 0 : file name used by cat command
* 1 : file name used by profiling output
*
* This is a platform specific interface
*
* Returns The name of temp file to be used for temporary results if sucessful,
* NULL otherwise
*/
#endif
#endif
const char *filesTempFileName(int fileNumber);
#ifdef USE_GNOME_DOCS
/**
* filesLoadCatalogs:
*
* Load the catalogs specifed by OPTIONS_CATALOG_NAMES if
* OPTIONS_CATALOGS is enabled
*
* Returns 1 if sucessful
* 0 otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Load the catalogs specifed by OPTIONS_CATALOG_NAMES if
* OPTIONS_CATALOGS is enabled
*
* @returns 1 if sucessful
* 0 otherwise
*/
#endif
#endif
int filesLoadCatalogs(void);
#ifdef USE_GNOME_DOCS
/**
* filesEncode:
* @text: Is valid, text to translate from UTF-8,
*
* Return A string of converted @text
*
* Returns A string of converted @text, may be NULL
*/
#else
#ifdef USE_KDE_DOCS
/**
* Return A string of converted @text
*
* @param text Is valid, text to translate from UTF-8,
*
* Returns A string of converted @text, may be NULL
*/
#endif
#endif
xmlChar *filesEncode(const xmlChar * text);
#ifdef USE_GNOME_DOCS
/**
* filesDeccode:
* @text: Is valid, text to translate from current encoding to UTF-8,
*
* Return A string of converted @text
*
* Returns A string of converted @text, may be NULL
*/
#else
#ifdef USE_KDE_DOCS
/**
* Return A string of converted @text
*
* @param test Is valid, text to translate from current encoding to UTF-8,
*
* Returns A string of converted @text, may be NULL
*/
#endif
#endif
xmlChar *filesDecode(const xmlChar * text);
#ifdef USE_GNOME_DOCS
/**
* filesSetEncoding:
* @encoding : Is a valid encoding supported by the iconv library or NULL
*
* Opens encoding for all standard output to @encoding. If @encoding
* is NULL then close current encoding and use UTF-8 as output encoding
*
* Returns 1 if successful in setting the encoding of all standard output
* to @encoding
* 0 otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Opens encoding for all standard output to @p encoding. If @p encoding
* is NULL then close current encoding and use UTF-8 as output encoding
*
* @param encoding Is a valid encoding supported by the iconv library or NULL
*
* Returns 1 if successful in setting the encoding of all standard output
* to @p encoding
* 0 otherwise
*/
#endif
#endif
int filesSetEncoding(const char *encoding);
#ifndef USE_KDOC
/* used by filesLoadXmlFile, filesFreeXmlFile functions */
typedef enum {
FILES_XMLFILE_TYPE = 100, /* pick a unique starting point */
FILES_SOURCEFILE_TYPE,
FILES_TEMPORARYFILE_TYPE
} FileTypeEnum;
#else
/* used by filesLoadXmlFile, filesFreeXmlFile functions */
enum FileTypeEnum {
FILES_XMLFILE_TYPE = 100, /* pick a unique starting point */
FILES_SOURCEFILE_TYPE,
FILES_TEMPORARYFILE_TYPE
};
#endif
#ifdef USE_GNOME_DOCS
/**
* openTerminal
* @device: terminal to redirect i/o to , will not work under win32
*
* Open communications to the terminal device @device
* Returns 1 if sucessful
* 0 otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Open communications to the terminal device @p device
*
* @param device Terminal to redirect i/o to , will not work under win32
*
* @returns 1 if sucessful
* 0 otherwise
*/
#endif
#endif
int openTerminal(xmlChar * device);
#ifdef USE_GNOME_DOCS
/**
* guessStyleSheetName:
* @searchInf : Is valid
*
* Try to find a matching stylesheet name
* Sets the values in @searchinf depending on outcome of search
*/
#else
#ifdef USE_KDE_DOCS
/**
* Try to find a matching stylesheet name
* Sets the values in @p searchinf depending on outcome of search
*
* @param searchInf Is valid
*/
#endif
#endif
void guessStylesheetName(searchInfoPtr searchInf);
#ifdef USE_GNOME_DOCS
/**
* stylePath:
*
* Returns the base path for the top stylesheet ie
* ie URL minus the actual file name
*/
#else
#ifdef USE_KDE_DOCS
/**
* Return the base path for the top stylesheet ie
* ie URL minus the actual file name
*
* @returns The base path for the top stylesheet ie
* ie URL minus the actual file name
*/
#endif
#endif
xmlChar *stylePath(void);
#ifdef USE_GNOME_DOCS
/**
* workingPath:
*
* Return the working directory as set by changeDir function
*/
#else
#ifdef USE_KDE_DOCS
/**
* Return the working directory as set by changeDir function
*
* @return the working directory as set by changeDir function
*/
#endif
#endif
xmlChar *workingPath(void);
#ifdef USE_GNOME_DOCS
/**
* changeDir:
* @path : path to adopt as new working directory
*
* Change working directory to path
*
* Returns 1 on success,
* 0 otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Change working directory to path
*
* @param path The operating system path(directory) to adopt as
* new working directory
*
* @returns 1 on success,
* 0 otherwise
*/
#endif
#endif
int changeDir(const xmlChar * path);
#ifdef USE_GNOME_DOCS
/**
* filesLoadXmlFile:
* @path : xml file to load
* @fileType : A valid FileTypeEnum
*
* Load specified file type, freeing any memory previously used
*
* Returns 1 on success,
* 0 otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Load specified file type, freeing any memory previously used
*
* @returns 1 on success,
* 0 otherwise
*
* @param path The xml file to load
* @param fileType A valid FileTypeEnum
*/
#endif
#endif
int filesLoadXmlFile(const xmlChar * path, FileTypeEnum fileType);
#ifdef USE_GNOME_DOCS
/**
* filesFreeXmlFile:
* @fileType : A valid FileTypeEnum
*
* Free memory associated with the xml file
*
* Returns 1 on success,
* 0 otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Free memory associated with the xml file
*
* @returns 1 on success,
* 0 otherwise
*
* @param fileType : A valid FileTypeEnum
*/
#endif
#endif
int filesFreeXmlFile(FileTypeEnum fileType);
#ifdef USE_GNOME_DOCS
/**
* filesGetStylesheet:
*
* Return the topmost stylesheet
*
* Returns non-null on success,
* NULL otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Return the topmost stylesheet
*
* @returns Non-null on success,
* NULL otherwise
*/
#endif
#endif
xsltStylesheetPtr filesGetStylesheet(void);
#ifdef USE_GNOME_DOCS
/**
* filesGetTemporaryDoc:
*
* Return the current "temporary" document
*
* Returns the current "temporary" document
*/
#else
#ifdef USE_KDE_DOCS
/**
* Return the current "temporary" document
*
* @returns non-null on success,
* NULL otherwise
*/
#endif
#endif
xmlDocPtr filesGetTemporaryDoc(void);
#ifdef USE_GNOME_DOCS
/**
* filesGetMainDoc:
*
* Returns the main docment
*/
#else
#ifdef USE_KDE_DOCS
/**
* Return the main docment
*
* @returns the main document
*/
#endif
#endif
xmlDocPtr filesGetMainDoc(void);
#ifdef USE_GNOME_DOCS
/**
* filesReloaded:
* @reloaded : if = -1 then ignore @reloaded
* otherwise change the status of files to value of @reloaded
*
* Returns 1 if stylesheet or its xml data file has been "flaged" as reloaded,
* 0 otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* @returns 1 if stylesheet or its xml data file has been "flaged" as reloaded,
* 0 otherwise
*
* @param reloaded If = -1 then ignore @p reloaded
* otherwise change the status of files to value of @p reloaded
*/
#endif
#endif
int filesReloaded(int reloaded);
#ifdef USE_GNOME_DOCS
/**
* filesInit:
*
* Initialize the file module
* Returns 1 on success,
* 0 otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Initialize the file module
*
* @returns 1 on success,
* 0 otherwise
*/
#endif
#endif
int filesInit(void);
#ifdef USE_GNOME_DOCS
/**
* filesFree:
*
* Free memory used by file related structures
*/
#else
#ifdef USE_KDE_DOCS
/**
* Free memory used by file related structures
*/
#endif
#endif
void filesFree(void);
#ifdef USE_GNOME_DOCS
/**
* filesIsSourceFile:
* @fileName : Is valid
*
* Test if filename could be a stylesheet
*
* Returns true if @name has the ".xsl" extension
*/
#else
#ifdef USE_KDE_DOCS
/**
* Test if filename could be a stylesheet
*
* @returns True if @name has the ".xsl" extension
*
* @param fileName Is valid
*/
#endif
#endif
int filesIsSourceFile(xmlChar * fileName);
#ifdef USE_GNOME_DOCS
/**
* filesMoreFile:
* @fileName : May be NULL
* @file : May be NULL
*
* Do a "more" like print of file specified by @fileName OR
* @file. If both are provided @file will be used. The content
* of file chosen must be in UTF-8, and will be printed in
* the current encoding selected.The function will pause output
* after FILES_NO_LINES lines have been printed waiting for
* user to enter "q" to quit or any other text to continue.
*
* Returns 1 if successful,
* 0 otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Do a "more" like print of file specified by @fileName OR
* @file. If both are provided @file will be used. The content
* of file chosen must be in UTF-8, and will be printed in
* the current encoding selected. The function will pause output
* after FILES_NO_LINES lines have been printed waiting for
* user to enter "q" to quit or any other text to continue.
*
* @returns 1 if successful,
* 0 otherwise
*
* @param fileName May be NULL
* @param file May be NULL
*
*/
#endif
#endif
int filesMoreFile(const xmlChar * fileName, FILE * file);
#ifdef USE_GNOME_DOCS
/**
* filesSearchResultsPath:
*
* Get the base path to be used for storing search results
*
* Returns The base path to be used for storing search results
*/
#else
#ifdef USE_KDE_DOCS
/**
* Get the base path to be used for storing search results
*
* @returns The base path to be used for storing search results
*/
#endif
#endif
const xmlChar *filesSearchResultsPath(void);
#ifdef USE_GNOME_DOCS
/**
* filesURItoFileName:
* @uri : A valid URI that uses the "file://" prefix
*
* Return A copy of the conversion of @uri to a file name
* that is suitable to be used with the fopen function.
* May be NULL, if out of memory, @uri does not use the
* "file://" prefix, or unable to convert to a valid file name
*
* Returns A copy of the conversion of @uri to a file name
* that is suitable to be used with the fopen function.
* May be NULL, if out of memory, @uri does not use the
* "file://" prefix, or unable to convert to a valid file name
*
*/
#else
#ifdef USE_KDE_DOCS
/**
* Return A copy of the conversion of @uri to a file name
* that is suitable to be used with the fopen function.
* May be NULL, if out of memory, @uri does not use the
* "file://" protocol, or unable to convert to a valid file name
*
* Returns A copy of the conversion of @uri to a file name
* that is suitable to be used with the fopen function.
* May be NULL, if out of memory, @uri does not use the
* "file://" prefix, or unable to convert to a valid file name
*
* @param uri A valid URI that uses the "file://" prefix
*
*/
#endif
#endif
xmlChar *filesURItoFileName(const xmlChar* uri);
#ifdef USE_GNOME_DOCS
/**
* xsldbgUpdateFileDetails:
* @node : A valid node
*
* Update the URL and line number that we stoped at
*/
#else
#ifdef USE_KDE_DOCS
/**
* Update the URL and line number that we stoped at
*
* @param node A valid node
*/
#endif
#endif
void xsldbgUpdateFileDetails(xmlNodePtr node);
#ifdef USE_GNOME_DOCS
/**
* xsldbgLineNo:
*
* What line number are we at
*
* Returns The current line number of xsldbg, may be -1
**/
#else
#ifdef USE_KDE_DOCS
/**
* What line number are we at
*
* @returns The current line number of xsldbg, may be -1
**/
#endif
#endif
int xsldbgLineNo(void);
#ifdef USE_GNOME_DOCS
/**
* xsldbgUrl:
*
* What URL did we stop at
*
* Returns A NEW copy of URL stopped at. Caller must free memory for URL,
* may be NULL
*/
#else
#ifdef USE_KDE_DOCS
/**
* What URL did we stop at
*
* @returns A NEW copy of URL stopped at. Caller must free memory for URL,
* may be NULL
*/
#endif
#endif
xmlChar *xsldbgUrl(void);
/*-----------------------------------------------------------
Platform specific file functions
-----------------------------------------------------------*/
#ifdef USE_GNOME_DOCS
/**
* filesPlatformInit:
*
* Intialize the platform specific files module
*
* This is a platform specific interface
*
* Returns 1 if sucessful
* 0 otherwise
*/
#else
#ifdef USE_KDE_DOCS
/**
* Intialize the platform specific files module
*
* This is a platform specific interface
*
* @returns 1 if sucessful
* 0 otherwise
*/
#endif
#endif
int filesPlatformInit(void);
#ifdef USE_GNOME_DOCS
/**
* filesPlatformFree:
*
* Free memory used by the platform specific files module
*
* This is a platform specific interface
*
*/
#else
#ifdef USE_KDE_DOCS
/**
* Free memory used by the platform specific files module
*
* This is a platform specific interface
*
*/
#endif
#endif
void filesPlatformFree(void);
#ifdef USE_GNOME_DOCS
/**
* filesExpandName:
* @fileName : A valid fileName
*
* Converts a fileName to an absolute path
* If operating system supports it a leading "~" in the fileName
* will be converted to the user's home path. Otherwise
* the same name will be returned
*
* Returns A copy of the converted @fileName or a copy of
* the @fileName as supplied. May return NULL
*/
#else
#ifdef USE_KDE_DOCS
/**
* Converts a fileName to an absolute path
* If operating system supports it a leading "~" in the fileName
* will be converted to the user's home path. Otherwise
* the same name will be returned
*
* Returns A copy of the converted @p fileName or a copy of
* the @p fileName as supplied. May return NULL
*
* @param fileName A valid fileName
*/
#endif
#endif
xmlChar *filesExpandName(const xmlChar * fileName);
#ifdef USE_GNOME_DOCS
/**
* filesSearchFileName:
* @fileType : Is valid
*
* Return a copy of the file name to use as an argument to searching
*
* Returns A copy of the file name to use as an argument to searching
*/
#else
#ifdef USE_KDE_DOCS
/**
* Return a copy of the file name to use as an argument to searching
*
* @returns A copy of the file name to use as an argument to searching
*
* @param fileType Is valid
*
*/
#endif
#endif
xmlChar *filesSearchFileName(FilesSearchFileNameEnum fileType);
#ifdef __cplusplus
}
#endif
#endif
|