2 do_ctl(optype,stab,func,argstr)
12 if (!stab || !argstr || !(stio = stab_io(stab)) || !stio->ifp) {
13 errno = EBADF; /* well, sort of... */
17 if (argstr->str_pok || !argstr->str_nok) {
23 #define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
27 retval = IOCPARM_LEN(func); /* on BSDish systes we're safe */
29 retval = 256; /* otherwise guess at what's safe */
31 if (argstr->str_cur < retval) {
32 Str_Grow(argstr,retval+1);
33 argstr->str_cur = retval;
37 s[argstr->str_cur] = 17; /* a little sanity check here */
40 retval = (int)str_gnum(argstr);
42 s = (char*)(long)retval; /* ouch */
44 s = (char*)retval; /* ouch */
49 if (optype == O_IOCTL)
50 retval = ioctl(fileno(stio->ifp), func, s);
53 fatal("fcntl is not implemented");
56 retval = fcntl(fileno(stio->ifp), func, s);
58 fatal("fcntl is not implemented");
65 if (argstr->str_pok) {
66 if (s[argstr->str_cur] != 17)
67 fatal("Return value overflowed string");
68 s[argstr->str_cur] = 0; /* put our null back */