MCPcopy Create free account
hub / github.com/coreboot/coreboot / vtxprintf

Function vtxprintf

src/console/vtxprintf.c:101–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101int vtxprintf(void (*tx_byte)(unsigned char byte, void *data), const char *fmt, va_list args,
102 void *data)
103{
104 int len;
105 unsigned long long num;
106 int i, base;
107 const char *s;
108
109 int flags; /* flags to number() */
110
111 int field_width; /* width of output field */
112 int precision; /* min. # of digits for integers; max
113 number of chars for from string */
114 int qualifier; /* 'h', 'H', 'l', 'L', 'z', or 'j' for integer fields */
115
116 int count;
117
118 for (count = 0; *fmt; ++fmt) {
119 if (*fmt != '%') {
120 call_tx(*fmt), count++;
121 continue;
122 }
123
124 /* process flags */
125 flags = 0;
126repeat:
127 ++fmt; /* this also skips first '%' */
128 switch (*fmt) {
129 case '-': flags |= LEFT; goto repeat;
130 case '+': flags |= PLUS; goto repeat;
131 case ' ': flags |= SPACE; goto repeat;
132 case '#': flags |= SPECIAL; goto repeat;
133 case '0': flags |= ZEROPAD; goto repeat;
134 }
135
136 /* get field width */
137 field_width = -1;
138 if (isdigit(*fmt)) {
139 field_width = skip_atoi((char **)&fmt);
140 } else if (*fmt == '*') {
141 ++fmt;
142 /* it's the next argument */
143 field_width = va_arg(args, int);
144 if (field_width < 0) {
145 field_width = -field_width;
146 flags |= LEFT;
147 }
148 }
149
150 /* get the precision */
151 precision = -1;
152 if (*fmt == '.') {
153 ++fmt;
154 if (isdigit(*fmt)) {
155 precision = skip_atoi((char **)&fmt);
156 } else if (*fmt == '*') {
157 ++fmt;
158 /* it's the next argument */

Callers 4

vsnprintfFunction · 0.85
wrap_interactive_printfFunction · 0.85
vprintkFunction · 0.85

Calls 4

skip_atoiFunction · 0.85
strnlenFunction · 0.85
numberFunction · 0.85
isdigitFunction · 0.50

Tested by

no test coverage detected