lib/texpect: prefer bsd/libutil.h if available
[obnox/samba/samba-obnox.git] / lib / texpect / texpect.c
index ac889792b38869327c0a86aae24b1562b061a0d5..75a32f4bed29d728e64463315f0c2668c591aaab 100644 (file)
  * SUCH DAMAGE.
  */
 
-#include "config.h"
+#include "replace.h"
+#include "system/filesys.h"
+#include "system/wait.h"
 
-#ifndef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #ifdef HAVE_PTY_H
 #include <pty.h>
 #endif
 #ifdef HAVE_UTIL_H
 #include <util.h>
 #endif
-#ifdef HAVE_LIBUTIL_H
+#ifdef HAVE_BSD_LIBUTIL_H
+#include <bsd/libutil.h>
+#elif defined HAVE_LIBUTIL_H
 #include <libutil.h>
 #endif
 
@@ -60,9 +52,7 @@
 #endif /* STREAMPTY */
 
 #include <popt.h>
-#include <errno.h>
 #include <err.h>
-#include <signal.h>
 
 struct command {
        enum { CMD_EXPECT = 0, CMD_SEND, CMD_PASSWORD } type;
@@ -370,8 +360,9 @@ int main(int argc, const char **argv)
        pid_t pid;
        poptContext pc;
        const char *instruction_file;
+       const char **args;
        const char *program;
-       char* const *program_args;
+       char * const *program_args;
 
        pc = poptGetContext("texpect",
                            argc,
@@ -389,7 +380,8 @@ int main(int argc, const char **argv)
        }
 
        instruction_file = poptGetArg(pc);
-       program_args = poptGetArgs(pc);
+       args = poptGetArgs(pc);
+       program_args = (char * const *)discard_const_p(char *, args);
        program = program_args[0];
 
        if (opt_verbose) {