home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / hl10osrc.lzh / EditLibr / EditLibr.cc < prev    next >
C/C++ Source or Header  |  1994-04-23  |  3KB  |  111 lines

  1. /* -*- Mode: C -*- */
  2. /* EditLibr.cc - Librarian Card Catalog editor
  3.  * Created by Robert Heller on Tue Dec 10 19:37:26 1991
  4.  *
  5.  * ------------------------------------------------------------------
  6.  * Home Libarian by Deepwoods Software
  7.  * Edit a Librarian Card Catalog file
  8.  * ------------------------------------------------------------------
  9.  * Modification History:
  10.  * ------------------------------------------------------------------
  11.  * Contents:
  12.  * ------------------------------------------------------------------
  13.  * 
  14.  * 
  15.  * Copyright (c) 1991,1992 by Robert heller (D/B/A Deepwoods Software)
  16.  *        All Rights Reserved
  17.  * 
  18.  */
  19.  
  20. #include <stream.h>
  21. #include <vBTree.h>
  22. #include <ctype.h>
  23. #ifdef MESSYDOS
  24. #include <CardRec.h>
  25. #include <ListRec.h>
  26. #else
  27. #include <CardRecord.h>
  28. #include <ListRecord.h>
  29. #endif
  30. #include <Terminal.h>
  31. #ifdef MESSYDOS
  32. #include <CmdScren.h>
  33. #else
  34. #include <CommandScreen.h>
  35. #endif
  36. #define VERSION "V1.0Beta"
  37. #include "EditLibr.h"
  38. #define MAIN
  39. #include "EditDefs.h"
  40. #include "EditGlob.h"
  41.  
  42. static int Quit()
  43. {
  44.     return 0;
  45. }
  46.  
  47. static int SpawnShell()
  48. {
  49.     static char* shellargs[] = {
  50.         ShellCommand,
  51.         0
  52.     };
  53.     int status = Term->forkprog(shellargs);
  54.     if (status < 0) return(1);
  55.     else return(-1);
  56. }
  57.  
  58. int EditCard();
  59. int DeleteCard();
  60. int DeleteByAuthor();
  61. int DeleteByTitle();
  62. int DeleteBySubj();
  63. int ListCards();
  64. int ListTitles();
  65. int ListAuthors();
  66. int ListSubjects();
  67.  
  68.  
  69. static CommandDescr Main[] = {
  70.     { "Quit", Quit, 0 },
  71.     { "Edit a Card", EditCard, 0 },
  72.     { "Delete a Card", DeleteCard, 0 },
  73.     { "Delete by Author", DeleteByAuthor, 0 },
  74.     { "Delete by Title", DeleteByTitle, 0 },
  75.     { "Delete by Subject", DeleteBySubj, 0 },
  76.     { "List Cards", ListCards, 0 },
  77.     { "List Titles", ListTitles, 0 },
  78.     { "List Authors", ListAuthors, 0 },
  79.     { "List Subjects", ListSubjects, 0 },
  80.     { "Spawn Shell", SpawnShell, 0}
  81. };
  82.  
  83. const NumCommands = sizeof(Main) / sizeof(CommandDescr);
  84.  
  85. main(int argc,char** argv)
  86. {
  87.     static EditLibr args(argc,argv);
  88.     OpenMode omode = ReadWrite;
  89.     if (args.minpages_passed) omode = (OpenMode)(ReadWrite|Create);
  90.     vBTree tree(args.editfile,omode,args.minpages);
  91.     if (tree.OpenStat() == failure) {
  92.         int error = errno;
  93.         cerr << "Could not open " << args.editfile << ": "
  94.              << strerror(error) << "\n";
  95.         exit(error);
  96.     }
  97.     Terminal term;
  98.     Term = &term;
  99.     static CommandScreen mainScreen("Main Command Menu",NumCommands,Main);
  100.     Tree = &tree;
  101.  
  102.     char* p = getenv("SHELL");
  103.     if (p == 0) strcpy(ShellCommand,DEFAULTSHELL);
  104.     else strcpy(ShellCommand,p);
  105.  
  106.     mainScreen.RunScreen();
  107. }
  108.  
  109.  
  110.  
  111.