source: git/MP/MP/MP_Env.c @ 341696

spielwiese
Last change on this file since 341696 was 341696, checked in by Hans Schönemann <hannes@…>, 15 years ago
Adding Id property to all files git-svn-id: file:///usr/local/Singular/svn/trunk@12231 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 23.8 KB
Line 
1/*************************************************************************
2 *                                                                 
3 *                                                                 
4 *                    MP version 1.1.2:  Multi Protocol
5 *                    Kent State University, Kent, OH
6 *                 Authors:  S. Gray, N. Kajler, P. Wang
7 *          (C) 1993, 1994, 1995, 1996, 1997 All Rights Reserved
8 *
9 *                                 NOTICE
10 *
11 *  Permission to use, copy, modify, and distribute this software and
12 *  its documentation for non-commercial purposes and without fee is
13 *  hereby granted provided that the above copyright notice appear in all
14 *  copies and that both the copyright notice and this permission notice
15 *  appear in supporting documentation.
16 * 
17 *  Neither Kent State University nor the Authors make any representations
18 *  about the suitability of this software for any purpose.  The MP Library
19 *  is distributed in the hope that it will be useful, but is provided  "as
20 *  is" and without any warranty of any kind and without even the implied 
21 *  warranty of merchantability or fitness for a particular purpose.
22 *
23 *    IMPORTANT ADDITION: as of September 2006, MP is also licenced under GPL
24 *
25 *   IMPLEMENTATION FILE:  MP_Env.c
26 *                               
27 *      Routines to initialize and destroy the MP environment.  The
28 *      environment includes the host name of the machine, the log
29 *      file name, the buffer pool, etc.  The call to MP_InitializeEnv()
30 *      must occur before any attempt is made to open a link.
31 *      MP_ReleaseEnv() is one of the last things that should be done
32 *      before exiting the program.
33 *
34 *  Change Log:
35 *       September 11, 1995 SG - Reorganization of files.  Cleaned up
36 *                               header files and relocated source to
37 *                               its own file.
38 *       September 18, 1995 SG - Added MP_AllocateEnv().
39 *                               Changed MP_InitializeEnv() to take env
40 *                               as an argument.  If env is NULL, we start
41 *                               from scratch, else we assume MP_AllocateEnv()
42 *                               was called previously.
43 *       10/16/95   OB - open always a new log file, i.e. do not
44 *                       reuse an existing one
45 *       11/25/96   SG - Added defines/declarations/functions to
46 *                                support negotiation of word ordering.
47 *       1/29/96 sgray - added MP_GetEnvOption().  Note that since we return
48 *                     MP_Failure for an illegal option, we must never
49 *                     allow a legal option to be the value MP_Failure (0).
50 *       3/3/96 SG - Added routines MP_AddEnvTranspDevice(),
51 *                   mp_free_env_transp_list(), and IMP_GetTranspByName(),
52 *                   to support adding devices to an environment dynamically.
53 *                   Also made necessary changes to the other environment fncs.
54 *       4/23/96 SG - Added code to support different arbitrary precision
55 *                    packages.  Modified MP_AllocateEnv() and added
56 *                    MP_SetEnvBigIntFormat().
57 ***************************************************************************/
58
59#ifndef lint
60static char vcid[] = "@(#) $Id$";
61#endif /*lint */
62
63#include <values.h>  /* to figure out if we use IEEE or not */
64#include "MP.h"
65
66#include <string.h>
67#include <sys/time.h>
68#include <time.h>
69
70#ifndef __WIN32__
71#include <unistd.h>
72#include <stdlib.h>
73#ifdef __cplusplus
74extern "C" 
75{
76#endif 
77#include <sys/stat.h>
78#ifdef __cplusplus
79}
80#endif
81#endif  /* __WIN32__ */
82
83#ifdef __WIN32__
84#define MP_LOGFILE          "mplog.100"
85#define MP_LOGFILE_NAME     "mplog."
86#else   /* not  __WIN32__ */
87#define MP_LOGFILE          "/tmp/mplog.100"
88#define MP_LOGFILE_NAME     "/tmp/mplog."
89#endif  /* not  __WIN32__ */
90
91/* These are the "builtin" devices we support */
92EXTERN MP_TranspOps_t tcp_ops;
93EXTERN MP_TranspOps_t file_ops;
94
95/* This is the default Big Integer package - GNU Multiple Precision */
96EXTERN MP_BigIntOps_t  gmp_bigint_ops;
97EXTERN MP_BigRealOps_t gmp_bigreal_ops;
98
99static char log_msg[128];
100/* Note: this is dependent on the order of supported formats defined */
101/*       in MP_BigNum.h.                                             */
102static char *bignum_format2string[4] = {"Dummy", "GMP", "PARI", "SAC"};
103
104
105/* At compile time we figure out what the native byte ordering is    */
106/* and set it in the environment.  Links will inherit this attribute */
107/* from the environment as the preferred word ordering and then may  */
108/* negotiate it with their partner.                                  */
109
110#ifdef WORDS_BIGENDIAN
111static MP_WordOrder_t MP_NATIVE_WORD_ORDER = MP_BigEndian;
112#else
113static MP_WordOrder_t MP_NATIVE_WORD_ORDER = MP_LittleEndian;
114#endif
115
116#ifdef _IEEE
117static MP_FpFormat_t MP_NATIVE_FP_FORMAT = MP_IEEE_fp;
118#elif vax
119static MP_FpFormat_t MP_NATIVE_FP_FORMAT = MP_Vax_fp;
120#elif _AIX
121static MP_FpFormat_t MP_NATIVE_FP_FORMAT = MP_IEEE_fp;
122#else
123static MP_FpFormat_t MP_NATIVE_FP_FORMAT = MP_IEEE_fp;
124#endif
125
126
127/* utility routines used private to this file */
128#ifdef __STDC__
129static void mp_free_env_transp_list(MP_Env_pt env)
130#else
131static void mp_free_env_transp_list(env)
132    MP_Env_pt env;
133#endif
134{
135    MP_TranspList_pt tp, tpn;
136
137    if (env == NULL)
138        return;
139
140    tp  = env->transp_dev_list;
141    tpn = (MP_TranspList_pt)tp->next;
142    IMP_MemFreeFnc(tp, sizeof(struct transp_list_elem));
143
144    while (tpn != NULL) {
145        tp  = tpn;
146        tpn = (MP_TranspList_pt)tp->next;
147        IMP_MemFreeFnc(tp, sizeof(struct transp_list_elem));
148    }
149}
150
151
152#ifdef __STDC__
153MP_Status_t open_logfile(MP_ENV env)
154#else
155MP_Status_t open_logfile(env)
156    MP_ENV env;
157#endif
158{
159    char  fname[128] = MP_LOGFILE;
160    char  logext[8];
161    int   ext = MP_INIT_LOGFILE_EXT;
162
163    /* Open a log file with a unique extension starting with mplog.100 */
164#ifdef __WIN32__   
165    while ((env->logfd = fopen(fname, "r")) != NULL && ext < 10000)
166    {
167      fclose(env->logfd);
168#else
169      struct stat buf;
170     
171      while ((stat(fname, &buf) == 0) && (ext < 100000))
172      {
173#endif       
174        sprintf(logext, "%d", ++ext);
175        fname[0]='\0';
176        strcpy(fname, MP_LOGFILE_NAME);
177        strcat(fname, logext);
178      }
179
180      /* Found a log file name which didn't exist previously, so open it now. */
181      env->logfd = fopen(fname, "w");
182      if (env->logfd == NULL) {
183        fprintf(stderr, "MP_InitializeEnv: can't open log file!!\n");
184        fflush(stderr);
185        return MP_Failure;
186      }
187
188#ifndef __WIN32__
189      /* chmod to a+w so that others can wipe out those files */
190      chmod(fname,
191             S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IROTH | S_IWOTH);
192#endif     
193
194      /* Store the log file name. */
195      env->logfilename = IMP_RawMemAllocFnc(strlen(fname) + 1);
196      if (env->logfilename == NULL) {
197        fprintf(stderr, "MP_InitializeEnv: can't allocate memory!!\n");
198        fflush(stderr);
199        IMP_MemFreeFnc(env, sizeof(MP_Env_t));
200        return MP_Failure;
201      }
202      strcpy(env->logfilename, fname);
203
204      return MP_Success;
205    }
206
207
208/******************  Public Interface starts here **************************/
209
210/***************************************************************************
211 * FUNCTION:  MP_AllocateEnv()
212 * ARGUMENT:  none
213 * RETURN:    env - pointer to a environment structure
214 * PURPOSE:   Simply allocate memory for an environment stucture and
215 *            initialize the variables the may be altered using
216 *            MP_SetEnvOption().  The rest will be handled by a subsequent
217 *            call to MP_InitializeEnv().
218 **************************************************************************/
219#ifdef __STDC__
220MP_ENV MP_AllocateEnv(void)
221#else
222MP_ENV MP_AllocateEnv()
223#endif
224{
225    MP_Env_pt env = ((MP_Env_pt)IMP_MemAllocFnc(sizeof(MP_Env_t)));
226
227    if (env == NULL) { /* make sure malloc() worked */
228        fprintf(stderr, "MP_AllocateEnv: can't allocate memory!!\n");
229        fflush(stderr);
230        return NULL;
231    }
232
233    env->transp_dev_list   = NULL;
234    env->initialized       = MP_FALSE;
235    env->buffer_size       = MP_DEFAULT_BUFF_SIZE;
236    env->max_free_buffers  = MP_DEFAULT_MAX_FREE_BUFF;
237    env->init_free_buffers = MP_DEFAULT_INIT_FREE_BUFF;
238    env->num_o_buff        = 1;
239    env->native_word_order = MP_NATIVE_WORD_ORDER;
240    env->native_fp_format  = MP_NATIVE_FP_FORMAT;
241
242    env->bignum.native_bigint_format  = imp_default_bigint_format;
243    env->bignum.bigint_ops            = &imp_default_bigint_ops;
244    env->bignum.native_bigreal_format = imp_default_bigreal_format;
245    env->bignum.bigreal_ops           = &imp_default_bigreal_ops;
246
247#ifndef NO_LOGGING
248    if (open_logfile(env) != MP_Success)
249        return NULL;
250#else
251    env->logfd       = 0;
252    env->logfilename = NULL;
253#endif
254
255    return env;
256}
257
258
259/***************************************************************************
260 * FUNCTION:  MP_InitializeEnv()
261 * ARGUMENT:  env - pointer to a environment structure (possibly NULL)
262 * RETURN:    env - pointer to a environment structure
263 * PURPOSE:   If env is NULL, then we start from scratch to create and
264 *            completely initialize an environment structure.  If env is
265 *            not NULL, we assume it was created previously with a call
266 *            to MP_AllocateEnv() and initialize everything except those
267 *            fields that are settable as options using MP_SetEnvOption().
268 **************************************************************************/
269#ifdef __STDC__
270MP_ENV MP_InitializeEnv(MP_Env_pt env)
271#else
272MP_ENV MP_InitializeEnv(env)
273    MP_Env_pt env;
274#endif
275{
276    char   *c;
277    time_t  now;
278
279    if (env == NULL)
280        if ((env = MP_AllocateEnv()) == NULL)
281            return NULL;
282
283    if (gethostname(env->thishost, MP_HOST_NAME_LEN) == -1)
284        if ((c = (char *)getenv("HOST")) != NULL)
285            strcpy(env->thishost, c);
286        else
287            strcpy(env->thishost, "can't_get_my_hostname");
288
289    env->num_links   = 0;
290    env->initialized = MP_TRUE;
291
292    if (m_create_pool(env, env->buffer_size, env->max_free_buffers,
293                      env->init_free_buffers) != MP_Success) {
294        fprintf(stderr, "MP_InitializeEnv: can't  allocate buffers!!\n");
295        return NULL;
296    }
297
298#ifndef NO_LOGGING
299    now = time(NULL);
300    fprintf(env->logfd, "MP environment: Multi Protocol (MP) version %s %s",
301            MP_VERSION, ctime(&now));
302    fprintf(env->logfd, "\thost:    %s\n", env->thishost);
303    fprintf(env->logfd, "\tlogfile: %s\n", env->logfilename);
304    fprintf(env->logfd, "\tbuffer size: %d bytes\n", env->buffer_size);
305    fprintf(env->logfd, "\tmax free buffers: %d\n", env->max_free_buffers);
306    fprintf(env->logfd, "\tinit free buffers: %d\n", env->init_free_buffers);
307    fprintf(env->logfd, "\tnumber output buffers: %d\n", env->num_o_buff);
308    fprintf(env->logfd, "\tnative word ordering: ");
309
310    if (MP_NATIVE_WORD_ORDER == MP_BigEndian)
311        fprintf(env->logfd, "big endian\n");
312    else
313        fprintf(env->logfd, "little endian\n");
314
315    /*
316     * the following is good for now, but will have to be developed when we
317     * add more floating point formats
318     */
319
320    fprintf(env->logfd, "\tnative floating point format: ");
321    if (MP_NATIVE_FP_FORMAT == MP_IEEE_fp)
322        fprintf(env->logfd, "IEEE\n");
323    else
324        fprintf(env->logfd, "VAX\n");
325    fprintf(env->logfd, "\tnative multiple precision integer format: %s\n",
326            bignum_format2string[env->bignum.native_bigint_format]);
327    fprintf(env->logfd, "\n");
328    fflush(env->logfd);
329#endif /* NO_LOGGING */
330
331    MP_AddEnvTranspDevice(env, MP_TcpTransportDev, &tcp_ops);
332    MP_AddEnvTranspDevice(env, MP_FileTransportDev, &file_ops);
333
334    return env;
335}
336
337
338/***************************************************************************
339 * FUNCTION:  MP_ReleaseEnv()
340 * ARGUMENT:  env - pointer to a environment structure (possibly NULL)
341 * RETURN:    none
342 * PURPOSE:   Release all the resources associated with this environment,
343 *            then release the environment structure.
344  **************************************************************************/
345#ifdef __STDC__
346void MP_ReleaseEnv(MP_Env_pt env)
347#else
348void MP_ReleaseEnv(env)
349    MP_Env_pt env;
350#endif
351{
352    if (env == NULL)
353        return;
354
355#ifndef NO_LOGGING
356    fprintf(env->logfd, "\nReleasing MP environment resources. \n");
357    fclose(env->logfd);
358    IMP_RawMemFreeFnc(env->logfilename);
359#endif
360
361    mp_free_env_transp_list(env);
362    m_free_pool(env->buff_pool);
363
364    IMP_MemFreeFnc(env, sizeof(MP_Env_t));
365}
366
367/********************************************************************
368 * FUNCTION:  MP_SetEnvOption
369 * ARGUMENT:  env    - pointer to a env structure
370 *            option - the option to set
371 *            value  - value to set the option to
372 * RETURN:    success - old value of the option
373 *            failure - MP_Failure
374 *
375 * PURPOSE:   Make sure that the option and value are valid.
376 ********************************************************************/
377#ifdef __STDC__
378int MP_SetEnvOption(MP_Env_pt env,
379                    int option,
380                    int value)
381#else
382int MP_SetEnvOption(env, option, value)
383    MP_Env_pt env;
384    int       option;
385    int       value;
386#endif
387{
388    int  oldval;
389    char logmsg[128];
390
391    if (env == NULL) {
392        fprintf(stderr, "MP_SetEnvOption: null environment!!\n");
393        fflush(stderr);
394        return MP_Failure;
395    }
396
397    switch (option) {
398    case MP_BUFFER_SIZE_OPT:
399        oldval = env->buffer_size;
400        sprintf(logmsg,
401                "Init Event  %s %d", "MP_SetEnvOption: set buffer size to",
402                value);
403        env->buffer_size = value;
404        break;
405
406    case MP_MAX_FREE_BUFFERS_OPT:
407        oldval = env->max_free_buffers;
408        sprintf(logmsg, "Init Event  %s %d",
409                "MP_SetEnvOption: set maximum free buffers to ", value);
410        env->max_free_buffers = value;
411        break;
412
413    case MP_INIT_FREE_BUFFERS_OPT:
414        oldval = env->init_free_buffers;
415        if (env->init_free_buffers > env->max_free_buffers)
416            env->init_free_buffers = env->max_free_buffers;
417        else
418            env->init_free_buffers = value;
419            sprintf(logmsg, "Init Event  %s %d",
420                    "MP_SetEnvOption: set initial number of free buffers to ",
421                    env->init_free_buffers);
422        break;
423
424    default:
425        sprintf(logmsg, "%s: MP_SetEnvOption: illegal option %d",
426                MP_ERROR_EVENT, option);
427        oldval = MP_Failure;
428    }
429
430#ifndef NO_LOGGING
431    fprintf(env->logfd, "%s\n", logmsg);
432#endif
433
434    return oldval;
435}
436
437
438
439/********************************************************************
440 * FUNCTION:  MP_GetEnvOption
441 * ARGUMENT:  env    - pointer to a env structure
442 *            option - the option to return
443 * RETURN:    success - value of the option
444 *            failure - MP_Failure
445 *
446 * PURPOSE:   Make sure that the option is valid.
447 ********************************************************************/
448#ifdef __STDC__
449int MP_GetEnvOption(MP_Env_pt env,
450                    int option)
451#else
452int MP_GetEnvOption(env, option)
453  MP_Env_pt env;
454  int       option;
455#endif
456{
457    if (env == NULL) {
458        fprintf(stderr, "MP_GetEnvOption: null environment!!\n");
459        fflush(stderr);
460        return MP_Failure;
461    }
462
463    switch (option) {
464    case MP_BUFFER_SIZE_OPT:
465        return env->buffer_size;
466
467    case MP_INIT_FREE_BUFFERS_OPT:
468        return env->init_free_buffers;
469
470    default: ;
471    }
472
473    return MP_Failure;
474}
475
476
477
478/***************************************************************************
479 * FUNCTION:  MP_AddEnvTranspDevice()
480 * ARGUMENT:  env - the environment to which we will add the device
481 *            name - the name by which the device will be known. This
482 *                   is the value to be used with -MPtransp (changed to int)
483 *            ops - the MP_TranspOps_t structure containing pointers to the
484 *                  functions for this device.
485 * RETURN:    MP_Status - MP_Success if all goes well
486 *                      - MP_Failure only if env is null or we run out of mem.
487 * PURPOSE:   Create a new transport list element structure, fill in the
488 *            fields with the function's arguments and place the new list
489 *            element at the head of the environment's device list.  Note
490 *            that we don't check for duplicates.  As my brother and I used
491 *            to say, if the user does this, "that his dumbness".
492 **************************************************************************/
493#ifdef __STDC__
494MP_Status_t MP_AddEnvTranspDevice(MP_Env_pt       env,
495                                  int             transp_dev,
496                                  MP_TranspOps_t *ops)
497#else
498MP_Status_t MP_AddEnvTranspDevice(env, transp_dev, ops)
499    MP_Env_pt      env;
500    int            transp_dev;
501    MP_TranspOps_t *ops;
502#endif
503{
504    MP_TranspList_pt tp;
505
506#ifdef MP_DEBUG
507    fprintf(stderr,"MP_AddEnvTranspDevice: entering to add device %d\n", transp_dev);
508    fflush(stderr);
509#endif
510
511    if (env == NULL)
512        return MP_Failure; /* may have to do more */
513
514    if ((tp = IMP_MemAllocFnc(sizeof(struct transp_list_elem))) == NULL)
515        return MP_Failure;
516
517    tp->transp_dev = transp_dev;
518
519    memcpy((char *)&(tp->transp_ops), (char *)ops, sizeof(MP_TranspOps_t));
520    tp->next = (MP_TranspList_pt *)env->transp_dev_list;
521    env->transp_dev_list = tp;
522
523#ifndef NO_LOGGING
524    fprintf(env->logfd, "\tAdded transport device %d to environment\n",
525       transp_dev );
526    fflush(env->logfd);
527#endif
528
529#ifdef MP_DEBUG
530    fprintf(stderr,"MP_AddEnvTranspDevice: exiting\n");
531    fflush(stderr);
532#endif
533
534    return MP_Success;
535}
536
537
538
539/***************************************************************************
540 * FUNCTION:  MP_SetEnvBigIntFormat()
541 * ARGUMENT:  env - the environment for which we  change the big num package
542 *            format - the name of the BigInt package to use.  The list of
543 *                   supported packages can also be found in MP_Types.h.
544 *            ops - the MP_BigIntOps_t structure containing pointers to the
545 *                  functions for this BigInt package.
546 * RETURN:    MP_Status - MP_Success if all goes well
547 *                      - MP_Failure only if env is null or we run out of mem.
548 * PURPOSE:   Change the big integer package to be used for sending and
549 *            receiving arbitrary precision integers.  The default is the
550 *            GNU Multiple Precision package.  But if communication is b/t
551 *            homogeneous systems, we want to avoid the conversion to GMP.
552 *            Also, this approach make any _necessary_ conversions transparent.
553 *            The sender at least has the illusion of sending in its "native"
554 *            format (assuming it is one of the supported packages).
555 *            NOTE: if the ops structure is not one already supported by MP,
556 *            we cannot verify that it has the correct functionality.  We
557 *            trust the programmer on this one.
558 **************************************************************************/
559#ifdef __STDC__
560MP_Status_t MP_SetEnvBigIntFormat(MP_Env_t          *env,
561                                  MP_BigIntOps_t    *ops,
562                                  MP_BigNumFormat_t  format)
563#else
564MP_Status_t MP_SetEnvBigIntFormat(env, ops, format)
565    MP_Env_t          *env;
566    MP_BigIntOps_t    *ops;
567    MP_BigNumFormat_t  format;
568#endif
569{
570    if (env == NULL)
571        return MP_NullLink;
572
573    switch (format) {
574    case MP_GMP:
575        sprintf(log_msg, "%s: environment BigInt format set to %s\n",
576                MP_INIT_EVENT, bignum_format2string[format]);
577        break;
578    case MP_SAC:
579        sprintf(log_msg, "%s: environment BigInt format set to %s\n",
580                MP_INIT_EVENT, bignum_format2string[format]);
581        break;
582    case MP_PARI:
583        sprintf(log_msg, "%s: environment BigInt format set to %s\n",
584                MP_INIT_EVENT, bignum_format2string[format]);
585        break;
586
587    default:
588        sprintf(log_msg, 
589          "%s: environment BigInt format set to user-supplied package: %d\n",
590          MP_INIT_EVENT, format);
591    }
592    env->bignum.native_bigint_format = format;
593    env->bignum.bigint_ops           = ops;
594
595#ifndef NO_LOGGING
596    fprintf(env->logfd, log_msg);
597#endif
598
599    return MP_Success;
600}
601
602/***************************************************************************
603 * FUNCTION:  MP_SetEnvBigRealFormat()
604 * ARGUMENT:  env - the environment for which we  change the big num package
605 *            format - the name of the BigReal package to use.  The list of
606 *                   supported packages can also be found in MP_Types.h.
607 *            ops - the MP_BigRealOps_t structure containing pointers to the
608 *                  functions for this BigReal package.
609 * RETURN:    MP_Status - MP_Success if all goes well
610 *                      - MP_Failure only if env is null or we run out of mem.
611 * PURPOSE:   Change the big real package to be used for sending and
612 *            receiving arbitrary precision reals.  The default is the
613 *            GNU Multiple Precision package.  But if communication is b/t
614 *            homogeneous systems, we want to avoid the conversion to GMP.
615 *            Also, this approach make any _necessary_ conversions transparent.
616 *            The sender at least has the illusion of sending in its "native"
617 *            format (assuming it is one of the supported packages).
618 *            NOTE: if the ops structure is not one already supported by MP,
619 *            we cannot verify that it has the correct functionality.  We
620 *            trust the programmer on this one.
621 **************************************************************************/
622#ifdef __STDC__
623MP_Status_t MP_SetEnvBigRealFormat(MP_Env_t         *env,
624                                  MP_BigRealOps_t   *ops,
625                                  MP_BigNumFormat_t  format)
626#else
627MP_Status_t MP_SetEnvBigRealFormat(env, ops, format)
628    MP_Env_t          *env;
629    MP_BigRealOps_t   *ops;
630    MP_BigNumFormat_t  format;
631#endif
632{
633    MP_Status_t status = MP_Success;
634
635    if (env == NULL)
636        return MP_NullLink;
637
638    switch (format) {
639    case MP_GMP:
640        sprintf(log_msg, "%s: environment BigReal format set to %s\n",
641                MP_INIT_EVENT, bignum_format2string[format]);
642        break;
643    case MP_SAC:
644        sprintf(log_msg, "%s: %s does not support a BigReal format\n",
645                MP_ERROR_EVENT, bignum_format2string[format]);
646        status = MP_Failure;
647        break;
648    case MP_PARI:
649        sprintf(log_msg, "%s: environment BigReal format set to %s\n",
650                MP_INIT_EVENT, bignum_format2string[format]);
651        break;
652
653    default:
654        sprintf(log_msg, 
655           "%s: environment BigReal format set to user-supplied package: %d\n",
656           MP_INIT_EVENT, format);
657    }
658    if (status == MP_Success) {
659        env->bignum.native_bigreal_format = format;
660        env->bignum.bigreal_ops           = ops;
661    }
662
663#ifndef NO_LOGGING
664    fprintf(env->logfd, log_msg);
665#endif
666
667    return status;
668}
669
670
671/***************************************************************************
672 * FUNCTION:  IMP_GetTranspByName
673 * ARGUMENT:  env - the environment to which we will add the device
674 *            name - the name of the device we are looking for.  This is the
675 *                   name used with -MPtransp.
676 * RETURN:    NULL on failure to find the device or env is NULL.
677 *            pointer to a transport list element if name is found.
678 * PURPOSE:   Search the environment's device list for a device with the
679 *            given name.  Return the _first_ occurrence found.
680 **************************************************************************/
681#ifdef __STDC__
682MP_TranspList_pt IMP_GetTranspByName(MP_Env_pt  env,
683                                     int        transp_dev)
684#else
685MP_TranspList_pt IMP_GetTranspByName(env, transp_dev)
686    MP_Env_pt  env;
687    int        transp_dev;
688#endif
689{
690    MP_TranspList_pt tp;
691
692    if (env == NULL)
693        return NULL;
694
695    tp = env->transp_dev_list;
696    while (tp != NULL && (transp_dev != tp->transp_dev))
697        tp = (MP_TranspList_pt)tp->next;
698
699    return tp;
700}
701
702
Note: See TracBrowser for help on using the repository browser.