@@ -133,7 +133,7 @@ static void vga_handle_resize(caca_display_t *dp) | |||
dp->resize.h = dp->cv->height; | |||
} | |||
static int vga_get_event(caca_display_t *dp, caca_event-t *ev) | |||
static int vga_get_event(caca_display_t *dp, caca_event_t *ev) | |||
{ | |||
/* FIXME */ | |||
ev->type = CACA_EVENT_NONE; | |||
@@ -17,7 +17,7 @@ | |||
* function prototypes that are sometimes missing. | |||
*/ | |||
#if defined(HAVE_INTTYPES_H) | |||
#if defined(HAVE_INTTYPES_H) && !defined(__KERNEL__) | |||
# include <inttypes.h> | |||
#else | |||
typedef signed char int8_t; | |||
@@ -69,3 +69,6 @@ static inline uint32_t hton32(uint32_t x) | |||
} | |||
#endif | |||
#if defined(__KERNEL__) | |||
#undef HAVE_ERRNO_H | |||
#endif |
@@ -209,9 +209,9 @@ fi | |||
if test "${enable_vga}" = "yes"; then | |||
ac_cv_my_have_vga="yes" | |||
CPPFLAGS="${CPPFLAGS} -I. -D__KERNEL__ -nostdinc -include kernel/kernel.h" | |||
CFLAGS="${CFLAGS} -fno-builtin -O2 -Wall" | |||
CFLAGS="${CFLAGS} -fno-builtin -O2 -Wall -I../kernel/" | |||
CCASFLAGS="${CCASFLAGS} -I." | |||
LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000" | |||
LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000 " | |||
AC_DEFINE(USE_VGA, 1, Define to 1 to activate the VGA backend driver) | |||
CACA_DRIVERS="${CACA_DRIVERS} vga" | |||
fi | |||
@@ -225,6 +225,7 @@ else | |||
AC_MSG_RESULT([${CACA_DRIVERS}]) | |||
fi | |||
AC_SUBST(MATH_LIBS) | |||
AC_SUBST(CACA_LIBS) | |||
@@ -62,6 +62,7 @@ cucul_buffer_t *cucul_load_memory(void *data, unsigned long int size) | |||
* \return A \e libcucul buffer containing the file's contents, or NULL | |||
* if an error occurred. | |||
*/ | |||
#if !defined(__KERNEL__) | |||
cucul_buffer_t *cucul_load_file(char const *file) | |||
{ | |||
cucul_buffer_t *buf; | |||
@@ -98,7 +99,7 @@ cucul_buffer_t *cucul_load_file(char const *file) | |||
return buf; | |||
} | |||
#endif | |||
/** \brief Get the buffer size. | |||
* | |||
* This function returns the length (in bytes) of the memory area stored | |||
@@ -98,13 +98,13 @@ cucul_canvas_t * cucul_create_canvas(unsigned int width, unsigned int height) | |||
if(ret < 0) | |||
{ | |||
#if defined(HAVE_ERRNO_H) | |||
#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__) | |||
int saved_errno = errno; | |||
#endif | |||
free(cv->allattr); | |||
free(cv->allchars); | |||
free(cv); | |||
#if defined(HAVE_ERRNO_H) | |||
#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__) | |||
errno = saved_errno; | |||
#endif | |||
return NULL; | |||
@@ -116,7 +116,7 @@ cucul_canvas_t * cucul_create_canvas(unsigned int width, unsigned int height) | |||
return cv; | |||
nomem: | |||
#if defined(HAVE_ERRNO_H) | |||
#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__) | |||
errno = ENOMEM; | |||
#endif | |||
return NULL; | |||
@@ -152,7 +152,7 @@ int cucul_set_canvas_size(cucul_canvas_t *cv, unsigned int width, | |||
{ | |||
if(cv->refcount) | |||
{ | |||
#if defined(HAVE_ERRNO_H) | |||
#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__) | |||
errno = EBUSY; | |||
#endif | |||
return -1; | |||
@@ -246,7 +246,7 @@ int cucul_free_canvas(cucul_canvas_t *cv) | |||
if(cv->refcount) | |||
{ | |||
#if defined(HAVE_ERRNO_H) | |||
#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__) | |||
errno = EBUSY; | |||
#endif | |||
return -1; | |||
@@ -316,7 +316,7 @@ int _cucul_set_canvas_size(cucul_canvas_t *cv, unsigned int width, | |||
new_size * sizeof(uint32_t)); | |||
if(!cv->allchars[f] || !cv->allattr[f]) | |||
{ | |||
#if defined(HAVE_ERRNO_H) | |||
#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__) | |||
errno = ENOMEM; | |||
#endif | |||
return -1; | |||
@@ -405,7 +405,7 @@ int _cucul_set_canvas_size(cucul_canvas_t *cv, unsigned int width, | |||
new_size * sizeof(uint32_t)); | |||
if(!cv->allchars[f] || !cv->allattr[f]) | |||
{ | |||
#if defined(HAVE_ERRNO_H) | |||
#if defined(HAVE_ERRNO_H) && !defined(__KERNEL__) | |||
errno = ENOMEM; | |||
#endif | |||
return -1; | |||
@@ -29,6 +29,9 @@ | |||
#define UPPER(x) (IS_LOWER(x)?(x+('A'-'a')):x) | |||
#define LOWER(x) (IS_UPPER(x)?(x-('a'-'A')):x) | |||
/* Our default seed for random number generator */ | |||
static int seed = 0x68743284; | |||
/* Our memory mapping */ | |||
static uint32_t *freemem = (uint32_t*) 0x00200000; | |||
@@ -94,9 +97,23 @@ char *getenv(const char *name) | |||
return NULL; | |||
} | |||
int getpid(void) | |||
{ | |||
return 0x1337; | |||
} | |||
void srand(unsigned int s) | |||
{ | |||
seed = rand(); | |||
} | |||
int time(void *dummy) | |||
{ | |||
return rand(); | |||
} | |||
int rand(void) | |||
{ | |||
static int seed = 0x68743284; | |||
seed = (seed * 0x7f32ba17) ^ 0xf893a735; | |||
return seed % RAND_MAX; | |||
} | |||
@@ -157,6 +174,18 @@ int strcasecmp(const char *s1, const char *s2) | |||
return (int)UPPER(*s1) - (int)UPPER(*s2); | |||
} | |||
int memcmp(const char *s1, const char *s2, size_t n) | |||
{ | |||
while(n) { | |||
if(*s1 != *s2) return *s1-*s2; | |||
*s1++; | |||
*s2++; | |||
n--; | |||
} | |||
return 0; | |||
} | |||
/* stdarg.h functions */ | |||
int vsnprintf(char *str, size_t size, const char *format, va_list ap) | |||
{ | |||
@@ -183,6 +212,11 @@ char *fgets(char *s, int size, FILE *stream) | |||
return NULL; | |||
} | |||
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) | |||
{ | |||
return 0; | |||
} | |||
int fclose(FILE *fp) | |||
{ | |||
/* FIXME */ | |||
@@ -298,4 +332,19 @@ double sqrt(double x) | |||
return ret; | |||
} | |||
/* XXX FIXME Converts only from little endian to big endian (x86) */ | |||
unsigned int htonl(unsigned int hostlong) | |||
{ | |||
return ((hostlong&0xFFFF0000)>>16)|((hostlong&0x0000FFFFFF)<<16); | |||
} | |||
/* XXX FIXME Converts only from little endian to big endian (x86) */ | |||
unsigned short htons(unsigned short hostlong) | |||
{ | |||
return ((hostlong&0xFF00)>>8)|((hostlong&0x00FF)<<8); | |||
} | |||
#endif /* __KERNEL__ */ |
@@ -17,6 +17,8 @@ | |||
* that must be used when building libcucul and libcaca into a kernel. | |||
*/ | |||
#ifndef __KERNEL_H_ | |||
#define __KERNEL_H_ | |||
/* Various defines */ | |||
#define NULL ((void *)0) | |||
#define BUFSIZ 4096 | |||
@@ -44,12 +46,6 @@ extern inline unsigned char inb(unsigned short port) | |||
/* Various typedefs -- some are x86-specific */ | |||
#define CUSTOM_INTTYPES | |||
typedef unsigned char uint8_t; | |||
typedef unsigned short uint16_t; | |||
typedef unsigned long int uint32_t; | |||
typedef long int intptr_t; | |||
typedef long unsigned int uintptr_t; | |||
typedef unsigned int size_t; | |||
typedef struct file | |||
@@ -81,13 +77,17 @@ char *getenv(const char *name); | |||
int rand(void); | |||
int abs(int j); | |||
void exit(int status); | |||
void srand(unsigned int s); | |||
int stdint; | |||
int stdout; | |||
int stderr; | |||
/* string.h functions */ | |||
void *memset(void *s, int c, size_t n); | |||
void *memcpy(void *dest, const void *src, size_t n); | |||
size_t strlen(const char *s); | |||
int strcasecmp(const char *s1, const char *s2); | |||
int memcmp(const char *s1, const char *s2, size_t n); | |||
/* stdarg.h functions */ | |||
typedef void * va_list; | |||
#define va_start(v,a) v = (void *)((uintptr_t)(&a) + sizeof(a)) | |||
@@ -98,6 +98,7 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap); | |||
FILE *fopen(const char *path, const char *mode); | |||
int feof(FILE *stream); | |||
char *fgets(char *s, int size, FILE *stream); | |||
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); | |||
int fclose(FILE *fp); | |||
int printf(const char *format, ...); | |||
int sprintf(char *str, const char *format, ...); | |||
@@ -105,12 +106,20 @@ int sscanf(const char *str, const char *format, ...); | |||
/* unistd.h functions */ | |||
void usleep(unsigned long usec); | |||
int getpid(void); | |||
/* time.h functions */ | |||
int gettimeofday(struct timeval *tv, struct timezone *tz); | |||
int time(void *); | |||
/* math.h functions */ | |||
double cos(double x); | |||
double sin(double x); | |||
double sqrt(double x); | |||
/* arpa/inet.h functions */ | |||
unsigned int htonl(unsigned int hostlong); | |||
unsigned short htons(unsigned short hostlong); | |||
#endif /* __KERNEL_H_ */ |
@@ -46,4 +46,3 @@ fcntl_programs = cacaserver | |||
else | |||
fcntl_programs = | |||
endif | |||
@@ -14,9 +14,11 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#include <stdio.h> | |||
#include <string.h> | |||
#include <stdlib.h> | |||
#if !defined(__KERNEL__) | |||
# include <stdio.h> | |||
# include <string.h> | |||
# include <stdlib.h> | |||
#endif | |||
#include "cucul.h" | |||
#include "caca.h" | |||
@@ -14,8 +14,10 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#include <stdio.h> | |||
#include <stdlib.h> | |||
#if !defined(__KERNEL__) | |||
#include <stdio.h> | |||
#include <stdlib.h> | |||
#endif | |||
#include "cucul.h" | |||
#include "caca.h" | |||
@@ -14,9 +14,11 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#if !defined(__KERNEL__) | |||
#include <stdio.h> | |||
#include <string.h> | |||
#include <stdlib.h> | |||
#endif | |||
#if defined(HAVE_SLEEP) | |||
# include <windows.h> | |||
@@ -14,14 +14,18 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#include <stdio.h> | |||
#include <string.h> | |||
#include <stdlib.h> | |||
#if !defined(__KERNEL__) | |||
# include <stdio.h> | |||
# include <string.h> | |||
# include <stdlib.h> | |||
#endif | |||
#if defined(HAVE_IMLIB2_H) | |||
# include <Imlib2.h> | |||
#else | |||
# include <stdio.h> | |||
# if !defined(__KERNEL__) | |||
# include <stdio.h> | |||
# endif | |||
#endif | |||
#include "cucul.h" | |||
@@ -14,9 +14,11 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#include <stdio.h> | |||
#if !defined(__KERNEL__) | |||
# include <stdio.h> | |||
#include <string.h> | |||
#include <stdlib.h> | |||
# endif | |||
#include "cucul.h" | |||
#include "common-image.h" | |||
@@ -13,11 +13,11 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#include <math.h> | |||
#include <string.h> | |||
#include <stdio.h> | |||
#if !defined(__KERNEL__) | |||
# include <math.h> | |||
# include <string.h> | |||
# include <stdio.h> | |||
#endif | |||
#include "caca.h" | |||
static void display_menu(void); | |||
@@ -23,9 +23,11 @@ | |||
#include "config.h" | |||
#include <math.h> | |||
#include <string.h> | |||
#include <stdio.h> | |||
#if !defined(__KERNEL__) | |||
# include <math.h> | |||
# include <string.h> | |||
# include <stdio.h> | |||
#endif | |||
#include "caca0.h" | |||
@@ -14,7 +14,9 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#include <stdio.h> | |||
#if !defined(__KERNEL__) | |||
# include <stdio.h> | |||
#endif | |||
#include "cucul.h" | |||
#include "caca.h" | |||
@@ -35,7 +37,7 @@ unsigned int points[] = | |||
char density[] = " ',+:;o&%w$W@#"; | |||
int main(void) | |||
int main(int argc, char *argv[]) | |||
{ | |||
cucul_canvas_t *cv; | |||
caca_display_t *dp; | |||
@@ -13,10 +13,11 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#include <stdio.h> | |||
#include <string.h> | |||
#include <stdlib.h> | |||
#if !defined(__KERNEL__) | |||
# include <stdio.h> | |||
# include <string.h> | |||
# include <stdlib.h> | |||
#endif | |||
#include "cucul.h" | |||
#include "caca.h" | |||
@@ -14,14 +14,15 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
#if !defined(__KERNEL__) | |||
# if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
# endif | |||
# include <stdio.h> | |||
# include <stdlib.h> | |||
# include <string.h> | |||
#endif | |||
#include <stdio.h> | |||
#include <stdlib.h> | |||
#include <string.h> | |||
#include "cucul.h" | |||
#define WIDTH 80 | |||
@@ -14,18 +14,20 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
#if !defined(__KERNEL__) | |||
# if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
# endif | |||
# if defined(HAVE_ENDIAN_H) | |||
# include <endian.h> | |||
# endif | |||
# include <stdio.h> | |||
# include <stdlib.h> | |||
# include <string.h> | |||
#endif | |||
#if defined(HAVE_ENDIAN_H) | |||
# include <endian.h> | |||
#endif | |||
#include <stdio.h> | |||
#include <stdlib.h> | |||
#include <string.h> | |||
#include "cucul.h" | |||
#include "caca.h" | |||
@@ -14,13 +14,14 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
#if !defined(__KERNEL__) | |||
# if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
# endif | |||
# include <stdio.h> | |||
# include <stdlib.h> | |||
#endif | |||
#include <stdio.h> | |||
#include <stdlib.h> | |||
#include "cucul.h" | |||
#define WIDTH 64 | |||
@@ -13,17 +13,17 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#if !defined(__KERNEL__) | |||
# if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
# endif | |||
#if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
# include <stdio.h> | |||
#endif | |||
#include <stdio.h> | |||
#include "cucul.h" | |||
#include "caca.h" | |||
int main(void) | |||
int main(int argc, char *argv[]) | |||
{ | |||
cucul_canvas_t *cv; | |||
caca_display_t *dp; | |||
@@ -14,11 +14,10 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
#endif | |||
#if !defined(__KERNEL__) | |||
# if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
# endif | |||
# include <stdio.h> | |||
# include <math.h> | |||
#endif | |||
@@ -28,7 +27,7 @@ | |||
uint32_t buffer[256 * 4]; | |||
int main(void) | |||
int main(int argc, char *argv[]) | |||
{ | |||
caca_event_t ev; | |||
cucul_canvas_t *cv, *cw, *mask; | |||
@@ -14,18 +14,19 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
#if !defined(__KERNEL__) | |||
# if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
# endif | |||
# include <stdio.h> | |||
#endif | |||
#include <stdio.h> | |||
#include "cucul.h" | |||
#include "caca.h" | |||
uint32_t buffer[256*256]; | |||
int main(void) | |||
int main(int argc, char *argv[]) | |||
{ | |||
cucul_canvas_t *cv; | |||
caca_display_t *dp; | |||
@@ -14,12 +14,15 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
#if !defined(__KERNEL__) | |||
# if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
# endif | |||
# include <stdio.h> | |||
# include <stdlib.h> | |||
#endif | |||
#include <stdio.h> | |||
#include <stdlib.h> | |||
#include "cucul.h" | |||
#include "caca.h" | |||
@@ -14,12 +14,13 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#if defined(HAVE_INTTYPES_H) | |||
#if !defined(__KERNEL__) | |||
# if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
# endif | |||
# include <string.h> | |||
#endif | |||
#include <string.h> | |||
#include "cucul.h" | |||
#include "caca.h" | |||
@@ -32,7 +33,7 @@ typedef struct textentry | |||
unsigned int size, cursor; | |||
} textentry; | |||
int main(void) | |||
int main(int argc, char *argv[]) | |||
{ | |||
textentry entries[TEXT_ENTRIES]; | |||
cucul_canvas_t *cv; | |||
@@ -13,9 +13,9 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#include <stdio.h> | |||
#if !defined(__KERNEL__) | |||
# include <stdio.h> | |||
#endif | |||
#include "cucul.h" | |||
#include "caca.h" | |||
@@ -13,14 +13,13 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
#if !defined(__KERNEL__) | |||
# if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
# endif | |||
# include <stdio.h> | |||
# include <string.h> | |||
#endif | |||
#include <stdio.h> | |||
#include <string.h> | |||
#include "cucul.h" | |||
#define STRING \ | |||
@@ -31,7 +30,7 @@ | |||
" \\ `--' / \n" \ | |||
" `----' \n" | |||
int main(void) | |||
int main(int argc, char *argv[]) | |||
{ | |||
cucul_canvas_t *cv; | |||
cucul_buffer_t *buffer; | |||
@@ -13,13 +13,13 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
#if !defined(__KERNEL__) | |||
# if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
# endif | |||
# include <stdio.h> | |||
#endif | |||
#include <stdio.h> | |||
#include "cucul.h" | |||
#include "caca.h" | |||
@@ -44,7 +44,7 @@ static char const *duck[] = | |||
NULL | |||
}; | |||
int main(void) | |||
int main(int argc, char *argv[]) | |||
{ | |||
cucul_canvas_t *cv, *normal, *flip, *flop, *rotate; | |||
caca_display_t *dp; | |||
@@ -14,16 +14,17 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
#if !defined(__KERNEL__) | |||
# if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
# endif | |||
# include <stdio.h> | |||
#endif | |||
#include <stdio.h> | |||
#include "cucul.h" | |||
#include "caca.h" | |||
int main(void) | |||
int main(int argc, char *argv[]) | |||
{ | |||
cucul_canvas_t *cv; | |||
caca_display_t *dp; | |||
@@ -14,16 +14,17 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
#if !defined(__KERNEL__) | |||
# if defined(HAVE_INTTYPES_H) | |||
# include <inttypes.h> | |||
# endif | |||
# include <stdio.h> | |||
#endif | |||
#include <stdio.h> | |||
#include "cucul.h" | |||
#include "caca.h" | |||
int main(void) | |||
int main(int argc, char *argv[]) | |||
{ | |||
cucul_canvas_t *cv; | |||
caca_display_t *dp; | |||
@@ -14,7 +14,9 @@ | |||
#include "config.h" | |||
#include "common.h" | |||
#include <stdio.h> | |||
#if !defined(__KERNEL__) | |||
# include <stdio.h> | |||
#endif | |||
#include "cucul.h" /* Only necessary for CUCUL_* macros */ | |||
@@ -44,7 +46,7 @@ static unsigned int const hue_list[] = | |||
} \ | |||
while(0); | |||
int main(void) | |||
int main(int argc, char *argv[]) | |||
{ | |||
int i; | |||