~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to pvm3/src/msgbox.c

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
static char rcsid[] =
3
 
        "$Id: msgbox.c,v 1.17 1997/06/27 17:32:30 pvmsrc Exp $";
 
3
        "$Id: msgbox.c,v 1.2 2002/10/14 14:37:49 chanceli Exp $";
4
4
 
5
5
/*
6
6
 *         PVM version 3.4:  Parallel Virtual Machine System
35
35
 *
36
36
 *      Message mailbox database.
37
37
 *
38
 
$Log: msgbox.c,v $
 
38
 * $Log: msgbox.c,v $
 
39
 * Revision 1.2  2002/10/14 14:37:49  chanceli
 
40
 * update
 
41
 *
 
42
 * Revision 1.25  2001/02/07 23:15:49  pvmsrc
 
43
 * 2nd Half of CYGWIN Check-ins...
 
44
 * (Spanker=kohl)
 
45
 *
 
46
 * Revision 1.24  2000/02/16 21:59:47  pvmsrc
 
47
 * Fixed up #include <sys/types.h> stuff...
 
48
 *      - use <bsd/sys/types.h> for IMA_TITN...
 
49
 *      - #include before any NEEDMENDIAN #includes...
 
50
 * (Spanker=kohl)
 
51
 *
 
52
 * Revision 1.23  1999/12/13 18:13:41  pvmsrc
 
53
 * Moved pvmmatchstring() routine to pvmcruft.c (for usage by pvmtester).
 
54
 * Re-integrated two versions of mb_name() into one with #ifdefs for
 
55
 *      the USE_GNU_REGEX stuff.
 
56
 * (Spanker=kohl)
 
57
 *
 
58
 * Revision 1.22  1999/12/10 21:30:45  pvmsrc
 
59
 * Yanked GNU Regex Stuff.
 
60
 *      - re-activate using -DUSE_GNU_REGEX define...  if you must.
 
61
 *      - replaced full regular expression matching in mb_names()
 
62
 *              with good ole Unix style '*' globbing,
 
63
 *              via pvmmatchstring() a la Jeembo.
 
64
 * (Spanker=kohl)
 
65
 *
 
66
 * Revision 1.21  1999/11/08 17:21:16  pvmsrc
 
67
 * Added new PvmMboxDirectIndex() flag handling to mb_insert().
 
68
 *      - allow atomic re-insert at a specific index.
 
69
 * (Spanker=kohl)
 
70
 *
 
71
 * Revision 1.20  1999/07/08 19:00:04  kohl
 
72
 * Fixed "Log" keyword placement.
 
73
 *      - indent with " * " for new CVS.
 
74
 *
 
75
 * Revision 1.19  1999/01/13  00:03:45  pvmsrc
 
76
 * Fixed up mbox insert stuff, bugs & 3.3 compat (insert/lookup/delete).
 
77
 *      - changed to always pass in -1 for index (internal arg only).
 
78
 *      - handle minst correctly, supercedes overwritable else no way to
 
79
 *              build a minst list from within a single task, always just look
 
80
 *              for next unused index if minst set.
 
81
 *      - check for pvm_insert() compat, if mbox exists and req != -1 (any),
 
82
 *              then return PvmDenied (no overwrite in 3.3).
 
83
 * (Spanker=kohl)
 
84
 *
 
85
 * Revision 1.18  1998/11/20  20:04:10  pvmsrc
 
86
 * Changes so that win32 will compile & build. Also, common
 
87
 * Changes so that compiles & builds on NT. Also
 
88
 * common source on win32 & unix.
 
89
 * (Spanker=sscott)
 
90
 *
39
91
 * Revision 1.17  1997/06/27  17:32:30  pvmsrc
40
92
 * Updated for WIN32 header files & Authors.
41
93
 *
128
180
 
129
181
#include <stdio.h>
130
182
#ifdef NEEDMENDIAN
 
183
#include <sys/types.h>
131
184
#include <machine/endian.h>
132
185
#endif
133
186
#ifdef NEEDENDIAN
136
189
#ifdef NEEDSENDIAN
137
190
#include <sys/endian.h>
138
191
#endif
139
 
#ifndef WIN32
 
192
 
 
193
#include <pvm3.h>
 
194
 
 
195
#if defined(WIN32) || defined(CYGWIN)
 
196
#include "..\xdr\types.h"
 
197
#include "..\xdr\xdr.h"
 
198
#else
140
199
#include <rpc/types.h>
141
200
#include <rpc/xdr.h>
142
 
#else 
143
 
#include "..\xdr\types.h"
144
 
#include "..\xdr\xdr.h"
145
201
#endif
146
202
 
147
203
#ifdef  SYSVSTR
149
205
#else
150
206
#include <strings.h>
151
207
#endif
152
 
#include <pvm3.h>
 
208
 
153
209
#include "pvmalloc.h"
154
210
#include "listmac.h"
155
211
#include "pmsg.h"
156
212
#include "msgbox.h"
157
213
#include "global.h"
158
214
 
 
215
 
 
216
#ifdef USE_GNU_REGEX
159
217
void *pvmcompileregex __ProtoGlarp__ (( char * ));
160
218
int pvmmatchregex __ProtoGlarp__ (( void *, char * ));
161
219
void pvmfreeregex __ProtoGlarp__ (( void ** ));
 
220
#else
 
221
int pvmmatchstring __ProtoGlarp__ (( char *, char * ));
 
222
#endif
162
223
 
163
224
 
164
225
/***************
265
326
        struct pvmmentry *ep;
266
327
        struct pvmmentry *ep2 = 0;
267
328
 
 
329
        int dind;       /* direct index */
 
330
        int cind;       /* current index */
 
331
 
 
332
        /* must change to always pass in -1 for 3.4 calls */
 
333
        /* then can distinguish between 3.4 reinsert which succeeds
 
334
                if !overwritable/minst & 3.3 reinsert which should fail */
 
335
        /* to fix the "if (ep->me_ind == req)" conditional
 
336
                use a "current index":  cind = ( req == -1 ) ? 0 : req; */
 
337
        /* also, minst supercedes overwritable, else no way to build
 
338
                a minst list from within a single task... */
 
339
 
268
340
        if (!(np = mc_find(name)))
269
341
                if (!(np = mc_new(name)))
270
342
                        return PvmNoMem;
271
343
 
 
344
        dind = PvmMboxDirectIndexOf( flags );
 
345
 
 
346
        cind = ( req == -1 ) ?
 
347
                ( ( dind ) ? dind : 0 )
 
348
                : req;
 
349
 
272
350
        for (ep = np->mc_ent->me_link; ep != np->mc_ent; ep = ep->me_link)
273
 
                if (ep->me_ind >= req)
 
351
                if (ep->me_ind >= cind)
274
352
                        break;
275
353
 
276
354
        /* default insert is "locked"... */
277
355
 
278
 
        if (flags & PvmMboxMultiInstance) {
279
 
                for (; ep != np->mc_ent; ep = ep->me_link) {
280
 
                        if (ep->me_ind != req)
281
 
                                break;
282
 
                        if ( (ep->me_flags & PvmMboxOverWritable)
283
 
                                        || tid == ep->me_tid ) {
284
 
                                ep2 = ep;
285
 
                                break;
 
356
        if (ep->me_ind == cind) {
 
357
                if (flags & PvmMboxMultiInstance) {
 
358
                        if ( req != -1 ) /* hack for 3.3 compat */
 
359
                                return PvmDenied;
 
360
                        for (; ep != np->mc_ent; ep = ep->me_link) {
 
361
                                if (ep->me_ind != cind)
 
362
                                        break;
 
363
                                cind++;
286
364
                        }
287
 
                        req = ep->me_ind + 1;
288
 
                }
289
 
        } else {
290
 
                if (ep->me_ind == req) {
 
365
                } else {
291
366
                        if ( !(ep->me_flags & PvmMboxOverWritable)
292
367
                                        && tid != ep->me_tid) {
293
368
                                return PvmDenied;
302
377
                pmsg_unref(ep2->me_msg);
303
378
                PVM_FREE(ep2);
304
379
        }
305
 
        ep2 = me_new(req);
 
380
 
 
381
        ep2 = me_new(cind);
306
382
        ep2->me_tid = tid;
307
383
        ep2->me_flags = flags;
308
384
        ep2->me_msg = mp;
309
385
        LISTPUTBEFORE(ep, ep2, me_link, me_rlink);
310
386
 
311
 
        return req;
 
387
        return cind;
312
388
}
313
389
 
314
390
 
398
474
        char *pattern;
399
475
        struct pmsg *mp;
400
476
{
 
477
        struct pvmmclass *np;
 
478
        struct pvmmentry *ep;
 
479
 
 
480
#ifdef USE_GNU_REGEX
401
481
        void *pattbuff;
402
 
 
403
 
        struct pvmmclass *np;
404
 
        struct pvmmentry *ep;
405
 
 
406
482
        int pattglob = 0;
 
483
#endif
 
484
 
407
485
        int cnt;
408
486
 
 
487
#ifdef USE_GNU_REGEX
 
488
 
409
489
        /* Check for "*" Global Match Pattern */
410
490
 
411
491
        if ( !strcmp( pattern, "*" ) )
416
496
        if ( !pattglob )
417
497
                pattbuff = pvmcompileregex( pattern );
418
498
 
 
499
#endif
 
500
 
419
501
        /* Count # of Classes */
420
502
 
421
503
        cnt = 0;
423
505
        for ( np = pvmmboxclasses->mc_link; np != pvmmboxclasses;
424
506
                        np = np->mc_link )
425
507
        {
 
508
#ifdef USE_GNU_REGEX
426
509
                if ( pattglob
427
510
                                || ( ( pattbuff ) ?
428
511
                                        ( pvmmatchregex( pattbuff, np->mc_name ) )
429
512
                                        : ( !strcmp( pattern, np->mc_name ) ) ) )
 
513
#else
 
514
                if ( pvmmatchstring( np->mc_name, pattern ) )
 
515
#endif
430
516
                {
431
517
                        cnt++;
432
518
                }
439
525
        for ( np = pvmmboxclasses->mc_link; np != pvmmboxclasses;
440
526
                        np = np->mc_link )
441
527
        {
 
528
#ifdef USE_GNU_REGEX
442
529
                if ( pattglob
443
530
                                || ( ( pattbuff ) ?
444
531
                                        ( pvmmatchregex( pattbuff, np->mc_name ) )
445
532
                                        : ( !strcmp( pattern, np->mc_name ) ) ) )
 
533
#else
 
534
                if ( pvmmatchstring( np->mc_name, pattern ) )
 
535
#endif
446
536
                {
447
537
                        pkstr( mp, np->mc_name );
448
538
 
468
558
                }
469
559
        }
470
560
 
 
561
#ifdef USE_GNU_REGEX
471
562
        if ( !pattglob && pattbuff )
472
563
                pvmfreeregex( &pattbuff );
 
564
#endif
473
565
 
474
566
        return 0;
475
567
}