Add ws_load_library and ws_module_open, which respectively call
[obnox/wireshark/wip.git] / epan / uat.h
index b32b6879fb3e5efbe2ebc2112b9599e911d52d1d..f5523aea9280a8d7486d4f49f9c274ff77543fc8 100644 (file)
@@ -59,7 +59,21 @@ typedef struct _uat_t uat_t;
  ********************************************/
 
 /********
- * Callbacks for the entire table (these deal with entire records)
+ * Callbacks dealing with the entire table
+ ********/
+
+/*
+ * Post-Update CB
+ *
+ * to be called after to the table has being edited
+ * Will be called once the user clicks the Apply or OK button
+ * optional
+ */
+typedef void (*uat_post_update_cb_t)(void);
+
+
+/********
+ * Callbacks dealing with records (these deal with entire records)
  ********/
 
 /*
@@ -84,7 +98,7 @@ typedef void (*uat_free_cb_t)(void*);
 /*
  * Update CB
  *
- * to be called after all record fields has been updated
+ * to be called after any record fields had been updated
  * optional, record will be updated always if not given
  * update(record,&error)
  */
@@ -128,7 +142,7 @@ typedef void (*uat_fld_tostr_cb_t)(void*, const char**, unsigned*, const void*,
 /***********
  * Text Mode
  *
- * used for file and dialog representation of fileds in columns,
+ * used for file and dialog representation of fields in columns,
  * when the file is read it modifies the way the value is passed back to the fld_set_cb
  * (see definition bellow for description)
  ***********/
@@ -211,13 +225,18 @@ typedef struct _uat_field_t {
 /** Create a new uat
  *
  * @param name The name of the table
- * @param data_ptr A pointer to a null terminated array of pointers to the data
- * @param default_data A pointer to a struct containing default values
  * @param size The size of the structure
  * @param filename The filename to be used (either in userdir or datadir)
+ * @param from_profile TRUE if profie directory to be used
+ * @param data_ptr A pointer to a null terminated array of pointers to the data
+ * @param num_items_ptr 
+ * @param category
+ * @param help A pointer to help text
  * @param copy_cb A function that copies the data in the struct
  * @param update_cb Will be called when a record is updated
  * @param free_cb Will be called to destroy a struct in the dataset
+ * @param post_update_cb Will be called once the user clicks the Apply or OK button
+ * @param flds_array A pointer to an array of uat_field_t structs
  *
  * @return A freshly-allocated and populated uat_t struct.
  */
@@ -226,12 +245,13 @@ uat_t* uat_new(const char* name,
                           const char* filename,
                           gboolean from_profile,
                           void** data_ptr,
-                          guint* num_items,
+                          guint* num_items_ptr,
                           const char* category,
                           const char* help,
                           uat_copy_cb_t copy_cb,
                           uat_update_cb_t update_cb,
                           uat_free_cb_t free_cb,
+                          uat_post_update_cb_t post_update_cb,
                           uat_field_t* flds_array);
 
 /** Populate a uat using its file.
@@ -277,6 +297,7 @@ uat_t* uat_get_table_by_name(const char* name);
  * Some common uat_fld_chk_cbs
  */
 gboolean uat_fld_chk_str(void*, const char*, unsigned, const void*, const void*, const char** err);
+gboolean uat_fld_chk_oid(void*, const char*, unsigned, const void*, const void*, const char** err);
 gboolean uat_fld_chk_proto(void*, const char*, unsigned, const void*, const void*, const char** err);
 gboolean uat_fld_chk_num_dec(void*, const char*, unsigned, const void*, const void*, const char** err);
 gboolean uat_fld_chk_num_hex(void*, const char*, unsigned, const void*, const void*, const char** err);
@@ -349,6 +370,14 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
 #define UAT_FLD_PATHNAME(basename,field_name,title,desc) \
        {#field_name, title, PT_TXTMOD_STRING,{uat_fld_chk_str,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL}
 
+/*
+ * OID - just a CSTRING with a specific check routine 
+ *
+ */
+#define UAT_FLD_OID(basename,field_name,title,desc) \
+       {#field_name, title, PT_TXTMOD_STRING,{uat_fld_chk_oid,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{0,0,0},0,desc,FLDFILL}
+
+
 /*
  * LSTRING MACROS
  */
@@ -442,6 +471,20 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
                        *out_ptr = ep_strdup(((value_string*)vs)[i].strptr); \
                        *out_len = (unsigned)strlen(*out_ptr); return; } } }
 
+#define UAT_VS_CSTRING_DEF(basename,field_name,rec_t,default_val,default_str) \
+static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, unsigned len, const void* vs, const void* u2 _U_) {\
+       guint i; \
+       char* str = ep_strndup(buf,len); \
+       const char* cstr; ((rec_t*)rec)->field_name = default_val; \
+       for(i=0; ( cstr = ((value_string*)vs)[i].strptr ) ;i++) { \
+               if (g_str_equal(cstr,str)) { \
+                 ((rec_t*)rec)->field_name = g_strdup(((value_string*)vs)[i].strptr); return; } } } \
+static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* vs _U_, const void* u2 _U_) {\
+               if (((rec_t*)rec)->field_name ) { \
+                       *out_ptr = (((rec_t*)rec)->field_name); \
+                       *out_len = (unsigned)strlen((((rec_t*)rec)->field_name)); \
+               } else { \
+                       *out_ptr = ""; *out_len = 0; } }
 
 #define UAT_FLD_VS(basename,field_name,title,enum,desc) \
        {#field_name, title, PT_TXTMOD_ENUM,{uat_fld_chk_enum,basename ## _ ## field_name ## _set_cb,basename ## _ ## field_name ## _tostr_cb},{&(enum),&(enum),&(enum)},&(enum),desc,FLDFILL}