Permalink
Browse files

curl init cleanup, pass through s3 interface

  • Loading branch information...
1 parent 73e7ac2 commit 546000ea06ad9586e1b7f5680bfdc5f62be73dd4 @benlemasurier committed Feb 2, 2012
Showing with 22 additions and 17 deletions.
  1. +8 −5 src/curl.c
  2. +1 −3 src/curl.h
  3. +11 −0 src/s3.c
  4. +1 −0 src/s3.h
  5. +1 −9 src/stormfs.c
View
@@ -1967,7 +1967,7 @@ stormfs_curl_put(const char *path, GList *headers)
return result;
}
-int
+static int
stormfs_curl_set_auth(const char *access_key, const char *secret_key)
{
curl.access_key = access_key;
@@ -1976,7 +1976,7 @@ stormfs_curl_set_auth(const char *access_key, const char *secret_key)
return 0;
}
-int
+static int
stormfs_curl_verify_ssl(int verify)
{
if(verify == 0)
@@ -2025,13 +2025,16 @@ share_init()
}
int
-stormfs_curl_init(const char *bucket, const char *url)
+stormfs_curl_init(struct stormfs *stormfs)
{
CURLcode result;
- curl.url = url;
- curl.bucket = bucket;
+ curl.url = stormfs->virtual_url;
+ curl.bucket = stormfs->bucket;
curl.verify_ssl = 1;
+ stormfs_curl_set_auth(stormfs->access_key, stormfs->secret_key);
+ stormfs_curl_verify_ssl(stormfs->verify_ssl);
+
if((result = curl_global_init(CURL_GLOBAL_ALL)) != CURLE_OK)
return -1;
if(share_init() != 0)
View
@@ -53,13 +53,11 @@ int stormfs_curl_get(const char *path, char **data);
int stormfs_curl_get_file(const char *path, FILE *f);
int stormfs_curl_head(const char *path, GList **meta);
int stormfs_curl_head_multi(const char *path, GList *files);
-int stormfs_curl_init(const char *bucket, const char *url);
+int stormfs_curl_init(struct stormfs *stormfs);
int stormfs_curl_list_bucket(const char *path, char **xml);
int stormfs_curl_put(const char *path, GList *headers);
int stormfs_curl_rename(const char *from, const char *to);
-int stormfs_curl_set_auth(const char *access_key, const char *secret_key);
int stormfs_curl_upload(const char *path, GList *headers, int fd);
-int stormfs_curl_verify_ssl(int verify);
int copy_multipart(const char *from, const char *to, GList *headers, off_t size);
#endif // stormfs_curl_H
View
@@ -76,6 +76,12 @@ xml_to_files(const char *path, char *xml)
return files;
}
+void
+s3_destroy(void)
+{
+ stormfs_curl_destroy();
+}
+
int
s3_getattr(const char *path, struct stat *st)
{
@@ -173,6 +179,11 @@ s3_init(struct stormfs *stormfs)
{
s3.stormfs = stormfs;
+ if(stormfs_curl_init(stormfs) != 0) {
+ fprintf(stderr, "%s: unable to initialize libcurl\n", stormfs->progname);
+ exit(EXIT_FAILURE);
+ }
+
return 0;
}
View
@@ -11,6 +11,7 @@
#ifndef s3_H
#define s3_H
+void s3_destroy(void);
int s3_getattr(const char *path, struct stat *st);
int s3_getattr_multi(const char *path, GList *files);
int s3_chmod(const char *path, struct stat *st);
View
@@ -1382,14 +1382,6 @@ stormfs_init(struct fuse_conn_info *conn)
exit(EXIT_FAILURE);
}
- if(stormfs_curl_init(stormfs.bucket, stormfs.virtual_url) != 0) {
- fprintf(stderr, "%s: unable to initialize libcurl\n", stormfs.progname);
- exit(EXIT_FAILURE);
- }
-
- stormfs_curl_set_auth(stormfs.access_key, stormfs.secret_key);
- stormfs_curl_verify_ssl(stormfs.verify_ssl);
-
if(cache_init() != 0) {
fprintf(stderr, "%s: unable to initialize cache\n", stormfs.progname);
exit(EXIT_FAILURE);
@@ -1402,7 +1394,7 @@ static void
stormfs_destroy(void *data)
{
cache_destroy();
- stormfs_curl_destroy();
+ s3_destroy();
free(stormfs.bucket);
free(stormfs.mountpoint);
free(stormfs.access_key);

0 comments on commit 546000e

Please sign in to comment.