From 8e07c1db6ba4bedd0f8fe537a6fb0ca80e5d25f4 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Sat, 19 May 2012 15:56:25 +0200 Subject: Better sprintf, vsprintf, String::sprintf, etc. --- src/user/lib/libc/include/stdio.h | 13 +++++-------- src/user/lib/libc/include/string.h | 4 ++++ src/user/lib/libc/include/tce/syscall.h | 16 ++++++++-------- 3 files changed, 17 insertions(+), 16 deletions(-) (limited to 'src/user/lib/libc/include') diff --git a/src/user/lib/libc/include/stdio.h b/src/user/lib/libc/include/stdio.h index d93ebf0..f19ce60 100644 --- a/src/user/lib/libc/include/stdio.h +++ b/src/user/lib/libc/include/stdio.h @@ -10,16 +10,13 @@ extern "C" { namespace libc { extern FILE term; -void print(char *s); -void printf(char *s, ...); +void print(const char *s); +void printf(const char *s, ...); char *readln(); -void fprint(FILE f, char *s); -void fprint_int(FILE f, int number); -void fprint_hex(FILE f, unsigned number); -void fprintf(FILE f, char *s, ...); - -void vfprintf(FILE f, char *s, va_list arg); +void fprint(FILE f, const char *s); +void fprintf(FILE f, const char *s, ...); +void vfprintf(FILE f, const char *s, va_list arg); #ifdef __cplusplus } } diff --git a/src/user/lib/libc/include/string.h b/src/user/lib/libc/include/string.h index 54fdf7a..5b86868 100644 --- a/src/user/lib/libc/include/string.h +++ b/src/user/lib/libc/include/string.h @@ -2,6 +2,7 @@ #define DEF_LIB_STRING_H #include +#include #ifdef __cplusplus extern "C" { namespace libc { @@ -20,6 +21,9 @@ int strcmp(const char *s1, const char *s2); char* format_int(char* buf, int number); char* format_hex(char *buf, unsigned v); +int printf_str_len(const char *fmt, va_list arg); +int vsprintf(char *buf, const char *fmt, va_list arg); +int sprintf(char *buf, const char *fmt, ...); #ifdef __cplusplus } } diff --git a/src/user/lib/libc/include/tce/syscall.h b/src/user/lib/libc/include/tce/syscall.h index 6ad37f1..6679f1a 100644 --- a/src/user/lib/libc/include/tce/syscall.h +++ b/src/user/lib/libc/include/tce/syscall.h @@ -15,7 +15,7 @@ void thread_exit(); void schedule(); void thread_sleep(int time); void process_exit(int retval); -void printk(char* str); +void printk(const char* str); void thread_new(void (*entry)(void*), void *data); void irq_wait(int number); int proc_priv(); @@ -23,18 +23,18 @@ int proc_priv(); void* sbrk(ptrdiff_t size); void brk(void* ptr); -int run(char* file, char** args, FILE zero_fd); +int run(const char* file, const char** args, FILE zero_fd); int waitpid(int pid, int block); -FILE open(char* filename, int mode); -FILE open_relative(FILE root, char* filename, int mode); -int stat(char* filename, file_info *info); -int stat_relative(FILE root, char* filename, file_info *info); +FILE open(const char* filename, int mode); +FILE open_relative(FILE root, const char* filename, int mode); +int stat(const char* filename, file_info *info); +int stat_relative(FILE root, const char* filename, file_info *info); int statf(FILE file, file_info *info); void close(FILE file); int read(FILE file, size_t offset, size_t len, char *buffer); -int write(FILE file, size_t offset, size_t len, char *buffer); -int link(char* from, char* to, int mode); +int write(FILE file, size_t offset, size_t len, const char *buffer); +int link(const char* from, const char* to, int mode); #ifdef __cplusplus } } -- cgit v1.2.3