#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <exec/types.h>

#include <dialog/user.h>
#include <dialog/input.h>

#include <proto/dlg.h>


extern struct USER_DATA StUser;
extern struct Ram_File  RStruct;
extern struct Library  *DLGBase;


long DLGInput(char *query,
             char *template,
             char *string,
             char *defstring,
             USHORT length,
             USHORT typelength,
             char  ftype)

{struct UserInfo  *ui = NULL;
 struct Query     *q = NULL;

   ui = calloc(1,sizeof(struct UserInfo));
   q =  calloc(1,sizeof(struct Query));

 q->prompt     = query;
 q->template   = template;
 q->string     = string;
 q->defstring  = (char *)defstring;
 q->valid      = NULL;
 q->length     = length;
 q->typelength = typelength;
 q->flags      = 0;

 switch(ftype)
       {case 1: q->flags |=  QUERY_UPCASE;
                break;
        case 2: q->flags |=  QUERY_HIDDEN;
                break;
        case 3: q->flags |=  QUERY_CAPITAL;
                break;
        case 4: q->valid  = "0123456789-";
                break;
        case 5: q->flags |=  QUERY_UPCASE;
                q->valid  = "YyNn";
                break;
        case 6: q->flags |=  QUERY_GUESS;
                break;
        case 7: q->flags |=  QUERY_NOSTACK;
                break;
        case 8: q->flags |=  QUERY_CAPITAL;
                q->flags |=  QUERY_GUESS;
                break;
       }

 if ((LONG)template == 1)
    {q->template = NULL;
     q->flags   |= QUERY_NODEFEDT;
    }

 ui->User = &StUser;
 ui->Ram  = &RStruct;

 Chk_Abort();
 return(DLGQuery(q, ui));
}

/// iinput
int iinput(char *query, int lower, int upper, int def)
{
   struct UserInfo  ui;

   ui.User = &StUser;
   ui.Ram  = &RStruct;

   Chk_Abort();
   return(IntQuery(query, lower, upper, def, &ui));
}
//-

char finput(char *query, char opt)

{struct UserInfo  ui;

 ui.User = &StUser;
 ui.Ram  = &RStruct;

 Chk_Abort();
 return((char)BoolQuery(query, opt, &ui));
}       
