1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#include <libnjb.h>
#include <getopt.h>
void usage(void);
int main(int argc, char **argv)
{
njb_t njbs[NJB_MAX_DEVICES], *njb;
int n, opt, debug;
extern int optind;
extern char *optarg;
char *path;
debug= 0;
while ( (opt= getopt(argc, argv, "D:")) != -1 ) {
switch (opt) {
case 'D':
debug= atoi(optarg);
break;
default:
usage();
}
}
argc-= optind;
argv+= optind;
if ( argc != 1 ) usage();
if ( debug ) NJB_Set_Debug(debug);
path= argv[0];
printf("Uploading image:\n");
printf("Filename: %s\n", path);
if ( NJB_Discover(njbs, 0, &n) == -1 ) {
njb_error_dump(stderr);
}
if ( n == 0 ) {
fprintf(stderr, "no NJB devices found\n");
return 0;
}
njb= njbs;
if ( NJB_Open(njb) == -1 ) {
njb_error_dump(stderr);
return 1;
}
NJB_Capture(njb);
if ( NJB_Set_Bitmap(njb, path) == -1 ) {
njb_error_dump(stderr);
}
NJB_Release(njb);
NJB_Close (njb);
return 0;
}
void usage (void)
{
fprintf(stderr, "usage: setpbm [ -D debuglvl ] <path>\n");
exit(1);
}
|