~ubuntu-branches/ubuntu/precise/netatalk/precise

« back to all changes in this revision

Viewing changes to libatalk/cnid/cnid_mangle_get.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Rittau
  • Date: 2004-01-19 12:43:49 UTC
  • Revision ID: james.westby@ubuntu.com-20040119124349-es563jbp0hk0ae51
Tags: upstream-1.6.4
ImportĀ upstreamĀ versionĀ 1.6.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: cnid_mangle_get.c,v 1.6.2.1 2003/02/08 03:16:53 jmarcus Exp $
 
3
 */
 
4
 
 
5
#ifdef HAVE_CONFIG_H
 
6
#include "config.h"
 
7
#endif /* HAVE_CONFIG_H */
 
8
 
 
9
#ifdef FILE_MANGLING
 
10
#include <stdio.h>
 
11
#include <string.h>
 
12
#include <sys/param.h>
 
13
#include <sys/stat.h>
 
14
#include <string.h>
 
15
#include <atalk/logger.h>
 
16
#include <errno.h>
 
17
 
 
18
#include <db.h>
 
19
#include <netatalk/endian.h>
 
20
#include <atalk/adouble.h>
 
21
#include <atalk/cnid.h>
 
22
 
 
23
#include "cnid_private.h"
 
24
 
 
25
/* Find a mangled filename entry. */
 
26
char *
 
27
cnid_mangle_get(void *CNID, char *mfilename)
 
28
{
 
29
    CNID_private *db;
 
30
    DBT key, data;
 
31
    cnid_t id;
 
32
    struct stat st;
 
33
    char *filename;
 
34
    int rc;
 
35
 
 
36
    if (!(db = CNID)) {
 
37
        return NULL;
 
38
    }
 
39
 
 
40
    memset(&key, 0, sizeof(key));
 
41
    memset(&data, 0, sizeof(data));
 
42
 
 
43
    key.data = mfilename;
 
44
    key.size = strlen(mfilename);
 
45
 
 
46
    while ((rc = db->db_mangle->get(db->db_mangle, NULL, &key, &data, 0))) {
 
47
        if (rc == DB_LOCK_DEADLOCK) {
 
48
            continue;
 
49
        }
 
50
 
 
51
        if (rc == DB_NOTFOUND) {
 
52
            LOG(log_debug, logtype_default, "cnid_mangle_get: Failed to find mangled entry for %s", mfilename);
 
53
            return NULL;
 
54
 
 
55
        }
 
56
 
 
57
        LOG(log_error, logtype_default, "cnid_mangle_get: Failed to get mangle entry from the database: %s", db_strerror(rc));
 
58
        return NULL;
 
59
    }
 
60
 
 
61
    filename = (char *)data.data;
 
62
 
 
63
    return filename;
 
64
}
 
65
#endif /* FILE_MANGLING */