mirror of
https://github.com/rclone/rclone
synced 2024-12-22 13:03:02 +01:00
5db88fed2b
- rename C exports to be namespaced with Rclone prefix - fix error handling in RcloneRPC - add more examples - add more docs - add README - simplify ctest Makefile
64 lines
1.4 KiB
C
64 lines
1.4 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <dlfcn.h>
|
|
#include "librclone.h"
|
|
|
|
void testRPC(char *method, char *in) {
|
|
struct RcloneRPC_return out = RcloneRPC(method, in);
|
|
printf("status: %d\n", out.r1);
|
|
printf("output: %s\n", out.r0);
|
|
free(out.r0);
|
|
}
|
|
|
|
// noop command
|
|
void testNoOp() {
|
|
printf("test rc/noop\n");
|
|
testRPC("rc/noop",
|
|
"{"
|
|
" \"p1\": [1,\"2\",null,4],"
|
|
" \"p2\": { \"a\":1, \"b\":2 } "
|
|
"}");
|
|
}
|
|
|
|
// error command
|
|
void testError() {
|
|
printf("test rc/error\n");
|
|
testRPC("rc/error",
|
|
"{"
|
|
" \"p1\": [1,\"2\",null,4],"
|
|
" \"p2\": { \"a\":1, \"b\":2 } "
|
|
"}");
|
|
}
|
|
|
|
// copy file using "operations/copyfile" command
|
|
void testCopyFile() {
|
|
printf("test operations/copyfile\n");
|
|
testRPC("operations/copyfile",
|
|
"{"
|
|
"\"srcFs\": \"/tmp\","
|
|
"\"srcRemote\": \"tmpfile\","
|
|
"\"dstFs\": \"/tmp\","
|
|
"\"dstRemote\": \"tmpfile2\""
|
|
"}");
|
|
}
|
|
|
|
// list the remotes
|
|
void testListRemotes() {
|
|
printf("test operations/listremotes\n");
|
|
testRPC("config/listremotes", "{}");
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
printf("c main begin\n");
|
|
RcloneInitialize();
|
|
|
|
testNoOp();
|
|
testError();
|
|
testCopyFile();
|
|
testListRemotes();
|
|
|
|
RcloneFinalize();
|
|
return EXIT_SUCCESS;
|
|
}
|