File: pvmfgetinfo.m4

package info (click to toggle)
pvm 3.4.5-7
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 6,480 kB
  • ctags: 6,227
  • sloc: ansic: 71,630; makefile: 1,216; fortran: 631; sh: 511; csh: 73; asm: 37
file content (83 lines) | stat: -rw-r--r-- 1,712 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

/* $Id: pvmfgetinfo.m4,v 1.4 1997/05/08 13:32:56 pvmsrc Exp $ */

#include "pvm3.h"
#include "pvm_consts.h"

void
FUNCTION(pvmfgetmboxinfo)
	ARGS(`STRING_ARG(pattern),
		STRING_ARG(name),
		nclassesp,
		nentriesp,
		indexp,
		ownerp,
		flagp,
		infop')

	STRING_ARG_DECL(pattern);
	STRING_ARG_DECL(name);
	int *nclassesp, *nentriesp, *indexp, *ownerp, *flagp, *infop;
{
	static struct pvmmboxinfo *classes = (struct pvmmboxinfo *) 0;
	static int nclasses = 0;
	static int next = 0;

	char tpattern[MAX_MBOX_NAME + 1];
	int nc;
	int cc;
	int i;

/* if user sets nclassesp to -1 then pvmfgetmboxinfo() will be reset */

    if ( nclasses && nclassesp && (*nclassesp == -1) )
		nclasses = 0;

	if ( !nclasses )
	{
		/*
		 *  Copy the pattern to make sure there is
		 *  a NUL at the end.
		 */
		if ( ftocstr( tpattern, sizeof(tpattern), STRING_PTR(pattern),
				STRING_LEN(pattern) ) ) {
			*infop = PvmBadParam;
			return;
		}

		if ( (cc = pvm_getmboxinfo( tpattern, &nc, &classes )) < 0 ) {
			*infop = cc;
			return;
		}

		nclasses = nc;
		next = 0;

		if ( !nclasses )
			*infop = PvmNotFound;
	}

	if ( next < nclasses )
	{
		if ( STRING_PTR(name) )
			ctofstr( STRING_PTR(name), STRING_LEN(name),
					classes[ next ].mi_name );
		if ( nentriesp ) *nentriesp = classes[ next ].mi_nentries;
		if ( indexp ) {
			for ( i=0 ; i < classes[ next ].mi_nentries ; i++ )
				indexp[i] = classes[ next ].mi_indices[i];
		}
		if ( ownerp ) {
			for ( i=0 ; i < classes[ next ].mi_nentries ; i++ )
				ownerp[i] = classes[ next ].mi_owners[i];
		}
		if ( flagp ) {
			for ( i=0 ; i < classes[ next ].mi_nentries ; i++ )
				flagp[i] = classes[ next ].mi_flags[i];
		}
	}

	if ( next == nclasses )
		nclasses = 0;
}