Skip to content

Commit 6cf9a14

Browse files
author
Rosen Nedyalkov
committed
Merge remote-tracking branch 'upstream/master'
Conflicts: src/ds3.c
2 parents 1f8a768 + 1f44dac commit 6cf9a14

21 files changed

+332064
-379
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
core
12
.*.swp
23
Makefile
34
Makefile.in

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ DS3 C SDK
33

44
This project contains a C library for using the DS3 Deep Storage REST interface.
55

6+
Contact Us
7+
==========
8+
9+
Join us at our [Google Groups](https://groups.google.com/d/forum/spectralogicds3-sdks) forum to ask questions, or see frequently asked questions.
10+
611
Windows
712
=======
813

@@ -182,7 +187,7 @@ int main (int args, char * argv[]) {
182187

183188
for (i = 0; i < response->num_buckets; i++) {
184189
ds3_bucket bucket = response->buckets[i];
185-
printf("Bucket: (%s) created on %s\n", bucket.name, bucket.creation_date);
190+
printf("Bucket: (%s) created on %s\n", bucket.name->value, bucket.creation_date->value);
186191
}
187192

188193
ds3_free_service_response(response);
@@ -319,5 +324,6 @@ int main (int args, char * argv[]) {
319324
}
320325
```
321326
322-
The structure of the code is very similar to the previous examples. Setup the client, setup the call, perform the call. Every request follows this same pattern. Things get a little more complicated with the bulk get/put cases. The following bulk put will demonstrate some of those complexities
327+
The structure of the code is very similar to the previous examples. Setup the client, setup the call, perform the call. Every request follows this same pattern.
323328
329+
Additional examples are available here: [samples](sample)

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([ds3], [1.0], [[email protected]])
1+
AC_INIT([ds3], [1.1], [[email protected]])
22
AC_CONFIG_MACRO_DIR([m4])
33
AC_PROG_CC
44

@@ -9,7 +9,7 @@ AM_PROG_CC_C_O
99
LT_INIT
1010

1111
GLIB2_CHECK="glib-2.0 >= 2.34"
12-
LIBCURL_CHECK="libcurl >= 7.31"
12+
LIBCURL_CHECK="libcurl >= 7.29"
1313
LIBXML2_CHECK="libxml-2.0 >= 2.9"
1414

1515
PKG_CHECK_MODULES([GLIB2], $GLIB2_CHECK)

sample/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
get-service
2+
put-bulk
3+
put-bucket
4+
get-bucket

sample/Makefile

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,40 @@ LIBS=`$(PKG_CONFIG) --libs libds3`
77
CFLAGS=`$(PKG_CONFIG) --cflags libds3`
88
CFLAGS+= -g -DDS3_LOG -Wall# Debug flags
99

10-
all: sample
11-
12-
run: sample
13-
LD_LIBRARY_PATH=../install/lib ./sample
10+
all: get-service get-bucket put-bulk
1411

1512
deps:
1613
./build_local.sh
1714

18-
sample: main.o
19-
$(CC) *.o $(CFLAGS) $(LIBS) -o sample
15+
run-get-service: get-service
16+
LD_LIBRARY_PATH=../install/lib ./get-service
17+
18+
get-service: get-service.o
19+
$(CC) $< $(CFLAGS) $(LIBS) -o $@
20+
21+
get-service.o: ../install/lib/pkgconfig/libds3.pc
22+
$(CC) -c get-service.c $(CFLAGS)
23+
24+
run-get-bucket: get-bucket
25+
LD_LIBRARY_PATH=../install/lib ./get-bucket
26+
27+
get-bucket: get-bucket.o
28+
$(CC) $< $(CFLAGS) $(LIBS) -o $@
2029

21-
main.o: ../install/lib/pkgconfig/libds3.pc
22-
$(CC) -c main.c $(CFLAGS)
30+
get-bucket.o: ../install/lib/pkgconfig/libds3.pc
31+
$(CC) -c get-bucket.c $(CFLAGS)
32+
33+
run-put-bulk: put-bulk
34+
LD_LIBRARY_PATH=../install/lib ./put-bulk
35+
36+
put-bulk: put-bulk.o
37+
$(CC) $< $(CFLAGS) $(LIBS) -o $@
38+
39+
put-bulk.o: ../install/lib/pkgconfig/libds3.pc
40+
$(CC) -c put-bulk.c $(CFLAGS)
2341

2442
../install/lib/pkgconfig/libds3.pc:
2543
$(error SDK not built. Please run make deps)
2644

2745
clean:
28-
rm -f *.o sample
29-
46+
rm -f *.o get-service get-bucket put-bulk

sample/get-bucket.c

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#include <stdlib.h>
2+
#include <string.h>
3+
#include <stdint.h>
4+
#include <stdio.h>
5+
#include <sys/types.h>
6+
#include <sys/stat.h>
7+
#include "ds3.h"
8+
9+
int main(void) {
10+
11+
///*
12+
// Get Bucket
13+
14+
ds3_get_bucket_response *response;
15+
uint64_t i;
16+
17+
// Setup client credentials and then the actual client itself.
18+
ds3_creds * creds = ds3_create_creds("cnlhbg==","ZIjGDQAs");
19+
ds3_client * client = ds3_create_client("http://192.168.56.101:8080", creds);
20+
21+
// You can optionally set a proxy server that a request should be sent through
22+
//ds3_client_proxy(client, "192.168.56.1:8888");
23+
24+
char * bucket = "books";
25+
26+
// Create the get bucket request.
27+
ds3_request* request = ds3_init_get_bucket(bucket);
28+
29+
// This performs the request to a DS3 appliance.
30+
// If there is an error 'error' will not be NULL
31+
// If the request completed successfully then 'error' will be NULL
32+
ds3_error* error = ds3_get_bucket(client, request, &response);
33+
ds3_free_request(request);
34+
35+
// Check that the request completed successfully
36+
if(error != NULL) {
37+
if(error->error != NULL) {
38+
printf("Got an error (%lu): %s\n", error->error->status_code, error->message->value);
39+
printf("Message Body: %s\n", error->error->error_body->value);
40+
}
41+
else {
42+
printf("Got a runtime error: %s\n", error->message->value);
43+
}
44+
ds3_free_error(error);
45+
ds3_free_creds(creds);
46+
ds3_free_client(client);
47+
return 1;
48+
}
49+
50+
if (response == NULL) {
51+
printf("Response was null\n");
52+
ds3_free_creds(creds);
53+
ds3_free_client(client);
54+
return 1;
55+
}
56+
57+
if(response->num_objects == 0) {
58+
printf("No objects returned\n");
59+
ds3_free_bucket_response(response);
60+
ds3_free_creds(creds);
61+
ds3_free_client(client);
62+
return 0;
63+
}
64+
65+
for (i = 0; i < response->num_objects; i++) {
66+
ds3_object object = response->objects[i];
67+
printf("Object: (%s) created on %s\n", object.name->value, object.last_modified->value);
68+
}
69+
70+
ds3_free_bucket_response(response);
71+
72+
ds3_free_creds(creds);
73+
ds3_free_client(client);
74+
ds3_cleanup();
75+
76+
return 0;
77+
}

sample/main.c renamed to sample/get-service.c

Lines changed: 14 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
#include <sys/stat.h>
77
#include "ds3.h"
88

9-
int main (int args, char * argv[]) {
10-
/*
9+
int main (void) {
1110
// Get Service
1211

13-
ds3_get_service_response *response;
12+
ds3_get_service_response *response;
1413
uint64_t i;
1514

1615
// Setup client credentials and then the actual client itself.
@@ -34,11 +33,11 @@ int main (int args, char * argv[]) {
3433
// Check that the request completed successfully
3534
if(error != NULL) {
3635
if(error->error != NULL) {
37-
printf("Got an error (%lu): %s\n", error->error->status_code, error->message);
36+
printf("Got an error (%lu): %s\n", error->error->status_code, error->message->value);
3837
printf("Message Body: %s\n", error->error->error_body);
3938
}
4039
else {
41-
printf("Got a runtime error: %s\n", error->message);
40+
printf("Got a runtime error: %s\n", error->message->value);
4241
}
4342
ds3_free_error(error);
4443
ds3_free_creds(creds);
@@ -63,7 +62,7 @@ int main (int args, char * argv[]) {
6362

6463
for (i = 0; i < response->num_buckets; i++) {
6564
ds3_bucket bucket = response->buckets[i];
66-
printf("Bucket: (%s) created on %s\n", bucket.name, bucket.creation_date);
65+
printf("Bucket: (%s) created on %s\n", bucket.name->value, bucket.creation_date->value);
6766
}
6867

6968
ds3_free_service_response(response);
@@ -72,65 +71,18 @@ int main (int args, char * argv[]) {
7271
ds3_free_client(client);
7372
ds3_cleanup();
7473

75-
*/
76-
7774
/*
7875
//Create Bucket
7976
8077
ds3_creds * creds = ds3_create_creds("cnlhbg==","ZIjGDQAs");
8178
ds3_client * client = ds3_create_client("http://192.168.56.101:8080", creds);
82-
79+
8380
//ds3_client_proxy(client, "192.168.56.1:8888");
8481
char * bucket = "books";
8582
ds3_request * create_bucket_request = ds3_init_put_bucket(bucket);
8683
ds3_error* error = ds3_put_bucket(client, create_bucket_request);
8784
ds3_free_request(create_bucket_request);
88-
89-
if(error != NULL) {
90-
if(error->error != NULL) {
91-
printf("Got an error (%lu): %s\n", error->error->status_code, error->message);
92-
printf("Message Body: %s\n", error->error->error_body);
93-
}
94-
else {
95-
printf("Got a runtime error: %s\n", error->message);
96-
}
97-
ds3_free_error(error);
98-
ds3_free_creds(creds);
99-
ds3_free_client(client);
100-
return 1;
101-
}
102-
103-
printf("Successfully created bucket: %s\n", bucket);
104-
ds3_free_creds(creds);
105-
ds3_free_client(client);
106-
ds3_cleanup();
107-
*/
108-
109-
///*
110-
// Get Bucket
111-
112-
ds3_get_bucket_response *response;
113-
uint64_t i;
114-
115-
// Setup client credentials and then the actual client itself.
116-
ds3_creds * creds = ds3_create_creds("cnlhbg==","ZIjGDQAs");
117-
ds3_client * client = ds3_create_client("http://192.168.56.101:8080", creds);
118-
119-
// You can optionally set a proxy server that a request should be sent through
120-
//ds3_client_proxy(client, "192.168.56.1:8888");
121-
122-
char * bucket = "books";
123-
124-
// Create the get bucket request.
125-
ds3_request* request = ds3_init_get_bucket(bucket);
126-
127-
// This performs the request to a DS3 appliance.
128-
// If there is an error 'error' will not be NULL
129-
// If the request completed successfully then 'error' will be NULL
130-
ds3_error* error = ds3_get_bucket(client, request, &response);
131-
ds3_free_request(request);
13285
133-
// Check that the request completed successfully
13486
if(error != NULL) {
13587
if(error->error != NULL) {
13688
printf("Got an error (%lu): %s\n", error->error->status_code, error->message);
@@ -145,33 +97,12 @@ int main (int args, char * argv[]) {
14597
return 1;
14698
}
14799
148-
if (response == NULL) {
149-
printf("Response was null\n");
150-
ds3_free_creds(creds);
151-
ds3_free_client(client);
152-
return 1;
153-
}
154-
155-
if(response->num_objects == 0) {
156-
printf("No objects returned\n");
157-
ds3_free_bucket_response(response);
158-
ds3_free_creds(creds);
159-
ds3_free_client(client);
160-
return 0;
161-
}
162-
163-
for (i = 0; i < response->num_objects; i++) {
164-
ds3_object object = response->objects[i];
165-
printf("Object: (%s) created on %s\n", object.name, object.last_modified);
166-
}
167-
168-
ds3_free_bucket_response(response);
169-
100+
printf("Successfully created bucket: %s\n", bucket);
170101
ds3_free_creds(creds);
171102
ds3_free_client(client);
172103
ds3_cleanup();
104+
*/
173105

174-
//*/
175106

176107
/*
177108
ds3_bulk_response *response;
@@ -192,11 +123,11 @@ int main (int args, char * argv[]) {
192123
ds3_free_bulk_response(response);
193124
194125
ds3_free_bulk_object_list(list);
195-
126+
196127
request = ds3_init_get_bucket(bucket);
197128
198129
ds3_print_request(request);
199-
130+
200131
ds3_get_bucket_response * bucket_response = ds3_get_bucket(client, request);
201132
ds3_free_request(request);
202133
for(n = 0; n < bucket_response->num_objects; n++) {
@@ -211,7 +142,7 @@ int main (int args, char * argv[]) {
211142
212143
ds3_free_bucket_response(bucket_response);
213144
214-
145+
215146
char * object = "huckfinn.txt";
216147
217148
struct stat st;
@@ -234,7 +165,7 @@ int main (int args, char * argv[]) {
234165
235166
ds3_put_bucket(client, create_bucket_request);
236167
ds3_free_request(create_bucket_request);
237-
168+
238169
239170
request = ds3_init_get_service();
240171
ds3_get_service_response * response = ds3_get_service(client, request);
@@ -243,11 +174,11 @@ int main (int args, char * argv[]) {
243174
for(i = 0; i < response->num_buckets; i++) {
244175
ds3_bucket bucket = response->buckets[i];
245176
printf("Bucket: (%s) created on %s\n", bucket.name, bucket.creation_date);
246-
177+
247178
request = ds3_init_get_bucket(bucket.name);
248179
249180
ds3_print_request(request);
250-
181+
251182
ds3_get_bucket_response * bucket_response = ds3_get_bucket(client, request);
252183
ds3_free_request(request);
253184
for(n = 0; n < bucket_response->num_objects; n++) {
@@ -266,6 +197,5 @@ int main (int args, char * argv[]) {
266197
ds3_free_service_response(response);
267198
*/
268199

269-
270200
return 0;
271201
}

sample/put-bulk.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <stdlib.h>
2+
#include <string.h>
3+
#include <stdint.h>
4+
#include <stdio.h>
5+
#include <sys/types.h>
6+
#include <sys/stat.h>
7+
#include "ds3.h"
8+
9+
int main(void) {
10+
11+
12+
return 0;
13+
}

0 commit comments

Comments
 (0)