Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix-up.

  • Loading branch information...
commit b31c3e04bcf1c74d0726ce9c6c65c1f473ea63ca 1 parent 27d63c5
Andrei Zmievski authored

Showing 1 changed file with 30 additions and 14 deletions. Show diff stats Hide diff stats

  1. +30 14 README.PARAMETER_PARSING_API
44 README.PARAMETER_PARSING_API
@@ -13,13 +13,8 @@ meaningful error messages.
13 13 Prototypes
14 14 ----------
15 15 /* Implemented. */
16   -zend_parse_parameters(int num_args, char *type_spec, ...);
17   -zend_parse_parameters_ex(int flags, int num_args, char *type_spec, ...);
18   -
19   -/* Not implemented yet. */
20   -zend_parse_parameters_hash(HashTable *ht, char *type_spec, ...);
21   -zend_parse_parameters_hash_ex(int flags, HashTable *ht, char *type_spec, ...);
22   -
  16 +int zend_parse_parameters(int num_args TSRMLS_DC, char *type_spec, ...);
  17 +int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, char *type_spec, ...);
23 18
24 19 The zend_parse_parameters() function takes the number of parameters
25 20 passed to the extension function, the type specifier string, and the
@@ -28,6 +23,8 @@ also takes 'flags' argument -- current only ZEND_PARSE_PARAMS_QUIET can
28 23 be used as 'flags' to specify that the function should operate quietly
29 24 and not output any error messages.
30 25
  26 +Both functions return SUCCESS or FAILURE depending on the result.
  27 +
31 28 The auto-conversions are performed as necessary. Arrays, objects, and
32 29 resources cannot be autoconverted.
33 30
@@ -61,41 +58,60 @@ long l;
61 58 char *s;
62 59 int s_len;
63 60 zval *param;
64   -zend_parse_parameters(ZEND_NUM_ARGS(), "lsz", &l, &s, &s_len, &param);
  61 +if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lsz",
  62 + &l, &s, &s_len, &param) == FAILURE) {
  63 + return;
  64 +}
65 65
66 66
67 67 /* Gets an object of class specified by my_ce, and an optional double. */
68 68 zval *obj;
69 69 double d = 0.5;
70   -zend_parse_parameters(ZEND_NUM_ARGS(), "O|d", &obj, my_ce, &d);
  70 +if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|d",
  71 + &obj, my_ce, &d) == FAILURE) {
  72 + return;
  73 +}
71 74
72 75
73 76 /* Gets an object or null, and an array.
74 77 If null is passed for object, obj will be set to NULL. */
75 78 zval *obj;
76 79 zval *arr;
77   -zend_parse_parameters(ZEND_NUM_ARGS(), "O!a", &obj, &arr);
  80 +if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O!a",
  81 + &obj, &arr) == FAILURE) {
  82 + return;
  83 +}
78 84
79 85
80 86 /* Gets a separated array. */
81 87 zval *arr;
82   -zend_parse_parameters(ZEND_NUM_ARGS(), "a/", &arr));
  88 +if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/",
  89 + &arr) == FAILURE) {
  90 + return;
  91 +}
83 92
84 93
85 94 /* Get only the first three parameters (useful for varargs functions). */
86 95 zval *z;
87 96 zend_bool b;
88 97 zval *r;
89   -zend_parse_parameters(3, "zbr!", &z, &b, &r);
  98 +if (zend_parse_parameters(3 TSRMLS_CC, "zbr!",
  99 + &z, &b, &r) == FAILURE) {
  100 + return;
  101 +}
90 102
91 103
92 104 /* Get either a set of 3 longs or a string. */
93 105 long l1, l2, l3;
94 106 char *s;
95   -if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "lll", &l1, &l2, &l3)) {
  107 +if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
  108 + "lll", &l1, &l2, &l3) == SUCCESS) {
96 109 /* manipulate longs */
97   -} else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "s", &s)) {
  110 +} else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
  111 + "s", &s) == SUCCESS) {
98 112 /* manipulate string */
99 113 } else {
100 114 /* output error */
  115 +
  116 + return;
101 117 }

0 comments on commit b31c3e0

Please sign in to comment.
Something went wrong with that request. Please try again.