-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcfstruct.c
229 lines (186 loc) · 8.01 KB
/
cfstruct.c
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/*===========================================================================*/
/* This supportpac is maintained by Jeff Lowrey */
/* Wayne M. Schutz is maintainer emeritus */
/* */
/* Chris Petty is the original author. */
/* */
/*(C)Copyright IBM Corporation 1995, 1997, 1998, 1999, 2000, */
/*(C)Copyright IBM Corporation 2002, 2003, 2004, 2005, 2006 */
/*(C)Copyright IBM Corporation 2007, 2008, 2009 */
/* */
/*===========================================================================*/
/* */
/* See the read.me file for change history */
/* */
/*===========================================================================*/
/* Module Name: stgclass.c */
/* DESCRIPTIVE NAME WebSphere MQ Save Queue Manager Object */
/* Definitions using PCFs (ms03 supportpac) */
/* */
/*===========================================================================*/
/* Include standard libraries */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* Include MQSeries headers */
#include <cmqc.h>
#include <cmqcfc.h>
#include <cmqxc.h>
/* Include Application headers */
#include "saveqmgr.h"
#include "mqutils.h"
/* If this isn't a zOS compile, don't bother compiling anything */
#if defined (zzzOS)
/* ------------------------------------------------------------------------ */
/* ProcessCFStructStringParm() */
/* ProcessCFStructIntegerParm() */
/* */
extern int noisy;
extern int header;
extern int oneLine; /* v601 -- whether to write the entire DEFINE on oneline */
extern char lineTerm[3]; /* v601 -- line terminator */
extern int platform;
int firstCFStruct = 1;
void ProcessCFStructStringParm( MQCFST *pPCFString
, CFStructParms *pCFStructDefn
, MQLONG *iCC
)
{
/* Initialise return codes */
*iCC = MQCC_OK;
switch ( pPCFString->Parameter ) {
case MQCA_CF_STRUC_NAME:
memset( pCFStructDefn->CFName
, ' ', MQ_CF_STRUC_NAME_LENGTH);
memcpy( pCFStructDefn->CFName
, pPCFString->String, pPCFString->StringLength);
break;
case MQCA_CF_STRUC_DESC:
memset( pCFStructDefn->CFDesc
, ' ', MQ_CF_STRUC_DESC_LENGTH );
memcpy( pCFStructDefn->CFDesc
, pPCFString->String, pPCFString->StringLength);
break;
case MQCA_ALTERATION_DATE:
memset( pCFStructDefn->AlterationDate
, ' ', MQ_DATE_LENGTH );
memcpy( pCFStructDefn->AlterationDate
, pPCFString->String, pPCFString->StringLength);
break;
case MQCA_ALTERATION_TIME:
memset( pCFStructDefn->AlterationTime
, ' ', MQ_TIME_LENGTH );
memcpy( pCFStructDefn->AlterationTime
, pPCFString->String, pPCFString->StringLength);
break;
case MQBACF_RESPONSE_ID: /* zOS things to ignore */
break;
case MQCACF_RESPONSE_Q_MGR_NAME: /* zOS things to ignore */
break;
default:
if(noisy) fprintf(stderr, "(CFStruct.c) Unknown PCF String Parameter: %ld\n",
pPCFString->Parameter);
*iCC = WARNING;
break;
} /* endswitch */
return;
}
/*************************************************************/
void ProcessCFStructIntegerParm( MQCFIN *pPCFInteger
, CFStructParms *pCFStructDefn
, MQLONG *iCC
)
{
/* Initialise return codes */
*iCC = MQCC_OK;
switch ( pPCFInteger->Parameter ) {
case MQIA_CF_LEVEL:
pCFStructDefn->cfLevel = pPCFInteger->Value;
break;
case MQIA_CF_RECOVER:
pCFStructDefn->recovery = pPCFInteger->Value;
break;
default:
if(noisy) fprintf(stderr, "(CFStruct.c) Unknown PCF Integer Parameter: %ld\n",
pPCFInteger->Parameter);
*iCC = WARNING;
break;
} /* endswitch */
return;
}
/* ------------------------------------------------------------------------ */
/* */
/* This process takes the attributes of a single authinfo and adds them */
/* to the end of a file, SAVEQMGR.TST, which can be found in the current */
/* directory. */
/* */
/* The file is of a format suitable for subsequent input to RUNMQSC. */
/* */
/* ------------------------------------------------------------------------ */
void AddToFileCFStruct(
CFStructParms *pCFStructDefn,
int UserVersion,
char * fileName, /* v32 Name of the output file */
FILE * fp, /* v51 */
int twolines, /* v601 */
MQLONG *iCC )
{
char * ParmBuffer; /* Temporary buffer to hold for output to file */
int options ; /* options for MQsprintf_X */
if ( !( ParmBuffer = (char *) malloc (PBSIZE) )) {
fprintf (stderr, "(CFStruct.c) Failed to allocate %d bytes \n", PBSIZE);
exit(2);
}
if (firstCFStruct) {
firstCFStruct = 0;
fprintf(fp, "******** CFStruct related definitions ********\n");
}
/* Initialise return codes */
*iCC = MQCC_OK;
/* v601 setup MQsprintf_X to break lines based on oneLine setting */
options = MQSPRINTF_X_DOUBLE_QUOTES + MQSPRINTF_X_NO_TRAILING_BLANKS;
if (!oneLine) options += MQSPRINTF_X_LINE_BREAKS;
if (twolines) fputs("* ", fp);
MQsprintf_X( ParmBuffer
, "*(2cr) DEFINE CFSTRUCT('%s') "
, pCFStructDefn->CFName
, MQ_CF_STRUC_NAME_LENGTH
, options
);
fputs( ParmBuffer, fp );
if (header && (!oneLine || twolines)) {
MQsprintf_X( ParmBuffer, "*(2cr)* ALTDATE (%s) ",
pCFStructDefn->AlterationDate,
MQ_CREATION_DATE_LENGTH,
options);
fputs( ParmBuffer, fp);
MQsprintf_X( ParmBuffer, "*(2cr)* ALTTIME (%s) ",
pCFStructDefn->AlterationTime,
MQ_CREATION_TIME_LENGTH,
options);
fputs( ParmBuffer, fp);
}
MQsprintf_X( ParmBuffer
, "*(2cr) DESCR('%s') "
, pCFStructDefn->CFDesc
, MQ_CF_STRUC_DESC_LENGTH
, options
);
sprintf(ParmBuffer,"*(2cr) CFLEVEL(%ld) %s", pCFStructDefn->cfLevel, lineTerm );
fputs( ParmBuffer, fp);
if ( pCFStructDefn->recovery == MQCFR_YES ) {
sprintf( ParmBuffer, "*(2cr) RECOVERY(YES) %s" , lineTerm );
} else {
sprintf( ParmBuffer, "*(2cr) RECOVERY(NO) %s" , lineTerm );
} /* endif */
fputs( ParmBuffer, fp );
sprintf( ParmBuffer, "*(2cr) REPLACE\n" );
fputs( ParmBuffer, fp );
if (!oneLine) {
fputs( "\n", fp );
}
free (ParmBuffer);
return;
}
/* end of don't compile anything */
#endif