Skip to content

Latest commit

 

History

History
93 lines (70 loc) · 2.68 KB

README.md

File metadata and controls

93 lines (70 loc) · 2.68 KB

CGI-Serviceprogram

This is my simple cgi.serviceporgram for my favorit platform IBMi.
This servieprogram handle the incoming and outgoing streams to std-io.

Setup HTTP-Server on IBMi

  1. Copy sourcefiles and compile them in your own library

  2. Start your admin-server: STRTCPSVR SERVER(*HTTP) HTTPSVR(*ADMIN)

  3. Create a new HTTP-Server instance

  4. Add the following parts to the http-config

ScriptAliasMatch /targetlib/(.*) /qsys.lib/targetlib.lib/$1

Auth against the IBMi - Userprofiles:

<Directory /qsys.lib/targetlib.lib>
  SetEnv QIBM_CGI_LIBRARY_LIST "targetlib;YAJL;QHTTPSVR"
  AuthType Basic
  AuthName "Restricted Area"
  PasswdFile %%SYSTEM%%
  UserID %%CLIENT%%
  Require valid-user
</Directory>

or without IBMi Userprofile with a validation-list:
Create a validation list on your IBMi with: CRTVLDL TARGETLIB/TEST.
Change the http-conf to the following:

<Directory /qsys.lib/targetlib.lib>
  SetEnv QIBM_CGI_LIBRARY_LIST "targetlib;YAJL;QHTTPSVR"
  AuthType Basic
  AuthName "Restricted Area"
  PasswdFile targetlib/test
  Require valid-user
</Directory>

Add the allowed users with the http-admin "Advanced" - "Internet-user"

  1. Start your new http-server

  2. Try out the delivered examples:

User informations
https://yourIP:port/targetlib/userinfos?usrcls=secofr&exppwd=1&enabled=0

Active jobs:
https://yourIP:port/targetlib/activejobs?sbs=qbatch&jobsts=msgw

Object locks:
https://yourIP:port/targetlib/objectlocks?lib=testlib&obj=customers

History log infos:
https://yourIP:port/targetlib/historylogs?start=2021-07-11&end=2021-07-12&query=brc

Job log infos:
https://yourIP:port/targetlib/joblogs?job=067435/QUSER/QZDASOINIT&limit=20

Object statistic infos:
https://yourIP:port/targetlib/objectinfos?lib=yajl&objtype=*file

Or try them with my small windows app written in vb.net:
https://github.com/PantalonOrange/Control-for-IBM-i

Pocedures within the serviceprogram

  1. getHTTPInput: Reads the stream and fill in the neccessary variables like "REQUEST_METHOD" and so on.
    These values are written to the "INPUTPARMDS" variable.

  2. writeHTTPOut: Here we can write to the io-std

  3. getHTTPHeader: Simple procedure to determine the HTTP header

  4. getValueByName Get the value by name from parameters

  5. vtranslateData: Convert data between different CCSID's.
    ICONV is used for translation.

  6. parseQueryString: The "QUERY_STRING" is parsed here.
    "id=1&test=5" becomes DS [id=1], [test=2]

  7. seperateValues: The parsed data from "parseQueryString" are simplified here even further.
    "id=1" or "test=5" becomes DS [{id}{1}] or [{test}{5}]