/*      $NetBSD: funcs.h,v 1.7 2020/04/18 19:32:19 christos Exp $       */

/*
* Id: funcs.h,v 1.9 2004/01/23 18:56:42 vixie Exp
*/

/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1997,2000 by Internet Software Consortium, Inc.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/* Notes:
*      This file has to be included by cron.h after data structure defs.
*      We should reorg this into sections by module.
*/

void            set_cron_uid(void),
               set_cron_cwd(void),
               load_database(cron_db *),
               open_logfile(void),
               sigpipe_func(void),
               job_add(entry *, user *, time_t),
               job_remove(entry *, user *),
               job_exit(pid_t),
               link_user(cron_db *, user *),
               unlink_user(cron_db *, user *),
               free_user(user *),
               env_free(char **),
               unget_char(int, FILE *),
               free_entry(entry *),
               acquire_daemonlock(int),
               skip_comments(FILE *),
               log_it(const char *, int, const char *, const char *),
               log_close(void);


void
               log_itx(const char *, int, const char *, const char *, ...)
                   __printflike(4, 5);

pid_t           do_command(entry *, user *);

int             job_runqueue(void),
               set_debug_flags(const char *),
               get_char(FILE *),
               get_string(char *, int, FILE *, const char *),
               load_env(char *, FILE *),
               cron_pclose(FILE *),
               cron_pabort(FILE *),
               glue_strings(char *, size_t, const char *, const char *, char),
               strcmp_until(const char *, const char *, char),
               strdtb(char *);

size_t          strlens(const char *, ...);

char            *env_get(const char *, char **),
               *arpadate(time_t *),
               *mkprints(char *, size_t),
               **env_init(void),
               **env_copy(char **),
               **env_set(char **, char *);

user            *load_user(int, struct passwd *, const char *),
               *find_user(cron_db *, const char *);

entry           *load_entry(FILE *, void (*)(const char *), struct passwd *, char **);

FILE            *cron_popen(char *, const char *, struct passwd *);

struct passwd   *pw_dup(const struct passwd *);

#ifndef HAVE_TM_GMTOFF
long            get_gmtoff(time_t *, struct tm *);
#endif

extern int close_all(int);
#ifdef USE_PAM
extern int cron_pam_start (const char *user);
extern int cron_pam_setcred (void);
extern void cron_pam_finish (void);
extern void cron_pam_child_close (void);
extern char **cron_pam_getenvlist (char **envp);
#endif