/[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.2 - (hide annotations) (download)
Thu Jan 17 21:05:34 2008 UTC (17 years, 6 months ago) by cnh
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -1 lines
File MIME type: text/plain
Standard incs that need to be there these days.

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

  ViewVC Help
Powered by ViewVC 1.1.22