This folder contains my console user interface library using NCurses.

The most interesting thing here is located within the file "loader.c": It
contains a dialog loader which is able to create a dialog from an XML
file, to populate it with data to be presented to the user and to retrieve
the data modified by the user.


The following is a minimal program to execute a dialog:

--------------------------------------------------------------------X8
int test(int argc, char **argv) {
  GWEN_XMLNODE *n;
  GWEN_XMLNODE *nn;
  GWEN_DB_NODE *dbData;
  GWEN_BUFFER *errMsg;
  int res;

  if (argc<2) {
    fprintf(stderr, "Name of testfile needed.\n");
    return 1;
  }
  n=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag,"root");
  GWEN_Logger_SetLevel(0, GWEN_LoggerLevelDebug);
  if (GWEN_XML_ReadFile(n, argv[1], GWEN_XML_FLAGS_DEFAULT)) {
    fprintf(stderr, "Error reading XML file.\n");
    return 1;
  }

  nn=GWEN_XMLNode_GetFindFirstTag(n, "widget", "name", "dlgConnectionData");
  if (!nn) {
    DBG_ERROR(0, "Dialog not found");
    return 1;
  }

  /* data could as well be read from a file... */
  dbData=GWEN_DB_Group_new("dialogData");
  /* preset with default data */
  GWEN_DB_SetCharValue(dbData, GWEN_DB_FLAGS_DEFAULT,
                       "type", "private");
  GWEN_DB_SetCharValue(dbData, GWEN_DB_FLAGS_DEFAULT,
                       "addr", "127.0.0.1");
  GWEN_DB_SetIntValue(dbData, GWEN_DB_FLAGS_DEFAULT,
                      "port", 32891);

  /* initialize UI */
  DBG_NOTICE(0, "Initializing UI");
  if (GWEN_UI_Begin()) {
    DBG_ERROR(0, "Could not init UI");
    return 2;
  }

  /* load, run and evaluate */
  res=GWEN_UILoader_ExecDialog(0, nn, dbData);
  DBG_NOTICE(0, "Response was: %d", res);
  
  /* deinit UI */
  DBG_NOTICE(0, "Deinitializing UI");
  if (GWEN_UI_End()) {
    DBG_ERROR(0, "Could not deinit UI");
    return 2;
  }

  /* show result if the user pressed ok */
  if (res==1) {
    GWEN_DB_Dump(dbData, stderr, 2);
  }

  return 0;
}


--------------------------------------------------------------------X8



