2  * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved. 
   4  * @APPLE_LICENSE_HEADER_START@ 
   6  * "Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights 
   7  * Reserved.  This file contains Original Code and/or Modifications of 
   8  * Original Code as defined in and that are subject to the Apple Public 
   9  * Source License Version 1.0 (the 'License').  You may not use this file 
  10  * except in compliance with the License.  Please obtain a copy of the 
  11  * License at http://www.apple.com/publicsource and read it before using 
  14  * The Original Code and all software distributed under the License are 
  15  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  16  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  17  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
  18  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the 
  19  * License for the specific language governing rights and limitations 
  22  * @APPLE_LICENSE_HEADER_END@ 
  25  * bootstrap -- fundamental service initiator and port server 
  26  * Mike DeMoney, NeXT, Inc. 
  27  * Copyright, 1990.  All rights reserved. 
  29  * lists.h -- interface to list routines 
  34 #import <mach/boolean.h> 
  35 #import <servers/bootstrap_defs.h> 
  40 #define NULL    ((void *)0) 
  43 typedef struct bootstrap bootstrap_info_t
; 
  44 typedef struct service service_t
; 
  45 typedef struct server server_t
; 
  49         bootstrap_info_t                
*next
;          /* list of all bootstraps */ 
  50         bootstrap_info_t                
*prev
; 
  51         bootstrap_info_t                
*parent
; 
  52         bootstrap_info_t                
*deactivate
;    /* list being deactivated */ 
  53         mach_port_name_t                bootstrap_port
; 
  54         mach_port_name_t                requestor_port
; 
  55         unsigned int                    ref_count
; 
  60         DECLARED
,       /* Declared in config file */ 
  61         REGISTERED      
/* Registered dynamically */ 
  65         service_t       
*next
;          /* list of all services */ 
  67         name_t          name
;           /* service name */ 
  68         mach_port_name_t        port
;           /* service port, 
  69                                            may have all rights if inactive */ 
  70         bootstrap_info_t        
*bootstrap
;     /* bootstrap port(s) used at this 
  72         boolean_t       isActive
;       /* server is running */ 
  73         servicetype_t   servicetype
;    /* Declared, Registered, or Machport */ 
  74         server_t        
*server
;        /* server, declared services only */ 
  79         SERVER
,         /* Launchable server */ 
  80         RESTARTABLE
,    /* Restartable server */ 
  81         DEMAND
,         /* Restartable server - on demand */ 
  82         MACHINIT
,       /* mach_init doesn't get launched. */ 
  85 #define NULL_SERVER     NULL 
  89         server_t        
*next
;          /* list of all servers */ 
  91         servertype_t    servertype
; 
  92         int             uid
;            /* uid to exec server with */ 
  93         auditinfo_t     auinfo
;         /* server's audit information */ 
  94         mach_port_t     port
;           /* server's priv bootstrap port */ 
  95         mach_port_t     task_port
;      /* server's task port */ 
  96         pid_t           pid
;            /* server's pid */ 
  97         int             activity
;               /* count of checkins/registers this instance */ 
  98         int             active_services
;/* count of active services */ 
  99         bootstrap_info_t 
*bootstrap
; /* bootstrap context */ 
 100         cmd_t           cmd
;            /* server command to exec */ 
 105 extern void init_lists(void); 
 107 extern server_t 
*new_server( 
 108         bootstrap_info_t        
*bootstrap
, 
 111         servertype_t            servertype
, 
 114 extern service_t                
*new_service( 
 115         bootstrap_info_t        
*bootstrap
, 
 117         mach_port_t                     service_port
, 
 119         servicetype_t           servicetype
, 
 122 extern bootstrap_info_t 
*new_bootstrap( 
 123         bootstrap_info_t        
*parent
, 
 124         mach_port_name_t        bootstrap_port
, 
 125         mach_port_name_t        requestor_port
); 
 127 extern server_t 
*lookup_server_by_port(mach_port_t port
); 
 128 extern server_t 
*lookup_server_by_task_port(mach_port_t port
); 
 129 extern void setup_server(server_t 
*serverp
); 
 130 extern void delete_server(server_t 
*serverp
); 
 131 extern boolean_t 
active_server(server_t 
*serverp
); 
 132 extern boolean_t 
useless_server(server_t 
*serverp
); 
 134 extern void delete_service(service_t 
*servicep
); 
 135 extern service_t 
*lookup_service_by_name(bootstrap_info_t 
*bootstrap
, name_t name
); 
 136 extern service_t 
*lookup_service_by_port(mach_port_t port
); 
 137 extern service_t 
*lookup_service_by_server(server_t 
*serverp
); 
 139 extern bootstrap_info_t 
*lookup_bootstrap_by_port(mach_port_t port
); 
 140 extern bootstrap_info_t 
*lookup_bootstrap_by_req_port(mach_port_t port
); 
 141 extern void deactivate_bootstrap(bootstrap_info_t 
*bootstrap
); 
 142 extern void deallocate_bootstrap(bootstrap_info_t 
*bootstrap
); 
 143 extern boolean_t 
active_bootstrap(bootstrap_info_t 
*bootstrap
); 
 145 extern void *ckmalloc(unsigned nbytes
); 
 147 extern bootstrap_info_t bootstraps
;             /* head of list of bootstrap ports */ 
 148 extern server_t servers
;                /* head of list of all servers */ 
 149 extern service_t services
;              /* head of list of all services */ 
 150 extern unsigned nservices
;              /* number of services in list */ 
 152 #define FIRST(q)                ((q).next) 
 153 #define NEXT(qe)                ((qe)->next) 
 154 #define PREV(qe)                ((qe)->prev) 
 155 #define IS_END(qe, q)           ((qe) == &(q))