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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
static char rcsid[] =
"$Id: taskf.c,v 1.5 2009/01/23 01:12:57 pvmsrc Exp $";
/*
* PVM version 3.4: Parallel Virtual Machine System
* University of Tennessee, Knoxville TN.
* Oak Ridge National Laboratory, Oak Ridge TN.
* Emory University, Atlanta GA.
* Authors: J. J. Dongarra, G. E. Fagg, M. Fischer
* G. A. Geist, J. A. Kohl, R. J. Manchek, P. Mucci,
* P. M. Papadopoulos, S. L. Scott, and V. S. Sunderam
* (C) 1997 All Rights Reserved
*
* NOTICE
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted
* provided that the above copyright notice appear in all copies and
* that both the copyright notice and this permission notice appear in
* supporting documentation.
*
* Neither the Institutions (Emory University, Oak Ridge National
* Laboratory, and University of Tennessee) nor the Authors make any
* representations about the suitability of this software for any
* purpose. This software is provided ``as is'' without express or
* implied warranty.
*
* PVM version 3 was funded in part by the U.S. Department of Energy,
* the National Science Foundation and the State of Tennessee.
*/
/**********************************************************************
* Filename: taskf.c
*
* contains functions used in mailbox example codes
*
* task0.c task1.c task_end.c
* lmbi.c gmbi.c rme.c
* others ???
*
*********************************************************************/
#include <stdio.h>
#ifdef HASSTDLIB
#include <stdlib.h>
#endif
#ifdef SYSVSTR
#include <string.h>
#else
#include <strings.h>
#endif
#include "pvm3.h"
/**********************************************************************
* Function: display_incomming_parameters
*
* displays the command line parameters from program
*********************************************************************/
void
display_incomming_parameters( who, argc, argv )
char *who;
int argc;
char *argv[];
{
char *me = "display_incomming_parameters";
int i;
printf( "\n%s: %d incoming parameters to main.\n", who, argc );
for ( i=0 ; i < argc ; i++ )
printf( "%s: argv[%d] = <%s>\n", who, i, argv[i] );
} /* display_incomming_parameters */
/**********************************************************************
* Function: get_flagstring
*
* flags: Incoming integer that represents the sum of Mbox flags.
*
* returns: Outgoing string of flags set.
* may have: PvmMboxDefault d = 0
* PvmMboxPersistent p = 1
* PvmMboxMultiInstance m = 2
* PvmMboxOverWritable o = 4
* PvmMboxFirstAvail f = 8
* PvmMboxReadAndDelete r = 16
*
* returns a pointer to a string containing flags set
* returns NULL pointer on error
*********************************************************************/
char *
get_flagstring( flags )
int flags;
{
char *me = "get_flagstring";
int size = 0;
char *flagstring = ( char * ) NULL;
/*
* string space to return
*/
if ( (flagstring = (char *) calloc( 255, sizeof(char) )) == NULL ) {
printf( "\n%s: failed on calloc.\n", me );
return( ( char * ) NULL );
}
/* set to null so that empty string test works */
flagstring[0] = '\0';
if ( flags == PvmMboxDefault ) {
strcat( flagstring, "PvmMboxDefault " );
}
else {
if ( flags >= PvmMboxReadAndDelete ) {
strcat( flagstring, "PvmMboxReadAndDelete " );
flags -= PvmMboxReadAndDelete;
}
if ( flags >= PvmMboxFirstAvail ) {
strcat( flagstring, "PvmMboxFirstAvail " );
flags -= PvmMboxFirstAvail;
}
if ( flags >= PvmMboxOverWritable ) {
strcat( flagstring, "PvmMboxOverWritable " );
flags -= PvmMboxOverWritable;
}
if ( flags >= PvmMboxMultiInstance ) {
strcat( flagstring, "PvmMboxMultiInstance " );
flags -= PvmMboxMultiInstance;
}
if ( flags >= PvmMboxPersistent ) {
strcat( flagstring, "PvmMboxPersistent " );
flags -= PvmMboxPersistent;
}
}
return( flagstring );
} /* get_flagstring */
/**********************************************************************
* Function: set_flags
*
* flagsin: Incoming string containing characters representing the
* Mbox switches set.
* An empty string is assumed to be "d" for PvmMboxDefault.
* valid chars are ( d p m o f r ) in any order.
* Any bogus characters are ignored...
*
* flagstring: Outgoing string of flags set.
* may have: PvmMboxDefault d = 0
* PvmMboxPersistent p = 1
* PvmMboxMultiInstance m = 2
* PvmMboxOverWritable o = 4
* PvmMboxFirstAvail f = 8
* PvmMboxReadAndDelete r = 16
*
* returns a positive integer representing addition of all set flags.
* returns a negative integer to indicate an error condition
*********************************************************************/
int
set_flags( flagsin, flagstring )
char *flagsin;
char **flagstring;
{
char *me = "set_flags";
int size = 0;
int flags = PvmMboxDefault;
/*
* check for existance of flag character and
* set results accordingly
*/
/* ambiguious but do anyway... */
if ( strchr( flagsin, 'd' ) != NULL ) {
flags |= PvmMboxDefault;
}
if ( strchr( flagsin, 'r' ) != NULL ) {
flags |= PvmMboxReadAndDelete;
}
if ( strchr( flagsin, 'f' ) != NULL ) {
flags |= PvmMboxFirstAvail;
}
if ( strchr( flagsin, 'o' ) != NULL ) {
flags |= PvmMboxOverWritable;
}
if ( strchr( flagsin, 'm' ) != NULL ) {
flags |= PvmMboxMultiInstance;
}
if ( strchr( flagsin, 'p' ) != NULL ) {
flags |= PvmMboxPersistent;
}
/*
* get flags.
* flags other than those expected "drfomp" will return as
* PvmMboxDefault
*/
if ( (*flagstring = get_flagstring( flags )) == NULL ) return( -1 );
return( flags );
} /* set_flags */
|