1 /*
2  * cups - Python bindings for CUPS
3  * Copyright (C) 2002-2020  Tim Waugh <twaugh@redhat.com>
4  * Authors: Tim Waugh <twaugh@redhat.com>
5  *          Zdenek Dohnal <zdohnal@redhat.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20  */
21 
22 #ifndef HAVE_CUPSCONNECTION_H
23 #define HAVE_CUPSCONNECTION_H
24 
25 #include <Python.h>
26 #include <cups/http.h>
27 
28 #include "cupsmodule.h"
29 
30 extern PyMethodDef Connection_methods[];
31 extern PyTypeObject cups_ConnectionType;
32 extern PyTypeObject cups_DestType;
33 
34 typedef struct
35 {
36   PyObject_HEAD
37   http_t *http;
38   char *host; /* for repr */
39   char *cb_password;
40   PyThreadState *tstate;
41 } Connection;
42 
43 typedef struct
44 {
45   PyObject_HEAD
46   int is_default;
47   char *destname;
48   char *instance;
49 
50   // Options
51   int num_options;
52   char **name;
53   char **value;
54 } Dest;
55 
56 extern PyObject *HTTPError;
57 extern PyObject *IPPError;
58 
59 void Connection_begin_allow_threads (void *connection);
60 void Connection_end_allow_threads (void *connection);
61 
62 const char *password_callback_newstyle (const char *prompt,
63 					http_t *http,
64 					const char *method,
65 					const char *resource,
66 					void *user_data);
67 const char *password_callback_oldstyle (const char *prompt,
68 					http_t *http,
69 					const char *method,
70 					const char *resource,
71 					void *user_data);
72 int cups_dest_cb (void *user_data,
73 		  unsigned flags,
74 		  cups_dest_t *dest);
75 
76 void set_ipp_error (ipp_status_t status,
77 		    const char *message);
78 #endif /* HAVE_CUPSCONNECTION_H */
79