pike.git / src / modules / Image / font.c

version» Context lines:

pike.git/src/modules/Image/font.c:1: - /* $Id: font.c,v 1.55 1999/09/25 19:54:48 grubba Exp $ */ + /* $Id: font.c,v 1.56 1999/10/16 09:40:00 mirar Exp $ */   #include "global.h"      #define SPACE_CHAR 'i'      extern unsigned char * image_default_font;   #define IMAGE_DEFAULT_FONT_SIZE 30596      /*   **! module Image   **! note - **! $Id: font.c,v 1.55 1999/09/25 19:54:48 grubba Exp $ + **! $Id: font.c,v 1.56 1999/10/16 09:40:00 mirar Exp $   **! class Font   **!   **! note   **! Short technical documentation on a font file:   **! This object adds the text-drawing and -creation   **! capabilities of the <ref>Image</ref> module.   **!   **! For simple usage, see   **! <ref>write</ref> and <ref>load</ref>.   **!
pike.git/src/modules/Image/font.c:167:   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"   #include "svalue.h"   #include "array.h"   #include "threads.h"   #include "builtin_functions.h"      #include "image.h" + #ifdef HAVE_UNISTD_H + #include <unistd.h> + #endif   #ifdef HAVE_MMAP   #include <sys/mman.h>   #endif      #include "dmalloc.h"      #include "fdlib.h"      extern struct program *font_program;   extern struct program *image_program;
pike.git/src/modules/Image/font.c:276: Inside #if undefined(HAVE_MMAP)
   }    }    return res;   }   #endif      static INLINE off_t file_size(int fd)   {    struct stat tmp;    if((!fd_fstat(fd, &tmp)) && -  (tmp.st_mode & S_IFREG)) +  S_ISREG(tmp.st_mode))    return (off_t)tmp.st_size;    return -1;   }      static INLINE void write_char(struct _char *ci,    rgb_group *pos,    INT32 xsize,    INT32 height)   {    rgb_group *nl;
pike.git/src/modules/Image/font.c:377:       size = (size_t) file_size(fd);    if (size > 0)    {    new_font=THIS=(struct font *)xalloc(sizeof(struct font));       THREADS_ALLOW();   #ifdef HAVE_MMAP    new_font->mem =    mmap(0,size,PROT_READ,MAP_SHARED,fd,0); + #ifdef MAP_FAILED +  if (new_font->mem==MAP_FAILED) + #else +  if (new_font->mem==(void*)-1) + #endif +  { +  new_font->mem=0; +  new_font->mmaped_size=0; +  } +  else    new_font->mmaped_size=size;   #else    new_font->mem = malloc(size);   #ifdef FONT_DEBUG    fprintf(stderr,"FONT Malloced %p (%d)\n",new_font->mem,size);   #endif    if ((new_font->mem) && (!my_read(fd,new_font->mem,size)))    {    free(new_font->mem);    new_font->mem = NULL;