static void smsctransmit(Dev *ep, Block *b) { int n; n = BLEN(b); b->rp -= 8; PUT4(b->rp, n | Txfirst | Txlast); PUT4(b->rp+4, n); write(ep->dfd, b->rp, BLEN(b)); freeb(b); }
static int plsetparam(Serialport *p) { uint8_t buf[ParamReqSz]; int res; Serial *ser; ser = p->s; PUT4(buf, p->baud); if(p->stop == 1) buf[4] = 0; else if(p->stop == 2) buf[4] = 2; /* see comment in getparam */ buf[5] = p->parity; buf[6] = p->bits; dsprint(2, "serial: setparam: "); if(serialdebug) dumpbuf(buf, sizeof buf); res = usbcmd(ser->dev, Rh2d | Rclass | Riface, SetLineReq, 0, 0, buf, sizeof buf); plmodemctl(p, p->mctl); plgetparam(p); /* make sure our state corresponds */ dsprint(2, "serial: setparam res: %d\n", res); return res; }
void write_constant_pool (CPool *cpool, unsigned char *buffer, int length) { unsigned char *ptr = buffer; int i = 1; union cpool_entry *datap = &cpool->data[1]; PUT2 (cpool->count); for ( ; i < cpool->count; i++, datap++) { int tag = cpool->tags[i]; PUT1 (tag); switch (tag) { case CONSTANT_NameAndType: case CONSTANT_Fieldref: case CONSTANT_Methodref: case CONSTANT_InterfaceMethodref: case CONSTANT_Float: case CONSTANT_Integer: PUT4 (datap->w); break; case CONSTANT_Class: case CONSTANT_String: PUT2 (datap->w); break; break; case CONSTANT_Long: case CONSTANT_Double: PUT4(datap->w); i++; datap++; PUT4 (datap->w); break; case CONSTANT_Utf8: { tree t = datap->t; int len = IDENTIFIER_LENGTH (t); PUT2 (len); PUTN (IDENTIFIER_POINTER (t), len); } break; } } if (ptr != buffer + length) abort (); }
static int zft_write_header_segments(__u8* buffer) { int header_1_ok = 0; int header_2_ok = 0; unsigned int time_stamp; TRACE_FUN(ft_t_noise); TRACE_CATCH(ftape_abort_operation(),); ftape_seek_to_bot(); /* prevents extra rewind */ if (GET4(buffer, 0) != FT_HSEG_MAGIC) { TRACE_ABORT(-EIO, ft_t_err, "wrong header signature found, aborting"); } /* Be optimistic: */ PUT4(buffer, FT_SEG_CNT, zft_written_segments + GET4(buffer, FT_SEG_CNT) + 2); if ((time_stamp = zft_get_time()) != 0) { PUT4(buffer, FT_WR_DATE, time_stamp); if (zft_label_changed) { PUT4(buffer, FT_LABEL_DATE, time_stamp); } } TRACE(ft_t_noise, "writing first header segment %d", ft_header_segment_1); header_1_ok = zft_verify_write_segments(ft_header_segment_1, buffer, FT_SEGMENT_SIZE, zft_deblock_buf) >= 0; TRACE(ft_t_noise, "writing second header segment %d", ft_header_segment_2); header_2_ok = zft_verify_write_segments(ft_header_segment_2, buffer, FT_SEGMENT_SIZE, zft_deblock_buf) >= 0; if (!header_1_ok) { TRACE(ft_t_warn, "Warning: " "update of first header segment failed"); } if (!header_2_ok) { TRACE(ft_t_warn, "Warning: " "update of second header segment failed"); } if (!header_1_ok && !header_2_ok) { TRACE_ABORT(-EIO, ft_t_err, "Error: " "update of both header segments failed."); } TRACE_EXIT 0; }
/* copy Z-label string to buffer, keeps track of the correct offset in * `buffer' */ void zft_update_label(__u8 *buffer) { TRACE_FUN(ft_t_flow); if (strncmp(&buffer[FT_LABEL], ZFTAPE_LABEL, sizeof(ZFTAPE_LABEL)-1) != 0) { TRACE(ft_t_info, "updating label from \"%s\" to \"%s\"", &buffer[FT_LABEL], ZFTAPE_LABEL); strcpy(&buffer[FT_LABEL], ZFTAPE_LABEL); memset(&buffer[FT_LABEL] + sizeof(ZFTAPE_LABEL) - 1, ' ', FT_LABEL_SZ - sizeof(ZFTAPE_LABEL + 1)); PUT4(buffer, FT_LABEL_DATE, 0); zft_label_changed = zft_header_changed = 1; /* changed */ } TRACE_EXIT; }