"Fossies" - the Fresh Open Source Software Archive

Member "wcalc-2.5/src/common/includes/variables.h" (29 Dec 2014, 1881 Bytes) of package /linux/privat/wcalc-2.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "variables.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.4.1_vs_2.5.

    1 #ifndef KBW_VARIABLES
    2 #define KBW_VARIABLES
    3 
    4 #ifdef HAVE_CONFIG_H
    5 # include "config.h"
    6 #endif
    7 #if HAVE_STRING_H
    8 # include <string.h>
    9 #else
   10 # if !HAVE_STRCHR
   11 #  define strchr  index
   12 #  define strrchr rindex
   13 # endif
   14 char *strchr(), *strrchr();
   15 #endif
   16 #include <stdlib.h>
   17 
   18 #include "number.h"
   19 
   20 typedef struct variable {
   21     char            *key;
   22     char            *expression;
   23     char            *description;
   24     Number           value;
   25     unsigned int     exp : 1;
   26     struct variable *next;
   27 } variable_t;
   28 
   29 typedef struct answer {
   30     Number       val;
   31     char        *exp;
   32     char        *desc;
   33     unsigned int err : 1;
   34 } answer_t;
   35 
   36 // requires a working Number
   37 void getvarval(Number      out,
   38                const char *key);
   39 
   40 // requires a working Number
   41 int putval(const char  *key,
   42            const Number value,
   43            const char  *desc);
   44 
   45 int putexp(const char *key,
   46            const char *value,
   47            const char *desc);
   48 int    varexists(const char *key);
   49 void   initvar(void);
   50 void   delnvar(const size_t n);
   51 void   cleanupvar(void);
   52 size_t numvars(void);
   53 void   printvariables(void);
   54 
   55 // this returns a char ** that must be freed. DO NOT free its contents
   56 char **listvarnames(void);
   57 
   58 /* ******************************
   59  * NOTE!
   60  * If you use these functions, they return
   61  * fully functioning Number structures that must be
   62  * num_free()'d when you're done with 'em.
   63  */
   64 
   65 /* getvar returns only the value, or an error if it doesn't have one */
   66 struct answer getvar(const char *key);
   67 
   68 /* getvar returns whatever is known about the variable, or an error if
   69  * it doesn't exist */
   70 struct answer getvar_full(const char *key);
   71 
   72 /* THIS function, however, exposes the innards of the variable system.
   73  * do not under any circumstance un-initialize the Number
   74  */
   75 struct variable *getrealnvar(const size_t n);
   76 #endif // ifndef KBW_VARIABLES
   77 /* vim:set expandtab: */