Skip to content

Instantly share code, notes, and snippets.

@kadler
Last active January 11, 2018 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kadler/cb31c1b35129d4b0747065f3e6cb303a to your computer and use it in GitHub Desktop.
Save kadler/cb31c1b35129d4b0747065f3e6cb303a to your computer and use it in GitHub Desktop.
Calling QzuiCreateInstance

For some reason I'm getting CPF3C1D when calling the API and I don't know why.

The API is defined here and the structure is defined here.

The last field of the structure is at offset 570 and is 512 bytes, which means the whole structure is 1082, which is what we're passing. It says that we need to pass 1 more byte, but I have no idea why or what it should be.

Also: the lib option to iSrvPgm does not work...

Update: I added a 2 byte dummy field to make it greater than 1083 bytes long and now get: "A value in the instance data at decimal offset 28 is not valid"

Even after fixing the table libs to be empty strings to match the documentation when the table names are *GLOBAL.

Update: Structure is not packed, so added alignment and now the API call works.

from itoolkit import *
from itoolkit.lib.ilibcall import *
itransport = iLibCall()
itool = iToolKit()
itool.add(iCmd('addlible', 'addlible QHTTPSVR'))
itool.add(
iSrvPgm('QzuiCreateInstance','QZHBCONF','QzuiCreateInstance', iopt={'lib': 'QHTTPSVR'}) # This doesn't seem to work, thus the ADDLIBLE above
.addParm(iData('instance','10a','TESTTK'))
.addParm(
iDS('INSD0110',{'len':'buflen'})
.addData(iData('autostart','10a','*NO'))
# structure is not packed, it seems, so add a 2 byte hole here
# so threads will be aligned on a 4-byte boundary (offset 12 instead of 10)
.addData(iData('pad_for_alignment','2h',''))
.addData(iData('threads','10i0','0'))
.addData(iData('ccsid','10i0','37'))
.addData(iData('out_table_name','10a','*GLOBAL'))
.addData(iData('out_table_lib','10a',''))
.addData(iData('in_table_name','10a','*GLOBAL'))
.addData(iData('in_table_lib','10a',''))
.addData(iData('config_file','512a','/www/testtk/httpd.conf'))
.addData(iData('server_root','512a','/www/testtk'))
)
.addParm(iData('bufsize','10i0','',{'setlen':'buflen'}))
.addParm(iData('format','10a','INSD0110'))
.addParm(
iDS('qus_ec_t',{'len':'errlen'})
.addData(iData('provided','10i0','',{'setlen': 'errlen'}))
.addData(iData('available','10i0',''))
.addData(iData('msgid','7A',''))
.addData(iData('reserved','1A',''))
# These are defined specifically for CPF3C1D
.addData(iData('parameter', '10i0', ''))
.addData(iData('parmlen', '10i0', ''))
.addData(iData('minlen', '10i0', ''))
.addData(iData('maxlen', '10i0', ''))
)
)
itool.call(itransport)
result = itool.dict_out('QzuiCreateInstance')
#print(result)
err = result['qus_ec_t']
if int(err['available']):
if err['msgid'] == 'CPF3C1D':
print("{4}: The length of {0} for parameter {1} is not valid. Values for this parameter must be greater than {2} and less than {3}.".format(err['parmlen'], err['parameter'], err['minlen'], err['maxlen'], err['msgid']))
elif err['msgid'] == 'HTPA103':
print('A value in the instance data at decimal offset {} is not valid'.format(err['parameter']))
else:
print(err['msgid'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment