source: git/MP/MP/MP.h @ 82dbf50

fieker-DuValspielwiese
Last change on this file since 82dbf50 was 82dbf50, checked in by Olaf Bachmann <obachman@…>, 26 years ago
* minor changes git-svn-id: file:///usr/local/Singular/svn/trunk@2675 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 81.3 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 
569EXTERN void* (*IMP_MemAllocFnc) _ANSI_ARGS_((size_t));
570EXTERN void* (*IMP_MemReallocFnc) _ANSI_ARGS_((void *, size_t, size_t));
571EXTERN void  (*IMP_MemFreeFnc) _ANSI_ARGS_((void *, size_t));
572
573EXTERN void* (*IMP_RawMemAllocFnc) _ANSI_ARGS_((size_t));
574EXTERN void* (*IMP_RawMemReallocFnc) _ANSI_ARGS_((void *, size_t));
575EXTERN void  (*IMP_RawMemFreeFnc) _ANSI_ARGS_((void *));
576
577
578#endif /* _MP_Memory_h */
579
580
581
582
583/* Stuff included from h/MP_BigNum.h */
584/****************************************************************
585 *                                                                 
586 *   HEADER FILE:  MP_BigNum.h
587 *                       
588 * The relevant declarations for the handling of BigNums
589 *
590 ****************************************************************/
591
592#ifndef _MP_BigNum_h
593#define _MP_BigNum_h
594
595#include "MP.h"
596
597/* Note: a type_to_string conversion array using the ordering given */
598/* below is defined in MP_Env.c.  So if you change the order below, */
599/* make the corresponding change in MP_Env.c, okay?                 */
600
601typedef MP_Uint8_t MP_BigNumFormat_t;
602
603typedef struct MP_BigIntOps_t
604{
605    MP_Status_t  (*put_bigint)(MP_Link_pt, MP_ApInt_t);
606    MP_Status_t  (*get_bigint)(MP_Link_pt link, MP_ApInt_t *bigint);
607    char*        (*bigint_to_str)(MP_ApInt_t bigint, char *buffer);
608    long         (*bigint_ascii_size)(MP_ApInt_t bigint);
609} MP_BigIntOps_t;
610typedef MP_BigIntOps_t * MP_BigIntOps_pt;
611
612EXTERN MP_BigIntOps_t imp_default_bigint_ops;
613EXTERN MP_BigNumFormat_t imp_default_bigint_format;
614
615typedef struct   MP_BigRealOps_t
616{
617    MP_Status_t  (*put_bigreal)(MP_Link_pt link, MP_ApReal_t bigreal);
618    MP_Status_t  (*get_bigreal)(MP_Link_pt link, MP_ApReal_t *bigreal);
619    char*        (*bigreal_to_str)(MP_ApReal_t bigreal, char *buffer);
620    long         (*bigreal_ascii_size)(MP_ApReal_t bigreal);
621} MP_BigRealOps_t;
622typedef MP_BigRealOps_t * MP_BigRealOps_pt;
623
624EXTERN MP_BigRealOps_t imp_default_bigreal_ops;
625EXTERN MP_BigNumFormat_t imp_default_bigreal_format;
626
627typedef struct  MP_BigNum_t
628{
629    MP_BigNumFormat_t native_bigint_format;
630    MP_BigIntOps_pt   bigint_ops;
631    MP_BigNumFormat_t native_bigreal_format; 
632    MP_BigRealOps_pt  bigreal_ops; 
633} MP_BigNum_t;
634
635EXTERN MP_Status_t IMP_PutDummyBigInt(MP_Link_pt link, MP_ApInt_t dummy);
636EXTERN MP_Status_t IMP_GetDummyBigInt(MP_Link_pt link, MP_ApInt_t *dummy);
637EXTERN char* IMP_DummyBigIntToStr(MP_ApInt_t dummy, char *buf);
638EXTERN long IMP_DummyBigIntAsciiSize(MP_ApInt_t dummy);
639EXTERN MP_Status_t IMP_PutDummyBigReal(MP_Link_pt link, MP_ApReal_t dummy);
640EXTERN MP_Status_t IMP_GetDummyBigReal(MP_Link_pt link, MP_ApReal_t *dummy);
641EXTERN char* IMP_DummyBigRealToStr(MP_ApReal_t dummy, char *buf);
642EXTERN long IMP_DummyBigRealAsciiSize(MP_ApReal_t dummy);
643
644
645#endif /* _MP_BigNum_h */
646
647/* Stuff included from h/MP_Env.h */
648/***************************************************************************
649 *                                                                 
650 *   HEADER FILE:  MP_Env.h
651 *
652 *        Declarations to maintain the MP environment.  The environment
653 *        includes the name of the host machine, the log file name and
654 *      file descriptor and the buffer pool containing all the buffers
655 *      to be shared among the links.  The initialization should be
656 *      done once before any MP-related activities occur.
657 *                                                               
658 *  Change Log:
659 *       September 10, 1995  SG - Updated implementation.  Much cleaning
660 *                                to make it presentable.
661 *       November 25, 1995   SG - Added field in env struct to support
662 *                                negotiation of endian order.
663 *       April 32, 1996      SG - Added support to handle different
664 *                                Big Integer packages.  See note in
665 *                                MP_SacBigInt.c for some details.
666 ***************************************************************************/
667#ifndef _MP_Env_h
668#define _MP_Env_h
669
670
671
672#include "MP.h"
673
674#define MP_HOST_NAME_LEN    64
675#define MP_INIT_LOGFILE_EXT 100
676
677/* These are the transport types currently supported   */
678/* These are the values stored in transp_dev.         */
679/* If you add to this list, you must also add a string */
680/* equivalent to transp_dev2string[] in MP_Link.c.    */
681
682#define MP_TcpTransportDev   0
683#define MP_FileTransportDev  1
684#define MP_PvmTransportDev   2
685#define MP_TbTransportDev    3
686
687
688/*
689 * Options that can be set for an environment
690 */
691#define MP_BUFFER_SIZE_OPT       1
692#define MP_MAX_FREE_BUFFERS_OPT  2
693#define MP_INIT_FREE_BUFFERS_OPT 3
694
695typedef struct  {
696    long         (*write_buf)VARARGS;       /* write buffer to transport   */
697    long         (*read_buf)VARARGS;        /* read transport to buffer    */
698    MP_Status_t  (*flush_buf)VARARGS;       /* flush buffer to transport   */
699    MP_Boolean_t (*get_status)VARARGS;      /* check status of the link    */
700    MP_Status_t  (*open_transp)VARARGS;     /* open the transport device   */
701    MP_Status_t  (*close_transp)VARARGS;    /* close the transport device  */
702    MP_Status_t  (*kill_transp)VARARGS;    /* kill the transport device  */
703} MP_TranspOps_t;
704
705
706typedef struct {
707    int            transp_dev;
708    MP_TranspOps_t *transp_ops;
709    char           *private1;    /* for opaque transport-specific structure */
710} MP_Transport_t;
711
712typedef struct transp_list_elem *MP_TranspList_pt;
713
714struct transp_list_elem {
715    int               transp_dev;
716    MP_TranspOps_t    transp_ops;
717    MP_TranspList_pt *next;
718};
719
720
721typedef struct mp_environment {
722    MP_TranspList_pt transp_dev_list; /* list of supported transport devices */
723    buffer_pool_pt   buff_pool;       /* buffer pool shared by  links in this
724                                       *  env 
725                                       */
726    int   num_o_buff;
727    int   buffer_size;                /* size of each buffer in the pool     */
728    int   max_free_buffers;           /* max number of free buffers in the
729                                       * pool
730                                       */
731
732    int   init_free_buffers;          /* initial number of free buffers in the
733                                       * pool
734                                       */
735
736    int   num_links;                  /* to handout unique link ids for this
737                                       * env
738                                       */
739
740    FILE  *logfd;                     /* log file for all logging events     */
741    char  *logfilename;
742    char  thishost[MP_HOST_NAME_LEN];
743    MP_Boolean_t initialized;         /* can't set options after env has been
744                                       * init
745                                       */
746
747    MP_WordOrder_t native_word_order; /* what this machine uses internally   */
748    MP_FpFormat_t  native_fp_format;  /* floating pnt format used internally */
749    MP_BigNum_t    bignum;            /* info on bignum package to be used   */
750} MP_Env_t;
751
752typedef MP_Env_t *MP_Env_pt;
753typedef MP_Env_pt MP_ENV;
754
755EXTERN MP_ENV MP_AllocateEnv _ANSI_ARGS_((void));
756EXTERN MP_ENV MP_InitializeEnv _ANSI_ARGS_((MP_Env_pt env));
757EXTERN void MP_ReleaseEnv _ANSI_ARGS_((MP_Env_pt env));
758EXTERN int MP_SetEnvOption _ANSI_ARGS_((MP_Env_pt env, int option, int value));
759EXTERN int    MP_GetEnvOption _ANSI_ARGS_((MP_Env_pt env, int option));
760EXTERN MP_TranspList_pt IMP_GetTranspByName _ANSI_ARGS_((MP_Env_pt env, 
761                                                         int transp_dev));
762EXTERN MP_Status_t MP_AddEnvTranspDevice _ANSI_ARGS_((MP_Env_pt env, 
763                                        int transp_dev, MP_TranspOps_t *ops));
764EXTERN MP_Status_t MP_SetEnvBigIntFormat _ANSI_ARGS_((MP_Env_t *env, 
765                             MP_BigIntOps_t *ops, MP_BigNumFormat_t format));
766EXTERN MP_Status_t MP_SetEnvBigRealFormat _ANSI_ARGS_((MP_Env_t *env, 
767                             MP_BigRealOps_t *ops, MP_BigNumFormat_t format));
768EXTERN MP_Status_t open_logfile _ANSI_ARGS_((MP_ENV env));
769#endif /* _MP_Env_h */
770
771/* Stuff included from h/MP_Link.h */
772/****************************************************************
773 *                                                                 
774 *   HEADER FILE:  MP_Link.h
775 *
776 *   struct link is adapted from the Sun XDR distribution.
777 *   Copyright (C) 1984, Sun Microsystems, Inc.
778 *
779 ***************************************************************/
780
781#ifndef _MP_Link_h
782#define _MP_Link_h
783
784/* Sending modes */
785#define MP_SEND_FRAG_MSG      1
786#define MP_SEND_WHOLE_MSG     2
787#define MP_DEFAULT_SEND_MODE  MP_SEND_FRAG_MSG
788
789/* Receiving modes */
790#define MP_RECV_FRAG_MSG_RECVER   1
791#define MP_RECV_FRAG_MSG_SENDER   2
792#define MP_RECV_WHOLE_MSG         3
793#define MP_DEFAULT_RECV_MODE      MP_RECV_FRAG_MSG_RECVER
794
795/* Options that can be set for a link */
796#define MP_LINK_SEND_MODE_OPT 1
797#define MP_LINK_RECV_MODE_OPT 2
798#define MP_LINK_LOG_MASK_OPT  3
799
800#define  eor_mask ((unsigned long)(1 << 31))
801
802
803struct MP_Link_t
804{
805    int               link_id;
806    int               errno;
807    MP_Env_pt         env;
808    MP_Transport_t    transp;
809    MP_BigNum_t       bignum;       /* bignum type & fncs struct  */
810    int               logmask;
811    buffer_handle_pt  i_buff;       /* ptr to list of input buff  */
812    buffer_handle_pt  o_buff;       /* ptr to list of output buff */
813    buffer_handle_pt  curr_o_buff;  /* current output buffer      */
814    buffer_handle_pt  curr_i_buff;  /* current input buffer       */
815    int               num_o_buff;   /* number of o_buff to keep with stream */
816
817    int snd_mode; /* Two possible values:
818                   * MP_SEND_FRAG_MSG - send a fragment at a time
819                   * MP_SEND_WHOLE_MSG - send a tree at a time
820                   */
821
822    int rcv_mode; /* Three possible value:
823                   * MP_RECV_FRAG_MSG_RECVER - read one sender's
824                   * fragment at a time,
825                   * MP_RECV_FRAG_MSG_SENDER - read one reciever's
826                   * fragment at a time,
827                   * MP_RECV_WHOLE_MSG - read a tree at a time.
828                   */
829    /*
830     * out-going bits
831     */
832    char   *out_base;         /* output buffer (points to frag header) */
833    char   *out_finger;       /* next output position */
834    char   *out_boundry;      /* data can go up to this address */
835    unsigned long  *o_frag_header;    /* beginning of current fragment */
836
837    /*
838     * in-coming bits
839     */
840    char   *in_base;          /* input buffer (points to frag header) */
841    char   *in_finger;        /* location of next byte to be had */
842    char   *in_boundry;       /* can read up to this location */
843    unsigned long  *i_frag_header;    /* points to fragment header */
844
845    long         fbtbc;        /* fragment bytes to be consumed */
846    long         sfblr;        /* sender's fragment bytes left to be read */
847    MP_Boolean_t last_frag;    /* tell if curr. input buff. is last of tree */
848    MP_Boolean_t s_last_frag;  /* tell if current input buffer is part of
849                                  sender's last frag. of tree */
850
851    /* the next three are inherited from the link's  environment, but
852     * are resettable and, in some cases, negotiated with the partner
853     */
854    MP_WordOrder_t    link_word_order;
855    MP_FpFormat_t     link_fp_format;
856    MP_BigNumFormat_t link_bigint_format;   /* format of SENDER! */
857    MP_BigNumFormat_t link_bigreal_format;
858};
859
860#define TEST_LINK_NULL(link) \
861   if (link == NULL) return (MP_NullLink)
862
863EXTERN MP_Link_pt MP_OpenLink _ANSI_ARGS_((MP_Env_pt env, int argc,
864                                             char **argv));
865
866EXTERN void MP_CloseLink _ANSI_ARGS_((MP_Link_pt link));
867
868EXTERN void MP_KillLink _ANSI_ARGS_((MP_Link_pt link));
869
870EXTERN MP_Status_t MP_PeekHeader _ANSI_ARGS_((MP_Link_pt link,
871                                              MP_NodeType_t *ntype,
872                                              MP_DictTag_t *dtag,
873                                              MP_Common_t *cval));
874
875EXTERN MP_Status_t MP_InitMsg _ANSI_ARGS_((MP_Link_pt link));
876
877EXTERN MP_Status_t MP_SkipMsg _ANSI_ARGS_((MP_Link_pt link));
878
879EXTERN MP_Status_t MP_EndMsg _ANSI_ARGS_((MP_Link_pt link));
880
881EXTERN MP_Status_t MP_EndMsgReset _ANSI_ARGS_((MP_Link_pt link));
882
883EXTERN MP_Boolean_t MP_TestEofMsg _ANSI_ARGS_((MP_Link_pt link));
884
885EXTERN int MP_SetLinkOption _ANSI_ARGS_((MP_Link_pt link, int option,
886                                         int value));
887
888EXTERN int MP_GetLinkOption _ANSI_ARGS_((MP_Link_pt link, int option));
889
890EXTERN MP_Boolean_t MP_GetLinkStatus _ANSI_ARGS_((MP_Link_pt link,
891                                            MP_LinkStatus_t status_to_check));
892
893EXTERN MP_Status_t IMP_GetLong _ANSI_ARGS_((MP_Link_pt link, long *lp));
894
895EXTERN MP_Status_t IMP_PutLong _ANSI_ARGS_((MP_Link_pt link, long *lp));
896
897EXTERN MP_Status_t IMP_GetBytes _ANSI_ARGS_((MP_Link_pt link, char *addr,
898                                             unsigned long len));
899
900EXTERN MP_Status_t IMP_PutBytes _ANSI_ARGS_((MP_Link_pt link, char *addr,
901                                             unsigned long len));
902
903EXTERN MP_Status_t IMP_Restore _ANSI_ARGS_((MP_Link_pt link, unsigned long n));
904#endif  /* _MP_Link_h */
905
906/* Stuff included from h/MP_Buffer.h */
907/****************************************************************
908 *                                                                 
909 *   HEADER FILE:  MP_Buffer.h
910 *
911 *       Contains all declarations related to buffer and buffer pool.
912 *
913 ****************************************************************/
914#ifndef _MP_Buffer_h
915#define _MP_Buffer_h
916
917#ifndef _MP_BuffTypes_h
918#include "MP_BuffTypes.h"
919#endif
920
921EXTERN MP_Status_t m_create_pool _ANSI_ARGS_((MP_Env_pt env, int buffer_size,
922                                       int max_free_buff, int init_free_buff));
923EXTERN void m_free_pool     _ANSI_ARGS_((buffer_pool_pt buff_pool));
924EXTERN void m_free_in_bufs  _ANSI_ARGS_((MP_Link_pt link));
925EXTERN int MP_ResetLink     _ANSI_ARGS_((MP_Link_pt link));
926EXTERN void destroy_buffer  _ANSI_ARGS_((buffer_handle_pt buff, long buffsize));
927EXTERN void free_buffer     _ANSI_ARGS_((buffer_pool_pt buff_pool,
928                                         buffer_handle_pt buff));
929EXTERN buffer_handle_pt create_buffer _ANSI_ARGS_((buffer_pool_pt buff_pool));
930EXTERN buffer_handle_pt get_buffer    _ANSI_ARGS_((buffer_pool_pt buff_pool));
931EXTERN buffer_handle_pt get_o_buff    _ANSI_ARGS_((MP_Link_pt link));
932EXTERN buffer_handle_pt get_i_buff    _ANSI_ARGS_((MP_Link_pt link));
933EXTERN MP_Status_t reset_i_buff       _ANSI_ARGS_((MP_Link_pt link));
934
935#endif /* _MP_Buffer_h */
936
937/* Stuff included from h/MP_Util.h */
938/****************************************************************
939 *                                                                 
940 *   HEADER FILE:  MP_Util.h
941 *
942 ***************************************************************/
943
944#ifndef _MP_Util_h
945#define _MP_Util_h
946
947/* defines for logging events */
948#define MP_ERROR_EVENT   "ErrorE "
949#define MP_WRITE_EVENT   "WriteE "
950#define MP_READ_EVENT    "ReadE  "
951#define MP_INIT_EVENT    "InitE  "
952#define MP_URGENT_EVENT  "UrgentE"
953#define MP_CONTROL_EVENT "CntrlE "
954
955/*
956 * Logging is done on a per link basis.  The user is allowed to
957 * specify which events to log.  The default is to log all events.
958 * Error events are always logged and cannot be disabled.
959 */
960
961#define MP_LOG_READ_EVENTS         1
962#define MP_LOG_WRITE_EVENTS        2
963#define MP_LOG_INIT_EVENTS         4
964#define MP_LOG_CONTROL_EVENTS      8
965#define MP_LOG_URGENT_EVENTS      16
966#define MP_LOG_ALL_EVENTS         31
967#define MP_LOG_NO_EVENTS           0
968#define MP_LOG_NO_READ_EVENTS     ~MP_LOG_READ_EVENTS
969#define MP_LOG_NO_WRITE_EVENTS    ~MP_LOG_WRITE_EVENTS
970#define MP_LOG_NO_INIT_EVENTS     ~MP_LOG_INIT_EVENTS
971#define MP_LOG_NO_CONTROL_EVENTS  ~MP_LOG_CONTROL_EVENTS
972#define MP_LOG_NO_URGENT_EVENTS   ~MP_LOG_URGENT_EVENTS
973
974#define log_msg_len 128
975
976EXTERN char *IMP_StrDup  _ANSI_ARGS_((char* s));
977
978EXTERN void MP_LogEvent _ANSI_ARGS_((MP_Link_pt link, char *event, char *msg));
979
980EXTERN MP_Status_t MP_SetError _ANSI_ARGS_((MP_Link_pt link, 
981                                            MP_Status_t the_err));
982
983#define MP_ClearError(link) ((MP_Status_t) (link)->errno = MP_Success)
984
985EXTERN void MP_PrintError _ANSI_ARGS_((MP_Link_pt link));
986
987EXTERN char* MP_ErrorStr _ANSI_ARGS_((MP_Link_pt link));
988
989EXTERN char* MP_StatusErrorStr _ANSI_ARGS_((MP_Link_pt link, MP_Status_t status));
990
991EXTERN char *IMP_GetCmdlineArg _ANSI_ARGS_((int argc, char **argv, char *cmd));
992
993EXTERN char *IMP_TypeToString  _ANSI_ARGS_((MP_NodeType_t t));
994
995/* the following are used internally by MP for logging */
996
997EXTERN void log_dicttype _ANSI_ARGS_((MP_Link_pt link, char *event,
998                                      char *type_str, MP_NodeType_t type,
999                                      MP_NumAnnot_t na, MP_DictTag_t dtag,
1000                                      void *data, MP_NumChild_t nc));
1001
1002EXTERN void log_fixnum _ANSI_ARGS_((MP_Link_pt link, char *event,
1003                                    char *type_str, int type, MP_NumAnnot_t na,
1004                                    void *val));
1005
1006EXTERN void log_fixreal _ANSI_ARGS_((MP_Link_pt link, char *event,
1007                                     char *type_str, int type, MP_NumAnnot_t na,
1008                                     void *val));
1009
1010EXTERN void annot_flags_to_str _ANSI_ARGS_((MP_AnnotFlags_t flags));
1011
1012#endif /* _MP_Util_h */
1013
1014/* Stuff included from h/MP_Put.h */
1015/****************************************************************
1016 *                                                                 
1017 *   HEADER FILE:  MP_Put.h
1018 *                       
1019 ***************************************************************/
1020
1021#ifndef _MP_Put_h
1022#define _MP_Put_h
1023
1024#include "MP.h"
1025
1026EXTERN MP_Status_t  MP_PutAnnotationPacket _ANSI_ARGS_((MP_Link_pt link,
1027                                                        MP_DictTag_t dtag,
1028                                                        MP_AnnotType_t atype, 
1029                                                        MP_AnnotFlags_t flags));
1030
1031EXTERN MP_Status_t  MP_PutApIntPacket _ANSI_ARGS_((MP_Link_pt link, 
1032                                                   MP_ApInt_t apint,
1033                                                   MP_NumAnnot_t  num_annots));
1034
1035EXTERN MP_Status_t  MP_PutApRealPacket _ANSI_ARGS_((MP_Link_pt link, 
1036                                                    MP_ApReal_t apreal, 
1037                                                    MP_NumAnnot_t num_annots));
1038
1039EXTERN MP_Status_t  MP_PutSint32Packet _ANSI_ARGS_((MP_Link_pt link,
1040                                                    MP_Sint32_t  n, 
1041                                                    MP_NumAnnot_t  num_annots));
1042
1043EXTERN MP_Status_t  MP_PutUint32Packet _ANSI_ARGS_((MP_Link_pt link, 
1044                                                    MP_Uint32_t  n, 
1045                                                    MP_NumAnnot_t  num_annots));
1046
1047EXTERN MP_Status_t  MP_PutSint8Packet _ANSI_ARGS_((MP_Link_pt link,
1048                                                   MP_Sint8_t n, 
1049                                                   MP_NumAnnot_t  num_annots));
1050
1051EXTERN MP_Status_t  MP_PutUint8Packet _ANSI_ARGS_((MP_Link_pt link, 
1052                                                   MP_Uint8_t n,
1053                                                   MP_NumAnnot_t  num_annots));
1054
1055EXTERN MP_Status_t  MP_PutBooleanPacket _ANSI_ARGS_((MP_Link_pt link, 
1056                                                     MP_Boolean_t n,
1057                                                     MP_NumAnnot_t num_annots));
1058
1059EXTERN MP_Status_t  MP_PutReal32Packet _ANSI_ARGS_((MP_Link_pt link, 
1060                                                    MP_Real32_t n, 
1061                                                    MP_NumAnnot_t  num_annots));
1062
1063EXTERN MP_Status_t  MP_PutReal64Packet _ANSI_ARGS_((MP_Link_pt link, 
1064                                                    MP_Real64_t n, 
1065                                                    MP_NumAnnot_t  num_annots));
1066
1067EXTERN MP_Status_t  MP_PutOperatorPacket _ANSI_ARGS_((MP_Link_pt link,
1068                                                      MP_DictTag_t dtag, 
1069                                                      char *op, 
1070                                                      MP_NumAnnot_t num_annots, 
1071                                                      MP_NumChild_t num_child));
1072EXTERN MP_Status_t  MP_PutMetaOperatorPacket _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));
1077
1078EXTERN MP_Status_t  MP_PutCommonOperatorPacket _ANSI_ARGS_((MP_Link_pt link,
1079                                                            MP_DictTag_t dtag,
1080                                                            MP_Common_t op,
1081                                                            MP_NumAnnot_t num_annots, 
1082                                                            MP_NumChild_t num_child));
1083
1084EXTERN MP_Status_t  MP_PutCommonMetaOperatorPacket _ANSI_ARGS_((MP_Link_pt link,
1085                                                            MP_DictTag_t dtag,
1086                                                            MP_Common_t op,
1087                                                            MP_NumAnnot_t num_annots,
1088                                                            MP_NumChild_t num_child));
1089EXTERN MP_Status_t  MP_PutCommonMetaTypePacket _ANSI_ARGS_((MP_Link_pt link,
1090                                                        MP_DictTag_t dtag,
1091                                                        MP_Common_t cm,
1092                                                        MP_NumAnnot_t num_annots));
1093
1094EXTERN MP_Status_t  MP_PutRawPacket _ANSI_ARGS_((MP_Link_pt link,
1095                                                 char *data, 
1096                                                 MP_Uint32_t len,
1097                                                 MP_NumAnnot_t  num_annots));
1098
1099EXTERN MP_Status_t  MP_PutConstantPacket _ANSI_ARGS_((MP_Link_pt link, 
1100                                                      MP_DictTag_t dtag,
1101                                                      char *cnst,
1102                                                      MP_NumAnnot_t num_annots));
1103
1104EXTERN MP_Status_t  MP_PutCommonConstantPacket _ANSI_ARGS_((MP_Link_pt link,
1105                                                            MP_DictTag_t dtag, 
1106                                                            MP_Common_t cnst,
1107                                                            MP_NumAnnot_t num_annots));
1108
1109EXTERN MP_Status_t  MP_PutIdentifierPacket _ANSI_ARGS_((MP_Link_pt link,
1110                                                        MP_DictTag_t dtag,
1111                                                        char *id,
1112                                                        MP_NumAnnot_t num_annots));
1113
1114EXTERN MP_Status_t  MP_PutCommonLatinIdentifierPacket _ANSI_ARGS_((MP_Link_pt link,
1115                                                                   MP_DictTag_t dtag,
1116                                                                   MP_Common_t id,
1117                                                                   MP_NumAnnot_t  num_annots));
1118
1119EXTERN MP_Status_t  MP_PutCommonGreekIdentifierPacket _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_PutStringPacket _ANSI_ARGS_((MP_Link_pt link,
1125                                                    char *s,
1126                                                    MP_NumAnnot_t  num_annots));
1127
1128EXTERN MP_Status_t  MP_PutMetaTypePacket _ANSI_ARGS_((MP_Link_pt link,
1129                                                  MP_DictTag_t dtag, char *s,
1130                                                  MP_NumAnnot_t  num_annots));
1131
1132EXTERN MP_Status_t  IMP_PutString _ANSI_ARGS_((MP_Link_pt link,
1133                                               char *s));
1134
1135EXTERN MP_Status_t  IMP_PutOperator _ANSI_ARGS_((MP_Link_pt link,
1136                                                 char *op));
1137
1138EXTERN MP_Status_t  IMP_PutMetaOperator _ANSI_ARGS_((MP_Link_pt link,
1139                                                     char *op));
1140
1141EXTERN MP_Status_t  IMP_PutApInt _ANSI_ARGS_((MP_Link_pt link,
1142                                              MP_ApInt_t apint)); 
1143
1144EXTERN MP_Status_t  IMP_PutApReal _ANSI_ARGS_((MP_Link_pt link,
1145                                               MP_ApReal_t apreal));
1146
1147EXTERN MP_Status_t  IMP_PutBoolean _ANSI_ARGS_((MP_Link_pt link, 
1148                                                MP_Boolean_t n));
1149
1150EXTERN MP_Status_t  IMP_PutSint8 _ANSI_ARGS_((MP_Link_pt link,
1151                                              MP_Sint8_t  n));
1152
1153EXTERN MP_Status_t  IMP_PutUint8 _ANSI_ARGS_((MP_Link_pt link,
1154                                              MP_Uint8_t  n));
1155
1156EXTERN MP_Status_t  IMP_PutSint32 _ANSI_ARGS_((MP_Link_pt link,
1157                                               MP_Sint32_t n));
1158
1159EXTERN MP_Status_t  IMP_PutUint32 _ANSI_ARGS_((MP_Link_pt link,
1160                                               MP_Uint32_t n));
1161
1162EXTERN MP_Status_t  IMP_PutReal32 _ANSI_ARGS_((MP_Link_pt link,
1163                                               MP_Real32_t n));
1164
1165EXTERN MP_Status_t  IMP_PutReal64 _ANSI_ARGS_((MP_Link_pt link,
1166                                               MP_Real64_t n));
1167
1168EXTERN MP_Status_t  IMP_PutRaw _ANSI_ARGS_((MP_Link_pt link,
1169                                            char *rawdata,
1170                                            MP_Uint32_t len));
1171
1172EXTERN MP_Status_t  IMP_PutNodeHeader _ANSI_ARGS_((MP_Link_pt link, 
1173                                                   MP_NodeType_t ntype,
1174                                                   MP_DictTag_t dtag,
1175                                                   MP_Common_t cval, 
1176                                                   MP_NumAnnot_t num_annots,
1177                                                   MP_NumChild_t num_child));
1178
1179EXTERN MP_Status_t  IMP_PutStringBasedTypePacket _ANSI_ARGS_((MP_Link_pt link,
1180                                                              char *s,
1181                                                              MP_NumAnnot_t num_annots,
1182                                                              MP_NodeType_t ntype));
1183
1184/*
1185*  defines for putting a string-based type to the data stream.
1186*  The prototype
1187*        IMP_PutStringBasedTypePacket  (MP_Link_pt link, char *s,
1188*                MP_NumAnnot_t  num_annots, MP_NodeType _t ntype)
1189*  clarifies the type of the arguments.
1190*/
1191
1192#define IMP_PutIdentifier(link, id) \
1193   (IMP_PutString(link, id))
1194
1195#define IMP_PutMetaType(link, meta) \
1196   (IMP_PutString(link, meta))
1197
1198#endif  /* _MP_put_h */
1199
1200/* Stuff included from h/MP_Get.h */
1201/****************************************************************
1202 *                                                                 
1203 *   HEADER FILE:  MP_Get.h
1204 *                       
1205 ***************************************************************/
1206
1207#ifndef _MP_Get_h
1208#define _MP_Get_h
1209
1210EXTERN MP_Status_t  MP_GetAnnotationPacket _ANSI_ARGS_((MP_Link_pt link,
1211                                MP_DictTag_t *dtag, MP_AnnotType_t *atype,
1212                                MP_AnnotFlags_t *flags));
1213
1214EXTERN MP_Status_t  MP_GetApIntPacket _ANSI_ARGS_((MP_Link_pt link, 
1215                        MP_ApInt_pt apint, MP_NumAnnot_t *num_annots));
1216
1217EXTERN MP_Status_t  MP_GetApRealPacket _ANSI_ARGS_((MP_Link_pt link, 
1218                        MP_ApReal_pt apreal, MP_NumAnnot_t *num_annots));
1219
1220EXTERN MP_Status_t  MP_GetSint32Packet _ANSI_ARGS_((MP_Link_pt link,
1221                                    MP_Sint32_t *n, MP_NumAnnot_t *num_annots));
1222
1223EXTERN MP_Status_t  MP_GetUint32Packet _ANSI_ARGS_((MP_Link_pt link, 
1224                                    MP_Uint32_t *n, MP_NumAnnot_t *num_annots));
1225
1226EXTERN MP_Status_t  MP_GetSint8Packet _ANSI_ARGS_((MP_Link_pt link, 
1227                                    MP_Sint8_t *n,  MP_NumAnnot_t *num_annots));
1228
1229EXTERN MP_Status_t  MP_GetUint8Packet _ANSI_ARGS_((MP_Link_pt link, 
1230                                     MP_Uint8_t *n, MP_NumAnnot_t *num_annots));
1231
1232EXTERN MP_Status_t MP_GetBooleanPacket _ANSI_ARGS_((MP_Link_pt link, 
1233                                   MP_Boolean_t *n, MP_NumAnnot_t *num_annots));
1234
1235EXTERN MP_Status_t  MP_GetReal32Packet _ANSI_ARGS_((MP_Link_pt link, 
1236                                    MP_Real32_t *n, MP_NumAnnot_t *num_annots));
1237
1238EXTERN MP_Status_t  MP_GetReal64Packet _ANSI_ARGS_((MP_Link_pt link, 
1239                                    MP_Real64_t *n, MP_NumAnnot_t *num_annots));
1240
1241EXTERN MP_Status_t  MP_GetOperatorPacket _ANSI_ARGS_((MP_Link_pt link,
1242                           MP_DictTag_t *dtag, char **op,
1243                          MP_NumAnnot_t *num_annots, MP_NumChild_t *num_child));
1244
1245EXTERN MP_Status_t MP_GetCommonOperatorPacket _ANSI_ARGS_((MP_Link_pt link, 
1246                         MP_DictTag_t *dtag, MP_Common_t *op, 
1247                         MP_NumAnnot_t *num_annots,  MP_NumChild_t *num_child));
1248
1249EXTERN MP_Status_t MP_GetCommonMetaTypePacket _ANSI_ARGS_((MP_Link_pt link, 
1250                                        MP_DictTag_t *dtag, MP_Common_t *cmt, 
1251                                                  MP_NumAnnot_t *num_annots));
1252
1253EXTERN MP_Status_t MP_GetIdentifierPacket _ANSI_ARGS_((MP_Link_pt link, 
1254                                              MP_DictTag_t *dtag, char **id, 
1255                                              MP_NumAnnot_t *num_annots));
1256
1257EXTERN MP_Status_t MP_GetCommonLatinIdentifierPacket _ANSI_ARGS_((MP_Link_pt
1258                                 link,  MP_DictTag_t *dtag, MP_Common_t *id,
1259                                 MP_NumAnnot_t *num_annots));
1260
1261EXTERN MP_Status_t MP_GetCommonGreekIdentifierPacket _ANSI_ARGS_((MP_Link_pt
1262                             link, MP_DictTag_t *dtag, MP_Common_t *id, 
1263                             MP_NumAnnot_t *num_annots));
1264
1265EXTERN MP_Status_t MP_GetStringPacket _ANSI_ARGS_((MP_Link_pt link, char **s,
1266                                                          MP_NumAnnot_t *num_annots));
1267
1268EXTERN MP_Status_t MP_GetConstantPacket _ANSI_ARGS_((MP_Link_pt link, 
1269                                 MP_DictTag_t *dtag, char **cnst, 
1270                                 MP_NumAnnot_t *num_annots));
1271
1272EXTERN MP_Status_t MP_GetCommonConstantPacket _ANSI_ARGS_((MP_Link_pt link,
1273                            MP_DictTag_t *dtag, MP_Common_t *cnst, 
1274                            MP_NumAnnot_t *num_annots));
1275
1276EXTERN MP_Status_t MP_GetMetaTypePacket _ANSI_ARGS_((MP_Link_pt link, 
1277                        MP_DictTag_t *dtag, char **m,
1278                        MP_NumAnnot_t *num_annots));
1279
1280EXTERN MP_Status_t MP_GetRawPacket _ANSI_ARGS_((MP_Link_pt link, char **rawdata,
1281                        MP_Uint32_t *len,  MP_NumAnnot_t *num_annots));
1282EXTERN MP_Status_t IMP_GetUint8 _ANSI_ARGS_((MP_Link_pt link, MP_Uint8_t *n));
1283EXTERN MP_Status_t IMP_GetSint8 _ANSI_ARGS_((MP_Link_pt link, MP_Sint8_t *n));
1284EXTERN MP_Status_t IMP_GetBoolean _ANSI_ARGS_((MP_Link_pt link, MP_Boolean_t *n));
1285EXTERN MP_Status_t IMP_GetApInt _ANSI_ARGS_((MP_Link_pt link, MP_ApInt_pt apint));
1286EXTERN MP_Status_t IMP_GetApReal _ANSI_ARGS_((MP_Link_pt link, MP_ApReal_pt apreal));
1287EXTERN MP_Status_t IMP_GetReal32 _ANSI_ARGS_((MP_Link_pt link, MP_Real32_t *n));
1288EXTERN MP_Status_t IMP_GetReal64 _ANSI_ARGS_((MP_Link_pt link, MP_Real64_t *n));
1289EXTERN MP_Status_t IMP_GetSint32 _ANSI_ARGS_((MP_Link_pt link, MP_Sint32_t *n));
1290EXTERN MP_Status_t IMP_GetUint32 _ANSI_ARGS_((MP_Link_pt link, MP_Uint32_t *n));
1291
1292EXTERN MP_Status_t IMP_GetNodeHeader _ANSI_ARGS_((MP_Link_pt link, 
1293                          MP_NodeType_t *ntype, MP_DictTag_t *dtag,
1294                          MP_Common_t *cv, MP_NumAnnot_t *num_annots,
1295                          MP_NumChild_t *num_child));
1296
1297EXTERN MP_Status_t IMP_GetStringBasedType _ANSI_ARGS_((MP_Link_pt link, 
1298                                                        char **s));
1299
1300EXTERN MP_Status_t IMP_GetRaw _ANSI_ARGS_((MP_Link_pt link, char **rawdata,
1301                                           MP_Uint32_t *len));
1302
1303EXTERN MP_Status_t IMP_GetOperator _ANSI_ARGS_((MP_Link_pt link, char **op));
1304
1305/*
1306 *  defines for getting a string-based type from the data stream.
1307 */
1308
1309#define IMP_GetIdentifier(link, id) \
1310   (IMP_GetStringBasedType(link, id))
1311
1312#define IMP_GetString(link, str) \
1313   (IMP_GetStringBasedType(link, str))
1314
1315#define IMP_GetMetaType(link, meta) \
1316   (IMP_GetStringBasedType(link, meta))
1317
1318#define MP_GetCommonMetaOperatorPacket(link, dtag, op, num_annots, num_child) \
1319   (MP_GetCommonOperatorPacket(link, dtag, op, num_annots, num_child))
1320
1321#define MP_GetMetaOperatorPacket(link, dtag, op, num_annots, num_child) \
1322   (MP_GetOperatorPacket(link, dtag, op, num_annots, num_child))
1323
1324#define IMP_GetMetaOperator(link, op) \
1325   (IMP_GetStringBasedType(link, op))
1326
1327#endif /* _MP_Get_h */
1328
1329/* Stuff included from h/MP_FileTransp.h */
1330/***************************************************************************
1331 *                                                                 
1332 *   HEADER FILE:  MP_FileTransp.h
1333 *
1334 *        Declarations for the "file" transport device.
1335 *                                                               
1336 *  Change Log:
1337 *       September 10, 1995  SG - Updated implementation.  Much cleaning
1338 *                                to make it presentable.
1339 *       August 21, 1996     SG - Changed FILE_MODE from 0x666 to 0666.
1340 *                                Now it behaves properly
1341 *
1342 ***************************************************************************/
1343#ifndef _MP_FileTransp_h
1344#define _MP_FileTransp_h
1345
1346#define MP_NO_SUCH_FILE_MODE    0
1347#define MP_READ_MODE            1
1348#define MP_WRITE_MODE           2
1349#define MP_APPEND_MODE          3
1350
1351typedef struct {
1352    FILE    *fptr;
1353    int      access_mode; /* read, write, or append as defined above */
1354    char    *fname;
1355} MP_FILE_t;
1356
1357MP_Status_t file_flush _ANSI_ARGS_((MP_Link_pt link));
1358long file_write _ANSI_ARGS_((MP_Link_pt link, char * buf, long len));
1359long file_read _ANSI_ARGS_((MP_Link_pt link,
1360                            char *buf,
1361                            long len));
1362MP_Boolean_t file_get_status _ANSI_ARGS_((MP_Link_pt      link,
1363                                          MP_LinkStatus_t status_to_check));
1364MP_Status_t file_open_connection _ANSI_ARGS_((MP_Link_pt link,
1365                                              int        argc,
1366                                              char       **argv));
1367MP_Status_t file_close_connection _ANSI_ARGS_((MP_Link_pt link));
1368MP_Status_t file_init_transport _ANSI_ARGS_((MP_Link_pt link));
1369int get_file_mode _ANSI_ARGS_((int  argc,
1370                               char **argv));
1371#endif /* _MP_FileTransp_h */
1372
1373/* Stuff included from h/MP_TcpTransp.h */
1374/***************************************************************************
1375 *
1376 *   HEADER FILE:  MP_TcpTransp.h
1377 *
1378 *        Isolate all the includes we need for unix TCP sockets.
1379 *
1380 *  Change Log:
1381 *       September 10, 1995  SG - Updated implementation.  Much cleaning
1382 *                                to make it presentable.
1383 *
1384 ***************************************************************************/
1385#ifndef __TcpTransp__h
1386#define __TcpTransp__h
1387
1388#include <stdio.h>
1389#include <sys/types.h>
1390#include <sys/time.h>
1391
1392#ifdef __WIN32__
1393
1394#   include <winsock.h>
1395
1396#   define  ERRORCODE(err)      WSA ## err
1397#   define  LASTERROR           WSAGetLastError()
1398
1399#   define  CLOSE_SOCKET(s)             closesocket(s)
1400#   define  READ_SOCKET(s, buf, len)    recv(s, buf, len, 0)
1401#   define  WRITE_SOCKET(s, buf, len)   send(s, buf, len, 0)
1402
1403int WinSockInitialize _ANSI_ARGS_((void));
1404
1405#else /* not __WIN32__ */
1406
1407#   include <sys/socket.h>
1408#   include <netinet/in.h>
1409#   include <netinet/tcp.h>
1410#   include <sys/ioctl.h>
1411#   include <arpa/inet.h>
1412#   include <netdb.h>
1413
1414typedef int SOCKET;
1415
1416#   define  INVALID_SOCKET      -1
1417#   define  SOCKET_ERROR        -1
1418#   define  IPPORT_RESERVED     1024
1419#   define  ERRORCODE(err)      err
1420#   define  LASTERROR           errno
1421
1422#   define  CLOSE_SOCKET(s)             close(s)
1423#   define  READ_SOCKET(s, buf, len)    read(s, buf, len)
1424#   define  WRITE_SOCKET(s, buf, len)   write(s, buf, len)
1425
1426#   define  HOSTENT             struct hostent
1427#   define  SOCKADDR            struct sockaddr
1428#   define  TIMEVAL             struct timeval
1429#   define  SOCKADDR_IN         struct sockaddr_in
1430
1431#endif /* not __WIN32__ */
1432
1433
1434#define MP_NO_SUCH_TCP_MODE     0
1435#define MP_CONNECT_MODE         1
1436#define MP_LISTEN_MODE          2
1437#define MP_LAUNCH_MODE          3
1438#define MP_FORK_MODE            4
1439
1440/* Initial port for listening */
1441#define MP_INIT_PORT            "1025"
1442
1443/* The maximum number of attempts made to bind a socket to a port address */
1444#define MP_MAX_BIND_ATTEMPTS    1000
1445
1446#define MP_ACCEPT_WAIT_SEC      5
1447#define MP_ACCEPT_WAIT_USEC     0
1448
1449MP_Status_t tcp_flush _ANSI_ARGS_((MP_Link_pt link));
1450long tcp_write _ANSI_ARGS_((MP_Link_pt, char *, long));
1451long tcp_read _ANSI_ARGS_((MP_Link_pt, char *, long));
1452MP_Boolean_t tcp_get_status _ANSI_ARGS_((MP_Link_pt, MP_LinkStatus_t));
1453MP_Status_t tcp_init_transport _ANSI_ARGS_((MP_Link_pt));
1454MP_Status_t tcp_open_connection _ANSI_ARGS_((MP_Link_pt, int, char**));
1455MP_Status_t tcp_close_connection _ANSI_ARGS_((MP_Link_pt));
1456MP_Status_t tcp_kill_connection _ANSI_ARGS_((MP_Link_pt));
1457MP_Status_t open_tcp_connect_mode _ANSI_ARGS_((MP_Link_pt, int, char**));
1458MP_Status_t open_tcp_listen_mode _ANSI_ARGS_((MP_Link_pt, int, char**));
1459MP_Status_t open_tcp_launch_mode _ANSI_ARGS_((MP_Link_pt, int, char**));
1460MP_Status_t socket_accept_blocking _ANSI_ARGS_((MP_Link_pt, SOCKET*));
1461MP_Status_t socket_accept_non_blocking _ANSI_ARGS_((MP_Link_pt, SOCKET*));
1462char* IMP_GetCmdlineArg _ANSI_ARGS_((int, char**, char*));
1463
1464
1465typedef struct{
1466    SOCKET  bindsock;
1467    SOCKET  sock;
1468    short   peerport;
1469    char    *peerhost;
1470    char    *myhost;
1471    MP_LinkStatus_t status;
1472    pid_t   peerpid;
1473  char *rsh;
1474  int mode;
1475} MP_TCP_t;
1476
1477#endif
1478
1479/* Stuff included from h/MP_Vector.h */
1480/****************************************************************
1481 *                                                                 
1482 *   HEADER FILE:  MP_Vector.h
1483 *                                                               
1484 ***************************************************************/
1485
1486#ifndef _MP_Vector_h
1487#define _MP_Vector_h
1488
1489#include "MP.h"
1490
1491/* Putting a Vector */
1492EXTERN MP_Status_t IMP_PutBasicVectorHeader
1493_ANSI_ARGS_((MP_Link_pt link, MP_Common_t elem_type,
1494              MP_NumAnnot_t na, MP_NumChild_t num_elems));
1495
1496EXTERN MP_Status_t MP_PutBasicVector
1497_ANSI_ARGS_((MP_Link_pt link, void *elems,
1498             MP_Common_t elem_type, MP_NumChild_t num_elems));
1499
1500EXTERN MP_Status_t IMP_PutBasicVector
1501_ANSI_ARGS_((MP_Link_pt link, void *elems,
1502             MP_Common_t elem_type, MP_NumChild_t num_elems));
1503
1504EXTERN MP_Status_t  IMP_PutReal64Vector
1505_ANSI_ARGS_((MP_Link_pt link, MP_Real64_t *dvec, MP_NumChild_t len));
1506
1507EXTERN MP_Status_t  IMP_PutUint32Vector
1508_ANSI_ARGS_((MP_Link_pt link, MP_Uint32_t *si32vec, MP_NumChild_t len));
1509
1510EXTERN MP_Status_t  IMP_PutUint16Vector
1511_ANSI_ARGS_((MP_Link_pt link, MP_Uint16_t *si16vec, MP_NumChild_t len));
1512
1513EXTERN MP_Status_t  IMP_PutUint8Vector
1514_ANSI_ARGS_((MP_Link_pt link, MP_Uint8_t *si8vec, MP_NumChild_t len));
1515
1516#define IMP_PutReal32Vector(link, vec, len)         \
1517IMP_PutUint32Vector(link, (MP_Uint32_t *) vec, len)
1518
1519#define IMP_PutSint32Vector(link, vec, len)         \
1520IMP_PutUint32Vector(link, (MP_Uint32_t *) vec, len)
1521
1522#define IMP_PutSint16Vector(link, vec, len)         \
1523IMP_PutUint16Vector(link, (MP_Uint16_t *) vec, len)
1524
1525#define IMP_PutSint8Vector(link, vec, len)         \
1526IMP_PutUint8Vector(link, (MP_Uint8_t *) vec, len)
1527
1528/* Getting a vector */
1529EXTERN MP_Status_t MP_GetBasicVector
1530_ANSI_ARGS_((MP_Link_pt link, void **elems,
1531             MP_Common_t elem_type, MP_NumChild_t num_elems));
1532
1533EXTERN MP_Status_t
1534IMP_GetReal64Vector _ANSI_ARGS_((MP_Link_pt link, 
1535                                 MP_Real64_t **dvec, MP_NumChild_t len));
1536
1537EXTERN MP_Status_t
1538IMP_GetUint32Vector _ANSI_ARGS_((MP_Link_pt link,
1539                                 MP_Uint32_t **si32vec, MP_NumChild_t len));
1540
1541EXTERN MP_Status_t  IMP_GetUint16Vector
1542_ANSI_ARGS_((MP_Link_pt link, MP_Uint16_t **si16vec, MP_NumChild_t len));
1543
1544EXTERN MP_Status_t  IMP_GetUint8Vector
1545_ANSI_ARGS_((MP_Link_pt link, MP_Uint8_t **si8vec, MP_NumChild_t len));
1546
1547#define IMP_GetReal32Vector(link, vec, len)         \
1548IMP_GetUint32Vector(link, (MP_Uint32_t **) vec, len)
1549
1550#define IMP_GetSint32Vector(link, vec, len)         \
1551IMP_GetUint32Vector(link, (MP_Uint32_t **) vec, len)
1552
1553#define IMP_GetSint16Vector(link, vec, len)         \
1554IMP_GetUint16Vector(link, (MP_Uint16_t **) vec, len)
1555
1556#define IMP_GetSint8Vector(link, vec, len)         \
1557IMP_GetUint8Vector(link, (MP_Uint8_t **) vec, len)
1558
1559#endif /* _MP_Vector_h */
1560
1561/* Stuff included from h/MP_GmpBigInt.h */
1562/****************************************************************
1563 *                                                                 
1564 *   HEADER FILE:  MP_GmpBigInt.h
1565 *
1566 *  The bigint routines of gmp
1567 *
1568 ****************************************************************/
1569
1570#ifndef _MP_GmpBigInt_h
1571#define _MP_GmpBigInt_h
1572
1573#include "MP.h"
1574
1575#ifdef MP_HAVE_GMP_APINT
1576
1577#include "gmp.h"
1578
1579EXTERN MP_BigIntOps_t imp_gmp_bigint_ops;
1580
1581EXTERN MP_Status_t IMP_GetGmpInt _ANSI_ARGS_((MP_Link_pt link,
1582                                              MP_ApInt_t* mp_apint));
1583EXTERN MP_Status_t IMP_PutGmpInt _ANSI_ARGS_((MP_Link_pt link,
1584                                              MP_ApInt_t mp_apint));
1585EXTERN char *IMP_GmpIntToStr _ANSI_ARGS_((MP_ApInt_t mp_apint,
1586                                          char *buffer));
1587EXTERN long IMP_GmpIntAsciiSize _ANSI_ARGS_((MP_ApInt_t mp_apint));
1588
1589#endif /* MP_HAVE_GMP_APINT */ 
1590
1591#endif /* _MP_GmpBigInt_h */
1592
1593/* Stuff included from h/MP_GmpBigReal.h */
1594/****************************************************************
1595 *                                                                 
1596 *   HEADER FILE:  MP_GmpBigReal.h
1597 *
1598 *  The bigreal routines of gmp
1599 *
1600 ****************************************************************/
1601
1602#ifndef _MP_GmpBigReal_h
1603#define _MP_GmpBigReal_h
1604
1605#include "MP.h"
1606
1607#ifdef MP_HAVE_GMP_APREAL
1608#include "gmp.h"
1609
1610EXTERN MP_BigRealOps_t imp_gmp_bigreal_ops;
1611
1612EXTERN MP_Status_t IMP_GetGmpReal _ANSI_ARGS_((MP_Link_pt link,
1613                                              MP_ApReal_t* mp_apreal));
1614EXTERN MP_Status_t IMP_PutGmpReal _ANSI_ARGS_((MP_Link_pt link,
1615                                              MP_ApReal_t mp_apreal));
1616EXTERN char *IMP_GmpRealToStr _ANSI_ARGS_((MP_ApReal_t mp_apreal,
1617                                          char *buffer));
1618EXTERN long IMP_GmpRealAsciiSize _ANSI_ARGS_((MP_ApReal_t mp_apreal));
1619
1620#endif /* MP_HAVE_GMP_APREAL */
1621#endif /* _MP_GmpBigReal_h */
1622
1623/* Stuff included from h/MP_PariBigInt.h */
1624/****************************************************************
1625 *                                                                 
1626 * HEADER FILE:  MP_PariBigInt.h
1627 * Authors:  O. Bachmann, T. Metzner, H. Schoenemann, A. Sorgatz
1628 * Date:    February 97
1629 *                                                               
1630 ***************************************************************/
1631
1632#ifndef _MP_PariBigInt_h
1633#define _MP_PariBigInt_h
1634
1635#include "MP.h"
1636#ifdef MP_HAVE_PARI
1637
1638/* Dirty hack with honors to andi: pari defines "overflow" identifier
1639   which conflicts with the definition in some libraries (e.g. in
1640   iostream -- hence, we overshadow this defitnition before includeing
1641   genpari */
1642#ifndef overflow
1643#define overflow muff
1644#include "genpari.h"
1645#undef overflow
1646#endif
1647
1648
1649EXTERN MP_BigIntOps_t imp_pari_bigint_ops;
1650
1651EXTERN MP_Status_t IMP_GetPariBigInt _ANSI_ARGS_((MP_Link_pt link,
1652                                                 MP_ApInt_t *pari_number));
1653EXTERN MP_Status_t IMP_PutPariBigInt _ANSI_ARGS_((MP_Link_pt link, 
1654                                                 MP_ApInt_t pari_number));
1655EXTERN char* IMP_PariBigIntToStr _ANSI_ARGS_((MP_ApInt_t pari_number,
1656                                              char *buffer));
1657EXTERN long IMP_PariBigIntAsciiSize _ANSI_ARGS_((MP_ApInt_t mp_number));
1658
1659/* Memory mamagment for Pari BigInts:
1660   By default, the following functions are simple cgeti and empty;
1661   You can reset this at run-time to whatever fits your needs
1662*/
1663EXTERN GEN (*IMP_AllocCgeti) _ANSI_ARGS_((long));
1664EXTERN void (*IMP_FreeCgeti) _ANSI_ARGS_((GEN));
1665
1666#ifdef HAVE_GMP_PARI_CONVERSIONS
1667#include "gmp.h"
1668EXTERN mpz_ptr _pari_to_gmp(GEN pnum, mpz_ptr *gnum_ptr);
1669EXTERN GEN     _gmp_to_pari(mpz_ptr gnum);
1670#endif
1671
1672#endif /* MP_HAVE_PARI */
1673
1674#endif  /* _MP_PariBigInt_h */
1675
1676/* Stuff included from h/MP_PvmTransp.h */
1677/***************************************************************************
1678 *                                                                 
1679 *   HEADER FILE:  MP_PvmTransp.h
1680 *
1681 *
1682 *  Change Log:
1683 *      1/25/96 sgray - formal creation of PVM transport device.
1684 *
1685 ***************************************************************************/
1686#ifndef __PvmTransp__h
1687#define __PvmTransp__h
1688
1689#include "MP_Config.h"
1690
1691#ifdef MP_HAVE_PVM
1692#include "pvm3.h"
1693
1694#define MP_NO_SUCH_PVM_MODE    0
1695
1696typedef struct{
1697  int     nhosts;
1698  int     ntids;  /* the number of tids in next field */
1699  int     *tids;
1700  int     tag;
1701  int     send_mode;
1702  char    *myhost;
1703} MP_PVM_t;
1704
1705/*#include "/tmp_mnt/home/Owl/sgray/MP/MP/MP_PvmTransp.c" */ 
1706
1707#endif /*  MP_HAVE_PVM */
1708
1709#endif
1710
1711/* Stuff included from h/MP_SacBigInt.h */
1712/****************************************************************
1713 *                                                                 
1714 *   HEADER FILE:  MP_SacBigInt.h
1715 *                                                               
1716 ***************************************************************/
1717
1718#ifndef _MP_SacBigInt_h
1719#define _MP_SacBigInt_h
1720
1721#include "MP.h"
1722
1723#ifdef MP_HAVE_SAC
1724#include "saclib.h"
1725#include "gmp.h"
1726
1727EXTERN MP_BigIntOps_t sac_ops;
1728
1729EXTERN MP_Status_t IMP_PutSacBigInt _ANSI_ARGS_((MP_Link_pt link, 
1730                                                 MP_ApInt_t sac_int));
1731
1732EXTERN MP_Status_t IMP_GetSacBigInt _ANSI_ARGS_((MP_Link_pt link,
1733                                                 MP_ApInt_t *sac_int));
1734
1735EXTERN char * IMP_SacBigIntToStr _ANSI_ARGS_((MP_ApInt_t big_int, 
1736                                             char *buffer));
1737
1738EXTERN long IMP_SacBigIntAsciiSize _ANSI_ARGS_((MP_ApInt_t mp_apint));
1739
1740#endif /* MP_HAVE_SAC */
1741
1742#endif  /* _MP_SacBigInt_h */
1743
1744/* Stuff included from h/MP_TbTransp.h */
1745/***************************************************************************
1746 *                                                                 
1747 *   HEADER FILE:  MP_TbTransp.h
1748 *
1749 *   PURPOSE: ToolBus stuff - not much to do.
1750 *
1751 *   Change Log:
1752 *      2/6/96 sgray - creation of TB transport device.
1753 *      6/9/96 sgray - updated tb struct to support buffering of terms
1754 *                     consistent with what the buffering layer expects.
1755 *
1756 ***************************************************************************/
1757#ifndef __TbTransp__h
1758#define __TbTransp__h
1759
1760#include "MP_Config.h"
1761
1762#ifdef MP_HAVE_TB
1763#include "TB.h"
1764
1765
1766typedef struct{
1767  term    *write_term,
1768          *read_term;
1769  char    *term_buf;     /* where next binary TB term will be unloaded    */
1770  char    *next_byte;    /* next byte to be consumed in term_buf          */
1771  unsigned long buf_len; /* number of bytes in term_buf                   */
1772  unsigned long tbtbc;   /* Term Bytes To Be Consumed in term_buf         */
1773  char    *myhost;       /* host on which we are running - must have this */
1774} MP_TB_t;
1775
1776EXTERN MP_Status_t MP_TbPutMsg _ANSI_ARGS_((MP_Link_pt link, char **tb_data, 
1777                                            unsigned long *len)); 
1778EXTERN MP_Status_t MP_TbGetMsg _ANSI_ARGS_((MP_Link_pt link, char *tb_data, 
1779                                            unsigned long len)); 
1780EXTERN MP_Status_t MP_TbSetTerm _ANSI_ARGS_((MP_Link_pt link, term *t));
1781
1782/*
1783 * if your device may not be available everywhere you want to use MP,
1784 * don't try to compile the source into the library as the link will
1785 * fail.  The alternative is to include the transport device interface
1786 * source here and have the user include this header file in their
1787 * application code.  Then the corresponding .c file will be compiled
1788 * with the application
1789 */
1790/* #include "../MP/MP_TbTransp.c" */
1791
1792#endif /* MP_HAVE_TB */
1793
1794#endif
1795
1796/* MP Dictionary includes */
1797
1798/* Stuff included from h/MP_BasicDict.h */
1799/***************************************************************************
1800 *
1801 *   HEADER FILE:  MP_BasicDict.h                                         
1802 *                                                               
1803 *      The MP basic dictionary (definitions and declarations)
1804 *     
1805 *       
1806 *   Change Log:
1807 *      1/97 obachman  -- this is a first try
1808 *
1809 ***************************************************************************/
1810#ifndef _MP_BasicDict_h
1811#define _MP_BasicDict_h
1812
1813
1814
1815/***************************************************************************
1816 *
1817 * Common Operator Definitions
1818 *
1819 ***************************************************************************/
1820/* for the time being, no attention was paid to "good" numeric value
1821   assignments */
1822#define MP_CopBasicInc              1
1823#define MP_CopBasicDec              2
1824#define MP_CopBasicSize             3
1825#define MP_CopBasicList             4
1826#define MP_CopBasicAdd              5
1827#define MP_CopBasicMinus            6
1828#define MP_CopBasicMult             7
1829#define MP_CopBasicDiv              8
1830#define MP_CopBasicMod              9
1831#define MP_CopBasicPow              10
1832#define MP_CopBasicGreaterEqual     11
1833#define MP_CopBasicGreater          12
1834#define MP_CopBasicLessEqual        13
1835#define MP_CopBasicLess             14
1836#define MP_CopBasicAnd              15
1837#define MP_CopBasicOr               16
1838#define MP_CopBasicEqual            17   
1839#define MP_CopBasicNotEqual         18
1840#define MP_CopBasicRange            19
1841#define MP_CopBasicIndex            20
1842#define MP_CopBasicDiff             21
1843#define MP_CopBasicInterSect        22       
1844#define MP_CopBasicSubst            23
1845#define MP_CopBasicNot              24
1846#define MP_CopBasicAssign           25
1847#define MP_CopBasicComplex          26
1848
1849#endif /* _MP_BasicDict_h */
1850
1851/* Stuff included from h/MP_MpDict.h */
1852/***************************************************************************
1853 *
1854 *   HEADER FILE:  MP_MpDict.h
1855 *
1856 *      The MP dictionary for (definitions and declarations)
1857 *
1858 *
1859 *   Change Log:
1860 *        3/26/97  sgray - Life begins for this file.
1861 *
1862 ***************************************************************************/
1863#ifndef _MP_MpDict_h
1864#define _MP_MpDict_h
1865
1866/* Let's give the MP Dictionary the number 2 */
1867
1868#define MP_MpDict 2
1869
1870/***************************************************************************
1871 *
1872 * Common Operator Definitions
1873 *
1874 ***************************************************************************/
1875#define MP_CopMpEndSession               1
1876
1877#define MP_CopMpByteOrderRequest        10
1878#define MP_CopMpFpFormatRequest         11
1879#define MP_CopMpBigIntFormatRequest     12
1880
1881/***************************************************************************
1882 *
1883 * Annotations
1884 *
1885 ***************************************************************************/
1886#define MP_AnnotMpLabel                 1
1887#define MP_AnnotMpRef                   2
1888#define MP_AnnotMpStore                 3
1889#define MP_AnnotMpStored                4
1890#define MP_AnnotMpRetrieve              5
1891#define MP_AnnotMpSource                6
1892#define MP_AnnotMpComment               7
1893#define MP_AnnotMpTiming                8
1894#define MP_AnnotMpType                  9
1895#define MP_AnnotMpUnits                10
1896
1897#endif /* _MP_MpDict_h  */
1898
1899/* Stuff included from h/MP_NumberDict.h */
1900/***************************************************************************
1901 *
1902 *   HEADER FILE:  MP_NumberDict.h                                         
1903 *                                                               
1904 *      The Numbertype dictionary (definitions and declarations)
1905 *     
1906 *       
1907 *   Change Log:
1908 *
1909 *
1910 ***************************************************************************/
1911#ifndef _MP_NumberDict_h
1912#define _MP_NumberDict_h
1913
1914/* Lets give the Number Dictionary the number 12 */
1915
1916#define MP_NumberDict 12
1917
1918/***************************************************************************
1919 *
1920 * Meta type definitions
1921 *
1922 ***************************************************************************/
1923#define MP_CmtNumberRational            1
1924#define MP_CmtNumberInteger             2
1925#define MP_CmtNumberComplex             3
1926#define MP_CmtNumberReal                4
1927#define MP_CmtNumberCharp               5
1928#define MP_CmtNumberModulo              6
1929
1930
1931/***************************************************************************
1932 *
1933 * Annot definitions
1934 *
1935 ***************************************************************************/
1936#define MP_AnnotNumberIsNormalized          1
1937#define MP_AnnotNumberIsPrime               2
1938#define MP_AnnotNumberModulos               3
1939
1940
1941/***************************************************************************
1942 *
1943 * Common Operator Definitions
1944 *
1945 ***************************************************************************/
1946#define MP_CopNumberPrime               1
1947#define MP_CopNumberExtGcd              2
1948#define MP_CopNumberGcd                 3
1949#define MP_CopNumberRandom              4
1950
1951
1952#endif /* _MP_NumberDict_h */
1953
1954/* Stuff included from h/MP_ProtoDict.h */
1955/***************************************************************************
1956 *
1957 *   HEADER FILE:  MP_ProtoDict.h                                         
1958 *                                                               
1959 *      The prototype dictionary (definitions and declarations)
1960 *     
1961 *       
1962 *   Change Log:
1963 *
1964 *
1965 ***************************************************************************/
1966#ifndef _MP_ProtoDict_h
1967#define _MP_ProtoDict_h
1968
1969#define MP_ProtoDict 6
1970
1971/***************************************************************************
1972 *
1973 * Meta type definitions
1974 *
1975 ***************************************************************************/
1976/* We use the same numerical values as we use for the MP types */
1977#define MP_CmtProto_2_MPType(cmt)   cmt
1978
1979#define MP_CmtProtoIMP_Sint8                        65
1980#define MP_CmtProtoIMP_Uint8                        67
1981#define MP_CmtProtoIMP_Boolean                      68
1982#define MP_CmtProtoIMP_LatinIdentifier              72
1983#define MP_CmtProtoIMP_GreekIdentifier              76
1984#define MP_CmtProtoIMP_CommonConstant               80
1985
1986#define MP_CmtProtoIMP_String                       36
1987#define MP_CmtProtoIMP_Constant                     40
1988#define MP_CmtProtoIMP_Identifier                   44
1989
1990#define MP_CmtProtoIMP_Sint32                       17
1991#define MP_CmtProtoIMP_Uint32                       19
1992#define MP_CmtProtoIMP_Real32                       18
1993
1994#define MP_CmtProtoIMP_ApInt                        9
1995#define MP_CmtProtoIMP_ApReal                       10
1996
1997#define MP_CmtProtoIMP_Real64                       6
1998
1999#define MP_CmtProtoRecStruct   128
2000#define MP_CmtProtoRecUnion    129
2001
2002/* Basic types, i.e. those which appear as a leaf of a data tree
2003   have numerical values between 0 and 127 ,i.e. bit 8 is zero */
2004#define IMP_IsBasicMetaType(type)    (!((type) & 128))
2005
2006/* native 8-bit types have numeric values between 64 and 127
2007   i.e. bit 8 is zero and bit 7 is one */
2008#define IMP_Is8BitNumericMetaType(type)    (!((type) & 128) && ((type) & 64))
2009
2010/* native String-based types have numeric values between 32 an 63,
2011   i.e. bit 8,7 are zero, bit 6 is one */
2012#define IMP_IsStringBasedMetaType(type)  (!((type) & 192) && ((type) & 32))
2013
2014/* native 32 bit types have numeric values beween 16 and 31, i.e. bits
2015   8,7,6, are zero, bit 5 is one. Furthermore, integers have bit 1 set
2016   to 1 and Reals have bit 1 set to 0 */
2017#define IMP_Is32BitNumericMetaType(type)    (!((type) & 224) && ((type) & 16))
2018#define IMP_Is16BitNumericMetaType(type) 0
2019/* Ap Numbers have bit 5-8 set to zero, bit 4 set to one */
2020#define IMP_IsApNumberMetaType(type) (!((type) & 240) && ((type) & 8))
2021
2022/* Native 64-bit numbers have bit 4-8 set to zero, bit 3 set to one */
2023#define IMP_Is64BitNumericMetaType(type)    (type == MP_CmtProtoIMP_Real64)
2024
2025/* Predicates for real and integers
2026   Integers are odd numbers, reals are even numbers, not divisble by 4*/
2027#define IMP_IsRealMetaType(type)   (IMP_IsBasicMetaType(type) &&    \
2028                                 !((type) & 1) &&           \
2029                                 ((type) >> 1) & 1)
2030#define IMP_IsIntegerMetaType(type)(IMP_IsBasicMetaType(type) && ((type) & 1))
2031
2032/***************************************************************************
2033 *
2034 * Common Operator Definitions
2035 *
2036 ***************************************************************************/
2037#define MP_CopProtoStruct                1
2038#define MP_CopProtoUnion                 2
2039#define MP_CopProtoArray                 3
2040#define MP_CopProtoPointer               4
2041#define MP_CopProtoRecStruct             5
2042#define MP_CopProtoRecUnion              6
2043
2044/***************************************************************************
2045 *
2046 * Definition of Annots
2047 *
2048 ***************************************************************************/
2049#define MP_AnnotProtoPrototype           1
2050
2051#endif /* _MP_ProtoDict_h */
2052
2053/* Stuff included from h/MP_PolyDict.h */
2054/***************************************************************************
2055 *
2056 *   HEADER FILE:  MP_PolyDict.h                                         
2057 *                                                               
2058 *      The Polytype dictionary (definitions and declarations)
2059 *     
2060 *       
2061 *   Change Log:
2062 *
2063 *
2064 ***************************************************************************/
2065#ifndef _MP_PolyDict_h
2066#define _MP_PolyDict_h
2067
2068/* Lets give the Poly Dictionary the number 10 */
2069
2070#define MP_PolyDict 10
2071
2072/***************************************************************************
2073 *
2074 * Annotations
2075 *
2076 ***************************************************************************/
2077#define MP_AnnotPolyModuleVector        1
2078#define MP_AnnotPolyVarNames            2
2079#define MP_AnnotPolyVarNumber           3
2080#define MP_AnnotPolyOrdering            4
2081#define MP_AnnotPolyDefRel              5
2082#define MP_AnnotPolyIrreducible         6
2083#define MP_AnnotPolyWeights             8
2084#define MP_AnnotPolyModuleRank          9
2085#define MP_AnnotShouldHavePolyOrdering  10
2086
2087/***************************************************************************
2088 *
2089 * (Common) Constants
2090 *
2091 ***************************************************************************/
2092#define MP_CcPolyOrdering_Unknown       0
2093#define MP_CcPolyOrdering_Vector        1 /* a */
2094#define MP_CcPolyOrdering_Matrix        2 /* M */
2095#define MP_CcPolyOrdering_IncComp       3 /* c */
2096#define MP_CcPolyOrdering_DecComp       4 /* C */
2097#define MP_CcPolyOrdering_Lex           5 /* lp */
2098#define MP_CcPolyOrdering_DegRevLex     6 /* dp */
2099#define MP_CcPolyOrdering_DegLex        7 /* Dp */
2100#define MP_CcPolyOrdering_NegLex        8 /* ls */
2101#define MP_CcPolyOrdering_NegDegRevLex  9 /* ds */
2102#define MP_CcPolyOrdering_NegDegLex     10 /* Ds */
2103#define MP_CcPolyOrdering_NegRevLex     11
2104#define MP_CcPolyOrdering_RevLex        12
2105
2106#if 0 /* Here is what it used to be */
2107#define MP_CcPolyOrdering_No    0
2108#define MP_CcPolyOrdering_a     1
2109#define MP_CcPolyOrdering_c     2
2110#define MP_CcPolyOrdering_C     3
2111#define MP_CcPolyOrdering_M     4
2112#define MP_CcPolyOrdering_lp    5
2113#define MP_CcPolyOrdering_Dp    6
2114#define MP_CcPolyOrdering_wp    7
2115#define MP_CcPolyOrdering_Wp    8
2116#define MP_CcPolyOrdering_ls    9
2117#define MP_CcPolyOrdering_ds    10
2118#define MP_CcPolyOrdering_Ds    11
2119#define MP_CcPolyOrdering_ws    12
2120#define MP_CcPolyOrdering_Ws    13
2121#define MP_CcPolyOrdering_Unspec 14
2122#endif
2123
2124
2125/***************************************************************************
2126 *
2127 * Common Operator Definitions
2128 *
2129 ***************************************************************************/
2130
2131#define MP_CopPolyBetti                 1
2132#define MP_CopPolyChar                  2
2133#define MP_CopPolyCharSeries            3
2134#define MP_CopPolyDeg                   4
2135#define MP_CopPolyDim                   5
2136#define MP_CopPolyFactorize             6
2137#define MP_CopPolyHilb                  7
2138#define MP_CopPolyHomog                 8
2139#define MP_CopPolyInDepSet              9
2140#define MP_CopPolyIdeal                 10
2141#define MP_CopPolyKbase                 11
2142#define MP_CopPolyLead                  12
2143#define MP_CopPolyLeadCoef              13
2144#define MP_CopPolyLeadExp               14
2145#define MP_CopPolyMaxIdeal              15
2146#define MP_CopPolyMinBase               16
2147#define MP_CopPolyMinRes                17
2148#define MP_CopPolyModule                18
2149#define MP_CopPolyMultiplicity          19
2150#define MP_CopPolyOrder                 20
2151#define MP_CopPolyPrune                 21
2152#define MP_CopPolyQHWeight              22
2153#define MP_CopPolyRegularity            23
2154#define MP_CopPolyStd                   24
2155#define MP_CopPolySyz                   25
2156#define MP_CopPolyVdim                  26
2157#define MP_CopPolyCoeffs                27
2158#define MP_CopPolyContract              28
2159#define MP_CopPolyEliminate             29
2160#define MP_CopPolyJet                   30
2161#define MP_CopPolyLift                  31
2162#define MP_CopPolyLiftstd               32
2163#define MP_CopPolyModulo                33
2164#define MP_CopPolyMres                  34
2165#define MP_CopPolyQuotient              35
2166#define MP_CopPolyReduce                36
2167#define MP_CopPolyPreimage              37
2168#define MP_CopPolyRes                   38
2169#define MP_CopPolyRing                  39
2170#define MP_CopPolyDenseDistPoly         40
2171#define MP_CopPolyDenseDistPolyFrac     41
2172#define MP_CopPolyClearDenom            42
2173#define MP_CopPolyFacStd                43
2174#define MP_CopPolyResultant             44
2175#define MP_CopPolyFreeModule            45
2176
2177/***************************************************************************
2178 *
2179 * Common Metat Types
2180 *
2181 ***************************************************************************/
2182
2183#define MP_CmtPolyExpTreePoly       1
2184
2185#endif /* _MP_PolyDict_h */
2186
2187/* Stuff included from h/MP_MatrixDict.h */
2188/***************************************************************************
2189 *
2190 *   HEADER FILE:  MP_MatrixDict.h                                         
2191 *                                                               
2192 *      The Matrixtype dictionary (definitions and declarations)
2193 *     
2194 *       
2195 *   Change Log:
2196 *
2197 *
2198 ***************************************************************************/
2199#ifndef _MP_MatrixDict_h
2200#define _MP_MatrixDict_h
2201
2202/* Lets give the Matrix Dictionary the number 11 */
2203
2204#define MP_MatrixDict 11
2205
2206/***************************************************************************
2207 *
2208 * Annotations
2209 *
2210 ***************************************************************************/
2211#define MP_AnnotMatrixDimension     1
2212
2213
2214/***************************************************************************
2215 *
2216 * Common Operator Definitions
2217 *
2218 ***************************************************************************/
2219
2220#define MP_CopMatrixBareiss             1
2221#define MP_CopMatrixCols                2
2222#define MP_CopMatrixDet                 3
2223#define MP_CopMatrixJacobi              4
2224#define MP_CopMatrixRows                6
2225#define MP_CopMatrixTrace               7
2226#define MP_CopMatrixTranspose           8
2227#define MP_CopMatrixKoszul              9
2228#define MP_CopMatrixMinor               10
2229#define MP_CopMatrixWedge               11
2230
2231#define MP_CopMatrixDenseMatrix         12
2232#define MP_CopMatrixDenseVector         13
2233
2234#endif /* _MP_MatrixDict_h */
2235
2236#endif /* _MP_h */
Note: See TracBrowser for help on using the repository browser.