Add Missing netatalk files
All checks were successful
Source release / source-package (push) Successful in 48s
All checks were successful
Source release / source-package (push) Successful in 48s
This commit is contained in:
35
cmake/modules/FindNetatalk.cmake
Normal file
35
cmake/modules/FindNetatalk.cmake
Normal file
@@ -0,0 +1,35 @@
|
||||
# Find Netatalk's libatalk.
|
||||
#
|
||||
# Result variables:
|
||||
# NETATALK_FOUND
|
||||
# NETATALK_INCLUDE_DIRS
|
||||
# NETATALK_LIBRARIES
|
||||
#
|
||||
# Optional cache hints:
|
||||
# NETATALK_ROOT
|
||||
# NETATALK_INCLUDE_DIR
|
||||
# NETATALK_LIBRARY
|
||||
|
||||
find_path(NETATALK_INCLUDE_DIR
|
||||
NAMES atalk/adouble.h
|
||||
HINTS ${NETATALK_ROOT}
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
|
||||
find_library(NETATALK_LIBRARY
|
||||
NAMES atalk libatalk
|
||||
HINTS ${NETATALK_ROOT}
|
||||
PATH_SUFFIXES lib lib64
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Netatalk
|
||||
REQUIRED_VARS NETATALK_INCLUDE_DIR NETATALK_LIBRARY
|
||||
)
|
||||
|
||||
if(NETATALK_FOUND)
|
||||
set(NETATALK_INCLUDE_DIRS ${NETATALK_INCLUDE_DIR})
|
||||
set(NETATALK_LIBRARIES ${NETATALK_LIBRARY})
|
||||
endif()
|
||||
|
||||
mark_as_advanced(NETATALK_INCLUDE_DIR NETATALK_LIBRARY)
|
||||
13
include/nwatalk.h
Normal file
13
include/nwatalk.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef _NWATALK_H_
|
||||
#define _NWATALK_H_
|
||||
|
||||
#include "net.h"
|
||||
|
||||
#define NWATALK_FINDER_INFO_LEN 32
|
||||
|
||||
int nwatalk_backend_available(void);
|
||||
int nwatalk_get_finder_info(const char *path, uint8 *finder_info,
|
||||
int finder_info_len);
|
||||
int nwatalk_get_resource_fork_size(const char *path, uint32 *resource_size);
|
||||
|
||||
#endif
|
||||
102
src/nwatalk.c
Normal file
102
src/nwatalk.c
Normal file
@@ -0,0 +1,102 @@
|
||||
/* Optional Netatalk/libatalk AFP metadata backend helpers. */
|
||||
#include "net.h"
|
||||
#include "config.h"
|
||||
#include "nwatalk.h"
|
||||
#include "tools.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if NETATALK_SUPPORT
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <atalk/adouble.h>
|
||||
#endif
|
||||
|
||||
int nwatalk_backend_available(void)
|
||||
{
|
||||
#if NETATALK_SUPPORT
|
||||
return(1);
|
||||
#else
|
||||
return(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if NETATALK_SUPPORT
|
||||
static int nwatalk_open_adouble(const char *path, struct adouble *ad)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (!path || !*path) return(-0x9c); /* invalid path */
|
||||
|
||||
ad_init_old(ad, AD_VERSION, 0);
|
||||
|
||||
result = ad_open(ad, path,
|
||||
ADFLAGS_HF | ADFLAGS_RF | ADFLAGS_RDONLY |
|
||||
ADFLAGS_NOHF | ADFLAGS_NORF);
|
||||
if (result < 0) {
|
||||
return(-0x9c);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int nwatalk_get_finder_info(const char *path, uint8 *finder_info,
|
||||
int finder_info_len)
|
||||
{
|
||||
#if NETATALK_SUPPORT
|
||||
struct adouble ad;
|
||||
void *entry;
|
||||
int result;
|
||||
|
||||
if (!finder_info || finder_info_len < NWATALK_FINDER_INFO_LEN) {
|
||||
return(-0x9c);
|
||||
}
|
||||
|
||||
memset(finder_info, 0, finder_info_len);
|
||||
|
||||
result = nwatalk_open_adouble(path, &ad);
|
||||
if (result < 0) return(result);
|
||||
|
||||
entry = ad_entry(&ad, ADEID_FINDERI);
|
||||
if (entry && ad_getentrylen(&ad, ADEID_FINDERI) >= NWATALK_FINDER_INFO_LEN) {
|
||||
memcpy(finder_info, entry, NWATALK_FINDER_INFO_LEN);
|
||||
}
|
||||
|
||||
ad_close(&ad, 0);
|
||||
return(0);
|
||||
#else
|
||||
(void)path;
|
||||
(void)finder_info;
|
||||
(void)finder_info_len;
|
||||
return(-0xbf); /* invalid namespace / backend unavailable */
|
||||
#endif
|
||||
}
|
||||
|
||||
int nwatalk_get_resource_fork_size(const char *path, uint32 *resource_size)
|
||||
{
|
||||
#if NETATALK_SUPPORT
|
||||
struct adouble ad;
|
||||
off_t size;
|
||||
int result;
|
||||
|
||||
if (!resource_size) return(-0x9c);
|
||||
*resource_size = 0;
|
||||
|
||||
result = nwatalk_open_adouble(path, &ad);
|
||||
if (result < 0) return(result);
|
||||
|
||||
size = ad_size(&ad, ADEID_RFORK);
|
||||
if (size > 0) {
|
||||
if (size > 0xffffffffUL) size = 0xffffffffUL;
|
||||
*resource_size = (uint32)size;
|
||||
}
|
||||
|
||||
ad_close(&ad, 0);
|
||||
return(0);
|
||||
#else
|
||||
(void)path;
|
||||
(void)resource_size;
|
||||
return(-0xbf); /* invalid namespace / backend unavailable */
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user