1 /*
2 * Configuration file for CUPS on Windows.
3 *
4 * Copyright © 2021-2025 by OpenPrinting
5 * Copyright © 2007-2019 by Apple Inc.
6 * Copyright © 1997-2007 by Easy Software Products.
7 *
8 * Licensed under Apache License v2.0. See the file "LICENSE" for more
9 * information.
10 */
11
12 #ifndef _CUPS_CONFIG_H_
13 #define _CUPS_CONFIG_H_
14
15 /*
16 * Include necessary headers...
17 */
18
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <stdarg.h>
23 #include <io.h>
24 #include <direct.h>
25
26
27 /*
28 * Microsoft renames the POSIX functions to _name, and introduces
29 * a broken compatibility layer using the original names. As a result,
30 * random crashes can occur when, for example, strdup() allocates memory
31 * from a different heap than used by malloc() and free().
32 *
33 * To avoid moronic problems like this, we #define the POSIX function
34 * names to the corresponding non-standard Microsoft names.
35 */
36
37 #define access _access
38 #define close _close
39 #define fileno _fileno
40 #define lseek _lseek
41 #define mkdir(d,p) _mkdir(d)
42 #define open _open
43 #define read _read
44 #define rmdir _rmdir
45 #define snprintf _snprintf
46 #define strdup _strdup
47 #define unlink _unlink
48 #define vsnprintf _vsnprintf
49 #define write _write
50
51
52 /*
53 * Microsoft "safe" functions use a different argument order than POSIX...
54 */
55
56 #define gmtime_r(t,tm) gmtime_s(tm,t)
57 #define localtime_r(t,tm) localtime_s(tm,t)
58
59
60 /*
61 * Map the POSIX strcasecmp() and strncasecmp() functions to the Win32
62 * _stricmp() and _strnicmp() functions...
63 */
64
65 #define strcasecmp _stricmp
66 #define strncasecmp _strnicmp
67
68
69 /*
70 * Map the POSIX sleep() and usleep() functions to the Win32 Sleep() function...
71 */
72
73 typedef unsigned long useconds_t;
74 #define sleep(X) Sleep(1000 * (X))
75 #define usleep(X) Sleep((X)/1000)
76
77
78 /*
79 * Map various parameters to Posix style system calls
80 */
81
82 # define F_OK 00
83 # define W_OK 02
84 # define R_OK 04
85 # define O_RDONLY _O_RDONLY
86 # define O_WRONLY _O_WRONLY
87 # define O_CREAT _O_CREAT
88 # define O_TRUNC _O_TRUNC
89
90
91 /*
92 * Compiler stuff...
93 */
94
95 #undef const
96 #undef __CHAR_UNSIGNED__
97
98
99 /*
100 * Version of software...
101 */
102
103 #define CUPS_SVERSION "CUPS v2.4.12"
104 #define CUPS_MINIMAL "CUPS/2.4.12"
105
106
107 /*
108 * Default user and groups...
109 */
110
111 #define CUPS_DEFAULT_USER ""
112 #define CUPS_DEFAULT_GROUP ""
113 #define CUPS_DEFAULT_SYSTEM_GROUPS ""
114 #define CUPS_DEFAULT_PRINTOPERATOR_AUTH ""
115 #define CUPS_DEFAULT_SYSTEM_AUTHKEY ""
116
117
118 /*
119 * Default file permissions...
120 */
121
122 #define CUPS_DEFAULT_CONFIG_FILE_PERM 0644
123 #define CUPS_DEFAULT_LOG_FILE_PERM 0644
124
125
126 /*
127 * Default logging settings...
128 */
129
130 #define CUPS_DEFAULT_LOG_LEVEL "warn"
131 #define CUPS_DEFAULT_ACCESS_LOG_LEVEL "none"
132 #define CUPS_DEFAULT_MAX_LOG_SIZE "1m"
133
134
135 /*
136 * Default fatal error settings...
137 */
138
139 #define CUPS_DEFAULT_FATAL_ERRORS "config"
140
141
142 /*
143 * Default browsing settings...
144 */
145
146 #define CUPS_DEFAULT_BROWSING 1
147 #define CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS "dnssd"
148 #define CUPS_DEFAULT_DEFAULT_SHARED 1
149
150
151 /*
152 * Default IPP port...
153 */
154
155 #define CUPS_DEFAULT_IPP_PORT 631
156
157
158 /*
159 * Default printcap file...
160 */
161
162 #define CUPS_DEFAULT_PRINTCAP ""
163
164
165 /*
166 * Default ErrorPolicy value...
167 */
168
169 #define CUPS_DEFAULT_ERROR_POLICY "stop-printer"
170
171
172 /*
173 * Default MaxCopies value...
174 */
175
176 #define CUPS_DEFAULT_MAX_COPIES 9999
177
178
179 /*
180 * Default SyncOnClose value...
181 */
182
183 /* #undef CUPS_DEFAULT_SYNC_ON_CLOSE */
184
185
186 /*
187 * Do we have domain socket support, and if so what is the default one?
188 */
189
190 #undef CUPS_DEFAULT_DOMAINSOCKET
191
192
193 /*
194 * Default WebInterface value...
195 */
196
197 #define CUPS_DEFAULT_WEBIF 0
198
199
200 /*
201 * Where are files stored?
202 *
203 * Note: These are defaults, which can be overridden by environment
204 * variables at run-time...
205 */
206
207 #define CUPS_BINDIR "C:/CUPS/bin"
208 #define CUPS_CACHEDIR "C:/CUPS/cache"
209 #define CUPS_DATADIR "C:/CUPS/share"
210 #define CUPS_DOCROOT "C:/CUPS/share/doc"
211 #define CUPS_LOCALEDIR "C:/CUPS/locale"
212 #define CUPS_LOGDIR "C:/CUPS/logs"
213 #define CUPS_REQUESTS "C:/CUPS/spool"
214 #define CUPS_SBINDIR "C:/CUPS/sbin"
215 #define CUPS_SERVERBIN "C:/CUPS/lib"
216 #define CUPS_SERVERROOT "C:/CUPS/etc"
217 #define CUPS_STATEDIR "C:/CUPS/run"
218
219
220 /*
221 * Do we have posix_spawn?
222 */
223
224 /* #undef HAVE_POSIX_SPAWN */
225
226
227 /*
228 * Do we have ZLIB?
229 */
230
231 #define HAVE_LIBZ 1
232 #define HAVE_INFLATECOPY 1
233
234
235 /*
236 * Do we have PAM stuff?
237 */
238
239 #define HAVE_LIBPAM 0
240 /* #undef HAVE_PAM_PAM_APPL_H */
241 /* #undef HAVE_PAM_SET_ITEM */
242 /* #undef HAVE_PAM_SETCRED */
243
244
245 /*
246 * Do we have <shadow.h>?
247 */
248
249 /* #undef HAVE_SHADOW_H */
250
251
252 /*
253 * Do we have <crypt.h>?
254 */
255
256 /* #undef HAVE_CRYPT_H */
257
258
259 /*
260 * Use <stdint.h>?
261 */
262
263 /* #undef HAVE_STDINT_H */
264
265
266 /*
267 * Use <string.h>, <strings.h>, and/or <bstring.h>?
268 */
269
270 #define HAVE_STRING_H 1
271 /* #undef HAVE_STRINGS_H */
272 /* #undef HAVE_BSTRING_H */
273
274
275 /*
276 * Do we have the long long type?
277 */
278
279 /* #undef HAVE_LONG_LONG */
280
281 #ifdef HAVE_LONG_LONG
282 # define CUPS_LLFMT "%lld"
283 # define CUPS_LLCAST (long long)
284 #else
285 # define CUPS_LLFMT "%ld"
286 # define CUPS_LLCAST (long)
287 #endif /* HAVE_LONG_LONG */
288
289
290 /*
291 * Do we have the strtoll() function?
292 */
293
294 /* #undef HAVE_STRTOLL */
295
296 #ifndef HAVE_STRTOLL
297 # define strtoll(nptr,endptr,base) strtol((nptr), (endptr), (base))
298 #endif /* !HAVE_STRTOLL */
299
300
301 /*
302 * Do we have the strXXX() functions?
303 */
304
305 #define HAVE_STRDUP 1
306 /* #undef HAVE_STRLCAT */
307 /* #undef HAVE_STRLCPY */
308
309
310 /*
311 * Do we have the geteuid() function?
312 */
313
314 /* #undef HAVE_GETEUID */
315
316
317 /*
318 * Do we have the setpgid() function?
319 */
320
321 /* #undef HAVE_SETPGID */
322
323
324 /*
325 * Do we have the vsyslog() function?
326 */
327
328 /* #undef HAVE_VSYSLOG */
329
330
331 /*
332 * Do we have the systemd journal functions?
333 */
334
335 /* #undef HAVE_SYSTEMD_SD_JOURNAL_H */
336
337
338 /*
339 * Do we have the (v)snprintf() functions?
340 */
341
342 #define HAVE_SNPRINTF 1
343 #define HAVE_VSNPRINTF 1
344
345
346 /*
347 * What signal functions to use?
348 */
349
350 /* #undef HAVE_SIGSET */
351 /* #undef HAVE_SIGACTION */
352
353
354 /*
355 * What wait functions to use?
356 */
357
358 /* #undef HAVE_WAITPID */
359 /* #undef HAVE_WAIT3 */
360
361
362 /*
363 * Do we have the mallinfo function and malloc.h?
364 */
365
366 /* #undef HAVE_MALLINFO */
367 /* #undef HAVE_MALLOC_H */
368
369
370 /*
371 * Do we have the POSIX ACL functions?
372 */
373
374 /* #undef HAVE_ACL_INIT */
375
376
377 /*
378 * Do we have the langinfo.h header file?
379 */
380
381 /* #undef HAVE_LANGINFO_H */
382
383
384 /*
385 * Which encryption libraries do we have?
386 */
387
388 #define HAVE_TLS 1
389 /* #undef HAVE_CDSASSL */
390 #define HAVE_OPENSSL 1
391 /* #undef HAVE_GNUTLS */
392 /* #undef HAVE_SSPISSL */
393
394
395 /*
396 * Do we have the gnutls_transport_set_pull_timeout_function function?
397 */
398
399 /* #undef HAVE_GNUTLS_TRANSPORT_SET_PULL_TIMEOUT_FUNCTION */
400
401
402 /*
403 * Do we have the gnutls_priority_set_direct function?
404 */
405
406 /* #undef HAVE_GNUTLS_PRIORITY_SET_DIRECT */
407
408
409 /*
410 * What Security framework headers do we have?
411 */
412
413 /* #undef HAVE_AUTHORIZATION_H */
414 /* #undef HAVE_SECCERTIFICATE_H */
415 /* #undef HAVE_SECITEM_H */
416 /* #undef HAVE_SECPOLICY_H */
417
418
419 /*
420 * Do we have the SecGenerateSelfSignedCertificate function?
421 */
422
423 /* #undef HAVE_SECGENERATESELFSIGNEDCERTIFICATE */
424
425
426 /*
427 * Do we have libpaper?
428 */
429
430 /* #undef HAVE_LIBPAPER */
431
432
433 /*
434 * Do we have DNS Service Discovery (aka Bonjour) support?
435 */
436
437 #define HAVE_DNSSD 1
438
439
440 /*
441 * Do we have mDNSResponder for DNS-SD?
442 */
443
444 #define HAVE_MDNSRESPONDER 1
445
446
447 /*
448 * Do we have Avahi for DNS-SD?
449 */
450
451 /* #undef HAVE_AVAHI */
452
453
454 /*
455 * Do we have <sys/ioctl.h>?
456 */
457
458 /* #undef HAVE_SYS_IOCTL_H */
459
460
461 /*
462 * Does the "stat" structure contain the "st_gen" member?
463 */
464
465 /* #undef HAVE_ST_GEN */
466
467
468 /*
469 * Does the "tm" structure contain the "tm_gmtoff" member?
470 */
471
472 /* #undef HAVE_TM_GMTOFF */
473
474
475 /*
476 * Do we have the timegm function?
477 */
478
479 /* #undef HAVE_TIMEGM */
480
481
482 /*
483 * Do we have rresvport_af()?
484 */
485
486 /* #undef HAVE_RRESVPORT_AF */
487
488
489 /*
490 * Do we have getaddrinfo()?
491 */
492
493 #define HAVE_GETADDRINFO 1
494
495
496 /*
497 * Do we have getnameinfo()?
498 */
499
500 #define HAVE_GETNAMEINFO 1
501
502
503 /*
504 * Do we have getifaddrs()?
505 */
506
507 /* #undef HAVE_GETIFADDRS */
508
509
510 /*
511 * Do we have hstrerror()?
512 */
513
514 /* #undef HAVE_HSTRERROR */
515
516
517 /*
518 * Do we have res_init()?
519 */
520
521 /* #undef HAVE_RES_INIT */
522
523
524 /*
525 * Do we have <resolv.h>
526 */
527
528 /* #undef HAVE_RESOLV_H */
529
530
531 /*
532 * Do we have the <sys/sockio.h> header file?
533 */
534
535 /* #undef HAVE_SYS_SOCKIO_H */
536
537
538 /*
539 * Does the sockaddr structure contain an sa_len parameter?
540 */
541
542 /* #undef HAVE_STRUCT_SOCKADDR_SA_LEN */
543
544
545 /*
546 * Do we have pthread support?
547 */
548
549 /* #undef HAVE_PTHREAD_H */
550
551
552 /*
553 * Do we have on-demand support (launchd/systemd/upstart)?
554 */
555
556 /* #undef HAVE_ONDEMAND */
557
558
559 /*
560 * Do we have launchd support?
561 */
562
563 /* #undef HAVE_LAUNCH_H */
564 /* #undef HAVE_LAUNCHD */
565
566
567 /*
568 * Do we have systemd support?
569 */
570
571 /* #undef HAVE_SYSTEMD */
572
573
574 /*
575 * Do we have upstart support?
576 */
577
578 /* #undef HAVE_UPSTART */
579
580
581 /*
582 * Do we have CoreFoundation public headers?
583 */
584
585 /* #undef HAVE_COREFOUNDATION_H */
586
587
588 /*
589 * Do we have ApplicationServices public headers?
590 */
591
592 /* #undef HAVE_APPLICATIONSERVICES_H */
593
594
595 /*
596 * Do we have the SCDynamicStoreCopyComputerName function?
597 */
598
599 /* #undef HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME */
600
601
602 /*
603 * Do we have the getgrouplist() function?
604 */
605
606 #undef HAVE_GETGROUPLIST
607
608
609 /*
610 * Do we have macOS 10.4's mbr_XXX functions?
611 */
612
613 /* #undef HAVE_MEMBERSHIP_H */
614 /* #undef HAVE_MBR_UID_TO_UUID */
615
616
617 /*
618 * Do we have Darwin's notify_post header and function?
619 */
620
621 /* #undef HAVE_NOTIFY_H */
622 /* #undef HAVE_NOTIFY_POST */
623
624
625 /*
626 * Do we have DBUS?
627 */
628
629 /* #undef HAVE_DBUS */
630 /* #undef HAVE_DBUS_MESSAGE_ITER_INIT_APPEND */
631 /* #undef HAVE_DBUS_THREADS_INIT */
632
633
634 /*
635 * Do we have the GSSAPI support library (for Kerberos support)?
636 */
637
638 /* #undef HAVE_GSS_ACQUIRE_CRED_EX_F */
639 /* #undef HAVE_GSS_C_NT_HOSTBASED_SERVICE */
640 /* #undef HAVE_GSS_GSSAPI_H */
641 /* #undef HAVE_GSS_GSSAPI_SPI_H */
642 /* #undef HAVE_GSSAPI */
643 /* #undef HAVE_GSSAPI_GSSAPI_H */
644 /* #undef HAVE_GSSAPI_H */
645
646
647 /*
648 * Default GSS service name...
649 */
650
651 #define CUPS_DEFAULT_GSSSERVICENAME "host"
652
653
654 /*
655 * Select/poll interfaces...
656 */
657
658 /* #undef HAVE_POLL */
659 /* #undef HAVE_EPOLL */
660 /* #undef HAVE_KQUEUE */
661
662
663 /*
664 * Do we have the <dlfcn.h> header?
665 */
666
667 /* #undef HAVE_DLFCN_H */
668
669
670 /*
671 * Do we have <sys/param.h>?
672 */
673
674 /* #undef HAVE_SYS_PARAM_H */
675
676
677 /*
678 * Do we have <sys/ucred.h>?
679 */
680
681 /* #undef HAVE_SYS_UCRED_H */
682
683
684 /*
685 * Do we have removefile()?
686 */
687
688 /* #undef HAVE_REMOVEFILE */
689
690
691 /*
692 * Do we have <sandbox.h>?
693 */
694
695 /* #undef HAVE_SANDBOX_H */
696
697
698 /*
699 * Which random number generator function to use...
700 */
701
702 /* #undef HAVE_ARC4RANDOM */
703 /* #undef HAVE_RANDOM */
704 /* #undef HAVE_LRAND48 */
705
706 #ifdef HAVE_ARC4RANDOM
707 # define CUPS_RAND() arc4random()
708 # define CUPS_SRAND(v)
709 #elif defined(HAVE_RANDOM)
710 # define CUPS_RAND() random()
711 # define CUPS_SRAND(v) srandom(v)
712 #elif defined(HAVE_LRAND48)
713 # define CUPS_RAND() lrand48()
714 # define CUPS_SRAND(v) srand48(v)
715 #else
716 # define CUPS_RAND() rand()
717 # define CUPS_SRAND(v) srand(v)
718 #endif /* HAVE_ARC4RANDOM */
719
720
721 /*
722 * Do we have libusb?
723 */
724
725 /* #undef HAVE_LIBUSB */
726
727
728 /*
729 * Do we have libwrap and tcpd.h?
730 */
731
732 /* #undef HAVE_TCPD_H */
733
734
735 /*
736 * Do we have <iconv.h>?
737 */
738
739 /* #undef HAVE_ICONV_H */
740
741
742 /*
743 * Do we have statfs or statvfs and one of the corresponding headers?
744 */
745
746 /* #undef HAVE_STATFS */
747 /* #undef HAVE_STATVFS */
748 /* #undef HAVE_SYS_MOUNT_H */
749 /* #undef HAVE_SYS_STATFS_H */
750 /* #undef HAVE_SYS_STATVFS_H */
751 /* #undef HAVE_SYS_VFS_H */
752
753
754 /*
755 * Location of macOS localization bundle, if any.
756 */
757
758 /* #undef CUPS_BUNDLEDIR */
759
760
761 /*
762 * Do we have XPC?
763 */
764
765 /* #undef HAVE_XPC */
766
767
768 /*
769 * Do we have the C99 abs() function?
770 */
771
772 /* #undef HAVE_ABS */
773 #if !defined(HAVE_ABS) && !defined(abs)
774 # if defined(__GNUC__) || __STDC_VERSION__ >= 199901L
775 # define abs(x) _cups_abs(x)
_cups_abs(int i)776 static inline int _cups_abs(int i) { return (i < 0 ? -i : i); }
777 # elif defined(_MSC_VER)
778 # define abs(x) _cups_abs(x)
_cups_abs(int i)779 static __inline int _cups_abs(int i) { return (i < 0 ? -i : i); }
780 # else
781 # define abs(x) ((x) < 0 ? -(x) : (x))
782 # endif /* __GNUC__ || __STDC_VERSION__ */
783 #endif /* !HAVE_ABS && !abs */
784
785 #endif /* !_CUPS_CONFIG_H_ */
786