1/* 2 * Copyright (c) 2010 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of Apple Inc. ("Apple") nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 * Portions of this software have been released under the following terms: 31 * 32 * (c) Copyright 1989-1993 OPEN SOFTWARE FOUNDATION, INC. 33 * (c) Copyright 1989-1993 HEWLETT-PACKARD COMPANY 34 * (c) Copyright 1989-1993 DIGITAL EQUIPMENT CORPORATION 35 * 36 * To anyone who acknowledges that this file is provided "AS IS" 37 * without any express or implied warranty: 38 * permission to use, copy, modify, and distribute this file for any 39 * purpose is hereby granted without fee, provided that the above 40 * copyright notices and this notice appears in all source code copies, 41 * and that none of the names of Open Software Foundation, Inc., Hewlett- 42 * Packard Company or Digital Equipment Corporation be used 43 * in advertising or publicity pertaining to distribution of the software 44 * without specific, written prior permission. Neither Open Software 45 * Foundation, Inc., Hewlett-Packard Company nor Digital 46 * Equipment Corporation makes any representations about the suitability 47 * of this software for any purpose. 48 * 49 * Copyright (c) 2007, Novell, Inc. All rights reserved. 50 * Redistribution and use in source and binary forms, with or without 51 * modification, are permitted provided that the following conditions 52 * are met: 53 * 54 * 1. Redistributions of source code must retain the above copyright 55 * notice, this list of conditions and the following disclaimer. 56 * 2. Redistributions in binary form must reproduce the above copyright 57 * notice, this list of conditions and the following disclaimer in the 58 * documentation and/or other materials provided with the distribution. 59 * 3. Neither the name of Novell Inc. nor the names of its contributors 60 * may be used to endorse or promote products derived from this 61 * this software without specific prior written permission. 62 * 63 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 64 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 65 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 66 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY 67 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 68 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 69 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 70 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 71 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 72 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 73 * 74 * @APPLE_LICENSE_HEADER_END@ 75 */ 76 77/* 78** 79** NAME 80** 81** NIDL.H 82** 83** 84** FACILITY: 85** 86** Remote Procedure Call (RPC) 87** 88** ABSTRACT: 89** 90** Mandatory header file containing all system dependent 91** includes and common macros used by the IDL compiler. 92** 93** VERSION: DCE 1.0 94*/ 95 96#ifndef NIDLH_INCL 97#define NIDLH_INCL 98 99#define NIDLBASE_H 100 101#ifdef HAVE_CONFIG_H 102#include <config.h> 103#endif 104 105/* Base include files needed by all IDL compiler modules */ 106 107#include <stdio.h> 108#include <string.h> 109#ifdef HAVE_STDBOOL_H 110#include <stdbool.h> 111#else 112typedef enum { false = 0, true = 1 } bool; 113#ifndef true 114#define true true 115#endif 116#ifndef false 117#define false false 118#endif 119#endif 120 121#ifdef DUMPERS 122# define DEBUG_VERBOSE 1 123#endif 124 125#ifdef __STDC__ 126# include <stdlib.h> 127# ifndef CHAR_BIT 128# include <limits.h> /* Bring in limits.h if not cacaded in yet */ 129# endif 130#else /* prototypes that normally come from stdlib.h */ 131 extern void *malloc(); 132 extern void free(); 133 extern char *getenv(); 134 extern int atoi(); 135 extern double atof(); 136 extern long atol(); 137#endif 138#ifdef __STDC__ 139# include <assert.h> 140#else 141# define assert(ex) if (ex) ; 142#endif 143#include <sysdep.h> 144 145/* 146 * some generally useful types and macros 147 */ 148 149typedef unsigned char unsigned8; 150typedef unsigned short int unsigned16; 151typedef unsigned long int unsigned32; 152 153typedef unsigned8 boolean; 154#ifndef TRUE 155#define TRUE true 156#define FALSE false 157#endif 158 159/* 160 * IDL's model of the info in a UUID (see idl_uuid_t in nbase.idl) 161 */ 162 163typedef struct 164{ 165 unsigned32 time_low; 166 unsigned16 time_mid; 167 unsigned16 time_hi_and_version; 168 unsigned8 clock_seq_hi_and_reserved; 169 unsigned8 clock_seq_low; 170 unsigned8 node[6]; 171} nidl_uuid_t; 172 173/* 174 * Include files needed by the remaining supplied definitions in this file. 175 * These need to be here, since they depend on the above definitions. 176 */ 177 178#include <errors.h> 179#include <nidlmsg.h> 180 181/* Language enum. Here for lack of any place else. */ 182typedef enum { 183 lang_ada_k, 184 lang_basic_k, 185 lang_c_k, 186 lang_cobol_k, 187 lang_fortran_k, 188 lang_pascal_k 189} language_k_t; 190 191/* 192 * Macro jackets for each of the C memory management routines. 193 * The macros guarantee that control will not return to the caller without 194 * memory; therefore the call site doesn't have to test. 195 */ 196 197/** 198 * Returns pointer to a new allocated object of the specified type. 199 * It behaves like C++ new. The returned pointer is already correctly typed to 200 * type *. So you should not cast it. Let the compiler detect any errors 201 * instead of casting. 202 * 203 * The the returned memory is cleared. 204 * 205 * @param type of the object that should be allocated 206 * @return a valid pointer correctly typed 207 */ 208#define NEW(type) \ 209( __extension__ \ 210 ({ \ 211 type * __local_pointer = calloc(1, sizeof(type)); \ 212 if (NULL == __local_pointer) \ 213 error (NIDL_OUTOFMEM); \ 214 __local_pointer; \ 215 })) 216 217/** 218 * Allocates and returns pointer to a vector of objects. 219 * It behaves like C++ new. The returned pointer is already correctly typed to 220 * type *. So you should not cast it. Let the compiler detect any errors 221 * instead of casting. 222 * 223 * The the returned memory is cleared. 224 * 225 * @notice size is the _number_ of objects to be allocated 226 * 227 * @param type of the object that should be allocated 228 * @param size number of objects to be allocated 229 * @return a valid pointer correctly typed 230 */ 231#define NEW_VEC(type, size) \ 232( __extension__ \ 233 ({ \ 234 type * __local_pointer = calloc((size), sizeof(type)); \ 235 if (NULL == __local_pointer) \ 236 error (NIDL_OUTOFMEM); \ 237 __local_pointer; \ 238 })) 239 240/** 241 * Reallocates prevoiusly allocated memory area and returns the pointer to it. 242 * It behaves like C++ new and C realloc. The returned pointer is already 243 * correctly typed to typeof(pointer). So you should not cast it. Let the compiler 244 * detect any errors instead of casting. 245 * 246 * The the returned memory is _not_ cleared. 247 * 248 * @notice size is the _number_ of objects to be allocated 249 * 250 * @param pointer points to previously allocated vector 251 * @param size number of objects to be allocated 252 * @return a valid pointer correctly typed 253 */ 254#define RENEW(pointer, size) \ 255( __extension__ \ 256 ({ \ 257 __typeof__ (pointer) __local_pointer; \ 258 __local_pointer = \ 259 realloc((pointer), \ 260 size * sizeof(__typeof__ (* (pointer)))); \ 261 if (NULL == __local_pointer) \ 262 error (NIDL_OUTOFMEM); \ 263 __local_pointer; \ 264 })) 265 266/** 267 * Allocates some memory area. 268 * The returned pointer is always valid. Do not use this function. The better 269 * sollution is to use one of the above *NEW* function which return already 270 * typed pointers. 271 * 272 * @param size of the area to be allocated 273 * @return a valid pointer to the allocated memory 274 */ 275#define MALLOC(size) \ 276( __extension__ \ 277 ({ \ 278 void * __local_pointer = calloc(1, (size)); \ 279 if (NULL == __local_pointer) \ 280 error (NIDL_OUTOFMEM); \ 281 __local_pointer; \ 282 })) 283 284/** 285 * Frees memory allocated with one of the above functions 286 * 287 * @param pointer to the memory to be freed 288 */ 289#define FREE(pointer) free (pointer); 290 291/* 292 * Enable YYDEBUG, and ASSERTION checking, if DUMPERS is defined 293 */ 294#ifdef DUMPERS 295# define YYDEBUG 1 296 /* If ASSERTION expression is FALSE, then issue warning */ 297# define ASSERTION(x) do { \ 298 if (!(x)) { warning(NIDL_INTERNAL_ERROR, __FILE__, __LINE__); } \ 299} while (0) 300#else 301# define ASSERTION(x) do {;} while (0); 302#endif 303 304#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED 305typedef struct YYLTYPE 306{ 307 int first_line; 308 int first_column; 309 int last_line; 310 int last_column; 311} YYLTYPE; 312# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ 313# define YYLTYPE_IS_DECLARED 1 314# define YYLTYPE_IS_TRIVIAL 1 315#endif 316 317typedef struct parser_location_t 318{ 319 unsigned lineno; 320 STRTAB_str_t fileid; 321 YYLTYPE location; 322 const char * text; 323} parser_location_t; 324 325extern const parser_location_t empty_parser_location; 326#define null_parser_location &empty_parser_location 327 328typedef const parser_location_t * parser_location_p; 329 330/* Public NIDL parser API ... */ 331struct nidl_parser_state_t; 332typedef struct nidl_parser_state_t * nidl_parser_p; 333 334nidl_parser_p nidl_parser_alloc (boolean *,void **,char *); 335void nidl_parser_destroy (nidl_parser_p); 336void nidl_parser_input (nidl_parser_p, FILE *); 337unsigned nidl_yylineno (nidl_parser_p); 338parser_location_p nidl_location (nidl_parser_p); 339unsigned nidl_errcount (nidl_parser_p); 340int nidl_yyparse(nidl_parser_p); 341 342/* Public ACF parser API ... */ 343struct acf_parser_state_t; 344typedef struct acf_parser_state_t * acf_parser_p; 345 346acf_parser_p acf_parser_alloc (boolean *, void **, char *); 347void acf_parser_input (acf_parser_p, FILE *); 348void acf_parser_destroy (acf_parser_p); 349unsigned acf_yylineno (acf_parser_p); 350parser_location_p acf_location (acf_parser_p); 351unsigned acf_errcount (acf_parser_p); 352int acf_yyparse (acf_parser_p); 353 354#endif 355