Last modified 4 years ago
How to develop simple dcap clients tools using libdcap with C
- Get yourself a copy of the dcap source code by either checking out complete dCache or just the submodule dcap.
- on the command line: svn co svn+ssh://svn.dcache.org/store/dCache/trunk/modules/dcap
- or browse the dcap code online
In case you checked out, build the library simply by typing make.
- Important files
- libdcap.so (the binary of the dcap client lib, either built by you through the previous make or shipped with the dcache-server-rpm under /opt/d-cache/dcap/lib)
- dcap.h (main interface to dcap, either part of the dcap source or shipped with the dcache-server-rpm under /opt/d-cache/dcap/include/)
- dcap_test.c (good example, start here to look how to use libdcap)
- How to compile you app, linked against libdcap
gcc -D_GNU_SOURCE -I/opt/d-cache/dcap/include/ -L/opt/d-cache/dcap/lib -ldcap -o /tmp/dc_exists /tmp/dc_exists.c
- A simple example how to check whether a file exists (dcap stat)
#include <dcap.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if( argc != 2 ) {
printf("usage: %s <filename>
", argv[0]);
exit(1);
}
dc_setDebugLevel(0);
return dc_access(argv[1], F_OK);
}
