chromium/third_party/fontconfig/src/src/fccache.c

/*
 * Copyright © 2000 Keith Packard
 * Copyright © 2005 Patrick Lam
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation, and that the name of the author(s) not be used in
 * advertising or publicity pertaining to distribution of the software without
 * specific, written prior permission.  The authors make no
 * representations about the suitability of this software for any purpose.  It
 * is provided "as is" without express or implied warranty.
 *
 * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 */
#include "fcint.h"
#include "fcarch.h"
#include "fcmd5.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#include <string.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>

#ifndef _WIN32
  #include <sys/time.h>
#else
  #include <winsock2.h> /* for struct timeval */
#endif

#include <assert.h>
#if defined(HAVE_MMAP) || defined(__CYGWIN__)
#  include <unistd.h>
#  include <sys/mman.h>
#endif
#if defined(_WIN32)
#include <sys/locking.h>
#endif

#ifndef O_BINARY
#define O_BINARY
#endif

FcBool
FcDirCacheCreateUUID (FcChar8  *dir,
		      FcBool    force,
		      FcConfig *config)
{}

FcBool
FcDirCacheDeleteUUID (const FcChar8  *dir,
		      FcConfig       *config)
{}

#define CACHEBASE_LEN

static FcBool
FcCacheIsMmapSafe (int fd)
{}

static const char bin2hex[] =;

static FcChar8 *
FcDirCacheBasenameMD5 (FcConfig *config, const FcChar8 *dir, FcChar8 cache_base[CACHEBASE_LEN])
{}

#ifndef _WIN32
static FcChar8 *
FcDirCacheBasenameUUID (FcConfig *config, const FcChar8 *dir, FcChar8 cache_base[CACHEBASE_LEN])
{}
#endif

FcBool
FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config)
{}

static int
FcDirCacheOpenFile (const FcChar8 *cache_file, struct stat *file_stat)
{}

/*
 * Look for a cache file for the specified dir. Attempt
 * to use each one we find, stopping when the callback
 * indicates success
 */
static FcBool
FcDirCacheProcess (FcConfig *config, const FcChar8 *dir,
		   FcBool (*callback) (FcConfig *config, int fd, struct stat *fd_stat,
				       struct stat *dir_stat, struct timeval *cache_mtime, void *closure),
		   void *closure, FcChar8 **cache_file_ret)
{}

#define FC_CACHE_MIN_MMAP

/*
 * Skip list element, make sure the 'next' pointer is the last thing
 * in the structure, it will be allocated large enough to hold all
 * of the necessary pointers
 */

FcCacheSkip;

struct _FcCacheSkip {};

/*
 * The head of the skip list; pointers for every possible level
 * in the skip list, plus the largest level in the list
 */

#define FC_CACHE_MAX_LEVEL

/* Protected by cache_lock below */
static FcCacheSkip	*fcCacheChains[FC_CACHE_MAX_LEVEL];
static int		fcCacheMaxLevel;


static FcMutex *cache_lock;

static void
lock_cache (void)
{}

static void
unlock_cache (void)
{}

static void
free_lock (void)
{}



/*
 * Generate a random level number, distributed
 * so that each level is 1/4 as likely as the one before
 *
 * Note that level numbers run 1 <= level <= MAX_LEVEL
 */
static int
random_level (void)
{}

/*
 * Insert cache into the list
 */
static FcBool
FcCacheInsert (FcCache *cache, struct stat *cache_stat)
{}

static FcCacheSkip *
FcCacheFindByAddrUnlocked (void *object)
{}

static FcCacheSkip *
FcCacheFindByAddr (void *object)
{}

static void
FcCacheRemoveUnlocked (FcCache *cache)
{}

static FcCache *
FcCacheFindByStat (struct stat *cache_stat)
{}

static void
FcDirCacheDisposeUnlocked (FcCache *cache)
{}

void
FcCacheObjectReference (void *object)
{}

void
FcCacheObjectDereference (void *object)
{}

void *
FcCacheAllocate (FcCache *cache, size_t len)
{}

void
FcCacheFini (void)
{}

static FcBool
FcCacheTimeValid (FcConfig *config, FcCache *cache, struct stat *dir_stat)
{}

static FcBool
FcCacheOffsetsValid (FcCache *cache)
{}

/*
 * Map a cache file into memory
 */
static FcCache *
FcDirCacheMapFd (FcConfig *config, int fd, struct stat *fd_stat, struct stat *dir_stat)
{}

void
FcDirCacheReference (FcCache *cache, int nref)
{}

void
FcDirCacheUnload (FcCache *cache)
{}

static FcBool
FcDirCacheMapHelper (FcConfig *config, int fd, struct stat *fd_stat, struct stat *dir_stat, struct timeval *latest_cache_mtime, void *closure)
{}

FcCache *
FcDirCacheLoad (const FcChar8 *dir, FcConfig *config, FcChar8 **cache_file)
{}

FcCache *
FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat)
{}

static int
FcDirChecksum (struct stat *statb)
{}

static int64_t
FcDirChecksumNano (struct stat *statb)
{}

/*
 * Validate a cache file by reading the header and checking
 * the magic number and the size field
 */
static FcBool
FcDirCacheValidateHelper (FcConfig *config, int fd, struct stat *fd_stat, struct stat *dir_stat, struct timeval *latest_cache_mtime, void *closure FC_UNUSED)
{}

static FcBool
FcDirCacheValidConfig (const FcChar8 *dir, FcConfig *config)
{}

FcBool
FcDirCacheValid (const FcChar8 *dir)
{}

/*
 * Build a cache structure from the given contents
 */
FcCache *
FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, struct stat *dir_stat, FcStrSet *dirs)
{}

FcCache *
FcDirCacheRebuild (FcCache *cache, struct stat *dir_stat, FcStrSet *dirs)
{}

/* write serialized state to the cache file */
FcBool
FcDirCacheWrite (FcCache *cache, FcConfig *config)
{}

FcBool
FcDirCacheClean (const FcChar8 *cache_dir, FcBool verbose)
{}

int
FcDirCacheLock (const FcChar8 *dir,
		FcConfig      *config)
{}

void
FcDirCacheUnlock (int fd)
{}

/*
 * Hokey little macro trick to permit the definitions of C functions
 * with the same name as CPP macros
 */
#define args1(x)
#define args2(x,y)

const FcChar8 *
FcCacheDir args1(const FcCache *c)
{}

FcFontSet *
FcCacheCopySet args1(const FcCache *c)
{}

const FcChar8 *
FcCacheSubdir args2(const FcCache *c, int i)
{}

int
FcCacheNumSubdir args1(const FcCache *c)
{}

int
FcCacheNumFont args1(const FcCache *c)
{}

FcBool
FcDirCacheCreateTagFile (const FcChar8 *cache_dir)
{}

void
FcCacheCreateTagFile (FcConfig *config)
{}

#define __fccache__
#include "fcaliastail.h"
#undef __fccache__