#
# line 1 "Ned_data.c"
#
/*
*       SCCS File Type - 
*
* 	What identification string
*/
static char *_S_Ned_data     "@(#)Ned_data.c	1.13";
# line 1 "KERcalls.h"
# ifndef NO_WHAT
/*
 *      SCCS file type - Emulator Include File
 *
 *      What identification string:
 */
static char *_S_Kercalls = "@(#)EM_KERcalls.h	3.4";
# endif

/*
COPYRIGHT:  1979, by Ford Aerospace and Communications Corp.
ADDRESS:    Ford Aerospace and Communications Corp.
            Western Development Laboratories
            3939 Fabian Way
            Palo Alto, California 94303
            Attention: Software Technology Dept.
            Mail Stop: V02 

CPCI:   Emulator

TAG:    EKL
MODULE NAME:  

		Kernel Interface Linkage Include file.

REFERENCES-
  A Specs:  ???
  B5 Specs:  ???

HISTORY:
  AUTHOR: Dan Ladermann, modified from Modula version by L.C.Dion, R.B.Neely.
  VERSION:  3.4 of 12/12/82
  MODULE TYPE: M4  file with C types.

PRIVILEGES:  None
SPECIAL NOTES:  None

*/


/*
 *      CONSTANTS
 */

          /* top  for bytes in a message     */

             /* boolean values */
             /* 0377 as used in Kernel */


/* bits for discretionary access  */

	
	
	
	
	
	
	
	
	

/* bits for discretionary access  for acc modes */

	
	
	


/* K_remap status selectors */

	
	
	

/* K_set_segment_status selectors */

	
	
	
	
	
	

/* K_(set)(get)_process_status selectors */

	            /* privileged to set    */
	            /* privileged to set    */
	            /* privileged to set    */
	            /* owner to set         */
	            /* owner to set         */
	            /* self only to set     */
	            /* owner to set         */
	            /* owner to set         */
	            /* set time_of_day_clock*/

/* K_set_object_level selectors */

	            /* set access_level     */
	            /* set effective owner  */
	            /* set effective group  */
	            /* set discr_access     */
	            /* set privileges       */


/*
 *      TYPES
 *
 *
 *      Each type declaration has two comments associated with it.
 *
 *      1. a short description as to what the type is used for
 *
 *      2. the size of the type ( in bytes of data space )
 *
 *      3. where m4 translates have been used for typedefs there is also
 *         and addition comment -typedef-
 */


     /* typedef */ /* 32-bit bits */
				      /* 4 bytes */

 /* typedef */ /* 32-bit cardinal */
				      /* 4 bytes */

 /* typedef */ /* 32-bit unsigned int */
				      /* 2 bytes */

    /* typedef */ /* status int */
				      /* 2 bytes */

    /* typedef */ /* -1 or 0 */
				      /* 1 byte */

    /* typedef */ /* -1 or 0 */
				      /* 1 byte */




/*
 *      nsp_type  - name space partition
 */

		/* 1 byte */


	/*
	 *      The file_nsp has been removed. If unsigned int( seid.nsp )
	 *              is greater than 127, then the namespace signifies
	 *              the file namespace (by definition).
	 */


	   /* null                 */
	   /* EXTENTS              */
	   /* TERMINALS            */
	   /* DEVICES              */
	   /* PROCESSES            */
	   /* SEGMENTS             */
	   /* SUBTYPES             */
	   /* Kernel gen. messages */
	   /* UNIX directories     */
	   /* ROOT directory nsp   */
	  /* mounted file systme  */
	  /* mounted file system  */

/*
 *       seid   -     SEID
 */

		/* 4 bytes */
		/* 4 bytes */

	struct  {
		char  nsp;          /* name space   */
		char      uniq_id0;     /* unique ID    */
		int       uniq_id1;     /* unique ID    */
	};

	/*
	 *      Seids can be move, compared for
	 *      equality and passed as longs. But
	 *      should be accessed using the
	 *      above structure and the following
	 *      macro(s).
	 */

	/* usage namespace(long)- returns the name space portion of the long */
	/* where long is a long.                                             */

	

  /* ID for asynchronous I/O */
			/* 2 bytes */

/*
 *      acc_mode        Access Modes
 */

	 /* access mode bit mask */
				/* 2 bytes */


/*
 *      compartments
 */
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

	   /* typedef */
				       /* 4 bytes */

/*
 *      direction       = (up,down)     (* segment growth direction     *)
 */
	 /* typedef */
				       /* 1 byte   */
	
	

/*
 *      discr_access - Discretionary access
 */

	  /* typedef */
				    /* 2 bytes */

/*
 *      domain_type  -  domains
 */

	      /* typedef */
					/* 1 byte */

	       /* domains */
	
	
	

   /* typedef */   /* block number in files */
			/* 4 bytes */

/*
 *       file_stat_block = RECORD               file status
 */                       /* 14 bytes */

	
	
	

	typedef struct  {
			long    f_size;           /* file size    */
			long          subtype;          /* file subtype */
			long    TLstMod;    /* time of last mod */
			char       OpenACr;    /* if open at crash */
		} fStatBl;

/*
 *      integrity categories
 */

	  /*typedef */
					  /* 1 byte */

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

/*
 *      ioFunction - device functions
 */

	  /* typedef */
				   /* 1 byte */
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

/*
 *      definitions for devices.
 */

	
	
	


/*
 *      msg_struct       = message portion of IPC
 */
	

	typedef char    msgStr[11 + 1];     /* message */
				/* 12 bytes */

/*
 *      ipc_block       = RECORD    -  IPC message
 */

	
	

	typedef struct  {       /* 16 bytes */
			long            ipcSeid;       /* long of sender */
			msgStr      ipc_msg;        /* message data   */
		}ipcBlk;

/*
 *      K_err_num -        Kernel error values
 */

	        /* typedef */
					/* 2 byte */
	   /* temp variable used for filling out err_nums */
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

/*
 *      ioStatus - I/O status of operation
 */

	    /* typedef */
				   /* 4 bytes */
	
	struct  {                     /* structure for accessing long */
		int        devIdep;     /* independent part */
		int             devDep  ;     /* dependent part   */
	};

/*
 *      ioc_block - struct of I/O completion message
 */

	typedef struct {
		long            ioc_seid;
		char            ioc_type;
		char            ioc_x1;
		long        ioc_stat;
		unsigned int    ioc_bytes;
		int         ioc_async;
		char            ioc_x2[2];
	} ioc_block;

/*
 *      mem_type - memory space divisions
 */

	  /* typedef */   /* memory space divisions */
				/* 1 byte  */
	
	
	

      /* typedef */  /* open file handle */
				  /* 2 bytes */
/*
 *     KopenModes - open modes
 */

	/* open modes as used by Kernel
	 *      openModes = RECORD
	 *                (* 4 bytes *)
	 *                        read            : char;
	 *                        write           : char;
	 *                        exclusive_read  : char;
	 *                        exclusive_write : char
	 *                  END;
	 */
	         /* typedef */

	/* structure for geting at  long */
	struct {
		char    KomRead;
		char    KomWrite;
		char    KomEread;
		char    KomEwrite;
	};


	/* open  modes used by the emulator - packed in char  */

	         /* typedef */

	      /* bit masks for open Modes */
	
	
	

	/*
	 * m4 macro used for converting packed character of open modes
	 * into two arguments of kernel open mode type.  Used in Kernel calls
	 */

	
/*
 * virt_addr, virt_loc - virtual address and location
 */

	  /* virtual address */
				/* 2 bytes */

	  /* virtual location */
				/* 4 bytes */

	/* structure definition used for accessing long */
	struct  {
		char     domain;         /* char */
		char        space;          /* char */
		int       address;        /* int  */
	};

	/* macros for getting domain and space from long that handles sign extention*/
	
	

/*
 *      p_block - parameter block
 */


	typedef struct {        /* parameter block */
				/* 6 bytes */
			long        location;       /* block address   */
			int             b_size  ;       /* block size      */
		}  p_block;

/*
 *      priv_names - privileges
 */

	  /* typedef */     /* set of privileges */
				      /* 4 bytes */

	   /* names of privileges */
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

/*
 *      proc_stat_block - process status block
 */

	

	typedef struct  {                       /* process status block     */
					/* 32 bytes */
			long            own;    /* own long -- read-only    */
			long            parent; /* parent long -- read-only */
			int             family; /* process family name      */

			int             owner;  /* real owner id --read-only*/
			int             group;  /* real group id --read-only*/

			int             aprio;  /* advisory priority        */
			int             pseint; /* pseudo-interrupt level   */
			int             ps;     /* processor status         */

			int             alarm;  /* real-time timer alarm    */
			long      clock;  /* time of day clock        */
			char         tt;     /* timer toggle enable      */

			int             stiming;/* supv timings - read-only */
			int             utiming;/* user timings - read-only */
		} PstatBl;

/*
 *      pseudo_int_levels  - pseudo interrupt levels
 */

	  /* starting address of pseduo int vectors */

	   /* typedef */
					  /* 2 byte */
	   /* emulator */
	   /* IPC      */
	   /* timer    */
	   /* K_signal */
	   /* I/O      */
	   /* hardware */

/*
 *      pseudo_int_vector    -- pseudo-interrupt vector
 */
	
	
	
	

	typedef struct  {
				/* 26 bytes */
			int             intPc;
			int             intPs;
			int             intPlev;
			ipcBlk       int_msg;
			int             new_pc;
			int             new_ps;
		} PIvec;


	

	typedef PIvec PIvecs[5 + 1] ;


/*
 *      security_cat_type - security categories
 */

	  /*typedef */
					  /* 1 byte */

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

    /* typedef */           /* open segment handle */
			/* 2 bytes */

   /* typedef */           /* size of segments */
			/* 2 bytes */

/*
 *      seg_stat_block  -- segment status block
 */

	
	
	
	
	
	
	
	
	
	
	
	

	/* entries marked K_build only can be set by K_build  */

	typedef struct {
				/* 22 bytes */
			char            memLock;       /* in mem       */
			char            memAdv;     /* I/O          */
			char            swapLk;      /* sticky       */
			char            sharabl;       /* sharabl     */
			char          growth;         /* K_build only */
			int           statSiz;      /* K_build only */
			long               statSed;      /* read only    */
			int            statDes;       /* read only    */
			char            statMap;    /* read only    */
			int           statAcc;       /* K_build only */
			long           statLoc;       /* K_build only */
		} segStBl;


/*
 *      access_level_type
 */

	
	
	
	

	typedef struct  {
					/* 6 bytes */
			char              secCat;
			char             intgCat;
			long                    secComp;
		} accLevT;

/*
 *      tii_struct
 */

	
	
	
	
	

	typedef struct  {
				/* 16 bytes */
			accLevT       accLev;
			int                     tiiOwn;
			int                     tiiGrp;
			int            da;
			long             tiiPriv;
		} tiiStru;



/* CONST   Typed constants */





                  /* all zero's */

              /* all false  */

              /* all zero's */

              /* 0, 0, 0 */

/* null structures (from Modula) - no C mapping  */
/*
 *      null_p_block         = p_block( long( 0,
 *                                                0, 0 ), 0 );
 *
 *      null_tii_struct       = tiiStru(
 *                                  accLevT(
 *                                      00,
 *                                      00,
 *                                      long( [], [] )
 *                                  ),
 *                                  0,0,[],long([],[])
 *                              );
 *      null_file_stat_block  = fStatBl(
 *                                  long( 0, 0 ),
 *                                  long( 0, 0C, 0 ),
 *                                  long( 0, 0 ),
 *                                  false
 *                              );
 *      null_proc_stat_block  = PstatBl(
 *                                  long( 0, 0C, 0 ),
 *                                  long( 0, 0C, 0 ),
 *                                  0,0,0,0,0,0,
 *                                  0,long( 0, 0 ),false,
 *                                  0,0
 *                              );
 *      null_seg_stat_block   = segStBl(
 *                                  false,false,false,false,0,
 *                                  0,
 *                                  int( false, false, false ),
 *                                  long( 0, 0, 0 )
 *                              );
 */

/* long to short name mapping for Kernel calls */







































/* K_boot not implemented in emulator interface */



# line 9 "Ned_data.c"
# line 1 "NKSRdefs.h"
#line 1 "NKSRdefs.h"
/*
*	SCCS File Type - 
*
* 	What identification string
*/
static char *_S_NKSRdefsh	"@(#)NKSRdefs.h	1.10";

/* need to  /kr/sunix/emulator//KERcalls.h before this file */


#define READ 0
#define WRITE 1
#define RW 2
#define RXW 3
#define XU 4

#define NAMELENGTH 8
#define PASSLENGTH 11
#define LINELENGTH 80
#define PATHLENGTH 64
#define SHORT 12
#define LONG 50
#define SYSNAMELEN 60

#define SEC_LOW_ENTRY      0
#define SEC_HIGH_ENTRY     15
#define INTEG_LOW_ENTRY     16
#define INTEG_HIGH_ENTRY    31
#define CMPTMNT_LOW_ENTRY   32
#define CMPTMNT_HIGH_ENTRY  63


/* an enumerated type used by the procedures "stoa" (security to ascii)
   and "ctoa" (compartment to ascii). */
#define LNAME      1    /* return the long name */
#define SNAME      2    /* return the short name */


	typedef char    nameType;
	typedef char    passType;
	typedef char    lineType;
	typedef char    pathType;

	
	
	
	typedef char    secshort;
	typedef char    seclong;
	typedef char    sysnType;

	/* system version type */
	/* major and minor have been renamed (different than the modula
	 * version) due to a conflict with emulator  files       */
	
	typedef struct
	{
		unsigned int majornum;      /* major version number */
		unsigned int minornum;      /* minor version number */
	} verType;

/*
 *   syspstruct
 *
 *   system profile database record
 */
	typedef struct
	{
		sysnType      sys_name[SYSNAMELEN];  /* system name for this system */
		sysnType      inst_name[SYSNAMELEN]; /* name of install where this system is located */
		unsigned int         sys_no;       /* unique KSOS system number */
		verType      version;      /* KSOS OS version number (major/minor) */
		long       gen_date;     /* KSOS OS system generation date */
		accLevT  systemMax;  /* max level ever permitted for this system */
		accLevT  currMax;    /* max level currently permitted on this system */
		accLevT  currMinMax; /* defines the lowest maximum level needed to
						  login in (ie if a user's max level is 
						  less than this level he can not login) */
		
	} syspstruct;

/*
 *   secMapstruct
 *
 *   shortName is in uppercase and needn't end with null
 *   longName is uppercase, may  blanks, and must end with null
 *   active is 'A' active or 'I' inactive
 *
 *   The map has 64 entries
 *    0 - 15 are security level categories
 *   16 - 31 are integrity level categories
 *   32 - 63 are seurity compartments
 */
	typedef struct
	{
		secshort    shortName[SHORT]; /* 12 bytes */
		seclong     longName[LONG];   /* 50 bytes */
		char		fillnull;	  /*  1 byte  */
		char    	active;           /*  1 byte */
	} secMapstruct;

	
	
	
/*
 *   uaastruct
 *
 *   user access authentication database
 */
	typedef struct                              /*  256 bytes */
	{
		nameType    usname[NAMELENGTH];   /*    8 bytes */
		passType    uspassw[PASSLENGTH]; /* 11 bytes */
		char        pad1;                   /*    1 byte  */
		char        loginOk;                /*    1 byte  */
		char        pad2;                   /*    1 byte  */
		accLevT usmxlev;     /*    6 bytes */
		tiiStru     tii;                 /*   16 bytes */
		pathType    loginDir[PATHLENGTH];   /*   64 bytes */
		pathType    loginShell[PATHLENGTH]; /*   64 bytes */
		pathType    loginEmul[PATHLENGTH];  /*   64 bytes */
		char        filler[20];             /*   20 bytes */

	} uaastruct;

	
	
	
/*
 *   gaastruct
 *
 *   group access authentication database
 */
	typedef struct                              /* 30 bytes */
	{

		nameType    gname[NAMELENGTH];  /*  8 bytes */
		passType    gpassw[PASSLENGTH]; /* 11 bytes */
		char	    fillchar;		    /* 1 byte  */
		int         groupid;                /*  2 bytes */
		accLevT gmaxlev;    /*  6 bytes */
		int         groupAdmin;             /*  2 bytes */
	} gaastruct;

	
	
	
	
	
	
/*
 *   dpstruct
 *
 *   device profile database
 */
	typedef struct                              /* 30 bytes */
	{
		nameType   dvcname[NAMELENGTH];  /*  8 bytes */
		long       dvcseid;              /*  4 bytes */
		tiiStru dvctii;              /* 16 bytes */
		char	   valrequr;	    /*  1 byte  setting of drive valid required */
		char    assrequr;         /*  1 byte  can be assigned to user by assign function */
	} dpstruct;

	/* valid parity types */
	typedef int	parityType;
	
	
	

/*
 *   tpstruct
 *
 *   terminal profile database
 */
	typedef struct                          /* 23 bytes */
	{
		char              ttyid;        /* 1 unique terminal id */
		char           config;       /* 1 terminal is configured */
		char           console;      /* 1 terminal is to be treated as a console */
		unsigned int          xmitBaud;     /* 2 default xmit baud rate */
		unsigned int          recBaud;      /* 2 default rec baud rate */
		parityTypes       parity;       /* 2 default parity */
		char              clrScreen[8]; /* 8 sequence required to clear the screen */
		accLevT maxLevel;     /* 6 maximum access level for this terminal */
	} tpstruct;
# line 10 "Ned_data.c"
# line 1 "NKedit.h"
#
/*
*	SCCS File Type - 
*
* 	What identification string
*/
static char *_S_NKedith   "@(#)NKedit.h       1.5";
#line 1 "NKedit.h"

#define ON 1
#define OFF 0
#define FOREVER 1
#define FOUND 1
#define NULL 0
#define ONE 1
#define ZERO 0
#define NOTEQUAL -1
#define ERROR -1
#define EQUAL 0

#define NEWLINE '\n'
#define ENDSTRING '\0'
#define BLANK ' '
#define ACTIVE 'A'
#define INACTIVE 'I'
#define ACTPLACE 63
#define YES 'y'
#define NO  'n'
#define EOF 0
#define CREATED 1
#define OPENED  0

#define INVALID 255
#define NOTAPPLICABLE 0
#define CATERROR 0700
#define CASEDIFF 0040
#define ECHO 000010

#define NUMSECCAT 16
#define NUMCAT 32
#define COMPLOW 32
#define COMPHIGH 64

#define HALFWAY 48
#define LOWMODE 0377  /*low bits */
#define PMODE 0644  /*RW,R,R*/

#define USERDA 64
#define GROUPDA 8

#define SECMAPLEN 64
#define SMRECLEN  64
#define NUMBLOCKSX2 2
#define BUFSIZE 512
#define RECSIZE 256
#define GRECSIZE 30
#define DRECSIZE 30
#define TRECSIZE 24
#define SYSRECLEN 148
#define ASCIPRTABLE 41  /*value of first printable ascii character */

#define OWNER "owner"
#define GROUP "group"
#define ADMIN "administrator"


	typedef struct
	{
		char    Name[NAMELENGTH];
		int     Uid;
	} namearray;

	typedef struct
	{
		char    shortname[SHORT];
		char    activ;
	} secarray;
# line 11 "Ned_data.c"
#line 11 "Ned_data.c"

char    *Tempfile;              /* pointer to tempfile */
int     Index;                  /* offset into input buffer */
int     Changed_flag = OFF;     /* flag set if changes made */
int     Numofgroups;            /* number of entries in the group list */
int     Numofnames;             /* number of entries in the name list */
int     F1, F2;                 /* file descriptors */

namearray  Namelist[1000];      /* list of owners and uids */
namearray  Grouplist[200];      /* list of groups and gids */
char    Edtor_comds[] =
	"a)dd\nc)hange\nd)elete\nf)ind\nn)ext\np)rint\nv)iew\nq)uit\n";
char    Notvalmessage[] =  "no longer a valid name";

uaastruct Uaarecord;            /* storage of one record */
char    Uchang_comds[] =
	"x)exit\nv)iew\np)swd\nl)ogok\no)wner id\ng)roup id\na)ccess level\nm)axl\nd)ir\ns)hell\ne)mul\n";

gaastruct  Gaarecord;           /* storage of one record */
char    Gchang_comds[] =
	"x)exit\nv)iew\np)swd\ng)roup id\na)dmin\nm)ax acc level\n";

secMapstruct Secmap[SECMAPLEN];    /* Security map */
secarray     seclist[SECMAPLEN];   /* stores the security map */
char	Level; 			   /* category type of secmap */
char    Smedtor_comds[] =
	"a)dd\nc)hange\nd)elete\nl)evel\np)rint\nv)iew\nq)uit\n";
char    Smchang_comds[] =
	"x)exit\nv)iew\ns)hort name\nl)ong name\na)ctive\n";

int     Numofdev;               /* number of entries in the device list */
namearray  Devicelist[200];     /* list of devices and uids */
dpstruct   Dprecord;            /* storage of one record */
char    Dpchang_comds[] =
	"x)exit\nv)iew\nn)ame\ns)eid\ng)roup id\nd)iscret access\na)cess level\nr)valrequr\nl)assignment allowed\n";

int     Numofterm;              /* number of entries in the terminal list */
char    Termlist[100];     	/* list of terminal ids */
tpstruct  Tprecord;             /* storage of one record */
char    Tpchang_comds[] =
	"x)exit\nv)iew\ni)d\nf)configured\nc)onsole\nt)ransmit rate\nr)eceive rate\np)arity\ns)creen clear\nm)ax access level\n";
syspstruct Sysrecord;
char	   Syschgcomds[] =
"q)uit\nv)iew\np)rint\ns)ys name\ni)nst name\nsys n)um\nve(r)sion num\ngen d)ate\nm)ax acc lev\nc)urr max acc lev\nmin l)ogin acc lev\n";
# line 4 "Standard Input"
