source: git/MP/MP/MP.h @ 4439165

spielwiese
Last change on this file since 4439165 was 4439165, checked in by Hans Schönemann <hannes@…>, 15 years ago
*hannes: gcc 4.3 git-svn-id: file:///usr/local/Singular/svn/trunk@11873 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 79.0 KB
Line 
1
2/* MP.h automatically generated by ./makeheader.pl */
3/****************************************************************
4 *
5 *   HEADER FILE:  MP.h
6 *
7 *        Everything we need.  Saves doing a zillion includes
8 *        in user programs.
9 *
10 ***************************************************************/
11
12#ifndef _MP_h
13#define _MP_h
14
15/*
16 * Definitions that allow this header file to be used either with or
17 * without ANSI C features like function prototypes.
18 */
19
20#undef _ANSI_ARGS_
21#undef CONST
22#if ((defined(__STDC__) || defined(SABER))  && !defined(NO_PROTOTYPE)) || defined(__cplusplus)
23#   define _ANSIC_
24#   define _USING_PROTOTYPES_ 1
25#   define _ANSI_ARGS_(x)       x
26#   define CONST const
27#   ifdef __cplusplus
28#       define VARARGS (...)
29#   else
30#       define VARARGS ()
31#   endif
32#else
33#   define _ANSI_ARGS_(x)      ()
34#   define CONST
35#endif
36
37#ifdef __cplusplus
38#   define EXTERN extern "C"
39#else
40#   define EXTERN extern
41#endif
42
43
44/* standard includes */
45
46#include <stddef.h>
47#include <stdio.h>
48#include <sys/types.h>
49#include <errno.h>
50
51/* MP Config include */
52#include "MP_Config.h"
53
54/* need select.h where available */
55#ifdef HAVE_SYS_SELECT_H
56#include <sys/select.h>
57#endif
58
59
60/* MP includes */
61
62
63/* Stuff included from h/MP_Types.h */
64/***************************************************************************
65 *
66 *   HEADER FILE:  MP_Types.h
67 *
68 *        Most of the typedefs needed by MP are here, including the definition
69 *      of node and annotation packets.
70 *
71 *   Change Log:
72 *     May 30, 1995 SG - added defines for new types for MP 1.0
73 *     December 12, 1995 SG - added ifdef for AIX per Hannes' instructions
74 *     December 20, 1995 SG - added enum for fp format
75 *     4/23/96 sgray - added defines to support different arbitrary precision
76 *                     integer formats.
77 *     Jan 6, 1997  OB - rearranged integer assignments for MP types
78 *
79 ***************************************************************************/
80
81#ifndef _MP_Types_h
82#define _MP_Types_h
83
84#define MP_TRUE  0x01
85#define MP_FALSE 0x00
86
87#ifdef __hpux
88#   define SELECT(maxfdp1, readfs, writefs, exceptfds, tvptr) \
89        select((int)maxfdp1, (int*)readfs, (int*)writefs,     \
90               (int*)exceptfds, tvptr)
91#else /*  not __hpux */
92#   define SELECT  select
93#endif /* not __hpux */
94
95
96/* to indicate the direction of traffic */
97#define MP_SEND     0
98#define MP_RECEIVE  1
99
100/* For checking the status of a link*/
101enum link_status_option {MP_UnknownStatus, MP_LinkReadyReading,
102                         MP_LinkReadyWriting,
103                         MP_LinkIsParent, MP_LinkIsChild};
104typedef enum link_status_option MP_LinkStatus_t;
105
106/* To determine which byte ordering is native and which is actually used. */
107/* The default is BigEndian. */
108enum word_order {MP_BigEndian, MP_LittleEndian};
109typedef enum word_order MP_WordOrder_t;
110
111/* To determine which floating format is native and which is actually used. */
112/* The default is IEEE format. */
113enum fp_format {MP_IEEE_fp, MP_Vax_fp};
114typedef enum fp_format MP_FpFormat_t;
115
116
117
118/*
119*  Important size used throughout
120*/
121#define  MP_BytesPerMPUnit        4
122
123/* New defines for MP 1.0 */
124
125/* shift values for the node packet */
126#define  MP_NodeOpFieldShift           8
127#define  MP_NodeNumChildFieldShift     8
128#define  MP_NodeAnnotFieldShift       12
129#define  MP_NodeDictTagFieldShift     16
130#define  MP_NodeCommonValueFieldShift 24
131
132/* used for the #children and #annots field in the node packet header
133   to indicate that there are more than 14 children or annotations and
134   that an extra field(s) (a long) must be retrieved from the stream */
135#define  MP_ExtraFieldIndicator             0xf
136
137/* used for the dictionary tag field to indicate that an extra four
138   bytes must be read to get the dictionary tag - don't expect to
139   actually have to use this for a long time                         */
140#define  MP_ExtraMPDictTagFieldIndicator    0x7f
141#define  MP_ExtraUserDictTagFieldIndicator  0xff
142
143/* masks for the node packet fields */
144#define  MP_NodeTypeMask         0x000000ff
145#define  MP_NodeNumChildMask     0x00000f00
146#define  MP_NodeNumAnnotMask     0x0000f000
147#define  MP_NodeDictTagMask      0x00ff0000
148#define  MP_NodeCommonValueMask  0xff000000
149
150
151#define MP_ExtraAnnotField   MP_ExtraFieldIndicator << MP_NodeAnnotFieldShift
152#define MP_ExtraChildField   MP_ExtraFieldIndicator << MP_NodeOpFieldShift
153#define MP_ExtraDictTagField MP_ExtraFieldIndicator << MP_NodeDictTagFieldShift
154
155
156/*
157*  The format of a node packet header is:
158*
159*  |    3           2            1              0    |
160*  +-----------+-----------|-------------+-----------+
161*  |  common   |dictionary |  ^   |  ^   |    Node   |
162*  |  value    |   tag     |  |   |  |   |    type   |
163*                             |      |- #children
164*                             |- #annots
165*/
166
167typedef unsigned char  MP_NodeType_t;
168typedef unsigned char  MP_CommonValue_t;
169typedef unsigned long  MP_NodeHeader_t;
170typedef unsigned long  MP_NumChild_t;
171typedef unsigned long  MP_NumAnnot_t;
172typedef unsigned long  MP_DictTag_t;      /* common to annotation packet header */
173
174/* macros for setting and getting the fields of a node header */
175
176#define MP_SetNodeTypeField(hdr, type)              \
177     (hdr = (hdr & ~MP_NodeTypeMask) | (long) type)
178
179#define MP_SetNodeNumChildField(hdr, nchild)                 \
180     (hdr =  (hdr & ~MP_NodeNumChildMask)                    \
181             | ((long) nchild << MP_NodeNumChildFieldShift))
182
183#define MP_SetNodeNumAnnotsField(hdr, nannots)            \
184     (hdr = (hdr & ~MP_NodeNumAnnotMask)                  \
185            | ((long) nannots << MP_NodeAnnotFieldShift))
186
187#define MP_SetNodeDictTagField(hdr, dtag)         \
188     (hdr = (hdr & ~MP_NodeDictTagMask)           \
189            | (dtag << MP_NodeDictTagFieldShift))
190
191#define MP_SetNodeExtraChildField(hdr)  \
192     (hdr |= (long) MP_ExtraChildField)
193
194#define MP_SetNodeExtraAnnotsField(hdr)  \
195     (hdr |= (long) MP_ExtraAnnotField)
196
197#define MP_SetNodeCommonValueField(hdr, value)                 \
198     (hdr = (hdr & ~MP_NodeCommonValueMask)                    \
199            | ((long) value <<  MP_NodeCommonValueFieldShift))
200
201#define MP_GetNodeFieldType(hdr) \
202     (hdr & MP_NodeTypeMask)
203
204#define MP_GetNodeNumAnnotsField(hdr) \
205     ((hdr & MP_NodeNumAnnotMask) >> MP_NodeAnnotFieldShift)
206
207#define MP_GetNodeNumChildField(hdr) \
208     ((hdr & MP_NodeNumChildMask) >> MP_NodeOpFieldShift)
209
210#define MP_GetNodeDictTagField(hdr) \
211     ((hdr & MP_NodeDictTagMask) >> MP_NodeDictTagFieldShift)
212
213#define MP_GetNodeCommonValueField(hdr) \
214    ((hdr & MP_NodeCommonValueMask) >> MP_NodeCommonValueFieldShift)
215
216/* see MP_Annotations.h for the defines for annotations */
217
218/* Note:  plain cc (old style?) doesn't like signed char!! */
219typedef signed char      MP_Sint8_t;
220typedef unsigned char    MP_Uint8_t;
221typedef unsigned short   MP_Uint16_t;   /* aren't real MP types yet */
222typedef signed short     MP_Sint16_t;
223typedef long             MP_Sint32_t;
224typedef unsigned long    MP_Uint32_t;
225typedef float            MP_Real32_t;
226typedef double           MP_Real64_t;
227typedef unsigned char    MP_Boolean_t;
228typedef unsigned char    MP_Common_t;  /* for common types rep as a char */
229typedef void *           MP_ApInt_t;
230typedef MP_ApInt_t *   MP_ApInt_pt;
231typedef void *          MP_ApReal_t;
232typedef MP_ApReal_t *   MP_ApReal_pt;
233
234typedef struct MP_Link_t MP_Link_t;
235typedef MP_Link_t * MP_Link_pt;
236
237/*
238   encodings for the Multi dictionaries
239*/
240#define MP_BasicDict              0
241#define MP_NoSemanticsDict      128
242#define MP_ReceiverDict         129
243#define MP_UnavailSemanticsDict 130
244#define MP_LocalDict            155
245
246
247/*
248*  encodings for the Multi types plus some useful macros
249*/
250#define MP_Sint8Type                        65
251#define MP_Uint8Type                        67
252#define MP_BooleanType                      68
253#define MP_CommonLatinIdentifierType        72
254#define MP_CommonGreekIdentifierType        76
255#define MP_CommonConstantType               80
256#define MP_CommonMetaType                   84
257#define MP_CommonMetaOperatorType           88
258
259#define MP_StringType                       36
260#define MP_ConstantType                     40
261#define MP_IdentifierType                   44
262#define MP_MetaType                         48
263#define MP_MetaOperatorType                 52
264
265#define MP_Sint32Type                       17
266#define MP_Uint32Type                       19
267#define MP_Real32Type                       18
268
269#define MP_ApIntType                        9
270#define MP_ApRealType                       10
271
272#define  MP_Real64Type                      6
273
274#define MP_OperatorType                     128
275#define MP_CommonOperatorType               129
276
277#define MP_RawType                          134
278
279/* MP_ANY_TYPE is used by the internal get node packet routine */
280#define MP_ANY_TYPE                     255
281
282
283/* And here are some Handy Macros */
284/* Basic types, i.e. those which appear as a leaf of a data tree
285   have numerical values between 0 and 127 ,i.e. bit 8 is zero */
286#define MP_IsBasicType(type)    (!((type) & 128))
287
288/* native 8-bit types have numeric values between 64 and 127
289   i.e. bit 8 is zero and bit 7 is one */
290#define MP_Is8BitNumericType(type)    (!((type) & 128) && ((type) & 64))
291
292/* native String-based types have numeric values between 32 an 63,
293   i.e. bit 8,7 are zero, bit 6 is one */
294#define MP_IsStringBasedType(type)  (!((type) & 192) && ((type) & 32))
295
296/* native 32 bit types have numeric values beween 16 and 31, i.e. bits
297   8,7,6, are zero, bit 5 is one. Furthermore, integers have bit 1 set
298   to 1 and Reals have bit 1 set to 0 */
299#define MP_Is32BitNumericType(type)    (!((type) & 224) && ((type) & 16))
300
301
302/* Ap Numbers have bit 5-8 set to zero, bit 4 set to one */
303#define MP_IsApNumberType(type) (!((type) & 240) && ((type) & 8))
304
305/* Native 64-bit numbers have bit 4-8 set to zero, bit 3 set to one */
306#define MP_Is64BitNumericType(type)    (type == MP_Real64Type)
307
308/* Predicates for real and integers
309   Integers are odd numbers, reals are even numbers, not divisble by 4*/
310#define MP_IsRealType(type)   (MP_IsBasicType(type) &&    \
311                                 !((type) & 1) &&           \
312                                 ((type) >> 1) & 1)
313#define MP_IsIntegerType(type)(MP_IsBasicType(type) && ((type) & 1))
314
315#define MP_IsFixedIntegerType(type)                     \
316(MP_IsIntegerType(type) && ! (type == MP_ApIntType))
317
318#define MP_IsIdType(type)                       \
319(type  == MP_IdentifierType ||                  \
320 type == MP_CommonLatinIdentifierType ||        \
321 type == MP_CommonGreekIdentifierType)
322
323#define MP_IsCommonType(type) ((type >= 72 && type <= 88) || type == 129)
324#endif /* _MP_Types_h */
325
326/* Stuff included from h/MP_Annotations.h */
327/****************************************************************
328 *
329 *   HEADER FILE:  MP_Annotations.h
330 *
331 *        Define the MP-defined annotations and establish
332 *        macros to set and clear the annotation packet
333 *        flag fields.
334 *
335 *   Change Log:
336 *     5/9/96  sgray - Fixed macros to set/clear the annotation
337 *                     packet header flags field.
338 *                   - Added predicate macros for the flags field
339 *                     per suggestion from obachman (good friend
340 *                     and drinking buddy).
341 ****************************************************************/
342
343#ifndef _MP_Annotations_h
344#define _MP_Annotations_h
345
346/* global variables - maps annotation numbers to string
347 * identifying the annotation - used for testing.  See
348 * the corresponding dictionary for the defines.
349 */
350EXTERN char *MpAnnotations[];         /* MP_MpDict.h    */
351EXTERN char *ProtoAnnotations[];      /* MP_ProtoDict.h */
352
353/*
354 * Annotation structure
355 *  The format of a annotation packet  is:
356 *
357 *  |     3           2            1            0     |
358 *  +-----------+-----------|-------------+-----------+
359 *  |   flags   |dictionary |        Annot type       |
360 *  |           |   tag     |                         |
361 *
362 *  sizes, typedefs, and masks for the fields of an
363 *  annotation packet
364 */
365
366typedef  unsigned char  MP_AnnotFlags_t;
367typedef  unsigned short MP_AnnotType_t;
368typedef  unsigned long  MP_AnnotHeader_t;
369
370#define  MP_AnnotTypeMask    0x0000ffff
371#define  MP_AnnotDictTagMask 0x00ff0000
372#define  MP_AnnotFlagsMask   0xff000000
373
374/*  Format of an annotation packet by field */
375
376#define  MP_AnnotDictTagFieldShift     16
377#define  MP_AnnotFlagsFieldShift       24
378
379
380/*
381 * Annotation flags
382 *                                         0             1
383 */
384#define MP_AnnotRequired    0x0001  /* supplemental   required   */
385#define MP_AnnotValuated    0x0002  /* simple         valuated   */
386#define MP_AnnotTreeScope   0x0004  /* node           subtree    */
387
388
389/*
390 * macros to set and unset flag fields
391 */
392#define MP_SetAnnotRequired(aflags)    (aflags |= MP_AnnotRequired)
393#define MP_SetAnnotValuated(aflags)    (aflags |= MP_AnnotValuated)
394#define MP_SetAnnotTreeScope(aflags)   (aflags |= MP_AnnotTreeScope)
395#define MP_ClearAnnotRequired(aflags)  (aflags &= ~MP_AnnotRequired)
396#define MP_ClearAnnotValuated(aflags)  (aflags &= ~MP_AnnotValuated)
397#define MP_ClearAnnotTreeScope(aflags) (aflags &= ~MP_AnnotTreeScope)
398#define MP_ClearAnnotFlags(aflags)     (aflags &= 0x0000)
399
400/*
401 * macros to detrmine if an annotation flag is set
402 */
403#define MP_IsAnnotRequired(aflags)     (aflags & MP_AnnotRequired)
404#define MP_IsAnnotValuated(aflags)     (aflags & MP_AnnotValuated)
405#define MP_IsAnnotTreeScope(aflags)    (aflags & MP_AnnotTreeScope)
406
407/*
408 * macros to set the fields of an annotation packet header
409 */
410#define MP_SetAnnotTypeField(hdr, type) \
411     (hdr = (hdr & ~MP_AnnotTypeMask) | (long) type)
412
413#define MP_SetAnnotDictTagField(hdr, dtag) \
414     (hdr = (hdr & ~MP_AnnotDictTagMask) | (dtag << MP_AnnotDictTagFieldShift))
415
416#define MP_SetAnnotFlagsField(hdr, aflag)          \
417     (hdr = (hdr & ~MP_AnnotFlagsMask)             \
418     | ((long) aflag <<  MP_AnnotFlagsFieldShift))
419
420#define MP_GetAnnotFieldType(hdr) \
421     (hdr & MP_AnnotTypeMask)
422
423#define MP_GetAnnotDictTagField(hdr) \
424     ((hdr & MP_AnnotDictTagMask) >> MP_AnnotDictTagFieldShift)
425
426#define MP_GetAnnotFlagsField(hdr) \
427    ((hdr & MP_AnnotFlagsMask) >> MP_AnnotFlagsFieldShift)
428
429
430#endif /* _MP_Annotations_h */
431
432/* Stuff included from h/MP_Error.h */
433/***************************************************************************
434 *
435 *   HEADER FILE:  MP_Error.h
436 *
437 *        All the error encodings and the routines the set clear
438 *        and print errors.
439 *
440 *  Change Log:
441 *       10/18/95 OB      - put MP_Failure, MP_Success into enum MP_Errors
442 *       July 7, 1995  SG - updated MP_Errors to reflect newtypes
443 *                          in MP-1.0 and coelesced a few error types.
444 *                          Also made the necessary changes to
445 *                          MP_Error.h, MP_Put.c, MP_Get.c
446 *       July 21, 1995 SG - more additions/corrections.  Checked against
447 *                          MP_Error.c for accuracy (enums with corresponding
448 *                          error messages)
449 *
450 *       5/24/96 sgray - deleted a bunch of obsolete error codes (consolidated)
451 *
452 ***************************************************************************/
453
454#ifndef _MP_Error_h
455#define _MP_Error_h
456
457#include "MP.h"
458/*
459 *  for returning error status from most routines
460 */
461
462enum MP_Errors { MP_Failure,
463                 MP_Success,
464                 MP_UnknownType,
465                 MP_UnknownAnnotation,
466                 MP_UnknownRequiredAnnotation,
467                 MP_NullLink,
468                 MP_NullTransport,
469                 MP_CantOpenFile,
470                 MP_CantConnect,
471                 MP_MemAlloc,
472                 MP_CantConvert,
473                 MP_ValueOutOfRange,
474                 MP_CantPutNodeHeader,
475                 MP_CantPutNodePacket,
476                 MP_CantPutDataPacket,
477                 MP_CantPutAnnotationPacket,
478                 MP_CantGetNodeHeader,
479                 MP_CantGetNodePacket,
480                 MP_CantGetDataPacket,
481                 MP_CantGetAnnotationPacket,
482                 MP_NotRequestedPacketType,
483                 MP_CantConvertBadString,
484                 MP_CantWriteLink,
485                 MP_CantReadLink,
486                 MP_NotCommonIdentifier,
487                         MP_WrongBasicVectorType,
488                 MP_DummyBigNum,
489                 MP_CantSkipMsg,
490                 MP_CantInitMsg,
491                 MP_ExternalError,
492                 MP_MaxError };
493
494typedef enum MP_Errors  MP_Status_t;
495
496EXTERN char *MP_errlist[];
497
498
499#define CHK_ALLOC_MEM(link, ptr, len, ptr_type) {                \
500  if (ptr == NULL)                                               \
501    if ((ptr = IMP_MemAllocFnc(len * sizeof(ptr_type))) == NULL) \
502      return MP_SetError(link, MP_MemAlloc);                     \
503}
504
505#define TEST_MEM_ALLOC_ERROR(link, ptr) {    \
506   if (ptr == NULL)                          \
507      return MP_SetError(link, MP_MemAlloc); \
508}
509
510#define RETURN_OK(link)       \
511   return MP_ClearError(link)
512
513#define ERR_CHK(fnc_status) {    \
514   if (fnc_status != MP_Success) \
515      return MP_Failure;         \
516}
517
518#endif  /* _MP_Error_h */
519
520/* Stuff included from h/MP_BuffTypes.h */
521/****************************************************************
522 *
523 *   HEADER FILE:  MP_BuffTypes.h
524 *
525 *       Contains all declarations related to buffer and buffer pool.
526 *
527 ****************************************************************/
528#ifndef _MP_BuffTypes_h
529#define _MP_BuffTypes_h
530
531
532#define MP_MINIMUM_BUFF_SIZE       512
533#define MP_DEFAULT_BUFF_SIZE      1024
534#define MP_DEFAULT_MAX_FREE_BUFF    32
535#define MP_DEFAULT_INIT_FREE_BUFF   16
536
537struct buffer_handle {
538        char * the_buffer; /* ptr to block of memory */
539        char * buff;       /* byte aligned ptr to buffer */
540        struct buffer_handle *next;
541};
542
543typedef struct buffer_handle buffer_handle_t;
544typedef buffer_handle_t  *buffer_handle_pt;
545
546struct buffer_pool {
547        int      buff_size;           /* buffer size */
548        int      max_free_buff;       /* max. no. of free buff. */
549        int      curr_free_buff;      /* current no. of free buff. */
550        buffer_handle_pt   buff;      /* ptr to list of buff handle */
551};
552
553typedef struct buffer_pool buffer_pool_t;
554typedef buffer_pool_t *buffer_pool_pt;
555
556#endif
557
558/* Stuff included from h/MP_Memory.h */
559/****************************************************************
560 *
561 *   HEADER FILE:  MP_Memory.h
562 *
563 ***************************************************************/
564
565
566#ifndef _MP_Memory_h
567#define _MP_Memory_h
568
569#ifdef EXTERNAL_MALLOC_H
570#include EXTERNAL_MALLOC_H
571#else
572
573EXTERN void* (*IMP_MemAllocFnc) _ANSI_ARGS_((size_t));
574EXTERN void* (*IMP_MemReallocFnc) _ANSI_ARGS_((void *, size_t, size_t));
575EXTERN void  (*IMP_MemFreeFnc) _ANSI_ARGS_((void *, size_t));
576
577EXTERN void* (*IMP_RawMemAllocFnc) _ANSI_ARGS_((size_t));
578EXTERN void* (*IMP_RawMemReallocFnc) _ANSI_ARGS_((void *, size_t));
579EXTERN void  (*IMP_RawMemFreeFnc) _ANSI_ARGS_((void *));
580
581#endif /* EXTERNAL_MALLOC_H */
582
583#endif /* _MP_Memory_h */
584
585
586
587
588/* Stuff included from h/MP_BigNum.h */
589/****************************************************************
590 *
591 *   HEADER FILE:  MP_BigNum.h
592 *
593 * The relevant declarations for the handling of BigNums
594 *
595 ****************************************************************/
596
597#ifndef _MP_BigNum_h
598#define _MP_BigNum_h
599
600#include "MP.h"
601
602/* Note: a type_to_string conversion array using the ordering given */
603/* below is defined in MP_Env.c.  So if you change the order below, */
604/* make the corresponding change in MP_Env.c, okay?                 */
605
606typedef MP_Uint8_t MP_BigNumFormat_t;
607
608typedef struct MP_BigIntOps_t
609{
610    MP_Status_t  (*put_bigint)(MP_Link_pt, MP_ApInt_t);
611    MP_Status_t  (*get_bigint)(MP_Link_pt link, MP_ApInt_t *bigint);
612    char*        (*bigint_to_str)(MP_ApInt_t bigint, char *buffer);
613    long         (*bigint_ascii_size)(MP_ApInt_t bigint);
614} MP_BigIntOps_t;
615typedef MP_BigIntOps_t * MP_BigIntOps_pt;
616
617EXTERN MP_BigIntOps_t imp_default_bigint_ops;
618EXTERN MP_BigNumFormat_t imp_default_bigint_format;
619
620typedef struct   MP_BigRealOps_t
621{
622    MP_Status_t  (*put_bigreal)(MP_Link_pt link, MP_ApReal_t bigreal);
623    MP_Status_t  (*get_bigreal)(MP_Link_pt link, MP_ApReal_t *bigreal);
624    char*        (*bigreal_to_str)(MP_ApReal_t bigreal, char *buffer);
625    long         (*bigreal_ascii_size)(MP_ApReal_t bigreal);
626} MP_BigRealOps_t;
627typedef MP_BigRealOps_t * MP_BigRealOps_pt;
628
629EXTERN MP_BigRealOps_t imp_default_bigreal_ops;
630EXTERN MP_BigNumFormat_t imp_default_bigreal_format;
631
632typedef struct  MP_BigNum_t
633{
634    MP_BigNumFormat_t native_bigint_format;
635    MP_BigIntOps_pt   bigint_ops;
636    MP_BigNumFormat_t native_bigreal_format;
637    MP_BigRealOps_pt  bigreal_ops;
638} MP_BigNum_t;
639
640EXTERN MP_Status_t IMP_PutDummyBigInt(MP_Link_pt link, MP_ApInt_t dummy);
641EXTERN MP_Status_t IMP_GetDummyBigInt(MP_Link_pt link, MP_ApInt_t *dummy);
642EXTERN char* IMP_DummyBigIntToStr(MP_ApInt_t dummy, char *buf);
643EXTERN long IMP_DummyBigIntAsciiSize(MP_ApInt_t dummy);
644EXTERN MP_Status_t IMP_PutDummyBigReal(MP_Link_pt link, MP_ApReal_t dummy);
645EXTERN MP_Status_t IMP_GetDummyBigReal(MP_Link_pt link, MP_ApReal_t *dummy);
646EXTERN char* IMP_DummyBigRealToStr(MP_ApReal_t dummy, char *buf);
647EXTERN long IMP_DummyBigRealAsciiSize(MP_ApReal_t dummy);
648
649
650#endif /* _MP_BigNum_h */
651
652/* Stuff included from h/MP_Env.h */
653/***************************************************************************
654 *
655 *   HEADER FILE:  MP_Env.h
656 *
657 *        Declarations to maintain the MP environment.  The environment
658 *        includes the name of the host machine, the log file name and
659 *      file descriptor and the buffer pool containing all the buffers
660 *      to be shared among the links.  The initialization should be
661 *      done once before any MP-related activities occur.
662 *
663 *  Change Log:
664 *       September 10, 1995  SG - Updated implementation.  Much cleaning
665 *                                to make it presentable.
666 *       November 25, 1995   SG - Added field in env struct to support
667 *                                negotiation of endian order.
668 *       April 32, 1996      SG - Added support to handle different
669 *                                Big Integer packages.  See note in
670 *                                MP_SacBigInt.c for some details.
671 ***************************************************************************/
672#ifndef _MP_Env_h
673#define _MP_Env_h
674
675
676
677#include "MP.h"
678
679#define MP_HOST_NAME_LEN    64
680#define MP_INIT_LOGFILE_EXT 100
681
682/* These are the transport types currently supported   */
683/* These are the values stored in transp_dev.         */
684/* If you add to this list, you must also add a string */
685/* equivalent to transp_dev2string[] in MP_Link.c.    */
686
687#define MP_TcpTransportDev   0
688#define MP_FileTransportDev  1
689#define MP_PvmTransportDev   2
690#define MP_TbTransportDev    3
691
692
693/*
694 * Options that can be set for an environment
695 */
696#define MP_BUFFER_SIZE_OPT       1
697#define MP_MAX_FREE_BUFFERS_OPT  2
698#define MP_INIT_FREE_BUFFERS_OPT 3
699
700typedef struct  {
701    long         (*write_buf)VARARGS;       /* write buffer to transport   */
702    long         (*read_buf)VARARGS;        /* read transport to buffer    */
703    MP_Status_t  (*flush_buf)VARARGS;       /* flush buffer to transport   */
704    MP_Boolean_t (*get_status)VARARGS;      /* check status of the link    */
705    MP_Status_t  (*open_transp)VARARGS;     /* open the transport device   */
706    MP_Status_t  (*close_transp)VARARGS;    /* close the transport device  */
707    MP_Status_t  (*kill_transp)VARARGS;    /* kill the transport device  */
708} MP_TranspOps_t;
709
710
711typedef struct {
712    int            transp_dev;
713    MP_TranspOps_t *transp_ops;
714    char           *private1;    /* for opaque transport-specific structure */
715} MP_Transport_t;
716
717typedef struct transp_list_elem *MP_TranspList_pt;
718
719struct transp_list_elem {
720    int               transp_dev;
721    MP_TranspOps_t    transp_ops;
722    MP_TranspList_pt *next;
723};
724
725
726typedef struct mp_environment {
727    MP_TranspList_pt transp_dev_list; /* list of supported transport devices */
728    buffer_pool_pt   buff_pool;       /* buffer pool shared by  links in this
729                                       *  env
730                                       */
731    int   num_o_buff;
732    int   buffer_size;                /* size of each buffer in the pool     */
733    int   max_free_buffers;           /* max number of free buffers in the
734                                       * pool
735                                       */
736
737    int   init_free_buffers;          /* initial number of free buffers in the
738                                       * pool
739                                       */
740
741    int   num_links;                  /* to handout unique link ids for this
742                                       * env
743                                       */
744
745    FILE  *logfd;                     /* log file for all logging events     */
746    char  *logfilename;
747    char  thishost[MP_HOST_NAME_LEN];
748    MP_Boolean_t initialized;         /* can't set options after env has been
749                                       * init
750                                       */
751
752    MP_WordOrder_t native_word_order; /* what this machine uses internally   */
753    MP_FpFormat_t  native_fp_format;  /* floating pnt format used internally */
754    MP_BigNum_t    bignum;            /* info on bignum package to be used   */
755} MP_Env_t;
756
757typedef MP_Env_t *MP_Env_pt;
758typedef MP_Env_pt MP_ENV;
759
760EXTERN MP_ENV MP_AllocateEnv _ANSI_ARGS_((void));
761EXTERN MP_ENV MP_InitializeEnv _ANSI_ARGS_((MP_Env_pt env));
762EXTERN void MP_ReleaseEnv _ANSI_ARGS_((MP_Env_pt env));
763EXTERN int MP_SetEnvOption _ANSI_ARGS_((MP_Env_pt env, int option, int value));
764EXTERN int    MP_GetEnvOption _ANSI_ARGS_((MP_Env_pt env, int option));
765EXTERN MP_TranspList_pt IMP_GetTranspByName _ANSI_ARGS_((MP_Env_pt env,
766                                                         int transp_dev));
767EXTERN MP_Status_t MP_AddEnvTranspDevice _ANSI_ARGS_((MP_Env_pt env,
768                                        int transp_dev, MP_TranspOps_t *ops));
769EXTERN MP_Status_t MP_SetEnvBigIntFormat _ANSI_ARGS_((MP_Env_t *env,
770                             MP_BigIntOps_t *ops, MP_BigNumFormat_t format));
771EXTERN MP_Status_t MP_SetEnvBigRealFormat _ANSI_ARGS_((MP_Env_t *env,
772                             MP_BigRealOps_t *ops, MP_BigNumFormat_t format));
773EXTERN MP_Status_t open_logfile _ANSI_ARGS_((MP_ENV env));
774#endif /* _MP_Env_h */
775
776/* Stuff included from h/MP_Link.h */
777/****************************************************************
778 *
779 *   HEADER FILE:  MP_Link.h
780 *
781 *   struct link is adapted from the Sun XDR distribution.
782 *   Copyright (C) 1984, Sun Microsystems, Inc.
783 *
784 ***************************************************************/
785
786#ifndef _MP_Link_h
787#define _MP_Link_h
788
789/* Sending modes */
790#define MP_SEND_FRAG_MSG      1
791#define MP_SEND_WHOLE_MSG     2
792#define MP_DEFAULT_SEND_MODE  MP_SEND_FRAG_MSG
793
794/* Receiving modes */
795#define MP_RECV_FRAG_MSG_RECVER   1
796#define MP_RECV_FRAG_MSG_SENDER   2
797#define MP_RECV_WHOLE_MSG         3
798#define MP_DEFAULT_RECV_MODE      MP_RECV_FRAG_MSG_RECVER
799
800/* Options that can be set for a link */
801#define MP_LINK_SEND_MODE_OPT 1
802#define MP_LINK_RECV_MODE_OPT 2
803#define MP_LINK_LOG_MASK_OPT  3
804
805#define  eor_mask ((unsigned long)(1 << 31))
806
807
808struct MP_Link_t
809{
810    int               link_id;
811    int               MP_errno;
812    MP_Env_pt         env;
813    MP_Transport_t    transp;
814    MP_BigNum_t       bignum;       /* bignum type & fncs struct  */
815    int               logmask;
816    buffer_handle_pt  i_buff;       /* ptr to list of input buff  */
817    buffer_handle_pt  o_buff;       /* ptr to list of output buff */
818    buffer_handle_pt  curr_o_buff;  /* current output buffer      */
819    buffer_handle_pt  curr_i_buff;  /* current input buffer       */
820    int               num_o_buff;   /* number of o_buff to keep with stream */
821
822    int snd_mode; /* Two possible values:
823                   * MP_SEND_FRAG_MSG - send a fragment at a time
824                   * MP_SEND_WHOLE_MSG - send a tree at a time
825                   */
826
827    int rcv_mode; /* Three possible value:
828                   * MP_RECV_FRAG_MSG_RECVER - read one sender's
829                   * fragment at a time,
830                   * MP_RECV_FRAG_MSG_SENDER - read one reciever's
831                   * fragment at a time,
832                   * MP_RECV_WHOLE_MSG - read a tree at a time.
833                   */
834    /*
835     * out-going bits
836     */
837    char   *out_base;         /* output buffer (points to frag header) */
838    char   *out_finger;       /* next output position */
839    char   *out_boundry;      /* data can go up to this address */
840    unsigned long  *o_frag_header;    /* beginning of current fragment */
841
842    /*
843     * in-coming bits
844     */
845    char   *in_base;          /* input buffer (points to frag header) */
846    char   *in_finger;        /* location of next byte to be had */
847    char   *in_boundry;       /* can read up to this location */
848    unsigned long  *i_frag_header;    /* points to fragment header */
849
850    long         fbtbc;        /* fragment bytes to be consumed */
851    long         sfblr;        /* sender's fragment bytes left to be read */
852    MP_Boolean_t last_frag;    /* tell if curr. input buff. is last of tree */
853    MP_Boolean_t s_last_frag;  /* tell if current input buffer is part of
854                                  sender's last frag. of tree */
855
856    /* the next three are inherited from the link's  environment, but
857     * are resettable and, in some cases, negotiated with the partner
858     */
859    MP_WordOrder_t    link_word_order;
860    MP_FpFormat_t     link_fp_format;
861    MP_BigNumFormat_t link_bigint_format;   /* format of SENDER! */
862    MP_BigNumFormat_t link_bigreal_format;
863};
864
865#define TEST_LINK_NULL(link) \
866   if (link == NULL) return (MP_NullLink)
867
868EXTERN MP_Link_pt MP_OpenLink _ANSI_ARGS_((MP_Env_pt env, int argc,
869                                             char **argv));
870
871EXTERN void MP_CloseLink _ANSI_ARGS_((MP_Link_pt link));
872
873EXTERN void MP_KillLink _ANSI_ARGS_((MP_Link_pt link));
874
875EXTERN MP_Status_t MP_PeekHeader _ANSI_ARGS_((MP_Link_pt link,
876                                              MP_NodeType_t *ntype,
877                                              MP_DictTag_t *dtag,
878                                              MP_Common_t *cval));
879
880EXTERN MP_Status_t MP_InitMsg _ANSI_ARGS_((MP_Link_pt link));
881
882EXTERN MP_Status_t MP_SkipMsg _ANSI_ARGS_((MP_Link_pt link));
883
884EXTERN MP_Status_t MP_EndMsg _ANSI_ARGS_((MP_Link_pt link));
885
886EXTERN MP_Status_t MP_EndMsgReset _ANSI_ARGS_((MP_Link_pt link));
887
888EXTERN MP_Boolean_t MP_TestEofMsg _ANSI_ARGS_((MP_Link_pt link));
889
890EXTERN int MP_SetLinkOption _ANSI_ARGS_((MP_Link_pt link, int option,
891                                         int value));
892
893EXTERN int MP_GetLinkOption _ANSI_ARGS_((MP_Link_pt link, int option));
894
895EXTERN MP_Boolean_t MP_GetLinkStatus _ANSI_ARGS_((MP_Link_pt link,
896                                            MP_LinkStatus_t status_to_check));
897
898EXTERN MP_Status_t IMP_GetLong _ANSI_ARGS_((MP_Link_pt link, long *lp));
899
900EXTERN MP_Status_t IMP_PutLong _ANSI_ARGS_((MP_Link_pt link, long *lp));
901
902EXTERN MP_Status_t IMP_GetBytes _ANSI_ARGS_((MP_Link_pt link, char *addr,
903                                             unsigned long len));
904
905EXTERN MP_Status_t IMP_PutBytes _ANSI_ARGS_((MP_Link_pt link, const char *addr,
906                                             unsigned long len));
907
908EXTERN MP_Status_t IMP_Restore _ANSI_ARGS_((MP_Link_pt link, unsigned long n));
909#endif  /* _MP_Link_h */
910
911/* Stuff included from h/MP_Buffer.h */
912/****************************************************************
913 *
914 *   HEADER FILE:  MP_Buffer.h
915 *
916 *       Contains all declarations related to buffer and buffer pool.
917 *
918 ****************************************************************/
919#ifndef _MP_Buffer_h
920#define _MP_Buffer_h
921
922#ifndef _MP_BuffTypes_h
923#include "MP_BuffTypes.h"
924#endif
925
926EXTERN MP_Status_t m_create_pool _ANSI_ARGS_((MP_Env_pt env, int buffer_size,
927                                       int max_free_buff, int init_free_buff));
928EXTERN void m_free_pool     _ANSI_ARGS_((buffer_pool_pt buff_pool));
929EXTERN void m_free_in_bufs  _ANSI_ARGS_((MP_Link_pt link));
930EXTERN int MP_ResetLink     _ANSI_ARGS_((MP_Link_pt link));
931EXTERN void destroy_buffer  _ANSI_ARGS_((buffer_handle_pt buff, long buffsize));
932EXTERN void free_buffer     _ANSI_ARGS_((buffer_pool_pt buff_pool,
933                                         buffer_handle_pt buff));
934EXTERN buffer_handle_pt create_buffer _ANSI_ARGS_((buffer_pool_pt buff_pool));
935EXTERN buffer_handle_pt get_buffer    _ANSI_ARGS_((buffer_pool_pt buff_pool));
936EXTERN buffer_handle_pt get_o_buff    _ANSI_ARGS_((MP_Link_pt link));
937EXTERN buffer_handle_pt get_i_buff    _ANSI_ARGS_((MP_Link_pt link));
938EXTERN MP_Status_t reset_i_buff       _ANSI_ARGS_((MP_Link_pt link));
939
940#endif /* _MP_Buffer_h */
941
942/* Stuff included from h/MP_Util.h */
943/****************************************************************
944 *
945 *   HEADER FILE:  MP_Util.h
946 *
947 ***************************************************************/
948
949#ifndef _MP_Util_h
950#define _MP_Util_h
951
952/* defines for logging events */
953#define MP_ERROR_EVENT   "ErrorE "
954#define MP_WRITE_EVENT   "WriteE "
955#define MP_READ_EVENT    "ReadE  "
956#define MP_INIT_EVENT    "InitE  "
957#define MP_URGENT_EVENT  "UrgentE"
958#define MP_CONTROL_EVENT "CntrlE "
959
960/*
961 * Logging is done on a per link basis.  The user is allowed to
962 * specify which events to log.  The default is to log all events.
963 * Error events are always logged and cannot be disabled.
964 */
965
966#define MP_LOG_READ_EVENTS         1
967#define MP_LOG_WRITE_EVENTS        2
968#define MP_LOG_INIT_EVENTS         4
969#define MP_LOG_CONTROL_EVENTS      8
970#define MP_LOG_URGENT_EVENTS      16
971#define MP_LOG_ALL_EVENTS         31
972#define MP_LOG_NO_EVENTS           0
973#define MP_LOG_NO_READ_EVENTS     ~MP_LOG_READ_EVENTS
974#define MP_LOG_NO_WRITE_EVENTS    ~MP_LOG_WRITE_EVENTS
975#define MP_LOG_NO_INIT_EVENTS     ~MP_LOG_INIT_EVENTS
976#define MP_LOG_NO_CONTROL_EVENTS  ~MP_LOG_CONTROL_EVENTS
977#define MP_LOG_NO_URGENT_EVENTS   ~MP_LOG_URGENT_EVENTS
978
979#define log_msg_len 128
980
981EXTERN char *IMP_StrDup  _ANSI_ARGS_((char* s));
982
983EXTERN void MP_LogEvent _ANSI_ARGS_((MP_Link_pt link, char *event, char *msg));
984
985EXTERN MP_Status_t MP_SetError _ANSI_ARGS_((MP_Link_pt link,
986                                            MP_Status_t the_err));
987
988#define MP_ClearError(link) ((MP_Status_t) ((link)->MP_errno = (int)MP_Success))
989
990EXTERN void MP_PrintError _ANSI_ARGS_((MP_Link_pt link));
991
992EXTERN char* MP_ErrorStr _ANSI_ARGS_((MP_Link_pt link));
993
994EXTERN char* MP_StatusErrorStr _ANSI_ARGS_((MP_Link_pt link, MP_Status_t status));
995
996EXTERN char *IMP_GetCmdlineArg _ANSI_ARGS_((int argc, char **argv, char *cmd));
997
998EXTERN char *IMP_TypeToString  _ANSI_ARGS_((MP_NodeType_t t));
999
1000/* the following are used internally by MP for logging */
1001
1002EXTERN void log_dicttype _ANSI_ARGS_((MP_Link_pt link, char *event,
1003                                      char *type_str, MP_NodeType_t type,
1004                                      MP_NumAnnot_t na, MP_DictTag_t dtag,
1005                                      void *data, MP_NumChild_t nc));
1006
1007EXTERN void log_fixnum _ANSI_ARGS_((MP_Link_pt link, char *event,
1008                                    char *type_str, int type, MP_NumAnnot_t na,
1009                                    void *val));
1010
1011EXTERN void log_fixreal _ANSI_ARGS_((MP_Link_pt link, char *event,
1012                                     char *type_str, int type, MP_NumAnnot_t na,
1013                                     void *val));
1014
1015EXTERN void annot_flags_to_str _ANSI_ARGS_((MP_AnnotFlags_t flags));
1016
1017#endif /* _MP_Util_h */
1018
1019/* Stuff included from h/MP_Put.h */
1020/****************************************************************
1021 *
1022 *   HEADER FILE:  MP_Put.h
1023 *
1024 ***************************************************************/
1025
1026#ifndef _MP_Put_h
1027#define _MP_Put_h
1028
1029#include "MP.h"
1030
1031EXTERN MP_Status_t  MP_PutAnnotationPacket _ANSI_ARGS_((MP_Link_pt link,
1032                                                        MP_DictTag_t dtag,
1033                                                        MP_AnnotType_t atype,
1034                                                        MP_AnnotFlags_t flags));
1035
1036EXTERN MP_Status_t  MP_PutApIntPacket _ANSI_ARGS_((MP_Link_pt link,
1037                                                   MP_ApInt_t apint,
1038                                                   MP_NumAnnot_t  num_annots));
1039
1040EXTERN MP_Status_t  MP_PutApRealPacket _ANSI_ARGS_((MP_Link_pt link,
1041                                                    MP_ApReal_t apreal,
1042                                                    MP_NumAnnot_t num_annots));
1043
1044EXTERN MP_Status_t  MP_PutSint32Packet _ANSI_ARGS_((MP_Link_pt link,
1045                                                    MP_Sint32_t  n,
1046                                                    MP_NumAnnot_t  num_annots));
1047
1048EXTERN MP_Status_t  MP_PutUint32Packet _ANSI_ARGS_((MP_Link_pt link,
1049                                                    MP_Uint32_t  n,
1050                                                    MP_NumAnnot_t  num_annots));
1051
1052EXTERN MP_Status_t  MP_PutSint8Packet _ANSI_ARGS_((MP_Link_pt link,
1053                                                   MP_Sint8_t n,
1054                                                   MP_NumAnnot_t  num_annots));
1055
1056EXTERN MP_Status_t  MP_PutUint8Packet _ANSI_ARGS_((MP_Link_pt link,
1057                                                   MP_Uint8_t n,
1058                                                   MP_NumAnnot_t  num_annots));
1059
1060EXTERN MP_Status_t  MP_PutBooleanPacket _ANSI_ARGS_((MP_Link_pt link,
1061                                                     MP_Boolean_t n,
1062                                                     MP_NumAnnot_t num_annots));
1063
1064EXTERN MP_Status_t  MP_PutReal32Packet _ANSI_ARGS_((MP_Link_pt link,
1065                                                    MP_Real32_t n,
1066                                                    MP_NumAnnot_t  num_annots));
1067
1068EXTERN MP_Status_t  MP_PutReal64Packet _ANSI_ARGS_((MP_Link_pt link,
1069                                                    MP_Real64_t n,
1070                                                    MP_NumAnnot_t  num_annots));
1071
1072EXTERN MP_Status_t  MP_PutOperatorPacket _ANSI_ARGS_((MP_Link_pt link,
1073                                                      MP_DictTag_t dtag,
1074                                                      char *op,
1075                                                      MP_NumAnnot_t num_annots,
1076                                                      MP_NumChild_t num_child));
1077EXTERN MP_Status_t  MP_PutMetaOperatorPacket _ANSI_ARGS_((MP_Link_pt link,
1078                                                      MP_DictTag_t dtag,
1079                                                      char *op,
1080                                                      MP_NumAnnot_t num_annots,
1081                                                      MP_NumChild_t num_child));
1082
1083EXTERN MP_Status_t  MP_PutCommonOperatorPacket _ANSI_ARGS_((MP_Link_pt link,
1084                                                            MP_DictTag_t dtag,
1085                                                            MP_Common_t op,
1086                                                            MP_NumAnnot_t num_annots,
1087                                                            MP_NumChild_t num_child));
1088
1089EXTERN MP_Status_t  MP_PutCommonMetaOperatorPacket _ANSI_ARGS_((MP_Link_pt link,
1090                                                            MP_DictTag_t dtag,
1091                                                            MP_Common_t op,
1092                                                            MP_NumAnnot_t num_annots,
1093                                                            MP_NumChild_t num_child));
1094EXTERN MP_Status_t  MP_PutCommonMetaTypePacket _ANSI_ARGS_((MP_Link_pt link,
1095                                                        MP_DictTag_t dtag,
1096                                                        MP_Common_t cm,
1097                                                        MP_NumAnnot_t num_annots));
1098
1099EXTERN MP_Status_t  MP_PutRawPacket _ANSI_ARGS_((MP_Link_pt link,
1100                                                 char *data,
1101                                                 MP_Uint32_t len,
1102                                                 MP_NumAnnot_t  num_annots));
1103
1104EXTERN MP_Status_t  MP_PutConstantPacket _ANSI_ARGS_((MP_Link_pt link,
1105                                                      MP_DictTag_t dtag,
1106                                                      char *cnst,
1107                                                      MP_NumAnnot_t num_annots));
1108
1109EXTERN MP_Status_t  MP_PutCommonConstantPacket _ANSI_ARGS_((MP_Link_pt link,
1110                                                            MP_DictTag_t dtag,
1111                                                            MP_Common_t cnst,
1112                                                            MP_NumAnnot_t num_annots));
1113
1114EXTERN MP_Status_t  MP_PutIdentifierPacket _ANSI_ARGS_((MP_Link_pt link,
1115                                                        MP_DictTag_t dtag,
1116                                                        const char *id,
1117                                                        MP_NumAnnot_t num_annots));
1118
1119EXTERN MP_Status_t  MP_PutCommonLatinIdentifierPacket _ANSI_ARGS_((MP_Link_pt link,
1120                                                                   MP_DictTag_t dtag,
1121                                                                   MP_Common_t id,
1122                                                                   MP_NumAnnot_t  num_annots));
1123
1124EXTERN MP_Status_t  MP_PutCommonGreekIdentifierPacket _ANSI_ARGS_((MP_Link_pt link,
1125                                                                   MP_DictTag_t dtag,
1126                                                                   MP_Common_t id,
1127                                                                   MP_NumAnnot_t  num_annots));
1128
1129EXTERN MP_Status_t  MP_PutStringPacket _ANSI_ARGS_((MP_Link_pt link,
1130                                                    char *s,
1131                                                    MP_NumAnnot_t  num_annots));
1132
1133EXTERN MP_Status_t  MP_PutMetaTypePacket _ANSI_ARGS_((MP_Link_pt link,
1134                                                  MP_DictTag_t dtag, char *s,
1135                                                  MP_NumAnnot_t  num_annots));
1136
1137EXTERN MP_Status_t  IMP_PutString _ANSI_ARGS_((MP_Link_pt link,
1138                                               char *s));
1139
1140EXTERN MP_Status_t  IMP_PutOperator _ANSI_ARGS_((MP_Link_pt link,
1141                                                 char *op));
1142
1143EXTERN MP_Status_t  IMP_PutMetaOperator _ANSI_ARGS_((MP_Link_pt link,
1144                                                     char *op));
1145
1146EXTERN MP_Status_t  IMP_PutApInt _ANSI_ARGS_((MP_Link_pt link,
1147                                              MP_ApInt_t apint));
1148
1149EXTERN MP_Status_t  IMP_PutApReal _ANSI_ARGS_((MP_Link_pt link,
1150                                               MP_ApReal_t apreal));
1151
1152EXTERN MP_Status_t  IMP_PutBoolean _ANSI_ARGS_((MP_Link_pt link,
1153                                                MP_Boolean_t n));
1154
1155EXTERN MP_Status_t  IMP_PutSint8 _ANSI_ARGS_((MP_Link_pt link,
1156                                              MP_Sint8_t  n));
1157
1158EXTERN MP_Status_t  IMP_PutUint8 _ANSI_ARGS_((MP_Link_pt link,
1159                                              MP_Uint8_t  n));
1160
1161EXTERN MP_Status_t  IMP_PutSint32 _ANSI_ARGS_((MP_Link_pt link,
1162                                               MP_Sint32_t n));
1163
1164EXTERN MP_Status_t  IMP_PutUint32 _ANSI_ARGS_((MP_Link_pt link,
1165                                               MP_Uint32_t n));
1166
1167EXTERN MP_Status_t  IMP_PutReal32 _ANSI_ARGS_((MP_Link_pt link,
1168                                               MP_Real32_t n));
1169
1170EXTERN MP_Status_t  IMP_PutReal64 _ANSI_ARGS_((MP_Link_pt link,
1171                                               MP_Real64_t n));
1172
1173EXTERN MP_Status_t  IMP_PutRaw _ANSI_ARGS_((MP_Link_pt link,
1174                                            char *rawdata,
1175                                            MP_Uint32_t len));
1176
1177EXTERN MP_Status_t  IMP_PutNodeHeader _ANSI_ARGS_((MP_Link_pt link,
1178                                                   MP_NodeType_t ntype,
1179                                                   MP_DictTag_t dtag,
1180                                                   MP_Common_t cval,
1181                                                   MP_NumAnnot_t num_annots,
1182                                                   MP_NumChild_t num_child));
1183
1184EXTERN MP_Status_t  IMP_PutStringBasedTypePacket _ANSI_ARGS_((MP_Link_pt link,
1185                                                              char *s,
1186                                                              MP_NumAnnot_t num_annots,
1187                                                              MP_NodeType_t ntype));
1188
1189/*
1190*  defines for putting a string-based type to the data stream.
1191*  The prototype
1192*        IMP_PutStringBasedTypePacket  (MP_Link_pt link, char *s,
1193*                MP_NumAnnot_t  num_annots, MP_NodeType _t ntype)
1194*  clarifies the type of the arguments.
1195*/
1196
1197#define IMP_PutIdentifier(link, id) \
1198   (IMP_PutString(link, id))
1199
1200#define IMP_PutMetaType(link, meta) \
1201   (IMP_PutString(link, meta))
1202
1203#endif  /* _MP_put_h */
1204
1205/* Stuff included from h/MP_Get.h */
1206/****************************************************************
1207 *
1208 *   HEADER FILE:  MP_Get.h
1209 *
1210 ***************************************************************/
1211
1212#ifndef _MP_Get_h
1213#define _MP_Get_h
1214
1215EXTERN MP_Status_t  MP_GetAnnotationPacket _ANSI_ARGS_((MP_Link_pt link,
1216                                MP_DictTag_t *dtag, MP_AnnotType_t *atype,
1217                                MP_AnnotFlags_t *flags));
1218
1219EXTERN MP_Status_t  MP_GetApIntPacket _ANSI_ARGS_((MP_Link_pt link,
1220                        MP_ApInt_pt apint, MP_NumAnnot_t *num_annots));
1221
1222EXTERN MP_Status_t  MP_GetApRealPacket _ANSI_ARGS_((MP_Link_pt link,
1223                        MP_ApReal_pt apreal, MP_NumAnnot_t *num_annots));
1224
1225EXTERN MP_Status_t  MP_GetSint32Packet _ANSI_ARGS_((MP_Link_pt link,
1226                                    MP_Sint32_t *n, MP_NumAnnot_t *num_annots));
1227
1228EXTERN MP_Status_t  MP_GetUint32Packet _ANSI_ARGS_((MP_Link_pt link,
1229                                    MP_Uint32_t *n, MP_NumAnnot_t *num_annots));
1230
1231EXTERN MP_Status_t  MP_GetSint8Packet _ANSI_ARGS_((MP_Link_pt link,
1232                                    MP_Sint8_t *n,  MP_NumAnnot_t *num_annots));
1233
1234EXTERN MP_Status_t  MP_GetUint8Packet _ANSI_ARGS_((MP_Link_pt link,
1235                                     MP_Uint8_t *n, MP_NumAnnot_t *num_annots));
1236
1237EXTERN MP_Status_t MP_GetBooleanPacket _ANSI_ARGS_((MP_Link_pt link,
1238                                   MP_Boolean_t *n, MP_NumAnnot_t *num_annots));
1239
1240EXTERN MP_Status_t  MP_GetReal32Packet _ANSI_ARGS_((MP_Link_pt link,
1241                                    MP_Real32_t *n, MP_NumAnnot_t *num_annots));
1242
1243EXTERN MP_Status_t  MP_GetReal64Packet _ANSI_ARGS_((MP_Link_pt link,
1244                                    MP_Real64_t *n, MP_NumAnnot_t *num_annots));
1245
1246EXTERN MP_Status_t  MP_GetOperatorPacket _ANSI_ARGS_((MP_Link_pt link,
1247                           MP_DictTag_t *dtag, char **op,
1248                          MP_NumAnnot_t *num_annots, MP_NumChild_t *num_child));
1249
1250EXTERN MP_Status_t MP_GetCommonOperatorPacket _ANSI_ARGS_((MP_Link_pt link,
1251                         MP_DictTag_t *dtag, MP_Common_t *op,
1252                         MP_NumAnnot_t *num_annots,  MP_NumChild_t *num_child));
1253
1254EXTERN MP_Status_t MP_GetCommonMetaTypePacket _ANSI_ARGS_((MP_Link_pt link,
1255                                        MP_DictTag_t *dtag, MP_Common_t *cmt,
1256                                                  MP_NumAnnot_t *num_annots));
1257
1258EXTERN MP_Status_t MP_GetIdentifierPacket _ANSI_ARGS_((MP_Link_pt link,
1259                                              MP_DictTag_t *dtag, char **id,
1260                                              MP_NumAnnot_t *num_annots));
1261
1262EXTERN MP_Status_t MP_GetCommonLatinIdentifierPacket _ANSI_ARGS_((MP_Link_pt
1263                                 link,  MP_DictTag_t *dtag, MP_Common_t *id,
1264                                 MP_NumAnnot_t *num_annots));
1265
1266EXTERN MP_Status_t MP_GetCommonGreekIdentifierPacket _ANSI_ARGS_((MP_Link_pt
1267                             link, MP_DictTag_t *dtag, MP_Common_t *id,
1268                             MP_NumAnnot_t *num_annots));
1269
1270EXTERN MP_Status_t MP_GetStringPacket _ANSI_ARGS_((MP_Link_pt link, char **s,
1271                                                          MP_NumAnnot_t *num_annots));
1272
1273EXTERN MP_Status_t MP_GetConstantPacket _ANSI_ARGS_((MP_Link_pt link,
1274                                 MP_DictTag_t *dtag, char **cnst,
1275                                 MP_NumAnnot_t *num_annots));
1276
1277EXTERN MP_Status_t MP_GetCommonConstantPacket _ANSI_ARGS_((MP_Link_pt link,
1278                            MP_DictTag_t *dtag, MP_Common_t *cnst,
1279                            MP_NumAnnot_t *num_annots));
1280
1281EXTERN MP_Status_t MP_GetMetaTypePacket _ANSI_ARGS_((MP_Link_pt link,
1282                        MP_DictTag_t *dtag, char **m,
1283                        MP_NumAnnot_t *num_annots));
1284
1285EXTERN MP_Status_t MP_GetRawPacket _ANSI_ARGS_((MP_Link_pt link, char **rawdata,
1286                        MP_Uint32_t *len,  MP_NumAnnot_t *num_annots));
1287EXTERN MP_Status_t IMP_GetUint8 _ANSI_ARGS_((MP_Link_pt link, MP_Uint8_t *n));
1288EXTERN MP_Status_t IMP_GetSint8 _ANSI_ARGS_((MP_Link_pt link, MP_Sint8_t *n));
1289EXTERN MP_Status_t IMP_GetBoolean _ANSI_ARGS_((MP_Link_pt link, MP_Boolean_t *n));
1290EXTERN MP_Status_t IMP_GetApInt _ANSI_ARGS_((MP_Link_pt link, MP_ApInt_pt apint));
1291EXTERN MP_Status_t IMP_GetApReal _ANSI_ARGS_((MP_Link_pt link, MP_ApReal_pt apreal));
1292EXTERN MP_Status_t IMP_GetReal32 _ANSI_ARGS_((MP_Link_pt link, MP_Real32_t *n));
1293EXTERN MP_Status_t IMP_GetReal64 _ANSI_ARGS_((MP_Link_pt link, MP_Real64_t *n));
1294EXTERN MP_Status_t IMP_GetSint32 _ANSI_ARGS_((MP_Link_pt link, MP_Sint32_t *n));
1295EXTERN MP_Status_t IMP_GetUint32 _ANSI_ARGS_((MP_Link_pt link, MP_Uint32_t *n));
1296
1297EXTERN MP_Status_t IMP_GetNodeHeader _ANSI_ARGS_((MP_Link_pt link,
1298                          MP_NodeType_t *ntype, MP_DictTag_t *dtag,
1299                          MP_Common_t *cv, MP_NumAnnot_t *num_annots,
1300                          MP_NumChild_t *num_child));
1301
1302EXTERN MP_Status_t IMP_GetStringBasedType _ANSI_ARGS_((MP_Link_pt link,
1303                                                        char **s));
1304
1305EXTERN MP_Status_t IMP_GetRaw _ANSI_ARGS_((MP_Link_pt link, char **rawdata,
1306                                           MP_Uint32_t *len));
1307
1308EXTERN MP_Status_t IMP_GetOperator _ANSI_ARGS_((MP_Link_pt link, char **op));
1309
1310/*
1311 *  defines for getting a string-based type from the data stream.
1312 */
1313
1314#define IMP_GetIdentifier(link, id) \
1315   (IMP_GetStringBasedType(link, id))
1316
1317#define IMP_GetString(link, str) \
1318   (IMP_GetStringBasedType(link, str))
1319
1320#define IMP_GetMetaType(link, meta) \
1321   (IMP_GetStringBasedType(link, meta))
1322
1323#define MP_GetCommonMetaOperatorPacket(link, dtag, op, num_annots, num_child) \
1324   (MP_GetCommonOperatorPacket(link, dtag, op, num_annots, num_child))
1325
1326#define MP_GetMetaOperatorPacket(link, dtag, op, num_annots, num_child) \
1327   (MP_GetOperatorPacket(link, dtag, op, num_annots, num_child))
1328
1329#define IMP_GetMetaOperator(link, op) \
1330   (IMP_GetStringBasedType(link, op))
1331
1332#endif /* _MP_Get_h */
1333
1334/* Stuff included from h/MP_FileTransp.h */
1335/***************************************************************************
1336 *
1337 *   HEADER FILE:  MP_FileTransp.h
1338 *
1339 *        Declarations for the "file" transport device.
1340 *
1341 *  Change Log:
1342 *       September 10, 1995  SG - Updated implementation.  Much cleaning
1343 *                                to make it presentable.
1344 *       August 21, 1996     SG - Changed FILE_MODE from 0x666 to 0666.
1345 *                                Now it behaves properly
1346 *
1347 ***************************************************************************/
1348#ifndef _MP_FileTransp_h
1349#define _MP_FileTransp_h
1350
1351#define MP_NO_SUCH_FILE_MODE    0
1352#define MP_READ_MODE            1
1353#define MP_WRITE_MODE           2
1354#define MP_APPEND_MODE          3
1355
1356typedef struct {
1357    FILE    *fptr;
1358    int      access_mode; /* read, write, or append as defined above */
1359    char    *fname;
1360} MP_FILE_t;
1361
1362MP_Status_t file_flush _ANSI_ARGS_((MP_Link_pt link));
1363long file_write _ANSI_ARGS_((MP_Link_pt link, char * buf, long len));
1364long file_read _ANSI_ARGS_((MP_Link_pt link,
1365                            char *buf,
1366                            long len));
1367MP_Boolean_t file_get_status _ANSI_ARGS_((MP_Link_pt      link,
1368                                          MP_LinkStatus_t status_to_check));
1369MP_Status_t file_open_connection _ANSI_ARGS_((MP_Link_pt link,
1370                                              int        argc,
1371                                              char       **argv));
1372MP_Status_t file_close_connection _ANSI_ARGS_((MP_Link_pt link));
1373MP_Status_t file_init_transport _ANSI_ARGS_((MP_Link_pt link));
1374int get_file_mode _ANSI_ARGS_((int  argc,
1375                               char **argv));
1376#endif /* _MP_FileTransp_h */
1377
1378/* Stuff included from h/MP_TcpTransp.h */
1379/***************************************************************************
1380 *
1381 *   HEADER FILE:  MP_TcpTransp.h
1382 *
1383 *        Isolate all the includes we need for unix TCP sockets.
1384 *
1385 *  Change Log:
1386 *       September 10, 1995  SG - Updated implementation.  Much cleaning
1387 *                                to make it presentable.
1388 *
1389 ***************************************************************************/
1390#ifndef __TcpTransp__h
1391#define __TcpTransp__h
1392
1393#include <stdio.h>
1394#include <sys/types.h>
1395#include <sys/time.h>
1396
1397#ifdef __WIN32__
1398
1399#   include <winsock.h>
1400
1401#   define  ERRORCODE(err)      WSA ## err
1402#   define  LASTERROR           WSAGetLastError()
1403
1404#   define  CLOSE_SOCKET(s)             closesocket(s)
1405#   define  READ_SOCKET(s, buf, len)    recv(s, buf, len, 0)
1406#   define  WRITE_SOCKET(s, buf, len)   send(s, buf, len, 0)
1407
1408int WinSockInitialize _ANSI_ARGS_((void));
1409
1410#else /* not __WIN32__ */
1411
1412#   include <sys/socket.h>
1413#   include <netinet/in.h>
1414#   include <netinet/tcp.h>
1415#   include <sys/ioctl.h>
1416#   include <arpa/inet.h>
1417#   include <netdb.h>
1418
1419typedef int SOCKET;
1420
1421#   define  INVALID_SOCKET      -1
1422#   define  SOCKET_ERROR        -1
1423#   define  IPPORT_RESERVED     1024
1424#   define  ERRORCODE(err)      err
1425#   define  LASTERROR           errno
1426
1427#   define  CLOSE_SOCKET(s)             close(s)
1428#   define  READ_SOCKET(s, buf, len)    read(s, buf, len)
1429#   define  WRITE_SOCKET(s, buf, len)   write(s, buf, len)
1430
1431#   define  HOSTENT             struct hostent
1432#   define  SOCKADDR            struct sockaddr
1433#   define  TIMEVAL             struct timeval
1434#   define  SOCKADDR_IN         struct sockaddr_in
1435
1436#endif /* not __WIN32__ */
1437
1438
1439#define MP_NO_SUCH_TCP_MODE     0
1440#define MP_CONNECT_MODE         1
1441#define MP_LISTEN_MODE          2
1442#define MP_LAUNCH_MODE          3
1443#define MP_FORK_MODE            4
1444
1445/* Initial port for listening */
1446#define MP_INIT_PORT            "1025"
1447
1448/* The maximum number of attempts made to bind a socket to a port address */
1449#define MP_MAX_BIND_ATTEMPTS    1000
1450
1451#define MP_ACCEPT_WAIT_SEC      5
1452#define MP_ACCEPT_WAIT_USEC     0
1453
1454MP_Status_t tcp_flush _ANSI_ARGS_((MP_Link_pt link));
1455long tcp_write _ANSI_ARGS_((MP_Link_pt, char *, long));
1456long tcp_read _ANSI_ARGS_((MP_Link_pt, char *, long));
1457MP_Boolean_t tcp_get_status _ANSI_ARGS_((MP_Link_pt, MP_LinkStatus_t));
1458MP_Status_t tcp_init_transport _ANSI_ARGS_((MP_Link_pt));
1459MP_Status_t tcp_open_connection _ANSI_ARGS_((MP_Link_pt, int, char**));
1460MP_Status_t tcp_close_connection _ANSI_ARGS_((MP_Link_pt));
1461MP_Status_t tcp_kill_connection _ANSI_ARGS_((MP_Link_pt));
1462MP_Status_t open_tcp_connect_mode _ANSI_ARGS_((MP_Link_pt, int, char**));
1463MP_Status_t open_tcp_listen_mode _ANSI_ARGS_((MP_Link_pt, int, char**));
1464MP_Status_t open_tcp_launch_mode _ANSI_ARGS_((MP_Link_pt, int, char**));
1465MP_Status_t socket_accept_blocking _ANSI_ARGS_((MP_Link_pt, SOCKET*));
1466MP_Status_t socket_accept_non_blocking _ANSI_ARGS_((MP_Link_pt, SOCKET*));
1467char* IMP_GetCmdlineArg _ANSI_ARGS_((int, char**, char*));
1468
1469
1470typedef struct{
1471    SOCKET  bindsock;
1472    SOCKET  sock;
1473    short   peerport;
1474    char    *peerhost;
1475    char    *myhost;
1476    MP_LinkStatus_t status;
1477    pid_t   peerpid;
1478  char *rsh;
1479  int mode;
1480} MP_TCP_t;
1481
1482#endif
1483
1484/* Stuff included from h/MP_Vector.h */
1485/****************************************************************
1486 *
1487 *   HEADER FILE:  MP_Vector.h
1488 *
1489 ***************************************************************/
1490
1491#ifndef _MP_Vector_h
1492#define _MP_Vector_h
1493
1494#include "MP.h"
1495
1496/* Putting a Vector */
1497EXTERN MP_Status_t IMP_PutBasicVectorHeader
1498_ANSI_ARGS_((MP_Link_pt link, MP_Common_t elem_type,
1499              MP_NumAnnot_t na, MP_NumChild_t num_elems));
1500
1501EXTERN MP_Status_t MP_PutBasicVector
1502_ANSI_ARGS_((MP_Link_pt link, void *elems,
1503             MP_Common_t elem_type, MP_NumChild_t num_elems));
1504
1505EXTERN MP_Status_t IMP_PutBasicVector
1506_ANSI_ARGS_((MP_Link_pt link, void *elems,
1507             MP_Common_t elem_type, MP_NumChild_t num_elems));
1508
1509EXTERN MP_Status_t  IMP_PutReal64Vector
1510_ANSI_ARGS_((MP_Link_pt link, MP_Real64_t *dvec, MP_NumChild_t len));
1511
1512EXTERN MP_Status_t  IMP_PutUint32Vector
1513_ANSI_ARGS_((MP_Link_pt link, MP_Uint32_t *si32vec, MP_NumChild_t len));
1514
1515EXTERN MP_Status_t  IMP_PutUint16Vector
1516_ANSI_ARGS_((MP_Link_pt link, MP_Uint16_t *si16vec, MP_NumChild_t len));
1517
1518EXTERN MP_Status_t  IMP_PutUint8Vector
1519_ANSI_ARGS_((MP_Link_pt link, MP_Uint8_t *si8vec, MP_NumChild_t len));
1520
1521#define IMP_PutReal32Vector(link, vec, len)         \
1522IMP_PutUint32Vector(link, (MP_Uint32_t *) vec, len)
1523
1524#define IMP_PutSint32Vector(link, vec, len)         \
1525IMP_PutUint32Vector(link, (MP_Uint32_t *) vec, len)
1526
1527#define IMP_PutSint16Vector(link, vec, len)         \
1528IMP_PutUint16Vector(link, (MP_Uint16_t *) vec, len)
1529
1530#define IMP_PutSint8Vector(link, vec, len)         \
1531IMP_PutUint8Vector(link, (MP_Uint8_t *) vec, len)
1532
1533/* Getting a vector */
1534EXTERN MP_Status_t MP_GetBasicVector
1535_ANSI_ARGS_((MP_Link_pt link, void **elems,
1536             MP_Common_t elem_type, MP_NumChild_t num_elems));
1537
1538EXTERN MP_Status_t
1539IMP_GetReal64Vector _ANSI_ARGS_((MP_Link_pt link,
1540                                 MP_Real64_t **dvec, MP_NumChild_t len));
1541
1542EXTERN MP_Status_t
1543IMP_GetUint32Vector _ANSI_ARGS_((MP_Link_pt link,
1544                                 MP_Uint32_t **si32vec, MP_NumChild_t len));
1545
1546EXTERN MP_Status_t  IMP_GetUint16Vector
1547_ANSI_ARGS_((MP_Link_pt link, MP_Uint16_t **si16vec, MP_NumChild_t len));
1548
1549EXTERN MP_Status_t  IMP_GetUint8Vector
1550_ANSI_ARGS_((MP_Link_pt link, MP_Uint8_t **si8vec, MP_NumChild_t len));
1551
1552#define IMP_GetReal32Vector(link, vec, len)         \
1553IMP_GetUint32Vector(link, (MP_Uint32_t **) vec, len)
1554
1555#define IMP_GetSint32Vector(link, vec, len)         \
1556IMP_GetUint32Vector(link, (MP_Uint32_t **) vec, len)
1557
1558#define IMP_GetSint16Vector(link, vec, len)         \
1559IMP_GetUint16Vector(link, (MP_Uint16_t **) vec, len)
1560
1561#define IMP_GetSint8Vector(link, vec, len)         \
1562IMP_GetUint8Vector(link, (MP_Uint8_t **) vec, len)
1563
1564#endif /* _MP_Vector_h */
1565
1566/* Stuff included from h/MP_GmpBigInt.h */
1567/****************************************************************
1568 *
1569 *   HEADER FILE:  MP_GmpBigInt.h
1570 *
1571 *  The bigint routines of gmp
1572 *
1573 ****************************************************************/
1574
1575#ifndef _MP_GmpBigInt_h
1576#define _MP_GmpBigInt_h
1577
1578#include "MP.h"
1579
1580#ifdef MP_HAVE_GMP_APINT
1581
1582#include "mp_gmp.h"
1583
1584EXTERN MP_BigIntOps_t imp_gmp_bigint_ops;
1585
1586EXTERN MP_Status_t IMP_GetGmpInt _ANSI_ARGS_((MP_Link_pt link,
1587                                              MP_ApInt_t* mp_apint));
1588EXTERN MP_Status_t IMP_PutGmpInt _ANSI_ARGS_((MP_Link_pt link,
1589                                              MP_ApInt_t mp_apint));
1590EXTERN char *IMP_GmpIntToStr _ANSI_ARGS_((MP_ApInt_t mp_apint,
1591                                          char *buffer));
1592EXTERN long IMP_GmpIntAsciiSize _ANSI_ARGS_((MP_ApInt_t mp_apint));
1593
1594#endif /* MP_HAVE_GMP_APINT */
1595
1596#endif /* _MP_GmpBigInt_h */
1597
1598/* Stuff included from h/MP_GmpBigReal.h */
1599/****************************************************************
1600 *
1601 *   HEADER FILE:  MP_GmpBigReal.h
1602 *
1603 *  The bigreal routines of gmp
1604 *
1605 ****************************************************************/
1606
1607#ifndef _MP_GmpBigReal_h
1608#define _MP_GmpBigReal_h
1609
1610#include "MP.h"
1611
1612#ifdef MP_HAVE_GMP_APREAL
1613#include "mp_gmp.h"
1614
1615EXTERN MP_BigRealOps_t imp_gmp_bigreal_ops;
1616
1617EXTERN MP_Status_t IMP_GetGmpReal _ANSI_ARGS_((MP_Link_pt link,
1618                                              MP_ApReal_t* mp_apreal));
1619EXTERN MP_Status_t IMP_PutGmpReal _ANSI_ARGS_((MP_Link_pt link,
1620                                              MP_ApReal_t mp_apreal));
1621EXTERN char *IMP_GmpRealToStr _ANSI_ARGS_((MP_ApReal_t mp_apreal,
1622                                          char *buffer));
1623EXTERN long IMP_GmpRealAsciiSize _ANSI_ARGS_((MP_ApReal_t mp_apreal));
1624
1625#endif /* MP_HAVE_GMP_APREAL */
1626#endif /* _MP_GmpBigReal_h */
1627
1628/* Stuff included from h/MP_PariBigInt.h */
1629/****************************************************************
1630 *
1631 * HEADER FILE:  MP_PariBigInt.h
1632 * Authors:  O. Bachmann, T. Metzner, H. Schoenemann, A. Sorgatz
1633 * Date:    February 97
1634 *
1635 ***************************************************************/
1636
1637#ifndef _MP_PariBigInt_h
1638#define _MP_PariBigInt_h
1639
1640#include "MP.h"
1641#ifdef MP_HAVE_PARI
1642
1643/* Dirty hack with honors to andi: pari defines "overflow" identifier
1644   which conflicts with the definition in some libraries (e.g. in
1645   iostream -- hence, we overshadow this defitnition before includeing
1646   genpari */
1647#ifndef overflow
1648#define overflow muff
1649#include "genpari.h"
1650#undef overflow
1651#endif
1652
1653
1654EXTERN MP_BigIntOps_t imp_pari_bigint_ops;
1655
1656EXTERN MP_Status_t IMP_GetPariBigInt _ANSI_ARGS_((MP_Link_pt link,
1657                                                 MP_ApInt_t *pari_number));
1658EXTERN MP_Status_t IMP_PutPariBigInt _ANSI_ARGS_((MP_Link_pt link,
1659                                                 MP_ApInt_t pari_number));
1660EXTERN char* IMP_PariBigIntToStr _ANSI_ARGS_((MP_ApInt_t pari_number,
1661                                              char *buffer));
1662EXTERN long IMP_PariBigIntAsciiSize _ANSI_ARGS_((MP_ApInt_t mp_number));
1663
1664/* Memory mamagment for Pari BigInts:
1665   By default, the following functions are simple cgeti and empty;
1666   You can reset this at run-time to whatever fits your needs
1667*/
1668EXTERN GEN (*IMP_AllocCgeti) _ANSI_ARGS_((long));
1669EXTERN void (*IMP_FreeCgeti) _ANSI_ARGS_((GEN));
1670
1671#ifdef HAVE_GMP_PARI_CONVERSIONS
1672#include "mp_gmp.h"
1673EXTERN mpz_ptr _pari_to_gmp(GEN pnum, mpz_ptr *gnum_ptr);
1674EXTERN GEN     _gmp_to_pari(mpz_ptr gnum);
1675#endif
1676
1677#endif /* MP_HAVE_PARI */
1678
1679#endif  /* _MP_PariBigInt_h */
1680
1681/* Stuff included from h/MP_PvmTransp.h */
1682/***************************************************************************
1683 *
1684 *   HEADER FILE:  MP_PvmTransp.h
1685 *
1686 *
1687 *  Change Log:
1688 *      1/25/96 sgray - formal creation of PVM transport device.
1689 *
1690 ***************************************************************************/
1691#ifndef __PvmTransp__h
1692#define __PvmTransp__h
1693
1694#include "MP_Config.h"
1695
1696#ifdef MP_HAVE_PVM
1697#include "pvm3.h"
1698
1699#define MP_NO_SUCH_PVM_MODE    0
1700
1701typedef struct{
1702  int     nhosts;
1703  int     ntids;  /* the number of tids in next field */
1704  int     *tids;
1705  int     tag;
1706  int     send_mode;
1707  char    *myhost;
1708} MP_PVM_t;
1709
1710/*#include "/tmp_mnt/home/Owl/sgray/MP/MP/MP_PvmTransp.c" */
1711
1712#endif /*  MP_HAVE_PVM */
1713
1714#endif
1715
1716/* Stuff included from h/MP_SacBigInt.h */
1717/****************************************************************
1718 *
1719 *   HEADER FILE:  MP_SacBigInt.h
1720 *
1721 ***************************************************************/
1722
1723#ifndef _MP_SacBigInt_h
1724#define _MP_SacBigInt_h
1725
1726#include "MP.h"
1727
1728#ifdef MP_HAVE_SAC
1729#include "saclib.h"
1730#include "mp_gmp.h"
1731
1732EXTERN MP_BigIntOps_t sac_ops;
1733
1734EXTERN MP_Status_t IMP_PutSacBigInt _ANSI_ARGS_((MP_Link_pt link,
1735                                                 MP_ApInt_t sac_int));
1736
1737EXTERN MP_Status_t IMP_GetSacBigInt _ANSI_ARGS_((MP_Link_pt link,
1738                                                 MP_ApInt_t *sac_int));
1739
1740EXTERN char * IMP_SacBigIntToStr _ANSI_ARGS_((MP_ApInt_t big_int,
1741                                             char *buffer));
1742
1743EXTERN long IMP_SacBigIntAsciiSize _ANSI_ARGS_((MP_ApInt_t mp_apint));
1744
1745#endif /* MP_HAVE_SAC */
1746
1747#endif  /* _MP_SacBigInt_h */
1748
1749/* Stuff included from h/MP_TbTransp.h */
1750/***************************************************************************
1751 *
1752 *   HEADER FILE:  MP_TbTransp.h
1753 *
1754 *   PURPOSE: ToolBus stuff - not much to do.
1755 *
1756 *   Change Log:
1757 *      2/6/96 sgray - creation of TB transport device.
1758 *      6/9/96 sgray - updated tb struct to support buffering of terms
1759 *                     consistent with what the buffering layer expects.
1760 *
1761 ***************************************************************************/
1762#ifndef __TbTransp__h
1763#define __TbTransp__h
1764
1765#include "MP_Config.h"
1766
1767#ifdef MP_HAVE_TB
1768#include "TB.h"
1769
1770
1771typedef struct{
1772  term    *write_term,
1773          *read_term;
1774  char    *term_buf;     /* where next binary TB term will be unloaded    */
1775  char    *next_byte;    /* next byte to be consumed in term_buf          */
1776  unsigned long buf_len; /* number of bytes in term_buf                   */
1777  unsigned long tbtbc;   /* Term Bytes To Be Consumed in term_buf         */
1778  char    *myhost;       /* host on which we are running - must have this */
1779} MP_TB_t;
1780
1781EXTERN MP_Status_t MP_TbPutMsg _ANSI_ARGS_((MP_Link_pt link, char **tb_data,
1782                                            unsigned long *len));
1783EXTERN MP_Status_t MP_TbGetMsg _ANSI_ARGS_((MP_Link_pt link, char *tb_data,
1784                                            unsigned long len));
1785EXTERN MP_Status_t MP_TbSetTerm _ANSI_ARGS_((MP_Link_pt link, term *t));
1786
1787/*
1788 * if your device may not be available everywhere you want to use MP,
1789 * don't try to compile the source into the library as the link will
1790 * fail.  The alternative is to include the transport device interface
1791 * source here and have the user include this header file in their
1792 * application code.  Then the corresponding .c file will be compiled
1793 * with the application
1794 */
1795/* #include "../MP/MP_TbTransp.c" */
1796
1797#endif /* MP_HAVE_TB */
1798
1799#endif
1800
1801/* MP Dictionary includes */
1802
1803/* Stuff included from h/MP_BasicDict.h */
1804/***************************************************************************
1805 *
1806 *   HEADER FILE:  MP_BasicDict.h
1807 *
1808 *      The MP basic dictionary (definitions and declarations)
1809 *
1810 *
1811 *   Change Log:
1812 *      1/97 obachman  -- this is a first try
1813 *
1814 ***************************************************************************/
1815#ifndef _MP_BasicDict_h
1816#define _MP_BasicDict_h
1817
1818
1819
1820/***************************************************************************
1821 *
1822 * Common Operator Definitions
1823 *
1824 ***************************************************************************/
1825/* for the time being, no attention was paid to "good" numeric value
1826   assignments */
1827#define MP_CopBasicInc              1
1828#define MP_CopBasicDec              2
1829#define MP_CopBasicSize             3
1830#define MP_CopBasicList             4
1831#define MP_CopBasicAdd              5
1832#define MP_CopBasicMinus            6
1833#define MP_CopBasicMult             7
1834#define MP_CopBasicDiv              8
1835#define MP_CopBasicMod              9
1836#define MP_CopBasicPow              10
1837#define MP_CopBasicGreaterEqual     11
1838#define MP_CopBasicGreater          12
1839#define MP_CopBasicLessEqual        13
1840#define MP_CopBasicLess             14
1841#define MP_CopBasicAnd              15
1842#define MP_CopBasicOr               16
1843#define MP_CopBasicEqual            17
1844#define MP_CopBasicNotEqual         18
1845#define MP_CopBasicRange            19
1846#define MP_CopBasicIndex            20
1847#define MP_CopBasicDiff             21
1848#define MP_CopBasicInterSect        22
1849#define MP_CopBasicSubst            23
1850#define MP_CopBasicNot              24
1851#define MP_CopBasicAssign           25
1852#define MP_CopBasicComplex          26
1853#define MP_CopBasicPackage          27
1854#endif /* _MP_BasicDict_h */
1855
1856/* Stuff included from h/MP_MpDict.h */
1857/***************************************************************************
1858 *
1859 *   HEADER FILE:  MP_MpDict.h
1860 *
1861 *      The MP dictionary for (definitions and declarations)
1862 *
1863 *
1864 *   Change Log:
1865 *        3/26/97  sgray - Life begins for this file.
1866 *
1867 ***************************************************************************/
1868#ifndef _MP_MpDict_h
1869#define _MP_MpDict_h
1870
1871/* Let's give the MP Dictionary the number 2 */
1872
1873#define MP_MpDict 2
1874
1875/***************************************************************************
1876 *
1877 * Common Operator Definitions
1878 *
1879 ***************************************************************************/
1880#define MP_CopMpEndSession               1
1881
1882#define MP_CopMpByteOrderRequest        10
1883#define MP_CopMpFpFormatRequest         11
1884#define MP_CopMpBigIntFormatRequest     12
1885
1886/***************************************************************************
1887 *
1888 * Annotations
1889 *
1890 ***************************************************************************/
1891#define MP_AnnotMpLabel                 1
1892#define MP_AnnotMpRef                   2
1893#define MP_AnnotMpStore                 3
1894#define MP_AnnotMpStored                4
1895#define MP_AnnotMpRetrieve              5
1896#define MP_AnnotMpSource                6
1897#define MP_AnnotMpComment               7
1898#define MP_AnnotMpTiming                8
1899#define MP_AnnotMpType                  9
1900#define MP_AnnotMpUnits                10
1901
1902#endif /* _MP_MpDict_h  */
1903
1904/* Stuff included from h/MP_NumberDict.h */
1905/***************************************************************************
1906 *
1907 *   HEADER FILE:  MP_NumberDict.h
1908 *
1909 *      The Numbertype dictionary (definitions and declarations)
1910 *
1911 *
1912 *   Change Log:
1913 *
1914 *
1915 ***************************************************************************/
1916#ifndef _MP_NumberDict_h
1917#define _MP_NumberDict_h
1918
1919/* Lets give the Number Dictionary the number 12 */
1920
1921#define MP_NumberDict 12
1922
1923/***************************************************************************
1924 *
1925 * Meta type definitions
1926 *
1927 ***************************************************************************/
1928#define MP_CmtNumberRational            1
1929#define MP_CmtNumberInteger             2
1930#define MP_CmtNumberComplex             3
1931#define MP_CmtNumberReal                4
1932#define MP_CmtNumberCharp               5
1933#define MP_CmtNumberModulo              6
1934
1935
1936/***************************************************************************
1937 *
1938 * Annot definitions
1939 *
1940 ***************************************************************************/
1941#define MP_AnnotNumberIsNormalized          1
1942#define MP_AnnotNumberIsPrime               2
1943#define MP_AnnotNumberModulos               3
1944
1945
1946/***************************************************************************
1947 *
1948 * Common Operator Definitions
1949 *
1950 ***************************************************************************/
1951#define MP_CopNumberPrime               1
1952#define MP_CopNumberExtGcd              2
1953#define MP_CopNumberGcd                 3
1954#define MP_CopNumberRandom              4
1955
1956
1957#endif /* _MP_NumberDict_h */
1958
1959/* Stuff included from h/MP_ProtoDict.h */
1960/***************************************************************************
1961 *
1962 *   HEADER FILE:  MP_ProtoDict.h
1963 *
1964 *      The prototype dictionary (definitions and declarations)
1965 *
1966 *
1967 *   Change Log:
1968 *
1969 *
1970 ***************************************************************************/
1971#ifndef _MP_ProtoDict_h
1972#define _MP_ProtoDict_h
1973
1974#define MP_ProtoDict 6
1975
1976/***************************************************************************
1977 *
1978 * Meta type definitions
1979 *
1980 ***************************************************************************/
1981/* We use the same numerical values as we use for the MP types */
1982#define MP_CmtProto_2_MPType(cmt)   cmt
1983
1984#define MP_CmtProtoIMP_Sint8                        65
1985#define MP_CmtProtoIMP_Uint8                        67
1986#define MP_CmtProtoIMP_Boolean                      68
1987#define MP_CmtProtoIMP_LatinIdentifier              72
1988#define MP_CmtProtoIMP_GreekIdentifier              76
1989#define MP_CmtProtoIMP_CommonConstant               80
1990
1991#define MP_CmtProtoIMP_String                       36
1992#define MP_CmtProtoIMP_Constant                     40
1993#define MP_CmtProtoIMP_Identifier                   44
1994
1995#define MP_CmtProtoIMP_Sint32                       17
1996#define MP_CmtProtoIMP_Uint32                       19
1997#define MP_CmtProtoIMP_Real32                       18
1998
1999#define MP_CmtProtoIMP_ApInt                        9
2000#define MP_CmtProtoIMP_ApReal                       10
2001
2002#define MP_CmtProtoIMP_Real64                       6
2003
2004#define MP_CmtProtoRecStruct   128
2005#define MP_CmtProtoRecUnion    129
2006
2007/* Basic types, i.e. those which appear as a leaf of a data tree
2008   have numerical values between 0 and 127 ,i.e. bit 8 is zero */
2009#define IMP_IsBasicMetaType(type)    (!((type) & 128))
2010
2011/* native 8-bit types have numeric values between 64 and 127
2012   i.e. bit 8 is zero and bit 7 is one */
2013#define IMP_Is8BitNumericMetaType(type)    (!((type) & 128) && ((type) & 64))
2014
2015/* native String-based types have numeric values between 32 an 63,
2016   i.e. bit 8,7 are zero, bit 6 is one */
2017#define IMP_IsStringBasedMetaType(type)  (!((type) & 192) && ((type) & 32))
2018
2019/* native 32 bit types have numeric values beween 16 and 31, i.e. bits
2020   8,7,6, are zero, bit 5 is one. Furthermore, integers have bit 1 set
2021   to 1 and Reals have bit 1 set to 0 */
2022#define IMP_Is32BitNumericMetaType(type)    (!((type) & 224) && ((type) & 16))
2023#define IMP_Is16BitNumericMetaType(type) 0
2024/* Ap Numbers have bit 5-8 set to zero, bit 4 set to one */
2025#define IMP_IsApNumberMetaType(type) (!((type) & 240) && ((type) & 8))
2026
2027/* Native 64-bit numbers have bit 4-8 set to zero, bit 3 set to one */
2028#define IMP_Is64BitNumericMetaType(type)    (type == MP_CmtProtoIMP_Real64)
2029
2030/* Predicates for real and integers
2031   Integers are odd numbers, reals are even numbers, not divisble by 4*/
2032#define IMP_IsRealMetaType(type)   (IMP_IsBasicMetaType(type) &&    \
2033                                 !((type) & 1) &&           \
2034                                 ((type) >> 1) & 1)
2035#define IMP_IsIntegerMetaType(type)(IMP_IsBasicMetaType(type) && ((type) & 1))
2036
2037/***************************************************************************
2038 *
2039 * Common Operator Definitions
2040 *
2041 ***************************************************************************/
2042#define MP_CopProtoStruct                1
2043#define MP_CopProtoUnion                 2
2044#define MP_CopProtoArray                 3
2045#define MP_CopProtoPointer               4
2046#define MP_CopProtoRecStruct             5
2047#define MP_CopProtoRecUnion              6
2048
2049/***************************************************************************
2050 *
2051 * Definition of Annots
2052 *
2053 ***************************************************************************/
2054#define MP_AnnotProtoPrototype           1
2055
2056#endif /* _MP_ProtoDict_h */
2057
2058/* Stuff included from h/MP_PolyDict.h */
2059/***************************************************************************
2060 *
2061 *   HEADER FILE:  MP_PolyDict.h
2062 *
2063 *      The Polytype dictionary (definitions and declarations)
2064 *
2065 *
2066 *   Change Log:
2067 *
2068 *
2069 ***************************************************************************/
2070#ifndef _MP_PolyDict_h
2071#define _MP_PolyDict_h
2072
2073/* Lets give the Poly Dictionary the number 10 */
2074
2075#define MP_PolyDict 10
2076
2077/***************************************************************************
2078 *
2079 * Annotations
2080 *
2081 ***************************************************************************/
2082#define MP_AnnotPolyModuleVector        1
2083#define MP_AnnotPolyVarNames            2
2084#define MP_AnnotPolyVarNumber           3
2085#define MP_AnnotPolyOrdering            4
2086#define MP_AnnotPolyDefRel              5
2087#define MP_AnnotPolyIrreducible         6
2088#define MP_AnnotPolyWeights             8
2089#define MP_AnnotPolyModuleRank          9
2090#define MP_AnnotShouldHavePolyOrdering  10
2091
2092/***************************************************************************
2093 *
2094 * (Common) Constants
2095 *
2096 ***************************************************************************/
2097#define MP_CcPolyOrdering_Unknown       0
2098#define MP_CcPolyOrdering_Vector        1 /* a */
2099#define MP_CcPolyOrdering_Matrix        2 /* M */
2100#define MP_CcPolyOrdering_IncComp       3 /* c */
2101#define MP_CcPolyOrdering_DecComp       4 /* C */
2102#define MP_CcPolyOrdering_Lex           5 /* lp */
2103#define MP_CcPolyOrdering_DegRevLex     6 /* dp */
2104#define MP_CcPolyOrdering_DegLex        7 /* Dp */
2105#define MP_CcPolyOrdering_NegLex        8 /* ls */
2106#define MP_CcPolyOrdering_NegDegRevLex  9 /* ds */
2107#define MP_CcPolyOrdering_NegDegLex     10 /* Ds */
2108#define MP_CcPolyOrdering_NegRevLex     11
2109#define MP_CcPolyOrdering_RevLex        12
2110
2111#if 0 /* Here is what it used to be */
2112#define MP_CcPolyOrdering_No    0
2113#define MP_CcPolyOrdering_a     1
2114#define MP_CcPolyOrdering_c     2
2115#define MP_CcPolyOrdering_C     3
2116#define MP_CcPolyOrdering_M     4
2117#define MP_CcPolyOrdering_lp    5
2118#define MP_CcPolyOrdering_Dp    6
2119#define MP_CcPolyOrdering_wp    7
2120#define MP_CcPolyOrdering_Wp    8
2121#define MP_CcPolyOrdering_ls    9
2122#define MP_CcPolyOrdering_ds    10
2123#define MP_CcPolyOrdering_Ds    11
2124#define MP_CcPolyOrdering_ws    12
2125#define MP_CcPolyOrdering_Ws    13
2126#define MP_CcPolyOrdering_Unspec 14
2127#endif
2128
2129
2130/***************************************************************************
2131 *
2132 * Common Operator Definitions
2133 *
2134 ***************************************************************************/
2135
2136#define MP_CopPolyBetti                 1
2137#define MP_CopPolyChar                  2
2138#define MP_CopPolyCharSeries            3
2139#define MP_CopPolyDeg                   4
2140#define MP_CopPolyDim                   5
2141#define MP_CopPolyFactorize             6
2142#define MP_CopPolyHilb                  7
2143#define MP_CopPolyHomog                 8
2144#define MP_CopPolyInDepSet              9
2145#define MP_CopPolyIdeal                 10
2146#define MP_CopPolyKbase                 11
2147#define MP_CopPolyLead                  12
2148#define MP_CopPolyLeadCoef              13
2149#define MP_CopPolyLeadExp               14
2150#define MP_CopPolyMaxIdeal              15
2151#define MP_CopPolyMinBase               16
2152#define MP_CopPolyMinRes                17
2153#define MP_CopPolyModule                18
2154#define MP_CopPolyMultiplicity          19
2155#define MP_CopPolyOrder                 20
2156#define MP_CopPolyPrune                 21
2157#define MP_CopPolyQHWeight              22
2158#define MP_CopPolyRegularity            23
2159#define MP_CopPolyStd                   24
2160#define MP_CopPolySyz                   25
2161#define MP_CopPolyVdim                  26
2162#define MP_CopPolyCoeffs                27
2163#define MP_CopPolyContract              28
2164#define MP_CopPolyEliminate             29
2165#define MP_CopPolyJet                   30
2166#define MP_CopPolyLift                  31
2167#define MP_CopPolyLiftstd               32
2168#define MP_CopPolyModulo                33
2169#define MP_CopPolyMres                  34
2170#define MP_CopPolyQuotient              35
2171#define MP_CopPolyReduce                36
2172#define MP_CopPolyPreimage              37
2173#define MP_CopPolyRes                   38
2174#define MP_CopPolyRing                  39
2175#define MP_CopPolyDenseDistPoly         40
2176#define MP_CopPolyDenseDistPolyFrac     41
2177#define MP_CopPolyClearDenom            42
2178#define MP_CopPolyFacStd                43
2179#define MP_CopPolyResultant             44
2180#define MP_CopPolyFreeModule            45
2181
2182/***************************************************************************
2183 *
2184 * Common Metat Types
2185 *
2186 ***************************************************************************/
2187
2188#define MP_CmtPolyExpTreePoly       1
2189
2190#endif /* _MP_PolyDict_h */
2191
2192/* Stuff included from h/MP_MatrixDict.h */
2193/***************************************************************************
2194 *
2195 *   HEADER FILE:  MP_MatrixDict.h
2196 *
2197 *      The Matrixtype dictionary (definitions and declarations)
2198 *
2199 *
2200 *   Change Log:
2201 *
2202 *
2203 ***************************************************************************/
2204#ifndef _MP_MatrixDict_h
2205#define _MP_MatrixDict_h
2206
2207/* Lets give the Matrix Dictionary the number 11 */
2208
2209#define MP_MatrixDict 11
2210
2211/***************************************************************************
2212 *
2213 * Annotations
2214 *
2215 ***************************************************************************/
2216#define MP_AnnotMatrixDimension     1
2217
2218
2219/***************************************************************************
2220 *
2221 * Common Operator Definitions
2222 *
2223 ***************************************************************************/
2224
2225#define MP_CopMatrixBareiss             1
2226#define MP_CopMatrixCols                2
2227#define MP_CopMatrixDet                 3
2228#define MP_CopMatrixJacobi              4
2229#define MP_CopMatrixRows                6
2230#define MP_CopMatrixTrace               7
2231#define MP_CopMatrixTranspose           8
2232#define MP_CopMatrixKoszul              9
2233#define MP_CopMatrixMinor               10
2234#define MP_CopMatrixWedge               11
2235
2236#define MP_CopMatrixDenseMatrix         12
2237#define MP_CopMatrixDenseVector         13
2238
2239#endif /* _MP_MatrixDict_h */
2240
2241#endif /* _MP_h */
Note: See TracBrowser for help on using the repository browser.