1 --- cups-filters-1.8.2/scripting/php/phpcups.c.orig 2016-03-21 21:04:50.568131047 +0100
2 +++ cups-filters-1.8.2/scripting/php/phpcups.c 2016-03-28 21:51:56.884340677 +0200
4 # define CUPS_SVERSION CPPSTR(CUPS_VERSION_MAJOR) "." CPPSTR(CUPS_VERSION_MINOR) "." CPPSTR(CUPS_VERSION_PATCH)
7 +#if PHP_MAJOR_VERSION >= 7
8 +# define php_add_property_string(arg, key, str, n) add_property_string(arg, key, str)
9 +# define php_add_assoc_string(arg, key, str, n) add_assoc_string(arg, key, str)
10 +# define PHP_RETURN_STRING(s, n) RETURN_STRING(s)
12 +# define php_add_property_string(arg, key, str, n) add_property_string(arg, key, str, n)
13 +# define php_add_assoc_string(arg, key, str, n) add_assoc_string(arg, key, str, n)
14 +# define PHP_RETURN_STRING(s, n) RETURN_STRING(s, n)
18 * PHP function list...
22 int num_options; /* Number of options */
23 HashTable *ht; /* Option array hash table */
24 - Bucket *current; /* Current element in array */
25 zval *value; /* Current value in array */
26 char temp[255]; /* String value for numbers */
27 +#if PHP_MAJOR_VERSION >= 7
30 + Bucket *current; /* Current element in array */
35 ht = Z_ARRVAL_P(optionsobj);
38 +#if PHP_MAJOR_VERSION >= 7
39 + ZEND_HASH_FOREACH_STR_KEY_VAL(ht, zkey, value)
40 + key = (const char*)&ZSTR_VAL(zkey);
42 for (current = ht->pListHead; current; current = current->pListNext)
44 value = (zval *)current->pDataPtr;
45 + key = current->arKey;
48 switch (Z_TYPE_P(value))
51 sprintf(temp, "%ld", Z_LVAL_P(value));
52 - num_options = cupsAddOption(current->arKey, temp, num_options,
53 + num_options = cupsAddOption(key, temp, num_options,
58 sprintf(temp, "%g", Z_DVAL_P(value));
59 - num_options = cupsAddOption(current->arKey, temp, num_options,
60 + num_options = cupsAddOption(key, temp, num_options,
64 +#if PHP_MAJOR_VERSION >= 7
66 + num_options = cupsAddOption(key, "false",
67 + num_options, options);
70 + num_options = cupsAddOption(key, "true",
71 + num_options, options);
75 - num_options = cupsAddOption(current->arKey,
76 + num_options = cupsAddOption(key,
77 Z_BVAL_P(value) ? "true" : "false",
78 num_options, options);
83 - num_options = cupsAddOption(current->arKey, Z_STRVAL_P(value),
84 + num_options = cupsAddOption(key, Z_STRVAL_P(value),
85 num_options, options);
88 +#if PHP_MAJOR_VERSION >= 7
89 + ZEND_HASH_FOREACH_END();
97 cups_dest_t *dests, /* Destinations */
98 *dest; /* Current destination */
99 cups_option_t *option; /* Current option */
100 +#if PHP_MAJOR_VERSION >= 7
101 + zval destobjs, optionsobjs; /* storage for the below */
103 zval *destobj, /* Destination object */
104 *optionsobj; /* Options object */
108 for (i = 0, dest = dests; i < num_dests; i ++, dest ++)
110 +#if PHP_MAJOR_VERSION >= 7
111 + destobj = &destobjs;
113 MAKE_STD_ZVAL(destobj);
116 if (object_init(destobj) == SUCCESS)
122 - add_property_string(destobj, "name", dest->name, 1);
123 - add_property_string(destobj, "instance",
124 + php_add_property_string(destobj, "name", dest->name, 1);
125 + php_add_property_string(destobj, "instance",
126 dest->instance ? dest->instance : "", 1);
127 add_property_long(destobj, "is_default", dest->is_default);
129 @@ -280,14 +323,18 @@
130 * Create an associative array for the options...
133 +#if PHP_MAJOR_VERSION >= 7
134 + optionsobj = &optionsobjs;
136 MAKE_STD_ZVAL(optionsobj);
139 if (array_init(optionsobj) == SUCCESS)
141 for (j = 0, option = dest->options;
142 j < dest->num_options;
144 - add_assoc_string(optionsobj, option->name, option->value, 1);
145 + php_add_assoc_string(optionsobj, option->name, option->value, 1);
147 add_property_zval(destobj, "options", optionsobj);
150 cups_job_t *jobs, /* Jobs */
151 *job; /* Current job */
152 zval *jobobj; /* Job object */
154 +#if PHP_MAJOR_VERSION >= 7
155 + zval jobobjs; /* Job object storage */
162 for (i = 0, job = jobs; i < num_jobs; i ++, job ++)
164 +#if PHP_MAJOR_VERSION >= 7
167 MAKE_STD_ZVAL(jobobj);
170 if (object_init(jobobj) == SUCCESS)
172 @@ -348,10 +401,10 @@
175 add_property_long(jobobj, "id", job->id);
176 - add_property_string(jobobj, "dest", job->dest, 1);
177 - add_property_string(jobobj, "title", job->title, 1);
178 - add_property_string(jobobj, "user", job->user, 1);
179 - add_property_string(jobobj, "format", job->format, 1);
180 + php_add_property_string(jobobj, "dest", job->dest, 1);
181 + php_add_property_string(jobobj, "title", job->title, 1);
182 + php_add_property_string(jobobj, "user", job->user, 1);
183 + php_add_property_string(jobobj, "format", job->format, 1);
184 add_property_long(jobobj, "state", job->state);
185 add_property_long(jobobj, "size", job->size);
186 add_property_long(jobobj, "priority", job->priority);
191 - RETURN_STRING((char *)cupsLastErrorString(), 1);
192 + PHP_RETURN_STRING((char *)cupsLastErrorString(), 1);
197 int num_options; /* Number of options */
198 cups_option_t *options; /* Options */
199 HashTable *ht2; /* Option array hash table */
200 +#if PHP_MAJOR_VERSION >= 7
203 Bucket *current; /* Current element in array */
209 ht2 = Z_ARRVAL_P(filesobj);
212 +#if PHP_MAJOR_VERSION >= 7
213 + ZEND_HASH_FOREACH_VAL(ht2, value)
214 + files[num_files ++] = Z_STRVAL_P(value);
216 + if (num_files >= (int)(sizeof(files) / sizeof(files[0])))
218 + ZEND_HASH_FOREACH_END();
220 for (current = ht2->pListHead; current; current = current->pListNext)
222 files[num_files ++] = Z_STRVAL_P(((zval *)current->pDataPtr));
224 if (num_files >= (int)(sizeof(files) / sizeof(files[0])))
229 num_options = cups_convert_options(optionsobj, &options);