home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / dn511.exe / LIST.CPP < prev    next >
C/C++ Source or Header  |  1995-01-09  |  901b  |  42 lines

  1. /*
  2. ** LIST [context]
  3. **
  4. **    List the object in the context container.
  5. **
  6. **    Author: John Buckle, Asia Pacific Support Centre, Novell Australia.
  7. */
  8.  
  9. # define DSCPP_IOSTREAM
  10.  
  11. # include "dslocale.h"
  12. # include "dsbuffer.h"
  13. # include "dsiterat.h"
  14.  
  15. class DSListIteration : public DSIteration
  16. {
  17. protected:
  18.     WORD        Count ;
  19. public:
  20.     NWDSCCODE    InitLoop()
  21.                 { return Count = 0 ; }
  22.     NWDSCCODE    InitObject(NWPSTR object, void * info)
  23.                 { cout << ++Count << "." << object << "\n" ;
  24.                   return 0 ; }
  25. } ;
  26.  
  27. int main(int argc, char * argv[])
  28. {
  29. DSLocale    dsLocale ;
  30. DSListIteration    dsListIteration ;
  31. DSBuffer    dsBuffer(argc == 2 ? argv[1] : "") ;
  32. char        context[MAX_DN_BYTES] ;
  33.  
  34.     if (dsLocale.status() || dsBuffer.status()) return 0 ;
  35.  
  36.     dsBuffer.GetContext(context) ;
  37.     cout << "Objects found under \"" << context << "\"\n" ;
  38.     dsBuffer.List("",& dsListIteration) ;
  39.  
  40.     return 0 ;
  41. }
  42.