This file is indexed.

/usr/include/ug/ugenv.h is in libug-dev 3.12.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
/****************************************************************************/
/*                                                                              */
/* File:      ugenv.h                                                       */
/*                                                                          */
/* Purpose:   header file for ug environment manager                        */
/*                                                                          */
/* Author:      Peter Bastian                                               */
/*              Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen */
/*              Universitaet Heidelberg                                     */
/*              Im Neuenheimer Feld 368                                     */
/*              6900 Heidelberg                                             */
/*                                                                          */
/* History:   06.02.92 begin, ug version 2.0                                */
/*                                                                          */
/* Revision:  08.09.95                                                      */
/*                                                                          */
/****************************************************************************/

/** \file
    \brief General data management concept in a tree structure

    The environment management of ug provides the possibility to store data in
    a tree structure.
    The data structures of the environment allow to create directories and items
    of specified size. Both data structures start with a general head (among
    others a name by which one can refer to it). The remaining memory up to the
    specified size can be used in arbitrary way.

    The head is identical with the struct ENVVAR.

    All items are members of doubly linked lists.

    The data structure for the directory ENVDIR has just an extra component to the
    start of a list which is the directory contents (and can consist of
    directories itself, of course).

    The tree starts with a root directory "/" and there is always a current
    or working directory. Paths are specified in UNIX-style. The current
    directory can be changed using 'ChangeEnvDir' while 'GetCurrentDir'
    returns a pointer to the current directory. The routine
    'MakeEnvItem' creates the specified item in the current directory and
    it is possible to 'RemoveEnvItem's created previously.

    Finally 'SearchEnv' offers the possibility to hierarchically search
    the environment tree for an item specified by its name.

 */


/* RCS_ID
   $Header$
 */

/****************************************************************************/
/*                                                                          */
/* auto include mechanism and other include files                           */
/*                                                                          */
/****************************************************************************/

#ifndef __UGENV__
#define __UGENV__


#include "ugtypes.h"

#include "namespace.h"

START_UG_NAMESPACE

/*****************************************************************************/
/*                                                                           */
/* defines in the following order                                            */
/*                                                                           */
/*          compile time constants defining static data size (i.e. arrays)   */
/*          other constants                                                  */
/*          macros                                                           */
/*                                                                           */
/*****************************************************************************/

/* CAUTION: when changing NAMESIZE also change scanf sizes!!! */
enum {NAMESIZE = 128};                 /* max length of name string            */
enum {NAMELEN  = 127};                 /* NAMESIZE-1                            */
#define NAMELENSTR             "127"    /* NAMESIZE-1 as string                    */

enum {SEARCHALL = -1};                 /*!< Scan through all directories         */
#define DIRSEP                "/"     /* character separating directories     */

/* directories with odd numbers */
#define ROOT_DIR            1        /* indicates root directory             */

/** \brief Return pointer to the first 'ENVITEM' contained in the directory. */
#define ENVITEM_DOWN(p)         (((ENVITEM *)(p))->d.down)

/** \brief Return pointer to the first 'ENVDIR' contained in the directory. */
#define ENVDIR_DOWN(p)            ((p)->down)

/** \brief Return pointer to the next 'ENVITEM' in the doubly linked list */
#define NEXT_ENVITEM(p)         (((ENVITEM *)(p))->v.next)

/** \brief Return pointer to the previous 'ENVITEM' in the doubly linked list. */
#define PREV_ENVITEM(p)         (((ENVITEM *)(p))->v.previous)

/** \brief Return the type of the 'ENVITEM' (odd: 'ENVDIR', even: 'ENVVAR'). */
#define ENVITEM_TYPE(p)         (((ENVITEM *)(p))->v.type)

#define IS_ENVDIR(p)            (ENVITEM_TYPE(p)%2==1)

/** \brief This macro returns a pointer to the name string of the 'ENVITEM'. */
#define ENVITEM_NAME(p)         (((ENVITEM *)(p))->v.name)

/** \brief 'RemoveEnvItem' checks this and returns an error if true. */
#define ENVITEM_LOCKED(p)         (((ENVITEM *)(p))->v.locked)

/****************************************************************************/
/*                                                                          */
/* data structures exported by the corresponding source file                */
/*                                                                          */
/****************************************************************************/

/** \brief User-defined variable */
typedef struct {

  /** \brief even number by GetNewEnvVarID           */
  INT type;

  /** \brief May not be changed or deleted            */
  INT locked;

  /** \brief Doubly linked list of environment items    */
  union envitem *next;
  union envitem *previous;

  /** \brief Name of that item. May be longer, but of no interest for env*/
  char name[NAMESIZE];

} ENVVAR;

/** \brief Directory */
typedef struct {

  /** \brief odd number by GetNewEnvDirID        */
  INT type;

  /** \brief May not be changed or deleted            */
  INT locked;

  /** \brief Doubly linked list of environment items    */
  union envitem *next;
  union envitem *previous;

  /** \brief Name of that item                        */
  char name[NAMESIZE];

  /** \brief One level down in the tree                */
  union envitem *down;
} ENVDIR;

union envitem {
  ENVVAR v;
  ENVDIR d;
};

typedef union envitem ENVITEM;

/****************************************************************************/
/*                                                                          */
/* function declarations                                                    */
/*                                                                          */
/****************************************************************************/

/* initialize environment  */
INT      InitUgEnv        ();

/* Free all memory allocated for the environment */
INT      ExitUgEnv();

/* change directory allows /, .., etc */
ENVDIR    *ChangeEnvDir    (const char *s);

/* get the current working directory */
ENVDIR    *GetCurrentDir    (void);

/* get path name of the current directory */
void     GetPathName    (char *s);

/* create a new environment item with user defined size */
ENVITEM *MakeEnvItem    (const char *name, const INT type, const INT size);

/* remove an item */
INT      RemoveEnvItem    (ENVITEM *theItem);

/* remove an complete directory */
INT      RemoveEnvDir     (ENVITEM *theItem);

/* move an envitem to a new directory */
INT              MoveEnvItem      (ENVITEM *item, ENVDIR *oldDir, ENVDIR *newDir);

/* search the environment for an item */
ENVITEM *SearchEnv        (const char *name, const char *where, INT type, INT dirtype);

/* allocate memory from the environment heap */
void    *AllocEnvMemory (INT size);

/* deallocate memory from the environment heap */
void     FreeEnvMemory    (void *buffer);

/* print used and size of environment heap */
void     EnvHeapInfo     (char *s);

/* return a unique ID for a new ENVDIR/ENVVAR type */
INT      GetNewEnvDirID (void);
INT      GetNewEnvVarID (void);


END_UG_NAMESPACE

#endif