2026-04-01 18:51:13 +01:00
|
|
|
#include "file.h"
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
extern int __fputc(int c, struct __opaque_file *stream);
|
|
|
|
|
|
|
|
|
|
int fputs(const char *restrict str, struct __opaque_file *restrict stream)
|
|
|
|
|
{
|
|
|
|
|
__libc_file_lock(stream);
|
|
|
|
|
if (stream->f_flags & (FILE_EOF | FILE_ERR)) {
|
|
|
|
|
__libc_file_unlock(stream);
|
|
|
|
|
return EOF;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t i = 0;
|
|
|
|
|
int err = 0;
|
|
|
|
|
for (i = 0; str[i]; i++) {
|
|
|
|
|
err = __fputc(str[i], stream);
|
|
|
|
|
if (err < 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__libc_file_unlock(stream);
|
|
|
|
|
|
|
|
|
|
if (i > 0) {
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
}
|