/[global]/global/htags/common.c
ViewVC logotype

Diff of /global/htags/common.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by shigio, Wed Mar 23 10:48:47 2005 UTC revision 1.13 by shigio, Sat Mar 26 11:07:15 2005 UTC
# Line 179  meta_record() Line 179  meta_record()
179          return buf;          return buf;
180  }  }
181  /*  /*
182     * Generate upper directory.
183     */
184    char *
185    upperdir(dir)
186            const char *dir;
187    {
188            static char path[MAXPATHLEN];
189            snprintf(path, sizeof(path), "../%s", dir);
190            return path;
191    }
192    /*
193   * Generate header tag.   * Generate header tag.
194   */   */
195  char *  char *
# Line 224  gen_image(where, file, alt) Line 235  gen_image(where, file, alt)
235          return buf;          return buf;
236  }  }
237  /*  /*
238     * Generate name tag.
239     */
240    char *
241    gen_name_number(number)
242            int number;
243    {
244            static char buf[128];
245            snprintf(buf, sizeof(buf), "<a name='%d'>", number);
246            return buf;
247    }
248    /*
249     * Generate name tag.
250     */
251    char *
252    gen_name_string(name)
253            const char *name;
254    {
255            static char buf[128];
256            snprintf(buf, sizeof(buf), "<a name='%s'>", name);
257            return buf;
258    }
259    /*
260     * Generate anchor begin tag.
261     * (complete format)
262     *
263     *      i)      dir     directory
264     *      i)      file    file
265     *      i)      suffix  suffix
266     *      i)      key     key
267     *      i)      title   title='xxx'
268     *      i)      target  target='xxx'
269     *      r)              generated anchor tag
270     */
271    char *
272    gen_href_begin_with_title_target(dir, file, suffix, key, title, target)
273            const char *dir;
274            const char *file;
275            const char *suffix;
276            const char *key;
277            const char *title;
278            const char *target;
279    {
280            static STRBUF *sb = NULL;
281    
282            if (sb == NULL)
283                    sb = strbuf_open(0);
284            else
285                    strbuf_reset(sb);
286            /*
287             * Construct URL.
288             * href='dir/file.suffix#key'
289             */
290            strbuf_puts(sb, "<a href='");
291            if (file) {
292                    if (dir) {
293                            strbuf_puts(sb, dir);
294                            strbuf_putc(sb, '/');
295                    }
296                    strbuf_puts(sb, file);
297                    if (suffix) {
298                            strbuf_putc(sb, '.');
299                            strbuf_puts(sb, suffix);
300                    }
301            }
302            if (key) {
303                    strbuf_putc(sb, '#');
304                    strbuf_puts(sb, key);
305            }
306            strbuf_putc(sb, '\'');
307            if (target)
308                    strbuf_sprintf(sb, " target='%s'", target);
309            if (title)
310                    strbuf_sprintf(sb, " title='%s'", title);
311            strbuf_putc(sb, '>');
312            return strbuf_value(sb);
313    }
314    /*
315     * Generate simple anchor begin tag.
316     */
317    char *
318    gen_href_begin_simple(file)
319            const char *file;
320    {
321            return gen_href_begin_with_title_target(NULL, file, NULL, NULL, NULL, NULL);
322    }
323    /*
324     * Generate anchor begin tag without title and target.
325     */
326    char *
327    gen_href_begin(dir, file, suffix, key)
328            const char *dir;
329            const char *file;
330            const char *suffix;
331            const char *key;
332    {
333            return gen_href_begin_with_title_target(dir, file, suffix, key, NULL, NULL);
334    }
335    /*
336     * Generate anchor begin tag without target.
337     */
338    char *
339    gen_href_begin_with_title(dir, file, suffix, key, title)
340            const char *dir;
341            const char *file;
342            const char *suffix;
343            const char *key;
344            const char *title;
345    {
346            return gen_href_begin_with_title_target(dir, file, suffix, key, title, NULL);
347    }
348    /*
349     * Generate anchor end tag.
350     */
351    char *
352    gen_href_end()
353    {
354            return "</a>";
355    }
356    /*
357   * Generate list begin tag.   * Generate list begin tag.
358   */   */
359  char *  char *
# Line 254  gen_list_body(srcdir, string) Line 384  gen_list_body(srcdir, string)
384          char *string;          char *string;
385  {  {
386          static STRBUF *sb = NULL;          static STRBUF *sb = NULL;
387          char *name, *lno, *filename, *line, *html;          char *name, *lno, *filename, *line, *fid;
388          char *p;          char *p;
389          SPLIT ptable;          SPLIT ptable;
390    
# Line 271  gen_list_body(srcdir, string) Line 401  gen_list_body(srcdir, string)
401          filename = ptable.part[2].start;          filename = ptable.part[2].start;
402          line = ptable.part[3].start;          line = ptable.part[3].start;
403          filename += 2;                          /* remove './' */          filename += 2;                          /* remove './' */
404          html = path2url(filename);          fid = path2fid(filename);
405    
406          if (table_list) {          if (table_list) {
407                  strbuf_sprintf(sb, "<tr><td nowrap><a href='%s/%s#%s'>%s</a></td>",                  strbuf_puts(sb, "<tr><td nowrap>");
408                          srcdir, html, lno, name);                  strbuf_puts(sb, gen_href_begin(srcdir, fid, HTML, lno));
409                  strbuf_sprintf(sb, "<td nowrap align='right'>%s</td><td nowrap align='left'>%s</td><td nowrap>",                  strbuf_puts(sb, name);
410                    strbuf_puts(sb, gen_href_end());
411                    strbuf_sprintf(sb, "</td><td nowrap align='right'>%s</td><td nowrap align='left'>%s</td><td nowrap>",
412                          lno, filename);                          lno, filename);
413    
414                  for (p = line; *p; p++) {                  for (p = line; *p; p++) {
# Line 301  gen_list_body(srcdir, string) Line 433  gen_list_body(srcdir, string)
433          } else {          } else {
434                  int done = 0;                  int done = 0;
435    
436                  strbuf_sprintf(sb, "<a href='%s/%s#%s'>%s</a>",                  strbuf_puts(sb, gen_href_begin(srcdir, fid, HTML, lno));
437                          srcdir, html, lno, name);                  strbuf_puts(sb, name);
438                    strbuf_puts(sb, gen_href_end());
439                  p = string + strlen(name);                  p = string + strlen(name);
440                  recover(&ptable);                  recover(&ptable);
441    

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26