home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / microcode / uxyp.c < prev    next >
C/C++ Source or Header  |  1999-01-02  |  2KB  |  82 lines

  1. /* -*-C-*-
  2.  
  3. $Id: uxyp.c,v 1.3 1999/01/02 06:11:34 cph Exp $
  4.  
  5. Copyright (c) 1987-1999 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21.  
  22. /* Interfacte to the Yellow Pages server */
  23.  
  24. #include "scheme.h"
  25. #include "prims.h"
  26. #include <stdio.h>
  27. #include <malloc.h>
  28. #include <ntl.h>
  29. #include <rpc/rpc.h>
  30. #include "uxyp.h"
  31.  
  32. #define YP_HOST "polar.lcs.mit.edu"
  33.  
  34. /*
  35.  * Please do not edit this procedure.
  36.  * It was generated using rpcgen.
  37.  */
  38.  
  39. /* Default timeout can be changed using clnt_control() */
  40. static struct timeval TIMEOUT = { 25, 0 };
  41.  
  42. char **
  43. do_yp_frame_1(argp, clnt)
  44.         char **argp;
  45.         CLIENT *clnt;
  46. {
  47.         static char *res;
  48.  
  49.         bzero((char *)&res, sizeof(res));
  50.         if (clnt_call(clnt, do_yp_frame, xdr_wrapstring, argp, xdr_wrapstring, &res, TIMEOUT) != RPC_SUCCESS) {
  51.                 return (NULL);
  52.         }
  53.         return (&res);
  54. }
  55.  
  56. static int yp_debug = 0;
  57. CLIENT *cl = NULL;
  58.  
  59. DEFINE_PRIMITIVE ("YELLOW-PAGES-LOOKUP", Prim_yellow_pages_lookup, 1, 1, 0)
  60. {
  61.   PRIMITIVE_HEADER (1);
  62.   CHECK_ARG (1, STRING_P);
  63.   {
  64.     fast SCHEME_OBJECT string = (ARG_REF (1));
  65.     unsigned char *c_string = STRING_LOC(string,0);
  66.     unsigned char **result;
  67.     
  68.     /*
  69.      * Do remote call
  70.      */
  71.     if(cl == NULL){
  72.       cl = clnt_create(YP_HOST,yp_server,yp_server_version,"tcp");
  73.       if(cl == NULL){
  74.     clnt_pcreateerror(YP_HOST);
  75.     return(NULL);
  76.       }
  77.     }
  78.     result = (unsigned char **) do_yp_frame_1(&c_string,cl);
  79.     PRIMITIVE_RETURN (char_pointer_to_string(*result));
  80.   }
  81. }
  82.