Source File rpsl/class.h

    1    | /******************
    2    |   Copyright (c) 2002                                        RIPE NCC
    3    |
    4    |   All Rights Reserved
    5    |
    6    |   Permission to use, copy, modify, and distribute this software and its
    7    |   documentation for any purpose and without fee is hereby granted,
    8    |   provided that the above copyright notice appear in all copies and that
    9    |   both that copyright notice and this permission notice appear in
    10   |   supporting documentation, and that the name of the author not be
    11   |   used in advertising or publicity pertaining to distribution of the
    12   |   software without specific, written prior permission.
    13   |
    14   |   THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
    15   |   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
    16   |   AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
    17   |   DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
    18   |   AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    19   |   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    20   |   ***************************************/
    21   |
    22   | #ifndef CLASS_H
    23   | #define CLASS_H
    24   |
    25   | #include <glib.h>
    26   |
    27   | typedef enum {
    28   |     ATTR_MANDATORY,
    29   |     ATTR_OPTIONAL,
    30   |     ATTR_GENERATED
    31   | } attr_choice_t;
    32   |
    33   | typedef enum {
    34   |     ATTR_SINGLE,
    35   |     ATTR_MULTIPLE
    36   | } attr_number_t;
    37   |
    38   | /* info about attributes used by this class */
    39   | typedef struct {
    40   |     int offset;
    41   |     attr_choice_t choice;
    42   |     attr_number_t number;
    43   | } class_attr_t;
    44   |
    45   | /* maximum number of attributes in a class */
    46   | #define MAX_CLASS_ATTR 50
    47   |
    48   | typedef struct {
    49   |     char *name;                         /* name of class */
    50   |     int id;                             /* identifier for this class,
    51   |                                            e.g. C_MT, C_RS, etc. */
    52   |     int num_attr;                       /* number of attributes */
    53   |     class_attr_t attr[MAX_CLASS_ATTR];  /* attribute information (in-order) */
    54   |     GHashTable *attr_hash;              /* hash of attribute name ->
    55   |                                             class_attr_t */
    56   | } class_t;
    57   |
    58   | /* functions */
    59   | const char* const *get_class_names();
    60   | const class_t *class_lookup(const char *name);
    61   | const class_attr_t *class_attr_lookup(const class_t *class,
    62   |                                       const char *attr_name);
    63   |
    64   | #endif /* CLASS_H */