double path (float p[], int n_args) /* for polar coordinates */ { float rhos[500], thetas[500]; int i, t; static double z = 0.017453292; /* Pi/180 */ /* check for proper input triplets */ if (n_args % 3) die("path", "Incorrect number of args. Check triplets!"); /* Separate coordinates */ t = 0; for (i = 0; i < n_args; i+=3) { rhos[t] = thetas[t] = p[i]; /* the time values */ rhos[t+1] = p[i+1]; thetas[t+1] = z * p[i+2]; /* convert to radians here */ t += 2; } /* Load into arrays */ setline(rhos,t,ARRAYSIZE,rholoc); setline(thetas,t,ARRAYSIZE,thetaloc); cartflag = 0; return 0.0; }
void _d_ipaddrv4_print(char_t* result, ipv4_addr_t *addr, int32_t retraction) { char_t line[128]; setline(result, line, retraction, "IPv4 address ptr: %p", addr); setline(result, line, retraction, "Value: %x", addr->value); setline(result, line, retraction, "Value: %d.%d.%d.%d", addr->bytes[0],addr->bytes[1],addr->bytes[2],addr->bytes[3]); }
double cpath (float p[], int n_args) /* for cartesian coordinates */ { float rhos[500], thetas[500]; int i, t; /* check for proper input triplets */ if (n_args % 3) die("cpath", "Incorrect number of args. Check triplets!"); /* Separate coordinates */ t = 0; for (i = 0; i < n_args; i+=3) { rhos[t] = thetas[t] = p[i]; rhos[t+1] = p[i+1]; thetas[t+1] = p[i+2]; t += 2; } /* Load into arrays */ setline(rhos,t,ARRAYSIZE,rholoc); setline(thetas,t,ARRAYSIZE,thetaloc); cartflag = 1; return 0.0; }
//sends data to lcd void sendData2Lcd() { if(it_is_first_time==1) { int j; char msg []="Kisobookaahh!!! software"; char *msg_address; setline(); msg_address=&msg; for(j=1;j<=32;j++) { P0=*msg_address++; toggleEnablePin(); } } else { if(number_representing_whose_turn_it_is==1) { int j; char msg []="Rd 1 and 2 GO!!"; char *msg_address; setline(); msg_address=&msg; for(j=1;j<=16;j++) { P0=*msg_address++; toggleEnablePin(); } } else if(number_representing_whose_turn_it_is==2) { int j; char msg []="Rd 3 and 4 GO!!"; char *msg_address; setline(); msg_address=&msg; for(j=1;j<=16;j++) { P0=*msg_address++; toggleEnablePin(); } } else if(number_representing_whose_turn_it_is==3) { int j; char msg []="Rd 5 and 6 GO!!"; char *msg_address; setline(); msg_address=&msg; for(j=1;j<=16;j++) { P0=*msg_address++; toggleEnablePin(); } } } }
int ujump(BW *bw) { int rtn = -1; P *p = pdup(bw->cursor, USTR "ujump"); P *q = pdup(p, USTR "ujump"); unsigned char *s; p_goto_bol(p); p_goto_eol(q); s = brvs(p, (int) (q->byte - p->byte)); prm(p); prm(q); if (s) { unsigned char *name = NULL; long line = -1; if (bw->b->parseone) bw->b->parseone(bw->b->o.charmap,s,&name,&line); else parseone(bw->b->o.charmap,s,&name,&line); if (name && line != -1) { ERROR *p = srcherr(name, line); if (p != NULL) { errptr = p; setline(errbuf, errptr->src); name = p->file; line = p->line; } uprevvw((BASE *)bw); rtn = jump_to_file_line(maint->curwin->object, name, line, NULL /* errptr->msg */); vsrm(name); } vsrm(s); } return rtn; }
static int mzp_init(int fd, unsigned long *id, unsigned long *extra) { if (logitech_command(fd, "*X*q")) return -1; setline(fd, CS8, B9600); return 0; }
static int warrior_init(int fd, unsigned long *id, unsigned long *extra) { if (logitech_command(fd, "*S")) return -1; setline(fd, CS8, B4800); return 0; }
void _d_pheader_print(char_t* result, ip_packet_header_t *header, int32_t retraction) { char_t line[128]; if(header == NULL){ setline(result, line, retraction, "%s", "HEADER IS NOT EXISTS"); return; } if(header->version == 4) { _d_pheaderv4_print(result, &(header->ipv4), retraction); } else if(header->version == 6){ _d_pheaderv6_print(result, &(header->ipv6), retraction); } else{ setline(result, line, retraction, "Version: %d", header->version); } }
void quoteline() /**/ { char *s; line[ll] = '\0'; s = makequote((char *) line); setline(s); }
// xmit_init is the only function that is required. It must set the xcvrio.send function // to a non-null value immediately // // return a non-zero number to indicate error int xmit_init(struct xcvrio *arg) { unsigned char d,cr; char buf[15]; ssize_t res; syslog(LOG_INFO,"Transmit thread starting\n"); sem_init(&sem_ack,0,0); io = arg; io->status = 1; io->send = transmit; // Now, connect up and set the status to 0 if successful. Finally, post to the semaphore to let // the parent know that all is well...then just wait for input from the device... serial = open(io->device,O_RDWR | O_NOCTTY | O_NONBLOCK); if (serial < 0) { syslog(LOG_INFO,"Error opening %s (%s)\n",io->device,strerror(errno)); goto error; } setline(serial,CS8,B9600); // specific to the device while(!readchar(serial,&d,timeout)); syslog(LOG_INFO,"Connecting to Powerlinc Serial Interface on %s\n",io->device); d = 0x02; res = write(serial,&d,1); if (res < 1) { syslog(LOG_INFO,"Error write to %s (%s)\n",io->device,strerror(errno)); goto error; } if (readchar(serial,&d,timeout)) { syslog(LOG_INFO,"Timeout reading from %s\n",io->device); goto error; } readchar(serial,&cr,timeout); if (d != 0x06) { syslog(LOG_INFO,"PowerLinc serial module found, but not ready\n"); goto error; } d = 'g'; res = write(serial,&d,1); readchar(serial,&buf[0],timeout); readchar(serial,&buf[1],timeout); readchar(serial,&buf[2],timeout); buf[3] = '\0'; syslog(LOG_INFO,"Powerinc version %s found\n",buf); done: io->status = 0; sem_post(&io->connected); if (delay < 1000) delay = 1000; sem_init(&cts,0,1); start(); return 0; error: io->status = errno; sem_post(&io->connected); return 1; }
void _d_pheaderv6_print(char_t* result, ipv6_packet_header_t *header, int32_t retraction) { char_t line[128]; setline(result, line, retraction, "IPv6 header ptr: %p", header); setline(result, line, retraction, "Flow label: %d", header->flow_label); setline(result, line, retraction, "Hop limit: %d", header->hop_limit); setline(result, line, retraction, "Next header: %d", header->next_header); setline(result, line, retraction, "Payload length: %d", header->payload_length); setline(result, line, retraction, "Traffic class1: %d", header->traffic_class1); setline(result, line, retraction, "Traffic class2: %d", header->traffic_class2); setline(result, line, retraction, "%s", "Source address "); _d_ipaddrv6_print(result, &(header->src_addr), retraction + 1); setline(result, line, retraction, "%s", "Destination address "); _d_ipaddrv6_print(result, &(header->dst_addr), retraction + 1); }
static void set_buffer(UNUSED(Param pm), char *x) { if(x) { setline(x, 0); zsfree(x); } else zlecs = zlell = 0; fixsuffix(); menucmp = 0; }
void main(int argc, char*argv[]) { char *p; Place pl; int newbaud; newbaud = -1; pl = nowhere; ARGBEGIN { default: fprint(2, "usage: %s [-b baud] [-d device] [-l longitude latitude] [-n newbaud]\n", argv0); exits("usage"); case 'D': debug++; break; case 'b': baud = strtol(ARGF(), nil, 0); break; case 'd': serial = ARGF(); break; case 'l': p = ARGF(); if(strtolatlon(p, &p, &pl) < 0) sysfatal("bad position"); while(*p == ' ' || *p == '\t' || *p == '\n') p++; if(*p == '\0') p = ARGF(); if (strtolatlon(p, &p, &pl) < 0) sysfatal("bad position"); while(*p == ' ' || *p == '\t' || *p == '\n') p++; if(*p != '\0') sysfatal("trailing gunk in position"); where = pl; break; case 'n': newbaud = strtol(ARGF(), nil, 0); break; } ARGEND if(newbaud < 0) newbaud = baud; fmtinstall('L', placeconv); print("Initializing GPS to %d baud, at %L, time %s\n", newbaud, where, ctime(time(nil))); setline(); evermore80(where, newbaud); }
//tells user that interrupt has been recieved void sendInterruptMessage() { int j; char msg []="SWITCHING..."; char *msg_address; setline(); msg_address=&msg; for(j=1;j<=16;j++) { P0=*msg_address++; toggleEnablePin(); } }
int zle_goto_hist(int ev) { char *t; remember_edits(); if(!(t = zle_get_event(ev))) return 0; histline = ev; setline(t); clearlist = 1; return 1; }
/* Creates the global array of AIR coefficients. */ void MBASE::set_gains() { int i, nvals = 16; static const float array[16] = { 0, .001, 10, .1, 25, .225, 35, .28, 50, .35, 65, .4, 85, .45, 95, .475 }; /* compensate for SR differences */ double adjust = 1.0 - (0.42 * (SR - 25000) / 25000.0); /* create scaled curve for coeffs */ setline((float *)array, nvals, NCOEFFS, AIRCOEFFS); for (i = 0; i < NCOEFFS; i++) AIRCOEFFS[i] = pow(AIRCOEFFS[i], adjust); }
/* Determines the proper gains for the feedback filters in reverb, based on reverb time and average delay length. It also creates the global array of coefficients. */ void RVB::set_gains(float rvbtime) { int i, fpoint, nvals = 16; float rescale, gain, dist, G1, temp = SR / MACH1; double adjust; static float array[16] = { 0, .001, 10, .1, 25, .225, 35, .28, 50, .35, 65, .4, 85, .45, 95, .475 }; /* compensate for variable delay lengths */ rescale = (0.05 * SR) / Nsdelay[0][0]; /* compensate for SR differences */ adjust = 1.0 - (0.42 * (SR - 25000) / 25000.0); /* create scaled curve for coeffs */ setline(array, nvals, NCOEFFS, AIRCOEFFS); for (i = 0; i < NCOEFFS; i++) AIRCOEFFS[i] = pow((double)AIRCOEFFS[i], adjust); gain = 1.0 - 0.366 / (rvbtime * rescale); /* a la Moorer */ gain = (gain < 0.0) ? 0.0 : gain; #ifdef debug printf("number of samples in each reverb delay line."); #endif for (i = 0; i < 2; ++i) { #ifdef debug printf("\nchannel %d:\n\n", i); #endif for (int j = 0; j < 6; ++j) { dist = Nsdelay[i][j] / temp; fpoint = (int)(dist * (float)NCOEFFS / 300.0); /* 300 ft. max dist. */ /* to avoid overrunning: */ fpoint = (fpoint <= NCOEFFS - 1) ? fpoint : NCOEFFS - 1; G1 = AIRCOEFFS[fpoint - 1]; /* G1 is filter coeff. */ m_rvbData[i][j].Rvb_air[0] = gain * (1.0 - G1); /* G2 is filt. gain */ m_rvbData[i][j].Rvb_air[1] = G1; #ifdef debug printf("delay %d: %g (%7.2f ms.) g1 = %f\n\n", j, Nsdelay[i][j], float(Nsdelay[i][j] * 1000.0 / SR), G1); #endif } } }
/* Reparse errbuf to errors if errbuf is a scratch buffer and it has changed * since the last parse. */ static void reparserr(void) { if (errbuf == NULL || !errbuf->scratch || !errbuf->changed || errbuf->name[0] != '*') { return; } if (errptr != &errors) { /* Keep the original error position. */ unsigned char *name = vsncpy(NULL, 0, sv(errptr->file)); long line = errptr->line; ERROR *p; parserr(errbuf); if (NULL != (p = srcherr(name, line))) { errptr = p; setline(errbuf, errptr->src); } vsrm(name); } else { parserr(errbuf); } }
int main() { int fahr,celsius; char s[50] = "goodmorning"; /*printf("helloworld!\n");*/ /*printf("hello, ");*/ /*printf("world");*/ /*printf("\n");*/ /*fahr = 0;*/ /*while (fahr <=300)*/ /*{*/ /*celsius = 5 * (fahr - 35) / 9;*/ /*printf("%d\t%d\n", fahr, celsius);*/ /*fahr = fahr + 50;*/ /*}*/ setline(s, 50); printf("%s\n",s); return 0; }
static int jump_to_error(BW *bw, ERROR *new_errptr) { W *w; if (new_errptr == NULL) { msgnw(bw->parent, joe_gettext(_("No more errors"))); return -1; } errptr = new_errptr; /* This moves the cursor to the beginning of line errptr->src, * and it also scrolls the window. */ setline(errbuf, errptr->src); /* Set errp to the beginning of line in errbuf. */ w = maint->curwin; do { if (w->watom->what == TYPETW) { BW *bw2 = w->object; if (bw2->b == errbuf) { if (errp != NULL) { pset(errp, bw2->cursor); } else { errp = pdup(bw2->cursor, USTR "errp"); } pgetc(errp); /* Move to next char to let the user type above. */ if (piseol(errp)) /* Undo the move for empty lines. */ p_goto_bol(errp); break; } } } while ((w = w->link.next) != maint->curwin); if (bw->b == errbuf) { uprevvw((BASE *)bw); bw = (BW*) maint->curwin->object; } return jump_to_file_line(bw,errptr->file,errptr->line,NULL /* errptr->msg */); }
int main(int argc, char **argv) { unsigned long devt; int ldisc; int type; long id, extra; int fd; char c; if (argc < 2 || argc > 4 || (argc == 4 && strcmp(argv[3], "--daemon")) || !strcmp("--help", argv[1])) { puts(""); puts("Usage: inputttach <mode> <device>"); puts(""); puts("Modes:"); puts(" --sunkbd -skb Sun Type 4 and Type 5 keyboards"); puts(" --lkkbd -lk DEC LK201 / LK401 keyboards"); puts(" --vsxxx-aa -vs DEC VSXXX-AA / VSXXX-GA mouse and VSXXX-AB tablet"); puts(" --spaceorb -orb SpaceOrb 360 / SpaceBall Avenger"); puts(" --spaceball -sbl SpaceBall 2003 / 3003 / 4000 FLX"); puts(" --magellan -mag Magellan / SpaceMouse"); puts(" --warrior -war WingMan Warrior"); puts(" --stinger -stng Gravis Stinger"); puts(" --mousesystems -msc 3-button Mouse Systems mice"); puts(" --sunmouse -sun 3-button Sun mice"); puts(" --microsoft -bare 2-button Microsoft mice"); puts(" --mshack -ms 3-button mice in Microsoft mode"); puts(" --mouseman -mman 3-button Logitech and Genius mice"); puts(" --intellimouse -ms3 Microsoft IntelliMouse"); puts(" --mmwheel -mmw Logitech mice with 4-5 buttons or wheel"); puts(" --iforce -ifor I-Force joysticks and wheels"); puts(" --h3600ts -ipaq Ipaq h3600 touchscreen"); puts(" --stowawaykbd -ipaqkbd Stowaway keyboard"); puts(" --ps2serkbd -ps2ser PS/2 via serial keyboard"); puts(" --twiddler -twid Handykey Twiddler chording keyboard"); puts(" --twiddler-joy -twidjoy Handykey Twiddler used as a joystick"); puts(""); return 1; } for (type = 0; input_types[type].speed; type++) { if (!strncasecmp(argv[1], input_types[type].name, 16) || !strncasecmp(argv[1], input_types[type].name2, 16)) break; } if (!input_types[type].speed) { fprintf(stderr, "inputattach: invalid mode\n"); return 1; } if ((fd = open(argv[2], O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) { perror("inputattach"); return 1; } setline(fd, input_types[type].flags, input_types[type].speed); if (input_types[type].flush) while (!readchar(fd, &c, 100)); id = input_types[type].id; extra = input_types[type].extra; if (input_types[type].init && input_types[type].init(fd, &id, &extra)) { fprintf(stderr, "inputattach: device initialization failed\n"); return 1; } ldisc = N_MOUSE; if(ioctl(fd, TIOCSETD, &ldisc)) { fprintf(stderr, "inputattach: can't set line discipline\n"); return 1; } devt = input_types[type].type | (id << 8) | (extra << 16); if(ioctl(fd, SPIOCSTYPE, &devt)) { fprintf(stderr, "inputattach: can't set device type\n"); return 1; } if (argc == 4 && !strcmp(argv[3],"--daemon")) daemon(0,0); read(fd, NULL, 0); ldisc = 0; ioctl(fd, TIOCSETD, &ldisc); close(fd); return 0; }
Tchar getch(void) { int k; Tchar i, j; g0: if (ch) { i = ch; if (cbits(i) == '\n') nlflg++; ch = 0; return(i); } if (nlflg) return('\n'); i = getch0(); if (ismot(i)) return(i); k = cbits(i); if (k >= sizeof(gchtab)/sizeof(gchtab[0]) || gchtab[k] == 0) /* nothing special */ return(i); if (k != ESC) { if (k == '\n') { nlflg++; if (ip == 0) numtabp[CD].val++; /* line number */ return(k); } if (k == FLSS) { copyf++; raw++; i = getch0(); if (!fi) flss = i; copyf--; raw--; goto g0; } if (k == RPT) { setrpt(); goto g0; } if (!copyf) { if (k == 'f' && lg && !lgf) { i = getlg(i); return(i); } if (k == fc || k == tabch || k == ldrch) { if ((i = setfield(k)) == 0) goto g0; else return(i); } if (k == '\b') { i = makem(-width(' ' | chbits)); return(i); } } return(i); } k = cbits(j = getch0()); if (ismot(j)) return(j); switch (k) { case 'n': /* number register */ setn(); goto g0; case '$': /* argument indicator */ seta(); goto g0; case '*': /* string indicator */ setstr(); goto g0; case '{': /* LEFT */ i = LEFT; goto gx; case '}': /* RIGHT */ i = RIGHT; goto gx; case '"': /* comment */ while (cbits(i = getch0()) != '\n') ; if (ip == 0) numtabp[CD].val++; /* line number */ nlflg++; return(i); /* experiment: put it here instead of copy mode */ case '(': /* special char name \(xx */ case 'C': /* \C'...' */ if ((i = setch(k)) == 0) goto g0; goto gx; case ESC: /* double backslash */ i = eschar; goto gx; case 'e': /* printable version of current eschar */ i = PRESC; goto gx; case '\n': /* concealed newline */ numtabp[CD].val++; goto g0; case ' ': /* unpaddable space */ i = UNPAD; goto gx; case '\'': /* \(aa */ i = ACUTE; goto gx; case '`': /* \(ga */ i = GRAVE; goto gx; case '_': /* \(ul */ i = UNDERLINE; goto gx; case '-': /* current font minus */ i = MINUS; goto gx; case '&': /* filler */ i = FILLER; goto gx; case 'c': /* to be continued */ i = CONT; goto gx; case '!': /* transparent indicator */ i = XPAR; goto gx; case 't': /* tab */ i = '\t'; return(i); case 'a': /* leader (SOH) */ /* old: *pbp++ = LEADER; goto g0; */ i = LEADER; return i; case '%': /* ohc */ i = OHC; return(i); case 'g': /* return format of a number register */ setaf(); /* should this really be in copy mode??? */ goto g0; case '.': /* . */ i = '.'; gx: setsfbits(i, sfbits(j)); return(i); } if (copyf) { *pbp++ = j; return(eschar); } switch (k) { case 'f': /* font indicator */ setfont(0); goto g0; case 's': /* size indicator */ setps(); goto g0; case 'v': /* vert mot */ numerr.type = numerr.escarg = 0; numerr.esc = k; if (i = vmot()) { return(i); } goto g0; case 'h': /* horiz mot */ numerr.type = numerr.escarg = 0; numerr.esc = k; if (i = hmot()) return(i); goto g0; case '|': /* narrow space */ if (NROFF) goto g0; return(makem((int)(EM)/6)); case '^': /* half narrow space */ if (NROFF) goto g0; return(makem((int)(EM)/12)); case 'w': /* width function */ setwd(); goto g0; case 'p': /* spread */ spread++; goto g0; case 'N': /* absolute character number */ numerr.type = numerr.escarg = 0; numerr.esc = k; if ((i = setabs()) == 0) goto g0; return i; case 'H': /* character height */ numerr.type = numerr.escarg = 0; numerr.esc = k; return(setht()); case 'S': /* slant */ numerr.type = numerr.escarg = 0; numerr.esc = k; return(setslant()); case 'z': /* zero with char */ return(setz()); case 'l': /* hor line */ numerr.type = numerr.escarg = 0; numerr.esc = k; setline(); goto g0; case 'L': /* vert line */ numerr.type = numerr.escarg = 0; numerr.esc = k; setvline(); goto g0; case 'D': /* drawing function */ numerr.type = numerr.escarg = 0; numerr.esc = k; setdraw(); goto g0; case 'X': /* \X'...' for copy through */ setxon(); goto g0; case 'b': /* bracket */ setbra(); goto g0; case 'o': /* overstrike */ setov(); goto g0; case 'k': /* mark hor place */ if ((k = findr(getsn())) != -1) { numtabp[k].val = numtabp[HP].val; } goto g0; case '0': /* number space */ return(makem(width('0' | chbits))); case 'x': /* extra line space */ numerr.type = numerr.escarg = 0; numerr.esc = k; if (i = xlss()) return(i); goto g0; case 'u': /* half em up */ case 'r': /* full em up */ case 'd': /* half em down */ return(sethl(k)); default: return(j); } /* NOTREACHED */ }
void draw_atext(Canvas *canvas, Quark *q) { VPoint anchor; AText *at = atext_get_data(q); TextFrame *tf; view bbox; if (!at || string_is_empty(at->s)) { return; } if (Apoint2Vpoint(q, &at->ap, &anchor) != RETURN_SUCCESS) { return; } anchor.x += at->offset.x; anchor.y += at->offset.y; setclipping(canvas, FALSE); tf = &at->frame; drawtext(canvas, &anchor, &at->text_props, tf, at->s, &bbox); at->bb = bbox; if ((tf->line.pen.pattern || tf->fillpen.pattern) && at->arrow_flag && tf->line.style) { VPoint vp1, vp2; vp2.x = anchor.x - at->offset.x; vp2.y = anchor.y - at->offset.y; switch (tf->decor) { case FRAME_DECOR_LINE: if (vp2.x < bbox.xv1) { vp1.x = bbox.xv1; } else if (vp2.x > bbox.xv2) { vp1.x = bbox.xv2; } else { vp1.x = vp2.x; } vp1.y = bbox.yv1; break; case FRAME_DECOR_OVAL: if (vp2.x < bbox.xv1) { vp1.x = bbox.xv1; } else if (vp2.x > bbox.xv2) { vp1.x = bbox.xv2; } else { vp1.x = (bbox.xv1 + bbox.xv2)/2; } if (vp2.y < bbox.yv1) { vp1.y = bbox.yv1; } else if (vp2.y > bbox.yv2) { vp1.y = bbox.yv2; } else { vp1.y = (bbox.yv1 + bbox.yv2)/2; } break; default: if (vp2.x < bbox.xv1) { vp1.x = bbox.xv1; } else if (vp2.x > bbox.xv2) { vp1.x = bbox.xv2; } else { vp1.x = vp2.x; } if (vp2.y < bbox.yv1) { vp1.y = bbox.yv1; } else if (vp2.y > bbox.yv2) { vp1.y = bbox.yv2; } else { vp1.y = vp2.y; } } setline(canvas, &tf->line); DrawLine(canvas, &vp1, &vp2); draw_arrowhead(canvas, &vp1, &vp2, &at->arrow, &tf->line.pen, &tf->line.pen); } }
void draw_object(Canvas *canvas, Quark *q) { VPoint anchor; DObject *o = object_get_data(q); if (o == NULL) { return; } if (Apoint2Vpoint(q, &o->ap, &anchor) != RETURN_SUCCESS) { return; } anchor.x += o->offset.x; anchor.y += o->offset.y; setclipping(canvas, FALSE); activate_bbox(canvas, BBOX_TYPE_TEMP, TRUE); reset_bbox(canvas, BBOX_TYPE_TEMP); switch (o->type) { case DO_LINE: { DOLineData *l = (DOLineData *) o->odata; VPoint vp1; double x, y, co, si; x = l->vector.x; y = l->vector.y; co = cos(M_PI/180.0*o->angle); si = sin(M_PI/180.0*o->angle); vp1.x = anchor.x + x*co - y*si; vp1.y = anchor.y + x*si + y*co; setline(canvas, &o->line); DrawLine(canvas, &anchor, &vp1); switch (l->arrow_end) { case ARROW_AT_NONE: break; case ARROW_AT_BEGINNING: draw_arrowhead(canvas, &vp1, &anchor, &l->arrow, &o->line.pen, &o->fillpen); break; case ARROW_AT_END: draw_arrowhead(canvas, &anchor, &vp1, &l->arrow, &o->line.pen, &o->fillpen); break; case ARROW_AT_BOTH: draw_arrowhead(canvas, &vp1, &anchor, &l->arrow, &o->line.pen, &o->fillpen); draw_arrowhead(canvas, &anchor, &vp1, &l->arrow, &o->line.pen, &o->fillpen); break; } } break; case DO_BOX: { DOBoxData *b = (DOBoxData *) o->odata; if (o->angle == 0.0) { VPoint vp1, vp2; vp1.x = anchor.x - b->width/2; vp2.x = anchor.x + b->width/2; vp1.y = anchor.y - b->height/2; vp2.y = anchor.y + b->height/2; setpen(canvas, &o->fillpen); DrawFilledRect(canvas, &vp1, &vp2); setline(canvas, &o->line); DrawRect(canvas, &vp1, &vp2); } else { VPoint vps[4]; double x, y, co, si; x = b->width/2; y = b->height/2; co = cos(M_PI/180.0*o->angle); si = sin(M_PI/180.0*o->angle); vps[0].x = anchor.x + x*co - y*si; vps[0].y = anchor.y + x*si + y*co; vps[1].x = anchor.x - x*co - y*si; vps[1].y = anchor.y - x*si + y*co; vps[2].x = anchor.x - x*co + y*si; vps[2].y = anchor.y - x*si - y*co; vps[3].x = anchor.x + x*co + y*si; vps[3].y = anchor.y + x*si - y*co; setpen(canvas, &o->fillpen); DrawPolygon(canvas, vps, 4); setline(canvas, &o->line); DrawPolyline(canvas, vps, 4, POLYLINE_CLOSED); } } break; case DO_ARC: { VPoint vp1, vp2; DOArcData *e = (DOArcData *) o->odata; vp1.x = anchor.x - e->width/2; vp2.x = anchor.x + e->width/2; vp1.y = anchor.y - e->height/2; vp2.y = anchor.y + e->height/2; setpen(canvas, &o->fillpen); /* FIXME: implement true ellipse rotation! */ DrawFilledArc(canvas, &vp1, &vp2, e->angle1 + o->angle, e->angle2, e->closure_type); setline(canvas, &o->line); DrawArc(canvas, &vp1, &vp2, e->angle1 + o->angle, e->angle2, e->closure_type, e->draw_closure); } break; case DO_NONE: break; } get_bbox(canvas, BBOX_TYPE_TEMP, &o->bb); }
void _d_ipaddrv6_print(char_t* result, ipv6_addr_t *addr, int32_t retraction) { char_t line[128]; setline(result, line, retraction, "IPv6 address ptr: %p", addr); setline(result, line, retraction, "Value: %x:%x:%x:%x", addr->value[0],addr->value[1],addr->value[2],addr->value[3]); }
char * zleread(char **lp, char **rp, int flags, int context) { char *s; int old_errno = errno; int tmout = getiparam("TMOUT"); #if defined(HAVE_POLL) || defined(HAVE_SELECT) /* may not be set, but that's OK since getiparam() returns 0 == off */ baud = getiparam("BAUD"); costmult = (baud) ? 3840000L / baud : 0; #endif /* ZLE doesn't currently work recursively. This is needed in case a * * select loop is used in a function called from ZLE. vared handles * * this differently itself. */ if(zleactive) { char *pptbuf; int pptlen; pptbuf = unmetafy(promptexpand(lp ? *lp : NULL, 0, NULL, NULL, &pmpt_attr), &pptlen); write_loop(2, pptbuf, pptlen); free(pptbuf); return shingetline(); } /* * The current status is what we need if we are going * to display a prompt. We'll remember it here for * use further in. */ pre_zle_status = lastval; keytimeout = (time_t)getiparam("KEYTIMEOUT"); if (!shout) { if (SHTTY != -1) init_shout(); if (!shout) return NULL; /* We could be smarter and default to a system read. */ /* If we just got a new shout, make sure the terminal is set up. */ if (termflags & TERM_UNKNOWN) init_term(); } fflush(shout); fflush(stderr); intr(); insmode = unset(OVERSTRIKE); eofsent = 0; resetneeded = 0; fetchttyinfo = 0; trashedzle = 0; raw_lp = lp; lpromptbuf = promptexpand(lp ? *lp : NULL, 1, NULL, NULL, &pmpt_attr); raw_rp = rp; rpmpt_attr = pmpt_attr; rpromptbuf = promptexpand(rp ? *rp : NULL, 1, NULL, NULL, &rpmpt_attr); free_prepostdisplay(); zlereadflags = flags; zlecontext = context; histline = curhist; undoing = 1; zleline = (ZLE_STRING_T)zalloc(((linesz = 256) + 2) * ZLE_CHAR_SIZE); *zleline = ZWC('\0'); virangeflag = lastcmd = done = zlecs = zlell = mark = 0; vichgflag = 0; viinsbegin = 0; statusline = NULL; selectkeymap("main", 1); selectlocalmap(NULL); fixsuffix(); if ((s = getlinknode(bufstack))) { setline(s, ZSL_TOEND); zsfree(s); if (stackcs != -1) { zlecs = stackcs; stackcs = -1; if (zlecs > zlell) zlecs = zlell; CCLEFT(); } if (stackhist != -1) { histline = stackhist; stackhist = -1; } } initundo(); if (isset(PROMPTCR)) putc('\r', shout); if (tmout) alarm(tmout); zleactive = 1; resetneeded = 1; errflag = retflag = 0; lastcol = -1; initmodifier(&zmod); prefixflag = 0; zrefresh(); zlecallhook("zle-line-init", NULL); zlecore(); if (errflag) setsparam("ZLE_LINE_ABORTED", zlegetline(NULL, NULL)); if (done && !exit_pending && !errflag) zlecallhook("zle-line-finish", NULL); statusline = NULL; invalidatelist(); trashzle(); free(lpromptbuf); free(rpromptbuf); zleactive = zlereadflags = lastlistlen = zlecontext = 0; alarm(0); freeundo(); if (eofsent) { s = NULL; } else { zleline[zlell++] = ZWC('\n'); s = zlegetline(NULL, NULL); } free(zleline); zleline = NULL; forget_edits(); errno = old_errno; /* highlight no longer valid */ set_region_highlight(NULL, NULL); return s; }
void _d_pheaderv4_print(char_t* result, ipv4_packet_header_t *header, int32_t retraction) { char_t line[128]; setline(result, line, retraction, "IPv4 header ptr: %p", header); setline(result, line, retraction, "IHL: %d", header->IHL); setline(result, line, retraction, "DSCP: %d", header->DSCP); setline(result, line, retraction, "ECN: %d", header->ECN); setline(result, line, retraction, "Flags: %d", header->flags); setline(result, line, retraction, "Checksum: %d", header->header_checksum); setline(result, line, retraction, "Identification: %d", header->identification); setline(result, line, retraction, "Protocol: %d", header->protocol); setline(result, line, retraction, "TTL: %d", header->time_to_live); setline(result, line, retraction, "Length: %d", header->total_length); setline(result, line, retraction, "%s", "Source address "); _d_ipaddrv4_print(result, &(header->src_addr), retraction + 1); setline(result, line, retraction, "%s", "Destination address "); _d_ipaddrv4_print(result, &(header->dst_addr), retraction + 1); }
int main(int argc, char **argv) { unsigned long devt; int ldisc; struct input_types *type = NULL; const char *device = NULL; int daemon_mode = 0; int need_device = 0; unsigned long id, extra; int fd; int i; char c; int retval; for (i = 1; i < argc; i++) { if (!strcasecmp(argv[i], "--help")) { show_help(); return EXIT_SUCCESS; } else if (!strcasecmp(argv[i], "--daemon")) { daemon_mode = 1; } else if (need_device) { device = argv[i]; need_device = 0; } else { if (type && type->name) { fprintf(stderr, "inputattach: '%s' - " "only one mode allowed\n", argv[i]); return EXIT_FAILURE; } for (type = input_types; type->name; type++) { if (!strcasecmp(argv[i], type->name) || !strcasecmp(argv[i], type->name2)) { break; } } if (!type->name) { fprintf(stderr, "inputattach: invalid mode '%s'\n", argv[i]); return EXIT_FAILURE; } need_device = 1; } } if (!type || !type->name) { fprintf(stderr, "inputattach: must specify mode\n"); return EXIT_FAILURE; } if (need_device) { fprintf(stderr, "inputattach: must specify device\n"); return EXIT_FAILURE; } fd = open(device, O_RDWR | O_NOCTTY | O_NONBLOCK); if (fd < 0) { fprintf(stderr, "inputattach: '%s' - %s\n", device, strerror(errno)); return 1; } setline(fd, type->flags, type->speed); if (type->flush) while (!readchar(fd, &c, 100)) /* empty */; id = type->id; extra = type->extra; if (type->init && type->init(fd, &id, &extra)) { fprintf(stderr, "inputattach: device initialization failed\n"); return EXIT_FAILURE; } ldisc = N_MOUSE; if (ioctl(fd, TIOCSETD, &ldisc)) { fprintf(stderr, "inputattach: can't set line discipline\n"); return EXIT_FAILURE; } devt = type->type | (id << 8) | (extra << 16); if (ioctl(fd, SPIOCSTYPE, &devt)) { fprintf(stderr, "inputattach: can't set device type\n"); return EXIT_FAILURE; } retval = EXIT_SUCCESS; if (daemon_mode && daemon(0, 0) < 0) { perror("inputattach"); retval = EXIT_FAILURE; } read(fd, NULL, 0); ldisc = 0; ioctl(fd, TIOCSETD, &ldisc); close(fd); return retval; }
char * zleread(char **lp, char **rp, int flags, int context, char *init, char *finish) { char *s, **bracket; int old_errno = errno; int tmout = getiparam("TMOUT"); #if defined(HAVE_POLL) || defined(HAVE_SELECT) /* may not be set, but that's OK since getiparam() returns 0 == off */ baud = getiparam("BAUD"); costmult = (baud) ? 3840000L / baud : 0; #endif /* ZLE doesn't currently work recursively. This is needed in case a * * select loop is used in a function called from ZLE. vared handles * * this differently itself. */ if(zleactive) { char *pptbuf; int pptlen; pptbuf = unmetafy(promptexpand(lp ? *lp : NULL, 0, NULL, NULL, &pmpt_attr), &pptlen); write_loop(2, pptbuf, pptlen); free(pptbuf); return shingetline(); } /* * The current status is what we need if we are going * to display a prompt. We'll remember it here for * use further in. */ pre_zle_status = lastval; keytimeout = (time_t)getiparam("KEYTIMEOUT"); if (!shout) { if (SHTTY != -1) init_shout(); if (!shout) return NULL; /* We could be smarter and default to a system read. */ /* If we just got a new shout, make sure the terminal is set up. */ if (termflags & TERM_UNKNOWN) init_term(); } fflush(shout); fflush(stderr); intr(); insmode = unset(OVERSTRIKE); eofsent = 0; resetneeded = 0; fetchttyinfo = 0; trashedzle = 0; raw_lp = lp; lpromptbuf = promptexpand(lp ? *lp : NULL, 1, NULL, NULL, &pmpt_attr); raw_rp = rp; rpmpt_attr = pmpt_attr; rpromptbuf = promptexpand(rp ? *rp : NULL, 1, NULL, NULL, &rpmpt_attr); free_prepostdisplay(); zlereadflags = flags; zlecontext = context; histline = curhist; vistartchange = -1; zleline = (ZLE_STRING_T)zalloc(((linesz = 256) + 2) * ZLE_CHAR_SIZE); *zleline = ZWC('\0'); virangeflag = lastcmd = done = zlecs = zlell = mark = 0; vichgflag = 0; viinsbegin = 0; statusline = NULL; selectkeymap("main", 1); initundo(); fixsuffix(); if ((s = getlinknode(bufstack))) { setline(s, ZSL_TOEND); zsfree(s); if (stackcs != -1) { zlecs = stackcs; stackcs = -1; if (zlecs > zlell) zlecs = zlell; CCLEFT(); } if (stackhist != -1) { histline = stackhist; stackhist = -1; } handleundo(); } /* * If main is linked to the viins keymap, we need to register * explicitly that we're now in vi insert mode as there's * no user operation to indicate this. */ if (openkeymap("main") == openkeymap("viins")) viinsert_init(); selectlocalmap(NULL); if (isset(PROMPTCR)) putc('\r', shout); if (tmout) alarm(tmout); /* * On some windowing systems we may enter this function before the * terminal is fully opened and sized, resulting in an infinite * series of SIGWINCH when the handler prints the prompt before we * have done so here. Therefore, hold any such signal until the * first full refresh has completed. The important bit is that the * handler must not see zleactive = 1 until ZLE really is active. * See the end of adjustwinsize() in Src/utils.c */ queue_signals(); zleactive = 1; resetneeded = 1; /* * Start of the main zle read. * Fully reset error conditions, including user interrupt. */ errflag = retflag = 0; lastcol = -1; initmodifier(&zmod); prefixflag = 0; zrefresh(); unqueue_signals(); /* Should now be safe to acknowledge SIGWINCH */ zlecallhook(init, NULL); if ((bracket = getaparam("zle_bracketed_paste")) && arrlen(bracket) == 2) fputs(*bracket, shout); zrefresh(); zlecore(); if (errflag) setsparam((zlecontext == ZLCON_VARED) ? "ZLE_VARED_ABORTED" : "ZLE_LINE_ABORTED", zlegetline(NULL, NULL)); if ((bracket = getaparam("zle_bracketed_paste")) && arrlen(bracket) == 2) fputs(bracket[1], shout); if (done && !exit_pending && !errflag) zlecallhook(finish, NULL); statusline = NULL; invalidatelist(); trashzle(); free(lpromptbuf); free(rpromptbuf); zleactive = zlereadflags = lastlistlen = zlecontext = 0; alarm(0); freeundo(); if (eofsent || errflag || exit_pending) { s = NULL; } else { zleline[zlell++] = ZWC('\n'); s = zlegetline(NULL, NULL); } free(zleline); zleline = NULL; forget_edits(); errno = old_errno; /* highlight no longer valid */ set_region_highlight(NULL, NULL); return s; }
int inputattach(int argc, char **argv){ unsigned long devt; int ldisc; struct input_types *type = NULL; char *device = NULL; int daemon_mode = 0; int need_device = 0; unsigned long id, extra; int fd; int i; char c; int retval; int baud = -1; for (i = 1; i < argc; i++) { if (!strcasecmp(argv[i], "--help")) { show_help(); return EXIT_SUCCESS; } else if (!strcasecmp(argv[i], "--daemon")) { daemon_mode = 1; } else if (need_device) { device = argv[i]; need_device = 0; } else if (!strcasecmp(argv[i], "--baud")) { if (argc <= i + 1) { show_help(); fprintf(stderr, "inputattach: require baud rate\n"); return EXIT_FAILURE; } baud = atoi(argv[++i]); } else { if (type && type->name) { fprintf(stderr, "inputattach: '%s' - " "only one mode allowed\n", argv[i]); return EXIT_FAILURE; } for (type = input_types; type->name; type++) { if (!strcasecmp(argv[i], type->name) || !strcasecmp(argv[i], type->name2)) { break; } } if (!type->name) { fprintf(stderr, "inputattach: invalid mode '%s'\n", argv[i]); return EXIT_FAILURE; } need_device = 1; } } if (!type || !type->name) { fprintf(stderr, "inputattach: must specify mode\n"); return EXIT_FAILURE; } if (need_device) { fprintf(stderr, "inputattach: must specify device\n"); return EXIT_FAILURE; } fd = open(device, O_RDWR | O_NOCTTY | O_NONBLOCK); if (fd < 0) { fprintf(stderr, "inputattach: '%s' - %s\n", device, strerror(errno)); return 1; } switch(baud) { case -1: break; case 2400: type->speed = B2400; break; case 4800: type->speed = B4800; break; case 9600: type->speed = B9600; break; case 19200: type->speed = B19200; break; case 38400: type->speed = B38400; break; case 115200: type->speed = B115200; break; default: fprintf(stderr, "inputattach: invalid baud rate '%d'\n", baud); return EXIT_FAILURE; } //return(0);//AKIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII setline(fd, type->flags, type->speed); /*acho que é aki o bloqueio*/ if (type->flush) while (!readchar(fd, &c, 100)) /* empty */; id = type->id; extra = type->extra; if (type->init && type->init(fd, &id, &extra)) { fprintf(stderr, "inputattach: device initialization failed\n"); return EXIT_FAILURE; } ldisc = N_MOUSE; if (ioctl(fd, TIOCSETD, &ldisc)) { fprintf(stderr, "inputattach: can't set line discipline\n"); return EXIT_FAILURE; } devt = type->type | (id << 8) | (extra << 16); if (ioctl(fd, SPIOCSTYPE, &devt)) { fprintf(stderr, "inputattach: can't set device type\n"); return EXIT_FAILURE; } retval = EXIT_SUCCESS; if (daemon_mode && daemon(0, 0) < 0) { perror("inputattach"); retval = EXIT_FAILURE; } if(read(fd, NULL, 0)<0){ } ldisc = 0; ioctl(fd, TIOCSETD, &ldisc);/*ou aki*/ close(fd); return retval; }