PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
TextDevices
libsimpletext
dosput.c
1
/*
2
* very simple printf, adapted from one written by me
3
* for the MiNT OS long ago
4
* placed in the public domain
5
* - Eric Smith
6
* 32 bit mode only. %b, %e, %f, %g added by Steve Denson
7
*/
8
#include <ctype.h>
9
#include <stdarg.h>
10
#include "
simpletext.h
"
11
12
int
SPUTC(
int
c,
char
*buf)
13
{
14
*buf++ = c;
15
return
1;
16
}
17
18
int
SPUTS(
char
*s,
char
*obuf)
19
{
20
char
*buf = obuf;
21
while
(*s) {
22
buf += SPUTC(*s++, buf);
23
}
24
return
buf-obuf;
25
}
26
27
28
int
SPUTL(
unsigned
long
u,
int
base,
int
width,
int
fill_char,
char
*obuf)
29
{
30
int
r = 0;
31
static
char
outbuf[32];
32
char
*t;
33
char
*buf = obuf;
34
35
t = outbuf;
36
37
do
{
38
*t++ =
"0123456789abcdef"
[u % base];
39
u /= base;
40
width--;
41
}
while
(u > 0);
42
43
while
(width-- > 0) {
44
buf += SPUTC(fill_char,buf);
45
r++;
46
}
47
while
(t != outbuf) {
48
buf += SPUTC(*--t, buf);
49
r++;
50
}
51
return
buf-obuf;
52
}
53
54
55
/* +--------------------------------------------------------------------
56
* | TERMS OF USE: MIT License
57
* +--------------------------------------------------------------------
58
* Permission is hereby granted, free of charge, to any person obtaining
59
* a copy of this software and associated documentation files
60
* (the "Software"), to deal in the Software without restriction,
61
* including without limitation the rights to use, copy, modify, merge,
62
* publish, distribute, sublicense, and/or sell copies of the Software,
63
* and to permit persons to whom the Software is furnished to do so,
64
* subject to the following conditions:
65
*
66
* The above copyright notice and this permission notice shall be
67
* included in all copies or substantial portions of the Software.
68
*
69
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
70
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
71
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
72
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
73
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
74
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
75
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
76
* +--------------------------------------------------------------------
77
*/
simpletext.h
This library provides a collection of functions for communicating with text devices such as SimpleIDE...
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17