Back to index

avfs  1.0.1
Classes | Defines | Typedefs | Functions
avfs.h File Reference
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <pthread.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _avtimestruc_t
struct  avstat
struct  avdirent
struct  _ventry
struct  _vfile
struct  avmount
struct  avfs
struct  ext_info
struct  avtm
struct  real_file
struct  rep_file

Defines

#define __attribute__(x)
#define AV_NEW(ptr)   ptr = av_calloc(sizeof(*(ptr)))
#define AV_NEW_OBJ(ptr, destr)   ptr = av_new_obj(sizeof(*(ptr)), (void (*)(void *)) destr)
#define AV_LOCK_DECL(mutex)   avmutex mutex
#define AV_INITLOCK(mutex)   pthread_mutex_init(&(mutex), NULL)
#define AV_INIT_RECURSIVELOCK(mutex)
#define AV_FREELOCK(mutex)   pthread_mutex_destroy(&(mutex));
#define AV_LOCK(mutex)   pthread_mutex_lock(&(mutex))
#define AV_UNLOCK(mutex)   pthread_mutex_unlock(&(mutex))
#define AV_INIT_EXT(e, f, t)   (e).from = (f), (e).to = (t)
#define AV_MAX(x, y)   ((x) > (y) ? (x) : (y))
#define AV_MIN(x, y)   ((x) < (y) ? (x) : (y))
#define AV_DIV(x, y)   ((x) ? (((x) - 1) / (y) + 1) : 0)
#define AV_TIME_LESS(t1, t2)
#define AV_TIME_EQ(t1, t2)   ((t1).sec == (t2).sec && (t1).nsec == (t2).nsec)
#define AV_BLOCKS(x)   AV_DIV(x, 512)
#define AV_MAXTIME   (~(1L << (sizeof(avtime_t) * 8 - 1)))
#define AV_MAXOFF   0x7FFFFFFFFFFFFFFFLL
#define AV_DIR_SEP_CHAR   '/'
#define AV_DIR_SEP_STR   "/"
#define NULL   ((void *) 0)
#define AVSEEK_SET   0
#define AVSEEK_CUR   1
#define AVSEEK_END   2
#define AVR_OK   4
#define AVW_OK   2
#define AVX_OK   1
#define AVF_OK   0
#define AVO_ACCMODE   0x03
#define AVO_RDONLY   0
#define AVO_WRONLY   1
#define AVO_RDWR   2
#define AVO_NOPERM   3
#define AV_ISWRITE(flags)
#define AVO_CREAT   0x00000040
#define AVO_EXCL   0x00000080
#define AVO_TRUNC   0x00000200
#define AVO_APPEND   0x00000400
#define AVO_NONBLOCK   0x00000800
#define AVO_SYNC   0x00001000
#define AVO_DIRECTORY   0x00010000
#define AVO_NOFOLLOW   0x00020000
#define AVA_DEV   (1 << 0)
#define AVA_INO   (1 << 1)
#define AVA_MODE   (1 << 2)
#define AVA_NLINK   (1 << 3)
#define AVA_UID   (1 << 4)
#define AVA_GID   (1 << 5)
#define AVA_RDEV   (1 << 6)
#define AVA_SIZE   (1 << 7)
#define AVA_BLKSIZE   (1 << 8)
#define AVA_BLKCNT   (1 << 9)
#define AVA_ATIME   (1 << 10)
#define AVA_MTIME   (1 << 11)
#define AVA_CTIME   (1 << 12)
#define AVA_ALL   0x00001fff
#define AV_IFMT   0170000
#define AV_IFDIR   0040000
#define AV_IFCHR   0020000
#define AV_IFBLK   0060000
#define AV_IFREG   0100000
#define AV_IFIFO   0010000
#define AV_IFLNK   0120000
#define AV_IFSOCK   0140000
#define AV_ISVTX   01000
#define AV_ISGID   02000
#define AV_ISUID   04000
#define AV_ISTYPE(mode, mask)   (((mode) & AV_IFMT) == (mask))
#define AV_ISDIR(mode)   AV_ISTYPE((mode), AV_IFDIR)
#define AV_ISCHR(mode)   AV_ISTYPE((mode), AV_IFCHR)
#define AV_ISBLK(mode)   AV_ISTYPE((mode), AV_IFBLK)
#define AV_ISREG(mode)   AV_ISTYPE((mode), AV_IFREG)
#define AV_ISFIFO(mode)   AV_ISTYPE((mode), AV_IFIFO)
#define AV_ISLNK(mode)   AV_ISTYPE((mode), AV_IFLNK)
#define AV_ISSOCK(mode)   AV_ISTYPE((mode), AV_IFSOCK)
#define AV_TYPE(mode)   (((mode) & AV_IFMT) >> 12)
#define AVLOG_ERROR   001
#define AVLOG_WARNING   002
#define AVLOG_DEBUG   004
#define AVLOG_SYSCALL   010
#define AVF_NEEDSLASH   (1 << 0)
#define AVF_ONLYROOT   (1 << 1)
#define AVF_NOLOCK   (1 << 2)

Typedefs

typedef unsigned char avbyte
typedef unsigned short avushort
typedef unsigned int avuint
typedef unsigned long avulong
typedef long long avquad
typedef unsigned long long avuquad
typedef avuquad avdev_t
typedef avuint avmode_t
typedef avuint avnlink_t
typedef avuint avuid_t
typedef avuint avgid_t
typedef avuquad avino_t
typedef avquad avoff_t
typedef long avtime_t
typedef avuint avsize_t
typedef int avssize_t
typedef avulong avblksize_t
typedef avquad avblkcnt_t
typedef pthread_mutex_t avmutex
typedef struct _avtimestruc_t
typedef struct _ventry
typedef struct _vfile

Functions

int av_new_avfs (const char *name, struct ext_info *exts, int version, int flags, struct vmodule *module, struct avfs **retp)
void av_add_avfs (struct avfs *avfs)
avino_t av_new_ino (struct avfs *avfs)
int av_check_version (const char *modname, const char *name, int version, int need_ver, int provide_ver)
int av_copy_ventry (ventry *ve, ventry **retp)
void av_free_ventry (ventry *ve)
int av_generate_path (ventry *ve, char **pathp)
avdev_t av_mkdev (int major, int minor)
void av_splitdev (avdev_t dev, int *majorp, int *minorp)
void av_default_stat (struct avstat *stbuf)
void av_log (int level, const char *format,...) __attribute__((format(printf
void char * av_get_config (const char *param)
void * av_malloc (avsize_t nbyte)
void * av_calloc (avsize_t nbyte)
void * av_realloc (void *ptr, avsize_t nbyte)
void av_free (void *ptr)
void * av_new_obj (avsize_t nbyte, void(*destr)(void *))
void av_ref_obj (void *obj)
void av_unref_obj (void *obj)
void av_obj_set_ref_lock (void *obj, avmutex *lock)
void av_obj_set_destr_locked (void *obj, void(*destr)(void *))
char * av_strdup (const char *s)
char * av_strndup (const char *s, avsize_t len)
char * av_stradd (char *s1,...)
void av_registerfd (int fd)
void av_curr_time (avtimestruc_t *tim)
avtime_t av_time ()
void av_sleep (unsigned long msec)
avtime_t av_mktime (struct avtm *tp)
void av_localtime (avtime_t t, struct avtm *tp)
int av_get_tmpfile (char **retp)
void av_del_tmpfile (char *tmpfile)
avoff_t av_tmp_free ()
avssize_t av_read_all (vfile *vf, char *buf, avsize_t nbyte)
avssize_t av_pread_all (vfile *vf, char *buf, avsize_t nbyte, avoff_t offset)

Class Documentation

struct _avtimestruc_t

Definition at line 51 of file avfs.h.

Class Members
long nsec
avtime_t sec
struct avstat

Definition at line 56 of file avfs.h.

Class Members
avtimestruc_t atime
avblksize_t blksize
avblkcnt_t blocks
avtimestruc_t ctime
avdev_t dev
avgid_t gid
avino_t ino
avmode_t mode
avtimestruc_t mtime
avnlink_t nlink
avdev_t rdev
avoff_t size
avuid_t uid
struct avdirent

Definition at line 72 of file avfs.h.

Class Members
avino_t ino
char * name
int type
struct _ventry

Definition at line 79 of file avfs.h.

Collaboration diagram for _ventry:
Class Members
void * data
struct avmount * mnt
struct _vfile

Definition at line 85 of file avfs.h.

Collaboration diagram for _vfile:
Class Members
void * data
int flags
avmutex lock
struct avmount * mnt
avoff_t ptr
struct avmount

Definition at line 93 of file avfs.h.

Collaboration diagram for avmount:
Class Members
struct avfs * avfs
ventry * base
int flags
char * opts
struct ext_info

Definition at line 142 of file avfs.h.

Class Members
const char * from
const char * to
struct avtm

Definition at line 147 of file avfs.h.

Class Members
int day
int hour
int min
int mon
int sec
int year
struct real_file

Definition at line 156 of file avfs.h.

Class Members
int is_tmp
char * name
struct rep_file

Definition at line 162 of file avfs.h.

Class Members
int outfd
ventry * ve

Define Documentation

#define __attribute__ (   x)

Definition at line 25 of file avfs.h.

#define AV_BLOCKS (   x)    AV_DIV(x, 512)

Definition at line 200 of file avfs.h.

#define AV_DIR_SEP_CHAR   '/'

Definition at line 205 of file avfs.h.

#define AV_DIR_SEP_STR   "/"

Definition at line 206 of file avfs.h.

#define AV_DIV (   x,
 
)    ((x) ? (((x) - 1) / (y) + 1) : 0)

Definition at line 193 of file avfs.h.

#define AV_FREELOCK (   mutex)    pthread_mutex_destroy(&(mutex));

Definition at line 185 of file avfs.h.

#define AV_IFBLK   0060000

Definition at line 259 of file avfs.h.

#define AV_IFCHR   0020000

Definition at line 258 of file avfs.h.

#define AV_IFDIR   0040000

Definition at line 257 of file avfs.h.

#define AV_IFIFO   0010000

Definition at line 261 of file avfs.h.

#define AV_IFLNK   0120000

Definition at line 262 of file avfs.h.

#define AV_IFMT   0170000

Definition at line 256 of file avfs.h.

#define AV_IFREG   0100000

Definition at line 260 of file avfs.h.

#define AV_IFSOCK   0140000

Definition at line 263 of file avfs.h.

#define AV_INIT_EXT (   e,
  f,
 
)    (e).from = (f), (e).to = (t)

Definition at line 189 of file avfs.h.

#define AV_INIT_RECURSIVELOCK (   mutex)
Value:
{ pthread_mutexattr_t attr;   \
        pthread_mutexattr_init(&attr);                                  \
        if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) { \
            av_log(AVLOG_ERROR, "Couldn't init recursive mutex");       \
            exit(1);                                                    \
        }                                                               \
        if (pthread_mutex_init(&(mutex), &attr) != 0) {                 \
            av_log(AVLOG_ERROR, "Couldn't init recursive mutex");       \
            exit(1);                                                    \
        }                                                               \
        pthread_mutexattr_destroy(&attr);}

Definition at line 174 of file avfs.h.

#define AV_INITLOCK (   mutex)    pthread_mutex_init(&(mutex), NULL)

Definition at line 173 of file avfs.h.

#define AV_ISBLK (   mode)    AV_ISTYPE((mode), AV_IFBLK)

Definition at line 273 of file avfs.h.

#define AV_ISCHR (   mode)    AV_ISTYPE((mode), AV_IFCHR)

Definition at line 272 of file avfs.h.

#define AV_ISDIR (   mode)    AV_ISTYPE((mode), AV_IFDIR)

Definition at line 271 of file avfs.h.

#define AV_ISFIFO (   mode)    AV_ISTYPE((mode), AV_IFIFO)

Definition at line 275 of file avfs.h.

#define AV_ISGID   02000

Definition at line 266 of file avfs.h.

#define AV_ISLNK (   mode)    AV_ISTYPE((mode), AV_IFLNK)

Definition at line 276 of file avfs.h.

#define AV_ISREG (   mode)    AV_ISTYPE((mode), AV_IFREG)

Definition at line 274 of file avfs.h.

#define AV_ISSOCK (   mode)    AV_ISTYPE((mode), AV_IFSOCK)

Definition at line 277 of file avfs.h.

#define AV_ISTYPE (   mode,
  mask 
)    (((mode) & AV_IFMT) == (mask))

Definition at line 269 of file avfs.h.

#define AV_ISUID   04000

Definition at line 267 of file avfs.h.

#define AV_ISVTX   01000

Definition at line 265 of file avfs.h.

#define AV_ISWRITE (   flags)
Value:

Definition at line 228 of file avfs.h.

#define AV_LOCK (   mutex)    pthread_mutex_lock(&(mutex))

Definition at line 186 of file avfs.h.

#define AV_LOCK_DECL (   mutex)    avmutex mutex

Definition at line 172 of file avfs.h.

#define AV_MAX (   x,
 
)    ((x) > (y) ? (x) : (y))

Definition at line 191 of file avfs.h.

#define AV_MAXOFF   0x7FFFFFFFFFFFFFFFLL

Definition at line 203 of file avfs.h.

#define AV_MAXTIME   (~(1L << (sizeof(avtime_t) * 8 - 1)))

Definition at line 202 of file avfs.h.

#define AV_MIN (   x,
 
)    ((x) < (y) ? (x) : (y))

Definition at line 192 of file avfs.h.

#define AV_NEW (   ptr)    ptr = av_calloc(sizeof(*(ptr)))

Definition at line 167 of file avfs.h.

#define AV_NEW_OBJ (   ptr,
  destr 
)    ptr = av_new_obj(sizeof(*(ptr)), (void (*)(void *)) destr)

Definition at line 169 of file avfs.h.

#define AV_TIME_EQ (   t1,
  t2 
)    ((t1).sec == (t2).sec && (t1).nsec == (t2).nsec)

Definition at line 198 of file avfs.h.

#define AV_TIME_LESS (   t1,
  t2 
)
Value:
((t1).sec < (t2).sec || \
                              ((t1).sec == (t2).sec && (t1).nsec < (t2).nsec))

Definition at line 195 of file avfs.h.

#define AV_TYPE (   mode)    (((mode) & AV_IFMT) >> 12)

Definition at line 279 of file avfs.h.

#define AV_UNLOCK (   mutex)    pthread_mutex_unlock(&(mutex))

Definition at line 187 of file avfs.h.

#define AVA_ALL   0x00001fff

Definition at line 254 of file avfs.h.

#define AVA_ATIME   (1 << 10)

Definition at line 250 of file avfs.h.

#define AVA_BLKCNT   (1 << 9)

Definition at line 249 of file avfs.h.

#define AVA_BLKSIZE   (1 << 8)

Definition at line 248 of file avfs.h.

#define AVA_CTIME   (1 << 12)

Definition at line 252 of file avfs.h.

#define AVA_DEV   (1 << 0)

Definition at line 240 of file avfs.h.

#define AVA_GID   (1 << 5)

Definition at line 245 of file avfs.h.

#define AVA_INO   (1 << 1)

Definition at line 241 of file avfs.h.

#define AVA_MODE   (1 << 2)

Definition at line 242 of file avfs.h.

#define AVA_MTIME   (1 << 11)

Definition at line 251 of file avfs.h.

#define AVA_NLINK   (1 << 3)

Definition at line 243 of file avfs.h.

#define AVA_RDEV   (1 << 6)

Definition at line 246 of file avfs.h.

#define AVA_SIZE   (1 << 7)

Definition at line 247 of file avfs.h.

#define AVA_UID   (1 << 4)

Definition at line 244 of file avfs.h.

#define AVF_NEEDSLASH   (1 << 0)

Definition at line 286 of file avfs.h.

#define AVF_NOLOCK   (1 << 2)

Definition at line 288 of file avfs.h.

#define AVF_OK   0

Definition at line 219 of file avfs.h.

#define AVF_ONLYROOT   (1 << 1)

Definition at line 287 of file avfs.h.

#define AVLOG_DEBUG   004

Definition at line 283 of file avfs.h.

#define AVLOG_ERROR   001

Definition at line 281 of file avfs.h.

#define AVLOG_SYSCALL   010

Definition at line 284 of file avfs.h.

#define AVLOG_WARNING   002

Definition at line 282 of file avfs.h.

#define AVO_ACCMODE   0x03

Definition at line 221 of file avfs.h.

#define AVO_APPEND   0x00000400

Definition at line 234 of file avfs.h.

#define AVO_CREAT   0x00000040

Definition at line 231 of file avfs.h.

#define AVO_DIRECTORY   0x00010000

Definition at line 237 of file avfs.h.

#define AVO_EXCL   0x00000080

Definition at line 232 of file avfs.h.

#define AVO_NOFOLLOW   0x00020000

Definition at line 238 of file avfs.h.

#define AVO_NONBLOCK   0x00000800

Definition at line 235 of file avfs.h.

#define AVO_NOPERM   3

Definition at line 226 of file avfs.h.

#define AVO_RDONLY   0

Definition at line 223 of file avfs.h.

#define AVO_RDWR   2

Definition at line 225 of file avfs.h.

#define AVO_SYNC   0x00001000

Definition at line 236 of file avfs.h.

#define AVO_TRUNC   0x00000200

Definition at line 233 of file avfs.h.

#define AVO_WRONLY   1

Definition at line 224 of file avfs.h.

#define AVR_OK   4

Definition at line 216 of file avfs.h.

#define AVSEEK_CUR   1

Definition at line 213 of file avfs.h.

#define AVSEEK_END   2

Definition at line 214 of file avfs.h.

#define AVSEEK_SET   0

Definition at line 212 of file avfs.h.

#define AVW_OK   2

Definition at line 217 of file avfs.h.

#define AVX_OK   1

Definition at line 218 of file avfs.h.

#define NULL   ((void *) 0)

Definition at line 209 of file avfs.h.


Typedef Documentation

typedef struct _avtimestruc_t

Definition at line 50 of file avfs.h.

typedef struct _ventry

Definition at line 78 of file avfs.h.

typedef struct _vfile

Definition at line 84 of file avfs.h.

typedef avquad avblkcnt_t

Definition at line 46 of file avfs.h.

Definition at line 45 of file avfs.h.

typedef unsigned char avbyte

Definition at line 28 of file avfs.h.

typedef avuquad avdev_t

Definition at line 35 of file avfs.h.

typedef avuint avgid_t

Definition at line 39 of file avfs.h.

typedef avuquad avino_t

Definition at line 40 of file avfs.h.

typedef avuint avmode_t

Definition at line 36 of file avfs.h.

typedef pthread_mutex_t avmutex

Definition at line 48 of file avfs.h.

typedef avuint avnlink_t

Definition at line 37 of file avfs.h.

typedef avquad avoff_t

Definition at line 41 of file avfs.h.

typedef long long avquad

Definition at line 32 of file avfs.h.

typedef avuint avsize_t

Definition at line 43 of file avfs.h.

typedef int avssize_t

Definition at line 44 of file avfs.h.

typedef long avtime_t

Definition at line 42 of file avfs.h.

typedef avuint avuid_t

Definition at line 38 of file avfs.h.

typedef unsigned int avuint

Definition at line 30 of file avfs.h.

typedef unsigned long avulong

Definition at line 31 of file avfs.h.

typedef unsigned long long avuquad

Definition at line 33 of file avfs.h.

typedef unsigned short avushort

Definition at line 29 of file avfs.h.


Function Documentation

void av_add_avfs ( struct avfs avfs)

Definition at line 247 of file parse.c.

{
    struct avfs_list *li;

    AV_NEW(li);
    AV_LOCK(avfs_lock);
    li->avfs = newavfs;
    li->next = &avfs_list;
    li->prev = avfs_list.prev;
    avfs_list.prev = li;
    li->prev->next = li;
    AV_UNLOCK(avfs_lock);
}

Here is the caller graph for this function:

void* av_calloc ( avsize_t  nbyte)

Definition at line 57 of file alloc.c.

{
    void *p;

    AV_LOCK(mallock);
    malloctr ++;
    AV_UNLOCK(mallock);
    
    if(nbyte == 0)
        nbyte = 1;
    
    p = calloc(nbyte, 1);
    if(p == NULL)
       out_of_memory();

    return p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_check_version ( const char *  modname,
const char *  name,
int  version,
int  need_ver,
int  provide_ver 
)

Definition at line 31 of file utils.c.

{
    if(version < need_ver || version > provide_ver) {
        if(version < need_ver) 
            av_log(AVLOG_WARNING, 
                     "%s: %s has version %i. Needs to be at least %i.",
                     modname, name, version, need_ver);
        else
            av_log(AVLOG_WARNING, 
                     "%s: %s has version %i. Cannot handle above %i.",
                     modname, name, version, provide_ver);
    
        return -ENODEV;
    }
  
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_copy_ventry ( ventry *  ve,
ventry **  retp 
)

Definition at line 854 of file parse.c.

{
    int res;
    ventry *newve;
    struct avmount *newmnt;
    void *newdata;
    struct avfs *avfs = ve->mnt->avfs;

    res = av_copy_vmount(ve->mnt, &newmnt);
    if(res < 0)
       return res;

    if(ve->data != NULL) {
        AVFS_LOCK(avfs);
        res = avfs->copyent(ve, &newdata);
        AVFS_UNLOCK(avfs);
        if(res < 0)
            return res;
    }
    else
       newdata = NULL;
    
    AV_NEW(newve);
    
    newve->data = newdata;
    newve->mnt = newmnt;

    *resp = newve;

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void av_curr_time ( avtimestruc_t *  tim)

Definition at line 274 of file sysdeps.c.

{
    struct timeval tv;

    gettimeofday(&tv, NULL);

    tim->sec = tv.tv_sec;
    tim->nsec = tv.tv_usec * 1000;
}

Here is the caller graph for this function:

void av_default_stat ( struct avstat stbuf)

Definition at line 249 of file sysdeps.c.

{
    static avuid_t myuid = -1;
    static avuid_t mygid = -1;

    if(myuid == -1) {
        myuid = getuid();
        mygid = getgid();
    }

    stbuf->dev = 0;
    stbuf->ino = 0;
    stbuf->mode = 0;
    stbuf->nlink = 0;
    stbuf->uid = myuid;
    stbuf->gid = mygid;
    stbuf->rdev = 0;
    stbuf->size = 0;
    stbuf->blksize = 512;
    stbuf->blocks = 0;
    av_curr_time(&stbuf->atime);
    stbuf->mtime = stbuf->atime;
    stbuf->ctime = stbuf->atime;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void av_del_tmpfile ( char *  tmpfile)

Definition at line 142 of file tmpfile.c.

{
    if(tmpf != NULL) {
       if(unlink(tmpf) == -1)
           rmdir(tmpf);
       
       av_free(tmpf);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void av_free ( void *  ptr)

Definition at line 178 of file leak.c.

{
    AV_LOCK(lock);
    register_free(p);
    AV_UNLOCK(lock);
}

Here is the call graph for this function:

void av_free_ventry ( ventry *  ve)

Definition at line 895 of file parse.c.

{
    if(ve != NULL) {
       struct avfs *avfs = ve->mnt->avfs;

        if(ve->data != NULL) {
            AVFS_LOCK(avfs);
            avfs->putent(ve);
            AVFS_UNLOCK(avfs);
        }

        av_free_vmount(ve->mnt);
        av_free(ve);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_generate_path ( ventry *  ve,
char **  pathp 
)

Definition at line 979 of file parse.c.

{
    int res;

    if(ve == NULL) 
        *pathp = NULL;
    else {
        res = av_generate_path(ve->mnt->base, pathp);
        if(res < 0)
            return res;

        res = add_segment(ve, pathp);
        if(res < 0) {
            av_free(*pathp);
            return res;
        }
    }

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void char* av_get_config ( const char *  param)

Definition at line 230 of file sysdeps.c.

{
    const char *val;

    val = NULL;

    if(strcmp(param, "moduledir") == 0) 
        val = MODULE_DIR;
    else if(strcmp(param, "compiledate") == 0) 
        val = COMPILE_DATE;
    else if(strcmp(param, "compilesystem") == 0) 
        val = COMPILE_SYSTEM;
  
    if(val == NULL)
        return NULL;

    return av_strdup(val);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int av_get_tmpfile ( char **  retp)

Definition at line 114 of file tmpfile.c.

{
    int res = 0;
    char buf[64];
  
    AV_LOCK(tmplock);
    if(tmpdir == NULL) {
        char *path;

        path = av_strdup("/tmp/.avfs_tmp_XXXXXX");
        res = make_tmp_dir(path);
        if(res < 0)
            av_free(path);
        else {
           AV_NEW(tmpdir);
           tmpdir->path = path;
           tmpdir->ctr = 0;
       }
    }
    if(tmpdir != NULL) {
       sprintf(buf, "/atmp%06i", tmpdir->ctr++);
       *retp = av_stradd(NULL, tmpdir->path, buf, NULL);
    }
    AV_UNLOCK(tmplock);

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void av_localtime ( avtime_t  t,
struct avtm tp 
)

Definition at line 321 of file sysdeps.c.

{
    struct tm tms;
  
    localtime_r(&t, &tms);
  
    tp->sec  = tms.tm_sec;
    tp->min  = tms.tm_min;
    tp->hour = tms.tm_hour;
    tp->day  = tms.tm_mday;
    tp->mon  = tms.tm_mon;
    tp->year = tms.tm_year;
}

Here is the caller graph for this function:

void av_log ( int  level,
const char *  format,
  ... 
)
void* av_malloc ( avsize_t  nbyte)

Definition at line 39 of file alloc.c.

{
    void *p;

    AV_LOCK(mallock);
    malloctr ++;
    AV_UNLOCK(mallock);

    if(nbyte == 0)
        nbyte = 1;

    p = malloc(nbyte);
    if(p == NULL) 
        out_of_memory();
    
    return p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

avdev_t av_mkdev ( int  major,
int  minor 
)

Definition at line 218 of file sysdeps.c.

{
    return makedev(major, minor);
}

Here is the caller graph for this function:

avtime_t av_mktime ( struct avtm tp)

Definition at line 306 of file sysdeps.c.

{
    struct tm tms;
  
    tms.tm_sec  = tp->sec;
    tms.tm_min  = tp->min;
    tms.tm_hour = tp->hour;
    tms.tm_mday = tp->day;
    tms.tm_mon  = tp->mon;
    tms.tm_year = tp->year;
    tms.tm_isdst = -1;

    return mktime(&tms);
}

Here is the caller graph for this function:

int av_new_avfs ( const char *  name,
struct ext_info exts,
int  version,
int  flags,
struct vmodule module,
struct avfs **  retp 
)

Definition at line 127 of file utils.c.

{
    int ret;
    struct avfs *avfs;

    ret = av_check_version("CoreLib", name, version, NEED_VER, AV_VER);
    if(ret < 0)
        return ret;

    AV_NEW_OBJ(avfs, free_avfs);
    AV_INITLOCK(avfs->lock);

    avfs->name = av_strdup(name);

    avfs->exts = copy_exts(exts);
    avfs->data = NULL;
    avfs->version = version;
    avfs->flags = flags;
    avfs->module = module;
    avfs->dev = av_mkdev(AVFS_MAJOR, new_minor());
    avfs->inoctr = 2;

    av_ref_obj(module);
    
    av_default_avfs(avfs);

    *retp = avfs;
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

avino_t av_new_ino ( struct avfs avfs)

Definition at line 114 of file utils.c.

{
    static AV_LOCK_DECL(lock);
    avino_t res;

    AV_LOCK(lock);
    res = avfs->inoctr;
    avfs->inoctr++;
    AV_UNLOCK(lock);

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* av_new_obj ( avsize_t  nbyte,
void(*)(void *)  destr 
)

Definition at line 236 of file utils.c.

{
    struct av_obj *ao;

    ao = (struct av_obj *) av_calloc(sizeof(*ao) + nbyte);
    ao->refctr = 1;
    ao->destr = destr;
    ao->ref_lock = NULL;
    ao->destr_locked = NULL;
    
    return (void *) (ao + 1);
}

Here is the call graph for this function:

void av_obj_set_destr_locked ( void *  obj,
void(*)(void *)  destr 
)

Definition at line 258 of file utils.c.

{
    if(obj != NULL) {
        struct av_obj *ao = ((struct av_obj *) obj) - 1;

        ao->destr_locked = destr_locked;
    }
}

Here is the caller graph for this function:

void av_obj_set_ref_lock ( void *  obj,
avmutex lock 
)

Definition at line 249 of file utils.c.

{
    if(obj != NULL) {
        struct av_obj *ao = ((struct av_obj *) obj) - 1;

        ao->ref_lock = lock;
    }
}

Here is the caller graph for this function:

avssize_t av_pread_all ( vfile *  vf,
char *  buf,
avsize_t  nbyte,
avoff_t  offset 
)

Definition at line 333 of file utils.c.

{
    avssize_t res;
    
    res = av_pread(vf, buf, nbyte, offset);
    if(res < 0)
        return res;
    
    if(res != nbyte) {
        av_log(AVLOG_ERROR, "Premature end of file");
        return -EIO;
    }

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

avssize_t av_read_all ( vfile *  vf,
char *  buf,
avsize_t  nbyte 
)

Definition at line 349 of file utils.c.

{
    avssize_t res;
    
    res = av_read(vf, buf, nbyte);
    if(res < 0)
        return res;
    
    if(res != nbyte) {
        av_log(AVLOG_ERROR, "Premature end of file");
        return -EIO;
    }

    return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* av_realloc ( void *  ptr,
avsize_t  nbyte 
)

Definition at line 75 of file alloc.c.

{
    void *p;
    
    AV_LOCK(mallock);
    if(ptr == 0)
        malloctr ++;
    else if(nbyte == 0)
        malloctr --;
    AV_UNLOCK(mallock);

    if(ptr == NULL && nbyte == 0)
        nbyte = 1;

    p = realloc(ptr, nbyte);
    if(p == NULL)
        out_of_memory();
  
    return p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void av_ref_obj ( void *  obj)

Definition at line 267 of file utils.c.

{
    if(obj != NULL) {
        struct av_obj *ao = ((struct av_obj *) obj) - 1;
        int refctr;
        
        if(ao->ref_lock != NULL) {
            AV_LOCK(*ao->ref_lock);
        } else {
            AV_LOCK(objlock);
        }

        if(ao->refctr > 0)
            ao->refctr ++;
        refctr = ao->refctr;

        if(ao->ref_lock != NULL) {
            AV_UNLOCK(*ao->ref_lock);
        } else {
            AV_UNLOCK(objlock);
        }

        if(refctr <= 0)
            av_log(AVLOG_ERROR, "Referencing deleted object (%p)", obj);
    }
}

Here is the call graph for this function:

void av_registerfd ( int  fd)

Definition at line 336 of file sysdeps.c.

{
    fcntl(fd, F_SETFD, FD_CLOEXEC);
}

Here is the caller graph for this function:

void av_sleep ( unsigned long  msec)

Definition at line 289 of file sysdeps.c.

{
    struct timespec rem;
    int res;

    rem.tv_sec = msec / 1000;
    rem.tv_nsec = (msec % 1000) * 1000 * 1000;

    do {
        struct timespec req;

        req = rem;
        res = nanosleep(&req, &rem);
    } while(res == -1 && errno == EINTR);
}

Here is the caller graph for this function:

void av_splitdev ( avdev_t  dev,
int *  majorp,
int *  minorp 
)

Definition at line 223 of file sysdeps.c.

{
    *majorp = major(dev);
    *minorp = minor(dev);
}
char* av_stradd ( char *  s1,
  ... 
)

Definition at line 206 of file utils.c.

{
    va_list ap;
    unsigned int origlen;
    unsigned int len;
    char *s, *ns;

    origlen = 0;
    if(str != NULL)
        origlen = strlen(str);

    len = origlen;
    va_start(ap, str);
    while((s = va_arg(ap, char*)) != NULL)
        len += strlen(s);
    va_end(ap);
  
    str = av_realloc(str, len + 1);
    ns = str + origlen;
    ns[0] = '\0';
    va_start(ap, str);
    while((s = va_arg(ap, char*)) != NULL) {
        strcpy(ns, s);
        ns += strlen(ns);
    }
    va_end(ap);
  
    return str;
}

Here is the call graph for this function:

char* av_strdup ( const char *  s)

Definition at line 178 of file utils.c.

{
    char *ns;

    if(s == NULL)
        return NULL;
  
    ns = (char *) av_malloc(strlen(s) + 1);
    strcpy(ns, s);

    return ns;
}

Here is the call graph for this function:

char* av_strndup ( const char *  s,
avsize_t  len 
)

Definition at line 191 of file utils.c.

{
    char *ns;

    if(s == NULL)
        return NULL;
  
    ns = (char *) av_malloc(len + 1);
    strncpy(ns, s, len);
    
    ns[len] = '\0';

    return ns;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 284 of file sysdeps.c.

{
    return time(NULL);
}

Here is the caller graph for this function:

Definition at line 152 of file tmpfile.c.

{
#ifdef HAVE_SYS_STATVFS_H
    int res;
    struct statvfs stbuf;
#endif
    avoff_t freebytes = -1;

#ifdef HAVE_SYS_STATVFS_H
    AV_LOCK(tmplock);
    if(tmpdir != NULL) {
        /* Check if fs supports df info (ramfs doesn't) */
        res = statvfs(tmpdir->path, &stbuf);
        if(res != -1 && stbuf.f_blocks != 0)
            freebytes = (avoff_t) stbuf.f_bavail * (avoff_t) stbuf.f_frsize;
    }
    AV_UNLOCK(tmplock);
#endif

#if 0    
    if(freebytes != -1)
        av_log(AVLOG_DEBUG, "free bytes in tmp directory: %lli", freebytes);
#endif

    return freebytes;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void av_unref_obj ( void *  obj)

Definition at line 294 of file utils.c.

{
    if(obj != NULL) {
        struct av_obj *ao = ((struct av_obj *) obj) - 1;
        int refctr;

        if(ao->ref_lock != NULL) {
            AV_LOCK(*ao->ref_lock);
        } else {
            AV_LOCK(objlock);
        }

        if(ao->refctr >= 0)
            ao->refctr --;
        refctr = ao->refctr;
        
        if(refctr == 0) {
            if(ao->destr_locked != NULL)
                ao->destr_locked(obj);
        }

        if(ao->ref_lock != NULL) {
            AV_UNLOCK(*ao->ref_lock);
        } else {
            AV_UNLOCK(objlock);
        }

        if(refctr == 0) {
            if(ao->destr != NULL)
                ao->destr(obj);

            av_free(ao);
            return;
        }
        else if(refctr < 0)
            av_log(AVLOG_ERROR, "Unreferencing deleted object (%p)", obj);
    }
}

Here is the call graph for this function: