2016-09-07 20:19:37 -07:00
|
|
|
/* A simple example on how to use the plasma store
|
2016-09-08 15:28:27 -07:00
|
|
|
*
|
2016-09-07 20:19:37 -07:00
|
|
|
* Can be called in the following way:
|
2016-09-08 15:28:27 -07:00
|
|
|
*
|
2016-09-07 20:19:37 -07:00
|
|
|
* cd build
|
|
|
|
* ./plasma_store -s /tmp/plasma_socket
|
|
|
|
* ./example -s /tmp/plasma_socket -g
|
|
|
|
* ./example -s /tmp/plasma_socket -c -f */
|
2016-08-13 17:11:11 -07:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "plasma.h"
|
2016-10-03 18:29:18 -07:00
|
|
|
#include "plasma_client.h"
|
2016-08-13 17:11:11 -07:00
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
2016-10-03 18:29:18 -07:00
|
|
|
plasma_store_conn *conn = NULL;
|
2016-09-05 15:34:11 -07:00
|
|
|
int64_t size;
|
2016-09-14 14:20:34 -07:00
|
|
|
uint8_t *data;
|
2016-08-13 17:11:11 -07:00
|
|
|
int c;
|
2016-10-03 18:29:18 -07:00
|
|
|
object_id id = {{255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
2016-09-08 15:28:27 -07:00
|
|
|
255, 255, 255, 255, 255, 255, 255, 255, 255, 255}};
|
2016-08-13 17:11:11 -07:00
|
|
|
while ((c = getopt(argc, argv, "s:cfg")) != -1) {
|
|
|
|
switch (c) {
|
|
|
|
case 's':
|
|
|
|
conn = plasma_store_connect(optarg);
|
|
|
|
break;
|
|
|
|
case 'c':
|
2016-10-03 18:29:18 -07:00
|
|
|
assert(conn != NULL);
|
2016-09-14 14:20:34 -07:00
|
|
|
plasma_create(conn, id, 100, NULL, 0, &data);
|
2016-08-13 17:11:11 -07:00
|
|
|
break;
|
|
|
|
case 'f':
|
2016-10-03 18:29:18 -07:00
|
|
|
assert(conn != NULL);
|
2016-08-13 17:11:11 -07:00
|
|
|
plasma_seal(conn, id);
|
|
|
|
break;
|
|
|
|
case 'g':
|
2016-09-14 14:20:34 -07:00
|
|
|
plasma_get(conn, id, &size, &data, NULL, NULL);
|
2016-08-13 17:11:11 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
2016-10-03 18:29:18 -07:00
|
|
|
assert(conn != NULL);
|
|
|
|
plasma_store_disconnect(conn);
|
2016-08-13 17:11:11 -07:00
|
|
|
}
|