فهرست منبع

Introducing CONSUME_ALL flag: all the subsequent parameters are
accepted without resolving or checking them
Can be used to implement selects with more than one parameter

Miklos Tirpak 17 سال پیش
والد
کامیت
c935a4a3ca
2فایلهای تغییر یافته به همراه19 افزوده شده و 3 حذف شده
  1. 11 0
      select.c
  2. 8 3
      select.h

+ 11 - 0
select.c

@@ -299,6 +299,17 @@ int resolve_select(select_t* s)
 		}
 
 		f = t->table[table_idx].new_f;
+
+		if (t->table[table_idx].flags & CONSUME_ALL) {
+			/* sanity checks */
+			if (t->table[table_idx].flags & NESTED)
+				WARN("resolve_select: CONSUME_ALL should not be set "
+					"together with NESTED flag!\n");
+			if ((t->table[table_idx].flags & FIXUP_CALL) == 0)
+				WARN("resolve_select: FIXUP_CALL should be defined "
+					"if CONSUME_ALL flag is set!\n");
+			break;
+		}
 	}
 
 	if (t->table[table_idx].flags & SEL_PARAM_EXPECTED) {

+ 8 - 3
select.h

@@ -66,11 +66,16 @@
  */
 #define CONSUME_NEXT_INT 1<<11
 
+/* accept all the following parameters
+ * without checking them
+ */
+#define CONSUME_ALL	1<<12
+
 /* next parameter is optional (use with CONSUME_NEXT_STR or CONSUME_NEXT_INT
  * resolution is accepted even if there is no other parameter
  * or the parameter is of wrong type
  */
-#define OPTIONAL         1<<12
+#define OPTIONAL         1<<13
 
 /* left function is noted to be called
  * rigth function continues in resolution
@@ -83,14 +88,14 @@
  * the only one parameter passed between nested calls
  * is the result str*
  */
-#define NESTED		1<<13
+#define NESTED		1<<14
 
 /* "fixup call" would be done, when the structure is resolved to this node
  * which means call with res and msg NULL
  *
  * if the fixup call return value <0, the select resolution will fail
  */
-#define FIXUP_CALL	1<<14
+#define FIXUP_CALL	1<<15
 
 /*
  * Selector call parameter