static INLINE uint8_t GetTTL (const EncState* enc) { char dir; if ( enc->p->packet_flags & PKT_FROM_CLIENT ) dir = FORWARD(enc) ? SSN_DIR_CLIENT : SSN_DIR_SERVER; else dir = FORWARD(enc) ? SSN_DIR_SERVER : SSN_DIR_CLIENT; return stream_api->get_session_ttl( enc->p->ssnptr, dir, !enc->ip_hdr); }
int SanityCheck1(Heap * h, Item * i) { Heap * h1; if(h == NULL_HEAP) { return(TRUE); } h1 = h; do { if(LessThan(ITEM(h1), i)) { return(FALSE); } if(!SanityCheck1(CHILD(h1), ITEM(h1))) { return(FALSE); } h1 = FORWARD(h1); } while(h1 != h); return(TRUE); }
void PrettyPrint(Heap * h) { Heap * h1; if(h == NULL_HEAP) { printf(" nil "); return; } printf("("); h1 = h; do { PrintItem(ITEM(h1)); printf("[%u] ", RANK(h1)); PrettyPrint(CHILD(h1)); h1 = FORWARD(h1); } while(h1 != h); printf(")"); }
DRESULT disk_readp ( BYTE *buff, /* Pointer to the read buffer (NULL:Read bytes are forwarded to the stream) */ DWORD lba, /* Sector number (LBA) */ WORD ofs, /* Byte offset to read from (0..511) */ WORD cnt /* Number of bytes to read (ofs + cnt mus be <= 512) */ ) { DRESULT res; BYTE rc; WORD bc; if (!(CardType & CT_BLOCK)) lba *= 512; /* Convert to byte address if needed */ res = RES_ERROR; if (send_cmd(CMD17, lba) == 0) { /* READ_SINGLE_BLOCK */ bc = 40000; do { /* Wait for data packet */ rc = rcv_spi(); } while (rc == 0xFF && --bc); if (rc == 0xFE) { /* A data packet arrived */ bc = 514 - ofs - cnt; /* Skip leading bytes */ if (ofs) { do rcv_spi(); while (--ofs); } /* Receive a part of the sector */ if (buff) { /* Store data to the memory */ do { *buff++ = rcv_spi(); } while (--cnt); } else { /* Forward data to the outgoing stream (depends on the project) */ do { FORWARD(rcv_spi()); } while (--cnt); } /* Skip trailing bytes and CRC */ do rcv_spi(); while (--bc); res = RES_OK; } } DESELECT(); rcv_spi(); return res; }
static ENC_STATUS IP4_Encode (EncState* enc, Buffer* in, Buffer* out) { int len; uint32_t start = out->end; IPHdr* hi = (IPHdr*)enc->p->layers[enc->layer-1].start; IPHdr* ho = (IPHdr*)(out->base + out->end); PROTO_ID next = NextEncoder(enc); UPDATE_BOUND(out, sizeof(*ho)); /* IPv4 encoded header is hardcoded 20 bytes */ ho->ip_verhl = 0x45; ho->ip_off = 0; ho->ip_id = IpId_Next(); ho->ip_tos = hi->ip_tos; ho->ip_proto = hi->ip_proto; if ( FORWARD(enc) ) { ho->ip_src.s_addr = hi->ip_src.s_addr; ho->ip_dst.s_addr = hi->ip_dst.s_addr; ho->ip_ttl = FwdTTL(enc, hi->ip_ttl); } else { ho->ip_src.s_addr = hi->ip_dst.s_addr; ho->ip_dst.s_addr = hi->ip_src.s_addr; ho->ip_ttl = RevTTL(enc, hi->ip_ttl); } enc->ip_hdr = (uint8_t*)hi; enc->ip_len = IP_HLEN(hi) << 2; if ( next < PROTO_MAX ) { ENC_STATUS err = encoders[next].fencode(enc, in, out); if ( ENC_OK != err ) return err; } if ( enc->proto ) { ho->ip_proto = enc->proto; enc->proto = 0; } len = out->end - start; ho->ip_len = htons((uint16_t)len); ho->ip_csum = 0; /* IPv4 encoded header is hardcoded 20 bytes, we save some * cycles and use the literal header size for checksum */ ho->ip_csum = in_chksum_ip((const uint16_t *)ho, sizeof *ho); return ENC_OK; }
int SanityCheck2(Heap * h) { int sum; Heap * h1; Heap * h2; if(h == NULL_HEAP) { return(TRUE); } h1 = h; do { if(CHILD(h1) != NULL_HEAP) { sum = 0; h2 = CHILD(h1); do { sum += RANK(h2) + 1; h2 = FORWARD(h2); } while(h2 != CHILD(h1)); if(sum != RANK(h1)) { return(FALSE); } if(!SanityCheck2(CHILD(h1))) { return(FALSE); } } h1 = FORWARD(h1); } while(h1 != h); return(TRUE); }
DRESULT disk_readp ( BYTE *buff, /* Pointer to the read buffer (NULL:Forward to the stream) */ DWORD sector, /* Sector number (LBA) */ UINT offset, /* Byte offset to read from (0..511) */ UINT count /* Number of bytes to read (ofs + cnt mus be <= 512) */ ) { DRESULT res; BYTE rc; UINT bc; if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ res = RES_ERROR; if (send_cmd(CMD17, sector) == 0) { /* READ_SINGLE_BLOCK */ bc = 40000; /* Time counter */ do { /* Wait for data packet */ rc = rcv_spi(); } while (rc == 0xFF && --bc); if (rc == 0xFE) { /* A data packet arrived */ bc = 512 + 2 - offset - count; /* Number of trailing bytes to skip */ /* Skip leading bytes */ while (offset--) rcv_spi(); /* Receive a part of the sector */ if (buff) { /* Store data to the memory */ do { *buff++ = rcv_spi(); } while (--count); } else { /* Forward data to the outgoing stream */ do { FORWARD(rcv_spi()); } while (--count); } /* Skip trailing bytes and CRC */ do rcv_spi(); while (--bc); res = RES_OK; } } DESELECT(); rcv_spi(); return res; }
DRESULT disk_readp ( BYTE *buff, /* Pointer to the read buffer (NULL:Read bytes are forwarded to the stream) */ DWORD lba, /* Sector number (LBA) */ WORD ofs, /* Byte offset to read from (0..511) */ WORD cnt /* Number of bytes to read (ofs + cnt mus be <= 512) */ ) { DRESULT res; BYTE d; WORD bc, tmr; if (!(CardType & CT_BLOCK)) lba *= 512; /* Convert to byte address if needed */ res = RES_ERROR; if (send_cmd(CMD17, lba) == 0) { /* READ_SINGLE_BLOCK */ tmr = 1000; do { /* Wait for data packet in timeout of 100ms */ DLY_US(100); d = rcvr_mmc(); } while (d == 0xFF && --tmr); if (d == 0xFE) { /* A data packet arrived */ bc = 514 - ofs - cnt; /* Skip leading bytes */ if (ofs) skip_mmc(ofs); /* Receive a part of the sector */ if (buff) { /* Store data to the memory */ do *buff++ = rcvr_mmc(); while (--cnt); } else { /* Forward data to the outgoing stream */ do { d = rcvr_mmc(); FORWARD(d); } while (--cnt); } /* Skip trailing bytes and CRC */ skip_mmc(bc); res = RES_OK; } } release_spi(); return res; }
static inline uint8_t GetTTL (const EncState* enc) { char dir; uint8_t ttl; int outer = !enc->ip_hdr; if ( !enc->p->ssnptr ) return 0; if ( enc->p->packet_flags & PKT_FROM_CLIENT ) dir = FORWARD(enc) ? SSN_DIR_FROM_CLIENT : SSN_DIR_FROM_SERVER; else dir = FORWARD(enc) ? SSN_DIR_FROM_SERVER : SSN_DIR_FROM_CLIENT; // outermost ip is considered to be outer here, // even if it is the only ip layer ... ttl = session_api->get_session_ttl(enc->p->ssnptr, dir, outer); // so if we don't get outer, we use inner if ( 0 == ttl && outer ) ttl = session_api->get_session_ttl(enc->p->ssnptr, dir, 0); return ttl; }
static ENC_STATUS Eth_Encode (EncState* enc, Buffer* in, Buffer* out) { // not raw ip -> encode layer 2 int raw = ( enc->flags & ENC_FLAG_RAW ); EtherHdr* hi = (EtherHdr*)enc->p->layers[enc->layer-1].start; PROTO_ID next = NextEncoder(enc); // if not raw ip AND out buf is empty if ( !raw && (out->off == out->end) ) { // for alignment out->off = out->end = SPARC_TWIDDLE; } // if not raw ip OR out buf is not empty if ( !raw || (out->off != out->end) ) { // we get here for outer-most layer when not raw ip // we also get here for any encapsulated ethernet layer. EtherHdr* ho = (EtherHdr*)(out->base + out->end); UPDATE_BOUND(out, sizeof(*ho)); ho->ether_type = hi->ether_type; if ( FORWARD(enc) ) { memcpy(ho->ether_src, hi->ether_src, sizeof(ho->ether_src)); /*If user configured remote MAC address, use it*/ if (NULL != dst_mac) memcpy(ho->ether_dst, dst_mac, sizeof(ho->ether_dst)); else memcpy(ho->ether_dst, hi->ether_dst, sizeof(ho->ether_dst)); } else { memcpy(ho->ether_src, hi->ether_dst, sizeof(ho->ether_src)); /*If user configured remote MAC address, use it*/ if (NULL != dst_mac) memcpy(ho->ether_dst, dst_mac, sizeof(ho->ether_dst)); else memcpy(ho->ether_dst, hi->ether_src, sizeof(ho->ether_dst)); } } if ( next < PROTO_MAX ) return encoders[next].fencode(enc, in, out); return ENC_OK; }
static ENC_STATUS FPath_Encode (EncState* enc, Buffer* in, Buffer* out) { // not raw ip -> encode layer 2 int raw = ( enc->flags & ENC_FLAG_RAW ); FPathHdr* hi = (FPathHdr*)enc->p->layers[enc->layer-1].start; PROTO_ID next = NextEncoder(enc); // if not raw ip AND out buf is empty if ( !raw && (out->off == out->end) ) { // for alignment out->off = out->end = 0; } // if not raw ip OR out buf is not empty if ( !raw || (out->off != out->end) ) { // we get here for outer-most layer when not raw ip // we also get here for any encapsulated ethernet layer. FPathHdr* ho = (FPathHdr*)(out->base + out->end); UPDATE_BOUND(out, sizeof(*ho)); ho->fpath_type = hi->fpath_type; if ( FORWARD(enc) ) { memcpy(ho->fpath_src, hi->fpath_src, sizeof(ho->fpath_src)); memcpy(ho->fpath_dst, hi->fpath_dst, sizeof(ho->fpath_dst)); } else { memcpy(ho->fpath_src, hi->fpath_dst, sizeof(ho->fpath_src)); memcpy(ho->fpath_dst, hi->fpath_src, sizeof(ho->fpath_dst)); } } if ( next < PROTO_MAX ) return encoders[next].fencode(enc, in, out); return ENC_OK; }
static ENC_STATUS Eth_Encode (EncState* enc, Buffer* in, Buffer* out) { int outer = 0; int raw = enc->flags & ENC_FLAG_RAW; EtherHdr* hi = (EtherHdr*)enc->p->layers[enc->layer-1].start; PROTO_ID next = NextEncoder(enc); if ( raw && (out->off == out->end) ) { // for alignment out->off = out->end = SPARC_TWIDDLE; outer = 1; // encoding outermost eth } if ( raw || !outer ) { // we get here for outer-most layer when raw is true; // we also get here for any encapsulated ethernet layer. EtherHdr* ho = (EtherHdr*)(out->base + out->end); UPDATE_BOUND(out, sizeof(*ho)); if ( FORWARD(enc) ) { memcpy(ho, hi, sizeof(*ho)); } else { ho->ether_type = hi->ether_type; memcpy(ho->ether_src, hi->ether_dst, sizeof(ho->ether_src)); memcpy(ho->ether_dst, hi->ether_src, sizeof(ho->ether_dst)); } } if ( next < PROTO_MAX ) return encoders[next].fencode(enc, in, out); return ENC_OK; }
int SanityCheck3(Heap * h, int rank) { int sum; Heap * h1; Heap * h2; if((h == NULL_HEAP) && (rank == 0)) { return(TRUE); } sum = 0; h1 = h; do { sum += RANK(h1) + 1; if(!SanityCheck3(CHILD(h1), RANK(h1))) { return(FALSE); } h1 = FORWARD(h1); } while(h1 != h); if(sum == rank) { return(TRUE); } else { return(FALSE); } }
/* edge_walker assumes that the current edge is being drawn CCW * around the current zone. Since only boundary edges are drawn * and we always walk around with the filled region to the left, * no edge is ever drawn CW. We attempt to advance to the next * edge on this boundary, but if current second endpoint is not * between the two contour levels, we exit back to zone_crosser. * Note that we may wind up marking no points. * -- edge_walker is never called for single level case */ static int edge_walker(Csite *site, Cdata *data, int pass2) { long edge= site->edge; long left= site->left; long n= site->n; long fwd= FORWARD(left,site->imax); long p0= POINT0(edge,fwd); long p1= POINT1(edge,fwd); int jedge= IS_JEDGE(edge,left); long edge0= site->edge0; long left0= site->left0; int level0= site->level0==2; int marked; const GpReal *x= pass2? site->x : 0; const GpReal *y= pass2? site->y : 0; GpReal *xcp= pass2? site->xcp : 0; GpReal *ycp= pass2? site->ycp : 0; int z0, z1, heads_up= 0; for (;;) { /* mark endpoint 0 only if value is 1 there, and this is a * two level task */ z0= data[p0]&Z_VALUE; z1= data[p1]&Z_VALUE; marked= 0; if (z0==1) { /* mark current boundary point */ if (pass2) { xcp[n]= x[p0]; ycp[n]= y[p0]; } marked= 1; } else if (!n) { /* if this is the first point is not between the levels * must do the job of the zone_crosser and mark the first cut here, * so that it will be marked again by zone_crosser as it closes */ if (pass2) { GpReal zcp= site->zlevel[(z0!=0)]; zcp= (zcp-site->z[p0])/(site->z[p1]-site->z[p0]); xcp[n]= zcp*(x[p1]-x[p0]) + x[p0]; ycp[n]= zcp*(y[p1]-y[p0]) + y[p0]; } marked= 1; } if (n) { /* check for closure */ if (level0 && edge==edge0 && left==left0) { site->edge= edge; site->left= left; site->n= n+marked; /* if the curve is closing on a hole, need to make a downslit */ if (fwd<0 && !(data[edge]&(jedge?J_BNDY:I_BNDY))) return slit_cutter(site, data, 0, pass2); return 3; } else if (pass2) { if (heads_up || (fwd<0 && (data[edge]&SLIT_DN))) { site->edge= edge; site->left= left; site->n= n+marked; return slit_cutter(site, data, heads_up, pass2); } } else { /* if this is not first point, clear start mark for this edge */ Cdata start= data[edge]&START_MARK(left); if (start) { data[edge]&=~start; site->count--; } } } if (marked) n++; /* if next endpoint not between levels, need to exit to zone_crosser */ if (z1!=1) { site->edge= edge; site->left= left; site->n= n; return (z1!=0); /* return level closest to p1 */ } /* step to p1 and find next edge * -- turn left if possible, else straight, else right * -- check for upward slit beginning at same time */ edge= p1 + (left>0? left : 0); if (pass2 && jedge && fwd>0 && (data[edge]&SLIT_UP)) { jedge= !jedge; heads_up= 1; } else if (data[edge]&(jedge?I_BNDY:J_BNDY)) { long tmp=fwd; fwd=left; left=-tmp; jedge= !jedge; } else { edge= p1 + (fwd>0? fwd : 0); if (pass2 && !jedge && fwd>0 && (data[edge]&SLIT_UP)) { heads_up= 1; } else if (!(data[edge]&(jedge?J_BNDY:I_BNDY))) { edge= p1 - (left<0? left : 0); jedge= !jedge; { long tmp=fwd; fwd=-left; left=tmp; } } } p0= p1; p1= POINT1(edge,fwd); } }
DRESULT disk_readp ( BYTE *buff, /* Pointer to the read buffer (NULL:Read bytes are forwarded to the stream) */ DWORD sector, /* Sector number (LBA) */ UINT offset, /* Byte offset to read from (0..511) */ UINT count /* Number of bytes to read (ofs + cnt mus be <= 512) */ ) { BYTE *buff_sec = buffer; DRESULT res; BYTE d; UINT bc, tmr; if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ // check if sector is already in sector buffer if(buffer_sector == sector) { buff_sec += offset; // skip to requested bytes while(count--) *buff++ = *buff_sec++; return RES_OK; } res = RES_ERROR; if (send_cmd(CMD17, sector) == 0) { /* READ_SINGLE_BLOCK */ tmr = 1000; do { /* Wait for data packet in timeout of 100ms */ DLY_US(100); d = rcvr_mmc(); } while (d == 0xFF && --tmr); if (d == 0xFE) { /* A data packet arrived */ bc = 512 - offset - count; /* Skip leading bytes (store in buffer only) */ while(offset--) *buff_sec++ = rcvr_mmc(); /* Receive a part of the sector */ if (buff) { /* Store data to the memory */ do *buff_sec++ = *buff++ = rcvr_mmc(); while (--count); } else { /* Forward data to the outgoing stream */ do { *buff_sec++ = d = rcvr_mmc(); FORWARD(d); } while (--count); } /* Skip trailing bytes (store in buffer only) */ while(bc--) *buff_sec++ = rcvr_mmc(); /* and skip crc */ skip_mmc(2); buffer_sector = sector; res = RES_OK; } } release_spi(); return res; }
static ENC_STATUS IP4_Encode (EncState* enc, Buffer* in, Buffer* out) { int len; uint32_t start = out->end; IPHdr* hi = (IPHdr*)enc->p->layers[enc->layer-1].start; IPHdr* ho = (IPHdr*)(out->base + out->end); PROTO_ID next = NextEncoder(enc); UPDATE_BOUND(out, sizeof(*ho)); len = GET_IP_HDR_LEN(hi) - sizeof(*hi); ho->ip_verhl = 0x45; ho->ip_off = 0; ho->ip_id = IpId_Next(); ho->ip_tos = hi->ip_tos; ho->ip_proto = hi->ip_proto; if ( FORWARD(enc) ) { uint8_t ttl = AdjTTL(hi->ip_ttl); ho->ip_src.s_addr = hi->ip_src.s_addr; ho->ip_dst.s_addr = hi->ip_dst.s_addr; if ( enc->p->ssnptr ) ttl = GetTTL(enc); #ifdef NORMALIZER if ( ttl < ScMinTTL() && ScNewTTL() ) ttl = ScNewTTL(); #endif ho->ip_ttl = ttl; } else { uint8_t ttl = MAX_TTL; ho->ip_src.s_addr = hi->ip_dst.s_addr; ho->ip_dst.s_addr = hi->ip_src.s_addr; if ( enc->p->ssnptr ) ttl = GetTTL(enc); #ifdef NORMALIZER if ( ttl < ScMinTTL() && ScNewTTL() ) ttl = ScNewTTL(); #endif ho->ip_ttl = ttl; } enc->ip_hdr = (uint8_t*)hi; enc->ip_len = IP_HLEN(hi) << 2; if ( next < PROTO_MAX ) { int err = encoders[next].fencode(enc, in, out); if ( err ) return err; } if ( enc->proto ) { ho->ip_proto = enc->proto; enc->proto = 0; } len = out->end - start; ho->ip_len = htons((u_int16_t)len); ip_checksum(ho, len); return ENC_OK; }
int main(int argc, char *argv[]) { char *file, *s; extern char *optarg; extern int optind; int i, c; AG_DataSource *ds = NULL; AG_ObjectHeader oh; Uint32 pos, sLen; size_t len; Uint8 *buf, *p; int asis = 0; if (AG_InitCore("agar-disasm", 0) == -1) { return (0); } while ((c = getopt(argc, argv, "?")) != -1) { switch (c) { case '?': default: printusage(); return (1); } } if (argc < 2) { printusage(); return (1); } file = argv[1]; if ((ds = AG_OpenFile(file, "r")) == NULL) { goto fail; } if (AG_ObjectReadHeader(ds, &oh) == -1) { goto fail; } printf("Class:\t\t%s\n", oh.cs.hier); if (oh.cs.libs[0] != '\0') { printf("Modules:\t%s\n", oh.cs.libs); } printf("Dataset at:\t%lx\n", (unsigned long)oh.dataOffs); printf("Version:\t%u.%u\n", oh.ver.major, oh.ver.minor); printf("Flags:\t\t0x%x\n", oh.flags); printf("\n"); if (AG_Seek(ds, 0, AG_SEEK_END) == -1) { goto fail; } len = AG_Tell(ds) - oh.dataOffs; if (AG_Seek(ds, (off_t)oh.dataOffs, AG_SEEK_SET) == -1) { goto fail; } pos = 0; if ((buf = malloc(len)) == NULL) { AG_SetError("Out of memory for dataset (%lu)", (unsigned long)len); goto fail; } if (AG_Read(ds, buf, len) == -1) goto fail; for (p = buf; ;) { for (i = 0; i < nTypes; i++) { if (AG_SwapBE32(*(Uint32 *)p) == types[i].type) { if (asis) { printf("\n"); } asis = 0; break; } } if (i == nTypes) { if (!asis) { printf("[%8s] ", "???"); asis = 1; } if (isprint(*(Uint8 *)p)) { fputc(*(Uint8 *)p, stdout); } else { printf("\\%x", *(Uint8 *)p); } FORWARD(1); continue; } FORWARD(4); printf("[%8s] ", types[i].name); switch (types[i].type) { case AG_SOURCE_UINT8: printf("%u\n", *(Uint8 *)p); FORWARD(1); break; case AG_SOURCE_UINT16: { Uint16 v = AG_SwapBE16(*(Uint16 *)p); printf("%u\n", (unsigned)v); FORWARD(2); } break; case AG_SOURCE_UINT32: { Uint32 v = AG_SwapBE32(*(Uint32 *)p); printf("%lu\n", (unsigned long)v); FORWARD(4); } break; #ifdef HAVE_64BIT case AG_SOURCE_UINT64: { Uint64 v = AG_SwapBE64(*(Uint64 *)p); printf("%llu\n", (unsigned long long)v); FORWARD(8); } break; #endif case AG_SOURCE_FLOAT: { float f = AG_SwapBEFLT(*(float *)p); printf("%f\n", f); FORWARD(4); } break; case AG_SOURCE_DOUBLE: { double f = AG_SwapBEDBL(*(double *)p); printf("%f\n", f); FORWARD(8); } break; #ifdef HAVE_LONG_DOUBLE case AG_SOURCE_LONG_DOUBLE: { long double f=AG_SwapBELDBL(*(long double *)p); printf("%Lf\n", f); FORWARD(16); } break; #endif case AG_SOURCE_STRING: if (AG_SwapBE32(*(Uint32 *)p) != AG_SOURCE_UINT32) { printf("Bad string length!\n"); break; } FORWARD(4); sLen = AG_SwapBE32(*(Uint32 *)p); FORWARD(4); if ((s = malloc(sLen+1)) == NULL) { printf("Out of memory for string!\n"); break; } memcpy(s, p, sLen); s[sLen] = '\0'; printf("\"%s\"\n", s); free(s); FORWARD(sLen); break; default: printf("(skipping)\n"); break; } } out: AG_CloseFile(ds); return (0); fail: fprintf(stderr, "%s\n", AG_GetError()); if (ds != NULL) { AG_CloseFile(ds); } AG_Destroy(); return (1); }
bool DOMInstanceOf(JSContext* cx, JSObject* proxy, int prototypeID, int depth, bool* bp) { FORWARD(domInstanceOf, (cx, proxy, prototypeID, depth, bp)); }
int main() { DDRC = 0xFF; PORTC = 0x00; DDRD = 0x00; PORTD = 0xFF; UCSR0B = 0x00; while(1) { while(tst_bit(PIND, B_ENABLE)); _delay_ms(10); set_bit(PORTC, ENA); set_bit(PORTC, ENB); while(!tst_bit(PIND, B_ENABLE)) { if(!tst_bit(PIND, B_FORWARD)) { _delay_ms(10); FORWARD(); while(!tst_bit(PIND, B_FORWARD)); _delay_ms(10); } if(!tst_bit(PIND, B_BACKWARD)) { _delay_ms(10); BACKWARD(); while(!tst_bit(PIND, B_BACKWARD)); _delay_ms(10); } if(!tst_bit(PIND, B_STOP)) { _delay_ms(10); STOP(); while(!tst_bit(PIND, B_STOP)); _delay_ms(10); } if(!tst_bit(PIND, B_RIGHT)) { _delay_ms(10); RIGHT(); while(!tst_bit(PIND, B_RIGHT)); _delay_ms(10); } if(!tst_bit(PIND, B_LEFT)) { _delay_ms(10); LEFT(); while(!tst_bit(PIND, B_LEFT)); _delay_ms(10); } if(!tst_bit(PIND, B_MOVE_ON)) { _delay_ms(10); MOVE_ON(); while(!tst_bit(PIND, B_MOVE_ON)); _delay_ms(10); } } _delay_ms(10); clr_bit(PORTC, ENA); clr_bit(PORTC, ENB); } } /*MAIN*/
/* zone_crosser assumes you are sitting at a cut edge about to cross * the current zone. It always marks the initial point, crosses at * least one zone, and marks the final point. On non-boundary i-edges, * it is responsible for removing start markers on the first pass. */ static int zone_crosser(Csite *site, Cdata *data, int level, int pass2) { long edge= site->edge; long left= site->left; long n= site->n; long fwd= FORWARD(left,site->imax); long p0, p1; int jedge= IS_JEDGE(edge,left); long edge0= site->edge0; long left0= site->left0; int level0= site->level0==level; int two_levels= site->zlevel[1]>site->zlevel[0]; short *triangle= site->triangle; const GpReal *x= pass2? site->x : 0; const GpReal *y= pass2? site->y : 0; const GpReal *z= pass2? site->z : 0; GpReal zlevel= pass2? site->zlevel[level] : 0.0; GpReal *xcp= pass2? site->xcp : 0; GpReal *ycp= pass2? site->ycp : 0; int z0, z1, z2, z3; int keep_left= 0; /* flag to try to minimize curvature in saddles */ int done= 0; if (level) level= 2; for (;;) { /* set edge endpoints */ p0= POINT0(edge,fwd); p1= POINT1(edge,fwd); /* always mark cut on current edge */ if (pass2) { /* second pass actually computes and stores the point */ GpReal zcp= (zlevel-z[p0])/(z[p1]-z[p0]); xcp[n]= zcp*(x[p1]-x[p0]) + x[p0]; ycp[n]= zcp*(y[p1]-y[p0]) + y[p0]; } if (!done && !jedge) { if (n) { /* if this is not the first point on the curve, and we're * not done, and this is an i-edge, check several things */ if (!two_levels && !pass2 && (data[edge]&OPEN_END)) { /* reached an OPEN_END mark, skip the n++ */ done= 4; /* same return value 4 used below */ break; } /* check for curve closure -- if not, erase any start mark */ if (edge==edge0 && left==left0) { /* may signal closure on a downstroke */ if (level0) done= (!pass2 && two_levels && left<0)? 5 : 3; } else if (!pass2) { Cdata start= data[edge]&(fwd>0?I0_START:I1_START); if (start) { data[edge]&=~start; site->count--; } if (!two_levels) { start= data[edge]&(fwd>0?I1_START:I0_START); if (start) { data[edge]&=~start; site->count--; } } } } } n++; if (done) break; /* cross current zone to another cut edge */ z0= (data[p0]&Z_VALUE) != level; /* 1 if fill toward p0 */ z1= !z0; /* know level cuts edge */ z2= (data[p1+left]&Z_VALUE) != level; z3= (data[p0+left]&Z_VALUE) != level; if (z0==z2) { if (z1==z3) { /* this is a saddle zone, need triangle to decide * -- set triangle if not already decided for this zone */ long zone= edge + (left>0? left : 0); if (triangle) { if (!triangle[zone]) { if (keep_left) triangle[zone]= jedge? -1 : 1; else triangle[zone]= jedge? 1 : -1; } if (triangle[zone]>0? !jedge : jedge) goto bkwd; } else { if (keep_left) goto bkwd; } } /* bend forward (right along curve) */ keep_left= 1; jedge= !jedge; edge= p1 + (left>0? left : 0); { long tmp=fwd; fwd=-left; left=tmp; } } else if (z1==z3) { bkwd: /* bend backward (left along curve) */ keep_left= 0; jedge= !jedge; edge= p0 + (left>0? left : 0); { long tmp=fwd; fwd=left; left=-tmp; } } else { /* straight across to opposite edge */ edge+= left; } /* after crossing zone, edge/left/fwd is oriented CCW relative to * the next zone, assuming we will step there */ /* now that we've taken a step, check for the downstroke * of a slit on the second pass (upstroke checked above) * -- taking step first avoids a race condition */ if (pass2 && two_levels && !jedge) { if (left>0) { if (data[edge]&SLIT_UP) done= 6; } else { if (data[edge]&SLIT_DN) done= 5; } } if (!done) { /* finally, check if we are on a boundary */ if (data[edge] & (jedge?J_BNDY:I_BNDY)) { done= two_levels? 2 : 4; /* flip back into the zone that exists */ left= -left; fwd= -fwd; if (!pass2 && (edge!=edge0||left!=left0)) { Cdata start= data[edge]&START_MARK(left); if (start) { data[edge]&=~start; site->count--; } } } } } site->edge= edge; site->n= n; site->left= left; return done>4? slit_cutter(site, data, done-5, pass2) : done; }
bool DOMInstanceOf(JSContext* cx, JSObject* proxyArg, int prototypeID, int depth, bool* bp) { RootedObject proxy(cx, proxyArg); FORWARD(domInstanceOf, (cx, proxy, prototypeID, depth, bp), false); }
, m_collection( coll ) , m_editors( editors ) {} void beginUpdate() { m_batchMode = true; foreach( TrackEditorPtr ec, m_editors ) ec->beginUpdate(); } void endUpdate() { foreach( TrackEditorPtr ec, m_editors ) ec->endUpdate(); m_batchMode = false; QTimer::singleShot( 0, m_collection, SLOT(slotUpdated()) ); } void setComment( const QString &newComment ) { FORWARD( setComment( newComment ) ) } void setTrackNumber( int newTrackNumber ) { FORWARD( setTrackNumber( newTrackNumber ) ) } void setDiscNumber( int newDiscNumber ) { FORWARD( setDiscNumber( newDiscNumber ) ) } void setBpm( const qreal newBpm ) { FORWARD( setBpm( newBpm ) ) } void setTitle( const QString &newTitle ) { FORWARD( setTitle( newTitle ) ) } void setArtist( const QString &newArtist ) { FORWARD( setArtist( newArtist ) ) } void setAlbum( const QString &newAlbum ) { FORWARD( setAlbum( newAlbum ) ) } void setAlbumArtist( const QString &newAlbumArtist ) { FORWARD( setAlbumArtist ( newAlbumArtist ) ) } void setGenre( const QString &newGenre ) { FORWARD( setGenre( newGenre ) ) } void setComposer( const QString &newComposer ) { FORWARD( setComposer( newComposer ) ) } void setYear( int newYear ) { FORWARD( setYear( newYear ) ) } private: bool m_batchMode; Collections::AggregateCollection *m_collection; QList<TrackEditorPtr> m_editors; };