core: kemi - option to return 0 instead of null for xval
authorDaniel-Constantin Mierla <miconda@gmail.com>
Sun, 3 May 2020 07:41:29 +0000 (09:41 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Sun, 3 May 2020 09:38:59 +0000 (11:38 +0200)
src/core/kemi.c
src/core/kemi.h

index d389c4b..8a77c22 100644 (file)
@@ -2377,16 +2377,24 @@ static sr_kemi_t _sr_kemi_hdr[] = {
  */
 void sr_kemi_xval_null(sr_kemi_xval_t *xval, int rmode)
 {
-       if(rmode==SR_KEMI_XVAL_NULL_PRINT) {
-               xval->vtype = SR_KEMIP_STR;
-               xval->v.s = *pv_get_null_str();
-       } else if(rmode==SR_KEMI_XVAL_NULL_EMPTY) {
-               xval->vtype = SR_KEMIP_STR;
-               xval->v.s = *pv_get_empty_str();
-       } else {
-               xval->vtype = SR_KEMIP_NULL;
-               xval->v.s.s = NULL;
-               xval->v.s.len = 0;
+       switch(rmode) {
+               case SR_KEMI_XVAL_NULL_PRINT:
+                       xval->vtype = SR_KEMIP_STR;
+                       xval->v.s = *pv_get_null_str();
+                       return;
+               case SR_KEMI_XVAL_NULL_EMPTY:
+                       xval->vtype = SR_KEMIP_STR;
+                       xval->v.s = *pv_get_empty_str();
+                       return;
+               case SR_KEMI_XVAL_NULL_ZERO:
+                       xval->vtype = SR_KEMIP_INT;
+                       xval->v.n = 0;
+                       return;
+               default:
+                       xval->vtype = SR_KEMIP_NULL;
+                       xval->v.s.s = NULL;
+                       xval->v.s.len = 0;
+                       return;
        }
 }
 
index 85cd521..dd7d4bf 100644 (file)
@@ -222,6 +222,7 @@ sr_kemi_t* sr_kemi_exports_get_pv(void);
 #define SR_KEMI_XVAL_NULL_NONE 0
 #define SR_KEMI_XVAL_NULL_PRINT 1
 #define SR_KEMI_XVAL_NULL_EMPTY 2
+#define SR_KEMI_XVAL_NULL_ZERO 3
 void sr_kemi_xval_null(sr_kemi_xval_t *xval, int rmode);
 void sr_kemi_xval_free(sr_kemi_xval_t *xval);
 #endif