Skip to content

Commit 23c6a8c

Browse files
committed
Merge branch 'master' of https://github.com/OpenPrinting/libcups
2 parents 98a33d8 + ca1648a commit 23c6a8c

18 files changed

Lines changed: 132 additions & 56 deletions

cups/Dependencies

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ hash.o: hash.c cups-private.h string-private.h ../config.h base.h \
7676
debug-internal.h debug-private.h array.h ipp-private.h cups.h file.h \
7777
ipp.h http.h language.h transcode.h pwg.h http-private.h \
7878
../cups/language.h \
79-
pwg-private.h thread.h md5-internal.h
79+
pwg-private.h thread.h \
80+
md5-internal.h
8081
http.o: http.c cups-private.h string-private.h ../config.h base.h \
8182
debug-internal.h debug-private.h array.h ipp-private.h cups.h file.h \
8283
ipp.h http.h language.h transcode.h pwg.h http-private.h \
@@ -116,12 +117,14 @@ json.o: json.c cups-private.h string-private.h ../config.h base.h \
116117
debug-internal.h debug-private.h array.h ipp-private.h cups.h file.h \
117118
ipp.h http.h language.h transcode.h pwg.h http-private.h \
118119
../cups/language.h \
119-
pwg-private.h thread.h json-private.h json.h
120+
pwg-private.h thread.h \
121+
json-private.h json.h
120122
jwt.o: jwt.c cups-private.h string-private.h ../config.h base.h \
121123
debug-internal.h debug-private.h array.h ipp-private.h cups.h file.h \
122124
ipp.h http.h language.h transcode.h pwg.h http-private.h \
123125
../cups/language.h \
124-
pwg-private.h thread.h jwt.h json.h json-private.h
126+
pwg-private.h thread.h jwt.h json.h \
127+
json-private.h
125128
langprintf.o: langprintf.c cups-private.h string-private.h ../config.h \
126129
base.h debug-internal.h debug-private.h array.h ipp-private.h cups.h \
127130
file.h ipp.h http.h language.h transcode.h pwg.h http-private.h \
@@ -131,11 +134,11 @@ language.o: language.c cups-private.h string-private.h ../config.h base.h \
131134
debug-internal.h debug-private.h array.h ipp-private.h cups.h file.h \
132135
ipp.h http.h language.h transcode.h pwg.h http-private.h \
133136
../cups/language.h \
134-
pwg-private.h thread.h strings/ca_strings.h strings/cs_strings.h \
135-
strings/da_strings.h strings/de_strings.h strings/en_strings.h \
136-
strings/es_strings.h strings/fr_strings.h strings/it_strings.h \
137-
strings/ja_strings.h strings/pt_BR_strings.h strings/ru_strings.h \
138-
strings/zh_CN_strings.h
137+
pwg-private.h thread.h \
138+
strings/ca_strings.h strings/cs_strings.h strings/da_strings.h \
139+
strings/de_strings.h strings/en_strings.h strings/es_strings.h \
140+
strings/fr_strings.h strings/it_strings.h strings/ja_strings.h \
141+
strings/pt_BR_strings.h strings/ru_strings.h strings/zh_CN_strings.h
139142
md5.o: md5.c md5-internal.h base.h string-private.h ../config.h
140143
notify.o: notify.c cups-private.h string-private.h ../config.h base.h \
141144
debug-internal.h debug-private.h array.h ipp-private.h cups.h file.h \
@@ -146,7 +149,8 @@ oauth.o: oauth.c cups-private.h string-private.h ../config.h base.h \
146149
debug-internal.h debug-private.h array.h ipp-private.h cups.h file.h \
147150
ipp.h http.h language.h transcode.h pwg.h http-private.h \
148151
../cups/language.h \
149-
pwg-private.h thread.h oauth.h jwt.h json.h form.h
152+
pwg-private.h thread.h oauth.h jwt.h \
153+
json.h form.h
150154
options.o: options.c cups-private.h string-private.h ../config.h base.h \
151155
debug-internal.h debug-private.h array.h ipp-private.h cups.h file.h \
152156
ipp.h http.h language.h transcode.h pwg.h http-private.h \
@@ -163,7 +167,8 @@ raster-error.o: raster-error.c cups-private.h string-private.h \
163167
../config.h base.h debug-internal.h debug-private.h array.h \
164168
ipp-private.h cups.h file.h ipp.h http.h language.h transcode.h pwg.h \
165169
http-private.h ../cups/language.h \
166-
pwg-private.h thread.h raster-private.h raster.h
170+
pwg-private.h thread.h \
171+
raster-private.h raster.h
167172
raster-stream.o: raster-stream.c raster-private.h raster.h cups.h file.h \
168173
base.h ipp.h http.h array.h language.h transcode.h pwg.h \
169174
debug-private.h string-private.h ../config.h debug-internal.h
@@ -191,7 +196,8 @@ tls.o: tls.c cups-private.h string-private.h ../config.h base.h \
191196
debug-internal.h debug-private.h array.h ipp-private.h cups.h file.h \
192197
ipp.h http.h language.h transcode.h pwg.h http-private.h \
193198
../cups/language.h \
194-
pwg-private.h thread.h dir.h tls-openssl.c \
199+
pwg-private.h thread.h dir.h \
200+
tls-openssl.c \
195201

196202
transcode.o: transcode.c cups.h file.h base.h ipp.h http.h array.h \
197203
language.h transcode.h pwg.h thread.h debug-internal.h debug-private.h \
@@ -226,16 +232,19 @@ testcreds.o: testcreds.c cups-private.h string-private.h ../config.h \
226232
base.h debug-internal.h debug-private.h array.h ipp-private.h cups.h \
227233
file.h ipp.h http.h language.h transcode.h pwg.h http-private.h \
228234
../cups/language.h \
229-
pwg-private.h thread.h test-internal.h
235+
pwg-private.h thread.h \
236+
test-internal.h
230237
testcups.o: testcups.c cups-private.h string-private.h ../config.h base.h \
231238
debug-internal.h debug-private.h array.h ipp-private.h cups.h file.h \
232239
ipp.h http.h language.h transcode.h pwg.h http-private.h \
233240
../cups/language.h \
234-
pwg-private.h thread.h test-internal.h
241+
pwg-private.h thread.h \
242+
test-internal.h
235243
testdest.o: testdest.c cups.h file.h base.h ipp.h http.h array.h \
236244
language.h transcode.h pwg.h
237-
testdnssd.o: testdnssd.c test-internal.h dnssd.h cups.h file.h base.h \
238-
ipp.h http.h array.h language.h transcode.h pwg.h thread.h
245+
testdnssd.o: testdnssd.c ../config.h test-internal.h dnssd.h cups.h \
246+
file.h base.h ipp.h http.h array.h language.h transcode.h pwg.h \
247+
string-private.h thread.h
239248
testfile.o: testfile.c string-private.h ../config.h base.h \
240249
debug-private.h cups.h file.h ipp.h http.h array.h language.h \
241250
transcode.h pwg.h dir.h test-internal.h
@@ -249,7 +258,8 @@ testhttp.o: testhttp.c cups-private.h string-private.h ../config.h base.h \
249258
debug-internal.h debug-private.h array.h ipp-private.h cups.h file.h \
250259
ipp.h http.h language.h transcode.h pwg.h http-private.h \
251260
../cups/language.h \
252-
pwg-private.h thread.h test-internal.h
261+
pwg-private.h thread.h \
262+
test-internal.h
253263
testi18n.o: testi18n.c string-private.h ../config.h base.h language.h \
254264
transcode.h test-internal.h cups.h file.h ipp.h http.h array.h pwg.h
255265
testipp.o: testipp.c file.h base.h string-private.h ../config.h \
@@ -267,7 +277,8 @@ testoptions.o: testoptions.c cups-private.h string-private.h ../config.h \
267277
base.h debug-internal.h debug-private.h array.h ipp-private.h cups.h \
268278
file.h ipp.h http.h language.h transcode.h pwg.h http-private.h \
269279
../cups/language.h \
270-
pwg-private.h thread.h test-internal.h
280+
pwg-private.h thread.h \
281+
test-internal.h
271282
testpwg.o: testpwg.c cups.h file.h base.h ipp.h http.h array.h language.h \
272283
transcode.h pwg.h pwg-private.h test-internal.h
273284
testraster.o: testraster.c raster-private.h raster.h cups.h file.h base.h \

cups/array.c

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,20 @@ cupsArrayGetCount(cups_array_t *a) // I - Array
385385
}
386386

387387

388+
//
389+
// '_cupsArrayFree()' - Free a string in an array.
390+
//
391+
392+
void
393+
_cupsArrayFree(void *s, // I - String to free
394+
void *data) // I - Callback data (unused)
395+
{
396+
(void)data;
397+
398+
free(s);
399+
}
400+
401+
388402
//
389403
// 'cupsArrayGetCurrent()' - Return the current element in an array.
390404
//
@@ -679,7 +693,7 @@ cupsArrayNewStrings(const char *s, // I - Delimited strings or `NULL` to create
679693
cups_array_t *a; // Array
680694

681695

682-
if ((a = cupsArrayNew((cups_array_cb_t)strcmp, NULL, NULL, 0, (cups_acopy_cb_t)_cupsStrAlloc, (cups_afree_cb_t)_cupsStrFree)) != NULL)
696+
if ((a = cupsArrayNew(_cupsArrayStrcmp, NULL, NULL, 0, _cupsArrayStrdup, _cupsArrayFree)) != NULL)
683697
cupsArrayAddStrings(a, s, delim);
684698

685699
return (a);
@@ -791,6 +805,35 @@ cupsArraySave(cups_array_t *a) // I - Array
791805
}
792806

793807

808+
//
809+
// '_cupsArrayStrcmp()' - Compare two strings in an array.
810+
//
811+
812+
int // O - Result of comparison
813+
_cupsArrayStrcmp(void *s, // I - first string to compare
814+
void *t, // I - second string to compare
815+
void *data) // I - Callback data (unused)
816+
{
817+
(void)data;
818+
819+
return (strcmp((const char *)s, (const char *)t));
820+
}
821+
822+
823+
//
824+
// '_cupsArrayStrdup()' - Copy a string in an array.
825+
//
826+
827+
void * // O - Copy of string
828+
_cupsArrayStrdup(void *s, // I - String to copy
829+
void *data) // I - Callback data (unused)
830+
{
831+
(void)data;
832+
833+
return (strdup((const char *)s));
834+
}
835+
836+
794837
//
795838
// 'cups_array_add()' - Insert or append an element to the array.
796839
//

cups/file.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ cupsFileOpen(const char *filename, // I - Name of file
656656
break;
657657

658658
case 'w' : // Write file
659-
fd = cups_open(filename, O_WRONLY | O_LARGEFILE | O_BINARY, perm);
659+
fd = cups_open(filename, O_WRONLY | O_LARGEFILE | O_BINARY, perm);
660660
if (fd < 0 && errno == ENOENT)
661661
{
662662
fd = cups_open(filename, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE | O_BINARY, perm);
@@ -1790,7 +1790,9 @@ cups_open(const char *filename, // I - Filename
17901790
// Then verify that the file descriptor doesn't point to a directory or hard-linked file.
17911791
if (fstat(fd, &fileinfo))
17921792
{
1793+
int temp = errno;
17931794
close(fd);
1795+
errno = temp;
17941796
return (-1);
17951797
}
17961798

@@ -1816,7 +1818,9 @@ cups_open(const char *filename, // I - Filename
18161818
// Then use lstat to determine whether the filename is a symlink...
18171819
if (lstat(filename, &linkinfo))
18181820
{
1821+
int temp = errno;
18191822
close(fd);
1823+
errno = temp;
18201824
return (-1);
18211825
}
18221826

cups/ipp-file.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// IPP data file functions.
33
//
4-
// Copyright © 2021-2024 by OpenPrinting.
4+
// Copyright © 2021-2025 by OpenPrinting.
55
// Copyright © 2007-2019 by Apple Inc.
66
// Copyright © 1997-2007 by Easy Software Products.
77
//
@@ -33,7 +33,6 @@ struct _ipp_file_s // IPP data file
3333
cups_option_t *vars; // Variables
3434
ipp_fattr_cb_t attr_cb; // Attribute (filter) callback
3535
ipp_ferror_cb_t error_cb; // Error reporting callback
36-
ipp_ftoken_cb_t token_cb; // Token processing callback
3736
void *cb_data; // Callback data
3837
char *buffer; // Output buffer
3938
size_t alloc_buffer; // Size of output buffer

cups/ipp-support.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,15 +1999,15 @@ ippCreateRequestedArray(ipp_t *request) // I - IPP request
19991999
// "all"...
20002000
if (op == IPP_OP_GET_JOBS)
20012001
{
2002-
ra = cupsArrayNew((cups_array_cb_t)strcmp, NULL, NULL, 0, NULL, NULL);
2002+
ra = cupsArrayNew(_cupsArrayStrcmp, NULL, NULL, 0, NULL, NULL);
20032003
cupsArrayAdd(ra, "job-id");
20042004
cupsArrayAdd(ra, "job-uri");
20052005

20062006
return (ra);
20072007
}
20082008
else if (op == IPP_OP_GET_DOCUMENTS)
20092009
{
2010-
ra = cupsArrayNew((cups_array_cb_t)strcmp, NULL, NULL, 0, NULL, NULL);
2010+
ra = cupsArrayNew(_cupsArrayStrcmp, NULL, NULL, 0, NULL, NULL);
20112011
cupsArrayAdd(ra, "document-number");
20122012

20132013
return (ra);
@@ -2024,7 +2024,7 @@ ippCreateRequestedArray(ipp_t *request) // I - IPP request
20242024
return (NULL);
20252025

20262026
// Create an array using "strcmp" as the comparison function...
2027-
ra = cupsArrayNew((cups_array_cb_t)strcmp, NULL, NULL, 0, NULL, NULL);
2027+
ra = cupsArrayNew(_cupsArrayStrcmp, NULL, NULL, 0, NULL, NULL);
20282028

20292029
for (i = 0; i < count; i ++)
20302030
{

cups/json.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// JSON API implementation for CUPS.
33
//
4-
// Copyright © 2022-2024 by OpenPrinting.
4+
// Copyright © 2022-2025 by OpenPrinting.
55
//
66
// Licensed under Apache License v2.0. See the file "LICENSE" for more
77
// information.
@@ -1326,11 +1326,11 @@ cupsJSONNew(cups_json_t *parent, // I - Parent JSON node or `NULL` for a root n
13261326

13271327
cups_json_t * // O - JSON node
13281328
cupsJSONNewKey(cups_json_t *parent, // I - Parent JSON node or `NULL` for a root node
1329-
cups_json_t *after, // I - Previous sibling node or `NULL` to append to the end
1330-
const char *value) // I - Key string
1329+
cups_json_t *after, // I - Previous sibling node or `NULL` to append to the end
1330+
const char *key) // I - Key string
13311331
{
13321332
cups_json_t *node; // JSON node
1333-
char *s = strdup(value); // Key string
1333+
char *s = strdup(key); // Key string
13341334

13351335

13361336
if (!s)

cups/json.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// JSON API definitions for CUPS.
33
//
4-
// Copyright © 2022-2024 by OpenPrinting.
4+
// Copyright © 2022-2025 by OpenPrinting.
55
//
66
// Licensed under Apache License v2.0. See the file "LICENSE" for more
77
// information.
@@ -61,7 +61,7 @@ extern cups_json_t *cupsJSONImportString(const char *s) _CUPS_PUBLIC;
6161
extern cups_json_t *cupsJSONImportURL(const char *url, time_t *last_modified) _CUPS_PUBLIC;
6262

6363
extern cups_json_t *cupsJSONNew(cups_json_t *parent, cups_json_t *after, cups_jtype_t type) _CUPS_PUBLIC;
64-
extern cups_json_t *cupsJSONNewKey(cups_json_t *parent, cups_json_t *after, const char *value) _CUPS_PUBLIC;
64+
extern cups_json_t *cupsJSONNewKey(cups_json_t *parent, cups_json_t *after, const char *key) _CUPS_PUBLIC;
6565
extern cups_json_t *cupsJSONNewNumber(cups_json_t *parent, cups_json_t *after, double number) _CUPS_PUBLIC;
6666
extern cups_json_t *cupsJSONNewString(cups_json_t *parent, cups_json_t *after, const char *value) _CUPS_PUBLIC;
6767

cups/libcups3.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ _cups_strcasecmp
88
_cups_strcpy
99
_cups_strcpy
1010
_cups_strncasecmp
11+
_cupsArrayFree
12+
_cupsArrayStrcmp
13+
_cupsArrayStrdup
1114
_cupsBufferGet
1215
_cupsBufferRelease
1316
_cupsConnect
@@ -291,9 +294,11 @@ cupsOAuthCopyRefreshToken
291294
cupsOAuthCopyUserId
292295
cupsOAuthGetAuthorizationCode
293296
cupsOAuthGetClientId
297+
cupsOAuthGetDeviceGrant
294298
cupsOAuthGetJWKS
295299
cupsOAuthGetMetadata
296300
cupsOAuthGetTokens
301+
cupsOAuthGetUserId
297302
cupsOAuthMakeAuthorizationURL
298303
cupsOAuthMakeBase64Random
299304
cupsOAuthSaveClientData

cups/oauth.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,12 +1308,15 @@ cupsOAuthGetTokens(
13081308

13091309
if (error)
13101310
{
1311-
// Handle "soft" device access token errors by setting access_expires to
1312-
// the next call time...
1313-
if (!strcmp(error, "slow_down"))
1314-
*access_expires = time(NULL) + 10;
1315-
else
1316-
*access_expires = time(NULL) + 5;
1311+
if (access_expires)
1312+
{
1313+
// Handle "soft" device access token errors by setting access_expires to
1314+
// the next call time...
1315+
if (!strcmp(error, "slow_down"))
1316+
*access_expires = time(NULL) + 10;
1317+
else
1318+
*access_expires = time(NULL) + 5;
1319+
}
13171320

13181321
// Free memory and return...
13191322
cupsJSONDelete(response);

cups/string-private.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// Private string definitions for CUPS.
33
//
4-
// Copyright © 2021-2023 by OpenPrinting.
4+
// Copyright © 2021-2025 by OpenPrinting.
55
// Copyright © 2007-2018 by Apple Inc.
66
// Copyright © 1997-2006 by Easy Software Products.
77
//
@@ -120,6 +120,10 @@ extern void _cups_strcpy(char *dst, const char *src) _CUPS_PRIVATE;
120120
extern int _cups_strcasecmp(const char *, const char *) _CUPS_PRIVATE;
121121
extern int _cups_strncasecmp(const char *, const char *, size_t n) _CUPS_PRIVATE;
122122

123+
extern void _cupsArrayFree(void *s, void *data) _CUPS_PRIVATE;
124+
extern int _cupsArrayStrcmp(void *s, void *t, void *data) _CUPS_PRIVATE;
125+
extern void *_cupsArrayStrdup(void *s, void *data) _CUPS_PRIVATE;
126+
123127
extern char *_cupsStrAlloc(const char *s) _CUPS_PRIVATE;
124128
extern void _cupsStrFlush(void) _CUPS_PRIVATE;
125129
extern void _cupsStrFree(const char *s) _CUPS_PRIVATE;

0 commit comments

Comments
 (0)