Compare commits
2 Commits
1f5073d0ac
...
04f49a6819
Author | SHA1 | Date |
---|---|---|
|
04f49a6819 | |
|
d465ea2a67 |
|
@ -24,7 +24,7 @@ struct ifreq
|
||||||
struct sockaddr ifru_netmask;
|
struct sockaddr ifru_netmask;
|
||||||
struct sockaddr ifru_gwaddr;
|
struct sockaddr ifru_gwaddr;
|
||||||
struct sockaddr ifru_hwaddr;
|
struct sockaddr ifru_hwaddr;
|
||||||
unsigned char __min_storage[sizeof(sockaddr) + 6];
|
unsigned char __min_storage[sizeof(struct sockaddr) + 6];
|
||||||
} ifr_ifru;
|
} ifr_ifru;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
#define __need_size_t 1
|
#define __need_size_t
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#define TTY_CMD_SET 0x01
|
#define TTY_CMD_SET 0x01
|
||||||
|
|
|
@ -102,6 +102,15 @@ char* ctermid(char* buffer)
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dprintf(int fildes, const char* __restrict format, ...)
|
||||||
|
{
|
||||||
|
va_list arguments;
|
||||||
|
va_start(arguments, format);
|
||||||
|
int ret = vdprintf(fildes, format, arguments);
|
||||||
|
va_end(arguments);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int fclose(FILE* file)
|
int fclose(FILE* file)
|
||||||
{
|
{
|
||||||
ScopeLock _(file);
|
ScopeLock _(file);
|
||||||
|
@ -811,6 +820,41 @@ int ungetc(int c, FILE* stream)
|
||||||
return ungetc_unlocked(c, stream);
|
return ungetc_unlocked(c, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int vdprintf(int fildes, const char* __restrict format, va_list arguments)
|
||||||
|
{
|
||||||
|
struct print_info
|
||||||
|
{
|
||||||
|
int fildes;
|
||||||
|
size_t offset;
|
||||||
|
char buffer[512];
|
||||||
|
};
|
||||||
|
|
||||||
|
print_info info {
|
||||||
|
.fildes = fildes,
|
||||||
|
.offset = 0,
|
||||||
|
.buffer = {},
|
||||||
|
};
|
||||||
|
|
||||||
|
const int ret = printf_impl(format, arguments,
|
||||||
|
[](int c, void* _info) -> int
|
||||||
|
{
|
||||||
|
auto* info = static_cast<print_info*>(_info);
|
||||||
|
info->buffer[info->offset++] = c;
|
||||||
|
if (info->offset >= sizeof(info->buffer))
|
||||||
|
{
|
||||||
|
write(info->fildes, info->buffer, info->offset);
|
||||||
|
info->offset = 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}, static_cast<void*>(&info)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (info.offset)
|
||||||
|
write(info.fildes, info.buffer, info.offset);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int vfprintf(FILE* file, const char* format, va_list arguments)
|
int vfprintf(FILE* file, const char* format, va_list arguments)
|
||||||
{
|
{
|
||||||
ScopeLock _(file);
|
ScopeLock _(file);
|
||||||
|
|
Loading…
Reference in New Issue