Changeset 1064


Ignore:
Timestamp:
Jan 23, 2007, 1:09:32 AM (12 years ago)
Author:
bruno
Message:

More controls at the compiler level
still working with the problems around variable arguments

Location:
branches/stable/mondo
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/configure.in

    r1051 r1064  
    7474        AC_CHECK_LIB(pthread, pthread_create, true, [echo "*** Cannot find -lpthread."; echo "*** Please make sure you have the linuxthreads glibc add-on installed."; exit 1])
    7575        PTHREAD="-lpthread"
    76         CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_REENTRANT"
     76        CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -Wshadow -funsigned-char -Wstrict-prototypes -Wunused -Winit-self -Wcast-align"
    7777        ;;
    7878    *)
  • branches/stable/mondo/src/include/mr_conf.h

    r1054 r1064  
    1919/*initialization and closing*/
    2020extern int mr_conf_open(const char *filename);
    21 extern void mr_conf_close();
     21extern void mr_conf_close(void);
    2222
    2323/*read integer number after string str in the current file*/
  • branches/stable/mondo/src/include/mr_err.h

    r1054 r1064  
    1111/* functions (public methods) */
    1212
    13 extern void mr_exit(int errorcode, const char *message);
    14 extern void mr_log_exit(int errorcode, const char *message);
     13extern inline void mr_exit(int errorcode, const char *message);
     14extern inline void mr_log_exit(int errorcode, const char *message);
    1515
    1616#endif                          /* MR_ERR_H */
  • branches/stable/mondo/src/include/mr_mem.h

    r1061 r1064  
    1616/* functions (public methods) */
    1717
    18 extern void mr_free(char *allocated);
    19 extern void mr_allocstr(char *alloc, const char *orig);
    20 extern void mr_asprintf(char **alloc, const char *fmt, va_list args);
    21 extern void mr_getline(char **lineptr, size_t *n, FILE *stream);
    22 extern void *mr_malloc(size_t size);
     18extern inline void mr_free(char *allocated);
     19extern inline void mr_allocstr(char *alloc, const char *orig);
     20extern inline void mr_asprintf(char **alloc, const char *fmt, ...);
     21extern inline void mr_getline(char **lineptr, size_t *n, FILE *stream);
     22extern inline void *mr_malloc(size_t size);
    2323
    2424#endif                          /* MR_MEM_H */
  • branches/stable/mondo/src/include/mr_msg.h

    r1061 r1064  
    1616/* functions (public methods) */
    1717
    18 extern void mr_msg(int debug, const char *fmt, va_list args);
     18extern inline void mr_msg(int debug, const char *fmt, ...);
     19extern void mr_msg_init(const char *configfile, int loglevel);
     20extern void mr_msg_close(void);
    1921
    2022#endif                          /* MR_MSG_H */
  • branches/stable/mondo/src/include/mr_str.h

    r1054 r1064  
    1111/* functions (public methods) */
    1212
    13 extern char *mr_strtok(char *instr, const char *delims, int *lastpos);
    14 extern char *mr_stresc(char *instr, char *toesc, const char escchr);
     13extern inline char *mr_strtok(char *instr, const char *delims, int *lastpos);
     14extern inline char *mr_stresc(char *instr, char *toesc, const char escchr);
    1515
    1616#endif                          /* MR_STR_H */
  • branches/stable/mondo/src/lib/mr_conf.c

    r1054 r1064  
    6868static size_t mr_conf_filesize(const char *name);
    6969static void mr_conf_error_msg(int error_code, const char *add_line);
    70 static void mr_conf_remove_comments();
     70static void mr_conf_remove_comments(void);
    7171static int mr_conf_check_int_flag(const int flag);
    7272static void mr_conf_set_int_flag(const int flag);
     
    141141
    142142/*release all memory and prepare to the next possiable config file*/
    143 void mr_conf_close() {
     143void mr_conf_close(void) {
    144144    /* if not opened => error */
    145145    if (!mr_conf_check_int_flag(MRCONF_INTFLAG_OPEN)) {
  • branches/stable/mondo/src/lib/mr_err.c

    r1061 r1064  
    99 * Provided under the GPLv2
    1010 */
     11
     12#ifndef _GNU_SOURCE
     13#define _GNU_SOURCE
     14#endif
    1115
    1216#include <stdio.h>
  • branches/stable/mondo/src/lib/mr_mem.c

    r1061 r1064  
    99 * Provided under the GPLv2
    1010 */
     11
     12#ifndef _GNU_SOURCE
     13#define _GNU_SOURCE
     14#endif
    1115
    1216#include <stdio.h>
     
    5256
    5357/* encapsulation function for asprintf */
    54 void mr_asprintf(char **strp, const char *fmt, va_list args) {
     58void mr_asprintf(char **strp, const char *fmt, ...) {
    5559
    5660    int res = 0;
     61    va_list args;
    5762
     63    va_start(args,fmt);
    5864    res = vasprintf(strp, fmt, args);
    5965    if (res == -1) {
    6066        mr_log_exit(-1,"Unable to alloc memory in mr_asprintf\nExiting...");
    6167    }
     68    va_end(args);
    6269}
    6370
  • branches/stable/mondo/src/lib/mr_msg.c

    r1061 r1064  
    1010 */
    1111
     12#ifndef _GNU_SOURCE
     13#define _GNU_SOURCE
     14#endif
    1215#include <stdio.h>
    1316#include <stdarg.h>
     17#include <stdlib.h>
    1418
    1519static int mr_loglevel = 0;
     
    4347 * but through other functions
    4448 */
    45 void _mr_msg(int debug, const char *file, const char *function, int line, const char *fmt, va_list args) {
     49void _mr_msg(int debug, const char *file, const char *function, int line, const char *fmt, ...) {
    4650
    4751    int i = 0;
    4852    int res = 0;
    4953    FILE *fout = NULL;
     54    va_list args;
    5055
    5156    if (mr_logfile == NULL) {
     
    5863            return;
    5964        }
     65        va_start(args,fmt);
    6066
    6167        // add 2 spaces to distinguish log levels
     
    6773        if (vfprintf(fout, fmt, args) < 0) {
    6874            fprintf(stderr,"Unable to print to %s\n",mr_logfile);
    69             return;
    7075        }
    7176
     
    7479            fprintf(stderr,"Unable to close %s\n",mr_logfile);
    7580        }
     81        va_end(args);
    7682    }
    7783}
    7884
    79 void mr_msg(int level, const char *fmt, va_list args) {
     85void mr_msg(int level, const char *fmt, ...) {
    8086
     87    va_list args;
     88
     89    va_start(args,fmt);
    8190    _mr_msg(level, __FILE__, __FUNCTION__, __LINE__, fmt, args);
     91    va_end(args);
    8292}
  • branches/stable/mondo/src/test/mktest

    r1054 r1064  
    77
    88lib="../lib/mr_conf.c ../lib/mr_msg.c ../lib/mr_err.c ../lib/mr_mem.c"
     9OPT="-Wall -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_REENTRANT -Wstrict-prototypes -Wshadow -funsigned-char -Wunused -Winit-self -Wcast-align -O2 -g -I../common -I../include"
    910
    1011echo "Generating test-msg"
    11 gcc -O2 -g -I../common -I../include test-msg.c $lib -o test-msg
     12gcc $OPT test-msg.c $lib -o test-msg
    1213echo "Generating test-string"
    13 gcc -O2 -g -I../common -I../include test-string.c ../lib/mr_str.c $lib -o test-string
     14gcc $OPT test-string.c ../lib/mr_str.c $lib -o test-string
    1415echo "Generating test-conf"
    15 gcc -O2 -g -I../common -I../include test-conf.c $lib -o test-conf
     16gcc $OPT test-conf.c $lib -o test-conf
    1617
    1718for f in test-conf test-string test-msg; do
  • branches/stable/mondo/src/test/test-conf.c

    r1054 r1064  
    1515int g_buffer_pid = 0;
    1616
    17 main() {
     17int main(void) {
    1818    int ret = 0;
    1919    int i = 0;
  • branches/stable/mondo/src/test/test-string.c

    r1054 r1064  
    66 */
    77
    8 #define _GNU_SOURCE
    98#include <string.h>
    109#include <stdlib.h>
     
    1413#include "mr_mem.h"
    1514
    16 main() {
     15int main(void) {
    1716    const char delims[3] = ": \n";
    1817   
Note: See TracChangeset for help on using the changeset viewer.