Pārlūkot izejas kodu

* Disable file operations in kernel mode.

* Implement strchr() in kernel.c.
  * Check for snprintf() at configure time.
tags/v0.99.beta14
Sam Hocevar sam pirms 17 gadiem
vecāks
revīzija
e895e01ee6
6 mainītis faili ar 38 papildinājumiem un 12 dzēšanām
  1. +1
    -1
      configure.ac
  2. +2
    -0
      cucul/figfont.c
  3. +23
    -11
      cucul/file.c
  4. +10
    -0
      kernel/kernel.c
  5. +1
    -0
      kernel/kernel.h
  6. +1
    -0
      msvc/config.h

+ 1
- 1
configure.ac Parādīt failu

@@ -88,7 +88,7 @@ AC_ARG_ENABLE(zzuf,
[ --enable-zzuf use zzuf for fuzzing tests (autodetected)])

AC_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)
AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp htons)
AC_CHECK_FUNCS(signal ioctl snprintf vsnprintf getenv putenv strcasecmp htons)
AC_CHECK_FUNCS(usleep gettimeofday)

AC_CHECK_FUNCS(getopt_long,


+ 2
- 0
cucul/figfont.c Parādīt failu

@@ -303,6 +303,7 @@ cucul_figfont_t * open_figfont(char const *path)

/* Open font: if not found, try .tlf, then .flf */
f = _cucul_file_open(path, "r");
#if !defined __KERNEL__ && defined HAVE_SNPRINTF
if(!f)
{
snprintf(altpath, 2047, "%s.tlf", path);
@@ -315,6 +316,7 @@ cucul_figfont_t * open_figfont(char const *path)
altpath[2047] = '\0';
f = _cucul_file_open(altpath, "r");
}
#endif
if(!f)
{
free(ff);


+ 23
- 11
cucul/file.c Parādīt failu

@@ -19,7 +19,7 @@
#include "config.h"
#include "common.h"

#if !defined(__KERNEL__)
#if !defined __KERNEL__
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
@@ -33,26 +33,31 @@
#include "cucul.h"
#include "cucul_internals.h"

#if defined HAVE_ZLIB_H
#if !defined __KERNEL__ && defined HAVE_ZLIB_H
static int zipread(cucul_file_t *, void *, unsigned int);
#endif

#if !defined __KERNEL__
struct cucul_file
{
#if defined HAVE_ZLIB_H
# if defined HAVE_ZLIB_H
unsigned char read_buffer[READSIZE];
z_stream stream;
gzFile gz;
int eof, zip;
#endif
# endif
FILE *f;
};
#endif

cucul_file_t *_cucul_file_open(char const *path, const char *mode)
{
#if defined __KERNEL__
return NULL;
#else
cucul_file_t *fp = malloc(sizeof(*fp));

#if defined HAVE_ZLIB_H
# if defined HAVE_ZLIB_H
uint8_t buf[4];
unsigned int skip_size = 0;

@@ -99,7 +104,7 @@ cucul_file_t *_cucul_file_open(char const *path, const char *mode)
gzclose(fp->gz);
return NULL;
}
#else
# else
fp->f = fopen(path, mode);

if(!fp->f)
@@ -107,14 +112,17 @@ cucul_file_t *_cucul_file_open(char const *path, const char *mode)
free(fp);
return NULL;
}
#endif
# endif

return fp;
#endif
}

int _cucul_file_close(cucul_file_t *fp)
{
#if defined HAVE_ZLIB_H
#if defined __KERNEL__
return 0;
#elif defined HAVE_ZLIB_H
gzFile gz = fp->gz;
if(fp->zip)
inflateEnd(&fp->stream);
@@ -129,7 +137,9 @@ int _cucul_file_close(cucul_file_t *fp)

int _cucul_file_eof(cucul_file_t *fp)
{
#if defined HAVE_ZLIB_H
#if defined __KERNEL__
return 1;
#elif defined HAVE_ZLIB_H
return fp->zip ? fp->eof : gzeof(fp->gz);
#else
return feof(fp->f);
@@ -138,7 +148,9 @@ int _cucul_file_eof(cucul_file_t *fp)

char *_cucul_file_gets(char *s, int size, cucul_file_t *fp)
{
#if defined HAVE_ZLIB_H
#if defined __KERNEL__
return NULL;
#elif defined HAVE_ZLIB_H
if(fp->zip)
{
int i;
@@ -167,7 +179,7 @@ char *_cucul_file_gets(char *s, int size, cucul_file_t *fp)
#endif
}

#if defined HAVE_ZLIB_H
#if !defined __KERNEL__ && defined HAVE_ZLIB_H
static int zipread(cucul_file_t *fp, void *buf, unsigned int len)
{
unsigned int total_read = 0;


+ 10
- 0
kernel/kernel.c Parādīt failu

@@ -212,6 +212,16 @@ char *strdup(const char *s)
return new;
}

char *strchr(const char *s, int c)
{
do
if(*s == c)
return (char *)(intptr_t)s;
while(*s++);

return NULL;
}

/* stdarg.h functions */
int vsnprintf(char *str, size_t size, const char *format, va_list ap)
{


+ 1
- 0
kernel/kernel.h Parādīt failu

@@ -87,6 +87,7 @@ int strcmp(const char *s1, const char *s2);
int strcasecmp(const char *s1, const char *s2);
int memcmp(const void *s1, const void *s2, size_t n);
char *strdup(const char *s);
char *strchr(const char *s, int c);

/* stdarg.h functions */
typedef void * va_list;


+ 1
- 0
msvc/config.h Parādīt failu

@@ -32,6 +32,7 @@
/* #undef HAVE_UNISTD_H */
/* #undef HAVE_USLEEP */
/* #undef HAVE_VSNPRINTF */
#define HAVE_SNPRINTF 1
#define HAVE_WINDOWS_H 1
/* #undef HAVE_X11_XKBLIB_H */
/* #undef NO_MINUS_C_MINUS_O */


Notiek ielāde…
Atcelt
Saglabāt