Changeset 2144 for libcaca


Ignore:
Timestamp:
Dec 16, 2007, 3:29:19 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Disable file operations in kernel mode.
  • Implement strchr() in kernel.c.
  • Check for snprintf() at configure time.
Location:
libcaca/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/configure.ac

    r2109 r2144  
    8989
    9090AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h inttypes.h endian.h unistd.h arpa/inet.h netinet/in.h winsock2.h errno.h locale.h getopt.h dlfcn.h termios.h)
    91 AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp htons)
     91AC_CHECK_FUNCS(signal ioctl snprintf vsnprintf getenv putenv strcasecmp htons)
    9292AC_CHECK_FUNCS(usleep gettimeofday)
    9393
  • libcaca/trunk/cucul/figfont.c

    r2111 r2144  
    304304    /* Open font: if not found, try .tlf, then .flf */
    305305    f = _cucul_file_open(path, "r");
     306#if !defined __KERNEL__ && defined HAVE_SNPRINTF
    306307    if(!f)
    307308    {
     
    316317        f = _cucul_file_open(altpath, "r");
    317318    }
     319#endif
    318320    if(!f)
    319321    {
  • libcaca/trunk/cucul/file.c

    r2109 r2144  
    2020#include "common.h"
    2121
    22 #if !defined(__KERNEL__)
     22#if !defined __KERNEL__
    2323#   include <stdio.h>
    2424#   include <stdlib.h>
     
    3434#include "cucul_internals.h"
    3535
    36 #if defined HAVE_ZLIB_H
     36#if !defined __KERNEL__ && defined HAVE_ZLIB_H
    3737static int zipread(cucul_file_t *, void *, unsigned int);
    3838#endif
    3939
     40#if !defined __KERNEL__
    4041struct cucul_file
    4142{
    42 #if defined HAVE_ZLIB_H
     43#   if defined HAVE_ZLIB_H
    4344    unsigned char read_buffer[READSIZE];
    4445    z_stream stream;
    4546    gzFile gz;
    4647    int eof, zip;
    47 #endif
     48#   endif
    4849    FILE *f;
    4950};
     51#endif
    5052
    5153cucul_file_t *_cucul_file_open(char const *path, const char *mode)
    5254{
     55#if defined __KERNEL__
     56    return NULL;
     57#else
    5358    cucul_file_t *fp = malloc(sizeof(*fp));
    5459
    55 #if defined HAVE_ZLIB_H
     60#   if defined HAVE_ZLIB_H
    5661    uint8_t buf[4];
    5762    unsigned int skip_size = 0;
     
    100105        return NULL;
    101106    }
    102 #else
     107#   else
    103108    fp->f = fopen(path, mode);
    104109
     
    108113        return NULL;
    109114    }
    110 #endif
     115#   endif
    111116
    112117    return fp;
     118#endif
    113119}
    114120
    115121int _cucul_file_close(cucul_file_t *fp)
    116122{
    117 #if defined HAVE_ZLIB_H
     123#if defined __KERNEL__
     124    return 0;
     125#elif defined HAVE_ZLIB_H
    118126    gzFile gz = fp->gz;
    119127    if(fp->zip)
     
    130138int _cucul_file_eof(cucul_file_t *fp)
    131139{
    132 #if defined HAVE_ZLIB_H
     140#if defined __KERNEL__
     141    return 1;
     142#elif defined HAVE_ZLIB_H
    133143    return fp->zip ? fp->eof : gzeof(fp->gz);
    134144#else
     
    139149char *_cucul_file_gets(char *s, int size, cucul_file_t *fp)
    140150{
    141 #if defined HAVE_ZLIB_H
     151#if defined __KERNEL__
     152    return NULL;
     153#elif defined HAVE_ZLIB_H
    142154    if(fp->zip)
    143155    {
     
    168180}
    169181
    170 #if defined HAVE_ZLIB_H
     182#if !defined __KERNEL__ && defined HAVE_ZLIB_H
    171183static int zipread(cucul_file_t *fp, void *buf, unsigned int len)
    172184{
  • libcaca/trunk/kernel/kernel.c

    r1462 r2144  
    213213}
    214214
     215char *strchr(const char *s, int c)
     216{
     217    do
     218        if(*s == c)
     219            return (char *)(intptr_t)s;
     220    while(*s++);
     221
     222    return NULL;
     223}
     224
    215225/* stdarg.h functions */
    216226int vsnprintf(char *str, size_t size, const char *format, va_list ap)
  • libcaca/trunk/kernel/kernel.h

    r1462 r2144  
    8888int memcmp(const void *s1, const void *s2, size_t n);
    8989char *strdup(const char *s);
     90char *strchr(const char *s, int c);
    9091
    9192/* stdarg.h functions */
  • libcaca/trunk/msvc/config.h

    r2108 r2144  
    3333/* #undef HAVE_USLEEP */
    3434/* #undef HAVE_VSNPRINTF */
     35#define HAVE_SNPRINTF 1
    3536#define HAVE_WINDOWS_H 1
    3637/* #undef HAVE_X11_XKBLIB_H */
Note: See TracChangeset for help on using the changeset viewer.