]> git.pld-linux.org Git - packages/cups-filters.git/blob - cups-filters-php7.patch
- rebuild with poppler 0.65.0
[packages/cups-filters.git] / cups-filters-php7.patch
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
3 @@ -37,6 +37,16 @@
4  #  define CUPS_SVERSION CPPSTR(CUPS_VERSION_MAJOR) "." CPPSTR(CUPS_VERSION_MINOR) "." CPPSTR(CUPS_VERSION_PATCH)
5  #endif
6  
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)
11 +#else
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)
15 +#endif
16 +
17  /*
18   * PHP function list...
19   */
20 @@ -87,44 +97,70 @@
21  {
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
28 +  zend_string   *zkey;
29 +#else
30 +  Bucket       *current;               /* Current element in array */
31 +#endif
32 +  const char    *key;
33  
34  
35    ht          = Z_ARRVAL_P(optionsobj);
36    num_options = 0;
37  
38 +#if PHP_MAJOR_VERSION >= 7
39 +  ZEND_HASH_FOREACH_STR_KEY_VAL(ht, zkey, value)
40 +    key = (const char*)&ZSTR_VAL(zkey);
41 +#else
42    for (current = ht->pListHead; current; current = current->pListNext)
43    {
44      value = (zval *)current->pDataPtr;
45 +    key = current->arKey;
46 +#endif
47  
48      switch (Z_TYPE_P(value))
49      {
50        case IS_LONG :
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,
54                                       options);
55            break;
56  
57        case IS_DOUBLE :
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,
61                                       options);
62            break;
63  
64 +#if PHP_MAJOR_VERSION >= 7
65 +      case IS_FALSE :
66 +          num_options = cupsAddOption(key, "false",
67 +                                     num_options, options);
68 +          break;
69 +      case IS_TRUE :
70 +          num_options = cupsAddOption(key, "true",
71 +                                     num_options, options);
72 +          break;
73 +#else
74        case IS_BOOL :
75 -          num_options = cupsAddOption(current->arKey,
76 +          num_options = cupsAddOption(key,
77                                       Z_BVAL_P(value) ? "true" : "false",
78                                       num_options, options);
79            break;
80 +#endif
81  
82        case IS_STRING :
83 -          num_options = cupsAddOption(current->arKey, Z_STRVAL_P(value),
84 +          num_options = cupsAddOption(key, Z_STRVAL_P(value),
85                                       num_options, options);
86            break;
87      }
88 +#if PHP_MAJOR_VERSION >= 7
89 +  ZEND_HASH_FOREACH_END();
90 +#else
91    }
92 +#endif
93  
94    return (num_options);
95  }
96 @@ -244,6 +280,9 @@
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 */
102 +#endif
103    zval         *destobj,               /* Destination object */
104                 *optionsobj;            /* Options object */
105  
106 @@ -262,7 +301,11 @@
107    {
108      for (i = 0, dest = dests; i < num_dests; i ++, dest ++)
109      {
110 +#if PHP_MAJOR_VERSION >= 7
111 +      destobj = &destobjs;
112 +#else
113        MAKE_STD_ZVAL(destobj);
114 +#endif
115  
116        if (object_init(destobj) == SUCCESS)
117        {
118 @@ -271,8 +314,8 @@
119         * members...
120         */
121  
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);
128  
129 @@ -280,14 +323,18 @@
130          * Create an associative array for the options...
131         */
132  
133 +#if PHP_MAJOR_VERSION >= 7
134 +       optionsobj = &optionsobjs;
135 +#else
136          MAKE_STD_ZVAL(optionsobj);
137 +#endif
138  
139         if (array_init(optionsobj) == SUCCESS)
140         {
141           for (j = 0, option = dest->options;
142                j < dest->num_options;
143                j ++, option ++)
144 -           add_assoc_string(optionsobj, option->name, option->value, 1);
145 +           php_add_assoc_string(optionsobj, option->name, option->value, 1);
146  
147           add_property_zval(destobj, "options", optionsobj);
148         }
149 @@ -316,7 +363,9 @@
150    cups_job_t   *jobs,                  /* Jobs */
151                 *job;                   /* Current job */
152    zval         *jobobj;                /* Job object */
153 -
154 +#if PHP_MAJOR_VERSION >= 7
155 +  zval         jobobjs;                /* Job object storage */
156 +#endif
157  
158  
159  
160 @@ -338,7 +387,11 @@
161    {
162      for (i = 0, job = jobs; i < num_jobs; i ++, job ++)
163      {
164 +#if PHP_MAJOR_VERSION >= 7
165 +      jobobj = &jobobjs;
166 +#else
167        MAKE_STD_ZVAL(jobobj);
168 +#endif
169  
170        if (object_init(jobobj) == SUCCESS)
171        {
172 @@ -348,10 +401,10 @@
173         */
174  
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);
187 @@ -394,7 +447,7 @@
188      WRONG_PARAM_COUNT;
189    }
190  
191 -  RETURN_STRING((char *)cupsLastErrorString(), 1);
192 +  PHP_RETURN_STRING((char *)cupsLastErrorString(), 1);
193  }
194  
195  
196 @@ -451,7 +504,11 @@
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
201 +  zval          *value;
202 +#else
203    Bucket       *current;               /* Current element in array */
204 +#endif
205    int          id;                     /* Job ID */
206  
207  
208 @@ -465,6 +522,14 @@
209    ht2       = Z_ARRVAL_P(filesobj);
210    num_files = 0;
211  
212 +#if PHP_MAJOR_VERSION >= 7
213 +  ZEND_HASH_FOREACH_VAL(ht2, value)
214 +    files[num_files ++] = Z_STRVAL_P(value);
215 +
216 +    if (num_files >= (int)(sizeof(files) / sizeof(files[0])))
217 +      break;
218 +  ZEND_HASH_FOREACH_END();
219 +#else
220    for (current = ht2->pListHead; current; current = current->pListNext)
221    {
222      files[num_files ++] = Z_STRVAL_P(((zval *)current->pDataPtr));
223 @@ -472,6 +537,7 @@
224      if (num_files >= (int)(sizeof(files) / sizeof(files[0])))
225        break;
226    }
227 +#endif
228  
229    num_options = cups_convert_options(optionsobj, &options);
230  
This page took 0.121175 seconds and 3 git commands to generate.