home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / unix / vim-6.2.tar.bz2 / vim-6.2.tar / vim62 / src / if_perlsfio.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-13  |  1.8 KB  |  94 lines

  1. /* vi:set ts=8 sts=4 sw=4:
  2.  *
  3.  * VIM - Vi IMproved    by Bram Moolenaar
  4.  *
  5.  * Do ":help uganda"  in Vim to read copying and usage conditions.
  6.  * Do ":help credits" in Vim to see a list of people who contributed.
  7.  * See README.txt for an overview of the Vim source code.
  8.  */
  9. /*
  10.  * if_perlsfio.c: Special I/O functions for Perl interface.
  11.  */
  12.  
  13. #define _memory_h    /* avoid memset redeclaration */
  14. #define IN_PERL_FILE    /* don't include if_perl.pro from prot.h */
  15.  
  16. #include "vim.h"
  17.  
  18. /*
  19.  * Avoid clashes between Perl and Vim namespace.
  20.  */
  21. #undef NORMAL
  22. #undef STRLEN
  23. #undef FF
  24. #undef OP_DELETE
  25. #undef OP_JOIN
  26. /* remove MAX and MIN, included by glib.h, redefined by sys/param.h */
  27. #ifdef MAX
  28. # undef MAX
  29. #endif
  30. #ifdef MIN
  31. # undef MIN
  32. #endif
  33. /* We use _() for gettext(), Perl uses it for function prototypes... */
  34. #ifdef _
  35. # undef _
  36. #endif
  37. #ifdef DEBUG
  38. # undef DEBUG
  39. #endif
  40.  
  41. #include <EXTERN.h>
  42. #include <perl.h>
  43. #include <XSUB.h>
  44.  
  45. #if defined(USE_SFIO) || defined(PROTO)
  46.  
  47. #ifndef USE_SFIO    /* just generating prototypes */
  48. # define Sfio_t int
  49. # define Sfdisc_t int
  50. #endif
  51.  
  52. #define NIL(type)    ((type)0)
  53.  
  54.     static int
  55. sfvimwrite(f, buf, n, disc)
  56.     Sfio_t        *f;        /* stream involved */
  57.     char        *buf;    /* buffer to read from */
  58.     int            n;        /* number of bytes to write */
  59.     Sfdisc_t        *disc;    /* discipline */
  60. {
  61.     char_u *str;
  62.  
  63.     str = vim_strnsave((char_u *)buf, n);
  64.     if (str == NULL)
  65.     return 0;
  66.     msg_split((char *)str);
  67.     vim_free(str);
  68.  
  69.     return n;
  70. }
  71.  
  72. /*
  73.  * sfdcnewnvi --
  74.  *  Create Vim discipline
  75.  */
  76.     Sfdisc_t *
  77. sfdcnewvim()
  78. {
  79.     Sfdisc_t    *disc;
  80.  
  81.     disc = (Sfdisc_t *)alloc((unsigned)sizeof(Sfdisc_t));
  82.     if (disc == NULL)
  83.     return NULL;
  84.  
  85.     disc->readf = (Sfread_f)NULL;
  86.     disc->writef = sfvimwrite;
  87.     disc->seekf = (Sfseek_f)NULL;
  88.     disc->exceptf = (Sfexcept_f)NULL;
  89.  
  90.     return disc;
  91. }
  92.  
  93. #endif /* USE_SFIO */
  94.