home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextLibrary / Documentation / NextDev / Examples / ServerVsHandler / simple_handler / simple_server.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-27  |  1.3 KB  |  77 lines

  1. /*
  2.  * Simple loadable kernel server example.
  3.  *
  4.  * This server accepts two messages:
  5.  *    simple_puts() prints the (inline string) argument on the console.
  6.  *    simple_vers() returns the running kernel's version string.
  7.  */
  8. #include "simple_handler.h"
  9. #include <kernserv/kern_server_types.h>
  10. #include <sys/mig_errors.h>
  11.  
  12. kern_return_t s_puts (
  13.     void        *arg,
  14.     simple_msg_t    string);
  15.  
  16. kern_return_t s_vers (
  17.     void        *arg,
  18.     simple_msg_t    string);
  19.  
  20. simple_t simple = {
  21.     0,
  22.     100,
  23.     s_puts,
  24.     s_vers
  25. };
  26.  
  27. death_pill_t *simple_outmsg;
  28.  
  29. /*
  30.  * Allocate an instance variable to be used by the kernel server interface
  31.  * routines for initializing and accessing this service.
  32.  */
  33. kern_server_t instance;
  34.  
  35. /*
  36.  * Stamp our arival.
  37.  */
  38. void simple_init(void)
  39. {
  40.     simple_outmsg = (death_pill_t *)kalloc(SIMPLE_OUTMSG_SIZE);
  41.     printf("Simple kernel server initialized\n");
  42. }
  43.  
  44. /*
  45.  * Notify the world that we're going away.
  46.  */
  47. void simple_signoff(void)
  48. {
  49.     kfree(simple_outmsg, SIMPLE_OUTMSG_SIZE);
  50.     simple_outmsg = 0;
  51.     printf("Simple kernel server unloaded\n");
  52. }
  53.  
  54. /*
  55.  * Print the passed string on the console.
  56.  */
  57. kern_return_t s_puts (
  58.     void        *arg,
  59.     simple_msg_t    string)
  60. {
  61.     printf(string);
  62.     return KERN_SUCCESS;
  63. }
  64.  
  65. /*
  66.  * Return the kernel version string to the caller.
  67.  */
  68. kern_return_t s_vers (
  69.     void        *arg,
  70.     simple_msg_t    string)
  71. {
  72.     extern char version[];
  73.     strcpy(string, version);
  74.     return KERN_SUCCESS;
  75. }
  76.  
  77.