/*

                                   _JNJ`                        
                               .JNMH`                           
                              JMMF`       `;.                   
                            .NMM)          `MN.                 
                            MMM)            (MML                
                           (MMM`             MMML               
                     M  I  D  N  I  G  H  T    C  o  D  E       
                           (NMMF             MHNH               
                            NMML            .MMM                
                             NMML          .NMH                 
                              4MMNL       .#F                   
                               `4HNNL_   `                      
                                   `"""`                        

                          Copyright (C) 2004-2006
       "Ian (Larry) Latter" <ian dot latter at midnightcode dot org>

    Midnight Code is a registered trademark of Ian Latter.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, and mirrored at the Midnight Code web
    site; as at version 2 of the License only.
  
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
  
    You should have received a copy of the GNU General Public License
    (version 2) along with this program; if not, write to the Free
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA, or see http://midnightcode.org/gplv2.txt

*/


/* midnightcode-process.h :: Midnight Code process library		*/


#ifndef __MIDNIGHTCODE_PROCESS_H
#define __MIDNIGHTCODE_PROCESS_H 1


#define SETSIG(sa, sig, func, flags) \
                do { \
                        sa.sa_handler = func; \
                        sa.sa_flags = flags; \
                        sigemptyset(&sa.sa_mask); \
                        sigaction(sig, &sa, NULL); \
                } while(0)

enum midnightcode_process_option_t
{
  MIDNIGHTCODE_PROCESS_OPTION_NONE = 0,
  MIDNIGHTCODE_PROCESS_OPTION_CONSOLE = 1,
  MIDNIGHTCODE_PROCESS_OPTION_NULLIO = 2,
  MIDNIGHTCODE_PROCESS_OPTION_BACKGROUND = 4,
  MIDNIGHTCODE_PROCESS_OPTION_WAITTERM = 8,
  MIDNIGHTCODE_PROCESS_OPTION_EXITCODE = 16,
  MIDNIGHTCODE_PROCESS_OPTION_GETPID = 32,
  MIDNIGHTCODE_PROCESS_OPTION_ALL = 255
};

int midnightcode_process_execute(char **args);
int midnightcode_process_execute_construct(int options, int terminal,
                                           char **args);
int midnightcode_process_parser(char **execute_buf, char *process_buf,
                                           char **args);
int midnightcode_process(char *command_buf, int options, int terminal);
int midnightcode_process_sysctl(char * control, char * value);


#endif
