This sample code prompts the user to enter a parameter number and a value at the prompt. This value is then put into a buffer for use by the function.
#define INCL_SPL #define INCL_SPLDOSPRINT #define INCL_SPLERRORS #include <os2.h> #include <stdio.h> /* for printf function */ #include <stdlib.h> /* for atoi function */ #include <string.h> /* for strlen function */ INT main (argc, argv) INT argc; CHAR *argv[]; { CHAR bufValue[2] = {0}; CHAR bufInput[128]= {0}; ULONG splerr ; ULONG cbBuf ; ULONG ulParmNum ; USHORT usParm ; PSZ pszComputerName ; PSZ pszQueueName ; PVOID pBuf; if (argc != 2) { printf("Syntax: setqryq QueueName \n"); DosExit( EXIT_PROCESS , 0 ) ; } /* This function will be for the local workstation. pszComputerName = (PSZ)NULL ; /* Get the parameter from the command line. */ pszQueueName = argv[1]; /* Prompt the user for the parameter and values, and put them in buffers. */ printf("Enter Parameter number to be modified\n"); gets(&bufValue[0]); printf("Enter new parameter value \n"); gets(&bufInput[0]); /* Convert the ParmNum to a ULONG. */ ulParmNum = atoi(&bufValue[0]); switch (ulParmNum){ case 2: case 3: case 4: case 10: /* Determine the size of the buffer needed. */ cbBuf = sizeof(PUSHORT); /* Convert the buffer input to a USHORT. */ usParm =(USHORT)atoi(&bufInput[0]); /* Set the pBuf pointer to point to the value obtained. */ pBuf = &usParm; break; case 5: case 6: case 8: case 9: case 12: case 13: /* Determine the size of the buffer needed. */ cbBuf = strlen(&bufInput[0])+1; /* Set the pBuf pointer to point to the value obtained from input. */ pBuf = (PSZ)&bufInput; break; case 14: printf("For simplicity this is not implemented."); break; default: printf("Invalid number\n"); DosExit( EXIT_PROCESS , 0 ) ; break; } /* Make the call with all the proper parameters. */ splerr = SplSetQueue(pszComputerName, pszQueueName, 3L, pBuf, cbBuf, ulParmNum) ; /* Print the resultant error code, and the parameters entered. */ printf("SplSetQueue Error= %ld, Parameter= %d, cbBuf= %ld, ulParmNum= %ld\n", splerr, usParm, cbBuf, ulParmNum); DosExit( EXIT_PROCESS , 0 ) ; return (splerr); }