00001 #ifndef _SCBUF_C_
00002 #define _SCBUF_C_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #define STP_BUF_LEN 8191
00016
00017
00018 char _stp_scbuf[STP_BUF_LEN+1];
00019 static int _stp_scbuf_len = STP_BUF_LEN;
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 void _stp_sprint (const char *fmt, ...)
00033 {
00034 int num;
00035 va_list args;
00036 char *buf = _stp_scbuf + STP_BUF_LEN - _stp_scbuf_len;
00037 va_start(args, fmt);
00038 num = vscnprintf(buf, _stp_scbuf_len, fmt, args);
00039 va_end(args);
00040 if (num > 0)
00041 _stp_scbuf_len -= num;
00042 }
00043
00044 void _stp_sprint_str (const char *str)
00045 {
00046 char *buf = _stp_scbuf + STP_BUF_LEN - _stp_scbuf_len;
00047 int num = strlen (str);
00048 if (num > _stp_scbuf_len)
00049 num = _stp_scbuf_len;
00050 strncpy (buf, str, num);
00051 _stp_scbuf_len -= num;
00052 }
00053
00054
00055
00056
00057
00058
00059 void _stp_scbuf_clear (void)
00060 {
00061 _stp_scbuf_len = STP_BUF_LEN;
00062 _stp_scbuf[0] = 0;
00063 }
00064
00065 static char *_stp_scbuf_cur (void)
00066 {
00067 return _stp_scbuf + STP_BUF_LEN - _stp_scbuf_len;
00068 }
00069
00070
00071 #endif