2016-09-07 20:19:37 -07:00
|
|
|
/* A simple example on how to use the plasma store
|
|
|
|
*
|
|
|
|
* Can be called in the following way:
|
|
|
|
*
|
|
|
|
* 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"
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
int conn = -1;
|
2016-09-05 15:34:11 -07:00
|
|
|
int64_t size;
|
|
|
|
void *data;
|
2016-08-13 17:11:11 -07:00
|
|
|
int c;
|
|
|
|
plasma_id id = {{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
|
|
|
255, 255, 255, 255, 255, 255, 255, 255}};
|
|
|
|
while ((c = getopt(argc, argv, "s:cfg")) != -1) {
|
|
|
|
switch (c) {
|
|
|
|
case 's':
|
|
|
|
conn = plasma_store_connect(optarg);
|
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
assert(conn != -1);
|
2016-09-05 15:34:11 -07:00
|
|
|
plasma_create(conn, id, 100, &data);
|
2016-08-13 17:11:11 -07:00
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
assert(conn != -1);
|
|
|
|
plasma_seal(conn, id);
|
|
|
|
break;
|
|
|
|
case 'g':
|
2016-09-05 15:34:11 -07:00
|
|
|
plasma_get(conn, id, &size, &data);
|
2016-08-13 17:11:11 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(conn != -1);
|
|
|
|
close(conn);
|
|
|
|
}
|