Logo Search packages:      
Sourcecode: cafix version File versions  Download package

com.c

#include <curses.h>
#include <unistd.h>
#include <stdlib.h>
int key, serialport, top, center, vreturn;
void checkreturn();
void sortir();
int main() {
initscr(); start_color(); init_pair(1,COLOR_GREEN,COLOR_BLACK); noecho(); curs_set(0);
serialport=0;
top=LINES/2-5;
center=COLS/2;
mvprintw(0,center-8,"Cafix port selector");
mvprintw(top,center,"ttyS0");
mvprintw(top+1,center,"ttyS1");
mvprintw(top+2,center,"ttyS2");
mvprintw(top+3,center,"ttyS4");
attr_on(COLOR_PAIR(1),NULL);
mvprintw(top+serialport,center-5,"->");
mvprintw(LINES-3,10,"press \"q\" to quit when done", serialport);


while (1) {key= getch();

mvprintw(LINES/2,center,"%i, %i\n",vreturn, key);
switch(key) {
case 10:
                switch(serialport){
                case 0:
                vreturn=system("ln -f -s /dev/ttyS0 /dev/casio 2>/dev/null");
                checkreturn();
                break;
                case 1:
                vreturn=system("ln -f -s /dev/ttyS1 /dev/casio 2>/dev/null");
                checkreturn();
                break;
                case 2:
                vreturn=system("ln -f -s /dev/ttyS2 /dev/casio 2>/dev/null");
                checkreturn();
                break;
                case 3:
                vreturn=system("ln -f -s /dev/ttyS3 /dev/casio 2>/dev/null");
                checkreturn();
                break;

                }
break;
case 65:
if (serialport>0) {mvprintw(top+serialport,center-5,"  "); serialport=serialport-1;}
break;
case 66:
if (serialport<3) { mvprintw(top+serialport,center-5,"  ");serialport=serialport+1;}
break;
case 113:
endwin();
return;
break;
default:
break;
}
mvprintw(top+serialport,center-5,"->");
}}


void checkreturn(){
                move(LINES-3,10);
                clrtoeol();
switch(vreturn) {
        case 0:
        mvprintw(LINES-3,10,"/dev/casio was successfully linked to /dev/ttyS%d", serialport);
        break;
        case 256:
        mvprintw(LINES-3,10,"You have to be root to do this");
        break;
}}

Generated by  Doxygen 1.6.0   Back to index