netatalk  4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
cache.c File Reference
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <atalk/afp.h>
#include <atalk/logger.h>
#include <atalk/uuid.h>
#include "cache.h"

Data Structures

struct  cacheduser
 

Typedefs

typedef struct cacheduser cacheduser_t
 

Functions

void uuidcache_dump (void)
 
static unsigned char hashstring (unsigned char *str)
 
static unsigned char hashuuid (uuidp_t uuid)
 
int add_cachebyname (const char *inname, const uuidp_t inuuid, const uuidtype_t type, const unsigned long uid)
 
int search_cachebyname (const char *name, uuidtype_t *type, unsigned char *uuid)
 Search cache by name and uuid type.
 
int search_cachebyuuid (uuidp_t uuidp, char **name, uuidtype_t *type)
 
int add_cachebyuuid (uuidp_t inuuid, const char *inname, uuidtype_t type, const unsigned long uid)
 

Variables

static cacheduser_tnamecache [256]
 
static cacheduser_tuuidcache [256]
 

Typedef Documentation

◆ cacheduser_t

typedef struct cacheduser cacheduser_t

Function Documentation

◆ add_cachebyname()

int add_cachebyname ( const char *  inname,
const uuidp_t  inuuid,
const uuidtype_t  type,
const unsigned long  uid 
)

◆ add_cachebyuuid()

int add_cachebyuuid ( uuidp_t  inuuid,
const char *  inname,
uuidtype_t  type,
const unsigned long  uid 
)

◆ hashstring()

static unsigned char hashstring ( unsigned char *  str)
static

hash string it into unsigned char using FNV-1a algorithm

◆ hashuuid()

static unsigned char hashuuid ( uuidp_t  uuid)
static

hash atalk_uuid_t into unsigned char

◆ search_cachebyname()

int search_cachebyname ( const char *  name,
uuidtype_t type,
unsigned char *  uuid 
)

Search cache by name and uuid type.

Parameters
[in]namename to search
[in,out]typetype (user or group) of name, returns found type here which might mark it as a negative entry
[out]uuidfound uuid is returned here
Returns
0 on success, entry found; -1 no entry found

◆ search_cachebyuuid()

int search_cachebyuuid ( uuidp_t  uuidp,
char **  name,
uuidtype_t type 
)

Caller must free allocated name

◆ uuidcache_dump()

void uuidcache_dump ( void  )

Variable Documentation

◆ namecache

cacheduser_t* namecache[256]
static

indexed by hash of name

◆ uuidcache

cacheduser_t* uuidcache[256]
static

indexed by hash of uuid