/*
**    Name: cmd_handler.c
**
**    Date: Thu Jan 17 12:13:43 2002
**
*/

#include "ODBC.h"
#include <stdio.h>
#include <string.h>
#include "rmamem.h"

_kernel_oserror *cmd_handler(char *arg_string,int argc,int cmd_no,void *pw)
    {
    int index;

    arg_string = arg_string;
    argc = argc;
    cmd_no = cmd_no;
    pw = pw;

    if (rmamem_status == RMAMEM_UNITIALISED)
        {

        memset(odbcquerytype.boundparameters,0,sizeof(odbcquerytype.boundparameters));
        strcpy(rmamem_name,"ODBCManager");
        rmamem_init(RMAMEM_UNITIALISED);
        }

    if (cmd_no == 0)
        {
        printf("   ODBC Manager Status\n");
        printf("      Query type: %d\n",odbcquerytype.type);
        printf("   Query subtype: %d\n",odbcquerytype.subtype);
        printf("           State: %d\n",odbcquerytype.state);
        printf("           Reply: %d\n",odbcquerytype.reply);
        printf("            Task: %d\n",odbcquerytype.task);
        printf("      Parameters: %d (%d)\n",odbcparameter_index,(int)odbcquerytype.parameters);

        index = 0;

        while (index < odbcparameter_index)
            {
            printf("     Type: %d   Size: %d   Value: %d\n",
                   odbcquerytype.parameters[index].type,
                   odbcquerytype.parameters[index].size,
                   odbcquerytype.parameters[index].value);
            index++;
            }

        printf("Bound parameters: (%d)\n",(int)odbcquerytype.boundparameters);

        index = 0;

        while (index < ODBCLIBMAXBOUNDPARAMETERS)
            {
            if (odbcquerytype.boundparameters[index].stmt != 0)
                {
                printf("    %d   %d -> %d   Size: %d\n",
                   odbcquerytype.boundparameters[index].stmt,
                   odbcquerytype.boundparameters[index].data,
                   odbcquerytype.boundparameters[index].rmadata,
                   odbcquerytype.boundparameters[index].size);
                }
            index++;
            }

        printf("\n\n");
        }

    return NULL;
    }
