/[MITgcm]/mitgcm.org/devel/buildweb/code-browser/F90Mapper/fd.c
ViewVC logotype

Annotation of /mitgcm.org/devel/buildweb/code-browser/F90Mapper/fd.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Fri Sep 20 19:47:31 2002 UTC (22 years, 9 months ago) by adcroft
Branch: MAIN
Branch point for: Import
File MIME type: text/plain
Initial revision

1 adcroft 1.1 /* $Id: $ */
2    
3     /*
4     File-directory table routines
5     */
6    
7     #include <stdio.h>
8     #include <string.h>
9     #include <ctype.h>
10    
11     #include "DD.h"
12     #include "FD.h"
13     #include "GLOBALS.h"
14    
15     /*
16     Set initial state of file-directory table
17     */
18     fdInit()
19     {
20     fdList = NULL;
21     fdListHead = fdList;
22     fdListTail = fdList;
23     }
24    
25     /*
26     Store directory, file and associated html source info.
27     Info. is stored in table of form
28     dirname1 file1 html
29     file2 html
30     file3 html
31     :
32    
33     dirname2 filen html
34     filem html
35     fileo html
36     :
37     etc..,,
38     */
39     fdAdd( srcDirName, srcFileName, sHtmlName )
40     char *srcDirName;
41     char *srcFileName;
42     char *sHtmlName;
43     {
44     int nComp, nCompPrev;
45     int nFd;
46     /* For search file names */
47     fdSTab *sfList, *sfListBefore, *sfListAfter;
48     fdDTab *fdListAfter, *fdListBefore;
49    
50     fdList = fdListHead;
51     fdListBefore = NULL;
52     fdListAfter = NULL;
53     nFd = 0;
54    
55     /* Search for the directory name */
56     /* Insert new names in alphabetical order */
57     nComp = -1;
58     while ( fdList != NULL ) {
59     /* nComp +ve arg1 alphabetically before arg2
60     nComp 0 arg1 == arg2
61     nComp -ve arg1 alphabetically after arg2
62     */
63     nComp = -strcmp( srcDirName, (fdList->dir).name );
64     ++nFd;
65     if ( nComp >= 0 ) {
66     fdListAfter = fdList;
67     break;
68     }
69     fdListBefore = fdList;
70     fdList = fdList->next;
71     }
72    
73     /* No match for directory name */
74     if ( nComp != 0 ) {
75     /* Create an entry */
76     fdList = (fdDTab *) malloc(sizeof(fdDTab));
77     fdList->next = fdListAfter;
78     fdList->prev = fdListBefore;
79     fdList->sList = NULL;
80     (fdList->dir).name = strdup(srcDirName);
81     /* Insert into list */
82     if ( fdListHead == NULL ) {
83     /* First entry */
84     fdListHead = fdList; fdListTail = fdList;
85     }
86     if ( fdListAfter == fdListHead ) {
87     /* Adding at head */
88     fdListHead = fdList;
89     }
90     /* Inserts between existing entries */
91     if ( fdList->next != NULL ) fdList->next->prev = fdList;
92     if ( fdList->prev != NULL ) fdList->prev->next = fdList;
93     }
94    
95     /* Search through file names paired with directory */
96     /* Insert new names in alphabetical order */
97     sfList = fdList->sList;
98     sfListBefore = NULL;
99     sfListAfter = NULL;
100     nFd = 0;
101     nComp = -1;
102     while ( sfList != NULL ) {
103     /* nComp +ve arg1 alphabetically before arg2
104     nComp 0 arg1 == arg2
105     nComp -ve arg1 alphabetically after arg2
106     */
107     nComp = -strcmp( srcFileName, (sfList->fileNam).name );
108     if ( nComp >= 0 ) {
109     sfListAfter = sfList;
110     break;
111     }
112     ++nFd;
113     sfListBefore = sfList;
114     sfList = sfList->next;
115     }
116     /* No match for file name */
117     if ( nComp != 0 ) {
118     /* Create an entry */
119     sfList = (fdSTab *) malloc(sizeof(fdSTab));
120     sfList->fileNam.name = strdup(srcFileName);
121     sfList->fileNam.hname = strdup(sHtmlName);
122     sfList->prev = sfListBefore;
123     sfList->next = sfListAfter;
124     if ( fdList->sList == NULL ) {
125     /* First file for this directory */
126     fdList->sList = sfList;
127     }
128     if ( fdList->sList == sfList->next ) {
129     /* Added to head of list */
130     fdList->sList = sfList;
131     }
132     if ( sfList->prev != NULL ) { sfList->prev->next = sfList; }
133     if ( sfList->next != NULL ) { sfList->next->prev = sfList; }
134     }
135    
136     }
137    
138     /*
139     Print fd tables.
140     */
141     fdPrint()
142     {
143     int nComp;
144     int nFd;
145     fdSTab *sfList, *sfListTail;
146    
147     fdList = fdListHead;
148     nFd = 0;
149    
150     /* Search for the directory name */
151     while ( fdList != NULL ) {
152     printf("FD %s",fdList->dir.name);
153     /* Search through file names paired with directory */
154     sfList = fdList->sList;
155     sfListTail = sfList;
156     nFd = 0;
157     while ( sfList != NULL ) {
158     printf(", %s<%s>",sfList->fileNam.name,sfList->fileNam.hname);
159     sfList = sfList->next;
160     }
161     printf("\n");
162     fdList = fdList->next;
163     }
164    
165     }
166    
167     /*
168     Write fd directories.
169     */
170     fdDirList(FILE *o)
171     {
172     int nComp;
173     int nFd;
174     fdSTab *sfList, *sfListTail;
175     char subURL[MAXPATHNAM];
176    
177     fdList = fdListHead;
178     nFd = 0;
179    
180     /* List directory names to DFMenu */
181     while ( fdList != NULL ) {
182     ++nFd;
183     sprintf(subURL,"%s/%s_dir%d%s target=codeBrowserWindow",
184     rootDir,SFDICT,nFd,HTMLSUF);
185     html_entryli(o,fdList->dir.name,subURL,"h4");
186     fdList = fdList->next;
187     }
188    
189     }
190    
191     /*
192     Write fd entry by letter
193     */
194     fdFlistAlpha(FILE *o)
195     {
196     int nComp;
197     int nFd;
198     fdSTab *sfList, *sfListTail;
199     char subURL[MAXPATHNAM];
200     char let1[2];
201     char lolet[27] = "abcdefghijklmnopqrstuvwxyz";
202     char uplet[27] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
203     int i;
204     int f1, f0;
205    
206     fdList = fdListHead;
207     nFd = 0;
208     let1[0]=' ';
209     let1[1]='\0';
210     f0=0;
211    
212     /* Make links for alphabetic file tables */
213     for (i=0;i<27;++i) {
214     fdList = fdListHead;
215     f1=0;
216     while ( fdList != NULL ) {
217     sfList = fdList->sList;
218     while ( sfList != NULL ) {
219     if ( ( sfList->fileNam.name[0] == lolet[i] ||
220     sfList->fileNam.name[0] == uplet[i] ) &&
221     f1 == 0 ) {
222     if ( f0 == 0 ) { html_li(o); f0=1; html_hn(o,"h4"); }
223     let1[0]=uplet[i];
224     sprintf(subURL,"%s/%s_pref%c%s target=codeBrowserWindow",
225     rootDir,SFDICT,uplet[i],HTMLSUF);
226     html_entry(o,let1,subURL);fprintf(o,", ");
227     f1=1;
228     }
229     sfList = sfList->next;
230     }
231     fdList = fdList->next;
232     }
233     }
234     if ( f0 == 1 ) { html_ehn(o,"h4"); html_eli(o); }
235     }
236    
237     fdTab()
238     {
239     FILE *allTabfd, *htout;
240     char allTabName[MAXPATHNAM];
241     fdSTab *sfList, *sfListTail;
242     int dNo;
243     ddRecord rec, *searchResult;
244    
245     fdList = fdListHead;
246    
247     /* Single list */
248     sprintf(allTabName,"%s/%s%s",rootDir,SFDICT,HTMLSUF);
249     allTabfd=fopen(allTabName,"w");
250     htout=allTabfd;
251    
252     html_start(htout);
253     html_FlistTabStart(htout);
254     html_FlistColHeader(htout);
255     while ( fdList != NULL ) {
256     sfList = fdList->sList;
257     while ( sfList != NULL ) {
258     rec.name = sfList->fileNam.name; rec.hrefEntry = NULL;
259     rec.textEntry = NULL; rec.unitsEntry = NULL;
260     rec.footNotesEntry = NULL; rec.active = 1;
261     searchResult = ddFind(&rec);
262     if ( searchResult != NULL ) {
263     html_FlistColRecord(htout,
264     fdList->dir.name,
265     sfList->fileNam.name,
266     sfList->fileNam.hname,
267     searchResult->textEntry);
268     } else {
269     html_FlistColRecord(htout,
270     fdList->dir.name,
271     sfList->fileNam.name,
272     sfList->fileNam.hname,
273     " "); /* NO DEFINITION */
274     }
275     sfList = sfList->next;
276     }
277     fdList = fdList->next;
278     }
279     html_FlistTabStop(htout);
280     html_end(htout);
281     fprintf(htout,"\n");
282    
283     fclose(allTabfd);
284    
285     /* Directory at a time tables */
286     fdList = fdListHead;
287     dNo=0;
288     while ( fdList != NULL ) {
289     ++dNo;
290     sprintf(allTabName,"%s/%s_dir%d%s",rootDir,SFDICT,dNo,HTMLSUF);
291     allTabfd=fopen(allTabName,"w");
292     htout=allTabfd;
293     html_start(htout);
294     html_FlistTabStart(htout);
295     html_FlistColHeader(htout);
296     sfList = fdList->sList;
297     while ( sfList != NULL ) {
298     rec.name = sfList->fileNam.name; rec.hrefEntry = NULL;
299     rec.textEntry = NULL; rec.unitsEntry = NULL;
300     rec.footNotesEntry = NULL; rec.active = 1;
301     searchResult = ddFind(&rec);
302     if ( searchResult != NULL ) {
303     html_FlistColRecord(htout,
304     fdList->dir.name,
305     sfList->fileNam.name,
306     sfList->fileNam.hname,
307     searchResult->textEntry);
308     } else {
309     html_FlistColRecord(htout,
310     fdList->dir.name,
311     sfList->fileNam.name,
312     sfList->fileNam.hname,
313     " "); /* NO DEFINITION */
314     }
315     sfList = sfList->next;
316     }
317     html_FlistTabStop(htout);
318     html_end(htout);
319     fprintf(htout,"\n");
320     fclose(allTabfd);
321     fdList = fdList->next;
322     }
323    
324     /* Alphabetic tables */
325     fdFlistAlphaTab();
326    
327     }
328    
329     /*
330     Write fd entry by letter
331     */
332     fdFlistAlphaTab()
333     {
334     int nComp; int nFd;
335     fdSTab *sfList, *sfListTail;
336     char subURL[MAXPATHNAM];
337     char let1[2];
338     char lolet[27] = "abcdefghijklmnopqrstuvwxyz";
339     char uplet[27] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
340     int i; int f1, f0;
341     FILE *htout;
342     ddRecord rec, *searchResult;
343    
344     fdList = fdListHead;
345     nFd = 0;
346     let1[0]=' ';
347     let1[1]='\0';
348     f0=0;
349    
350     /* Make alphabetic file tables */
351     for (i=0;i<27;++i) {
352     fdList = fdListHead;
353     f1=0;
354     while ( fdList != NULL ) {
355     sfList = fdList->sList;
356     while ( sfList != NULL ) {
357     if ( sfList->fileNam.name[0] == lolet[i] ||
358     sfList->fileNam.name[0] == uplet[i] )
359     {
360     if ( f1 == 0 ) {
361     sprintf(subURL,"%s/%s_pref%c%s",rootDir,SFDICT,uplet[i],HTMLSUF);
362     htout=fopen(subURL,"w");
363     f1=1;
364     html_start(htout); html_FlistTabStart(htout); html_FlistColHeader(htout);
365     }
366     rec.name = sfList->fileNam.name; rec.hrefEntry = NULL;
367     rec.textEntry = NULL; rec.unitsEntry = NULL;
368     rec.footNotesEntry = NULL; rec.active = 1;
369     searchResult = ddFind(&rec);
370    
371     if ( searchResult != NULL ) {
372     html_FlistColRecord(htout,
373     fdList->dir.name,
374     sfList->fileNam.name,
375     sfList->fileNam.hname,
376     searchResult->textEntry);
377     } else {
378     html_FlistColRecord(htout,
379     fdList->dir.name,
380     sfList->fileNam.name,
381     sfList->fileNam.hname,
382     " "); /* NO DEFINITION */
383    
384     }
385     }
386     sfList = sfList->next;
387     }
388     fdList = fdList->next;
389     }
390     if ( f1 == 1 ) {
391     html_FlistTabStop(htout); html_end(htout); fprintf(htout,"\n");
392     fclose(htout);
393     }
394     }
395     }

  ViewVC Help
Powered by ViewVC 1.1.22