00001 #include "common.h"
00002
00003 int main (int argc, char **argv)
00004 {
00005 njb_t njbs[NJB_MAX_DEVICES];
00006 njb_t *njb;
00007 int n, opt, debug;
00008 extern char *optarg;
00009 u_int64_t total;
00010 u_int64_t free;
00011
00012 debug = 0;
00013 while ( (opt = getopt(argc, argv, "D:")) != -1 ) {
00014 switch (opt) {
00015 case 'D':
00016 debug = atoi(optarg);
00017 break;
00018 default:
00019 fprintf(stderr, "usage: handshake [ -D debuglvl ]\n");
00020 return 1;
00021 }
00022 }
00023
00024 if ( debug ) NJB_Set_Debug(debug);
00025
00026 if (NJB_Discover(njbs, 0, &n) == -1) {
00027 fprintf(stderr, "could not locate any jukeboxes\n");
00028 return 1;
00029 }
00030
00031 if ( n == 0 ) {
00032 fprintf(stderr, "no NJB devices found\n");
00033 return 0;
00034 }
00035
00036 njb = &njbs[0];
00037
00038 if ( NJB_Open(njb) == -1 ) {
00039 NJB_Error_Dump(njb,stderr);
00040 return 1;
00041 }
00042
00043 if (NJB_Get_Disk_Usage(njb, &total, &free) == -1) {
00044 NJB_Error_Dump(njb,stderr);
00045 return 1;
00046 }
00047
00048 #ifdef __WIN32__
00049 printf("Total bytes on jukebox: %I64u (%I64u MB)\n",
00050 total, total/(1024*1024));
00051 printf("Free bytes on jukebox: %I64u (%I64u MB)\n",
00052 free, free/(1024*1024));
00053 #else
00054 printf("Total bytes on jukebox: %llu (%llu MB)\n",
00055 total, total/(1024*1024));
00056 printf("Free bytes on jukebox: %llu (%llu MB)\n",
00057 free, free/(1024*1024));
00058 #endif
00059
00060 NJB_Close(njb);
00061
00062 return 0;
00063 }
00064