]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Implement MONITOR-PRINTER-STATE parsing and skeleton of thread code.
authorMichael R Sweet <michael.r.sweet@gmail.com>
Wed, 31 Mar 2021 14:38:44 +0000 (10:38 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Wed, 31 Mar 2021 14:38:44 +0000 (10:38 -0400)
config-scripts/cups-threads.m4
configure
tools/ipptool.c
xcode/CUPS.xcodeproj/project.pbxproj

index ee308ea2bc8caf57550ee8c40489b072871dabed..98933a9577d24c6b2d8ba5750fd3c17656a9dfc2 100644 (file)
@@ -8,45 +8,44 @@ dnl
 dnl Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
 dnl
 
-AC_ARG_ENABLE([threads], AS_HELP_STRING([--disable-threads], [disable multi-threading support]))
-
 have_pthread="no"
 PTHREAD_FLAGS=""
+AC_SUBST([PTHREAD_FLAGS])
 
-AS_IF([test "x$enable_threads" != xno], [
-    AC_CHECK_HEADER([pthread.h], [
-        AC_DEFINE([HAVE_PTHREAD_H], [1], [Do we have the <pthread.h> header?])
-    ])
+AC_CHECK_HEADER([pthread.h], [
+    AC_DEFINE([HAVE_PTHREAD_H], [1], [Do we have the <pthread.h> header?])
+])
 
-    AS_IF([test x$ac_cv_header_pthread_h = xyes], [
-       dnl Check various threading options for the platforms we support
-       for flag in -lpthreads -lpthread -pthread; do
-           AC_MSG_CHECKING([for pthread_create using $flag])
-           SAVELIBS="$LIBS"
-           LIBS="$flag $LIBS"
-           AC_LINK_IFELSE([
-               AC_LANG_PROGRAM([[#include <pthread.h>]], [[
-                   pthread_create(0, 0, 0, 0);
-               ]])
-           ], [
-               have_pthread="yes"
-           ], [
-               LIBS="$SAVELIBS"
-           ])
-           AC_MSG_RESULT([$have_pthread])
+AS_IF([test x$ac_cv_header_pthread_h = xyes], [
+    dnl Check various threading options for the platforms we support
+    for flag in -lpthreads -lpthread -pthread; do
+       AC_MSG_CHECKING([for pthread_create using $flag])
+       SAVELIBS="$LIBS"
+       LIBS="$flag $LIBS"
+       AC_LINK_IFELSE([
+           AC_LANG_PROGRAM([[#include <pthread.h>]], [[
+               pthread_create(0, 0, 0, 0);
+           ]])
+       ], [
+           have_pthread="yes"
+       ], [
+           LIBS="$SAVELIBS"
+       ])
+       AC_MSG_RESULT([$have_pthread])
 
-           AS_IF([test $have_pthread = yes], [
-               PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
+       AS_IF([test $have_thread = yes], [
+           PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
 
-               # Solaris requires -D_POSIX_PTHREAD_SEMANTICS to be POSIX-
-               # compliant... :(
-               AS_IF([test $host_os_name = sunos], [
-                   PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
-               ])
-               break
+           # Solaris requires -D_POSIX_PTHREAD_SEMANTICS to be POSIX-
+           # compliant... :(
+           AS_IF([test $host_os_name = sunos], [
+               PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
            ])
-       done
-    ])
+           break
+       ])
+    done
 ])
 
-AC_SUBST([PTHREAD_FLAGS])
+AS_IF([test $have_pthread = no], [
+    AC_MSG_ERROR([CUPS requires threading support.])
+])
index 6eead76e5c49781d2d41d1270d94a67a7fb6232b..fe89d47c7d730b5db8afc8d81cbce407a473c32e 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,11 +1,12 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.70 for CUPS 2.4.0.
+# Generated by GNU Autoconf 2.71 for CUPS 2.4.0.
 #
 # Report bugs to <https://github.com/openprinting/cups/issues>.
 #
 #
-# Copyright (C) 1992-1996, 1998-2017, 2020 Free Software Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation,
+# Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
@@ -651,6 +652,7 @@ ac_subst_vars='LTLIBOBJS
 LIBOBJS
 UNINSTALL_LANGUAGES
 INSTALL_LANGUAGES
+SYSTEMD_WANTED_BY
 CUPS_WEBIF
 DEFAULT_IPP_PORT
 CUPS_SNMP_COMMUNITY
@@ -895,7 +897,6 @@ enable_sanitizer
 with_domainsocket
 enable_gssapi
 with_gssservicename
-enable_threads
 with_tls
 enable_pam
 with_pam_module
@@ -1596,7 +1597,6 @@ Optional Features:
   --enable-relro          build with the relro option
   --enable-sanitizer      build with AddressSanitizer
   --enable-gssapi         enable (deprecated) GSSAPI/Kerberos support
-  --disable-threads       disable multi-threading support
   --disable-pam           disable PAM support
   --disable-largefile     omit support for large files
   --enable-snapped-cupsd  enable support for packaging CUPS in a Snap
@@ -1763,9 +1763,9 @@ test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
 CUPS configure 2.4.0
-generated by GNU Autoconf 2.70
+generated by GNU Autoconf 2.71
 
-Copyright (C) 2020 Free Software Foundation, Inc.
+Copyright (C) 2021 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -2118,7 +2118,7 @@ This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by CUPS $as_me 2.4.0, which was
-generated by GNU Autoconf 2.70.  Invocation command line was
+generated by GNU Autoconf 2.71.  Invocation command line was
 
   $ $0$ac_configure_args_raw
 
@@ -4173,7 +4173,10 @@ else
     CFLAGS=
   fi
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5
+ac_prog_cc_stdc=no
+if test x$ac_prog_cc_stdc = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5
 printf %s "checking for $CC option to enable C11 features... " >&6; }
 if test ${ac_cv_prog_cc_c11+y}
 then :
@@ -4197,28 +4200,28 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam
 done
 rm -f conftest.$ac_ext
 CC=$ac_save_CC
-
 fi
-# AC_CACHE_VAL
-ac_prog_cc_stdc_options=
-case "x$ac_cv_prog_cc_c11" in #(
-  x) :
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-printf "%s\n" "none needed" >&6; } ;; #(
-  xno) :
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-printf "%s\n" "unsupported" >&6; } ;; #(
-  *) :
-    ac_prog_cc_stdc_options=" $ac_cv_prog_cc_c11"
-    CC="$CC$ac_prog_cc_stdc_options"
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5
-printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c11" != xno
+
+if test "x$ac_cv_prog_cc_c11" = xno
 then :
-  ac_prog_cc_stdc=c11
-                ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
+else $as_nop
+  if test "x$ac_cv_prog_cc_c11" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
 else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5
+printf "%s\n" "$ac_cv_prog_cc_c11" >&6; }
+     CC="$CC $ac_cv_prog_cc_c11"
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11
+  ac_prog_cc_stdc=c11
+fi
+fi
+if test x$ac_prog_cc_stdc = xno
+then :
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5
 printf %s "checking for $CC option to enable C99 features... " >&6; }
 if test ${ac_cv_prog_cc_c99+y}
@@ -4229,9 +4232,9 @@ else $as_nop
 ac_save_CC=$CC
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-$ac_c_conftest_c89_program
+$ac_c_conftest_c99_program
 _ACEOF
-for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x -qlanglvl=extc99
+for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99=
 do
   CC="$ac_save_CC $ac_arg"
   if ac_fn_c_try_compile "$LINENO"
@@ -4243,28 +4246,28 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam
 done
 rm -f conftest.$ac_ext
 CC=$ac_save_CC
-
 fi
-# AC_CACHE_VAL
-ac_prog_cc_stdc_options=
-case "x$ac_cv_prog_cc_c99" in #(
-  x) :
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-printf "%s\n" "none needed" >&6; } ;; #(
-  xno) :
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-printf "%s\n" "unsupported" >&6; } ;; #(
-  *) :
-    ac_prog_cc_stdc_options=" $ac_cv_prog_cc_c99"
-    CC="$CC$ac_prog_cc_stdc_options"
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
-printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c99" != xno
+
+if test "x$ac_cv_prog_cc_c99" = xno
 then :
-  ac_prog_cc_stdc=c99
-                   ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
 else $as_nop
+  if test "x$ac_cv_prog_cc_c99" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
+printf "%s\n" "$ac_cv_prog_cc_c99" >&6; }
+     CC="$CC $ac_cv_prog_cc_c99"
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99
+  ac_prog_cc_stdc=c99
+fi
+fi
+if test x$ac_prog_cc_stdc = xno
+then :
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5
 printf %s "checking for $CC option to enable C89 features... " >&6; }
 if test ${ac_cv_prog_cc_c89+y}
@@ -4277,8 +4280,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $ac_c_conftest_c89_program
 _ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 do
   CC="$ac_save_CC $ac_arg"
   if ac_fn_c_try_compile "$LINENO"
@@ -4290,34 +4292,25 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam
 done
 rm -f conftest.$ac_ext
 CC=$ac_save_CC
-
 fi
-# AC_CACHE_VAL
-ac_prog_cc_stdc_options=
-case "x$ac_cv_prog_cc_c89" in #(
-  x) :
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-printf "%s\n" "none needed" >&6; } ;; #(
-  xno) :
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-printf "%s\n" "unsupported" >&6; } ;; #(
-  *) :
-    ac_prog_cc_stdc_options=" $ac_cv_prog_cc_c89"
-    CC="$CC$ac_prog_cc_stdc_options"
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
-printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c89" != xno
+
+if test "x$ac_cv_prog_cc_c89" = xno
 then :
-  ac_prog_cc_stdc=c89
-                      ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
+else $as_nop
+  if test "x$ac_cv_prog_cc_c89" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
 else $as_nop
-  ac_prog_cc_stdc=no
-                      ac_cv_prog_cc_stdc=no
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+printf "%s\n" "$ac_cv_prog_cc_c89" >&6; }
+     CC="$CC $ac_cv_prog_cc_c89"
 fi
-
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89
+  ac_prog_cc_stdc=c89
 fi
-
 fi
 
 ac_ext=c
@@ -4733,19 +4726,22 @@ else
     CXXFLAGS=
   fi
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
+ac_prog_cxx_stdcxx=no
+if test x$ac_prog_cxx_stdcxx = xno
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
 printf %s "checking for $CXX option to enable C++11 features... " >&6; }
-if test ${ac_cv_prog_cxx_cxx11+y}
+if test ${ac_cv_prog_cxx_11+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_cv_prog_cxx_cxx11=no
+  ac_cv_prog_cxx_11=no
 ac_save_CXX=$CXX
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $ac_cxx_conftest_cxx11_program
 _ACEOF
-for ac_arg in '' -std=gnu++11 -std=c++11 -std=gnu++0x -std=c++0x -qlanglvl=extended0x -AA
+for ac_arg in '' -std=gnu++11 -std=gnu++0x -std=c++11 -std=c++0x -qlanglvl=extended0x -AA
 do
   CXX="$ac_save_CXX $ac_arg"
   if ac_fn_cxx_try_compile "$LINENO"
@@ -4757,36 +4753,35 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam
 done
 rm -f conftest.$ac_ext
 CXX=$ac_save_CXX
-
 fi
-# AC_CACHE_VAL
-ac_prog_cxx_stdcxx_options=
-case "x$ac_cv_prog_cxx_cxx11" in #(
-  x) :
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-printf "%s\n" "none needed" >&6; } ;; #(
-  xno) :
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-printf "%s\n" "unsupported" >&6; } ;; #(
-  *) :
-    ac_prog_cxx_stdcxx_options=" $ac_cv_prog_cxx_cxx11"
-    CXX=$CXX$ac_prog_cxx_stdcxx_options
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx11" >&5
-printf "%s\n" "$ac_cv_prog_cxx_cxx11" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cxx_cxx11" != xno
+
+if test "x$ac_cv_prog_cxx_cxx11" = xno
 then :
-  ac_prog_cxx_stdcxx=cxx11
-                   ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11
-                   ac_cv_prog_cxx_cxx98=$ac_cv_prog_cxx_cxx11
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
 else $as_nop
+  if test "x$ac_cv_prog_cxx_cxx11" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx11" >&5
+printf "%s\n" "$ac_cv_prog_cxx_cxx11" >&6; }
+     CXX="$CXX $ac_cv_prog_cxx_cxx11"
+fi
+  ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11
+  ac_prog_cxx_stdcxx=cxx11
+fi
+fi
+if test x$ac_prog_cxx_stdcxx = xno
+then :
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5
 printf %s "checking for $CXX option to enable C++98 features... " >&6; }
-if test ${ac_cv_prog_cxx_cxx98+y}
+if test ${ac_cv_prog_cxx_98+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_cv_prog_cxx_cxx98=no
+  ac_cv_prog_cxx_98=no
 ac_save_CXX=$CXX
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -4804,32 +4799,25 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam
 done
 rm -f conftest.$ac_ext
 CXX=$ac_save_CXX
-
 fi
-# AC_CACHE_VAL
-ac_prog_cxx_stdcxx_options=
-case "x$ac_cv_prog_cxx_cxx98" in #(
-  x) :
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-printf "%s\n" "none needed" >&6; } ;; #(
-  xno) :
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-printf "%s\n" "unsupported" >&6; } ;; #(
-  *) :
-    ac_prog_cxx_stdcxx_options=" $ac_cv_prog_cxx_cxx98"
-    CXX=$CXX$ac_prog_cxx_stdcxx_options
-    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx98" >&5
-printf "%s\n" "$ac_cv_prog_cxx_cxx98" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cxx_cxx98" != xno
+
+if test "x$ac_cv_prog_cxx_cxx98" = xno
 then :
-  ac_prog_cxx_stdcxx=cxx98
-                       ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf "%s\n" "unsupported" >&6; }
 else $as_nop
-  ac_prog_cxx_stdcxx=no
-                       ac_cv_prog_cxx_stdcxx=no
+  if test "x$ac_cv_prog_cxx_cxx98" = x
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf "%s\n" "none needed" >&6; }
+else $as_nop
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx98" >&5
+printf "%s\n" "$ac_cv_prog_cxx_cxx98" >&6; }
+     CXX="$CXX $ac_cv_prog_cxx_cxx98"
+fi
+  ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98
+  ac_prog_cxx_stdcxx=cxx98
 fi
-
 fi
 
 ac_ext=c
@@ -9564,20 +9552,11 @@ printf "%s\n" "#define CUPS_DEFAULT_GSSSERVICENAME \"$CUPS_DEFAULT_GSSSERVICENAM
 
 
 
-# Check whether --enable-threads was given.
-if test ${enable_threads+y}
-then :
-  enableval=$enable_threads;
-fi
-
-
 have_pthread="no"
 PTHREAD_FLAGS=""
 
-if test "x$enable_threads" != xno
-then :
 
-    ac_fn_c_check_header_compile "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
+ac_fn_c_check_header_compile "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
 if test "x$ac_cv_header_pthread_h" = xyes
 then :
 
@@ -9588,23 +9567,23 @@ printf "%s\n" "#define HAVE_PTHREAD_H 1" >>confdefs.h
 fi
 
 
-    if test x$ac_cv_header_pthread_h = xyes
+if test x$ac_cv_header_pthread_h = xyes
 then :
 
-               for flag in -lpthreads -lpthread -pthread; do
-           { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_create using $flag" >&5
+        for flag in -lpthreads -lpthread -pthread; do
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_create using $flag" >&5
 printf %s "checking for pthread_create using $flag... " >&6; }
-           SAVELIBS="$LIBS"
-           LIBS="$flag $LIBS"
-           cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+       SAVELIBS="$LIBS"
+       LIBS="$flag $LIBS"
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-               #include <pthread.h>
+           #include <pthread.h>
 int
 main (void)
 {
 
-                   pthread_create(0, 0, 0, 0);
+               pthread_create(0, 0, 0, 0);
 
   ;
   return 0;
@@ -9614,41 +9593,44 @@ _ACEOF
 if ac_fn_c_try_link "$LINENO"
 then :
 
-               have_pthread="yes"
+           have_pthread="yes"
 
 else $as_nop
 
-               LIBS="$SAVELIBS"
+           LIBS="$SAVELIBS"
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
-           { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_pthread" >&5
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_pthread" >&5
 printf "%s\n" "$have_pthread" >&6; }
 
-           if test $have_pthread = yes
+       if test $have_thread = yes
 then :
 
-               PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
+           PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
 
-               # Solaris requires -D_POSIX_PTHREAD_SEMANTICS to be POSIX-
-               # compliant... :(
-               if test $host_os_name = sunos
+           # Solaris requires -D_POSIX_PTHREAD_SEMANTICS to be POSIX-
+           # compliant... :(
+           if test $host_os_name = sunos
 then :
 
-                   PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
+               PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
 
 fi
-               break
+           break
 
 fi
-       done
+    done
 
 fi
 
-fi
+if test $have_pthread = no
+then :
 
+    as_fn_error $? "CUPS requires threading support." "$LINENO" 5
 
+fi
 
 
 
@@ -11558,6 +11540,8 @@ then :
 fi
 
 
+SYSTEMD_WANTED_BY="printers.target"
+
 LANGUAGES="$(ls -1 locale/cups_*.po 2>/dev/null | sed -e '1,$s/locale\/cups_//' -e '1,$s/\.po//' | tr '\n' ' ')"
 
 
@@ -12376,6 +12360,13 @@ esac
 printf "%s\n" "#define CUPS_DEFAULT_WEBIF $CUPS_DEFAULT_WEBIF" >>confdefs.h
 
 
+if test $CUPS_WEBIF = Yes || test $CUPS_BROWSING = Yes
+then :
+
+  SYSTEMD_WANTED_BY="$SYSTEMD_WANTED_BY multi-user.target"
+fi
+
+
 
 INSTALL_LANGUAGES=""
 UNINSTALL_LANGUAGES=""
@@ -12914,7 +12905,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # values after options handling.
 ac_log="
 This file was extended by CUPS $as_me 2.4.0, which was
-generated by GNU Autoconf 2.70.  Invocation command line was
+generated by GNU Autoconf 2.71.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -12979,10 +12970,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
 CUPS config.status 2.4.0
-configured by $0, generated by GNU Autoconf 2.70,
+configured by $0, generated by GNU Autoconf 2.71,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2020 Free Software Foundation, Inc.
+Copyright (C) 2021 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
index f6085add25cd199cf281097b56f4348c984b204a..12eb71bb419f3526f673a090d452a8ab3bbe983a 100644 (file)
@@ -2,8 +2,8 @@
  * ipptool command for CUPS.
  *
  * Copyright Â© 2021 by OpenPrinting.
- * Copyright @ 2020 by The Printer Working Group.
- * Copyright Â©Â 2007-2019 by Apple Inc.
+ * Copyright Â© 2020 by The Printer Working Group.
+ * Copyright Â©Â 2007-2021 by Apple Inc.
  * Copyright Â©Â 1997-2007 by Easy Software Products.
  *
  * Licensed under Apache License v2.0.  See the file "LICENSE" for more
@@ -153,6 +153,13 @@ typedef struct ipptool_test_s              /**** Test Data ****/
   char         test_id[1024];          /* Test identifier */
   ipptool_transfer_t transfer;         /* To chunk or not to chunk */
   int          version;                /* IPP version number to use */
+  _cups_thread_t monitor_thread;       /* Monitoring thread ID */
+  int          monitor_done;           /* Set to 1 to stop monitor thread */
+  char         *monitor_uri;           /* MONITOR-PRINTER-STATE URI */
+  useconds_t   monitor_delay,          /* MONITOR-PRINTER-STATE DELAY value, if any */
+               monitor_interval;       /* MONITOR-PRINTER-STATE DELAY interval */
+  int          num_monitor_expects;    /* Number MONITOR-PRINTER-STATE EXPECTs */
+  ipptool_expect_t monitor_expects[10];        /* MONITOR-PRINTER-STATE EXPECTs */
 } ipptool_test_t;
 
 
@@ -170,6 +177,7 @@ static int  Cancel = 0;             /* Cancel test? */
 static void    add_stringf(cups_array_t *a, const char *s, ...) _CUPS_FORMAT(2, 3);
 static int      compare_uris(const char *a, const char *b);
 static void    copy_hex_string(char *buffer, unsigned char *data, int datalen, size_t bufsize);
+static void    *do_monitor_test(ipptool_test_t *data);
 static int     do_test(_ipp_file_t *f, _ipp_vars_t *vars, ipptool_test_t *data);
 static int     do_tests(const char *testfile, _ipp_vars_t *vars, ipptool_test_t *data);
 static int     error_cb(_ipp_file_t *f, ipptool_test_t *data, const char *error);
@@ -178,6 +186,7 @@ static char *get_filename(const char *testfile, char *dst, const char *src, size
 static const char *get_string(ipp_attribute_t *attr, int element, int flags, char *buffer, size_t bufsize);
 static void    init_data(ipptool_test_t *data);
 static char    *iso_date(const ipp_uchar_t *date);
+static int     parse_monitor_printer_state(_ipp_file_t *f, _ipp_vars_t *vars, ipptool_test_t *data);
 static void    pause_message(const char *message);
 static void    print_attr(cups_file_t *outfile, ipptool_output_t output, ipp_attribute_t *attr, ipp_tag_t *group);
 static void    print_csv(ipptool_test_t *data, ipp_t *ipp, ipp_attribute_t *attr, int num_displayed, char **displayed, size_t *widths);
@@ -877,13 +886,136 @@ copy_hex_string(char          *buffer,   /* I - String buffer */
 }
 
 
+/*
+ * 'do_monitor_printer_state()' - Do the MONITOR-PRINTER-STATE tests in the background.
+ */
+
+static void *                          // O - Thread exit status
+do_monitor_printer_state(
+    ipptool_test_t *data)              // I - Test data
+{
+  char         scheme[32],             // URI scheme
+               userpass[32],           // URI username:password
+               host[256],              // URI hostname/IP address
+               resource[256];          // URI resource path
+  int          port;                   // URI port number
+  http_encryption_t encryption;                // Encryption to use
+  http_t       *http;                  // Connection to printer
+  ipp_t                *request,               // IPP request
+               *response;              // IPP response
+  ipp_attribute_t *attr;               // Current attribute
+  ipptool_expect_t *expect;            // Current EXPECT test
+  static const char *pattrs[] =                // List of attributes we care about
+  {
+    "marker-change-time",              // "marker-xxx" are a CUPS/AirPrint extension
+    "marker-colors",
+    "marker-high-levels",
+    "marker-levels",
+    "marker-low-levels",
+    "marker-message",
+    "marker-names",
+    "marker-types",
+    "printer-alert",
+    "printer-alert-description",
+    "printer-config-change-date-time",
+    "printer-config-change-time",
+    "printer-config-changes",
+    "printer-current-time",
+    "printer-finisher",
+    "printer-finisher-description",
+    "printer-finisher-supplies",
+    "printer-finisher-supplies-description",
+    "printer-impressions-completed",
+    "printer-impressions-completed-col",
+    "printer-input-tray",
+    "printer-is-accepting-jobs",
+    "printer-media-sheets-completed",
+    "printer-media-sheets-completed-col",
+    "printer-message-date-time",
+    "printer-message-from-operator",
+    "printer-message-time",
+    "printer-output-tray",
+    "printer-pages-completed",
+    "printer-pages-completed-col",
+    "printer-state",
+    "printer-state-change-date-time",
+    "printer-state-change-time",
+    "printer-state-reasons",
+    "printer-supply",
+    "printer-supply-description",
+    "printer-up-time",
+    "queued-job-count"
+  };
+
+
+  // Connect to the printer...
+  if (httpSeparateURI(HTTP_URI_CODING_ALL, data->monitor_uri, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
+  {
+    print_fatal_error(data, "Bad printer URI \"%s\".", data->monitor_uri);
+    return (NULL);
+  }
+
+  if (!_cups_strcasecmp(scheme, "https") || !_cups_strcasecmp(scheme, "ipps") || port == 443)
+    encryption = HTTP_ENCRYPTION_ALWAYS;
+  else
+    encryption = data->encryption;
+
+  if ((http = httpConnect2(host, port, NULL, data->family, encryption, 1, 30000, NULL)) == NULL)
+  {
+    print_fatal_error(data, "Unable to connect to \"%s\" on port %d - %s", host, port, cupsLastErrorString());
+    return (0);
+  }
+
+#ifdef HAVE_LIBZ
+  httpSetDefaultField(http, HTTP_FIELD_ACCEPT_ENCODING, "deflate, gzip, identity");
+#else
+  httpSetDefaultField(http, HTTP_FIELD_ACCEPT_ENCODING, "identity");
+#endif /* HAVE_LIBZ */
+
+  if (data->timeout > 0.0)
+    httpSetTimeout(http, data->timeout, timeout_cb, NULL);
+
+  // Wait for the initial delay as needed...
+  if (data->monitor_delay)
+    usleep(data->monitor_delay);
+
+  // Create a query request that we'll reuse...
+  request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
+  ippSetVersion(request, data->version / 10, data->version % 10);
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, data->monitor_uri);
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
+  ippAddStrings(request, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_KEYWORD), "requested-attributes", (int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
+
+  // Loop until we need to stop...
+  while (!data->monitor_done && !Cancel)
+  {
+    // Poll the printer state...
+
+
+
+
+    // Sleep between requests...
+    if (data->monitor_done || Cancel)
+      break;
+
+    usleep(data->monitor_interval);
+  }
+
+  // Close the connection to the printer and return...
+  httpClose(http);
+  ippDelete(request);
+
+  return (NULL);
+}
+
+
 /*
  * 'do_test()' - Do a single test from the test file.
  */
 
 static int                             /* O - 1 on success, 0 on failure */
-do_test(_ipp_file_t      *f,           /* I - IPP data file */
-        _ipp_vars_t      *vars,                /* I - IPP variables */
+do_test(_ipp_file_t    *f,             /* I - IPP data file */
+        _ipp_vars_t    *vars,          /* I - IPP variables */
         ipptool_test_t *data)          /* I - Test data */
 
 {
@@ -923,6 +1055,13 @@ do_test(_ipp_file_t      *f,              /* I - IPP data file */
     data->pause[0] = '\0';
   }
 
+ /*
+  * Start the background thread as needed...
+  */
+
+  if (data->monitor_uri)
+    data->monitor_thread = _cupsThreadCreate((_cups_thread_func_t)do_monitor_printer_state, data);
+
  /*
   * Take over control of the attributes in the request...
   */
@@ -1822,6 +1961,12 @@ do_test(_ipp_file_t      *f,             /* I - IPP data file */
 
   skip_error:
 
+  if (data->monitor_thread)
+  {
+    data->monitor_done = 1;
+    _cupsThreadWait(data->monitor_thread);
+  }
+
   if (data->output == IPPTOOL_OUTPUT_PLIST)
     cupsFilePuts(data->outfile, "</dict>\n");
 
@@ -1867,6 +2012,32 @@ do_test(_ipp_file_t      *f,             /* I - IPP data file */
     free(data->displayed[i]);
   data->num_displayed = 0;
 
+  free(data->monitor_uri);
+  data->monitor_uri = NULL;
+
+  for (i = data->num_monitor_expects, expect = data->monitor_expects; i > 0; i --, expect ++)
+  {
+    free(expect->name);
+    if (expect->of_type)
+      free(expect->of_type);
+    if (expect->same_count_as)
+      free(expect->same_count_as);
+    if (expect->if_defined)
+      free(expect->if_defined);
+    if (expect->if_not_defined)
+      free(expect->if_not_defined);
+    if (expect->with_value)
+      free(expect->with_value);
+    if (expect->define_match)
+      free(expect->define_match);
+    if (expect->define_no_match)
+      free(expect->define_no_match);
+    if (expect->define_value)
+      free(expect->define_value);
+  }
+  data->num_monitor_expects = 0;
+
+
   return (data->ignore_errors || data->prev_pass);
 }
 
@@ -1876,9 +2047,9 @@ do_test(_ipp_file_t      *f,              /* I - IPP data file */
  */
 
 static int                             /* O - 1 on success, 0 on failure */
-do_tests(const char       *testfile,   /* I - Test file to use */
-         _ipp_vars_t      *vars,       /* I - Variables */
-         ipptool_test_t *data) /* I - Test data */
+do_tests(const char     *testfile,     /* I - Test file to use */
+         _ipp_vars_t    *vars,         /* I - Variables */
+         ipptool_test_t *data)         /* I - Test data */
 {
   http_encryption_t encryption;                /* Encryption mode */
 
@@ -1887,7 +2058,7 @@ do_tests(const char       *testfile,      /* I - Test file to use */
   * Connect to the printer/server...
   */
 
-  if (!_cups_strcasecmp(vars->scheme, "https") || !_cups_strcasecmp(vars->scheme, "ipps"))
+  if (!_cups_strcasecmp(vars->scheme, "https") || !_cups_strcasecmp(vars->scheme, "ipps") || vars->port == 443)
     encryption = HTTP_ENCRYPTION_ALWAYS;
   else
     encryption = data->encryption;
@@ -2200,6 +2371,410 @@ iso_date(const ipp_uchar_t *date)       /* I - IPP (RFC 1903) date/time value */
 }
 
 
+/*
+ * 'parse_monitor_printer_state()' - Parse the MONITOR-PRINTER-STATE directive.
+ *
+ * MONITOR-PRINTER-STATE [printer-uri] {
+ *     DELAY nnn
+ *     EXPECT attribute-name ...
+ * }
+ */
+
+static int                             /* O - 1 to continue, 0 to stop */
+parse_monitor_printer_state(
+    _ipp_file_t    *f,                 /* I - IPP file data */
+    _ipp_vars_t    *vars,              /* I - IPP variables */
+    ipptool_test_t *data)              /* I - Test data */
+{
+  char token[256],                     /* Token string */
+       name[1024],                     /* Name string */
+       temp[1024],                     /* Temporary string */
+       value[1024],                    /* Value string */
+       *ptr;                           /* Pointer into value */
+
+
+  if (!_ippFileReadToken(f, temp, sizeof(temp)))
+  {
+    print_fatal_error(data, "Missing printer URI on line %d of \"%s\".", f->linenum, f->filename);
+    return (0);
+  }
+
+  if (strcmp(temp, "{"))
+  {
+    // Got a printer URI so copy it...
+    data->monitor_uri = strdup(temp);
+
+    // Then see if we have an opening brace...
+    if (!_ippFileReadToken(f, temp, sizeof(temp)) || strcmp(temp, "{"))
+    {
+      print_fatal_error(data, "Missing opening brace on line %d of \"%s\".", f->linenum, f->filename);
+      return (0);
+    }
+  }
+  else
+  {
+    // Use the default printer URI...
+    data->monitor_uri = strdup(vars->uri);
+  }
+
+  // Loop until we get a closing brace...
+  while (_ippFileReadToken(f, token, sizeof(token)))
+  {
+    if (_cups_strcasecmp(token, "COUNT") &&
+       _cups_strcasecmp(token, "DEFINE-MATCH") &&
+       _cups_strcasecmp(token, "DEFINE-NO-MATCH") &&
+       _cups_strcasecmp(token, "DEFINE-VALUE") &&
+       _cups_strcasecmp(token, "IF-DEFINED") &&
+       _cups_strcasecmp(token, "IF-NOT-DEFINED") &&
+       _cups_strcasecmp(token, "IN-GROUP") &&
+       _cups_strcasecmp(token, "OF-TYPE") &&
+       _cups_strcasecmp(token, "WITH-VALUE"))
+      data->last_expect = NULL;
+
+    if (!strcmp(token, "}"))
+      return (1);
+    else if (!_cups_strcasecmp(token, "EXPECT"))
+    {
+     /*
+      * Expected attributes...
+      */
+
+      if (data->num_monitor_expects >= (int)(sizeof(data->monitor_expects) / sizeof(data->monitor_expects[0])))
+      {
+       print_fatal_error(data, "Too many EXPECT's on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+
+      if (!_ippFileReadToken(f, name, sizeof(name)))
+      {
+       print_fatal_error(data, "Missing EXPECT name on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+
+      data->last_expect = data->monitor_expects + data->num_monitor_expects;
+      data->num_monitor_expects ++;
+
+      memset(data->last_expect, 0, sizeof(ipptool_expect_t));
+      data->last_expect->repeat_limit = 1000;
+
+      if (name[0] == '!')
+      {
+       data->last_expect->not_expect = 1;
+       data->last_expect->name       = strdup(name + 1);
+      }
+      else if (name[0] == '?')
+      {
+       data->last_expect->optional = 1;
+       data->last_expect->name     = strdup(name + 1);
+      }
+      else
+       data->last_expect->name = strdup(name);
+    }
+    else if (!_cups_strcasecmp(token, "COUNT"))
+    {
+      int      count;                  /* Count value */
+
+      if (!_ippFileReadToken(f, temp, sizeof(temp)))
+      {
+       print_fatal_error(data, "Missing COUNT number on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+
+      if ((count = atoi(temp)) <= 0)
+      {
+       print_fatal_error(data, "Bad COUNT \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename);
+       return (0);
+      }
+
+      if (data->last_expect)
+      {
+       data->last_expect->count = count;
+      }
+      else
+      {
+       print_fatal_error(data, "COUNT without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+    }
+    else if (!_cups_strcasecmp(token, "DEFINE-MATCH"))
+    {
+      if (!_ippFileReadToken(f, temp, sizeof(temp)))
+      {
+       print_fatal_error(data, "Missing DEFINE-MATCH variable on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+
+      if (data->last_expect)
+      {
+       data->last_expect->define_match = strdup(temp);
+      }
+      else
+      {
+       print_fatal_error(data, "DEFINE-MATCH without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+    }
+    else if (!_cups_strcasecmp(token, "DEFINE-NO-MATCH"))
+    {
+      if (!_ippFileReadToken(f, temp, sizeof(temp)))
+      {
+       print_fatal_error(data, "Missing DEFINE-NO-MATCH variable on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+
+      if (data->last_expect)
+      {
+       data->last_expect->define_no_match = strdup(temp);
+      }
+      else
+      {
+       print_fatal_error(data, "DEFINE-NO-MATCH without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+    }
+    else if (!_cups_strcasecmp(token, "DEFINE-VALUE"))
+    {
+      if (!_ippFileReadToken(f, temp, sizeof(temp)))
+      {
+       print_fatal_error(data, "Missing DEFINE-VALUE variable on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+
+      if (data->last_expect)
+      {
+       data->last_expect->define_value = strdup(temp);
+      }
+      else
+      {
+       print_fatal_error(data, "DEFINE-VALUE without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+    }
+    else if (!_cups_strcasecmp(token, "DELAY"))
+    {
+     /*
+      * Delay before operation...
+      */
+
+      double dval;                    /* Delay value */
+
+      if (!_ippFileReadToken(f, temp, sizeof(temp)))
+      {
+       print_fatal_error(data, "Missing DELAY value on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+
+      _ippVarsExpand(vars, value, temp, sizeof(value));
+
+      if ((dval = _cupsStrScand(value, &ptr, localeconv())) < 0.0 || (*ptr && *ptr != ','))
+      {
+       print_fatal_error(data, "Bad DELAY value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename);
+       return (0);
+      }
+
+      data->monitor_delay = (useconds_t)(1000000.0 * dval);
+
+      if (*ptr == ',')
+      {
+       if ((dval = _cupsStrScand(ptr + 1, &ptr, localeconv())) <= 0.0 || *ptr)
+       {
+         print_fatal_error(data, "Bad DELAY value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename);
+         return (0);
+       }
+
+       data->monitor_interval = (useconds_t)(1000000.0 * dval);
+      }
+      else
+       data->monitor_interval = data->monitor_delay;
+    }
+    else if (!_cups_strcasecmp(token, "OF-TYPE"))
+    {
+      if (!_ippFileReadToken(f, temp, sizeof(temp)))
+      {
+       print_fatal_error(data, "Missing OF-TYPE value tag(s) on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+
+      if (data->last_expect)
+      {
+       data->last_expect->of_type = strdup(temp);
+      }
+      else
+      {
+       print_fatal_error(data, "OF-TYPE without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+    }
+    else if (!_cups_strcasecmp(token, "IN-GROUP"))
+    {
+      ipp_tag_t        in_group;               /* IN-GROUP value */
+
+      if (!_ippFileReadToken(f, temp, sizeof(temp)))
+      {
+       print_fatal_error(data, "Missing IN-GROUP group tag on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+
+      if ((in_group = ippTagValue(temp)) == IPP_TAG_ZERO || in_group >= IPP_TAG_UNSUPPORTED_VALUE)
+      {
+       print_fatal_error(data, "Bad IN-GROUP group tag \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename);
+       return (0);
+      }
+      else if (data->last_expect)
+      {
+       data->last_expect->in_group = in_group;
+      }
+      else
+      {
+       print_fatal_error(data, "IN-GROUP without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+    }
+    else if (!_cups_strcasecmp(token, "IF-DEFINED"))
+    {
+      if (!_ippFileReadToken(f, temp, sizeof(temp)))
+      {
+       print_fatal_error(data, "Missing IF-DEFINED name on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+
+      if (data->last_expect)
+      {
+       data->last_expect->if_defined = strdup(temp);
+      }
+      else
+      {
+       print_fatal_error(data, "IF-DEFINED without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+    }
+    else if (!_cups_strcasecmp(token, "IF-NOT-DEFINED"))
+    {
+      if (!_ippFileReadToken(f, temp, sizeof(temp)))
+      {
+       print_fatal_error(data, "Missing IF-NOT-DEFINED name on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+
+      if (data->last_expect)
+      {
+       data->last_expect->if_not_defined = strdup(temp);
+      }
+      else
+      {
+       print_fatal_error(data, "IF-NOT-DEFINED without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+    }
+    else if (!_cups_strcasecmp(token, "WITH-VALUE"))
+    {
+      off_t    lastpos;                /* Last file position */
+      int      lastline;               /* Last line number */
+
+      if (!_ippFileReadToken(f, temp, sizeof(temp)))
+      {
+       print_fatal_error(data, "Missing %s value on line %d of \"%s\".", token, f->linenum, f->filename);
+       return (0);
+      }
+
+     /*
+      * Read additional comma-delimited values - needed since legacy test files
+      * will have unquoted WITH-VALUE values with commas...
+      */
+
+      ptr = temp + strlen(temp);
+
+      for (;;)
+      {
+        lastpos  = cupsFileTell(f->fp);
+        lastline = f->linenum;
+        ptr      += strlen(ptr);
+
+       if (!_ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp))))
+         break;
+
+        if (!strcmp(ptr, ","))
+        {
+         /*
+          * Append a value...
+          */
+
+         ptr += strlen(ptr);
+
+         if (!_ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp))))
+           break;
+        }
+        else
+        {
+         /*
+          * Not another value, stop here...
+          */
+
+          cupsFileSeek(f->fp, lastpos);
+          f->linenum = lastline;
+          *ptr = '\0';
+          break;
+       }
+      }
+
+      if (data->last_expect)
+      {
+       /*
+       * Expand any variables in the value and then save it.
+       */
+
+       _ippVarsExpand(vars, value, temp, sizeof(value));
+
+       ptr = value + strlen(value) - 1;
+
+       if (value[0] == '/' && ptr > value && *ptr == '/')
+       {
+        /*
+         * WITH-VALUE is a POSIX extended regular expression.
+         */
+
+         data->last_expect->with_value = calloc(1, (size_t)(ptr - value));
+         data->last_expect->with_flags |= IPPTOOL_WITH_REGEX;
+
+         if (data->last_expect->with_value)
+           memcpy(data->last_expect->with_value, value + 1, (size_t)(ptr - value - 1));
+       }
+       else
+       {
+        /*
+         * WITH-VALUE is a literal value...
+         */
+
+         for (ptr = value; *ptr; ptr ++)
+         {
+           if (*ptr == '\\' && ptr[1])
+           {
+            /*
+             * Remove \ from \foo...
+             */
+
+             _cups_strcpy(ptr, ptr + 1);
+           }
+         }
+
+         data->last_expect->with_value = strdup(value);
+         data->last_expect->with_flags |= IPPTOOL_WITH_LITERAL;
+       }
+      }
+      else
+      {
+       print_fatal_error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename);
+       return (0);
+      }
+    }
+  }
+
+  print_fatal_error(data, "Missing closing brace on line %d of \"%s\".", f->linenum, f->filename);
+
+  return (0);
+}
+
+
 /*
  * 'pause_message()' - Display the message and pause until the user presses a key.
  */
@@ -3012,10 +3587,10 @@ timeout_cb(http_t *http,                /* I - Connection to server */
  */
 
 static int                             /* O - 1 to continue, 0 to stop */
-token_cb(_ipp_file_t      *f,          /* I - IPP file data */
-         _ipp_vars_t      *vars,       /* I - IPP variables */
-         ipptool_test_t *data, /* I - Test data */
-         const char       *token)      /* I - Current token */
+token_cb(_ipp_file_t    *f,            /* I - IPP file data */
+         _ipp_vars_t    *vars,         /* I - IPP variables */
+         ipptool_test_t *data,         /* I - Test data */
+         const char     *token)                /* I - Current token */
 {
   char name[1024],                     /* Name string */
        temp[1024],                     /* Temporary string */
@@ -3073,6 +3648,16 @@ token_cb(_ipp_file_t      *f,            /* I - IPP file data */
     {
       return (do_test(f, vars, data));
     }
+    else if (!strcmp(token, "MONITOR-PRINTER-STATE"))
+    {
+      if (data->monitor_uri)
+      {
+       print_fatal_error(data, "Extra MONITOR-PRINTER-STATE seen on line %d of \"%s\".", f->linenum, f->filename);
+       return (0);
+      }
+
+      return (parse_monitor_printer_state(f, vars, data));
+    }
     else if (!strcmp(token, "COMPRESSION"))
     {
      /*
@@ -4017,6 +4602,12 @@ token_cb(_ipp_file_t      *f,            /* I - IPP file data */
       data->transfer      = data->def_transfer;
       data->version       = data->def_version;
 
+      free(data->monitor_uri);
+      data->monitor_uri         = NULL;
+      data->monitor_delay       = 0;
+      data->monitor_interval    = 5000000;
+      data->num_monitor_expects = 0;
+
       _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL))));
 
       f->attrs     = ippNew();
index a7eaf335282278e0cca2be0b333b2facc347a801..082a9af12fee088e06658b51caa56f13c7ce8ca8 100644 (file)
                278C58E8136B64B000836530 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<absolute>"; };
                279AE6F42395B80F004DD600 /* libpam.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libpam.tbd; path = usr/lib/libpam.tbd; sourceTree = SDKROOT; };
                27A0347B1A8BDB1300650675 /* lpadmin */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lpadmin; sourceTree = BUILT_PRODUCTS_DIR; };
+               27C89C8F2613E7C300A58F43 /* cups-snap.m4 */ = {isa = PBXFileReference; lastKnownFileType = text; name = "cups-snap.m4"; path = "../config-scripts/cups-snap.m4"; sourceTree = "<group>"; };
+               27C89C902613E7C300A58F43 /* cups-tls.m4 */ = {isa = PBXFileReference; lastKnownFileType = text; name = "cups-tls.m4"; path = "../config-scripts/cups-tls.m4"; sourceTree = "<group>"; };
                27D3037D134148CB00F022B1 /* libcups2.def */ = {isa = PBXFileReference; lastKnownFileType = text; name = libcups2.def; path = ../cups/libcups2.def; sourceTree = "<group>"; };
                27F89DA21B3AC43B00E5A4B7 /* testraster.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testraster.c; path = ../cups/testraster.c; sourceTree = "<group>"; };
                720DD6C21358FD5F0064AA82 /* snmp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = snmp; sourceTree = BUILT_PRODUCTS_DIR; };
                72E65BB018DC799B00097E89 /* cups-pam.m4 */ = {isa = PBXFileReference; lastKnownFileType = text; name = "cups-pam.m4"; path = "../config-scripts/cups-pam.m4"; sourceTree = "<group>"; };
                72E65BB118DC799B00097E89 /* cups-poll.m4 */ = {isa = PBXFileReference; lastKnownFileType = text; name = "cups-poll.m4"; path = "../config-scripts/cups-poll.m4"; sourceTree = "<group>"; };
                72E65BB318DC799B00097E89 /* cups-sharedlibs.m4 */ = {isa = PBXFileReference; lastKnownFileType = text; name = "cups-sharedlibs.m4"; path = "../config-scripts/cups-sharedlibs.m4"; sourceTree = "<group>"; };
-               72E65BB418DC799B00097E89 /* cups-ssl.m4 */ = {isa = PBXFileReference; lastKnownFileType = text; name = "cups-ssl.m4"; path = "../config-scripts/cups-ssl.m4"; sourceTree = "<group>"; };
                72E65BB518DC799B00097E89 /* cups-threads.m4 */ = {isa = PBXFileReference; lastKnownFileType = text; name = "cups-threads.m4"; path = "../config-scripts/cups-threads.m4"; sourceTree = "<group>"; };
                72E65BB618DC79CC00097E89 /* cups-config.in */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; name = "cups-config.in"; path = "../cups-config.in"; sourceTree = "<group>"; };
                72E65BB718DC79CC00097E89 /* Makedefs.in */ = {isa = PBXFileReference; lastKnownFileType = text; name = Makedefs.in; path = ../Makedefs.in; sourceTree = "<group>"; };
                                72E65BB018DC799B00097E89 /* cups-pam.m4 */,
                                72E65BB118DC799B00097E89 /* cups-poll.m4 */,
                                72E65BB318DC799B00097E89 /* cups-sharedlibs.m4 */,
-                               72E65BB418DC799B00097E89 /* cups-ssl.m4 */,
+                               27C89C8F2613E7C300A58F43 /* cups-snap.m4 */,
                                72E65BB518DC799B00097E89 /* cups-threads.m4 */,
+                               27C89C902613E7C300A58F43 /* cups-tls.m4 */,
                        );
                        name = "Autoconf Files";
                        sourceTree = "<group>";