- Main Page
- Related Pages
- Modules
- Data Structures
- Files
- Examples

- File List
- Globals

# /home/v/Kate/WORK_TREES/kate-sorceress-backup/v/src/kate/src/kate_internal.h

    00001 /* Copyright (C) 2008, 2009 Vincent Penquerc'h.
    00002    This file is part of the Kate codec library.
    00003    Written by Vincent Penquerc'h.
    00004
    00005    Use, distribution and reproduction of this library is governed
    00006    by a BSD style source license included with this source in the
    00007    file 'COPYING'. Please read these terms before distributing. */
    00008
    00009
    00010 #ifndef KATE_kate_internal_h_GUARD
    00011 #define KATE_kate_internal_h_GUARD
    00012
    00013 #define KATE_LIMIT_COMMENTS 4096
    00014 #define KATE_LIMIT_COMMENT_LENGTH 4096
    00015 #define KATE_LIMIT_REGIONS 4096
    00016 #define KATE_LIMIT_STYLES 4096
    00017 #define KATE_LIMIT_CURVE_POINTS 4096
    00018 #define KATE_LIMIT_CURVES 4096
    00019 #define KATE_LIMIT_MOTION_CURVES 4096
    00020 #define KATE_LIMIT_MOTIONS 4096
    00021 #define KATE_LIMIT_PALETTES 4096
    00022 #define KATE_LIMIT_BITMAPS 4096
    00023 #define KATE_LIMIT_BITMAP_SIZE 4096
    00024 #define KATE_LIMIT_BITMAP_RAW_SIZE  4194304
    00025 #define KATE_LIMIT_FONT_RANGES 4096
    00026 #define KATE_LIMIT_FONT_MAPPINGS 4096
    00027 #define KATE_LIMIT_FONT_MAPPING_RANGES 4096
    00028 #define KATE_LIMIT_TEXT_MOTIONS 4096
    00029 #define KATE_LIMIT_LANGUAGE_LENGTH 1024
    00030 #define KATE_LIMIT_TEXT_LENGTH 1048576
    00031
    00032 #include "config.h"
    00033
    00034 #include "kate/kate.h"
    00035
    00036 #if !defined __GNUC__ || (((__GNUC__*0x100)+(__GNUC_MINOR__+0))<0x0303)
    00037 #define __attribute__(x)
    00038 #endif
    00039
    00040 #ifdef __ELF__
    00041 #define kate_internal __attribute__((visibility("internal")))
    00042 #else
    00043 #define kate_internal
    00044 #endif
    00045
    00046 /* from http://www.fefe.de/intof.html */
    00047 #define KATE_TYPE_HALF_MAX_SIGNED(type) ((type)1 << (sizeof(type)*8-2))
    00048 #define KATE_TYPE_MAX_SIGNED(type) (KATE_TYPE_HALF_MAX_SIGNED(type) - 1 + KATE_TYPE_HALF_MAX_SIGNED(type))
    00049 #define KATE_TYPE_MIN_SIGNED(type) (-1 - KATE_TYPE_MAX_SIGNED(type))
    00050 #define KATE_TYPE_MIN(type) ((type)-1 < 1?KATE_TYPE_MIN_SIGNED(type):(type)0)
    00051 #define KATE_TYPE_MAX(type) ((type)~KATE_TYPE_MIN(type))
    00052
    00053 static inline int kate_check_add_overflow(size_t x,size_t y,size_t *res) __attribute__((pure));
    00054 static inline int kate_check_add_overflow(size_t x,size_t y,size_t *res)
    00055 {
    00056   if (KATE_TYPE_MAX(size_t)-(y)>=x) {
    00057     if (res) *res=x+y;
    00058     return 0;
    00059   }
    00060   return KATE_E_LIMIT;
    00061 }
    00062
    00063 static inline int kate_check_mul_overflow_generic(size_t x,size_t y,size_t *res) __attribute__((pure));
    00064 static inline int kate_check_mul_overflow_generic(size_t x,size_t y,size_t *res)
    00065 {
    00066   kate_uint64_t r,mask;
    00067   if ((x&y)>>(sizeof(size_t)*4)) return KATE_E_LIMIT;
    00068   mask=KATE_TYPE_MAX(size_t)>>(sizeof(size_t)*4);
    00069   r=(x>>(sizeof(size_t)*4))*(y&mask)+(y>>(sizeof(size_t)*4))*(x&mask);
    00070   if (r>>(sizeof(size_t)*4)) return KATE_E_LIMIT;
    00071   r<<=(sizeof(size_t)*4);
    00072   return kate_check_add_overflow(r,(x&mask)*(y&mask),res);
    00073 }
    00074
    00075 static inline int kate_check_mul_overflow(size_t x,size_t y,size_t *res) __attribute__((pure));
    00076 static inline int kate_check_mul_overflow(size_t x,size_t y,size_t *res)
    00077 {
    00078   if (sizeof(size_t)>4) {
    00079     return kate_check_mul_overflow_generic(x,y,res);
    00080   }
    00081   else {
    00082     kate_uint64_t r=((kate_uint64_t)x)*y;
    00083     if ((r>>(sizeof(size_t)*4))>>(sizeof(size_t)*4)) return KATE_E_LIMIT;
    00084     if (res) *res=(size_t)r;
    00085     return 0;
    00086   }
    00087 }
    00088
    00089 /* granule operations */
    00090 extern kate_int64_t kate_time_granule(const kate_info *ki,kate_float base,kate_float offset) kate_internal;
    00091
    00092 /* motions */
    00093 extern int kate_motion_destroy(const kate_info *ki,kate_motion **motions,const int *destroy,size_t nmotions,int force) kate_internal;
    00094
    00095 /* event tracking */
    00096 extern kate_event *kate_event_create(const kate_info *ki) kate_internal;
    00097 extern int kate_event_track(kate_event *ev) kate_internal;
    00098 extern int kate_event_release(kate_event *ev) kate_internal;
    00099 extern int kate_event_destroy(kate_event *ev) kate_internal;
    00100
    00101 /* checks for header references */
    00102 extern int kate_find_region(const kate_info *ki,const kate_region *kr);
    00103 extern int kate_find_style(const kate_info *ki,const kate_style *ks);
    00104 extern int kate_find_curve(const kate_info *ki,const kate_curve *kc);
    00105 extern int kate_find_motion(const kate_info *ki,const kate_motion *km);
    00106 extern int kate_find_palette(const kate_info *ki,const kate_palette *kp);
    00107 extern int kate_find_bitmap(const kate_info *ki,const kate_bitmap *kb);
    00108 extern int kate_find_font_range(const kate_info *ki,const kate_font_range *kfr);
    00109 extern int kate_find_font_mapping(const kate_info *ki,const kate_font_mapping *kfm);
    00110
    00111 /* utility */
    00112 extern int kate_ascii_strncasecmp(const char *s0,const char *s1,size_t n) kate_internal __attribute__((pure));
    00113
    00114 extern int kate_is_valid_code_point(int c) kate_internal __attribute__((const));
    00115
    00116 extern int kate_font_check_ranges(const kate_font_mapping *kfm);
    00117
    00118 extern void *kate_checked_malloc(size_t n,size_t sz) kate_internal __attribute__((malloc));
    00119 extern void *kate_checked_realloc(void *ptr,size_t n,size_t sz) kate_internal;
    00120
    00121 #endif
    00122