-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStreamSpec.c
More file actions
executable file
·82 lines (72 loc) · 2.45 KB
/
StreamSpec.c
File metadata and controls
executable file
·82 lines (72 loc) · 2.45 KB
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
/**
*Alterado: Itamar 03/10/2006
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
#include "StreamSpec.h"
#include "FilterData/Policies.h"
// tag 0 is for internal Void messages
// tag 1 is for PvmTaskExit notifications
// tag 2 is for PvmHostDelete notifications
// tag 3 is for filter termination
static int nextTag = 4;
void resetStream(StreamSpec *s){
s->tag = nextTag++;
}
/* Constructor and destroyer *****************************************************/
/// Constructor
StreamSpec *createEmptyStreamSpec() {
StreamSpec *s = (StreamSpec *) malloc(sizeof(StreamSpec));
s->tag = nextTag++;
s->numToSend = 0;
return s;
}
/// Destroyer
void destroyStreamSpec(StreamSpec *s){
//we dont need to free stuff, as they are allocated statically
free(s);
}
/********************************************************************************/
/* Setting source and destinations **********************************************/
/// Set stream origin, ie, the filter which writes to this stream
int setFrom(StreamSpec *s, FilterSpec *filter, char *portName
#ifdef VOID_TERM
, int breakLoop
#endif
){
s->fromFilter = filter;
strncpy(s->fromPortName, portName, MAX_PTNAME_LENGTH);
s->fromFilter->outputs[s->fromFilter->numOutputs++] = s;
#ifdef VOID_TERM
s->breakLoop = breakLoop;
#endif
return 1;
}
///set stream destination, ie, the filter which reads from this stream
//ITAMAR changes to permit that various 'to' of one 'from'
int setTo(StreamSpec *s, FilterSpec *filter, char *portName, char *writePolicyName, char *polibName){
//we are not using read policies...
int indStream = s->numToSend;
s->numToSend += 1;
writePolicy_t p; //The policy change from 'setFrom' to here
strncpy(s->writePolicyName[indStream], writePolicyName, MAX_PLNAME_LENGTH);
s->toFilter[indStream] = filter;
s->toFilter[indStream]->inputs[s->toFilter[indStream]->numInputs++] = s;
strncpy(s->toPortName[indStream], portName, MAX_PTNAME_LENGTH);
//if we are using labeled stream, we need the library name of the functions
p = getWritePolicyByName(writePolicyName);
if ((p == LABELED_STREAM) || (p == MULTICAST_LABELED_STREAM)){
//if we are labeled, we need a policy library name
if ((polibName == NULL) || (strlen(polibName) == 0))
return 0;
else
strncpy(s->lsLibName[indStream], polibName, MAX_PLNAME_LENGTH);
}
else if (p == W_POLICY_ERROR){
return 0;
}
return 1;
}
/*******************************************************************************/