diff options
author | João Valverde <j@v6e.pt> | 2022-11-19 19:21:19 +0000 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2022-11-28 15:46:44 +0000 |
commit | a0d77e93298ab2e62600ec835099691b37fce69b (patch) | |
tree | c364f785b543b432a906d9d0779362114026ec2e /epan/dfilter/dfilter-int.h | |
parent | b4196ab772bd80f0bd95981fa4e70e884bfb8937 (diff) |
dfilter: Return an error object instead of string
Return an struct containing error information. This simplifies
the interface to more easily provide richer diagnostics in the future.
Add an error code besides a human-readable error string to allow
checking programmatically for errors in a robust manner. Currently
there is only a generic error code, it is expected to increase
in the future.
Move error location information to the struct. Change callers and
implementation to use the new interface.
Diffstat (limited to 'epan/dfilter/dfilter-int.h')
-rw-r--r-- | epan/dfilter/dfilter-int.h | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/epan/dfilter/dfilter-int.h b/epan/dfilter/dfilter-int.h index ad38e368d6..7ad88f2280 100644 --- a/epan/dfilter/dfilter-int.h +++ b/epan/dfilter/dfilter-int.h @@ -43,8 +43,8 @@ struct epan_dfilter { typedef struct { /* Syntax Tree stuff */ stnode_t *st_root; - gboolean syntax_error; - gchar *error_message; + gboolean parse_failure; + df_error_t error; GPtrArray *insns; GHashTable *loaded_fields; GHashTable *loaded_raw_fields; @@ -55,7 +55,6 @@ typedef struct { GHashTable *references; /* hfinfo -> pointer to array of references */ GHashTable *raw_references; /* hfinfo -> pointer to array of references */ char *expanded_text; - stloc_t err_loc; } dfwork_t; /* @@ -80,17 +79,17 @@ void Dfilter(void*, int, stnode_t*, dfwork_t*); #define SCAN_FAILED -1 /* not 0, as that means end-of-input */ void -dfilter_vfail(dfwork_t *dfw, stloc_t *err_loc, +dfilter_vfail(dfwork_t *dfw, int code, stloc_t *err_loc, const char *format, va_list args); void -dfilter_fail(dfwork_t *dfw, stloc_t *err_loc, - const char *format, ...) G_GNUC_PRINTF(3, 4); +dfilter_fail(dfwork_t *dfw, int code, stloc_t *err_loc, + const char *format, ...) G_GNUC_PRINTF(4, 5); WS_NORETURN void -dfilter_fail_throw(dfwork_t *dfw, stloc_t *err_loc, - const char *format, ...) G_GNUC_PRINTF(3, 4); +dfilter_fail_throw(dfwork_t *dfw, int code, stloc_t *err_loc, + const char *format, ...) G_GNUC_PRINTF(4, 5); void dfw_set_error_location(dfwork_t *dfw, stloc_t *err_loc); @@ -126,4 +125,13 @@ reference_new(const field_info *finfo, gboolean raw); void reference_free(df_reference_t *ref); +void dfw_error_init(df_error_t *err); + +void dfw_error_clear(df_error_t *err); + +void dfw_error_set_msg(df_error_t **errp, const char *fmt, ...) +G_GNUC_PRINTF(2, 3); + +void dfw_error_take(df_error_t **errp, df_error_t *src); + #endif |