diff --git a/include/System/config.h b/include/System/config.h index c82bf45..bdb5073 100644 --- a/include/System/config.h +++ b/include/System/config.h @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2006-2012 Pierre Pronchery */ +/* Copyright (c) 2006-2013 Pierre Pronchery */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -19,15 +19,16 @@ # define LIBSYSTEM_CONFIG_H # include "hash.h" +# include "string.h" /* Config */ /* types */ typedef Hash Config; -typedef void (*ConfigForeachCallback)(char const * section, void * priv); -typedef void (*ConfigForeachSectionCallback)(char const * variable, - char const * value, void * priv); +typedef void (*ConfigForeachCallback)(String const * section, void * priv); +typedef void (*ConfigForeachSectionCallback)(String const * variable, + String const * value, void * priv); /* functions */ @@ -35,19 +36,19 @@ Config * config_new(void); void config_delete(Config * config); /* accessors */ -char const * config_get(Config * config, char const * section, - char const * variable); -int config_set(Config * config, char const * section, char const * variable, - char const * value); +String const * config_get(Config * config, String const * section, + String const * variable); +int config_set(Config * config, String const * section, String const * variable, + String const * value); /* useful */ void config_foreach(Config * config, ConfigForeachCallback callback, void * priv); -void config_foreach_section(Config * config, char const * section, +void config_foreach_section(Config * config, String const * section, ConfigForeachSectionCallback callback, void * priv); -int config_load(Config * config, char const * filename); +int config_load(Config * config, String const * filename); int config_reset(Config * config); -int config_save(Config * config, char const * filename); +int config_save(Config * config, String const * filename); #endif /* !LIBSYSTEM_CONFIG_H */ diff --git a/include/System/error.h b/include/System/error.h index fe74c28..dcf9652 100644 --- a/include/System/error.h +++ b/include/System/error.h @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2007-2012 Pierre Pronchery */ +/* Copyright (c) 2007-2013 Pierre Pronchery */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -18,17 +18,20 @@ #ifndef LIBSYSTEM_ERROR_H # define LIBSYSTEM_ERROR_H +# include "string.h" + /* functions */ /* accessors */ -char const * error_get(void); -char const * error_get_code(int * code); +String const * error_get(void); +String const * error_get_code(int * code); -void error_set(char const * format, ...); -int error_set_code(int code, char const * format, ...); -int error_set_print(char const * program, int code, char const * format, ...); +void error_set(String const * format, ...); +int error_set_code(int code, String const * format, ...); +int error_set_print(String const * program, int code, + String const * format, ...); /* useful */ -int error_print(char const * program); +int error_print(String const * program); #endif /* !LIBSYSTEM_ERROR_H */ diff --git a/src/array.c b/src/array.c index 4431957..c4d57a1 100644 --- a/src/array.c +++ b/src/array.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2005-2012 Pierre Pronchery */ +/* Copyright (c) 2005-2013 Pierre Pronchery */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -20,7 +20,9 @@ #include #include #include -#include "System.h" +#include "System/error.h" +#include "System/object.h" +#include "System/array.h" /* Array */ diff --git a/src/buffer.c b/src/buffer.c index c1016b6..4a57aac 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2006-2012 Pierre Pronchery */ +/* Copyright (c) 2006-2013 Pierre Pronchery */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -20,7 +20,9 @@ #include #include #include -#include "System.h" +#include "System/error.h" +#include "System/object.h" +#include "System/buffer.h" /* Buffer */ diff --git a/src/config.c b/src/config.c index 565c6e5..7f58ce2 100644 --- a/src/config.c +++ b/src/config.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2005-2012 Pierre Pronchery */ +/* Copyright (c) 2005-2013 Pierre Pronchery */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -22,7 +22,8 @@ #include #include #include -#include "System.h" +#include "System/error.h" +#include "System/config.h" /* Config */ diff --git a/src/error.c b/src/error.c index edfe6fa..ee373c0 100644 --- a/src/error.c +++ b/src/error.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2007-2012 Pierre Pronchery */ +/* Copyright (c) 2007-2013 Pierre Pronchery */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -17,44 +17,30 @@ #include #include -#include -#include "System.h" +#include "System/error.h" +/* Error */ /* private */ -/* error_do */ -static char const * _error_do(int * codeptr, char const * format, va_list args) -{ - static char buf[256] = ""; - static int code = 0; - - if(format != NULL) /* setting the error */ - { - vsnprintf(buf, sizeof(buf), format, args); - if(codeptr != NULL) - code = *codeptr; - return buf; - } - if(codeptr != NULL) - *codeptr = code; - return buf; -} +/* prototypes */ +static String const * _error_do(int * codeptr, String const * format, + va_list args); /* public */ /* accessors */ /* error_get */ -static char const * _get_do(char const * null, ...); +static String const * _get_do(String const * null, ...); -char const * error_get(void) +String const * error_get(void) { /* XXX workaround for portability */ return _get_do(NULL); } -static char const * _get_do(char const * null, ...) +static String const * _get_do(String const * null, ...) { - char const * ret; + String const * ret; va_list args; va_start(args, null); @@ -65,17 +51,17 @@ static char const * _get_do(char const * null, ...) /* error_get_code */ -static char const * _get_code_do(int * code, ...); +static String const * _get_code_do(int * code, ...); -char const * error_get_code(int * code) +String const * error_get_code(int * code) { /* XXX workaround for portability */ return _get_code_do(code); } -static char const * _get_code_do(int * code, ...) +static String const * _get_code_do(int * code, ...) { - char const * ret; + String const * ret; va_list args; va_start(args, code); @@ -86,7 +72,7 @@ static char const * _get_code_do(int * code, ...) /* error_set */ -void error_set(char const * format, ...) +void error_set(String const * format, ...) { va_list args; @@ -97,7 +83,7 @@ void error_set(char const * format, ...) /* error_set_code */ -int error_set_code(int code, char const * format, ...) +int error_set_code(int code, String const * format, ...) { va_list args; @@ -109,7 +95,7 @@ int error_set_code(int code, char const * format, ...) /* error_set_print */ -int error_set_print(char const * program, int code, char const * format, ...) +int error_set_print(String const * program, int code, String const * format, ...) { va_list args; @@ -122,15 +108,15 @@ int error_set_print(char const * program, int code, char const * format, ...) /* useful */ /* error_print */ -static int _print_do(char const * program, ...); +static int _print_do(String const * program, ...); -int error_print(char const * program) +int error_print(String const * program) { /* XXX workaround for portability */ return _print_do(program); } -static int _print_do(char const * program, ...) +static int _print_do(String const * program, ...) { int ret = 0; va_list args; @@ -146,3 +132,25 @@ static int _print_do(char const * program, ...) va_end(args); return ret; } + + +/* private */ +/* functions */ +/* error_do */ +static String const * _error_do(int * codeptr, String const * format, + va_list args) +{ + static String buf[256] = ""; + static int code = 0; + + if(format != NULL) /* setting the error */ + { + vsnprintf(buf, sizeof(buf), format, args); + if(codeptr != NULL) + code = *codeptr; + return buf; + } + if(codeptr != NULL) + *codeptr = code; + return buf; +} diff --git a/src/event.c b/src/event.c index 8d25b0d..f1bda80 100644 --- a/src/event.c +++ b/src/event.c @@ -32,7 +32,10 @@ typedef int suseconds_t; /* XXX */ # include #endif #include -#include "System.h" +#include "System/array.h" +#include "System/error.h" +#include "System/object.h" +#include "System/event.h" /* macros */ #ifndef max diff --git a/src/hash.c b/src/hash.c index fb25f8a..fdd10a4 100644 --- a/src/hash.c +++ b/src/hash.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2005-2012 Pierre Pronchery */ +/* Copyright (c) 2005-2013 Pierre Pronchery */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -17,7 +17,9 @@ #include #include -#include "System.h" +#include "System/error.h" +#include "System/object.h" +#include "System/hash.h" /* HashEntry */ diff --git a/src/object.c b/src/object.c index 6cc37e7..afb9733 100644 --- a/src/object.c +++ b/src/object.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2008-2012 Pierre Pronchery */ +/* Copyright (c) 2008-2013 Pierre Pronchery */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -21,7 +21,7 @@ #endif #include #include -#include "System.h" +#include "System/object.h" /* Object */ diff --git a/src/parser.c b/src/parser.c index d89dadf..4606d2d 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2008-2012 Pierre Pronchery */ +/* Copyright (c) 2008-2013 Pierre Pronchery */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -22,7 +22,9 @@ #include #include #include -#include "System.h" +#include "System/error.h" +#include "System/object.h" +#include "System/parser.h" #include "token.h" diff --git a/src/plugin.c b/src/plugin.c index 2c12f09..8b70c10 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2008-2012 Pierre Pronchery */ +/* Copyright (c) 2008-2013 Pierre Pronchery */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -24,7 +24,8 @@ #else # include #endif -#include "System.h" +#include "System/error.h" +#include "System/plugin.h" /* Plugin */ diff --git a/src/string.c b/src/string.c index 716cac1..8242628 100644 --- a/src/string.c +++ b/src/string.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2005-2012 Pierre Pronchery */ +/* Copyright (c) 2005-2013 Pierre Pronchery */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -22,7 +22,9 @@ #include #include #include -#include "System.h" +#include "System/error.h" +#include "System/object.h" +#include "System/string.h" /* String */ diff --git a/src/token.c b/src/token.c index 8a5a1c1..974c3e2 100644 --- a/src/token.c +++ b/src/token.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2008-2012 Pierre Pronchery */ +/* Copyright (c) 2008-2013 Pierre Pronchery */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -21,7 +21,10 @@ #ifdef DEBUG # include #endif -#include "System.h" +#include "System/error.h" +#include "System/object.h" +#include "System/string.h" +#include "System/token.h" #include "token.h" diff --git a/src/token.h b/src/token.h index ccda2c8..50d55e4 100644 --- a/src/token.h +++ b/src/token.h @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2010-2012 Pierre Pronchery */ +/* Copyright (c) 2010-2013 Pierre Pronchery */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -21,6 +21,7 @@ /* Token */ /* functions */ +/* protected */ Token * token_new(char const * filename, unsigned int line, unsigned int col); #endif /* !_LIBSYSTEM_TOKEN_H */ diff --git a/src/variable.c b/src/variable.c index ba8f439..338369e 100644 --- a/src/variable.c +++ b/src/variable.c @@ -20,7 +20,9 @@ #include #include #include -#include "System.h" +#include "System/error.h" +#include "System/object.h" +#include "System/variable.h" /* Variable */