/* ** Initialize the application and connect to brlapi ** Init brlapi raw mode and print a welcome message on the terminal */ int brl_init(t_env *env) { brlapi_settings_t settings; char p[100]; unsigned int x, y; settings.host = NULL; /* Connect to BrlAPI */ if (brlapi_initializeConnection(NULL, NULL) < 0) { brlapi_perror("brlapi_initializeConnection"); return -1; } /* Get driver id & name */ brlapi_getDriverName(p, 100); if (!p) brlapi_perror("brlapi_getDriverName"); else printf("Driver name: %s\n",p); /* Get display size */ if (brlapi_getDisplaySize(&x, &y) < 0) brlapi_perror("brlapi_getDisplaySize"); else printf("Braille display has %d line%s of %d column%s\n",y,y>1?"s":"",x,x>1?"s":""); /* Try entering raw mode, immediately go out from raw mode */ printf("Trying to enter in raw mode... "); if (brlapi_enterRawMode("EuroBraille") < 0) brlapi_perror("brlapi_getRaw"); else { printf("Ok\n"); } /* welcome message */ brl_lasting_message(EUTP_VERSION); get_ident(env->ident); printf("Identification: %20s\n", env->ident); return 0; }
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; }