PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/hnb-1.9.18.pre7/src/query.c

#
C | 52 lines | 24 code | 5 blank | 23 comment | 1 complexity | a683ee1f59fc3097e7bdc58d35a1f030 MD5 | raw file
Possible License(s): GPL-2.0
  1. /*
  2. * query.c -- querying the user for input
  3. *
  4. *
  5. * Copyright (C) 2001,2003 ?yvind Kol?s <pippin@users.sourceforge.net>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it under
  8. * the terms of the GNU General Public License as published by the Free
  9. * Software Foundation; either version 2, or (at your option) any later
  10. * version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program; if not, write to the Free Software Foundation, Inc., 59
  19. * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. #include <string.h>
  22. #include "tree.h"
  23. #include "prefs.h"
  24. #include "ui.h"
  25. #include <cli.h>
  26. static char query[100];
  27. static void* getquery_cmd (int argc, char **argv, void *data)
  28. {
  29. Node *pos = (Node *) data;
  30. strcpy (query, "");
  31. if(argc==2)
  32. ui_getstr (argv[1], &query[0]);
  33. else
  34. ui_getstr ("enter string", &query[0]);
  35. return pos;
  36. }
  37. /*
  38. !init_query();
  39. */
  40. void init_query ()
  41. {
  42. cli_add_command ("getquery", getquery_cmd, "<prompt>");
  43. cli_add_help ("getquery",
  44. "Input a string from the user (put into the variable query, used by amongst other function the search function, and at least some of the export/import functions");
  45. cli_add_string ("query", query,
  46. "last query (also settable as a variable)");
  47. }