mirror of
https://github.com/TurboGit/hubicfuse.git
synced 2026-08-02 02:42:00 +02:00
Merge branch 'chauffer-master'
* chauffer-master: Add configure check for libmagic headers. Code cleanup. Implement mime-type recognition.
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@ @XML_CFLAGS@ @CURL_CFLAGS@ @FUSE_CFLAGS@ @OPENSSL_CFLAGS@ @JSON_CFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@ @XML_LIBS@ @CURL_LIBS@ @FUSE_LIBS@ @OPENSSL_LIBS@ @JSON_LIBS@
|
||||
LIBS = @LIBS@ @XML_LIBS@ @CURL_LIBS@ @FUSE_LIBS@ @OPENSSL_LIBS@ @JSON_LIBS@ -lmagic
|
||||
INSTALL = @INSTALL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
prefix = @prefix@
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <magic.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
@@ -23,6 +24,7 @@
|
||||
#include "config.h"
|
||||
#include <fuse.h>
|
||||
|
||||
|
||||
#define RHEL5_LIBCURL_VERSION 462597
|
||||
#define RHEL5_CERTIFICATE_FILE "/etc/pki/tls/certs/ca-bundle.crt"
|
||||
|
||||
@@ -512,11 +514,44 @@ void cloudfs_init()
|
||||
}
|
||||
}
|
||||
|
||||
int file_is_readable(const char *fname)
|
||||
{
|
||||
FILE *file;
|
||||
if ( file = fopen( fname, "r" ) )
|
||||
{
|
||||
fclose( file );
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * get_file_mimetype ( const char *path )
|
||||
{
|
||||
if( file_is_readable( path ) == 1 )
|
||||
{
|
||||
magic_t magic;
|
||||
const char *mime;
|
||||
|
||||
magic = magic_open( MAGIC_MIME_TYPE );
|
||||
magic_load( magic, NULL );
|
||||
magic_compile( magic, NULL );
|
||||
mime = magic_file( magic, path );
|
||||
magic_close( magic );
|
||||
|
||||
return mime;
|
||||
}
|
||||
|
||||
const char *error = "application/octet-stream";
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
int cloudfs_object_read_fp(const char *path, FILE *fp)
|
||||
{
|
||||
|
||||
long flen;
|
||||
fflush(fp);
|
||||
const char *filemimetype = get_file_mimetype( path );
|
||||
|
||||
// determine the size of the file and segment if it is above the threshhold
|
||||
fseek(fp, 0, SEEK_END);
|
||||
@@ -574,6 +609,7 @@ int cloudfs_object_read_fp(const char *path, FILE *fp)
|
||||
add_header(&headers, "x-object-manifest", manifest);
|
||||
add_header(&headers, "x-object-meta-mtime", meta_mtime);
|
||||
add_header(&headers, "Content-Length", "0");
|
||||
add_header(&headers, "Content-Type", filemimetype);
|
||||
|
||||
int response = send_request_size("PUT", encoded, NULL, NULL, headers, 0, 0);
|
||||
curl_slist_free_all(headers);
|
||||
|
||||
@@ -58,6 +58,9 @@ long segment_above;
|
||||
char *override_storage_url;
|
||||
char *public_container;
|
||||
|
||||
int file_is_readable(const char *fname);
|
||||
const char * get_file_mimetype ( const char *filename );
|
||||
|
||||
int cloudfs_object_read_fp(const char *path, FILE *fp);
|
||||
int cloudfs_object_write_fp(const char *path, FILE *fp);
|
||||
int cloudfs_list_directory(const char *path, dir_entry **);
|
||||
|
||||
@@ -4584,6 +4584,14 @@ $as_echo "#define HAVE_OPENSSL /**/" >>confdefs.h
|
||||
fi
|
||||
|
||||
|
||||
ac_fn_c_check_header_mongrel "$LINENO" "magic.h" "ac_cv_header_magic_h" "$ac_includes_default"
|
||||
if test "x$ac_cv_header_magic_h" = xyes; then :
|
||||
|
||||
else
|
||||
as_fn_error $? "'Unable to find libmagic headers. Please make sure header files are installed.'" "$LINENO" 5
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
|
||||
|
||||
+2
-1
@@ -21,7 +21,7 @@ PKG_CHECK_MODULES(XML, libxml-2.0, , AC_MSG_ERROR('Unable to find libxml2. Pleas
|
||||
PKG_CHECK_MODULES(CURL, libcurl, , AC_MSG_ERROR('Unable to find libcurl. Please make sure library and header files are installed.'))
|
||||
PKG_CHECK_MODULES(FUSE, fuse, , AC_MSG_ERROR('Unable to find libfuse. Please make sure library and header files are installed.'))
|
||||
PKG_CHECK_MODULES(JSON, json-c, ,
|
||||
PKG_CHECK_MODULES(JSON, json, , AC_MSG_ERROR('Unable to find libjson. Please make sure library and header files are installed.')))
|
||||
PKG_CHECK_MODULES(JSON, json, , AC_MSG_ERROR('Unable to find libjson. Please make sure library and header files are installed.')))
|
||||
PKG_CHECK_MODULES(OPENSSL, openssl, , [])
|
||||
|
||||
# Checks for header files.
|
||||
@@ -29,6 +29,7 @@ AC_FUNC_ALLOCA
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([fcntl.h stdint.h stddef.h stdlib.h string.h strings.h sys/time.h unistd.h pthread.h fuse.h curl/curl.h libxml/tree.h])
|
||||
AC_CHECK_HEADER([openssl/crypto.h], AC_DEFINE([HAVE_OPENSSL], [], [Openssl headers were found]), , [])
|
||||
AC_CHECK_HEADER([magic.h], , AC_MSG_ERROR('Unable to find libmagic headers. Please make sure header files are installed.'))
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
|
||||
Reference in New Issue
Block a user