void eutp_abort(int exitstatus) { brlapi_leaveRawMode(); brlapi_closeConnection(); exit(exitstatus); }
int main(int argc, char *argv[]) { transferfun *transfer; char driverName[13]; int stilloptions=1; char *home; brlapi_settings_t brlapi_settings; transfer=CheckSendOrRecv(argv[0]); /* first use options file */ if ((home=getenv("HOME"))) { char vstprc[strlen(home)+strlen(VSTPRC)+2]; strcpy(vstprc,home); strcat(vstprc,"/" VSTPRC); Parse(vstprc); } /* a first pass to check options and record them, before doing anything */ CheckOptions(argc--,argv++); /* ok, one can try to open the socket */ brlapi_settings.host = socketport; brlapi_settings.auth = keyname; if (brlapi_initializeConnection(&brlapi_settings,NULL)<0) { brlapi_perror("Couldn't initialize connection with BrlAPI"); exit(RET_ECONN); } if (brlapi_getDriverName(driverName, sizeof(driverName))<12) { brlapi_perror("Couldn't get driver name"); brlapi_closeConnection(); exit(RET_ECONN); } if (strcmp(driverName,"VisioBraille")) { fprintf(stderr,"braille driver is not VisioBraille\n"); brlapi_closeConnection(); exit(RET_ECONN); } if (brlapi_enterRawMode("VisioBraille")<0) { fprintf(stderr,"Couldn't get raw mode\n"); brlapi_closeConnection(); exit(RET_ECONN); } signal(SIGINT,handleint); signal(SIGTERM,handleint); #ifdef SIGHUP signal(SIGHUP,handleint); #endif /* SIGHUP */ #ifdef SIGQUIT signal(SIGQUIT,handleint); #endif /* SIGQUIT */ #ifdef SIGPIPE signal(SIGPIPE,handleint); #endif /* SIGPIPE */ #ifdef SIGALRM signal(SIGALRM,transfer_timeout); #endif /* SIGALRM */ if (visiobases_dir && chdir(visiobases_dir)<0) { perror(visiobases_dir); fprintf(stderr,"couldn't chdir to download dir, please use -d if you want to store files in .\n"); exit(RET_EUNIX); } for(;argc;argc--, argv++) { /* is it an option ? */ if (stilloptions) if (argv[0][0]=='-') { switch (argv[0][1]) { case '-': stilloptions=0; continue; case 's': /* already parsed */ case 'k': case 'm': argc--; argv++; case 'b': case 'n': case 'f': case 'i': case 'd': default: continue; } } /* no, a file name, let's try to transfer it */ transfer(argv[0]); } printf("transfers finished\n"); transfer_finish(transfer); brlapi_leaveRawMode(); /* can't do much it it fails ! */ brlapi_closeConnection(); return 0; }
/* ** Closes the connection to BRLAPI */ int brl_close(void) { brlapi_leaveRawMode(); brlapi_closeConnection(); return 0; }