********************************************/
/********
- * 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)
********/
/*
/*
* 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)
*/
/***********
* 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)
***********/
/** 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.
*/
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.
* 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);
#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
*/
*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}