#include <cups/cups-private.h>
#include <cups/file-private.h>
#include <cups/ppd-private.h>
#include <limits.h>
#include <time.h>
#include <signal.h>
#include <fcntl.h>
#include <math.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/wait.h>
#ifdef WIN32
# include <direct.h>
#else
# include <unistd.h>
#endif
#include "mime.h"
#if defined(HAVE_CDSASSL)
# include <CoreFoundation/CoreFoundation.h>
#endif
#ifndef HAVE_HSTRERROR
# ifdef hstrerror
# undef hstrerror
# endif
# define hstrerror cups_hstrerror
extern const char *cups_hstrerror(int);
#endif
#ifndef FALSE
# define FALSE 0
# define TRUE (!FALSE)
#endif
#define MAX_ENV 100
#define MAX_USERPASS 33
#define MAX_FILTERS 20
#define MAX_SYSTEM_GROUPS 32
#define DEFAULT_HISTORY INT_MAX
#define DEFAULT_FILES 86400
#define DEFAULT_TIMEOUT 300
#define DEFAULT_KEEPALIVE 30
#ifdef _MAIN_C_
# define VAR
# define VALUE(x) =x
# define VALUE2(x,y) ={x,y}
#else
# define VAR extern
# define VALUE(x)
# define VALUE2(x,y)
#endif
#include "sysman.h"
#include "statbuf.h"
#include "cert.h"
#include "auth.h"
#include "client.h"
#include "policy.h"
#include "printers.h"
#include "classes.h"
#include "job.h"
#include "colorman.h"
#include "conf.h"
#include "banners.h"
#include "dirsvc.h"
#include "network.h"
#include "subscriptions.h"
#define RELOAD_NONE 0
#define RELOAD_ALL 1
#define RELOAD_CUPSD 2
typedef void (*cupsd_selfunc_t)(void *data);
VAR int TestConfigFile VALUE(0);
VAR int MaxFDs VALUE(0);
VAR time_t ReloadTime VALUE(0);
VAR int NeedReload VALUE(RELOAD_ALL),
DoingShutdown VALUE(0);
VAR void *DefaultProfile VALUE(0);
#ifdef HAVE_ONDEMAND
VAR int OnDemand VALUE(0);
#endif
extern void cupsdInitEnv(void);
extern int cupsdLoadEnv(char *envp[], int envmax);
extern void cupsdSetEnv(const char *name, const char *value);
extern void cupsdSetEnvf(const char *name, const char *value, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
extern void cupsdUpdateEnv(void);
extern void cupsdCleanFiles(const char *path, const char *pattern);
extern int cupsdCloseCreatedConfFile(cups_file_t *fp,
const char *filename);
extern void cupsdClosePipe(int *fds);
extern cups_file_t *cupsdCreateConfFile(const char *filename, mode_t mode);
extern cups_file_t *cupsdOpenConfFile(const char *filename);
extern int cupsdOpenPipe(int *fds);
extern int cupsdRemoveFile(const char *filename);
extern int cupsdUnlinkOrRemoveFile(const char *filename);
extern int cupsdAddString(cups_array_t **a, const char *s);
extern void cupsdCheckProcess(void);
extern void cupsdClearString(char **s);
extern void cupsdFreeStrings(cups_array_t **a);
extern void cupsdHoldSignals(void);
extern char *cupsdMakeUUID(const char *name, int number,
char *buffer, size_t bufsize);
extern void cupsdReleaseSignals(void);
extern void cupsdSetString(char **s, const char *v);
extern void cupsdSetStringf(char **s, const char *f, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
extern void *cupsdCreateProfile(int job_id, int allow_networking);
extern void cupsdDestroyProfile(void *profile);
extern int cupsdEndProcess(int pid, int force);
extern const char *cupsdFinishProcess(int pid, char *name, size_t namelen, int *job_id);
extern int cupsdStartProcess(const char *command, char *argv[],
char *envp[], int infd, int outfd,
int errfd, int backfd, int sidefd,
int root, void *profile,
cupsd_job_t *job, int *pid);
extern int cupsdAddSelect(int fd, cupsd_selfunc_t read_cb,
cupsd_selfunc_t write_cb, void *data);
extern int cupsdDoSelect(long timeout);
#ifdef CUPSD_IS_SELECTING
extern int cupsdIsSelecting(int fd);
#endif
extern void cupsdRemoveSelect(int fd);
extern void cupsdStartSelect(void);
extern void cupsdStopSelect(void);
extern void cupsdStartServer(void);
extern void cupsdStopServer(void);