Скачиваний:
20
Добавлен:
01.05.2014
Размер:
1.38 Кб
Скачать
/*
 * Please do not edit this file.
 * It was generated using rpcgen.
 */

#ifndef _SHELL_H_RPCGEN
#define	_SHELL_H_RPCGEN

#include <iostream.h>
#include <rpc/rpc.h>
#include <thread.h>
#include <string.h>

#define	SHELLPROG ((unsigned long)(0x20000001))
#define	SHELLVER  ((unsigned long)(1))
#define	EXECSHELL ((unsigned long)(1))

typedef void* (*FNPTR)( void *);

class shellObj {
      char*   help_msg;
      FNPTR   action; 
      void*   (*fnptr)( void* );
      int     create_thread;
   public:
      // constructor. Set help msg, action func, and errno
      shellObj( const char* msg, FNPTR func, int thr_ok=1) {
           help_msg = new char[strlen(msg)+1];
           strcpy(help_msg,msg);
           action  = func;
           create_thread = thr_ok;
      };

      // destructor function 
      ~shellObj() { delete help_msg; };

      ostream& usage( ostream& os, int idx) {
           os << idx << ": " << help_msg << endl;
           return os;
      };

      // do action via a thread
      int doit( void* argp ) {
          if (create_thread) {
             thread_t  tid;
             if (thr_create(0,0,action,argp,THR_DETACHED,&tid))
   		perror("thr_create");
             return (int)tid;
          }
          else return (int)action(argp);
      };
};
            
#endif /* !_SHELL_H_RPCGEN */
Соседние файлы в папке main_shell