root/htags/anchor.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2004, 2005 Tama Communications Corporation
   3  *
   4  * This file is part of GNU GLOBAL.
   5  *
   6  * This program is free software: you can redistribute it and/or modify
   7  * it under the terms of the GNU General Public License as published by
   8  * the Free Software Foundation, either version 3 of the License, or
   9  * (at your option) any later version.
  10  * 
  11  * This program is distributed in the hope that it will be useful,
  12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14  * GNU General Public License for more details.
  15  * 
  16  * You should have received a copy of the GNU General Public License
  17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18  */
  19 #ifndef _ANCHOR_H_
  20 #define _ANCHOR_H_
  21 
  22 #include "checkalloc.h"
  23 /**
  24  * @struct anchor
  25  *
  26  * Anchor table.
  27  *
  28  * Most names are written to #tag[] directly.
  29  * Long name whose length \> #ANCHOR_NAMELEN are written to newly allocated
  30  * memory and are linked to reserve. It is necessary to clear the variable
  31  * which is not used.
  32  */
  33 #define ANCHOR_NAMELEN  32
  34 struct anchor {
  35         int lineno;
  36         char type;
  37         char done;
  38         int length;
  39         char tag[ANCHOR_NAMELEN];
  40         char *reserve;
  41 };
  42 
  43 #define gettag(a)       (a->tag[0] ? a->tag : a->reserve)
  44 #define settag(a, b)    do {                                            \
  45         char *tag = b;                                                  \
  46         (a)->length = strlen(tag);                                      \
  47         if ((a)->length < ANCHOR_NAMELEN) {                             \
  48                 strlimcpy((a)->tag, tag, sizeof((a)->tag));             \
  49                 (a)->reserve = NULL;                                    \
  50         } else {                                                        \
  51                 (a)->reserve = check_strdup(tag);                       \
  52                 (a)->tag[0] = '\0';                                     \
  53         }                                                               \
  54 } while (0)
  55 
  56 #define A_PREV          0
  57 #define A_NEXT          1
  58 #define A_FIRST         2
  59 #define A_LAST          3
  60 #define A_TOP           4
  61 #define A_BOTTOM        5
  62 #define A_SIZE          6
  63 
  64 #define A_INDEX         6
  65 #define A_HELP          7
  66 #define A_LIMIT         8
  67 
  68 void anchor_prepare(FILE *);
  69 void anchor_load(const char *);
  70 void anchor_unload(void);
  71 struct anchor *anchor_first(void);
  72 struct anchor *anchor_next(void);
  73 struct anchor *anchor_get(const char *, int, int, int);
  74 int define_line(int);
  75 int *anchor_getlinks(int);
  76 void anchor_dump(FILE *, int);
  77 
  78 #endif /* _ANCHOR_H_ */

/* [previous][next][first][last][top][bottom][index][help] */