/* setbkspc.c */ #include #include #include #include #include #include #include int main (int argc, char **argv) { int rc; int errcode; struct termios tio; int verbose= 0; const char *term, *kbs; int handle= 0; if (argc>1 && strcmp (argv[1], "-v")==0) verbose= 1; term= getenv ("TERM"); if (!term || !*term) { fprintf (stderr, "TERM unset\n"); return 3; } rc= tcgetattr (handle, &tio); if (rc) { int ern= errno; fprintf (stderr, "*** error in tcgetattr errno=%d: %s\n" , ern, strerror (ern)); return 4; } errcode= 0; rc= setupterm ((char *)term, handle, &errcode); if (rc) { fprintf (stderr, "setupterm(%s) returned %d errcode=%d\n" , term, rc, errcode); return 5; } kbs= tigetstr ("kbs"); if (kbs==NULL || kbs==(char *)-1 || strlen(kbs)!=1) { fprintf (stderr, "tigetstr(\"kbs\") error result=%p\n" , (void *)kbs); return 5; } if (kbs[0]==tio.c_cc[VERASE]) { if (verbose) { fprintf (stderr, "erase has already been set to 0x%02x\n" , kbs[0]); } return 0; } tio.c_cc[VERASE]= kbs[0]; rc= tcsetattr (handle, TCSAFLUSH, &tio); if (rc) { int ern= errno; fprintf (stderr, "*** error in tcsetattr errno=%d: %s\n" , ern, strerror (ern)); return 6; } if (verbose) { fprintf (stderr, "now erase is set to 0x%02x\n" , kbs[0]); } return 0; }