home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / linux / backup / star-1.3.1.tar.gz / star-1.3.1.tar / star-1.3.1 / lib / jssprintf.c < prev    next >
C/C++ Source or Header  |  2000-05-07  |  2KB  |  67 lines

  1. /* @(#)jssprintf.c    1.14 00/05/07 Copyright 1985 J. Schilling */
  2. /*
  3.  *    Copyright (c) 1985 J. Schilling
  4.  */
  5. /*
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2, or (at your option)
  9.  * any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; see the file COPYING.  If not, write to
  18.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. #include <mconfig.h>
  22. #include <vadefs.h>
  23. #include <standard.h>
  24. #include <schily.h>
  25.  
  26. /*
  27.  * Do not include stdio.h, BSD systems define sprintf the wrong way!
  28.  */
  29. EXPORT    int js_sprintf __PR((char *, const char *, ...));
  30.  
  31. #ifdef    PROTOTYPES
  32. static void _cput(char c, long ba)
  33. #else
  34. static void _cput(c, ba)
  35.     char    c;
  36.     long    ba;
  37. #endif
  38. {
  39.     *(*(char **) ba)++ = c;
  40. }
  41.  
  42. /* VARARGS2 */
  43. #ifdef    PROTOTYPES
  44. int js_sprintf(char *buf, const char *form, ...)
  45. #else
  46. int js_sprintf(buf, form, va_alist)
  47.     char    *buf;
  48.     char    *form;
  49.     va_dcl
  50. #endif
  51. {
  52.     va_list    args;
  53.     int    cnt;
  54.     char    *bp = buf;
  55.  
  56. #ifdef    PROTOTYPES
  57.     va_start(args, form);
  58. #else
  59.     va_start(args);
  60. #endif
  61.     cnt = format(_cput, (long)&bp, form,  args);
  62.     va_end(args);
  63.     *bp = '\0';
  64.  
  65.     return (cnt);
  66. }
  67.