home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yeah09.zip / samples / readsub / readsub.cpp < prev   
Text File  |  1996-05-25  |  1KB  |  47 lines

  1. //------------------------------------------------------------
  2. //
  3. // Name:     readsub.cpp
  4. // Version:  0.9
  5. // Author:   Björn Fahller.
  6. //
  7. // Copyright (C) Björn Fahller, 1996.
  8. //
  9. // Purpose:  Show how to read an extended attribute of known
  10. //           type and name (.SUBJECT is always a string.)
  11. //
  12. // History:
  13. //          Ver.  Date         What
  14. //          0.9   1996-05-26   First official release.
  15. //
  16. //------------------------------------------------------------
  17.  
  18. #include <YEA.H>
  19. #include <iostream.h>
  20.  
  21. int main(int argc, char* argv[])
  22. {
  23.   try {
  24.     if (argc != 2)
  25.     {
  26.       cerr << "Usage: " << argv[0] << ": filename" << endl;
  27.       return -1;
  28.     }
  29.  
  30.     StringEA subject(argv[1],".SUBJECT");
  31.     cout << ".SUBJECT for \"" << argv[1] << "\" is \"" << subject << "\"" << endl;
  32.   }
  33.   catch (EAError& e)
  34.   {
  35.     cerr << "Oops, something was wrong here..." << endl;
  36.     cerr << e.name() << endl;
  37.     for (unsigned i=0; i < e.textCount(); ++i)
  38.     {
  39.       cerr << e.text(i) << endl;
  40.     }
  41.  
  42.     cerr << endl << "Error code = " << e.errorId()
  43.          << " (" << hex << e.errorId() << ')' << endl;
  44.   }
  45.   return 0;
  46. }
  47.