mirror of
https://github.com/SEPPDROID/Digital-Research-Source-Code.git
synced 2025-10-23 08:24:18 +00:00
41 lines
1.4 KiB
C
41 lines
1.4 KiB
C
/************************************************************************
|
|
*
|
|
* s p r i n t f F u n c t i o n
|
|
* -------------------------------
|
|
* Copyright 1982 by Digital Research Inc. All rights reserved.
|
|
*
|
|
* "sprintf" prints args specified in format string to a string
|
|
* pointed to by str. No checks for str overflow are possible.
|
|
* sprintf returns str.
|
|
*
|
|
* Calling sequence:
|
|
* s = sprintf(string,fmt,arg1,arg2,...argn);
|
|
* Where:
|
|
* string = place to put info
|
|
* fmt -> a string specifying how arg1-n are to be printed.
|
|
* s = number chars put to string
|
|
*
|
|
* 10/83 - return num chars printed (like printf & fprintf) whf
|
|
*
|
|
**************************************************************************/
|
|
|
|
#include "stdio.h"
|
|
|
|
WORD sprintf(str,fmt,args) /* CLEAR FUNCTION ***********/
|
|
BYTE *str,
|
|
*fmt,
|
|
*args;
|
|
{
|
|
FILE stream; /* pseudo stream tab */
|
|
REG FILE *sp; /* ptr thereto */
|
|
REG WORD rv; /* return val from _doprt */
|
|
/* */
|
|
sp = &stream; /* point to pseudo stream */
|
|
sp->_cnt = 32767; /* assume 'infinite' buf */
|
|
sp->_ptr = sp->_base = str; /* stream buf -> string */
|
|
sp->_flag = _IOWRT | _IOSTRI; /* writeable string */
|
|
sp->_fd = -1; /* insure no real i/o */
|
|
rv = _doprt(sp,fmt,&args); /* do the print */
|
|
putc(NULL,sp); /* NULL terminate string */
|
|
return(rv); /* tell user what happened */
|