GET API

1. wbGetAuthType

wbGetAuthType() determines the client’s authentication method and returns information corresponding to the CGI environment variable AUTH_TYPE. This function is useful for a client to check the authentication method. It returns the authentication type, and if no authentication method is used, it returns NULL.

The authentication method currently supported in WebtoB is Basic.

When using the wbGetAuthType() function in conjunction with the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the returned value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetAuthType(WBSVCINFO *rqst)
  • Return value

    If authentication is used, it returns the authentication type. If authentication is not used, it returns NULL.

  • Example

    <wbauth.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    HostName = "tmaxh1",
                    PORT = "7654"
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD, AuthentName = authent1
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc = 2
     wbauth         SVGNAME = webapg, MinProc = 1, MaxProc = 2
    
     *SERVICE
     test           SVRNAME = wbauth
    
    *URI
     wbapi          Uri="/svct/", Svrtype = WEBSTD
    
    *AUTHENT
     authent1       Type = Basic, UserFile = "/user2/haninho/webtob/pwfile"
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $ wscfl –i wbauth.m

      Create a file storing the ID and password using wsmkpw.

      $wsmkpw –p haninho haninho pwfile
    2. Create a service table.

      $ wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named wbauth.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst) {
       char *auth_type;
       auth_type = wbGetAuthType(rqst);
       wbPrint(rqst, "<HTML><BODY>");
       if(auth_type==NULL)
       {
               wbPrint(rqst, "<H1>Not used Authentication</H1>");
       }
       else
       {
               wbPrint(rqst, "<H1>AuthType : %s</H1>", auth_type);
       }
       wbPrint(rqst, "</BODY></HTML>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbauth
    5. The following is the screen where the results are printed.

      Since we did not use a specific WBAPI authentication type to distinguish the authentication method, the following results are produced:

      image

  • Related functions

    wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

2. wbGetContentLength

wbGetContentLength returns the size of the content sent by the client. This function is used to obtain information corresponding to the CGI environment variable CONTENT_LENGTH.

When using the wbGetContentLength() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the returned value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetContentLength(WBSVCINFO *rqst)
  • Return value

    Returns the size of the content sent by the client.

  • Example

    <wbcontent.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbcontent      SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = wbcontent
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $ wscfl –I wbcontent.m
    2. Create a service table.

      $ wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbcontent.html>

      <html>
      <head><title>CONTENT LENGTH</title></head>
      <body>
      <form method=post action="/svct/test">
      <table width=370>
      <br>
      <tr>
      <td> input name</td>
      <td><input type=input name=name></td>
      <td><input type=submit value="submit"></td>
      </tr>
      </table>
      </form>
      </body>
      </html>

      Below is an example WBAPI program that processes the request.

      <wbcontent.c>

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *content_length;
       content_length = wbGetContentLength(rqst);
       wbPrint(rqst, "<HTML><BODY>");
       if( content_length != NULL)
       {
       wbPrint(rqst, "<H1>CONTENT_LENGTH : %s</H1>", content_length);
       }
       else
       {
       wbPrint(rqst, "<H1>CONTENT IS NULL</H1>");
       }
       wbPrint(rqst, "</Body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbcontent
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

3. wbGetDocumentRoot

wbGetDocumentRoot returns the value of the Home directory of WebtoB. The return value of this function is the same as the value set by the user in the DocRoot item of the NODE section when setting the WebtoB environment.

When using the wbGetDocumentRoot() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the return value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetDocumentRoot(WBSVCINFO *rqst)
  • Return value

    Returns the value of the Home directory of WebtoB.

  • Example

    <docroot.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbdocroot      SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = wbdocroot
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbdocroot.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes a request, named docroot.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *document_root;
       document_root = wbGetDocumentRoot(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       wbPrint(rqst, "<H1>DocumentRoot : %s</H1>", document_root);
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbdocroot
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

4. wbGetMethod

wbGetMethod returns the HTTP method value as a string. It outputs the method actually requested by the user in string format.

When using the wbGetMethod() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the return value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetMethod(WBSVCINFO *rqst)
  • Return value

    Returns the HTTP method used in the request as a string.

    Return value Description

    [GET]

    Indicates that the HTTP method used by the client to send the request is GET.

    [POST]

    Indicates that the HTTP method used by the client to send the request is POST.

    [PUT]

    Indicates that the HTTP method used by the client to send the request is PUT.

    [HEAD]

    Indicates that the HTTP method used by the client to send the request is HEAD.

    [DELETE]

    Indicates that the HTTP method used by the client to send the request is DELETE.

    [CONNECT]

    Indicates that the HTTP method used by the client to send the request is CONNECT.

    [OPTIONS]

    Indicates that the HTTP method used by the client to send the request is OPTIONS.

    [TRACE]

    Indicates that the HTTP method used by the client to send the request is TRACE.

    [INVALID]

    The argument is invalid. The method is not defined in wbapi.h.

  • Example

    <wbmethod.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbmethod       SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = wbmethod
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbmethod.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbmethod.html>

      <html>
      <head><title>WBGETMETHOD</title></head>
      <body>
      <form method=post action="/svct/test">
      <table width=370>
      <br>
      <tr>
      <td> input name</td>
      <td><input type=input name=name></td>
      <td><input type=submit value="submit"></td>
      </tr>
      </table>
      </form>
      </body>
      </html>

      Below is an example WBAPI program that processes the request.

      <wbmethod.c>

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *method_name;
       method_name = wbGetMethod(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if( method_name != NULL) {
               wbPrint(rqst, "<H1>method name : %s</H1>", method_name);
       }
       else {
               wbPrint(rqst, "<H1>method name is null</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbmethod
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

5. wbGetParsedURI

wbGetParsedURI returns the URI information requested by the client. It returns all information that can also be retrieved by the wbGetScriptName() and wbGetPathInfo() functions.

For example, if a client enters http://tmax.co.kr/enc.cgi/a/b in the address bar, wbGetParsedURI() returns the additional path information /enc.cgi/a/b. If no path information is available, it returns NULL.

When using the wbGetParsedURI() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the returned value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetParsedURI(WBSVCINFO *rqst)
  • Return value

    Returns the URI information requested by the client.

  • Example

    <wburi.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = "7654"
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wburi          SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = wburi
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wburi.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named wburi.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *parsed_uri;
       parsed_uri = wbGetParsedURI(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       wbPrint(rqst, "<H1>URI : %s</H1>", parsed_uri);
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wburi
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

6. wbGetPathInfo

wbGetPathInfo returns the relative path associated with the request. The function retrieves the information that corresponds to PATH_INFO in CGI environment variables.

For example, if the client enters http://tmax.co.kr/enc.cgi/a/b in the address bar, wbGetPathInfo() returns the additional path information /a/b. If no path information is available, it returns NULL.

When using the wbGetPathInfo() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the return value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetPathInfo(WBSVCINFO *rqst)
  • Return value

    Returns the additional path information associated with the request. If no path information is available, NULL is returned.

  • Example

    <wbpath.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg         NODENAME = "tmaxh1", SvrType = HTML
     webapg        NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html          SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbpath        SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test          SVRNAME = wbpath
    
    *URI
     wbapi         Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm           MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbpath.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes a request, named wbpath.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
      
       test(WBSVCINFO *rqst) {
       char *path;
       path = wbGetPathInfo(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if(path != NULL) {
       wbPrint(rqst, "<H1>PATH : %s</H1>", path);
       }
       else {
       wbPrint(rqst, "<H1>PATH is null</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbpath
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

      If you call the WBAPI service from a browser using the format http://61.77.153.5:7654/svct/test/a/b, you will get the following result.

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), bGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), bGetServerName(), wbGetServerPort(), bGetServerSoftware(), bGetTranslatedURI()

7. wbGetPathTranslated

wbGetPathTranslated returns the actual path of the service associated with the request. The function retrieves the information that corresponds to the CGI environment variable PATH_TRANSLATED.

When using wbGetPathTranslated() alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the return value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetPathTranslated(WBSVCINFO *rqst)
  • Return value

    Returns the additional path information associated with the request. If no path information is available, NULL is returned.

  • Example

    <wbpathtrans.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbpathtrans    SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = wbpathtrans
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbpathtrans.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes a request, named wbpathtrans.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *pathtrans;
       pathtrans = wbGetPathTranslated(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if(pathtrans != NULL){
       wbPrint(rqst, "<H1>PATHTRANS : %s</H1>", pathtrans);
       }
       else {
       wbPrint(rqst, "<H1>PATHTRANS is null</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbpathtrans
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

      If you call the WBAPI service from a browser using the format http://61.77.153.5:7654/svct/test/a/b, you will get the following result.

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

8. wbGetProtocol

wbGetProtocol returns the protocol information associated with the request. The function retrieves the information that corresponds to SERVER_PROTOCOL in CGI environment variables.

When using the wbGetProtocol() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the return value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    int wbSvrInit(int argc, char *argv[])
  • Return value

    Returns the protocol information associated with the request. If no information is available, NULL is returned.

  • Example

    <wbprotocol.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
    *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbprotocol     SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
    *SERVICE
     test           SVRNAME = wbprotocol
    
    *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
    *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbprotocol.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named wbprotocol.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *protocol;
       protocol = wbGetProtocol(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       wbPrint(rqst, "<H1>protocol : %s</H1>", protocol);
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbprotocol
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

9. wbGetQueryString

wbGetQueryString returns the query string from the request URL. This value is equivalent to the CGI variable QUERY_STRING.

When using the wbGetQueryString() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the returned value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetQueryString(WBSVCINFO *rqst)
  • Return value

    Returns a query string from the request URL.

  • Example

    <wbquery.m>

     *DOMAIN
     webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbquery        SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test1          SVRNAME = wbquery
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbquery.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbquery.html>

      <html>
      <head><title>wbGetQueryString</title></head>
      <body>
      <form method=get action="/svct/test">
      <table width=370>
      <br>
      <tr>
      <td> input name</td>
      <td><input type=input name=name></td>
      <td><input type=submit value="submit"></td>
      </tr>
      </table>
      </form>
      </body>
      </html>

      Below is an example WBAPI program that processes the request.

      <wbquery.c>

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *query;
       query = wbGetQueryString(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if(query != NULL)
       {
       wbPrint(rqst, "<H1>QUERY : %s</H1>", query);
       }
       else
       {
       wbPrint(rqst, "<H1>QUERY is null</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbquery
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

10. wbGetRemoteAddr

wbGetRemoteAddr returns the IP address of the remote host that made the request. The function retrieves the information that corresponds to the CGI environment variable REMOTE_ADDR.

When using the wbGetRemoteAddr() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the returned value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetRemoteAddr(WBSVCINFO *rqst)
  • Return value

    Returns the IP address of the remote host of the client making the request.

  • Example

    <wbremoteaddr.m>

    *DOMAIN
    webtob1
    
    *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbremoteaddr   SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbremoteaddr
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbremoteaddr.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbremoteaddr.html>

      <html>
      <head><title>wbGetRemoteAddr</title></head>
      <body>
      <form method=get action="/svct/test">
      <table width=370>
      <br>
      <tr>
      <td> input name</td>
      <td><input type=input name=name></td>
      <td><input type=submit value="submit"></td>
      </tr>
      </table>
      </form>
      </body>
      </html>

      Below is an example WBAPI program that processes the request.

      <wbremoteaddr.c>

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst) {
       char *addr;
       addr = wbGetRemoteAddr(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if(addr != NULL) {
       wbPrint(rqst, "REMOTE_ADDR : %s", addr);
       } else {
       wbPrint(rqst, "<H1>addr is null</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbremoteaddr
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

11. wbGetRemoteHost

wbGetRemoteHost returns the name of the remote host making the request. The function retrieves the information that corresponds to the CGI environment variable REMOTE_HOST. If this information is not found in the remote host, it returns the REMOTE_ADDR value instead.

When using the wbGetRemoteHost() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the return value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetRemoteHost(WBSVCINFO *rqst)
  • Return value

    Returns the hostname of the remote host that made the request.

  • Example

    <wbremotehost.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
    *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbremotehost   SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbremotehost
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbremotehost.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbremotehost.html>

      <html>
      <head><title>wbGetRemoteHost</title></head>
      <body>
      <form method=get action="/svct/test">
      <table width=370>
      <br>
      <tr>
      <td> input name</td>
      <td><input type=input name=name></td>
      <td><input type=submit value="submit"></td>
      </tr>
      </table>
      </form>
      </body>
      </html>

      Below is an example WBAPI program that processes the request.

      <wbremotehost.c>

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *host;
       host = wbGetRemoteHost(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if(host != NULL)
       {
       wbPrint(rqst, "REMOTE_HOST : %s", host);
       }
       else
       {
       wbPrint(rqst, "<H1>host is null</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbremotehost
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

      wbGetRemoteHost() retrieves the information corresponding to the CGI environment variable REMOTE_HOST. In this example, as there is no remote host information, the REMOTE_ADDR value is returned instead.

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

12. wbGetRemoteUser

wbGetRemoteUser returns the name of the client making the request. The function is equivalent to the CGI variable REMOTE_USER. If access to WebtoB is unrestricted, it returns NULL. This generally means that the client logged in using HTTP authentication.

When using the wbGetRemoteUser() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the returned value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetRemoteUser(WBSVCINFO *rqst)
  • Return value

    Returns the name of the client making the request. If accessing WebtoB is unrestricted, NULL is returned.

  • Example

    <wbremoteuser.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD, Authentname = authent1
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbremoteuser   SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbremoteuser
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *AUTHENT
     authent1       Type = Basic, UserFile = "/user2/haninho/webtob/pwfile"
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbremoteuser.m

      Create a file storing the ID and password using wsmkpw.

      $wsmkpw –p haninho haninho pwfile
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named wbremoteuser.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst) {
       char *user;
       user = wbGetRemoteUser(rqst); 
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if(user != NULL) {
       wbPrint(rqst, "REMOTE_USER : %s", user);
       } else {
       wbPrint(rqst, "<H1>user is null</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbremoteuser
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

13. wbGetRequestURI

wbGetRequestURI returns the URI (Universal Resource Identifier) of the request, containing all details of the request except for the domain name.

When using the wbGetRequestURI() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the return value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetRequestURI(WBSVCINFO *rqst)
  • Return value

    Returns the URI of the request.

  • Example

    <wbrequest.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbrequest      SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbrequest
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbrquest.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes a request, named wbrequest.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *user;
       user = wbGetRequestURI(rqst); 
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if(user != NULL)
       {
       wbPrint(rqst, "REQUEST_URI : %s", user);
       } else {
       wbPrint(rqst, "<H1>uri is null</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbrequest
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

14. wbGetScheme

wbGetScheme returns the protocol information of the requested service. For example, if you use an HTML service, wbGetScheme() returns ‘HTTP’, and if you use an SSL service, it returns ‘HTTPS’.

When using the wbGetScheme() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the returned value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetScheme(WBSVCINFO *rqst)
  • Return value

    Returns the protocol for the requested service.

  • Example

    <wbscheme.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbscheme       SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbscheme
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbscheme.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes a request, named wbscheme.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst) {
       char *sch;
       sch = wbGetScheme(rqst);    
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if(sch != NULL)
       {
       wbPrint(rqst, "scheme : %s", sch);
       }
       else
       {
       wbPrint(rqst, "<H1>scheme is null</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbscheme
    5. When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

15. wbGetScriptFilename

wbGetScriptFilename returns the absolute path where the requested WBAPI service is running.

For example, if the path where the service runs is /usr/local/webtob/ap/test, the value returned by wbGetScriptFilename() is /usr/local/webtob/ap/test.

When using the wbGetScriptFilename() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the return value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetScriptFilename(WBSVCINFO *rqst)
  • Return value

    Returns the absolute path where the requested service is running.

  • Example

    <wbscriptfile.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVICE
     test           SVRNAME = wbscriptfile
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *ALIAS
     alias          uri="/svct/", RealPath="/user2/haninho/webtob/svct/"
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbscriptfile.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named wbscriptfile.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *name;
       name = wbGetScriptFilename(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if(name != NULL) {
       wbPrint(rqst, "Script Filename : %s", name);
       } else {
       wbPrint(rqst, "<H1>error</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbscriptfile
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

16. wbGetScriptName

wbGetScriptName returns the path where the requested service is executed. The function retrieves the information that corresponds to the CGI environment variable SCRIPT_NAME.

When using the wbGetScriptName() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the return value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetScriptName(WBSVCINFO *rqst)
  • Return value

    Returns the absolute path of the requested file.

  • Example

    <wbscriptname.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbscriptname   SVGNAME = webapg, MinProc = 1, MaxProc = 2 
    
     *SERVICE
     test           SVRNAME = wbscriptname
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbscriptname.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes a request, named wbscriptname.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst) {
       char *name;
       name = wbGetScriptName(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if(name != NULL) {
       wbPrint(rqst, "Script Name : %s", name);
       } else {
       wbPrint(rqst, "<H1>error</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbscriptname
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

17. wbGetServerName

wbGetServerName returns the server’s hostname. The function retrieves the information that corresponds to the CGI environment variable SERVER_NAME.

When using the wbGetServerName() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the returned value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetServerName(WBSVCINFO *rqst)
  • Return value

    Returns the server’s hostname.

  • Example

    <wbservername.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    $wscfl –i wbscriptfile.m
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbservername   SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbservername
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbservername.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named wbservername.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *name;
       name = wbGetServerName(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if(name != NULL)
       {
       wbPrint(rqst, "Server Name : %s", name);
       }
       else
       {
       wbPrint(rqst, "<H1>error</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbservername
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerPort(), wbGetServerSoftware(), wbGetTranslatedURI()

18. wbGetServerPort

wbGetServerPort returns the server’s port number. The function retrieves the information that corresponds to the CGI environment variable SERVER_PORT.

When using the wbGetServerPort() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the return value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetServerPort(WBSVCINFO *rqst)
  • Return value

    Returns the port number of the server.

  • Example

    <wbserverport.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbserverport   SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbserverport
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbserverport.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named wbserverport.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *port;
       port = wbGetServerPort(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if(port != NULL)
       {
       wbPrint(rqst, "Server Port : %s", port);
       }
       else
       {
       wbPrint(rqst, "<H1>error</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbserverport
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerSoftware(), wbGetTranslatedURI()

19. wbGetServerSoftware

wbGetServerSoftware returns the server’s software information. The function retrieves the information that corresponds to the CGI environment variable SERVER_SOFTWARE.

When using the wbGetServerSoftware() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the return value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetServerSoftware(WBSVCINFO *rqst)
  • Return value

    Returns the server’s software information.

  • Example

    <wbsoft.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg          NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbsoft         SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbsoft
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbsoft.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named wbsoft.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *server;
       server= wbGetServerSoftware(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if(server != NULL)
       {
       wbPrint(rqst, "SERVER : %s", server);
       }
       else
       {
       wbPrint(rqst, "<H1>server is null</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbsoft
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetTranslatedURI()

20. wbGetTranslatedURI

wbGetTranslatedURI interprets the parsed URI of the requested service and returns the actual path.

When using the wbGetTranslatedURI() function alongside the functions listed in the “Related Functions” section below, be aware that they share a buffer. If you do not use String Copy on the returned value, the last returned value will be output. Therefore, it is recommended to use String Copy.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetTranslatedURI(WBSVCINFO *rqst)
  • Return value

    Interprets the URI of the requested service and returns the actual path.

  • Example

    <wbtransuri.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbtransuri     SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbtransuri
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *ALIAS
     alias          uri="/svct/", RealPath="/user2/haninho/webtob/svct/"
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbtransuri.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named wbtransuri.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst) {
       char *uri;
       uri = wbGetTranslatedURI(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       if(uri != NULL) {
       wbPrint(rqst, "URI : %s", uri);
       } else {
       wbPrint(rqst, "<H1>URI is null</H1>");
       }
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbtransuri
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetAuthType(), wbGetContentLength(), wbGetDocumentRoot(), wbGetMethod(), wbGetParsedURI(), wbGetPathInfo(), wbGetPathTranslated(), wbGetProtocol(), wbGetQueryString(), wbGetRemoteAddr(), wbGetRemoteHost(), wbGetRemoteIdent(), wbGetRemoteUser(), wbGetRequestURI(), wbGetScheme(), wbGetScriptFilename(), wbGetScriptName(), wbGetServerName(), wbGetServerPort(), wbGetServerSoftware()

21. wbGetHdr

wbGetHdr returns the value associated with a key in the request header. This function searches for and retrieves the value for a specified header key within the client’s request headers. By using the name of the header as the key, you can obtain the corresponding value directly.

The argument key is the name of a header, such as Content-type or Referer.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetHdr(WBSVCINFO *rqst, char *key)
  • Return value

    Returns the header value corresponding to the value of the argument key. If no corresponding information is found, NULL is returned.

  • Example

    <wbhdr.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbhdr          SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbhdr
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbhdr.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbhdr.html>

      <head><title>wbGetHdr</title></head>
      <body>
      <form method=get action="/svct/test">
      <table width=370>
      <br>
      <tr>
      <td> input name</td>
      <td><input type=input name=name></td>
      <td><input type=submit value="submit"></td>
      </tr>
      </table>
      </form>
      </body>
      </html>

      Below is an example WBAPI program that processes the request.

      <wbhdr.c>

       #include        <stdio.h>
       #include        <usrinc/atmi.h>
       #include        <usrinc/wbapi.h>
       test(WBSVCINFO *rqst)
       {
       char *header1;
       char *header2;
       header1 = wbGetHdr(rqst, "Referer");
       header2 = wbGetHdr(rqst, "Host");
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<H1>Referer : %s</H1>", header1);
       wbPrint(rqst, "<H1>Host : %s</H1>", header2);
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbhdr
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetDateHdr(), wbGetIntHdr(), wbGetNthHdr(), wbGetHdrCount()

22. wbGetDateHdr

wbGetDateHdr returns the date value of a header as long type data. If the requested header does not exist or its value cannot be converted to a date, an error is raised. This API is useful for handling date-based headers, such as “If-Modified-Since” and “If-Unmodified-Since”.

The argument name is a header representing the date. Currently, the wbGetDateHdr() function returns values only for “Last-Modified” and “If-Modified-Since”.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    long wbGetDateHdr(WBSVCINFO *rqst, char *name)
  • Return value

    Returns a header as a long type value representing the number of milliseconds since midnight, January 1, 1970 GMT.

    If the requested header does not exist or its value cannot be converted to a date, -1 is returned.

  • Example

    <wbdatehdr.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbdatehdr      SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbdatehdr
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbdatahdr.m
    2. Create a service table.

      $wsgst
    3. Generate the source file. The following is an example WBAPI program that processes the request, named wbdatehdr.c.

       #include <stdio.h>
       #include <usrinc/atmi.h>
       #include <usrinc/wbapi.h>
       test (WBSVCINFO *rqst)
       {
              long date1;
              long date2;
      
              date1 = wbGetDateHdr(rqst, "If-Modified-Since");
              date2 = wbGetDateHdr(rqst, "If-Unmodified-Since");
      
              wbPrint(rqst, "<HTML>\n");
              wbPrint(rqst, "<HEAD><TITLE> wbGetDateHdr Test </TITLE></HEAD>\n");
              wbPrint(rqst, "<BODY>\n");
              wbPrint(rqst, "<H1> wbGetDateHdr Test </H1>\n");
              wbPrint(rqst, "If-Modified-Since : %ld<br>", date1);
              wbPrint(rqst, "If-Unmodified-Since : %ld<br>", date2);
              wbPrint(rqst, "</BODY>\n");
              wbPrint(rqst, "</HTML>\n");
      
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbdatahdr
    5. The following is an example of the resulting output.

      When you call the WBAPI service with a browser, you get the following result:

       telnet 61.77.153.5 7654
       Trying 61.77.153.5...
       Connected to 61.77.153.5.
       Escape character is '^]'.
       GET /svct/test HTTP/1.1
       Host:tmax.co.kr
       If-Modified-Since:Mon, 20 Aug 2001 23:02:16 GMT
       If-UnModified-Since:Mon, 20 Aug 2001 23:02:16 GMT 
      
       HTTP/1.1 200 OK
       Date: Mon, 05 Nov 2001 08:26:52 GMT
       Server: WebtoB/3.0
       Content-Type: text/html
       Content-Length:     175
      
       <HTML>
       <HEAD><TITLE> wbGetDateHdr Test </TITLE></HEAD>
       <BODY>
       <H1> wbGetDateHdr Test </H1>
       If-Modified-Since : 998348536<br>If-Unmodified-Since : 998348536<br></BODY>
       </HTML>
  • Related functions

    wbGetHdr(), wbGetIntHdr(), wbGetNthHdr(), wbGetHdrCount()

23. wbGetIntHdr

wbGetIntHdr returns the value of a header as an integer. If the header was not sent as part of the request, the function returns -1. It also raises an error if the header value cannot be converted to an integer. The argument name is the name of the header as an integer, such as “Age” or “Retry-After”.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    int wbGetIntHdr(WBSVCINFO *rqst, char *name)
  • Return value

    Returns the value of the specified header as an integer. If an error occurs, -1 is returned.

  • Example

    <wbinthdr.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbinthdr       SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbinthdr
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbinthdr.m
    2. Create a service table.

      $wsgst
    3. Generate the source file. The following is an example WBAPI program that processes requests, and the file name is wbinthdr.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
              int hdr1, hdr2, hdr3;
              wbPutHdr(rqst, "Content-type", "text/html");
              wbPrint(rqst, "<HTML><BODY>");
              hdr1 = wbGetIntHdr(rqst, "Max-Forwards");
              wbPrint(rqst, "wbGetIntHdr(Max-Forwards) : %d<br>", hdr1);
              hdr2 = wbGetIntHdr(rqst, "Retry-After");
              wbPrint(rqst, "wbGetIntHdr(Retry-After) : %d<br>", hdr2);
              hdr3 = wbGetIntHdr(rqst, "Age");
              wbPrint(rqst, "wbGetIntHdr(Age) : %d<br>", hdr2);
              wbPrint(rqst, "</body></html>");
              wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbinthdr
    5. Here is an example of the resulting output.

      Calling the WBAPI service via Telnet produces the following result:

       telnet 61.77.153.5 7654
       Trying 61.77.153.5...
       Connected to 61.77.153.5.
       Escape character is '^]'.
       GET /svct/test HTTP/1.1
       Host: tmaxh1.co.kr
       Retry-After: 111
       Max-Forwards: 222
       Age: 333
      
       HTTP/1.1 200 OK
       Date: Mon, 05 Nov 2001 08:56:07 GMT
       Server: WebtoB/3.0
       Content-type: text/html
       Content-Length:     121
      
       <HTML><BODY>wbGetIntHdr(Max-Forwards) :
       222<br>wbGetIntHdr(Retry-After) : 111<br>wbGetIntHdr(Age) :
       333<br></body></html>
  • Related functions

    wbSvrInit()

24. wbGetNthHdr

wbGetNthHdr returns the value of the header corresponding to a specific sequence number. This function retrieves the value of the header that is the 'N’th entry among the request headers.

The argument nth sets the desired order of values among the header values coming from the client.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetNthHdr(WBSVCINFO *rqst, int nth)
  • Return value

    Returns the value of the header corresponding to nth.

  • Example

    <wbnthhdr.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbnthhdr       SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbnthhdr
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbnthhdr.m
    2. Create a service table.

      $wsgst
    3. Generate the source file. The following is an example WBAPI program that processes the request, named wbnthhdr.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *header;
       header = wbGetNthHdr(rqst, 1); 
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       wbPrint(rqst, "wbGetNthHdr : %s<br>", header);
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbnthhdr
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetHdr(), wbGetDateHdr(), wbGetIntHdr(), wbGetHdrCount()

25. wbGetHdrCount

wbGetHdrCount returns the total number of request headers.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    int wbGetHdrCount(WBSVCINFO *rqst)
  • Return value

    Returns the total number of headers.

  • Example

    <wbhdrcount.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbhdrcount     SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbhdrcount
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbhdrcount.m
    2. Create a service table.

      $wsgst
    3. Generate a source file. The following is an example WBAPI program that processes requests, named wbhdrcount.c.

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       int header;
       header = wbGetHdrCount(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       wbPrint(rqst, "Total header : %d<br>", header);
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbhdrcount
    5. The following is the screen where the results are printed.

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetHdr(), wbGetDateHdr(), wbGetIntHdr(), wbGetNthHdr()

26. wbGetData

wbGetData returns the value corresponding to a key value in the data field of a request.

This function retrieves the desired value from the data included in a client’s request, which often contains not only headers but also data meant for the server. By using the specified key, you can obtain the corresponding data value.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetData(WBSVCINFO *rqst, char *name)
  • Return value

    Returns the data value of the field corresponding to the key. If the corresponding value does not exist, NULL is returned.

  • Example

    <wbdata.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbdata         SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbdata
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbdata.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbdata.html>

      <HTML>
      <HEAD> <TITLE>WebToB Bulletin</TITLE> </HEAD>
      <BODY>
      <H2><big>WebToB Board Upload</big></H3>
      </h2>
      <HR WIDTH=500 ALIGN=left>
      <BR>
      <FORM METHOD=post ACTION="/svct/test">
      <TABLE WIDTH=500 BORDER=0>
      <TR>
      <TD>Writer</TD>
      <TD><INPUT NAME=writer SIZE=20></TD>
      </TR>
      <TR>
      <TD>Title</TD>
      <TD><INPUT NAME=title SIZE=50></TD>
      </TR>
      <TR><TD COLSPAN=2><B>Contents</B></TD></TR>
      <TR><TD COLSPAN=2>
      <TEXTAREA NAME=doc COLS=60 ROWS=10></TEXTAREA>
      </TD> </TR>
      <TR>
      <TD>E-Mail</TD>
      <TD><INPUT NAME=email SIZE=40></TD>
      </TR>
      <TR>
      <TD>Home Page</TD>
      <TD><INPUT NAME=homepage SIZE=40 VALUE="http://"></TD>
      </TR>
      </TABLE>
      <BR>
      <INPUT TYPE=submit VALUE="Submit">
      <INPUT TYPE=reset VALUE="Clear">
      </FORM>
      </BODY>
      </HTML>

      Below is an example WBAPI program that processes the request.

      <wbdata.c>

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst) {
       char *name;
       char *title;
       name = wbGetData(rqst, "name");
       title = wbGetData(rqst, "title");
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       wbPrint(rqst, "<H1>input name : %s</H1>", name);
       wbPrint(rqst, "<BR>");
       wbPrint(rqst, "<H1>input title : %s</H1>", title);
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbdata
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetNthData(), wbGetDataCount()

27. wbGetNthKey

wbGetNthKey returns data for the 'N’th key in the request.

When a client sends a request, particularly in CGI, the data is transmitted as a series of fields, typically in the order the client entered them. This function allows you to retrieve the input value corresponding to a specific order. By specifying the nth value, you can access the variable name associated with that position. For instance, if you set the nth value to 2, the function will return the value for the second data field received.

Let’s say the client assigns the value andy to a variable called name. Here, the variable name is the first variable entered. If another value, test, is assigned to a different variable called title, then title becomes the second variable. If you input the value 2 for nth using this function, the variable title will be returned. This function is useful for identifying the names of the variables sent by the client through WBAPI, among other uses.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetNthKey(WBSVCINFO *rqst, int nth)
  • Return value

    Returns the field name corresponding to nth. If the corresponding field name does not exist, NULL is returned.

  • Example

    <wbnthkey.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbnthkey       SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbnthkey
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbnthkey.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbnthkey.html>

      <HTML>
      <HEAD> <TITLE>WebToB Bulletin</TITLE> </HEAD>
      <BODY>
      <H2><big>WebToB Board Upload</big></H3>
      </h2>
      <HR WIDTH=500 ALIGN=left>
      <BR>
      <FORM METHOD=post ACTION="/svct/test">
      <TABLE WIDTH=500 BORDER=0>
      <TR>
      <TD>Writer</TD>
      <TD><INPUT NAME=writer SIZE=20></TD>
      </TR>
      <TR>
      <TD>Title</TD>
      <TD><INPUT NAME=title SIZE=50></TD>
      </TR>
      <TR><TD COLSPAN=2><B>Contents</B></TD></TR>
      <TR><TD COLSPAN=2>
      <TEXTAREA NAME=doc COLS=60 ROWS=10></TEXTAREA>
      </TD> </TR>
      <TR>
      <TD>E-Mail</TD>
      <TD><INPUT NAME=email SIZE=40></TD>
      </TR>
      <TR>
      <TD>Home Page</TD>
      <TD><INPUT NAME=homepage SIZE=40 VALUE="http://"></TD>
      </TR>
      </TABLE>
      <BR>
      <INPUT TYPE=submit VALUE="Submit">
      <INPUT TYPE=reset VALUE="Clear">
      </FORM>
      </BODY>
      </HTML>

      Below is an example WBAPI program that processes the request.

      <wbnthkey.c>

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
      
       test(WBSVCINFO *rqst)
       {
       char *first, *second;
       first = wbGetNthKey(rqst, 1);
       second = wbGetNthKey(rqst, 2);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       wbPrint(rqst, "<H1>first data : %s</H1>", first);
       wbPrint(rqst, "<BR>");
       wbPrint(rqst, "<H1>second data : %s</H1>", second);
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbnthkey
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetData(), wbGetNthData(), wbGetValue()

28. wbGetNthData

wbGetNthData returns the 'N’th piece of data from the request. In addition to headers, multiple data entries can be sent in a single client request. This means you can obtain the data that corresponds to a specific sequence number.

When a client sends a request, particularly in CGI, the data comes in as consecutive fields, typically in the order they were entered by the client. To retrieve data in a specific order, use this function. By specifying the sequence number in the nth parameter, the function will return the data associated with that number. For example, if the nth value is set to 2, it will return the second piece of data submitted.

It’s important to differentiate this function from wbGetNthKey(): while wbGetNthKey() returns the variable name, wbGetNthData() returns the actual value of the variable.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetNthData(WBSVCINFO *rqst, int nth)
  • Return value

    Returns the data value corresponding to nth. If there is no corresponding data value, NULL is returned.

  • Example

    <wbnthdata.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbnthdata      SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbnthdata
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbnthdata.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbnthdata.html>

      <HTML>
      <HEAD> <TITLE>WebToB Bulletin</TITLE> </HEAD>
      <BODY>
      <H2><big>WebToB Board Upload</big></H3>
      </h2>
      <HR WIDTH=500 ALIGN=left>
      <BR>
      <FORM METHOD=post ACTION="/svct/test">
      <TABLE WIDTH=500 BORDER=0>
      <TR>
      <TD>Writer</TD>
      <TD><INPUT NAME=writer SIZE=20></TD>
      </TR>
      <TR>
      <TD>Title</TD>
      <TD><INPUT NAME=title SIZE=50></TD>
      </TR>
      <TR><TD COLSPAN=2><B>Contents</B></TD></TR>
      <TR><TD COLSPAN=2>
      <TEXTAREA NAME=doc COLS=60 ROWS=10></TEXTAREA>
      </TD> </TR>
      <TR>
      <TD>E-Mail</TD>
      <TD><INPUT NAME=email SIZE=40></TD>
      </TR>
      <TR>
      <TD>Home Page</TD>
      <TD><INPUT NAME=homepage SIZE=40 VALUE="http://"></TD>
      </TR>
      </TABLE>
      <BR>
      <INPUT TYPE=submit VALUE="Submit">
      <INPUT TYPE=reset VALUE="Clear">
      </FORM>
      </BODY>
      </HTML>

      Below is an example WBAPI program that processes the request.

      <wbnthdata.c>

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst) {
       char *first, *second;
       first = wbGetNthData(rqst, 1);
       second = wbGetNthData(rqst, 2);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       wbPrint(rqst, "<H1>first data : %s</H1>", first);
       wbPrint(rqst, "<BR>");
       wbPrint(rqst, "<H1>second data : %s</H1>", second);
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbnthdata
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetData(), wbGetDataCount()

29. wbGetDataCount

wbGetDataCount returns the number of data inputs from the request. In addition to headers, multiple data entries can be sent simultaneously from a client request. wbGetDataCount() returns the total number of data inputs transmitted from the client to the server through the request.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    int wbGetDataCount(WBSVCINFO *rqst)
  • Return value

    Returns the total number of data inputs sent by the client to the server.

  • Example

    <wbdatacount.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbdatacount    SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbdatacount
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbdatacount.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbdatacount.html>

      <HTML>
      <HEAD> <TITLE>WebToB Bulletin</TITLE> </HEAD>
      <BODY>
      <H2><big>WebToB Board Upload</big></H3>
      </h2>
      <HR WIDTH=500 ALIGN=left>
      <BR>
      <FORM METHOD=post ACTION="/svct/test">
      <TABLE WIDTH=500 BORDER=0>
      <TR>
      <TD>Writer</TD>
      <TD><INPUT NAME=writer SIZE=20></TD>
      </TR>
      <TR>
      <TD>Title</TD>
      <TD><INPUT NAME=title SIZE=50></TD>
      </TR>
      <TR><TD COLSPAN=2><B>Contents</B></TD></TR>
      <TR><TD COLSPAN=2>
      <TEXTAREA NAME=doc COLS=60 ROWS=10></TEXTAREA>
      </TD> </TR>
      <TR>
      <TD>E-Mail</TD>
      <TD><INPUT NAME=email SIZE=40></TD>
      </TR>
      <TR>
      <TD>Home Page</TD>
      <TD><INPUT NAME=homepage SIZE=40 VALUE="http://"></TD>
      </TR>
      </TABLE>
      <BR>
      <INPUT TYPE=submit VALUE="Submit">
      <INPUT TYPE=reset VALUE="Clear">
      </FORM>
      </BODY>
      </HTML>

      Below is an example WBAPI program that processes the request.

      <wbdatacount.c>

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       int count;
       count = wbGetDataCount(rqst);   
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       wbPrint(rqst, "<H1>total data count : %d</H1>", count);
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbdatacount
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetData(), wbGetNthData()

30. wbGetValue

wbGetValue returns the 'N’th data for a specific key value in the request. When a client sends a request to the server, multiple data entries can be associated with a single variable. In such cases, you can retrieve data entries in the order they were received. For example, if a client submits two values under the variable name name, you can access these values by specifying the nth parameter.

For example, if you set nth to 1, the function will return the first value submitted for the variable name. Similarly, setting nth to 2 will return the second value.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetValue(WBSVCINFO *rqst, char *key, int nth)
  • Return value

    Returns the nth data for a specific key. If the corresponding data does not exist, NULL is returned.

  • Example

    <wbvalue.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbvalue        SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbvalue
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbvalue.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbvalue.html>

      <html>
      <head><title>wbGetValue</title></head>
      <body>
      <form method=get action="/svct/test">
      <table width=370>
      <br>
      <h1> input name</h1>
      <tr>
      <td><input type=input name=name></td>
      <td><input type=input name=name></td>
      <td><input type=input name=name></td>
      <td><input type=submit value="submit"></td>
      </tr>
      </table>
      </form>
      </body>
      </html>

      Below is an example WBAPI program that processes the request.

      <wbvalue.c>

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst) {
       char *value1, *value2, *value3;
       value1 = wbGetValue(rqst,"name",3);
       value2 = wbGetValue(rqst,"name",2);
       value3 = wbGetValue(rqst,"name",1);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       wbPrint(rqst, "<H1>value1 is : %s</H1>", value1);
       wbPrint(rqst, "<H1>value2 is : %s</H1>", value2);
       wbPrint(rqst, "<H1>value3 is : %s</H1>", value3);
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbvalue
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetData(), wbGetNthData()

31. wbKeyOccur

wbKeyOccur returns the number of key values in the request data.

When a client sends a request to a server, it can include multiple data entries, and these entries can be associated with a single variable name. In such cases, wbKeyOccur() can be used to count how many data entries were sent for a specific variable name. This function returns the number of values corresponding to the variable name specified in the key argument.

The key argument represents the name of the variable used by the client when sending data to the server.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    int wbKeyOccur(WBSVCINFO *rqst, char *key)
  • Return value

    Returns the number of data corresponding to a specific key.

  • Example

    <wboccur.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wboccur        SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wboccur
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wboccur.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wboccur.html>

      <html>
      <head><title>wbGetOccur</title></head>
      <body>
      <form method=get action="/svct/test">
      <table width=370>
      <br>
      <h1> input name</h1>
      <tr>
      <td><input type=input name=name></td>
      <td><input type=input name=name></td>
      <td><input type=input name=name></td>
      <td><input type=submit value="submit"></td>
      </tr>
      </table>
      </form>
      </body>
      </html>

      Below is an example WBAPI program that processes the request.

      <wboccur.c>

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst) {
       int count;
       count = wbKeyOccur(rqst,"name");   
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       wbPrint(rqst, "<H1>data name is : %d</H1>", count);
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wboccur
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

32. wbGetReqLine

wbGetReqLine returns a pointer to the first line of the request.

When a client sends a request to a server, it may include the entire request on a single line, although this is not typical. This function provides a pointer to the first line of the request sent by the client, which can be useful in programming with WBAPI when you need to clearly understand the client’s request.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetReqLine(WBSVCINFO *rqst)
  • Return value

    Returns a pointer to the first line of the request sent by the client.

  • Example

    <wbreqline.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbreqline      SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbreqline
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbreqline.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbreqline.html>

      <html>
      <head><title>wbGetReqline</title></head>
      <body>
      <form method=get action="/svct/test">
      <table width=370>
      <br>
      <h1> input name</h1>
      <tr>
      <td><input type=input name=name></td>
      <td><input type=input name=name></td>
      <td><input type=input name=name></td>
      <td><input type=submit value="submit"></td>
      </tr>
      </table>
      </form>
      </body>
      </html>

      Below is an example WBAPI program that processes the request.

      <wbreqline.c>

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst) {
       char *pointer;
       pointer = wbGetReqLine(rqst);
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       wbPrint(rqst, "first line : %s", pointer);
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbreqline
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

33. wbGetRequestURL

wbGetRequestURL returns the requested URL. When a client sends a request to a server, it retrieves all the information entered in the browser’s address bar.

For example, if you entered http://www.tmax.co.kr/cgi-bin/tmax.cgi in the address bar, the returned value is http://www.tmax.co.kr/cgi-bin/tmax.cgi.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetRequestURL(WBSVCINFO *rqst)
  • Return value

    Returns the URL of the request sent by the client.

  • Example

    <wbrequrl.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbrequrl       SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbrequrl
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbrequri.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbrequrl.html>

      <html>
      <head><title>wbGetReqURL</title></head>
      <body>
      <form method=get action="/svct/test">
      <table width=370>
      <br>
      <h1> input name</h1>
      <tr>
      <td><input type=input name=name></td>
      <td><input type=input name=name></td>
      <td><input type=input name=name></td>
      <td><input type=submit value="submit"></td>
      </tr>
      </table>
      </form>
      </body>
      </html>

      Below is an example WBAPI program that processes the request.

      <wbrequrl.c>

       #include <stdio.h>
       #include <usrinc/wbapi.h>
       #include <usrinc/atmi.h>
       test(WBSVCINFO *rqst)
       {
       char *url;
       url = wbGetRequestURL(rqst); 
       wbPutHdr(rqst, "Content-type", "text/html");
       wbPrint(rqst, "<HTML><BODY>");
       wbPrint(rqst, "Request URL is : %s", url);
       wbPrint(rqst, "</body></html>");
       wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbrequri
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

34. wbGetFileName

wbGetFileName returns the name of a file. This function retrieves the name of a file from the data field of a request sent by a client.

You can use the key value to get a file name.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    char *wbGetFileName(WBSVCINFO *rqst, char *key)
  • Return value

    Returns the name of the file.

  • Example

    <wbfilename.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbfilename     SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbfilename
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbfilename.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbfilename.html>

      <TITLE> wbGetFileName() Test </TITLE>
      <BODY>
      <H2> wbGetFileName TEST </H2>
      <FORM METHOD=post ACTION="/svct/test" enctype='multipart/form-data'>
      <B>FILE UPLOAD</B>
      <TABLE WIDTH=650 BGCOLOR=#DDDDDD>
      <TR>
      <TD><SMALL><B>file</B></SMALL></TD>
      <TD><INPUT TYPE=file NAME=upfile SIZE=35></TD>
      </TR>
      <TR>
      <TD><INPUT TYPE=submit VALUE="upload"></TD>
      </TR></TABLE>
      </FORM>
      </BODY>
      </HTML>

      Below is an example WBAPI program that processes the request.

      <wbfilename.c>

       #include        <stdio.h>
       #include        <usrinc/atmi.h>
       #include        <usrinc/wbapi.h>
       test(WBSVCINFO *rqst)
       {
       char  *filename, *temp;
         int k, count;
         FILE *fp;
         count = wbGetDataCount(rqst);
         for(k=1; k<=count; k++)
         {
       temp = wbGetNthKey(rqst, k);
          if((filename=wbGetFileName(rqst, temp)) != NULL)
          {
          wbPrint(rqst,"filename=%s\n",filename);
          }
          }
          wbReturn(rqst, WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbfilename
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetFileLen()

35. wbGetFileLen

wbGetFileLen returns the size of a file. This function retrieves the size of a file based on the information provided in the data field of the client’s request. To obtain the file size, you can use the key value corresponding to the file’s path. This allows you to determine the size of the desired file efficiently.

  • Prototype

    #include <wbapi.h>
    #include <atmi.h>
    long wbGetFileLen(WBSVCINFO *rqst, char *key)
  • Return value

    Returns the size of the file corresponding to the key. The unit of the returned value is byte.

  • Example

    <wbfilelen.m>

    *DOMAIN
    webtob1
    
     *NODE
     tmaxh1         WEBTOBDIR="/user2/haninho/webtob",
                    SHMKEY = 54777,
                    DOCROOT="/user2/haninho/webtob/docs",
                    APPDIR="/user2/haninho/webtob/ap",
                    PORT = “7654”
    
     *SVRGROUP
     htmlg          NODENAME = "tmaxh1", SvrType = HTML
     webapg         NODENAME = "tmaxh1", SVRTYPE = WEBSTD
    
     *SERVER
     html           SVGNAME = htmlg, MinProc = 1, MaxProc =2
     wbfilelen      SVGNAME = webapg, MinProc = 1, MaxProc = 2, 
    
     *SERVICE
     test           SVRNAME = wbfilelen
    
     *URI
     wbapi          Uri = "/svct/", Svrtype = WEBSTD
    
     *EXT
     htm            MimeType = "text/html", SvrType = HTML
    1. Compile the configuration file.

      $wscfl –i wbfilelen.m
    2. Create a service table.

      $wsgst
    3. Generate source files.

      Below is an example of an html file that sends a request.

      <wbfilelen.html>

      <TITLE> wbGetFileLen Test </TITLE>
      <BODY>
      <H2> wbGetFileName TEST </H2>
      <FORM METHOD=post ACTION="/svct/test" enctype='multipart/form-data'>
      <B>FILE UPLOAD</B>
      <TABLE WIDTH=650 BGCOLOR=#DDDDDD>
      <TR>
      <TD><SMALL><B>file</B></SMALL></TD>
      <TD><INPUT TYPE=file NAME=upfile SIZE=35></TD>
      </TR>
      <TR>
      <TD><INPUT TYPE=submit VALUE="upload"></TD>
      </TR></TABLE>
      </FORM>
      </BODY>
      </HTML>

      Below is an example WBAPI program that processes the request.

      <wbfilelen.c>

       #include        <stdio.h>
       #include        <usrinc/atmi.h>
       #include        <usrinc/wbapi.h>
       test(WBSVCINFO *rqst) {
       char *temp, *filedata, *filename, path[255];
       long filelen;
       int k, count, rtn;
       FILE *fp;
       count = wbGetDataCount(rqst);
       for(k=1; k<=count; k++)
       {
       temp = wbGetNthKey(rqst, k);
       if((filename=wbGetFileName(rqst, temp)) != NULL)
       {
       filelen = wbGetFileLen(rqst, temp);
       wbPrint(rqst,"filelength=%ld\n",filelen);
       }
       }
       wbReturn(rqst,WBSUCCESS);
       }
    4. Compile the C file created with WBAPI using the Makefile file.

      $compile c wbfilelen
    5. The following is the screen where the results are printed.

      image

      When you call the WBAPI service with a browser, you get the following result:

      image

  • Related functions

    wbGetFileName()