openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

cint_variables.h (4083B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * File:        cint_variables.h
      8  * Purpose:     CINT variable interfaces
      9  */
     10 
     11 #ifndef __CINT_VARIABLES_H__
     12 #define __CINT_VARIABLES_H__
     13 
     14 /*
     15  * Generic variable instance structure
     16  */
     17 
     18 #include <sal/core/sync.h>
     19 #include "cint_types.h"
     20 #include "cint_error.h"
     21 #include "cint_interpreter.h"
     22 
     23 #define CINT_VARIABLE_F_AUTO            0x1
     24 #define CINT_VARIABLE_F_SDATA           0x2
     25 #define CINT_VARIABLE_F_SNAME           0x4
     26 #define CINT_VARIABLE_F_CONST           0x8
     27 #define CINT_VARIABLE_F_VOLATILE        0x10
     28 #define CINT_VARIABLE_F_NODESTROY       0x20
     29 #define CINT_VARIABLE_F_AUTOCAST        0x40
     30 #define CINT_VARIABLE_F_CSTRING         0x80
     31 
     32 typedef struct cint_variable_s {
     33     
     34     /* Private */
     35     struct cint_variable_s* next; 
     36     struct cint_variable_s* prev; 
     37 
     38 
     39     /* Variable Flags */
     40     unsigned int flags; 
     41 
     42     /* The name of the variable */
     43     char* name; 
     44     
     45     cint_datatype_t dt; 
     46     
     47     void* data; 
     48     int size; 
     49     
     50     /* 
     51      * When arrays are converted to pointers their dimension data is saved here
     52      * and the source is set to zero. 
     53      */
     54     int cached_num_dimensions;
     55 
     56 } cint_variable_t; 
     57 
     58 extern sal_mutex_t cint_variables_mutex;
     59 #define CINT_VARIABLES_LOCK   sal_mutex_take(cint_variables_mutex, sal_mutex_FOREVER)
     60 #define CINT_VARIABLES_UNLOCK sal_mutex_give(cint_variables_mutex)
     61 
     62 /*
     63  * Initialize variable management
     64  */
     65 extern int cint_variable_init(void); 
     66 
     67 /*
     68  * Assign current scope to be the global scope. Return current scope.
     69  *
     70  * cint_variable_create() adds the newly added variable to the current scope.
     71  * This functionality is required so that the application can set the global
     72  * scope and inject variables into it.
     73  *
     74  * The CINT loger allows users to supply a user-defined CINT function which
     75  * will be called prior to generating any logs. Called the "filter function",
     76  * this function can see the arguments provided to the API as named variables.
     77  * These functions are used by loger to inject these variables into the global
     78  * scope, thus making them available to not only the filter function, but also
     79  * to any other functions it may call.
     80  */
     81 extern void* cint_variable_scope_global_set(const char *msg);
     82 
     83 /*
     84  * Assign provided scope to be the current scope, irrespective of the current
     85  * scope. Return current scope.
     86  */
     87 extern void* cint_variable_scope_set(const char *msg, void *vscope);
     88 
     89 /*
     90  * Start a new local variable scope. 
     91  * All variables from previous local scopes are also available. 
     92  */
     93 extern int cint_variable_lscope_push(const char* msg); 
     94 
     95 /*
     96  * End the existing local variable scope
     97  */
     98 extern int cint_variable_lscope_pop(const char* msg); 
     99 
    100 /*
    101  * Start a new variable scope. 
    102  */
    103 extern int cint_variable_scope_push(const char* msg); 
    104 
    105 /*
    106  * End an existing variable scope. 
    107  */
    108 extern int cint_variable_scope_pop(const char* msg); 
    109 
    110 /*
    111  * Variable List for given scope
    112  */
    113 extern cint_variable_t* cint_variable_scope(int); 
    114 
    115 /*
    116  * Allocate a variable 
    117  */
    118 extern cint_variable_t* cint_variable_alloc(void); 
    119 
    120 /*
    121  * Free a variable 
    122  */
    123 extern int cint_variable_free(cint_variable_t* v); 
    124 
    125 /*
    126  * Find a variable. All scopes or current scope only. 
    127  */
    128 extern cint_variable_t* cint_variable_find(const char* name, int cscope); 
    129 
    130 /*
    131  * Add a variable to the current scope or global scope. 
    132  */
    133 extern int cint_variable_add(cint_variable_t* v); 
    134 extern int cint_variable_list_remove(cint_variable_t* v); 
    135 extern int cint_variable_rename(cint_variable_t* v, const char *name);
    136 
    137 /*
    138  * Delete a variable from the current scope. 
    139  */
    140 extern int cint_variable_delete(const char* name); 
    141 
    142 /*
    143  * Clear and delete all variables with the AUTO flag in the current scope
    144  */
    145 extern int cint_variable_auto_save(cint_variable_t* v); 
    146 extern int cint_variable_auto_clear(void); 
    147 
    148 extern int cint_variable_clear(void); 
    149 extern int cint_variable_dump(void); 
    150 
    151 #endif /* __CINT_VARIABLES_H__ */