-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsaveqmgr.c
2609 lines (2319 loc) · 94.8 KB
/
saveqmgr.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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*===========================================================================*/
/* 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: saveqmgr.c */
/* DESCRIPTIVE NAME WebSphere MQ Save Queue Manager Object */
/* Definitions using PCFs (ms03 supportpac) */
/* */
/*===========================================================================*/
/* */
/* This is a program to inquire of a queue manager about its */
/* own attributes and those of all the objects, (queues, channels and */
/* processes), defined to it. The inquiry may be made of a local or remote */
/* queue manager. */
/* */
/*===========================================================================*/
/* Include standard libraries */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/* Include WebSphere MQ headers */
#include <cmqc.h>
#include <cmqcfc.h>
#include <cmqxc.h>
#if defined USEMQCNX
#define USEMQCONNX
#endif
/* Include Application headers */
#include "args.h"
#include "saveqmgr.h"
#include "mqutils.h"
int diagnostics = 0; /* determines whether to issue some diags around mq ops */
int noisy = 1; /* whether or not to put bad PCF attr messages */
int chlReset = 0; /* determines whether or not to issue RESET CHANNEL cmds */
int header = 1; /* whether to create header in output file *//* v513 */
int authHeader = 1; /* whether to create header in oam output file */
int permDyn = 0; /* v530 *//* whether to create qlocal from Permdyn */
int ignoreDamaged = 0; /* v530 *//* whether to ignore damaged obj messages */
int noMsgOnTimeout = 0; /* v531a *//* whether to give an error msg on timeout */
int foundDamagedObject = 0; /* v531a */
int foundnpmclass = 0; /* v533a */
int SysObjs = 0; /* [v51].. create "system" objects */
int oneLine = 0; /* [v601].. create each DEFINE on one line */
char lineTerm[3]; /* v601 -- line terminator */
int platform = 0; /* platform to generate code for */
int qsgQmgr = 0; /* v602 ..is this a qsg qmgr ? (set in qmgr.c) */
pqList qListAnchor=0; /* point to first qlist element */
pqList qListTerm=(pqList)&qListAnchor; /* point to last qlist element */
int main(int argc, char *argv[]) {
int parmCount = 1;
CmdArgParms myParmStruc;
CmdArgParmsPtr pMyParms = &myParmStruc;
MQCHAR48 ReplyToQ; /* DynamicQName for this run */
MQHCONN hConn=MQHC_UNUSABLE_HCONN; /* handle to connected queue mgr */
MQLONG CompCode=0; /* MQ API completion code */
MQLONG Reason=0; /* Reason qualifying above */
MQLONG pcfReason=0; /* PCF Reason return code */
MQHOBJ hAdminQ=MQHO_UNUSABLE_HOBJ; /* handle to output queue */
MQHOBJ hReplyQ=MQHO_UNUSABLE_HOBJ; /* handle to input queue */
int ParmCount = 0;
int QmgrVersion = 0; /* version number we detected */
/* int UserVersion = 0; *//* version number we detected */
MQLONG ObjectSets=0; /* number of sets of objects to process */
MQLONG RetCode = 0; /* Return code from this program */
/*** v532 drive mqconnx for client version of supportpac ***/
#if defined USEMQCONNX
MQCNO Connect_options = { MQCNO_DEFAULT}; /* MQCONNX options */
int isClient = 1;
#else
int isClient = 0;
#endif
char connVerb[8]= "";
int inValidParm=0;
char work[12]; /* small work area (for platform name) */
/*filename constructed from queue manager name or "saveqmgr.tst" */
/* file handle for output MQSC file */
FILE *outputfp = 0;
/* file handle for output OAM file */
FILE *authOutputfp = 0;
int useSSL;
/* variables for handling -o option */
int i=0;
/* default is to put +nl at the end of each line */
strcpy(lineTerm, "+\n");
/* ********************************************************************** */
/* Get a connection to the queue manager and open the */
/* required application queues. */
/* */
/* SYSTEM.ADMIN.COMMAND.QUEUE is the output queue for this application */
/* and the default command queue for the queue manager. Messages placed */
/* on this queue must be of a format suitable for processing by the */
/* supplied WebSphere MQ command server, STRMQCSV. */
/* */
/* SAVEQMGR.* is the prefix for the name of the dynamic queue to which */
/* the command server will send the messages generated in response to */
/* our request. This will be based on the definition of the queue */
/* SYSTEM.DEFAULT.MODEL.QUEUE */
/* ********************************************************************** */
/* A little hack to print which version of WebSphere MQ we were */
/* compiled for .... */
#if defined(MQCMDL_LEVEL_701)
fprintf(stderr, "Compiled for Websphere MQ V7.0.1.0 on %s\n", __DATE__);
#elif defined(MQOT_TOPIC)
fprintf(stderr, "Compiled for Websphere MQ V7.0 on %s\n", __DATE__);
#elif defined (MQOT_SERVICE)
fprintf (stderr, "Compiled for Websphere MQ V6.0 on %s\n",__DATE__);
#elif defined (MQCMD_INQUIRE_AUTH_INFO)
fprintf (stderr, "Compiled for Websphere MQ V5.3 on %s\n",__DATE__);
#elif defined (MQCMDL_LEVEL_520)
fprintf (stderr, "Compiled for MQSeries V5.2 on %s\n",__DATE__);
#elif defined (MQOO_BIND_ON_OPEN)
fprintf (stderr, "Compiled for MQSeries V5.1 on %s\n",__DATE__);
#elif defined (MQDL_NOT_SUPPORTED)
fprintf (stderr, "Compiled for MQSeries V5.0 on %s\n",__DATE__);
#else
fprintf(stderr, "Compiled for MQSeries V2 on %s\n", __DATE__);
#endif
i=0;
/* Process input parameter list */
inValidParm = ProcessArgs(argc,argv, pMyParms,&parmCount,isClient );
/* fprintf(stderr,"Parm Count = %d\n", parmCount); */
#if defined MQSCO_DEFAULT
if (diagnostics) {
fprintf(stderr, "(saveqmgr.c) executing with SSL support enabled\n");
}
useSSL = 0;
#endif
if(inValidParm) {
/* invalid parameter */
fprintf(stderr, "Invalid invocation, option: \"%s\"\n", argv[parmCount] );
if (isClient) {
fprintf(stderr, USAGE, pMyParms->myName,USAGE2 );
} else {
fprintf(stderr, USAGE, pMyParms->myName,USAGE3 );
}
fprintf(stderr, " \n\n %s\n\n", THISVERSION);
exit( ERROR );
}
diagnostics = pMyParms->diagnostics;
if (diagnostics) {
fprintf(stderr, "(saveqmgr.c) executing with diagnostic level %d\n", diagnostics);
}
header = pMyParms->header;
if (diagnostics>20) {
fprintf(stderr, "(saveqmgr.c) executing with header %d\n", header);
}
authHeader = pMyParms->authHeader;
if (pMyParms->std_out != 0 ) outputfp = stdout; /* user wants stdout option */
chlReset = pMyParms->chlReset;
SysObjs = pMyParms->SysObjs;
if (diagnostics>2) {
fprintf(stderr, "(saveqmgr.c) executing with SysObjs = %d\n", SysObjs );
}
noisy = pMyParms->noisy;
permDyn = pMyParms->permDyn;
ignoreDamaged = pMyParms->ignoreDamaged;
oneLine = pMyParms->oneLine;
strcpy(lineTerm, pMyParms->lineTerm);
platform = pMyParms->platform;
qsgQmgr = pMyParms->qsgQmgr;
/* UserVersion = pMyParms->UserVersion; */
/** v532 use MQCONNX if USEMQCONNX set */
fprintf(stderr, "%s\n", THISVERSION);
#if defined USEMQCONNX
/******************************************************************/
/* */
/* Initialise the client channel definition if required */
/* */
/******************************************************************/
if (pMyParms->flagCONNAME> 0)
{
strncpy(pMyParms->ClientConn.ConnectionName,
pMyParms->argCONNAME,
MQ_CONN_NAME_LENGTH);
strncpy(pMyParms->ClientConn.ChannelName,
pMyParms->argSVRCONN,
MQ_CHANNEL_NAME_LENGTH);
/* Point the MQCNO to the client connection definition */
Connect_options.ClientConnPtr = &(pMyParms->ClientConn);
fprintf(stderr, "Using the server connection channel \"%s\"\n",
pMyParms->argSVRCONN);
fprintf(stderr, "\ton connection name \"%s\".\n", pMyParms->argCONNAME);
if (pMyParms->ClientConn.SecurityExit[0]) fprintf(stderr, "\tsecurity exit \"%.128s\"\n", pMyParms->ClientConn.SecurityExit);
if (pMyParms->ClientConn.SecurityUserData[0]) fprintf(stderr, "\tsecurity user data \"%.32s\"\n", pMyParms->ClientConn.SecurityUserData);
if (pMyParms->ClientConn.SendExit[0]) fprintf(stderr, "\tsend exit \"%.128s\"\n", pMyParms->ClientConn.SendExit);
if (pMyParms->ClientConn.SendUserData[0]) fprintf(stderr, "\tsend user data \"%.32s\"\n", pMyParms->ClientConn.SendUserData);
if (pMyParms->ClientConn.ReceiveExit[0]) fprintf(stderr, "\treceive exit \"%.128s\"\n", pMyParms->ClientConn.ReceiveExit);
if (pMyParms->ClientConn.ReceiveUserData[0]) fprintf(stderr, "\treceive user data \"%.32s\"\n", pMyParms->ClientConn.ReceiveUserData);
/* Client connection fields are in the version 2 part of the */
/* MQCNO so we must set the version number to 2 or they will */
/* be ignored, for SSL we must use version 4 */
if (pMyParms->flagSSL) {
#if defined USESSL
pMyParms->ClientConn.Version = MQCD_VERSION_7;
Connect_options.Version = MQCNO_VERSION_4;
Connect_options.SSLConfigPtr = &(pMyParms->SSL_options);
fprintf(stderr, "\tSSL Cipher = %.32s\n", pMyParms->ClientConn.SSLCipherSpec);
fprintf(stderr, "\tSSL KeyRepository = %.256s\n", pMyParms->SSL_options.KeyRepository);
#endif
} else {
Connect_options.Version = MQCNO_VERSION_2;
}
}
else
{
fprintf(stderr, "With no client connection information specified.\n");
}
/******************************************************************/
/* */
/* Connect to queue manager */
/* */
/******************************************************************/
strcpy(connVerb, "MQCONNX");
MQCONNX(pMyParms->LclQMgrName, /* queue manager */
&Connect_options, /* options for connection */
&hConn, /* connection handle */
&CompCode, /* completion code */
&Reason); /* reason code */
#else
strcpy(connVerb, "MQCONN");
MQCONN( pMyParms->LclQMgrName /* I : use default queue manager */
, &hConn /* O : queue manager handle */
, &CompCode /* O : Completion code */
, &Reason /* O : Reason qualifying CompCode */
);
#endif /* v532 */
/* v3.2 check for failed, since os/400 can return a warning .... */
if ( CompCode == MQCC_FAILED ) {
fprintf(stderr, "%s failed for %s, CC=%ld RC=%ld\n"
, connVerb
, pMyParms->LclQMgrName
, CompCode
, Reason
);
exit( ERROR );
} /* endif */
CompCode = OpenQ( hConn
, pMyParms->RmtQMgrName
, pMyParms->CmdSvrQName
, NULL
, MQOO_OUTPUT
, &hAdminQ
);
if (CompCode!=MQCC_FAILED) {
strcpy( ReplyToQ, "SAVEQMGR.*" );
CompCode = OpenQ( hConn
, pMyParms->LclQMgrName
, "SYSTEM.DEFAULT.MODEL.QUEUE\0"
, &ReplyToQ
, MQOO_INPUT_EXCLUSIVE
, &hReplyQ
);
}/* End if*/
if (CompCode==MQCC_FAILED) {
MQDISC ( &hConn,
&CompCode,
&Reason
);
exit ( ERROR );
}
/* ******************************************************************** */
/* QUEUE MANAGER */
/* First, get the command level of the queue manager. We need this to */
/* tell us what further objects (such as namelists) we can query. */
/* ******************************************************************** */
fprintf(stderr, "Requesting attributes of the queue manager...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_Q_MGR /* Command to execute */
, 0 /* Attribute to search on */
, pMyParms /*command args */
);
if (RetCode!=ERROR) {
RetCode = ProcessReplyQ( hConn /* QMgr connection handle */
, hReplyQ /* Handle to open input Q */
, &pMyParms->UserVersion /* Command level user is requesting */
, &QmgrVersion /* Command level we detected */
, &outputfp /* [v51]output file handle */
, pMyParms->fileName /* v32 Name of the output file */
, &authOutputfp /* [v51]output file handle */
, pMyParms->authFileName /* v32 Name of the output file */
, 1 /* number of reply sets to process */
, SysObjs /* system object flag [v51] */
, pMyParms->overlay /* v534 overlay flag */
, pMyParms->twoLines /* v601 */
, &pcfReason
, pMyParms
);
#if defined(zzzOS)
/* if we got a MQRCCF_CFH_VERSION_ERROR, this is probably becuase we are connected to a zOS */
/* qmgr, so set the platform to that and try again */
if (pcfReason == MQRCCF_CFH_VERSION_ERROR) {
if (diagnostics>10) {
fprintf(stderr, "(saveqmgr.c) pcfReason = %ld\n", pcfReason);
}
platform = MQPL_MVS;
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_Q_MGR /* Command to execute */
, 0 /* Attribute to search on */
, pMyParms /*command args */
);
RetCode = ProcessReplyQ( hConn /* QMgr connection handle */
, hReplyQ /* Handle to open input Q */
, &pMyParms->UserVersion /* Command level user is requesting */
, &QmgrVersion /* Command level we detected */
, &outputfp /* [v51]output file handle */
, pMyParms->fileName /* v32 Name of the output file */
, &authOutputfp /* [v51]output file handle */
, pMyParms->authFileName /* v32 Name of the output file */
, 1 /* number of reply sets to process */
, SysObjs /* system object flag [v51] */
, pMyParms->overlay /* v534 overlay flag */
, pMyParms->twoLines /* v601 */
, &pcfReason
, pMyParms
);
}
#endif
}/* End if*/
/* ******************************************************************** */
/* Other objects: */
/* Now we can request all the other objects that are appropriate for */
/* this level of the queue manager. For example, mqv5 doesn't */
/* support listener objects */
/* ******************************************************************** */
if (RetCode!=ERROR) {
toStrMQPLATFORM((char*)&work, platform);
fprintf(stderr, "Generating code for platform %s\n", work);
}
ObjectSets = 0; /* number of sets requested */
#if defined (MQCMD_INQUIRE_AUTH_INFO)
if (QmgrVersion >= MQCMDL_LEVEL_530 && /* We're V5.3 or better */
pMyParms->UserVersion >= MQCMDL_LEVEL_530 /* and user wants authinfo */
) {
/* ******************************************************************** */
/* [v53] Authinfo Objects */
/* ******************************************************************** */
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting attributes of all authinfo objects...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_AUTH_INFO /* Command to execute */
, MQCA_AUTH_INFO_NAME /* Attribute to search on */
, pMyParms /*command args */
);
}/* End if retcode != ERROR */
}
#endif
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting attributes of all queues...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_Q /* Command to execute */
, MQCA_Q_NAME /* Attribute to search on */
, pMyParms /*command args */
);
}/* End if retcode != ERROR */
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting attributes of all channels...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_CHANNEL /* Command to execute */
, MQCACH_CHANNEL_NAME /* Attribute to search on */
, pMyParms /*command args */
);
}/* End if retcode != ERROR */
/* Special note. Contrary to the documentation I have, it appears that */
/* V5.1 of MQSeries includes client-conn channels when you ask for all */
/* channels. Since we asked for all channel types above, we will not do */
/* it again here ... */
if (QmgrVersion < MQCMDL_LEVEL_510 && /* see BIG note above */
/* MQAT_DEFAULT != MQAT_OS400 ) { *//* Os/400 doesn't support clients*/
platform != MQPL_OS400 ) { /* Os/400 doesn't support clients*/
if (RetCode!=ERROR) {
ObjectSets++;
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, XZCMD_INQUIRE_CHANNEL_CLNT /* Command to execute */
, MQCACH_CHANNEL_NAME /* Attribute to search on */
, pMyParms /*command args */
);
}/* End if retcode != ERROR */
}
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting attributes of all processes...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_PROCESS /* Command to execute */
, MQCA_PROCESS_NAME /* Attribute to search on */
, pMyParms /*command args */
);
}/* End if retcode != ERROR */
#if defined (MQCMD_INQUIRE_NAMELIST)
if (QmgrVersion >= MQCMDL_LEVEL_510 && /* We're V5.1 or better */
pMyParms->UserVersion >= MQCMDL_LEVEL_510 /* and user wants namelists */
) {
/* ******************************************************************** */
/* [v51] Namelists */
/* ******************************************************************** */
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting attributes of all namelists...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_NAMELIST /* Command to execute */
, MQCA_NAMELIST_NAME /* Attribute to search on */
, pMyParms /*command args */
);
}/* End if retcode != ERROR */
}
#endif
/*** v6 Inquire on Listeners and services ***/
#if defined (zzMQV60)
if (QmgrVersion >= MQCMDL_LEVEL_600 && /* We're V6.0 or better */
pMyParms->UserVersion >= MQCMDL_LEVEL_600 && /* and user wants namelists */
platform != MQPL_MVS /* and its not zOS */
) {
/* ******************************************************************** */
/* Listeners */
/* ******************************************************************** */
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting attributes of all listeners...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_LISTENER /* Command to execute */
, MQCACH_LISTENER_NAME /* Attribute to search on */
, pMyParms /*command args */
);
}/* End if retcode != ERROR */
/* ******************************************************************** */
/* Services */
/* ******************************************************************** */
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting attributes of all services...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_SERVICE /* Command to execute */
, MQCA_SERVICE_NAME /* Attribute to search on */
, pMyParms /*command args */
);
}/* End if retcode != ERROR */
}
/* ******************************************************************** */
/* Authority Classes */
/* if the target qmgrs is NOT MVS, and at least V6 */
/* OR the target qmgr is at least v7, all platforms */
/* ******************************************************************** */
if (pMyParms->makeSecurityDefs) {
if (( QmgrVersion >= MQCMDL_LEVEL_600 && (
platform==MQPL_UNIX ||
platform==MQPL_WINDOWS_NT ||
platform==MQPL_OS400 )) || (QmgrVersion >= MQCMDL_LEVEL_700 && platform!=MQPL_MVS)) {
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting attributes of all OAM classes...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_AUTH_RECS /* Command to execute */
, 0 /* Attribute to search on */
, pMyParms /*command args */
);
}
} else {
fprintf(stderr, "(saveqmgr.c) -z flag specified but target ");
fprintf(stderr, "qmgr is wrong platform or < v6, flag is ignored\n");
RetCode=WARNING;
}
}
#endif /* of zzMQV60 */
#if defined(zzMQV70)
/*Complete: Need a runtime check for this as well, so we do not inquire against a non v7 qmgr.*/
if (QmgrVersion >= MQCMDL_LEVEL_700) { /* We're V7.0 or better */
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting attributes of all topics...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_TOPIC /* Command to execute */
, MQCA_TOPIC_NAME /* Attribute to search on */
, pMyParms /*command args */
);
}/* End if retcode != ERROR */
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting attributes of all subscriptions...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_SUBSCRIPTION /* Command to execute */
, MQCACF_SUB_NAME /* Attribute to search on */
, pMyParms /*command args */
);
}/* End if retcode != ERROR */
}
#endif
#if defined(zzzOS)
if (platform==MQPL_MVS) {
/* ******************************************************************** */
/* Storage Classes */
/* ******************************************************************** */
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting attributes of all storage classes...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_STG_CLASS /* Command to execute */
, MQCA_STORAGE_CLASS /* Attribute to search on */
, pMyParms /*command args */
);
}
/* ******************************************************************** */
/* LOG data sets */
/* ******************************************************************** */
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting attributes of all logs...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_LOG /* Command to execute */
, 0 /* Attribute to search on */
, pMyParms /*command args */
);
}
/* ******************************************************************** */
/* Archive Information */
/* ******************************************************************** */
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting attributes of archives...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_ARCHIVE /* Command to execute */
, 0 /* Attribute to search on */
, pMyParms /*command args */
);
}
/* ******************************************************************** */
/* Inquire Usage */
/* ******************************************************************** */
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting Usage Information (MQCMD_INQUIRE_USAGE)...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_USAGE /* Command to execute */
, 0 /* Attribute to search on */
, pMyParms /*command args */
);
}
/* ******************************************************************** */
/* Inquire System */
/* ******************************************************************** */
if (RetCode!=ERROR) {
ObjectSets++;
fprintf(stderr, "Requesting System Information (MQCMD_INQUIRE_SYSTEM)...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_SYSTEM /* Command to execute */
, 0 /* Attribute to search on */
, pMyParms /*command args */
);
}
/* ******************************************************************** */
/* CF Structure */
/* ******************************************************************** */
if (RetCode!=ERROR && qsgQmgr) {
ObjectSets++;
fprintf(stderr, "Requesting attributes of all CF Structures...\n" );
RetCode = InquireDefinition( hConn /* QMgr connection handle */
, hAdminQ /* Handle to open output Q */
, ReplyToQ /* Name of queue to reply to */
, MQCMD_INQUIRE_CF_STRUC /* Command to execute */
, MQCA_CF_STRUC_NAME /* Attribute to search on */
, pMyParms /*command args */
);
}
}
#endif /* of zzzOs */
/* ******************************************************************** */
/* Now that we have requested all the required object attributes, */
/* call ProcessReplyQ to handle the responses. ObjectSets tell us */
/* how many sets of replies there are. */
/* ******************************************************************** */
if (RetCode!=ERROR) {
RetCode = ProcessReplyQ( hConn /* QMgr connection handle */
, hReplyQ /* Handle to open input Q */
, &pMyParms->UserVersion /* Command level user is requesting */
, &QmgrVersion /* Command level we detected */
, &outputfp /* [v51]output file handle */
, pMyParms->fileName /* v32 Name of the output file */
, &authOutputfp
, pMyParms->authFileName
, ObjectSets /* number of sets of replies to process */
, SysObjs /* system object flag [v51] */
, pMyParms->overlay /* v534 overlay flag */
, pMyParms->twoLines /* v601 two lines flag */
, &pcfReason
, pMyParms
);
}
/* ******************************************************************** */
/* Close down in an orderly manner. */
/* */
/* No need to test for these calls failing, the result is the same! */
/* ******************************************************************** */
MQCLOSE( hConn /* Queue manager handle */
, &hAdminQ /* Handle to queue */
, MQCO_NONE /* Parameters on close */
, &CompCode /* Completion code */
, &Reason /* Reason code */
);
MQCLOSE( hConn /* Queue manager handle */
, &hReplyQ /* Handle to queue */
, MQCO_NONE /* Parameters on close */
, &CompCode /* Completion code */
, &Reason /* Reason code */
);
/* [v51] close output file */
if (outputfp) fclose (outputfp);
/* [v603] close output file */
if (authOutputfp) fclose (authOutputfp);
if (hConn!=MQHC_UNUSABLE_HCONN) {
MQDISC( &hConn
, &CompCode
, &Reason
);
}/* End if*/
/* we do this so we can return the correct "status" based on the platfrm */
/* saveqmgr.h defines the actual return codes by platform */
switch (RetCode) {
case (MQCC_OK): return (OK);
case (MQCC_WARNING): return (WARNING);
case (MQCC_FAILED): return (ERROR);
default: return(RetCode);
}
} /* end MAIN */
/* ************************************************************************ */
/* InquireDefinition() */
/* */
/* This is a procedure to inquire of the queue manager about the objects */
/* defined to it. */
/* */
/* SearchType indicates the type of object for which information is */
/* required. Objects can either be queues, channels, processes or the */
/* queue manager itself. */
/* */
/* SearchParm indicates the parameter on which the request is based. A */
/* SearchString specifies a 'mask' for the search. So, for example, a */
/* SearchParm of MQCA_Q_NAME and a SearchString of "*" will request */
/* information about all queues. */
/* */
/* SearchParmLen indicates the maximum length of a string of this type, */
/* SearchStringLen indicates the length of the search mask. Note that */
/* NULL characters in the SearchString are treated as valid. The */
/* SearchString should, therefore, be padded with blanks (' '). */
/* */
/* */
/* The actual request consists of a Request Header and a parameter block */
/* used to specify the context for the search. The header and the parameter */
/* block follow each other in a contiguous buffer which is pointed to by */
/* the variable pAdminMsg. This entire buffer is then put to the queue. */
/* */
/* The command server, (use STRMQCSV to start it), processes the */
/* SYSTEM.ADMIN.COMMAND.QUEUE and puts a reply on the application */
/* ReplyToQ for each defined queue. */
/* ************************************************************************ */
MQLONG InquireDefinition(MQHCONN hConn, MQHOBJ hAdminQ, MQCHAR48 ReplyToQ,
MQLONG SearchType /* QUEUE|CHANNEL|PROCESS|QMGR */
, MQLONG SearchParm, CmdArgParmsPtr MyParms) {
MQLONG AdminMsgLen; /* Length of user message buffer */
MQBYTE *pAdminMsg; /* Ptr to outbound data buffer */
MQCFH *pPCFHeader; /* Ptr to PCF header structure */
MQCFST *pPCFString; /* Ptr to PCF string parm block */
MQCFIN *pPCFInteger; /* v32 ptr to chltype param for clntconn */
MQCFIL *pPCFIntegerList; /* v32 ptr to chltype param for clntconn */
MQCHAR CmdSvrQName[MQ_Q_MGR_NAME_LENGTH+1];
MQCHAR12 UserID;
#if defined(zzzOS)||defined(zzMQV70)
MQCFBS *pPCFByte; /* Ptr to PCF byte string parm block */
#endif
MQLONG RetCode = 0; /* Return code from function */
/* ----------------------------------------------------------------------- */
/* The search for queue manager attributes is slightly different to that */
/* for other objects, in that there is only one. */
/* The PCF header is the only piece of the request message required in */
/* this case. */
/* */
/* When requesting attributes for queues, channels or processes a */
/* parameter block follows the header in which you specify the context */
/* of the request. That is, you specify the parameter to base the */
/* request on, and a mask to search against. In this example we want */
/* all attributes for all objects so we base our search on object name */
/* and use the '*' wildcard to indicate a generic search. */
/* */
/* This procedure will eventually perform an MQPUT to the */
/* SYSTEM.ADMIN.COMMAND.QUEUE. The request outlined above will be */
/* encapsulated in a single message occupying a contiguous block of */
/* storage. To help with manipulation of this buffer we will use */
/* several pointers into the buffer. */
/* */
/* pAdminMsg points to the start of the entire message buffer. */
/* This is a pointer to a flat block of storage allocated to be large */
/* enough to contain the entire request. */
/* */
/* pPCFHeader points to a structure of type MQCFH, a command format */
/* header. It is points to the same address as pAdminMsg and */
/* effectively remaps the first piece of our message buffer. It is */
/* used to indicate the type of command we wish to execute and the */
/* number of parameter blocks following in the message buffer. */
/* */
/* pPCFString points to a structure of type MQCFST, a command format */
/* string. It points into the message buffer at an address immediately */
/* following the header described above. It is used to map the following */
/* bytes onto a PCF string parameter block which in this case is used */
/* to indicate the name of the object we want details about, * indicating */
/* all. */
/* */
/* Note that this example is a generic search for all attributes of */
/* all objects known to the queue manager. By using different, */
/* or more, parameter blocks in the request header it is possible */
/* to narrow the search. */
/* ----------------------------------------------------------------------- */
if (SearchParm == 0) {
/* Inquire of the queue manager (or log) attributes. It is only necessary */
/* to complete the request header in this case. */
/* Set the length for the message buffer */
AdminMsgLen = MQCFH_STRUC_LENGTH;
/* Allocate storage for the message buffer and set a pointer to */
/* its start address. */
pAdminMsg = (MQBYTE *)malloc(AdminMsgLen);
memset(pAdminMsg, '\0', AdminMsgLen);
/* pPCFHeader is set equal to pAdminMsg in order to provide a */
/* structure to the newly allocated block of storage. We can */
/* then create a request header of the correct format in the */
/* message buffer. */
pPCFHeader = (MQCFH *)pAdminMsg;
/* Setup request header */
pPCFHeader->StrucLength = MQCFH_STRUC_LENGTH;
pPCFHeader->Type = MQCFT_COMMAND;
pPCFHeader->Command = SearchType;
pPCFHeader->Version = MQCFH_VERSION_1;
pPCFHeader->MsgSeqNumber = MQCFC_LAST;
pPCFHeader->Control = MQCFC_LAST;
#if defined (zzzOS)
if (platform == MQPL_MVS) {
pPCFHeader->Type = MQCFT_COMMAND_XR; /* zOS */
pPCFHeader->Version = MQCFH_VERSION_3; /* zOS */
}
#endif
pPCFHeader->ParameterCount = 0;
} else {
/* Inquire of queue, channel or process attributes; exact one to */
/* be indicated by SearchType. */
/* Set the length for the message buffer */
AdminMsgLen = MQCFH_STRUC_LENGTH + MQCFST_STRUC_LENGTH_FIXED + 4;
/* Allocate storage for the message buffer and set a pointer to */
/* its start address. */
pAdminMsg = (MQBYTE *)malloc(AdminMsgLen);
memset(pAdminMsg, '\0', AdminMsgLen);
/* pPCFHeader is set equal to pAdminMsg in order to provide a */
/* structure to the newly allocated block of storage. We can */
/* then create a request header of the correct format in the */
/* message buffer. */
pPCFHeader = (MQCFH *)pAdminMsg;
/* pPCFString is set to point into the message buffer immediately */
/* after the request header. This allows us to specify a context */
/* for the request in the required format. */
pPCFString = (MQCFST *)(pAdminMsg + MQCFH_STRUC_LENGTH );
/* Setup request header */
pPCFHeader->Type = MQCFT_COMMAND;
pPCFHeader->StrucLength = MQCFH_STRUC_LENGTH;
pPCFHeader->Version = MQCFH_VERSION_1;
pPCFHeader->Command = SearchType;
pPCFHeader->MsgSeqNumber = MQCFC_LAST;
pPCFHeader->Control = MQCFC_LAST;
pPCFHeader->ParameterCount = 1;
/* Setup parameter block */
pPCFString->Type = MQCFT_STRING;
pPCFString->StrucLength = MQCFST_STRUC_LENGTH_FIXED + 4;
pPCFString->Parameter = SearchParm;
pPCFString->CodedCharSetId = MQCCSI_DEFAULT;
pPCFString->StringLength = 1;
memset(pPCFString->String, '\0', 4);
strcpy(pPCFString->String, "*");
#if defined (zzzOS)
if (platform == MQPL_MVS) {
pPCFHeader->Type = MQCFT_COMMAND_XR; /* zOS */
pPCFHeader->Version = MQCFH_VERSION_3; /* zOS */
}
#endif
} /* endif */
/* v32 More additions for clntconn channels */
/* V32 add integer attribute chltype to query */
if (SearchType == XZCMD_INQUIRE_CHANNEL_CLNT) {
/* V32 change some previously set values */
AdminMsgLen += MQCFIN_STRUC_LENGTH;
pAdminMsg = (MQBYTE *) realloc( (void *) pAdminMsg, AdminMsgLen);
pPCFHeader = (MQCFH *)pAdminMsg;
/* V32 memset( pAdminMsg, '\0', AdminMsgLen ); */
pPCFHeader->Command = MQCMD_INQUIRE_CHANNEL;
pPCFHeader->ParameterCount = 2;
/* V32 fill in values for clntconn channel type */
pPCFInteger = (MQCFIN *)(pAdminMsg + MQCFH_STRUC_LENGTH
+ MQCFST_STRUC_LENGTH_FIXED + 4 );
pPCFInteger->Type = MQCFT_INTEGER;
pPCFInteger->StrucLength = MQCFIN_STRUC_LENGTH;
pPCFInteger->Parameter = MQIACH_CHANNEL_TYPE;
pPCFInteger->Value = MQCHT_CLNTCONN;
}
/* V32 End Clntconn addition */
#if defined(zzMQV60)
/* v603 Special handling for Authority Objects */
if (SearchType == MQCMD_INQUIRE_AUTH_RECS) {
/* change some previously set values */
AdminMsgLen = MQCFH_STRUC_LENGTH + 2*MQCFIN_STRUC_LENGTH +
/* needs to be fullword */
MQCFST_STRUC_LENGTH_FIXED + MQCFIL_STRUC_LENGTH_FIXED + 8;
pAdminMsg = (MQBYTE *) realloc( (void *) pAdminMsg, AdminMsgLen);
pPCFHeader = (MQCFH *)pAdminMsg;
pPCFHeader->ParameterCount = 4;
/* set the Options field */
pPCFInteger = (MQCFIN *)(pAdminMsg + MQCFH_STRUC_LENGTH);
pPCFInteger->Type = MQCFT_INTEGER;
pPCFInteger->StrucLength = MQCFIN_STRUC_LENGTH;
pPCFInteger->Parameter = MQIACF_AUTH_OPTIONS;
pPCFInteger->Value
= MQAUTHOPT_ENTITY_EXPLICIT+MQAUTHOPT_NAME_ALL_MATCHING;
/* set the ObjectType field */
pPCFInteger = (MQCFIN *)(pAdminMsg + MQCFH_STRUC_LENGTH
+ MQCFIN_STRUC_LENGTH);
pPCFInteger->Type = MQCFT_INTEGER;
pPCFInteger->StrucLength = MQCFIN_STRUC_LENGTH;
pPCFInteger->Parameter = MQIACF_OBJECT_TYPE;
pPCFInteger->Value = MQOT_ALL;
/* set the Profile Name field */
pPCFString = (MQCFST *)(pAdminMsg + MQCFH_STRUC_LENGTH + 2
* MQCFIN_STRUC_LENGTH);
pPCFString->Type = MQCFT_STRING;
pPCFString->StrucLength = MQCFST_STRUC_LENGTH_FIXED + 4;
pPCFString->Parameter = MQCACF_AUTH_PROFILE_NAME;
pPCFString->CodedCharSetId = MQCCSI_DEFAULT;
pPCFString->StringLength = 1;
memset(pPCFString->String, '\0', 4);
/* indicate required attributes */