├── .gitignore ├── CLA.md ├── LICENSE ├── README.md └── src ├── Makefile ├── README.txt ├── q.c ├── q.h ├── q.txt ├── qlaccess.c ├── qlaccess.h ├── qlcs.c ├── qlcs.h ├── qlgetopt.c ├── qlgetopt.h ├── qlmsg.c ├── qload.c ├── qload.h ├── qload.txt ├── qloadfnc.c ├── qlparse.c ├── qlparse.h ├── qlstruct.c ├── qlstruct.h ├── qlutil.c ├── qlutil.h ├── qlvalues.c └── qlvalues.h /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | 3 | # Object files 4 | *.o 5 | *.ko 6 | *.obj 7 | *.elf 8 | 9 | # Precompiled Headers 10 | *.gch 11 | *.pch 12 | 13 | # Libraries 14 | *.lib 15 | *.a 16 | *.la 17 | *.lo 18 | 19 | # Shared objects (inc. Windows DLLs) 20 | *.dll 21 | *.so 22 | *.so.* 23 | *.dylib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | *.i*86 30 | *.x86_64 31 | *.hex 32 | -------------------------------------------------------------------------------- /CLA.md: -------------------------------------------------------------------------------- 1 | IBM Contributor License Agreement 2 | ================================= 3 | 4 | Version 1.0.0 January 14, 2014 5 | 6 | In order for You (as defined below) to make intellectual property Contributions (as defined below) now or in the future to IBM GitHub repositories, 7 | You must agree to this Contributor License Agreement ("CLA"). 8 | 9 | Please read this CLA carefully before accepting its terms. By accepting the CLA, You are agreeing to be bound by its terms. 10 | If You submit a Pull Request against an IBM repository on GitHub You must include in the Pull Request a statement of Your acceptance of this CLA. 11 | 12 | As used in this CLA: 13 | (i) "You" (or "Your") shall mean the entity that is making this Agreement with IBM; 14 | (ii)"Contribution" shall mean any original work of authorship, including any modifications or additions to an existing work, that is submitted by You to IBM for inclusion in, 15 | or documentation of, any of the IBM GitHub repositories; 16 | (iii) "Submit" (or "Submitted") means any form of communication sent to IBM (e.g. the content You post in a GitHub Issue or submit as part of a GitHub Pull Request). 17 | 18 | This agreement applies to all Contributions You Submit. 19 | 20 | This CLA, and the license(s) associated with the particular IBM GitHub repositories You are contributing to, provides a license to Your Contributions to IBM and downstream consumers, 21 | but You still own Your Contributions, and except for the licenses provided for in this CLA, You reserve all right, title and interest in Your Contributions. 22 | 23 | IBM requires that each Contribution You Submit now or in the future comply with the following four commitments. 24 | 25 | 1) You will only Submit Contributions where You have authored 100% of the content. 26 | 2) You will only Submit Contributions to which You have the necessary rights. This means that if You are employed You have received the necessary permissions from Your employer to make the 27 | Contributions. 28 | 3) Whatever content You Contribute will be provided under the license(s) associated with the particular IBM GitHub repository You are contributing to. 29 | 4) You understand and agree that IBM GitHub repositories and Your contributions are public, and that a record of the contribution (including all personal information You submit with it) 30 | is maintained indefinitely and may be redistributed consistent with the license(s) involved. 31 | You will promptly notify the Eclipse Foundation if You become aware of any facts or circumstances that would make these commitments inaccurate in any way. 32 | To do so, please create an Issue in the appropriate GitHub repository. 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Eclipse Public License - v 1.0 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 4 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 5 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 6 | 7 | 1. DEFINITIONS 8 | 9 | "Contribution" means: 10 | 11 | a) in the case of the initial Contributor, the initial code and documentation 12 | distributed under this Agreement, and 13 | b) in the case of each subsequent Contributor: 14 | i) changes to the Program, and 15 | ii) additions to the Program; 16 | 17 | where such changes and/or additions to the Program originate from and are 18 | distributed by that particular Contributor. A Contribution 'originates' 19 | from a Contributor if it was added to the Program by such Contributor 20 | itself or anyone acting on such Contributor's behalf. Contributions do not 21 | include additions to the Program which: (i) are separate modules of 22 | software distributed in conjunction with the Program under their own 23 | license agreement, and (ii) are not derivative works of the Program. 24 | 25 | "Contributor" means any person or entity that distributes the Program. 26 | 27 | "Licensed Patents" mean patent claims licensable by a Contributor which are 28 | necessarily infringed by the use or sale of its Contribution alone or when 29 | combined with the Program. 30 | 31 | "Program" means the Contributions distributed in accordance with this 32 | Agreement. 33 | 34 | "Recipient" means anyone who receives the Program under this Agreement, 35 | including all Contributors. 36 | 37 | 2. GRANT OF RIGHTS 38 | a) Subject to the terms of this Agreement, each Contributor hereby grants 39 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 40 | reproduce, prepare derivative works of, publicly display, publicly 41 | perform, distribute and sublicense the Contribution of such Contributor, 42 | if any, and such derivative works, in source code and object code form. 43 | b) Subject to the terms of this Agreement, each Contributor hereby grants 44 | Recipient a non-exclusive, worldwide, royalty-free patent license under 45 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 46 | transfer the Contribution of such Contributor, if any, in source code and 47 | object code form. This patent license shall apply to the combination of 48 | the Contribution and the Program if, at the time the Contribution is 49 | added by the Contributor, such addition of the Contribution causes such 50 | combination to be covered by the Licensed Patents. The patent license 51 | shall not apply to any other combinations which include the Contribution. 52 | No hardware per se is licensed hereunder. 53 | c) Recipient understands that although each Contributor grants the licenses 54 | to its Contributions set forth herein, no assurances are provided by any 55 | Contributor that the Program does not infringe the patent or other 56 | intellectual property rights of any other entity. Each Contributor 57 | disclaims any liability to Recipient for claims brought by any other 58 | entity based on infringement of intellectual property rights or 59 | otherwise. As a condition to exercising the rights and licenses granted 60 | hereunder, each Recipient hereby assumes sole responsibility to secure 61 | any other intellectual property rights needed, if any. For example, if a 62 | third party patent license is required to allow Recipient to distribute 63 | the Program, it is Recipient's responsibility to acquire that license 64 | before distributing the Program. 65 | d) Each Contributor represents that to its knowledge it has sufficient 66 | copyright rights in its Contribution, if any, to grant the copyright 67 | license set forth in this Agreement. 68 | 69 | 3. REQUIREMENTS 70 | 71 | A Contributor may choose to distribute the Program in object code form under 72 | its own license agreement, provided that: 73 | 74 | a) it complies with the terms and conditions of this Agreement; and 75 | b) its license agreement: 76 | i) effectively disclaims on behalf of all Contributors all warranties 77 | and conditions, express and implied, including warranties or 78 | conditions of title and non-infringement, and implied warranties or 79 | conditions of merchantability and fitness for a particular purpose; 80 | ii) effectively excludes on behalf of all Contributors all liability for 81 | damages, including direct, indirect, special, incidental and 82 | consequential damages, such as lost profits; 83 | iii) states that any provisions which differ from this Agreement are 84 | offered by that Contributor alone and not by any other party; and 85 | iv) states that source code for the Program is available from such 86 | Contributor, and informs licensees how to obtain it in a reasonable 87 | manner on or through a medium customarily used for software exchange. 88 | 89 | When the Program is made available in source code form: 90 | 91 | a) it must be made available under this Agreement; and 92 | b) a copy of this Agreement must be included with each copy of the Program. 93 | Contributors may not remove or alter any copyright notices contained 94 | within the Program. 95 | 96 | Each Contributor must identify itself as the originator of its Contribution, 97 | if 98 | any, in a manner that reasonably allows subsequent Recipients to identify the 99 | originator of the Contribution. 100 | 101 | 4. COMMERCIAL DISTRIBUTION 102 | 103 | Commercial distributors of software may accept certain responsibilities with 104 | respect to end users, business partners and the like. While this license is 105 | intended to facilitate the commercial use of the Program, the Contributor who 106 | includes the Program in a commercial product offering should do so in a manner 107 | which does not create potential liability for other Contributors. Therefore, 108 | if a Contributor includes the Program in a commercial product offering, such 109 | Contributor ("Commercial Contributor") hereby agrees to defend and indemnify 110 | every other Contributor ("Indemnified Contributor") against any losses, 111 | damages and costs (collectively "Losses") arising from claims, lawsuits and 112 | other legal actions brought by a third party against the Indemnified 113 | Contributor to the extent caused by the acts or omissions of such Commercial 114 | Contributor in connection with its distribution of the Program in a commercial 115 | product offering. The obligations in this section do not apply to any claims 116 | or Losses relating to any actual or alleged intellectual property 117 | infringement. In order to qualify, an Indemnified Contributor must: 118 | a) promptly notify the Commercial Contributor in writing of such claim, and 119 | b) allow the Commercial Contributor to control, and cooperate with the 120 | Commercial Contributor in, the defense and any related settlement 121 | negotiations. The Indemnified Contributor may participate in any such claim at 122 | its own expense. 123 | 124 | For example, a Contributor might include the Program in a commercial product 125 | offering, Product X. That Contributor is then a Commercial Contributor. If 126 | that Commercial Contributor then makes performance claims, or offers 127 | warranties related to Product X, those performance claims and warranties are 128 | such Commercial Contributor's responsibility alone. Under this section, the 129 | Commercial Contributor would have to defend claims against the other 130 | Contributors related to those performance claims and warranties, and if a 131 | court requires any other Contributor to pay any damages as a result, the 132 | Commercial Contributor must pay those damages. 133 | 134 | 5. NO WARRANTY 135 | 136 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN 137 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR 138 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, 139 | NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each 140 | Recipient is solely responsible for determining the appropriateness of using 141 | and distributing the Program and assumes all risks associated with its 142 | exercise of rights under this Agreement , including but not limited to the 143 | risks and costs of program errors, compliance with applicable laws, damage to 144 | or loss of data, programs or equipment, and unavailability or interruption of 145 | operations. 146 | 147 | 6. DISCLAIMER OF LIABILITY 148 | 149 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 150 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 151 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 152 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 153 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 154 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 155 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 156 | OF SUCH DAMAGES. 157 | 158 | 7. GENERAL 159 | 160 | If any provision of this Agreement is invalid or unenforceable under 161 | applicable law, it shall not affect the validity or enforceability of the 162 | remainder of the terms of this Agreement, and without further action by the 163 | parties hereto, such provision shall be reformed to the minimum extent 164 | necessary to make such provision valid and enforceable. 165 | 166 | If Recipient institutes patent litigation against any entity (including a 167 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 168 | (excluding combinations of the Program with other software or hardware) 169 | infringes such Recipient's patent(s), then such Recipient's rights granted 170 | under Section 2(b) shall terminate as of the date such litigation is filed. 171 | 172 | All Recipient's rights under this Agreement shall terminate if it fails to 173 | comply with any of the material terms or conditions of this Agreement and does 174 | not cure such failure in a reasonable period of time after becoming aware of 175 | such noncompliance. If all Recipient's rights under this Agreement terminate, 176 | Recipient agrees to cease use and distribution of the Program as soon as 177 | reasonably practicable. However, Recipient's obligations under this Agreement 178 | and any licenses granted by Recipient relating to the Program shall continue 179 | and survive. 180 | 181 | Everyone is permitted to copy and distribute copies of this Agreement, but in 182 | order to avoid inconsistency the Agreement is copyrighted and may only be 183 | modified in the following manner. The Agreement Steward reserves the right to 184 | publish new versions (including revisions) of this Agreement from time to 185 | time. No one other than the Agreement Steward has the right to modify this 186 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 187 | Eclipse Foundation may assign the responsibility to serve as the Agreement 188 | Steward to a suitable separate entity. Each new version of the Agreement will 189 | be given a distinguishing version number. The Program (including 190 | Contributions) may always be distributed subject to the version of the 191 | Agreement under which it was received. In addition, after a new version of the 192 | Agreement is published, Contributor may elect to distribute the Program 193 | (including its Contributions) under the new version. Except as expressly 194 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 195 | licenses to the intellectual property of any Contributor under this Agreement, 196 | whether expressly, by implication, estoppel or otherwise. All rights in the 197 | Program not expressly granted under this Agreement are reserved. 198 | 199 | This Agreement is governed by the laws of the State of New York and the 200 | intellectual property laws of the United States of America. No party to this 201 | Agreement will bring a legal action under this Agreement more than one year 202 | after the cause of action arose. Each party waives its rights to a jury trial in 203 | any resulting litigation. 204 | 205 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-messaging/mq-q-qload/899bb4b0e8b6c50e1b2030394623c1672e2c0870/README.md -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | # Build Q and QLOAD programs for Linux 2 | 3 | Q_OBJS= \ 4 | q.o \ 5 | qlmsg.o \ 6 | qlcs.o \ 7 | qlparse.o \ 8 | qlaccess.o \ 9 | qlstruct.o \ 10 | qlvalues.o \ 11 | qlutil.o 12 | 13 | 14 | QLOAD_OBJS= \ 15 | qload.o \ 16 | qloadfnc.o \ 17 | qlcs.o \ 18 | qlvalues.o \ 19 | qlutil.o 20 | 21 | MQLIB=/opt/mqm/lib64 22 | MQINC=/opt/mqm/inc 23 | LIBS=-lpthread -ldl -lmqm 24 | CFLAGS= -I$(MQINC) -I. -DAMQ_UNIX -D_LINUX_2 25 | PLAT=linux_x64 26 | 27 | all: q qload 28 | -mkdir -p ../ship/$(PLAT) 29 | rm -f ../ship/$(PLAT)/* *.o 30 | mv q qload ../ship/$(PLAT) 31 | cp *.txt ../ship/$(PLAT) 32 | 33 | 34 | q: $(Q_OBJS) Makefile 35 | $(CC) -o $@ $(Q_OBJS) -L$(MQLIB) $(LIBS) 36 | 37 | qload: $(QLOAD_OBJS) Makefile 38 | $(CC) -o $@ $(QLOAD_OBJS) -L$(MQLIB) $(LIBS) 39 | -------------------------------------------------------------------------------- /src/README.txt: -------------------------------------------------------------------------------- 1 | Building the programs 2 | 3 | Included in this package is a Makefile for Linux x64. 4 | You can use that Makefile as a template for other platforms, 5 | with appropriate #define values. Often the platform compiler 6 | will define some of the values that can be seen as #ifdef 7 | elements in this source tree, but some MQ-related definitions 8 | may also be needed. 9 | 10 | Used #defines in the code which differentiate platforms include 11 | 12 | AMQ_AS400 13 | AMQ_UNIX (for all Unix and Linux platforms) 14 | MVS 15 | WIN32, WIN64, WINDOWS, _WINDOWS 16 | HP_NSK 17 | 18 | Within the Unix/Linux family, there are also 19 | subdivisions for the #defines. You will see 20 | _AIX 21 | _HPUX_SOURCE 22 | _LINUX_2 23 | _SOLARIS_2 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/q.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1995, 2014 IBM Corporation and other Contributors. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Paul Clarke - Initial Contribution 11 | */ 12 | /*********************************************************************/ 13 | /**********************************************************************/ 14 | /* FILE : Q.H */ 15 | /* PURPOSE: MQSeries Queueing Program */ 16 | /**********************************************************************/ 17 | /* Verbose Levels */ 18 | #define VL_MESSAGE 1 19 | #define VL_MQAPI 2 20 | #define VL_MQDETAILS 3 21 | /* Message Options */ 22 | #define MO_DETAIL_2 '2' 23 | #define MO_DETAIL_3 '3' 24 | #define MO_MQMD_BEFORE 'D' 25 | #define MO_PROP_FORCE_RFH2 'F' 26 | #define MO_MQGMO_BEFORE 'G' 27 | #define MO_OUTPUT_NOMSG 'N' 28 | #define MO_MQOD_BEFORE 'O' 29 | #define MO_MQPMO_BEFORE 'P' 30 | #define MO_MQSRO_BEFORE 'R' 31 | #define MO_MQSD_BEFORE 'S' 32 | #define MO_OUTPUT_NOXML 'X' 33 | #define MO_PROP_ALL 'a' 34 | #define MO_IGNORE_CRLF 'c' 35 | #define MO_MQMD_AFTER 'd' 36 | #define MO_OUTPUT_MQMD 'd' 37 | #define MO_OUTPUT_FORMAT 'f' 38 | #define MO_MQGMO_AFTER 'g' 39 | #define MO_OUTPUT_HEX 'h' 40 | #define MO_OUTPUT_MSGLEN 'l' 41 | #define MO_PROP_NONE 'n' 42 | #define MO_MQOD_AFTER 'o' 43 | #define MO_MQPMO_AFTER 'p' 44 | #define MO_MQSRO_AFTER 'r' 45 | #define MO_MQSD_AFTER 's' 46 | #define MO_OUTPUT_OFFSET 't' 47 | #define MO_OUTPUT_XML 'x' 48 | 49 | /* Typedefs */ 50 | typedef struct _MQ 51 | { 52 | MQAPI Api; 53 | MQHCONN hQm; 54 | char Qm[50]; 55 | void * pQArray; 56 | } MQ; 57 | /* Global variables */ 58 | #ifdef Q_GLOBALS 59 | MQ Mq; 60 | int verbose; 61 | #else 62 | extern MQ Mq; 63 | extern int verbose; 64 | #endif 65 | 66 | /* MVS defines */ 67 | #ifdef MVS 68 | #define QueryQMName QuQMName 69 | #define OpenQueue OpenQ 70 | #pragma linkage(QuQMName, OS) 71 | #pragma linkage(OpenQ, OS) 72 | #endif 73 | 74 | #ifndef MQRR_DEFAULT /* Strangly missing from cmqc.h for MVS */ 75 | typedef struct tagMQRR MQRR; 76 | typedef MQRR MQPOINTER PMQRR; 77 | 78 | struct tagMQRR { 79 | MQLONG CompCode; /* Completion code for queue */ 80 | MQLONG Reason; /* Reason code for queue */ 81 | }; 82 | 83 | #define MQRR_DEFAULT MQCC_OK,\ 84 | MQRC_NONE 85 | #endif 86 | /* Prototypes */ 87 | MQLONG QueryQMName (MQ * pMQ, 88 | MQCHAR48 QM); 89 | 90 | MQLONG OpenQueue (MQ * Mq, 91 | char * Q, 92 | MQLONG OpenFlags, 93 | MQLONG Version, 94 | MQHOBJ * hObJ); 95 | 96 | void Usage (int AskedFor,char * Topic); 97 | -------------------------------------------------------------------------------- /src/q.txt: -------------------------------------------------------------------------------- 1 | IBM MQ Q Program 2 | 3 | Usage: Q 4 | [-a[dnpqcRrstfFaAcD] Message attributes 5 | p:Persistent,n:Non-Persisent,q:Persistence as Q,s:Allow Segmentation 6 | c:complete message,d:Datagram,R:Request,r:Reply,t:Report 7 | f:Async put, F:no async put 8 | a:Read Ahead, A:No Read Ahead 9 | c:Complete message 10 | C:Close Quiesce, D:Close Delete 11 | i:Individual queues o:Use offsets 12 | x:No # message procesing X:Input exclusive 13 | 2:Force message properties as MQRFH2s 14 | [-A[i|o|a] Application Identity|Origin Data|Acct Token 15 | (c) [-b Browse input Q (DEP:use i rather than I] 16 | [-cCCSid[:X'Encoding'] Convert] 17 | [-C[a][i][A][I] Context] 18 | a: pass all context i: pass identity context 19 | A: set all context I: set identity context 20 | n: no context 21 | (c) [-d[h][f][n][w][1][2][3] Display Detail 22 | h:Print message in hex n:Don't print message 23 | d/D:Print out MQMD o/O:Print out MQOD 24 | p/P:Print out MQPMO g/G:Print out MQGMO 25 | s/S:Print out MQSD r/R:Print out MQSRO 26 | a:All properties n:No properties 27 | F:Force RFH2 28 | x:Use XML Shortform X:No XML Auto detect 29 | l:Print message length f:Format recognised messages 30 | 1:Low level of detail 2:Medium level of detail 31 | 3:High level of detail 32 | [-e Echo to Reply Queue] 33 | [-E Echo to Reply Queue and set Reply QMgr] 34 | [-f Input file] Each line is one message 35 | [-F Load/Unload file] Entire file for one message 36 | [-X Load a file in hex as one message 37 | [-g[p][x][C][m|c|g]identifier Get or Put by identifier 38 | x:ID is in hex p:Put with ID C:Use MQCI New session 39 | m:Message ID c:Correlation ID g:Group ID 40 | [-h Filter string] 41 | [-H Selection string] 42 | (c) [-i Input Queue (browse)] 43 | (c) [-I Input Queue (get)] 44 | [-j Specify format name ] 45 | [-k Browse Lock] 46 | [-l Library name] e.g.mqm or mqic 47 | [-L Message Limit] Maximum number of messages to process 48 | [-m LocalQueueManager] 49 | [-M Simple text message] 50 | [-n"Confirm options" below :- 51 | [ca|cad|cafd] [cd|cdd|cdfd] [e|ed|efd] [x|xd|xfd] 52 | [pan][nan][newm][passm][copym][disc][passd][act] 53 | (c) {-o Output Queue} Multiple use uses distribution list 54 | {-O Output Queue} Bind on Open version of above 55 | [-p Commit interval] [-P Message Priority] 56 | [-q Quiet....don't write messages to screen 57 | [-r[+] Reply Queue] 58 | [-s Force msg output to stdout] 59 | [-$ Queue Separator character] 60 | [-t Print timings 61 | [-U[+] User Identifier [+]: Alternate Userid 62 | [-v[p|P|1|2|3|4|5] Verbose Level 63 | p: Pause, P: Cmd line parms >=1: Message info,>=2: API info] 64 | [-V[z][c] Return value, default MQRC] 65 | z:Force zero return c:MQCC mapped to 0,4,8 66 | (c) [-w Wait for messages (in seconds)] 67 | [-W Sleep before issuing MQGET (in milliseconds)] 68 | [-x[f][s][i][b|n][c][q][N][t][u] Use MQCONNX] 69 | f:Fast binding s:Standard binding i:Isolated 70 | b:Shared Blocking Connection n:Shared Nonblocking Connection 71 | c:Specify channel on MQCONNX 72 | q:No fail if quiescing N:No MQDISC 73 | t:Specify connection tag on MQCONNX 74 | u:Specify User ID and Password MQCONNX 75 | v:Register event handler (client mode only) 76 | [-y Expire time in 1/10th's second 77 | [-z Zero out MsgId before MQPUT 78 | [-Z TimeZone (hours) Put Date/Time 79 | [-1 Use MQPUT1 rather than MQPUT 80 | [-# Structure versions] eg. #m1p2g2o1x4 or #c for current 81 | [-* Repeat execution] 82 | [-=[n] Set Max Msg Length - 'n' will not truncate] 83 | [-! Do not use exithandler] 84 | [-S[o:TopicObject] Subscribe to Topic Object 85 | [ [s:TopicString] Subscribe to Topic String 86 | [ [n:SubName] Subscription Name 87 | [ [u:SubUserData] Subscription User Data 88 | [ [l SubLevel] Subscription Level 89 | [ [c][r][a] [d][v][f][g] [N][R] [C][T] 90 | c:Create (def) r:Resume a:Alter subscription 91 | d:Durable 92 | v:Any User f:Fixed User g:Group Sub 93 | N:New pubs only R:Pubs on request 94 | C:Wildcard Char T:Wildcard Topic 95 | D:Delete durable sub 96 | [-T[o:TopicObject] Publish to Topic Object 97 | [ [s:TopicString] Publish to Topic String 98 | [ [r][p][n][w] 99 | r:Retain p:Supress ReplyTo 100 | n:Not own Subs w:Warn if no match 101 | 102 | Common options marked with (c) 103 | 104 | Examples 105 | -------- 106 | Write to a queue : q -oQ1 107 | Write to two queues (Dist list) : q -oQ1 -oQ2 108 | Write to a queue on remote Qmgr : q -oQM2/Q1 109 | Read from a queue : q -IQ1 110 | Browse from a queue : q -iQ1 111 | Show Message Descriptor : q -iQ1 -dd3 112 | Wait for messages : q -IQ1 -w60 113 | Move messages between Queues : q -IQ1 -oQ2 114 | Copy messages between Queues : q -iQ1 -oQ2 115 | Subscribe to a topic : q -Ss:TopicStr -w60 116 | Make a durable subscription : q -Sds:TopicStr -Sn:MySubName -w60 117 | Publish on a topic : q -Ts:TopicStr 118 | -------------------------------------------------------------------------------- /src/qlaccess.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1995, 2014 IBM Corporation and other Contributors. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Paul Clarke - Initial Contribution 11 | */ 12 | /**********************************************************************/ 13 | /* FILE : QLACCESS.C */ 14 | /* PURPOSE: Give dynamic link access to MQAPI */ 15 | /**********************************************************************/ 16 | /* Include files */ 17 | #include "stdlib.h" 18 | #include "stdio.h" 19 | #include "string.h" 20 | #if defined(WIN32) 21 | #include "windows.h" 22 | #endif 23 | #if defined(AMQ_UNIX) 24 | #include 25 | #include 26 | #endif 27 | #include 28 | #include "qlcs.h" 29 | #include "qlaccess.h" 30 | 31 | #ifndef CHAR 32 | #define CHAR char 33 | #endif 34 | 35 | 36 | #if defined(NOLOAD) 37 | #undef LOADLIBRARY 38 | #endif 39 | /* Defines */ 40 | #define DO_NOT_LOAD_MQM_DLL 10 /* Error conditions */ 41 | #define ERROR_LOADING_DLL 11 42 | 43 | /**********************************************************************/ 44 | /* UNSUPPORTED FUNCTIONS */ 45 | /**********************************************************************/ 46 | static void MQENTRY NotSupportedMQCONNX (PMQCHAR pQMgrName, 47 | PMQCNO pConnectOpts, 48 | PMQHCONN pHconn, 49 | PMQLONG pCompCode, 50 | PMQLONG pReason) 51 | { 52 | *pCompCode = MQCC_FAILED; 53 | *pReason = MQRC_FUNCTION_NOT_SUPPORTED; 54 | } 55 | 56 | #ifndef HP_NSK 57 | static void MQENTRY NotSupportedMQSUB (MQHCONN Hconn, 58 | PMQVOID pSubDesc, 59 | PMQHOBJ pHobj, 60 | PMQHOBJ pHsub, 61 | PMQLONG pCompCode, 62 | PMQLONG pReason) 63 | { 64 | *pCompCode = MQCC_FAILED; 65 | *pReason = MQRC_FUNCTION_NOT_SUPPORTED; 66 | } 67 | 68 | static void MQENTRY NotSupportedMQSUBRQ (MQHCONN Hconn, 69 | MQHOBJ Hsub, 70 | MQLONG Action, 71 | PMQVOID pSubRqOpts, 72 | PMQLONG pCompCode, 73 | PMQLONG pReason) 74 | { 75 | *pCompCode = MQCC_FAILED; 76 | *pReason = MQRC_FUNCTION_NOT_SUPPORTED; 77 | } 78 | 79 | static void MQENTRY NotSupportedMQCB (MQHCONN Hconn, 80 | MQLONG Operation, 81 | PMQVOID pCallBackDesc, 82 | MQHOBJ Hobj, 83 | PMQVOID pMsgDesc, 84 | PMQVOID pGetMsgOpts, 85 | PMQLONG pCompCode, 86 | PMQLONG pReason) 87 | { 88 | *pCompCode = MQCC_FAILED; 89 | *pReason = MQRC_FUNCTION_NOT_SUPPORTED; 90 | } 91 | 92 | static void MQENTRY NotSupportedMQCTL (MQHCONN Hconn, 93 | MQLONG Operation, 94 | PMQVOID pControlOpts, 95 | PMQLONG pCompCode, 96 | PMQLONG pReason) 97 | { 98 | *pCompCode = MQCC_FAILED; 99 | *pReason = MQRC_FUNCTION_NOT_SUPPORTED; 100 | } 101 | 102 | static void MQENTRY NotSupportedMQCRTMH (MQHCONN Hconn, 103 | PMQVOID pCrtMsgHOpts, 104 | PMQHMSG pHmsg, 105 | PMQLONG pCompCode, 106 | PMQLONG pReason) 107 | { 108 | *pCompCode = MQCC_FAILED; 109 | *pReason = MQRC_FUNCTION_NOT_SUPPORTED; 110 | } 111 | 112 | static void MQENTRY NotSupportedMQDLTMH (MQHCONN Hconn, 113 | PMQHMSG pHmsg, 114 | PMQVOID pDltMsgHOpts, 115 | PMQLONG pCompCode, 116 | PMQLONG pReason) 117 | { 118 | *pCompCode = MQCC_FAILED; 119 | *pReason = MQRC_FUNCTION_NOT_SUPPORTED; 120 | } 121 | 122 | static void MQENTRY NotSupportedMQINQMP (MQHCONN Hconn, 123 | MQHMSG Hmsg, 124 | PMQVOID pInqPropOpts, 125 | PMQVOID pName, 126 | PMQVOID pPropDesc, 127 | PMQLONG pType, 128 | MQLONG ValueLength, 129 | PMQVOID pValue, 130 | PMQLONG pDataLength, 131 | PMQLONG pCompCode, 132 | PMQLONG pReason) 133 | { 134 | *pCompCode = MQCC_FAILED; 135 | *pReason = MQRC_FUNCTION_NOT_SUPPORTED; 136 | } 137 | 138 | static void MQENTRY NotSupportedMQSETMP (MQHCONN Hconn, 139 | MQHMSG Hmsg, 140 | PMQVOID pSetPropOpts, 141 | PMQVOID pName, 142 | PMQVOID pPropDesc, 143 | MQLONG Type, 144 | MQLONG ValueLength, 145 | PMQVOID pValue, 146 | PMQLONG pCompCode, 147 | PMQLONG pReason) 148 | { 149 | *pCompCode = MQCC_FAILED; 150 | *pReason = MQRC_FUNCTION_NOT_SUPPORTED; 151 | } 152 | 153 | static void MQENTRY NotSupportedMQDLTMP (MQHCONN Hconn, 154 | MQHMSG Hmsg, 155 | PMQVOID pDltPropOpts, 156 | PMQVOID pName, 157 | PMQLONG pCompCode, 158 | PMQLONG pReason) 159 | { 160 | *pCompCode = MQCC_FAILED; 161 | *pReason = MQRC_FUNCTION_NOT_SUPPORTED; 162 | } 163 | 164 | static void MQENTRY NotSupportedMQBUFMH (MQHCONN Hconn, 165 | MQHMSG Hmsg, 166 | PMQVOID pBufMsgHOpts, 167 | PMQVOID pMsgDesc, 168 | MQLONG BufferLength, 169 | PMQVOID pBuffer, 170 | PMQLONG pDataLength, 171 | PMQLONG pCompCode, 172 | PMQLONG pReason) 173 | { 174 | *pCompCode = MQCC_FAILED; 175 | *pReason = MQRC_FUNCTION_NOT_SUPPORTED; 176 | } 177 | 178 | static void MQENTRY NotSupportedMQMHBUF (MQHCONN Hconn, 179 | MQHMSG Hmsg, 180 | PMQVOID pMsgHBufOpts, 181 | PMQVOID pName, 182 | PMQVOID pMsgDesc, 183 | MQLONG BufferLength, 184 | PMQVOID pBuffer, 185 | PMQLONG pDataLength, 186 | PMQLONG pCompCode, 187 | PMQLONG pReason) 188 | { 189 | *pCompCode = MQCC_FAILED; 190 | *pReason = MQRC_FUNCTION_NOT_SUPPORTED; 191 | } 192 | 193 | static void MQENTRY NotSupportedMQSTAT (MQHCONN Hconn, 194 | MQLONG Type, 195 | PMQVOID pStatus, 196 | PMQLONG pCompCode, 197 | PMQLONG pReason) 198 | { 199 | *pCompCode = MQCC_FAILED; 200 | *pReason = MQRC_FUNCTION_NOT_SUPPORTED; 201 | } 202 | #endif 203 | 204 | 205 | #ifdef LOADLIBRARY 206 | 207 | static char * GetDefaultPath(void) 208 | { 209 | BOOL Bit64 = sizeof(char *) == 8; 210 | 211 | /* printf("Bit64 is %d\n",Bit64); */ 212 | 213 | #if defined(_LINUX_2) 214 | return Bit64 ? "/opt/mqm/lib64" : "/opt/mqm/lib"; 215 | #elif defined(_SOLARIS_2) 216 | return Bit64 ? "/opt/mqm/lib64" : "/opt/mqm/lib"; 217 | #elif defined(_AIX) 218 | return Bit64 ? "/usr/mqm/lib64" : "/usr/mqm/lib"; 219 | #elif defined(_HPUX_SOURCE) 220 | return Bit64 ? "/opt/mqm/lib64" : "/opt/mqm/lib"; 221 | #elif defined(WIN32) || defined(WIN64) 222 | return ""; 223 | #elif defined(AMQ_AS400) 224 | return ""; 225 | #else 226 | #error Please add default path to GetDefaultPath 227 | #endif 228 | } 229 | 230 | static char * GetClientPath(void) 231 | { 232 | char * pPath = getenv("MQIC_DLL_PATH"); 233 | if (!pPath) pPath = GetDefaultPath(); 234 | return pPath; 235 | } 236 | 237 | static char * GetServerPath(void) 238 | { 239 | char * pPath = getenv("MQM_DLL_PATH"); 240 | if (!pPath) pPath = GetDefaultPath(); 241 | return pPath; 242 | } 243 | /**********************************************************************/ 244 | /* Function : MQAccess */ 245 | /* Purpose : Dynamically load the supplied library. Resolve the MQI */ 246 | /* function adresses and place them in the given MQAPI */ 247 | /* control block. */ 248 | /* MQI can then be called using the indirect MQ macros */ 249 | /* defined in MQACCESS.H. */ 250 | /**********************************************************************/ 251 | int MQAccess(char * Library, MQAPI * MQApi) 252 | { 253 | int rc = 0; 254 | #ifdef AMQ_AS400 255 | CSLIBHANDLE lib = 0; 256 | #else 257 | CSLIBHANDLE lib = NULL; 258 | #endif 259 | CHAR * pPath = NULL; 260 | 261 | CSLock(0); 262 | 263 | if (Library && *Library) 264 | { 265 | /* Is this a client ? */ 266 | if (strstr(Library,"mqic")) 267 | { 268 | pPath = GetClientPath(); 269 | /* Is it EXACTLY the client */ 270 | if (!strcmp(Library,"mqic" )) Library = CLIENT_LIB; 271 | if (!strcmp(Library,"mqic32")) Library = CLIENT_LIB; 272 | } 273 | else 274 | pPath = GetServerPath(); 275 | 276 | rc = CSAccessLibrary(Library,pPath,NULL,0,&lib); 277 | } 278 | else 279 | { 280 | rc = CSAccessLibrary(SERVER_LIB,GetServerPath(),NULL,0,&lib); 281 | if (rc) rc = CSAccessLibrary(CLIENT_LIB,GetClientPath(),NULL,0,&lib); 282 | } 283 | /********************************************************************/ 284 | /* Do we have a library loaded then ? */ 285 | /********************************************************************/ 286 | if (rc) goto MOD_EXIT; 287 | /* Load the MQI entry points */ 288 | if ((MQApi->MQCONN = (void *) CSAccessProc(lib, "MQCONN" )) == NULL) 289 | { 290 | rc = ERROR_LOADING_DLL; 291 | goto MOD_EXIT; 292 | } 293 | if ((MQApi->MQDISC = (void *) CSAccessProc(lib, "MQDISC" )) == NULL) 294 | { 295 | rc = ERROR_LOADING_DLL; 296 | goto MOD_EXIT; 297 | } 298 | if ((MQApi->MQCMIT = (void *) CSAccessProc(lib, "MQCMIT" )) == NULL) 299 | { 300 | rc = ERROR_LOADING_DLL; 301 | goto MOD_EXIT; 302 | } 303 | if ((MQApi->MQBACK = (void *) CSAccessProc(lib, "MQBACK" )) == NULL) 304 | { 305 | rc = ERROR_LOADING_DLL; 306 | goto MOD_EXIT; 307 | } 308 | if ((MQApi->MQPUT = (void *) CSAccessProc(lib, "MQPUT" )) == NULL) 309 | { 310 | rc = ERROR_LOADING_DLL; 311 | goto MOD_EXIT; 312 | } 313 | if ((MQApi->MQGET = (void *) CSAccessProc(lib, "MQGET" )) == NULL) 314 | { 315 | rc = ERROR_LOADING_DLL; 316 | goto MOD_EXIT; 317 | } 318 | if ((MQApi->MQPUT1 = (void *) CSAccessProc(lib, "MQPUT1" )) == NULL) 319 | { 320 | rc = ERROR_LOADING_DLL; 321 | goto MOD_EXIT; 322 | } 323 | if ((MQApi->MQINQ = (void *) CSAccessProc(lib, "MQINQ" )) == NULL) 324 | { 325 | rc = ERROR_LOADING_DLL; 326 | goto MOD_EXIT; 327 | } 328 | if ((MQApi->MQSET = (void *) CSAccessProc(lib, "MQSET" )) == NULL) 329 | { 330 | rc = ERROR_LOADING_DLL; 331 | goto MOD_EXIT; 332 | } 333 | if ((MQApi->MQOPEN = (void *) CSAccessProc(lib, "MQOPEN" )) == NULL) 334 | { 335 | rc = ERROR_LOADING_DLL; 336 | goto MOD_EXIT; 337 | } 338 | if ((MQApi->MQCLOSE = (void *) CSAccessProc(lib, "MQCLOSE")) == NULL) 339 | rc = ERROR_LOADING_DLL; 340 | /********************************************************************/ 341 | /* The following APIs might not be there. We try to load them */ 342 | /* but if we fail we point it at a 'dummy' function */ 343 | /********************************************************************/ 344 | MQApi->MQCONNX = (void *) CSAccessProc(lib, "MQCONNX" ); 345 | if (!MQApi->MQCONNX) 346 | { 347 | MQApi->MQCONNX = NotSupportedMQCONNX; 348 | } 349 | 350 | MQApi->MQSUB = (void *) CSAccessProc(lib, "MQSUB" ); 351 | if (!MQApi->MQSUB) 352 | { 353 | MQApi->MQSUB = NotSupportedMQSUB; 354 | } 355 | 356 | MQApi->MQSUBRQ = (void *) CSAccessProc(lib, "MQSUBRQ" ); 357 | if (!MQApi->MQSUBRQ) 358 | { 359 | MQApi->MQSUBRQ = NotSupportedMQSUBRQ; 360 | } 361 | 362 | MQApi->MQCB = (void *) CSAccessProc(lib, "MQCB" ); 363 | if (!MQApi->MQCB) 364 | { 365 | MQApi->MQCB = NotSupportedMQCB; 366 | } 367 | 368 | MQApi->MQCTL = (void *) CSAccessProc(lib, "MQCTL" ); 369 | if (!MQApi->MQCTL) 370 | { 371 | MQApi->MQCTL = NotSupportedMQCTL; 372 | } 373 | 374 | MQApi->MQCRTMH = (void *) CSAccessProc(lib, "MQCRTMH" ); 375 | if (!MQApi->MQCRTMH) 376 | { 377 | MQApi->MQCRTMH = NotSupportedMQCRTMH; 378 | } 379 | 380 | MQApi->MQDLTMH = (void *) CSAccessProc(lib, "MQDLTMH" ); 381 | if (!MQApi->MQDLTMH) 382 | { 383 | MQApi->MQDLTMH = NotSupportedMQDLTMH; 384 | } 385 | 386 | MQApi->MQINQMP = (void *) CSAccessProc(lib, "MQINQMP" ); 387 | if (!MQApi->MQINQMP) 388 | { 389 | MQApi->MQINQMP = NotSupportedMQINQMP; 390 | } 391 | 392 | MQApi->MQSETMP = (void *) CSAccessProc(lib, "MQSETMP" ); 393 | if (!MQApi->MQSETMP) 394 | { 395 | MQApi->MQSETMP = NotSupportedMQSETMP; 396 | } 397 | 398 | MQApi->MQDLTMP = (void *) CSAccessProc(lib, "MQDLTMP" ); 399 | if (!MQApi->MQDLTMP) 400 | { 401 | MQApi->MQDLTMP = NotSupportedMQDLTMP; 402 | } 403 | 404 | MQApi->MQBUFMH = (void *) CSAccessProc(lib, "MQBUFMH" ); 405 | if (!MQApi->MQBUFMH) 406 | { 407 | MQApi->MQBUFMH = NotSupportedMQBUFMH; 408 | } 409 | 410 | MQApi->MQMHBUF = (void *) CSAccessProc(lib, "MQMHBUF" ); 411 | if (!MQApi->MQMHBUF) 412 | { 413 | MQApi->MQMHBUF = NotSupportedMQMHBUF; 414 | } 415 | 416 | MQApi->MQSTAT = (void *) CSAccessProc(lib, "MQSTAT" ); 417 | if (!MQApi->MQSTAT) 418 | { 419 | MQApi->MQSTAT = NotSupportedMQSTAT; 420 | } 421 | 422 | MOD_EXIT: 423 | CSUnlock(0); 424 | return rc; 425 | } 426 | #endif 427 | 428 | #ifndef LOADLIBRARY 429 | /**********************************************************************/ 430 | /* Function : MQAccess */ 431 | /* Purpose : Non dynamically loaded version. */ 432 | /**********************************************************************/ 433 | int MQAccess(char * Library, MQAPI * MQApi) 434 | { 435 | MQApi->MQCONN = MQCONN; 436 | MQApi->MQCONNX = MQCONNX; 437 | MQApi->MQDISC = MQDISC; 438 | MQApi->MQCMIT = MQCMIT; 439 | MQApi->MQBACK = MQBACK; 440 | MQApi->MQPUT = MQPUT; 441 | MQApi->MQGET = MQGET; 442 | MQApi->MQPUT1 = MQPUT1; 443 | MQApi->MQINQ = MQINQ; 444 | MQApi->MQSET = MQSET; 445 | MQApi->MQOPEN = MQOPEN; 446 | MQApi->MQCLOSE = MQCLOSE; 447 | 448 | #ifndef HP_NSK 449 | MQApi->MQSUB = MQSUB; 450 | MQApi->MQSUBRQ = MQSUBRQ; 451 | MQApi->MQCB = MQCB; 452 | MQApi->MQCTL = MQCTL; 453 | MQApi->MQCRTMH = MQCRTMH; 454 | MQApi->MQDLTMH = MQDLTMH; 455 | MQApi->MQINQMP = MQINQMP; 456 | MQApi->MQSETMP = MQSETMP; 457 | MQApi->MQDLTMP = MQDLTMP; 458 | MQApi->MQBUFMH = MQBUFMH; 459 | MQApi->MQMHBUF = MQMHBUF; 460 | MQApi->MQSTAT = MQSTAT; 461 | #endif 462 | 463 | return 0; 464 | } 465 | #endif 466 | -------------------------------------------------------------------------------- /src/qlaccess.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1995, 2014 IBM Corporation and other Contributors. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Paul Clarke - Initial Contribution 11 | */ 12 | /**********************************************************************/ 13 | /* FILE : QLACCESS.H */ 14 | /* PURPOSE: Give dynamic access to MQAPI */ 15 | /**********************************************************************/ 16 | 17 | #if defined(MVS) || defined (HP_NSK) 18 | 19 | #define SERVER_LIB NULL 20 | #define CLIENT_LIB NULL 21 | /* Datatypes */ 22 | #elif defined(WIN32) 23 | #define LOADLIBRARY 24 | #define SERVER_LIB "mqm.dll" 25 | #define CLIENT_LIB "mqic32.dll" 26 | #define MQ_DEFAULT_PATH "" 27 | 28 | #elif defined(AMQ_UNIX) || defined(AMQ_AS400) 29 | #define LOADLIBRARY 30 | 31 | #ifdef _AIX 32 | #ifdef _REENTRANT 33 | #define SERVER_LIB "libmqm_r.a(libmqm_r.o)" 34 | #define CLIENT_LIB "libmqic_r.a(mqic_r.o)" 35 | #else 36 | #define SERVER_LIB "libmqm.a(libmqm.o)" 37 | #define CLIENT_LIB "libmqic.a(mqic.o)" 38 | #endif 39 | #endif 40 | 41 | #ifdef _HPUX_SOURCE 42 | #ifdef HP_IPF 43 | #ifdef _REENTRANT 44 | #define SERVER_LIB "libmqm_r.so" 45 | #define CLIENT_LIB "libmqic_r.so" 46 | #else 47 | #define SERVER_LIB "libmqm.so" 48 | #define CLIENT_LIB "libmqic.so" 49 | #endif 50 | #else 51 | #ifdef _REENTRANT 52 | #define SERVER_LIB "libmqm_r.sl" 53 | #define CLIENT_LIB "libmqic_r.sl" 54 | #else 55 | #define SERVER_LIB "libmqm.sl" 56 | #define CLIENT_LIB "libmqic.sl" 57 | #endif 58 | #endif 59 | #endif 60 | 61 | #ifdef _SOLARIS_2 62 | #define SERVER_LIB "libmqm.so" 63 | #define CLIENT_LIB "libmqic.so" 64 | #endif 65 | 66 | #ifdef AMQ_AS400 67 | #ifdef _REENTRANT 68 | #define SERVER_LIB "QMQM/LIBMQM_R" 69 | #define CLIENT_LIB "QMQM/LIBMQIC_R" 70 | #else 71 | #define SERVER_LIB "QMQM/LIBMQM" 72 | #define CLIENT_LIB "QMQM/LIBMQIC" 73 | #endif 74 | #endif 75 | 76 | #if defined (_LINUX_2) 77 | #ifdef _REENTRANT 78 | #define SERVER_LIB "libmqm_r.so" 79 | #define CLIENT_LIB "libmqic_r.so" 80 | #else 81 | #define SERVER_LIB "libmqm.so" 82 | #define CLIENT_LIB "libmqic.so" 83 | #endif 84 | #endif 85 | 86 | 87 | #endif 88 | /* Datatypes */ 89 | #define PMQENTRY MQENTRY * 90 | /* Indirect MQAPI macros */ 91 | #ifdef NOLOAD 92 | #define IMQBACK(m,Hconn,pC,pR) \ 93 | MQBACK(Hconn,pC,pR) 94 | 95 | #define IMQCLOSE(m,Hconn,pHobj,Options,pC,pR) \ 96 | MQCLOSE(Hconn,pHobj,Options,pC,pR) 97 | 98 | #define IMQCMIT(m,Hconn,pC,pR) \ 99 | MQCMIT(Hconn,pC,pR) 100 | 101 | #define IMQCONN(m,pName,pHconn,pC,pR) \ 102 | MQCONN(pName,pHconn,pC,pR) 103 | 104 | #define IMQCONNX(m,pName,pConnOpts,pHconn,pC,pR) \ 105 | MQCONNX(pName,pConnOpts,pHconn,pC,pR) 106 | 107 | #define IMQDISC(m,pHconn,pC,pR) \ 108 | MQDISC(pHconn,pC,pR) 109 | 110 | #define IMQGET(m,Hconn,Hobj,pMQMD,pMQGMO,BufLen,Buf,DatLen,pC,pR) \ 111 | MQGET(Hconn,Hobj,pMQMD,pMQGMO,BufLen,Buf,DatLen,pC,pR) 112 | 113 | #define IMQINQ(m,Hconn,Hobj,Sc,pS,Ia,pI,Cha,pCh,pC,pR) \ 114 | MQINQ(Hconn,Hobj,Sc,pS,Ia,pI,Cha,pCh,pC,pR) 115 | 116 | #define IMQOPEN(m,Hconn,pMQOD,Opt,pHobj,pC,pR) \ 117 | MQOPEN(Hconn,pMQOD,Opt,pHobj,pC,pR) 118 | 119 | #define IMQPUT(m,Hconn,Hobj,pMQMD,pMQPMO,BufLen,Buf,pC,pR) \ 120 | MQPUT(Hconn,Hobj,pMQMD,pMQPMO,BufLen,Buf,pC,pR) 121 | 122 | #define IMQPUT1(m,Hconn,pMQOD,pMQMD,pMQPMO,BufLen,Buf,pC,pR) \ 123 | MQPUT1(Hconn,pMQOD,pMQMD,pMQPMO,BufLen,Buf,pC,pR) 124 | 125 | #define IMQSET(m,Hconn,Hobj,Sc,pS,Ia,pI,Cha,pCh,pC,pR) \ 126 | MQSET(Hconn,Hobj,Sc,pS,Ia,pI,Cha,pCh,pC,pR) 127 | 128 | #define IMQSUB(m,Hconn,pSD,Hobj,Hsub,pC,pR) \ 129 | MQSUB(Hconn,pSD,Hobj,Hsub,pC,pR) 130 | 131 | #define IMQSUBRQ(m,Hconn,Hsub,Action,pMQSRO,pC,pR) \ 132 | MQSUBRQ(Hconn,Hsub,Action,pMQSRO,pC,pR) 133 | 134 | #define IMQCB(m,Hconn,Operation,pMQCBD,Hobj,pMQMD,pMQGMO,pC,pR) \ 135 | MQCB(Hconn,Operation,pMQCBD,Hobj,pMQMD,pMQGMO,pC,pR) 136 | 137 | #define IMQCTL(m,Hconn,Operation,pCTLO,pC,pR) \ 138 | MQCTL(Hconn,Operation,pCTLO,pC,pR) 139 | 140 | #define IMQCRTMH(m,Hconn,pCMHO,pHmsg,pC,pR) \ 141 | MQCRTMH(Hconn,pCMHO,pHmsg,pC,pR) 142 | 143 | #define IMQDLTMH(m,Hconn,pHmsg,pDMHO,pC,pR) \ 144 | MQDLTMH(Hconn,pHmsg,pDMHO,pC,pR) 145 | 146 | #define IMQINQMP(m,Hconn,Hmsg,pIPO,pName,pPD,pType,ValLen,pValue,DatLen,pC,pR) \ 147 | MQINQMP(Hconn,Hmsg,pIPO,pName,pPD,pType,ValLen,pValue,DatLen,pC,pR) 148 | 149 | #define IMQSETMP(m,Hconn,Hmsg,pSPO,pName,pPD,Type,ValLen,pValue,pC,pR) \ 150 | MQSETMP(Hconn,Hmsg,pSPO,pName,pPD,Type,ValLen,pValue,pC,pR) 151 | 152 | #define IMQDLTMP(m,Hconn,Hmsg,pDPO,pName,pC,pR) \ 153 | MQDLTMP(Hconn,Hmsg,pDPO,pName,pC,pR) 154 | 155 | #define IMQBUFMH(m,Hconn,Hmsg,pBMHO,pMQMD,BufLen,Buf,DatLen,pC,pR) \ 156 | MQBUFMH(Hconn,Hmsg,pBMHO,pMQMD,BufLen,Buf,DatLen,pC,pR) 157 | 158 | #define IMQMHBUF(m,Hconn,Hmsg,pMHBO,pName,pMQMD,BufLen,Buf,DatLen,pC,pR) \ 159 | MQMHBUF(Hconn,Hmsg,pMHBO,pName,pMQMD,BufLen,Buf,DatLen,pC,pR) 160 | 161 | #define IMQSTAT(m,Hconn,Type,pStatus,pC,pR) \ 162 | MQSTAT(Hconn,Type,pStatus,pC,pR) 163 | 164 | #else /* not NOLOAD */ 165 | #define IMQBACK(m,Hconn,pC,pR) \ 166 | (*(m).MQBACK)(Hconn,pC,pR) 167 | 168 | #define IMQCLOSE(m,Hconn,pHobj,Options,pC,pR) \ 169 | (*(m).MQCLOSE)(Hconn,pHobj,Options,pC,pR) 170 | 171 | #define IMQCMIT(m,Hconn,pC,pR) \ 172 | (*(m).MQCMIT)(Hconn,pC,pR) 173 | 174 | #define IMQCONN(m,pName,pHconn,pC,pR) \ 175 | (*(m).MQCONN)(pName,pHconn,pC,pR) 176 | 177 | #define IMQCONNX(m,pName,pConnOpts,pHconn,pC,pR) \ 178 | (*(m).MQCONNX)(pName,pConnOpts,pHconn,pC,pR) 179 | 180 | #define IMQDISC(m,pHconn,pC,pR) \ 181 | (*(m).MQDISC)(pHconn,pC,pR) 182 | 183 | #define IMQGET(m,Hconn,Hobj,pMQMD,pMQGMO,BufLen,Buf,DatLen,pC,pR) \ 184 | (*(m).MQGET)(Hconn,Hobj,pMQMD,pMQGMO,BufLen,Buf,DatLen,pC,pR) 185 | 186 | #define IMQINQ(m,Hconn,Hobj,Sc,pS,Ia,pI,Cha,pCh,pC,pR) \ 187 | (*(m).MQINQ)(Hconn,Hobj,Sc,pS,Ia,pI,Cha,pCh,pC,pR) 188 | 189 | #define IMQOPEN(m,Hconn,pMQOD,Opt,pHobj,pC,pR) \ 190 | (*(m).MQOPEN)(Hconn,pMQOD,Opt,pHobj,pC,pR) 191 | 192 | #define IMQPUT(m,Hconn,Hobj,pMQMD,pMQPMO,BufLen,Buf,pC,pR) \ 193 | (*(m).MQPUT)(Hconn,Hobj,pMQMD,pMQPMO,BufLen,Buf,pC,pR) 194 | 195 | #define IMQPUT1(m,Hconn,pMQOD,pMQMD,pMQPMO,BufLen,Buf,pC,pR) \ 196 | (*(m).MQPUT1)(Hconn,pMQOD,pMQMD,pMQPMO,BufLen,Buf,pC,pR) 197 | 198 | #define IMQSET(m,Hconn,Hobj,Sc,pS,Ia,pI,Cha,pCh,pC,pR) \ 199 | (*(m).MQSET)(Hconn,Hobj,Sc,pS,Ia,pI,Cha,pCh,pC,pR) 200 | 201 | #ifndef HP_NSK 202 | 203 | #define IMQSUB(m,Hconn,pSD,Hobj,Hsub,pC,pR) \ 204 | (*(m).MQSUB)(Hconn,pSD,Hobj,Hsub,pC,pR) 205 | 206 | #define IMQSUBRQ(m,Hconn,Hsub,Action,pMQSRO,pC,pR) \ 207 | (*(m).MQSUBRQ)(Hconn,Hsub,Action,pMQSRO,pC,pR) 208 | 209 | #define IMQCB(m,Hconn,Operation,pMQCBD,Hobj,pMQMD,pMQGMO,pC,pR) \ 210 | (*(m).MQCB)(Hconn,Operation,pMQCBD,Hobj,pMQMD,pMQGMO,pC,pR) 211 | 212 | #define IMQCTL(m,Hconn,Operation,pCTLO,pC,pR) \ 213 | (* (m).MQCTL)(Hconn,Operation,pCTLO,pC,pR) 214 | 215 | #define IMQCRTMH(m,Hconn,pCMHO,pHmsg,pC,pR) \ 216 | (* (m).MQCRTMH)(Hconn,pCMHO,pHmsg,pC,pR) 217 | 218 | #define IMQDLTMH(m,Hconn,pHmsg,pDMHO,pC,pR) \ 219 | (* (m).MQDLTMH)(Hconn,pHmsg,pDMHO,pC,pR) 220 | 221 | #define IMQINQMP(m,Hconn,Hmsg,pIPO,pName,pPD,pType,ValLen,pValue,DatLen,pC,pR) \ 222 | (* (m).MQINQMP)(Hconn,Hmsg,pIPO,pName,pPD,pType,ValLen,pValue,DatLen,pC,pR) 223 | 224 | #define IMQSETMP(m,Hconn,Hmsg,pSPO,pName,pPD,Type,ValLen,pValue,pC,pR) \ 225 | (* (m).MQSETMP)(Hconn,Hmsg,pSPO,pName,pPD,Type,ValLen,pValue,pC,pR) 226 | 227 | #define IMQDLTMP(m,Hconn,Hmsg,pDPO,pName,pC,pR) \ 228 | (* (m).MQDLTMP)(Hconn,Hmsg,pDPO,pName,pC,pR) 229 | 230 | #define IMQBUFMH(m,Hconn,Hmsg,pBMHO,pMQMD,BufLen,Buf,DatLen,pC,pR) \ 231 | (* (m).MQBUFMH)(Hconn,Hmsg,pBMHO,pMQMD,BufLen,Buf,DatLen,pC,pR) 232 | 233 | #define IMQMHBUF(m,Hconn,Hmsg,pMHBO,pName,pMQMD,BufLen,Buf,DatLen,pC,pR) \ 234 | (* (m).MQMHBUF)(Hconn,Hmsg,pMHBO,pName,pMQMD,BufLen,Buf,DatLen,pC,pR) 235 | 236 | #define IMQSTAT(m,Hconn,Type,pStatus,pC,pR) \ 237 | (* (m).MQSTAT)(Hconn,Type,pStatus,pC,pR) 238 | 239 | #endif 240 | 241 | #endif /* not NOLOAD */ 242 | /* Typedefs */ 243 | typedef struct _MQAPI 244 | { 245 | void (PMQENTRY MQBACK) ( 246 | MQHCONN Hconn, /* Connection handle */ 247 | PMQLONG pCompCode, /* Completion code */ 248 | PMQLONG pReason); /* Reason code qualifying CompCode */ 249 | 250 | void (PMQENTRY MQCLOSE) ( 251 | MQHCONN Hconn, /* Connection handle */ 252 | PMQHOBJ pHobj, /* Object handle */ 253 | MQLONG Options, /* Options that control the action of MQCLOSE */ 254 | PMQLONG pCompCode, /* Completion code */ 255 | PMQLONG pReason); /* Reason code qualifying CompCode */ 256 | 257 | void (PMQENTRY MQCMIT) ( 258 | MQHCONN Hconn, /* Connection handle */ 259 | PMQLONG pCompCode, /* Completion code */ 260 | PMQLONG pReason); /* Reason code qualifying CompCode */ 261 | 262 | void (PMQENTRY MQCONN) ( 263 | PMQCHAR pName, /* Name of queue manager */ 264 | PMQHCONN pHconn, /* Connection handle */ 265 | PMQLONG pCompCode, /* Completion code */ 266 | PMQLONG pReason); /* Reason code qualifying CompCode */ 267 | 268 | void (PMQENTRY MQCONNX) ( 269 | PMQCHAR pName, /* Name of queue manager */ 270 | PMQCNO pConnOpts, /* Connect Options */ 271 | PMQHCONN pHconn, /* Connection handle */ 272 | PMQLONG pCompCode, /* Completion code */ 273 | PMQLONG pReason); /* Reason code qualifying CompCode */ 274 | 275 | void (PMQENTRY MQDISC) ( 276 | PMQHCONN pHconn, /* Connection handle */ 277 | PMQLONG pCompCode, /* Completion code */ 278 | PMQLONG pReason); /* Reason code qualifying CompCode */ 279 | 280 | void (PMQENTRY MQGET) ( 281 | MQHCONN Hconn, /* Connection handle */ 282 | MQHOBJ Hobj, /* Object handle */ 283 | PMQVOID pMsgDesc, /* Message descriptor */ 284 | PMQVOID pGetMsgOpts, /* Options that control the action of 285 | MQGET */ 286 | MQLONG BufferLength, /* Length in bytes of the Buffer area */ 287 | PMQVOID pBuffer, /* Area to contain the message data */ 288 | PMQLONG pDataLength, /* Length of the message */ 289 | PMQLONG pCompCode, /* Completion code */ 290 | PMQLONG pReason); /* Reason code qualifying CompCode */ 291 | 292 | void (PMQENTRY MQINQ) ( 293 | MQHCONN Hconn, /* Connection handle */ 294 | MQHOBJ Hobj, /* Object handle */ 295 | MQLONG SelectorCount, /* Count of selectors */ 296 | PMQLONG pSelectors, /* Array of attribute selectors */ 297 | MQLONG IntAttrCount, /* Count of integer attributes */ 298 | PMQLONG pIntAttrs, /* Array of integer attributes */ 299 | MQLONG CharAttrLength, /* Length of character attributes buffer */ 300 | PMQCHAR pCharAttrs, /* Character attributes */ 301 | PMQLONG pCompCode, /* Completion code */ 302 | PMQLONG pReason); /* Reason code qualifying CompCode */ 303 | 304 | void (PMQENTRY MQOPEN) ( 305 | MQHCONN Hconn, /* Connection handle */ 306 | PMQVOID pObjDesc, /* Object descriptor */ 307 | MQLONG Options, /* Options that control the action of MQOPEN */ 308 | PMQHOBJ pHobj, /* Object handle */ 309 | PMQLONG pCompCode, /* Completion code */ 310 | PMQLONG pReason); /* Reason code qualifying CompCode */ 311 | 312 | 313 | void (PMQENTRY MQPUT) ( 314 | MQHCONN Hconn, /* Connection handle */ 315 | MQHOBJ Hobj, /* Object handle */ 316 | PMQVOID pMsgDesc, /* Message descriptor */ 317 | PMQVOID pPutMsgOpts, /* Options that control the action of 318 | MQPUT */ 319 | MQLONG BufferLength, /* Length of the message in Buffer */ 320 | PMQVOID pBuffer, /* Message data */ 321 | PMQLONG pCompCode, /* Completion code */ 322 | PMQLONG pReason); /* Reason code qualifying CompCode */ 323 | 324 | 325 | void (PMQENTRY MQPUT1) ( 326 | MQHCONN Hconn, /* Connection handle */ 327 | PMQVOID pObjDesc, /* Object descriptor */ 328 | PMQVOID pMsgDesc, /* Message descriptor */ 329 | PMQVOID pPutMsgOpts, /* Options that control the action of 330 | MQPUT1 */ 331 | MQLONG BufferLength, /* Length of the message in Buffer */ 332 | PMQVOID pBuffer, /* Message data */ 333 | PMQLONG pCompCode, /* Completion code */ 334 | PMQLONG pReason); /* Reason code qualifying CompCode */ 335 | 336 | 337 | void (PMQENTRY MQSET) ( 338 | MQHCONN Hconn, /* Connection handle */ 339 | MQHOBJ Hobj, /* Object handle */ 340 | MQLONG SelectorCount, /* Count of selectors */ 341 | PMQLONG pSelectors, /* Array of attribute selectors */ 342 | MQLONG IntAttrCount, /* Count of integer attributes */ 343 | PMQLONG pIntAttrs, /* Array of integer attributes */ 344 | MQLONG CharAttrLength, /* Length of character attributes buffer */ 345 | PMQCHAR pCharAttrs, /* Character attributes */ 346 | PMQLONG pCompCode, /* Completion code */ 347 | PMQLONG pReason); /* Reason code qualifying CompCode */ 348 | 349 | #ifndef HP_NSK 350 | 351 | void (PMQENTRY MQSUB) ( 352 | MQHCONN Hconn, /* I: Connection handle */ 353 | PMQVOID pSubDesc, /* IO: Subscription descriptor */ 354 | PMQHOBJ pHobj, /* IO: Object handle for queue */ 355 | PMQHOBJ pHsub, /* O: Subscription object handle */ 356 | PMQLONG pCompCode, /* OC: Completion code */ 357 | PMQLONG pReason); /* OR: Reason code qualifying CompCode */ 358 | 359 | void (PMQENTRY MQSUBRQ) ( 360 | MQHCONN Hconn, /* I: Connection handle */ 361 | MQHOBJ Hsub, /* I: Subscription handle */ 362 | MQLONG Action, /* I: Action requested on the subscription */ 363 | PMQVOID pSubRqOpts, /* IO: Subscription Request Options */ 364 | PMQLONG pCompCode, /* O: Completion code */ 365 | PMQLONG pReason); /* O: Reason code qualifying CompCode */ 366 | 367 | void (PMQENTRY MQCB) ( 368 | MQHCONN Hconn, /* I: Connection handle */ 369 | MQLONG Operation, /* I: Operation */ 370 | PMQVOID pCallbackDesc, /* I: Callback descriptor */ 371 | MQHOBJ Hobj, /* I: Object handle */ 372 | PMQVOID pMsgDesc, /* I: Message Descriptor */ 373 | PMQVOID pGetMsgOpts, /* I: Get options */ 374 | PMQLONG pCompCode, /* O: Completion code */ 375 | PMQLONG pReason); /* O: Reason code qualifying CompCode */ 376 | 377 | void (PMQENTRY MQCTL) ( 378 | MQHCONN Hconn, /* I: Connection handle */ 379 | MQLONG Operation, /* I: Operation */ 380 | PMQVOID pControlOpts, /* I: Control options */ 381 | PMQLONG pCompCode, /* O: Completion code */ 382 | PMQLONG pReason); /* O: Reason code qualifying CompCode */ 383 | 384 | 385 | 386 | void (PMQENTRY MQCRTMH) ( 387 | MQHCONN Hconn, /* I: Connection handle */ 388 | PMQVOID pCrtMsgHOpts, /* I: Options that control the action of MQCRTMH */ 389 | PMQHMSG pHmsg, /* IO: Message handle */ 390 | PMQLONG pCompCode, /* OC: Completion code */ 391 | PMQLONG pReason); /* OR: Reason code qualifying CompCode */ 392 | 393 | void (PMQENTRY MQDLTMH) ( 394 | MQHCONN Hconn, /* I: Connection handle */ 395 | PMQHMSG pHmsg, /* IO: Message handle */ 396 | PMQVOID pDltMsgHOpts, /* I: Options that control the action of MQDLTMH */ 397 | PMQLONG pCompCode, /* OC: Completion code */ 398 | PMQLONG pReason); /* OR: Reason code qualifying CompCode */ 399 | 400 | void (PMQENTRY MQINQMP) ( 401 | MQHCONN Hconn, /* I: Connection handle */ 402 | MQHMSG Hmsg, /* I: Message handle */ 403 | PMQVOID pInqPropOpts, /* IO: Options that control the action of MQINQMP */ 404 | PMQVOID pName, /* I: Property name */ 405 | PMQVOID pPropDesc, /* O: Property descriptor */ 406 | PMQLONG pType, /* IO: Property data type */ 407 | MQLONG ValueLength, /* IL: Length in bytes of the Value area */ 408 | PMQVOID pValue, /* OB: Property value */ 409 | PMQLONG pDataLength, /* O: Length of the property value */ 410 | PMQLONG pCompCode, /* OC: Completion code */ 411 | PMQLONG pReason); /* OR: Reason code qualifying CompCode */ 412 | 413 | void (PMQENTRY MQSETMP) ( 414 | MQHCONN Hconn, /* I: Connection handle */ 415 | MQHMSG Hmsg, /* I: Message handle */ 416 | PMQVOID pSetPropOpts, /* I: Options that control the action of MQSETMP */ 417 | PMQVOID pName, /* I: Property name */ 418 | PMQVOID pPropDesc, /* IO: Property descriptor */ 419 | MQLONG Type, /* I: Property data type */ 420 | MQLONG ValueLength, /* IL: Length of the Value area */ 421 | PMQVOID pValue, /* IB: Property value */ 422 | PMQLONG pCompCode, /* OC: Completion code */ 423 | PMQLONG pReason); /* OR: Reason code qualifying CompCode */ 424 | 425 | void (PMQENTRY MQDLTMP) ( 426 | MQHCONN Hconn, /* I: Connection handle */ 427 | MQHMSG Hmsg, /* I: Message handle */ 428 | PMQVOID pDltPropOpts, /* I: Options that control the action of MQDLTMP */ 429 | PMQVOID pName, /* I: Property name */ 430 | PMQLONG pCompCode, /* OC: Completion code */ 431 | PMQLONG pReason); /* OR: Reason code qualifying CompCode */ 432 | 433 | void (PMQENTRY MQBUFMH) ( 434 | MQHCONN Hconn, /* I: Connection handle */ 435 | MQHMSG Hmsg, /* I: Message handle */ 436 | PMQVOID pBufMsgHOpts, /* I: Options that control the action of MQBUFMH */ 437 | PMQVOID pMsgDesc, /* IO: Message descriptor */ 438 | MQLONG BufferLength, /* IL: Length in bytes of the Buffer area */ 439 | PMQVOID pBuffer, /* IOB: Area to contain the message buffer */ 440 | PMQLONG pDataLength, /* O: Length of the output buffer */ 441 | PMQLONG pCompCode, /* OC: Completion code */ 442 | PMQLONG pReason); /* OR: Reason code qualifying CompCode */ 443 | 444 | void (PMQENTRY MQMHBUF) ( 445 | MQHCONN Hconn, /* I: Connection handle */ 446 | MQHMSG Hmsg, /* I: Message handle */ 447 | PMQVOID pMsgHBufOpts, /* I: Options that control the action of MQMHBUF */ 448 | PMQVOID pName, /* I: Property name */ 449 | PMQVOID pMsgDesc, /* IO: Message descriptor */ 450 | MQLONG BufferLength, /* IL: Length in bytes of the Buffer area */ 451 | PMQVOID pBuffer, /* OB: Area to contain the properties */ 452 | PMQLONG pDataLength, /* O: Length of the properties */ 453 | PMQLONG pCompCode, /* OC: Completion code */ 454 | PMQLONG pReason); /* OR: Reason code qualifying CompCode */ 455 | 456 | void (PMQENTRY MQSTAT) ( 457 | MQHCONN Hconn, /* I: Connection handle */ 458 | MQLONG Type, /* I: Status information type */ 459 | PMQVOID pStatus, /* O: Status information */ 460 | PMQLONG pCompCode, /* O: Completion code */ 461 | PMQLONG pReason); /* O: Reason code qualifying CompCode */ 462 | 463 | #endif 464 | 465 | } MQAPI; 466 | /* Prototypes */ 467 | int MQAccess (char * Library,MQAPI * MQApi); 468 | -------------------------------------------------------------------------------- /src/qlcs.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1995, 2014 IBM Corporation and other Contributors. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Paul Clarke - Initial Contribution 11 | */ 12 | /**********************************************************************/ 13 | /* FILE : QLCS.H */ 14 | /* PURPOSE: Common Service routines */ 15 | /**********************************************************************/ 16 | #include 17 | #include 18 | #ifndef CS_H_INCLUDED 19 | #define CS_H_INCLUDED 20 | /* Constants */ 21 | #define CSENC_NORMAL 1 22 | #define CSENC_REVERSED 2 23 | 24 | #if defined (WIN32) || defined(WIN64) 25 | #define CSENC_LOCAL 2 26 | #define CSENC_NONLOCAL 1 27 | #endif 28 | #ifdef MVS 29 | #define CSENC_LOCAL 1 30 | #define CSENC_NONLOCAL 2 31 | #endif 32 | #ifdef AMQ_UNIX 33 | #ifdef _LINUX_2 34 | #define CSENC_LOCAL 2 35 | #define CSENC_NONLOCAL 1 36 | #else 37 | #define CSENC_LOCAL 1 38 | #define CSENC_NONLOCAL 2 39 | #endif 40 | #include 41 | typedef void * THREAD_START_ROUTINE(void *); 42 | typedef THREAD_START_ROUTINE * LPTHREAD_START_ROUTINE; 43 | #endif 44 | 45 | #ifdef AMQ_AS400 46 | #include 47 | typedef void * THREAD_START_ROUTINE(void *); 48 | typedef THREAD_START_ROUTINE * LPTHREAD_START_ROUTINE; 49 | #define CSENC_LOCAL 1 50 | #define CSENC_NONLOCAL 2 51 | #endif 52 | 53 | #if defined(MVS) || defined(AMQ_AS400) 54 | #define CS_EBCDIC 55 | #define CS_IS_EBCDIC 1 56 | #else 57 | #define CS_IS_EBCDIC 0 58 | #endif 59 | 60 | #ifdef DEBUG 61 | #define CHECKSTORAGE yes 62 | #endif 63 | 64 | #ifndef MVS 65 | #if defined (WIN32) || defined(WIN64) 66 | #ifndef WINDOWS 67 | #define WINDOWS 68 | #endif 69 | #define stricmp _stricmp 70 | #define memicmp _memicmp 71 | #include 72 | typedef HANDLE CSMUTEX; 73 | typedef HANDLE CSEVENT; 74 | typedef HMODULE CSLIBHANDLE; 75 | #define PATH_SEP '\\' 76 | 77 | #define CSMUTEX_NULL NULL 78 | #define CSEVENT_NULL NULL 79 | #define CSMUTEX_IS_NULL(s) (*s == NULL) 80 | #define CSEVENT_IS_NULL(s) (*s == NULL) 81 | 82 | #else 83 | #ifdef AMQ_AS400 84 | typedef unsigned long long CSLIBHANDLE; 85 | #else 86 | typedef void * CSLIBHANDLE; 87 | #endif 88 | #define PATH_SEP '/' 89 | #define stricmp strcmp 90 | #define INFINITE -1 91 | typedef struct 92 | { 93 | int defined; 94 | pthread_mutex_t mutex; 95 | } CSMUTEX; 96 | typedef struct 97 | { 98 | int defined; 99 | int posted; 100 | pthread_cond_t cond; 101 | pthread_mutex_t mutex; 102 | } CSEVENT; 103 | 104 | #define CSMUTEX_NULL {0} 105 | #define CSEVENT_NULL {0} 106 | #define CSMUTEX_IS_NULL(s) ((s)->defined == 0) 107 | #define CSEVENT_IS_NULL(s) ((s)->defined == 0) 108 | #endif 109 | #else 110 | #define stricmp strcmp 111 | #endif /* End of #ifndef MVS */ 112 | 113 | typedef struct _MYCOLOURS 114 | { 115 | int colour; 116 | #if defined (WIN32) || defined(WIN64) 117 | HBRUSH hBrush; 118 | #else 119 | int hBrush; 120 | #endif 121 | } MYCOLOURS; 122 | 123 | typedef int INT32; 124 | typedef unsigned int UINT32; 125 | typedef unsigned int BIT32; 126 | typedef unsigned short BIT16; 127 | typedef UINT32 * PUINT32; 128 | 129 | #if defined(AMQ_UNIX) || defined(MVS) || defined(AMQ_AS400) 130 | typedef int LONG; 131 | typedef unsigned short USHORT; 132 | typedef char CHAR; 133 | typedef unsigned int ULONG; 134 | typedef ULONG * PULONG; 135 | typedef int BOOL; 136 | typedef unsigned char BYTE; 137 | typedef unsigned int UINT; 138 | typedef int INT; 139 | typedef short SHORT; 140 | typedef unsigned char UCHAR; 141 | 142 | 143 | #ifndef pascal 144 | #define pascal 145 | #endif 146 | 147 | #ifndef TRUE 148 | #define TRUE 1 149 | #endif 150 | 151 | #ifndef FALSE 152 | #define FALSE 0 153 | #endif 154 | 155 | typedef struct tagSIZE 156 | { 157 | LONG cx; 158 | LONG cy; 159 | } SIZE, *PSIZE, *LPSIZE; 160 | #endif 161 | 162 | #ifdef _HPUX_SOURCE 163 | char * CSltoa ( int v, char * s,int r); 164 | char * CSultoa(unsigned int v, char * s,int r); 165 | 166 | #define LTOA CSltoa 167 | #define ULTOA CSultoa 168 | #else 169 | #define LTOA _ltoa 170 | #define ULTOA _ultoa 171 | #endif 172 | 173 | #ifndef min 174 | #define min(a,b) (ab ? a:b) 179 | #endif 180 | 181 | #ifdef _SOLARIS_2 182 | #define CHK_EYE(a,b) (memcmp(a,b,4)==0) 183 | #define SET_EYE(a,b) memcpy(a,b,4) 184 | #else 185 | #define CHK_EYE(a,b) (*(int *)a == *(int *)b) 186 | #define SET_EYE(a,b) *(int *)a = *(int *)b 187 | #endif 188 | 189 | #ifndef MQSTRUCT_INCLUDED 190 | #include 191 | #endif 192 | /* Error return codes */ 193 | #define CSRC_FAILED -1 194 | #define CSRC_TIMEOUT 2 195 | #define CSRC_NOT_FOUND 3 196 | /* CS Options */ 197 | #define CSO_MEMORY 0x00000001 198 | #define CSO_MESSAGES 0x00000002 199 | #define CSO_FRONT 0x00000004 200 | #define CSO_NOHEADER 0x00000008 201 | #define CSO_FORMATTED 0x00000010 202 | #define CSO_EBCDIC 0x00000020 203 | #define CSO_NOALLOC 0x00000040 204 | #define CSO_NOT_UNIQUE 0x00000080 205 | /* CS Output format */ 206 | #define CSF_HEADER 0x00000001 207 | #define CSF_DUMP 0x00000002 208 | #define CSF_TEXT 0x00000004 209 | 210 | /* Storage Types */ 211 | #define ST_HEAP 0x00000001 212 | #define ST_MAIN 0x00000002 213 | /* First byte is detail level */ 214 | #define MF_DETAIL 0x000000FF 215 | #define MF_HEX 0x00000100 216 | #define MF_FORMAT 0x00000200 217 | #define MF_MQMD 0x00000400 218 | #define MF_NOMSG 0x00000800 219 | #define MF_DETAILED 0x00001000 220 | #define MF_NOFORMAT 0x00002000 221 | #define MF_HEXBITS 0x00004000 222 | #define MF_OFFSET 0x00008000 223 | #define MF_HEXSEP 0x00010000 /* Hex space separators */ 224 | #define MF_HEXCH 0x00020000 /* Output HEX also as Char */ 225 | #define MF_HEXCH_PREDICT 0x00040000 /* Predict whether ASCII/EBCDIC*/ 226 | #define MF_AUTO_DETECT_XML 0x00080000 227 | #define MF_XML_SHORTFORM 0x00100000 228 | #define MF_TRUNCATED 0x00200000 229 | #define MF_LOCAL_TIMES 0x00400000 230 | #define MF_NO_ASCII_COLUMN 0x00800000 231 | 232 | #define MF_SHOWCONST 0x02000000 /* Show const name plus descr */ 233 | #define MF_FIELDOFFSET 0x04000000 /* Show field offset in string */ 234 | #define MF_ENCLOCAL 0x08000000 /* Reset to local encoding */ 235 | #define MF_ENCBYTESWAP 0x10000000 /* Reset to nonlocal encoding */ 236 | #define MF_ENCASCII 0x20000000 /* Data is in ascii */ 237 | #define MF_ENCEBCDIC 0x40000000 /* Data is in ebcdic */ 238 | #define MF_NOFOLLOWPTR 0x80000000 /* Dont Follow ptrs */ 239 | 240 | #define MF2_NO_BYTESWAP_VERSION 0x00000001 241 | #define MF2_IGNORE_CRLF 0x00000002 242 | #define MF2_ZERO_LENGTH_STRINGS 0x00000004 243 | /* Return codes */ 244 | #define MFRC_FORMATTING_ON 10 245 | #define MFRC_FORMATTING_OFF 11 246 | #define MFRC_STOP 12 247 | 248 | 249 | #if defined (WIN32) || defined(WIN64) 250 | #define CSTrap(v) CSTrapfn(__FILE__, __TIMESTAMP__, __LINE__, (int)(v)) 251 | #else 252 | #define CSTrap(v) CSTrapfn(__FILE__, "DD/MM/YYYY" , __LINE__, (int)(v)) 253 | #endif 254 | 255 | #ifdef _DEBUG 256 | #define CSDebugTrap(v) CSTrap(v) 257 | #else 258 | #define CSDebugTrap(v) 259 | #endif 260 | 261 | #define FORMATTING (!(pOptions->Options & MF_NOFORMAT)) 262 | 263 | #define CALLOUTFN(p,b,l) \ 264 | rc=outfn(p,pOptions,b,l); \ 265 | if (rc) \ 266 | { \ 267 | if (rc == MFRC_FORMATTING_ON) \ 268 | {pOptions->Options &= ~MF_NOFORMAT; pOptions->OutFormat |= CSO_FORMATTED;} \ 269 | if (rc == MFRC_FORMATTING_OFF) \ 270 | {pOptions->Options |= MF_NOFORMAT; pOptions->OutFormat &=~CSO_FORMATTED;} \ 271 | if (rc == MFRC_STOP) goto MOD_EXIT; \ 272 | } 273 | 274 | #define CALLOUTFNX(p,b,l) \ 275 | rc=outfn(p,pOptions,b,l); \ 276 | if (rc) \ 277 | { \ 278 | if (rc == MFRC_FORMATTING_ON) \ 279 | {pOptions->Options &= ~MF_NOFORMAT; pOptions->OutFormat |= CSO_FORMATTED;} \ 280 | if (rc == MFRC_FORMATTING_OFF) \ 281 | {pOptions->Options |= MF_NOFORMAT; pOptions->OutFormat &=~CSO_FORMATTED;} \ 282 | } 283 | 284 | #define CSOFFSETOF(s,c) (int)(ptrdiff_t)&(((s *)0)->c) 285 | 286 | #define CSTRACEIN(f) if (CSTracing) CSTraceIn(f); 287 | #define CSTRACEOUT(f,r) if (CSTracing) CSTraceOut(f,r); 288 | #define CSTRACEMSGIN(a,b,c,d,e) if (CSTracing) CSTraceMsgIn(a,(int)b,c,d,e); 289 | #define CSTRACEMSGOUT(a,b,c,d) if (CSTracing) CSTraceMsgOut(a,(int)b,c,d); 290 | #define CSPRINTF(a) if (CSTracing) CSPrintf a; 291 | 292 | #define CSWITHIN(_v,_s,_l) (((_v) >= (_s)) && ((_v) <= (_l))) 293 | 294 | #define CSINVARIANT(_a) ((_a) && (CSWITHIN((_a),'a','z') || \ 295 | CSWITHIN((_a),'A','Z') || \ 296 | CSWITHIN((_a),'0','9') || \ 297 | strchr(" '()+,-./:=?_", (_a)) )) 298 | 299 | /* Typedefs */ 300 | #define STORAGE_EYECATCHERF "STGF" 301 | #define STORAGE_EYECATCHER "STG." 302 | 303 | typedef struct _CSSTORAGE 304 | { 305 | char ID[4]; 306 | struct _CSSTORAGE * Next; 307 | struct _CSSTORAGE * Prev; 308 | int Size; 309 | int Type; 310 | #ifdef WINDOWS 311 | HGLOBAL hArea; 312 | #endif 313 | char Name[20]; 314 | } CSSTORAGE; 315 | 316 | typedef struct _CSSUBBLOCK 317 | { 318 | short Size; 319 | struct _CSSUBBLOCK * Next; 320 | } CSSUBBLOCK; 321 | 322 | typedef struct _CSBLOCK 323 | { 324 | struct _CSBLOCK * Next; 325 | CSSUBBLOCK * pSub; 326 | int Size; 327 | int Used; 328 | short LargestSub; 329 | } CSBLOCK; 330 | 331 | typedef struct _CSPARTS 332 | { 333 | int Value; 334 | char * Name; 335 | char * sName; 336 | char * plural; 337 | } CSPARTS; 338 | /* Structure for data indirection */ 339 | typedef struct _CSDATA 340 | { 341 | int Size; 342 | int Length; 343 | char * Data; 344 | } CSDATA; 345 | 346 | typedef struct 347 | { 348 | char * Base; 349 | int Size; 350 | char * Name; 351 | } CSHEADROOM; 352 | 353 | /**********************************************************************/ 354 | /* The following structure must match the start of CSLIST */ 355 | /**********************************************************************/ 356 | typedef struct _CSNEXTPREV 357 | { 358 | struct _CSNEXTPREV * Next; 359 | struct _CSNEXTPREV * Prev; 360 | } CSNEXTPREV; 361 | 362 | typedef struct _CSLISTROOT 363 | { 364 | CSNEXTPREV * Top; 365 | CSNEXTPREV * Bottom; 366 | int Count; 367 | } CSLISTROOT; 368 | 369 | typedef struct _CSLIST 370 | { 371 | struct _CSLIST * Next; 372 | struct _CSLIST * Prev; 373 | short Length; /* Not including header */ 374 | short Options; /* Callers use....not CS */ 375 | /*CSLISTROOT Links; */ 376 | CSLISTROOT * Root; 377 | } CSLIST; 378 | 379 | typedef struct _CSLINK 380 | { 381 | struct _CSLINK * Next; 382 | struct _CSLINK * Prev; 383 | struct _CSLINK * Other; 384 | void * Source; 385 | void * Target; 386 | short Dir; /* 0 - source, 1 - target */ 387 | short Type; 388 | int Data; 389 | } CSLINK; 390 | 391 | 392 | typedef struct _CSTREE 393 | { 394 | struct _CSTREE * Sub[2]; /* Left and Right subtrees */ 395 | struct _CSTREE * Coll[2]; /* Collating list */ 396 | CSLINK * Links; 397 | short Type; /* Free for caller of tree */ 398 | unsigned short Height; 399 | int TreeIndex; /* Collating index */ 400 | #ifdef CSDEFINE_GLOBALS 401 | char Key[1]; 402 | #endif 403 | } CSTREE; 404 | 405 | #define CSTreeNext(a) (((CSTREE *)a)->Coll[1]) 406 | #define CSTreePrev(a) (((CSTREE *)a)->Coll[0]) 407 | 408 | typedef struct _CSITC 409 | { 410 | CSLIST List; 411 | #ifdef WINDOWS 412 | HANDLE EventSem; 413 | #endif 414 | } CSITC; 415 | 416 | typedef struct _CSITCBLOCK 417 | { 418 | CSLIST Header; 419 | void * p; 420 | int ParmLength; 421 | } CSITCBLOCK; 422 | 423 | /*********************************************************************/ 424 | /* Callback options */ 425 | /*********************************************************************/ 426 | typedef struct _CBOPT 427 | { 428 | int Options; /* MF_* */ 429 | int Options2; /* MF2_* */ 430 | int Checked; 431 | int ScreenWidth; /* Width of screen in chars */ 432 | int AsciiColumn; /* 0 = No */ 433 | int DataWidth; /* How many bytes of data/line */ 434 | int DataGap; /* Spaces gap before any ASCII */ 435 | CSDATA * pData; /* Callback data */ 436 | int OutFormat; /* Format of output data */ 437 | int FieldMsgOffset; /* Offset in message till start of field */ 438 | int FieldLineMsgOffset; /* Offset in message till start of field */ 439 | int LineMsgOffset; /* Offset in message till start of data */ 440 | int LineMsgLength; /* Msg length represented by line */ 441 | short LineDataOffset; /* Offset of data in line */ 442 | int LineDataLength; /* Data Length on this line */ 443 | int LineDataMaxLength; /* Max Data Length on this line */ 444 | MQFIELD * pField; 445 | int FieldType; /* To overrise MQFIELD */ 446 | } CBOPT; 447 | /* Prototypes */ 448 | #ifndef MVS 449 | int CSAccessLibrary(char * Library, 450 | char * pPath, 451 | char * ErrorMsg, 452 | int ErrorMsgLen, 453 | CSLIBHANDLE * pLibHandle); 454 | 455 | void * CSAccessProc(CSLIBHANDLE lib,char * fn); 456 | #endif 457 | 458 | #ifdef CHECKSTORAGE 459 | void CSCheckStorage (void); 460 | #else 461 | #define CSCheckStorage() 462 | #endif 463 | int CSGetRelTime (void); 464 | void CSSleep (int d); 465 | void CSMSSleep (int d); 466 | void CSTrapfn (char * file, 467 | char * timestamp, 468 | int line, 469 | int value); 470 | void CSffdc (void); 471 | void * CSGetMem (int size, 472 | char * Name); 473 | void CSFreeMem (void * p); 474 | void CSInitialise (char * filename); 475 | void CSTerminate (void); 476 | 477 | int CSIssueCommand (char * Command, 478 | char ** pErrorText); 479 | 480 | CSBLOCK * CSGetBlock (int BlockSize); 481 | void CSFreeBlock (CSBLOCK * pcsb); 482 | void * CSGetSubBlock (CSBLOCK * pcsb, 483 | int Size); 484 | /* Tree functions */ 485 | void * CSTreeAdd (void * ppRoot, 486 | int Options, 487 | void * Elem, 488 | int Size, 489 | int KeySize); 490 | 491 | int CSTreeDelete (void * ppRoot, 492 | int (* fn)(void *,void *), 493 | void * Parm); 494 | 495 | int CSTreeDeleteItem(void * ppRoot, 496 | int (* fn)(void *,void *), 497 | void * Parm, 498 | void * Elem, 499 | int KeySize); 500 | 501 | void * CSTreeFind (void * pRoot, 502 | void * Key, 503 | int KeySize); 504 | 505 | int CSTreeCount (void * pRoot); 506 | 507 | void * CSTreeGetIndex (void * pRoot, 508 | int Index); 509 | 510 | void CSTreeTraverse (void * pRoot, 511 | int (* fn)(void *,void *), 512 | void * Parm); 513 | 514 | void CSTreeTraverseB (void * pRoot, 515 | int (* fn)(void *,void *), 516 | void * Parm); 517 | 518 | void * CSTreeFirst (void * pRoot); 519 | 520 | void * CSTreeLast (void * pRoot); 521 | 522 | /* List functions */ 523 | void * CSListAdd (CSLISTROOT * pRoot, 524 | int Options, 525 | void * Elem, 526 | int Size); 527 | 528 | void * CSListAddSort (CSLISTROOT * pRoot, 529 | int Options, 530 | void * Elem, 531 | int Size, 532 | int KeySize); 533 | 534 | void CSListDelete (CSLISTROOT * pRoot, 535 | int (* fn)(void *,void *), 536 | void * Parm); 537 | 538 | void CSListDeleteItem(void * Elem); 539 | 540 | int CSListCount (CSLISTROOT * pRoot ); 541 | 542 | void * CSListFind (CSLISTROOT * pRoot, 543 | void * Elem); 544 | 545 | void * CSListFindEntry(CSLISTROOT * pRoot, 546 | int Options, 547 | void * Elem, 548 | int Size); 549 | 550 | void CSListTraverse (CSLISTROOT * pRoot, 551 | int (* fn)(void *,void *), 552 | void * Parm); 553 | 554 | /* Link functions */ 555 | CSLINK * CSLinkAdd (void * Source, 556 | void * Target, 557 | short Type, 558 | int Data); 559 | 560 | CSLINK * CSLinkFind (void * Source, 561 | void * Target, 562 | short Type, 563 | BOOL Either); 564 | 565 | void CSLinkRmvAll (void * Source, 566 | short Type); 567 | 568 | void CSLinkRmv (CSLINK * pLink); 569 | 570 | CSLINK * CSLinkNext (void * Object, 571 | short Type, 572 | CSLINK * pLink); 573 | 574 | void * CSListLink (CSLISTROOT * pRoot, 575 | int Options, 576 | CSLIST * pElem); 577 | 578 | void * CSListUnlink (CSLISTROOT * pRoot, 579 | int Options); 580 | 581 | void CSByteSwapShort (unsigned char * pShort, 582 | int array); 583 | 584 | void CSByteSwapLong (unsigned char * pLong, 585 | int array); 586 | 587 | int CSToAscii (unsigned char * pOut, 588 | unsigned char * pIn, 589 | int Length); 590 | 591 | int CSToEbcdic (unsigned char * pOut, 592 | unsigned char * pIn, 593 | int Length); 594 | 595 | void CSConvTest (); 596 | void CSConvGenerate (); 597 | 598 | int CSIsEbcdic (int CCSID); 599 | 600 | int CSItcCreate (CSITC * itc); 601 | int CSItcDestroy (CSITC * itc); 602 | int CSItcPost (CSITC * itc, 603 | void * parms, 604 | int length, 605 | void * p); 606 | int CSItcWait (CSITC * itc, 607 | void * parms, 608 | int length, 609 | void ** p, 610 | int timeout); 611 | 612 | int CSDumpHex (int (outfn)(void *,CBOPT *,char *,int ), 613 | void * Parm, 614 | unsigned char * pMsg, 615 | int Len, 616 | CBOPT * pOptions); 617 | 618 | void CSCheckOpts (CBOPT * pOptions); 619 | 620 | void CSTraceIn (char * func); 621 | 622 | void CSTraceOut (char * func, 623 | int rc); 624 | void CSTraceGroup (); 625 | void CSTraceGroupEnd(); 626 | void CSTraceMsgIn (char * proc, int hwnd, int msg, int mp1,int mp2); 627 | void CSTraceMsgOut (char * proc, int hwnd, int msg, int res); 628 | int CSTraceStart (char * tracefile); 629 | 630 | int CSTraceStop (); 631 | 632 | void CSPrintf (int nl, 633 | char * format, 634 | ...); 635 | 636 | char * CSStringAdd (char * p, 637 | int len); 638 | 639 | void CSStringDelete (char * p); 640 | 641 | int CSStringReplace(char ** pString, 642 | char * p, 643 | int len); 644 | 645 | int CSStringReplaceMax(char ** pString, 646 | char * p, 647 | int len, 648 | BOOL NoEmpty); 649 | 650 | char * CSLoadFile (FILE * file, 651 | int * byteread); 652 | 653 | void CSAdjustTime (char * pDate, 654 | char * pTime, 655 | int Adjust); 656 | 657 | void CSConvertParts (int Amount, 658 | char * Buffer, 659 | CSPARTS * pParts, 660 | BOOL Parts); 661 | 662 | int CSParseParts (char * Buffer, 663 | CSPARTS * pParts, 664 | int check); 665 | 666 | void CSAtomicUpdate (char * pNew, 667 | char ** pTarget, 668 | char ** pOld); 669 | BOOL CSHeadRoom (CSHEADROOM * Head, 670 | void ** ppCur, 671 | int Room); 672 | 673 | #ifndef MVS 674 | BOOL CSCreateThread(LPTHREAD_START_ROUTINE fn, 675 | void * parm, 676 | int * pTid); 677 | BOOL CSCreateMutex (CSMUTEX * mutex); 678 | void CSDestroyMutex(CSMUTEX * mutex); 679 | BOOL CSRequestMutex(CSMUTEX * mutex,int Timeout); 680 | void CSReleaseMutex(CSMUTEX * mutex); 681 | BOOL CSCreateEvent (CSEVENT * event); 682 | void CSDestroyEvent(CSEVENT * event); 683 | void CSSetEvent (CSEVENT * event); 684 | void CSWaitEvent (CSEVENT * event, int Timeout); 685 | #endif 686 | 687 | #if defined (WIN32) || defined(WIN64) 688 | 689 | typedef struct 690 | { 691 | HANDLE LockMutex; 692 | int LockMutexOwner; 693 | int LockMutexCount; 694 | } CSLOCK; 695 | 696 | void CSLock (int Index); 697 | void CSUnlock (int Index); 698 | void CSLockIt (CSLOCK * pLock); 699 | void CSUnlockIt (CSLOCK * pLock); 700 | #else 701 | #define CSLock(a) 702 | #define CSUnlock(a); 703 | int GetLastError(); 704 | #endif 705 | 706 | #ifdef CSDEFINE_GLOBALS 707 | int CSOptions = 0L; 708 | int CSMemAlloc = 0; 709 | int CSMemHigh = 0; 710 | int CSMemBlocks= 0; 711 | int CSMemCount = 0; 712 | int CSTracing = 0; 713 | char CSFileRoot[150]=""; 714 | #else 715 | extern int CSOptions; 716 | extern int CSMemAlloc; 717 | extern int CSMemHigh; 718 | extern int CSMemBlocks; 719 | extern int CSMemCount; 720 | extern int CSTracing; 721 | extern char CSFileRoot[]; 722 | #endif 723 | #endif 724 | -------------------------------------------------------------------------------- /src/qlgetopt.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1995, 2014 IBM Corporation and other Contributors. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Paul Clarke - Initial Contribution 11 | */ 12 | /**********************************************************************/ 13 | /* FILE : QLGETOPT.C */ 14 | /* PURPOSE: Windows version of UNIX getopt code */ 15 | /**********************************************************************/ 16 | /* Includes */ 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define GETOPT_DEFINES 23 | #include "qlgetopt.h" 24 | /* Defines */ 25 | #define EMPTY_MSG "" 26 | #define BADCH ('?') 27 | #define COLON (':') 28 | 29 | static char *place = EMPTY_MSG; /* option letter processing */ 30 | /**********************************************************************/ 31 | /* Function: getopt */ 32 | /* Purpose : Simulate the UNIX getopt function */ 33 | /* Each time this function is called it returns the next */ 34 | /* option letter and sets a static pointer pointing to */ 35 | /* any option argument. */ 36 | /**********************************************************************/ 37 | int getopt(int argc, char **argv, char *ostr) 38 | { 39 | char *oli = NULL; /* option letter list index */ 40 | unsigned int i; /* loop index */ 41 | int found = 0; /* found flag */ 42 | 43 | if (!place || !*place) 44 | { /* update scanning pointer */ 45 | place = argv[optind]; 46 | /****************************************************************/ 47 | /* Check for end of input */ 48 | /****************************************************************/ 49 | 50 | if ((optind >= argc) || 51 | ((*place != '-') && (*place != '/')) || 52 | (!*++place)) 53 | { 54 | return EOF; 55 | } 56 | } 57 | 58 | /******************************************************************/ 59 | /* option letter okay? */ 60 | /******************************************************************/ 61 | 62 | optopt = (int)*place++; /* Current option */ 63 | 64 | for (i=0; (i < strlen(ostr)) && !found; i++) 65 | { /* check in option string for option */ 66 | if (optopt == ostr[i]) 67 | { 68 | found = 1; /* option is present */ 69 | oli = &ostr[i]; /* set oli to point to it */ 70 | } 71 | } /* End check in option string for option */ 72 | 73 | if (optopt == (int)COLON || !oli) 74 | 75 | { /* Current option not valid */ 76 | if (!*place) 77 | { 78 | ++optind; 79 | } 80 | return BADCH; 81 | } /* End current option not valid */ 82 | 83 | /******************************************************************/ 84 | /* Check if this option requires an argument */ 85 | /******************************************************************/ 86 | 87 | if (*++oli != COLON) 88 | { /* this option doesn't require*/ 89 | /* an arg */ 90 | optarg = NULL; 91 | if (!*place) 92 | { 93 | ++optind; 94 | } 95 | } 96 | else 97 | { /* this option needs an arg */ 98 | if (*place) 99 | { 100 | optarg = place; /* parm follows arg directly */ 101 | if (*optarg == COLON) 102 | optarg++; /* Remove colon if present */ 103 | } 104 | else 105 | { 106 | if (argc <= ++optind) 107 | { /* No argument found */ 108 | place = EMPTY_MSG; 109 | return BADCH; 110 | } 111 | else 112 | { 113 | optarg = argv[optind]; /* white space */ 114 | if (*optarg == COLON) 115 | optarg++; /* Remove colon if present */ 116 | } 117 | } 118 | 119 | place = EMPTY_MSG; 120 | ++optind; 121 | } 122 | 123 | return optopt; /* return option letter */ 124 | } 125 | 126 | -------------------------------------------------------------------------------- /src/qlgetopt.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1995, 2014 IBM Corporation and other Contributors. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Paul Clarke - Initial Contribution 11 | */ 12 | /**********************************************************************/ 13 | /* FILE : QLGETOPT.H */ 14 | /* PURPOSE: Windows version of UNIX getopt code */ 15 | /**********************************************************************/ 16 | #ifdef GETOPT_DEFINES 17 | int optind=1; /* index into parent argv vector */ 18 | int optopt; /* character checked for validity */ 19 | char *optarg; /* argument associated with option */ 20 | 21 | int getopt(int argc, char **argv, char *ostr); 22 | 23 | 24 | #else 25 | extern int optind; /* index into parent argv vector */ 26 | extern int optopt; /* character checked for validity */ 27 | extern char *optarg; /* argument associated with option */ 28 | 29 | extern int getopt(int argc, char **argv, char *ostr); 30 | #endif 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/qlmsg.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1995, 2014 IBM Corporation and other Contributors. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Paul Clarke - Initial Contribution 11 | */ 12 | /**********************************************************************/ 13 | /* FILE : QLMSG.C */ 14 | /* PURPOSE: Various functions operating on MQI objects */ 15 | /**********************************************************************/ 16 | #ifdef MVS 17 | #pragma csect(code,"MSGCODE") 18 | #pragma csect(static,"MSGSTAT") 19 | #pragma options(RENT) 20 | #endif 21 | /* Include files */ 22 | #include "string.h" 23 | #include "stdlib.h" 24 | #include "stdio.h" 25 | #include "time.h" 26 | #include "cmqc.h" 27 | #ifdef MVS 28 | #define NOLOAD /* Can't use MQAccess on MVS */ 29 | #endif 30 | #include "qlaccess.h" 31 | #include "qlvalues.h" 32 | #include "q.h" 33 | 34 | /**********************************************************************/ 35 | /* Function: QueryQMName */ 36 | /* Purpose : Get the name of the Queue Manager */ 37 | /**********************************************************************/ 38 | MQLONG QueryQMName(MQ * pMQ, 39 | MQCHAR48 QM) 40 | { 41 | MQOD ObjDesc = { MQOD_DEFAULT }; 42 | MQLONG flQueueFlags = MQOO_INQUIRE; 43 | MQHOBJ QmHobj = MQHO_UNUSABLE_HOBJ; 44 | MQLONG CompCode, Reason; 45 | MQLONG Selectors[1]; 46 | /* Open QM Object */ 47 | ObjDesc.Version = MQOD_VERSION_1; 48 | ObjDesc.ObjectType = MQOT_Q_MGR; 49 | 50 | IMQOPEN( pMQ->Api, 51 | pMQ->hQm, 52 | &ObjDesc, 53 | flQueueFlags, 54 | &QmHobj, 55 | &CompCode, 56 | &Reason ); 57 | if (CompCode == MQCC_FAILED) 58 | { 59 | MQError("MQOPEN",ObjDesc.ObjectName,Reason); 60 | goto MOD_EXIT; 61 | } 62 | if (verbose >= VL_MQAPI) MQError("MQOPEN",ObjDesc.ObjectName,Reason); 63 | if (verbose >= VL_MQDETAILS) fprintf(stderr,"MQHOBJ = %d\n",QmHobj); 64 | /* Now issue query */ 65 | Selectors[0] = MQCA_Q_MGR_NAME; 66 | 67 | IMQINQ(pMQ->Api, 68 | pMQ->hQm, /* Connection handle */ 69 | QmHobj, /* Object handle */ 70 | 1, /* Count of selectors */ 71 | Selectors, /* Array of attribute selectors */ 72 | 0, /* Count of integer attributes */ 73 | NULL, /* Array of integer attributes */ 74 | MQ_Q_MGR_NAME_LENGTH, /* Length of character-attributes */ 75 | /* buffer */ 76 | QM, /* Character attributes */ 77 | &CompCode, 78 | &Reason); 79 | if (CompCode == MQCC_FAILED) 80 | { 81 | MQError("MQINQ",ObjDesc.ObjectName,Reason); 82 | goto MOD_EXIT; 83 | } 84 | 85 | if (verbose >= VL_MQAPI) MQError("MQINQ",ObjDesc.ObjectName,Reason); 86 | 87 | MOD_EXIT: 88 | 89 | if (QmHobj != MQHO_UNUSABLE_HOBJ) 90 | { 91 | /* Close Queue Manager Desc. */ 92 | IMQCLOSE(pMQ->Api, 93 | pMQ->hQm, 94 | &QmHobj, 95 | MQCO_NONE, 96 | &CompCode, 97 | &Reason); 98 | 99 | if (verbose >= VL_MQAPI) MQError("MQCLOSE",ObjDesc.ObjectName,Reason); 100 | } 101 | return Reason; 102 | } 103 | /**********************************************************************/ 104 | /* End of function QueryQMName */ 105 | /**********************************************************************/ 106 | 107 | /**********************************************************************/ 108 | /* Function: OpenQueue */ 109 | /* Purpose : Open a MQ Queue */ 110 | /**********************************************************************/ 111 | MQLONG OpenQueue (MQ * pMQ, 112 | char * Q, 113 | MQLONG OpenFlags, 114 | MQLONG Version, 115 | MQHOBJ * hObj) 116 | { 117 | MQLONG CompCode,Reason; 118 | MQOD ObjDesc = { MQOD_DEFAULT }; 119 | char * p; 120 | 121 | ObjDesc.Version = Version; 122 | /********************************************************************/ 123 | /* Parse the input Queue name */ 124 | /********************************************************************/ 125 | /* Is there a QM name ? */ 126 | p = strchr(Q,'/'); 127 | if (!p) p = strchr(Q,'#'); 128 | if (!p) p = strchr(Q,'\\'); 129 | if (!p) p = strchr(Q,','); 130 | 131 | if (p) 132 | { 133 | memcpy(ObjDesc.ObjectQMgrName,Q, p-Q); 134 | Q = p+1; 135 | } 136 | /* Copy Queue Name */ 137 | strncpy(ObjDesc.ObjectName,Q,(int)MQ_Q_NAME_LENGTH); 138 | 139 | IMQOPEN( pMQ->Api, 140 | pMQ->hQm, 141 | &ObjDesc, 142 | OpenFlags, 143 | hObj, 144 | &CompCode, 145 | &Reason ); 146 | 147 | if (verbose >= VL_MQAPI || CompCode == MQCC_FAILED) 148 | MQError("MQOPEN",Q,Reason); 149 | 150 | return Reason; 151 | } 152 | -------------------------------------------------------------------------------- /src/qload.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 1995, 2014 IBM Corporation and other Contributors. 3 | * 4 | * All rights reserved. This program and the accompanying materials 5 | * are made available under the terms of the Eclipse Public License v1.0 6 | * which accompanies this distribution, and is available at 7 | * http://www.eclipse.org/legal/epl-v10.html 8 | * 9 | * Contributors: 10 | * Paul Clarke - Initial Contribution 11 | */ 12 | /**********************************************************************/ 13 | /* FILE : QLOAD.C */ 14 | /* PURPOSE: MQSeries Queue Unload/Reload Utility */ 15 | /**********************************************************************/ 16 | 17 | #ifdef MVS 18 | #pragma csect(code,"CMQUDLOD") 19 | #pragma csect(static,"CSTUDLOD") 20 | #pragma options(RENT) 21 | #pragma runopts(POSIX(ON)) 22 | #define _XOPEN_SOURCE /* Required for optarg, optind */ 23 | #define _XOPEN_SOURCE_EXTENDED 1 /* Required for timeb */ 24 | #define _SHARE_EXT_VARS /* because of APAR PQ03847 */ 25 | #endif 26 | /* Defines */ 27 | #define MIN(a,b) (a\n"); 107 | fprintf(stdout," [-a \n"); 108 | fprintf(stdout," a Append\n"); 109 | fprintf(stdout," b Binary\n"); 110 | fprintf(stdout," [-b ]\n"); 111 | #ifndef MVS 112 | fprintf(stdout," [-c Connect in client mode]\n"); 113 | #endif 114 | fprintf(stdout," [-C [A][I][a][i][d][n] Context]\n"); 115 | fprintf(stdout," A Set all context (default)\n"); 116 | fprintf(stdout," I Set identity context\n"); 117 | fprintf(stdout," a Pass all context\n"); 118 | fprintf(stdout," i Pass identity context\n"); 119 | fprintf(stdout," d Default context\n"); 120 | fprintf(stdout," n No context\n"); 121 | fprintf(stdout," [-d ]\n"); 122 | fprintf(stdout," a Add ASCII columns to HEX file\n"); 123 | fprintf(stdout," A Write output file in ASCII lines rather than HEX\n"); 124 | fprintf(stdout," c Output ApplData MQMD fields as char\n"); 125 | fprintf(stdout," C Display Correlation Id in summary\n"); 126 | fprintf(stdout," H Don't write file header\n"); 127 | fprintf(stdout," i Write message index\n"); 128 | fprintf(stdout," p Write output file in printable characters format\n"); 129 | fprintf(stdout," s Display queue summary\n"); 130 | fprintf(stdout," M Display Message Ids in summary\n"); 131 | fprintf(stdout," N Don't write MQMD to file\n"); 132 | fprintf(stdout," t Write output file in text lines\n"); 133 | fprintf(stdout," T Display time on queue\n"); 134 | #ifdef DEBUG 135 | fprintf(stdout," xtest Run file format test\n"); 136 | #endif 137 | fprintf(stdout," w Data width\n"); 138 | fprintf(stdout," [-D ]\n"); 139 | fprintf(stdout," +ve fixed delay in milliseconds\n"); 140 | fprintf(stdout," -ve random delay in milliseconds\n"); 141 | fprintf(stdout," r[time%%] relative delay\n"); 142 | fprintf(stdout," [-f or -f ]\n"); 143 | fprintf(stdout," [-F (forcing overwrite)]\n"); 144 | fprintf(stdout," [-g [x][c][m][g] Get by Id\n"); 145 | fprintf(stdout," x Id is in Hex\n"); 146 | fprintf(stdout," m Id is Message Id\n"); 147 | fprintf(stdout," c Id is Correlation Id\n"); 148 | fprintf(stdout," g Id is Group Id\n"); 149 | fprintf(stdout," [-h Strip headers\n"); 150 | fprintf(stdout," [-i (Browse)]\n"); 151 | fprintf(stdout," [-I (Get)]\n"); 152 | #ifndef NOLOAD 153 | fprintf(stdout," [-l e.g.mqm or mqic32]\n"); 154 | #endif 155 | fprintf(stdout," [-m ]\n"); 156 | fprintf(stdout," [-o ]\n"); 157 | fprintf(stdout," [-p Purge source queue]\n"); 158 | fprintf(stdout," [-P [:X'Encoding'] CodePage conversion]\n"); 159 | fprintf(stdout," [-q Quiet]\n"); 160 | fprintf(stdout," [-r ]\n"); 161 | fprintf(stdout," x Message x only\n"); 162 | fprintf(stdout," x..y Message x to message y\n"); 163 | fprintf(stdout," x#y y messages starting at message x\n"); 164 | fprintf(stdout," #x First x messages\n"); 165 | fprintf(stdout," [-t ]\n"); 166 | fprintf(stdout," [-T