示例#1
0
static void
garmin_pack_d1004 ( D1004 * prof, uint8 ** pos )
{
    int i;
    int j;

    for ( i = 0; i < 3; i++ ) {
        for ( j = 0; j < 5; j++ ) {
            PUTU8(prof->activities[i].heart_rate_zones[j].low_heart_rate);
            PUTU8(prof->activities[i].heart_rate_zones[j].high_heart_rate);
            SKIP(2);
        }
        for ( j = 0; j < 10; j++ ) {
            PUTF32(prof->activities[i].speed_zones[j].low_speed);
            PUTF32(prof->activities[i].speed_zones[j].high_speed);
            PUTSTR(prof->activities[i].speed_zones[j].name);
        }
        PUTF32(prof->activities[i].gear_weight);
        PUTU8(prof->activities[i].max_heart_rate);
        SKIP(3);
    }
    PUTF32(prof->weight);
    PUTU16(prof->birth_year);
    PUTU8(prof->birth_month);
    PUTU8(prof->birth_day);
    PUTU8(prof->gender);
}
示例#2
0
文件: analysis.c 项目: Jay87682/eserv
int parseURL(ExHttp *pHttp)
{
	/* we should treat URL carefully to prevent security issues. */
	char *ePos = NULL;
	char *pBuf = pHttp->curPos;

	TRIM_HEAD(&pBuf);
	pHttp->url = pBuf;
	SKIP(&pBuf, ' ');
	TRIMI_LB_TAIL(pBuf);

	TRIM_HEAD(&pBuf);
	pHttp->protocol = pBuf;
	SKIP(&pBuf, '\n');
	TRIMI_LB_TAIL(pBuf);

	pHttp->curPos = pBuf;
	pHttp->queryString = NULL;
	if (*(pHttp->method) == 'G') {
		/* if URL is empty, take index file as default */
		if (*(pHttp->url) == '\0') {
			pHttp->url = (char *) IndexFile;
		}
		else if ((ePos = strchr(pHttp->url, '?')) != NULL) {
			*ePos = '\0';
			pHttp->queryString = ++ePos;
			pHttp->paramEndPos = find_lb_end(pHttp->protocol);
		}
	}
	/* convert URL to UTF-8 encoding */
	return url_decode(pHttp->url, pHttp->url, 0);
}
示例#3
0
文件: sql.cpp 项目: Devba/blockparser
    virtual void startBlock(
        const Block *b,
        uint64_t
    )
    {
        if(0<=cutoffBlock && cutoffBlock<b->height) wrapup();

        uint8_t blockHash[kSHA256ByteSize];
        sha256Twice(blockHash, b->data, 80);

        const uint8_t *p = b->data;
        SKIP(uint32_t, version, p);
        SKIP(uint256_t, prevBlkHash, p);
        SKIP(uint256_t, blkMerkleRoot, p);
        LOAD(uint32_t, blkTime, p);

        // id BIGINT PRIMARY KEY
        // hash BINARY(32)
        // time BIGINT
        fprintf(blockFile, "%" PRIu64 "\t", (blkID = b->height-1));

        writeEscapedBinaryBuffer(blockFile, blockHash, kSHA256ByteSize);
        fputc('\t', blockFile);

        fprintf(blockFile, "%" PRIu64 "\n", (uint64_t)blkTime);
        if(0==(b->height)%500) {
            fprintf(
                stderr,
                "block=%8" PRIu64 " "
                "nbOutputs=%8" PRIu64 "\n",
                b->height,
                outputMap.size()
            );
        }
    }
示例#4
0
const char *acl_split_nameval(char *buf, char **name, char **value)
{
	char   *np;				/* name substring */
	char   *vp;				/* value substring */
	char   *cp;
	char   *ep;

	/*
	 * Ugly macros to make complex expressions less unreadable.
	 */
#define SKIP(start, var, cond) \
	for (var = start; *var && (cond); var++);

#define TRIM(s) { \
	char *p; \
	for (p = (s) + strlen(s); p > (s) && ACL_ISSPACE(p[-1]); p--); \
		*p = 0; \
}

	SKIP(buf, np, ACL_ISSPACE(*np));		/* find name begin */
	if (*np == 0)
		return ("missing attribute name");
	SKIP(np, ep, !ACL_ISSPACE(*ep) && *ep != '=');	/* find name end */
	SKIP(ep, cp, ACL_ISSPACE(*cp));			/* skip blanks before '=' */
	if (*cp != '=')				/* need '=' */
		return ("missing '=' after attribute name");
	*ep = 0;				/* terminate name */
	cp++;					/* skip over '=' */
	SKIP(cp, vp, ACL_ISSPACE(*vp));		/* skip leading blanks */
	TRIM(vp);				/* trim trailing blanks */
	*name = np;
	*value = vp;
	return (NULL);
}
示例#5
0
gboolean
mpeg4_util_parse_GOV (GstBuffer * buf, Mpeg4GroupofVideoObjectPlane * gov)
{
  GstBitReader reader = GST_BIT_READER_INIT_FROM_BUFFER (buf);

  guint8 gov_start_code;

  /* start code prefix */
  SKIP (&reader, 24);

  READ_UINT8 (&reader, gov_start_code, 8);
  if (gov_start_code != MPEG4_PACKET_GOV)
    goto wrong_start_code;

  READ_UINT8 (&reader, gov->hours, 5);
  READ_UINT8 (&reader, gov->minutes, 6);
  /* marker bit */
  SKIP (&reader, 1);
  READ_UINT8 (&reader, gov->seconds, 6);

  READ_UINT8 (&reader, gov->closed, 1);
  READ_UINT8 (&reader, gov->broken_link, 1);

  return TRUE;

error:
  GST_WARNING ("error parsing \"Group of Video Object Plane\"");
  return FALSE;

wrong_start_code:
  GST_WARNING ("got buffer with wrong start code");
  goto error;
}
示例#6
0
static void parseTX(
    const uint8_t *&p
)
{
    uint8_t *txHash = 0;
    const uint8_t *txStart = p;

    if(gNeedTXHash && !skip) {
        const uint8_t *txEnd = p;
        parseTX<true>(txEnd);
        txHash = allocHash256();
        sha256Twice(txHash, txStart, txEnd - txStart);
    }

    if(!skip) startTX(p, txHash);

        SKIP(uint32_t, version, p);

        parseInputs<skip>(p, txHash);

        if(gNeedTXHash && !skip)
            gTXMap[txHash] = p;

        parseOutputs<skip, false>(p, txHash);

        SKIP(uint32_t, lockTime, p);

    if(!skip) endTX(p);
}
示例#7
0
SlimList* SlimList_Deserialize(char* serializedList)
{
	int listLength;
	SlimList * list = 0;
	char* current = 0;
	
	if(serializedList == 0 || strlen(serializedList) == 0)
		return 0;
	
	current = serializedList;
	list = SlimList_Create();

	SKIP('[')
	
	listLength = readLength(&current);
	
	SKIP(':')
	
	while (listLength--)
	{
		int elementLength = readLength(&current);
		SKIP(':')
		SlimList_AddBuffer(list, current, elementLength);
		current += elementLength;
		SKIP(':')
	}

	SKIP(']')
	return list;
}
示例#8
0
static void
usage(void)
{
#define SKIP(s)			/* nothing */
#define KEEP(s) s "\n"
    static const char msg[] =
    {
	KEEP("")
	KEEP("Options:")
	SKIP("  -a arpanet  (obsolete)")
	KEEP("  -c          set control characters")
	SKIP("  -d dialup   (obsolete)")
	KEEP("  -e ch       erase character")
	KEEP("  -I          no initialization strings")
	KEEP("  -i ch       interrupt character")
	KEEP("  -k ch       kill character")
	KEEP("  -m mapping  map identifier to type")
	SKIP("  -p plugboard (obsolete)")
	KEEP("  -Q          do not output control key settings")
	KEEP("  -q          display term only, do no changes")
	KEEP("  -r          display term on stderr")
	SKIP("  -S          (obsolete)")
	KEEP("  -s          output TERM set command")
	KEEP("  -V          print curses-version")
	KEEP("  -w          set window-size")
	KEEP("")
	KEEP("If neither -c/-w are given, both are assumed.")
    };
#undef KEEP
#undef SKIP
    (void) fprintf(stderr, "Usage: %s [options] [terminal]\n", _nc_progname);
    fputs(msg, stderr);
    ExitProgram(EXIT_FAILURE);
    /* NOTREACHED */
}
示例#9
0
int rc_read_mapfile(char *filename)
{
	char buffer[1024];
	FILE *mapfd;
	char *c, *name, *id, *q;
	struct map2id_s *p;
	int lnr = 0;

	if ((mapfd = fopen(filename,"r")) == NULL)
	{
		error("rc_read_mapfile: can't read %s: %s", filename, strerror(errno));
		return (-1);
	}

#define SKIP(p) while(*p && isspace(*p)) p++;

	while (fgets(buffer, sizeof(buffer), mapfd) != NULL)
	{
		lnr++;

		q = buffer;

		SKIP(q);

		if ((*q == '\n') || (*q == '#') || (*q == '\0'))
			continue;

		if (( c = strchr(q, ' ')) || (c = strchr(q,'\t'))) {

			*c = '\0'; c++;
			SKIP(c);

			name = q;
			id = c;

			if ((p = (struct map2id_s *)malloc(sizeof(*p))) == NULL) {
				novm("rc_read_mapfile");
				return (-1);
			}

			p->name = strdup(name);
			p->id = atoi(id);
			p->next = map2id_list;
			map2id_list = p;

		} else {

			error("rc_read_mapfile: malformed line in %s, line %d", filename, lnr);
			return (-1);

		}
	}

#undef SKIP

	fclose(mapfd);

	return 0;
}
示例#10
0
bool TestExtDatetime::test_strftime() {
  int ts = f_mktime(0, 0, 0, 8, 5, 1998);

  f_setlocale(2, k_LC_TIME, "C");
  VS(f_strftime("%A", ts), "Wednesday");

  if (f_setlocale(2, k_LC_TIME, "fi_FI")) {
    VS(f_strftime(" in Finnish is %A,", ts), " in Finnish is keskiviikko,");
  } else {
    SKIP("setlocale() failed");
  }

  if (f_setlocale(2, k_LC_TIME, "fr_FR")) {
    VS(f_strftime(" in French %A and", ts), " in French mercredi and");
  } else {
    SKIP("setlocale() failed");
  }

  if (f_setlocale(2, k_LC_TIME, "de_DE")) {
    VS(f_strftime(" in German %A.", ts), " in German Mittwoch.");
  } else {
    SKIP("setlocale() failed");
  }

  f_setlocale(2, k_LC_TIME, "C");

/*
  December 2002 / January 2003
  ISOWk  M   Tu  W   Thu F   Sa  Su
  ----- ----------------------------
  51     16  17  18  19  20  21  22
  52     23  24  25  26  27  28  29
  1      30  31   1   2   3   4   5
  2       6   7   8   9  10  11  12
  3      13  14  15  16  17  18  19
*/
  VS(f_strftime("%V,%G,%Y", f_strtotime("12/28/2002")), "52,2002,2002");
  VS(f_strftime("%V,%G,%Y", f_strtotime("12/30/2002")), "01,2003,2002");
  VS(f_strftime("%V,%G,%Y", f_strtotime("1/3/2003")),   "01,2003,2003");
  VS(f_strftime("%V,%G,%Y", f_strtotime("1/10/2003")),  "02,2003,2003");

/*
  December 2004 / January 2005
  ISOWk  M   Tu  W   Thu F   Sa  Su
  ----- ----------------------------
  51     13  14  15  16  17  18  19
  52     20  21  22  23  24  25  26
  53     27  28  29  30  31   1   2
  1       3   4   5   6   7   8   9
  2      10  11  12  13  14  15  16
*/
  VS(f_strftime("%V,%G,%Y", f_strtotime("12/23/2004")), "52,2004,2004");
  VS(f_strftime("%V,%G,%Y", f_strtotime("12/31/2004")), "53,2004,2004");
  VS(f_strftime("%V,%G,%Y", f_strtotime("1/2/2005")),   "53,2004,2005");
  VS(f_strftime("%V,%G,%Y", f_strtotime("1/3/2005")),   "01,2005,2005");

  return Count(true);
}
示例#11
0
bool Scenario::read(bool save_triggers)
{
	printf("[R] Reading scenario\n");

	FILE *scx=fopen("scndata.hex", "rb");
	if (scx==NULL)
		return false; //must open scn before reading data

	
	trigger_start = skiptotriggers("scndata.hex");

	long bytes_read = 0;
	SKIP(scx, trigger_start);
	
	int numtriggers;
	READ(&numtriggers, sizeof(long), 1, scx);

	printf("\t[R] numtriggers=%d\n",numtriggers);
	
	long trigger_skip=0;
	bool displayed=0;

	std::vector<Trigger *> scen_triggers;
	for (int i=0; i<numtriggers; i++)
	{
		//printf("[R] TRIGGER %d\n", i);
		Trigger *t = new Trigger;
		t->read(scx);
		scen_triggers.push_back(t);
		//printf("[R] END TRIGGER %d. triggerskip=%d\n", i, ftell(scx)-bytes_read);
	}
	if (save_triggers)
		triggers = scen_triggers;
	
	printf("\t[R] Done reading triggers\n");
	
	trigger_skip = ftell(scx) - bytes_read;
	bytes_read+=trigger_skip;

	//at the end is numtriggers longs representing order of triggers.
	//skip them. they're just the display order, not execution order
	SKIP(scx, 4*numtriggers);

	trigger_end = bytes_read;

	scenario_end = skiptoscenarioend("scndata.hex");

	long filesize=fsize("scndata.hex");
	printf("\t[R] trigger start=%d, trigger end=%d\n", trigger_start, trigger_end);
	printf("\t[R] scenario_end=%d\n", scenario_end);
	printf("\t[R] scndata.hex size: %d, size without triggers: %d\n", filesize, filesize-trigger_skip-4*numtriggers-4);

	printf("\t[R] Read done\n");

	fclose(scx);

	return true;
}
示例#12
0
static void
test_protect_symlinks(TestBatchRunner *runner) {
#ifdef ENABLE_SYMLINK_TESTS
    FSFolder *folder    = (FSFolder*)S_set_up();
    String   *foo       = (String*)SSTR_WRAP_UTF8("foo", 3);
    String   *bar       = (String*)SSTR_WRAP_UTF8("bar", 3);
    String   *foo_boffo = (String*)SSTR_WRAP_UTF8("foo/boffo", 9);

    FSFolder_MkDir(folder, foo);
    FSFolder_MkDir(folder, bar);
    OutStream *outstream = FSFolder_Open_Out(folder, foo_boffo);
    DECREF(outstream);

    if (!S_create_test_symlinks()) {
        FAIL(runner, "symlink creation failed");
        FAIL(runner, "symlink creation failed");
        FAIL(runner, "symlink creation failed");
        FAIL(runner, "symlink creation failed");
        FAIL(runner, "symlink creation failed");
        // Try to clean up anyway.
        FSFolder_Delete_Tree(folder, foo);
        FSFolder_Delete_Tree(folder, bar);
    }
    else {
        VArray *list = FSFolder_List_R(folder, NULL);
        bool saw_bazooka_boffo = false;
        for (uint32_t i = 0, max = VA_Get_Size(list); i < max; i++) {
            String *entry = (String*)VA_Fetch(list, i);
            if (Str_Ends_With_Utf8(entry, "bazooka/boffo", 13)) {
                saw_bazooka_boffo = true;
            }
        }
        TEST_FALSE(runner, saw_bazooka_boffo,
                   "List_R() shouldn't follow symlinks");
        DECREF(list);

        TEST_TRUE(runner, FSFolder_Delete_Tree(folder, bar),
                  "Delete_Tree() returns true");
        TEST_FALSE(runner, FSFolder_Exists(folder, bar),
                   "Tree is really gone");
        TEST_TRUE(runner, FSFolder_Exists(folder, foo),
                  "Original folder sill there");
        TEST_TRUE(runner, FSFolder_Exists(folder, foo_boffo),
                  "Delete_Tree() did not follow directory symlink");
        FSFolder_Delete_Tree(folder, foo);
    }
    DECREF(folder);
    S_tear_down();
#else
    SKIP(runner, "Tests requiring symlink() disabled");
    SKIP(runner, "Tests requiring symlink() disabled");
    SKIP(runner, "Tests requiring symlink() disabled");
    SKIP(runner, "Tests requiring symlink() disabled");
    SKIP(runner, "Tests requiring symlink() disabled");
#endif // ENABLE_SYMLINK_TESTS
}
示例#13
0
static void
garmin_pack_d1012 ( D1012 * point, uint8 ** pos )
{
    PUTSTR(point->name);
    SKIP(1);
    PUTU16(point->course_index);
    SKIP(2);
    PUTU32(point->track_point_time);
    PUTU8(point->point_type);
}
示例#14
0
    virtual void startBlock(
        const Block *b,
        uint64_t chainSize
    )
    {
        curBlock = b;

        const uint8_t *p = b->data;
        const uint8_t *sz = -4 + p;
        LOAD(uint32_t, size, sz);
        offset += size;

        double now = usecs();
        static double startTime = 0;
        static double lastStatTime = 0;
        double elapsed = now - lastStatTime;
        bool longEnough = (5*1000*1000<elapsed);
        bool closeEnough = ((chainSize - offset)<80);
        if(unlikely(longEnough || closeEnough)) {

            if(0==startTime) {
                startTime = now;
            }

            double progress = offset/(double)chainSize;
            double elasedSinceStart = 1e-6*(now - startTime);
            double speed = progress / elasedSinceStart;
            info(
                "%8" PRIu64 " blocks, "
                "%8.3f MegaAddrs , "
                "%6.2f%% , "
                "elapsed = %5.2fs , "
                "eta = %5.2fs , "
                ,
                curBlock->height,
                addrMap.size()*1e-6,
                100.0*progress,
                elasedSinceStart,
                (1.0/speed) - elasedSinceStart
            );

            lastStatTime = now;
        }

        SKIP(uint32_t, version, p);
        SKIP(uint256_t, prevBlkHash, p);
        SKIP(uint256_t, blkMerkleRoot, p);
        LOAD(uint32_t, bTime, p);
        blockTime = bTime;

        if(0<=cutoffBlock && cutoffBlock<=curBlock->height) {
            wrapup();
        }
    }
示例#15
0
 virtual void startBlock(
     const Block *b
 )
 {
     const uint8_t *p = b->data;
     SKIP(uint32_t, version, p);
     SKIP(uint256_t, prevBlkHash, p);
     SKIP(uint256_t, blkMerkleRoot, p);
     LOAD(uint32_t, blkTime, p);
     bTime = blkTime;
 }
示例#16
0
    virtual void startBlock(
        const Block *b,
        uint64_t
    ) {
        currBlock = b->height;

        const uint8_t *p = b->chunk->getData();
        SKIP(uint32_t, version, p);
        SKIP(uint256_t, prevBlkHash, p);
        SKIP(uint256_t, blkMerkleRoot, p);
        LOAD(uint32_t, blkTime, p);
        bTime = blkTime;
    }
示例#17
0
static void parseBlock(
    const Block *block
) {
    startBlock(block);
        auto p = block->chunk->getData();

            auto header = p;
            SKIP(uint32_t, version, p);
            SKIP(uint256_t, prevBlkHash, p);
            SKIP(uint256_t, blkMerkleRoot, p);
            SKIP(uint32_t, blkTime, p);
            SKIP(uint32_t, blkBits, p);
            SKIP(uint32_t, blkNonce, p);

            #if defined PROTOSHARES
                SKIP(uint32_t, nBirthdayA, p);
                SKIP(uint32_t, nBirthdayB, p);
            #endif

            startTXs(p);
                LOAD_VARINT(nbTX, p);
                for(uint64_t txIndex=0; likely(txIndex<nbTX); ++txIndex) {
                    parseTX<false>(block, p);
                }
            endTXs(p);

            #if defined(PEERCOIN) || defined(CLAM) || defined(JUMBUCKS)
                LOAD_VARINT(vchBlockSigSize, p);
                p += vchBlockSigSize;
            #endif

        block->chunk->releaseData();
    endBlock(block);
}
示例#18
0
static void parseInput(
    const Block   *block,
    const uint8_t *&p,
    const uint8_t *txHash,
    uint64_t      inputIndex
) {
    if(!skip) {
        startInput(p);
    }

        auto upTXHash = p;
        const Chunk *upTX = 0;
        if(gNeedTXHash && !skip) {
            auto isGenTX = (0==memcmp(gNullHash.v, upTXHash, sizeof(gNullHash)));
            if(likely(false==isGenTX)) {
                auto i = gTXOMap.find(upTXHash);
                if(unlikely(gTXOMap.end()==i)) {
                    errFatal("failed to locate upstream transaction");
                }
                upTX = i->second;
            }
        }

        SKIP(uint256_t, dummyUpTXhash, p);
        LOAD(uint32_t, upOutputIndex, p);
        LOAD_VARINT(inputScriptSize, p);

        if(!skip && 0!=upTX) {
            auto inputScript = p;
            auto upTXOutputs = upTX->getData();
                parseOutputs<false, true>(
                    upTXOutputs,
                    upTXHash,
                    upOutputIndex,
                    txHash,
                    inputIndex,
                    inputScript,
                    inputScriptSize
                );
            upTX->releaseData();
        }

        p += inputScriptSize;
        SKIP(uint32_t, sequence, p);

    if(!skip) {
        endInput(p);
    }
}
示例#19
0
文件: csv.cpp 项目: Devba/blockparser
    virtual void startBlock(
        const Block *b,
        uint64_t chainBase
    )
    {
        if (lastBlock >= 0 && lastBlock < b->height - 1) wrapup();
        if (b->height - 1 == firstBlock) active = 1;

        if (active) {
            uint8_t blockHash[kSHA256ByteSize];
            sha256Twice(blockHash, b->data, 80);

            const uint8_t *p = b->data;

            // Total block size is 81 bytes plus transactions
            blkSize = 81;

            totalBlkFees = 0;
            totalBlkOutput = 0;
            numBlkTxs = 0;

            LOAD(uint32_t, version, p);
            SKIP(uint256_t, prevBlkHash, p);
            LOAD(uint256_t, blkMerkleRoot, p);
            LOAD(uint32_t, blkTime, p);
            LOAD(uint32_t, difficultyBits, p);
            LOAD(uint32_t, nonce, p);

            // ID
            fprintf(blockFile, "%" PRIu64 ",", blkID);

            // Hash
            uint8_t buf[1 + 2*kSHA256ByteSize];
            toHex(buf, blockHash);
            fprintf(blockFile, "\"%s\",", buf);

            // Version
            fprintf(blockFile, "%" PRIu32 ",", version);

            // Timestamp
            time_t blockTime = blkTime;
            char tbuf[23];
            strftime(tbuf, sizeof tbuf, "%FT%TZ", gmtime(&blockTime));

            fprintf(blockFile, "\"%s\",", tbuf);

            // Nonce
            fprintf(blockFile, "%" PRIu32 ",", nonce);

            // Difficulty
            fprintf(blockFile, "%f,", difficulty(difficultyBits));

            // Merkle root
            uint8_t buf2[kSHA256ByteSize];
            uint8_t buf3[1 + 2*kSHA256ByteSize];
            memcpy(buf2, &blkMerkleRoot, kSHA256ByteSize);
            toHex(buf3, buf2);
            fprintf(blockFile, "\"%s\",", buf3);
        }
    }
示例#20
0
static void
garmin_pack_d403 ( D403 * prx, uint8 ** pos )
{
    garmin_pack_d103(&prx->wpt,pos);
    SKIP(sizeof(D103));
    PUTF32(prx->dst);
}
示例#21
0
bool TestExtMemcached::test_Memcached_cas() {
  CREATE_MEMCACHED();
  for (ArrayIter iter(memc_version); iter; ++iter) {
    if (!f_version_compare(iter.second().toString(), "1.3.0", ">=")) {
      SKIP("Need memcached 1.3.0 for CAS");
      return Count(true);
    }
  }

  const char *key = "cas_test";

  VERIFY(memc->t_set(key, 10, EXPIRATION));

  Variant cas;

  VS(memc->t_get(key, null, strongBind(cas)), 10);

  VERIFY(!cas.isNull() && cas.isDouble());
  VERIFY(memc->t_cas(cas.toDouble(), key, 11, EXPIRATION));

  VS(memc->t_get(key, null, cas), 11);
  VERIFY(!memc->t_cas(cas.toDouble(), key, 12, EXPIRATION));
  VS(memc->t_get(key, null, cas), 11);

  return Count(true);
}
示例#22
0
文件: tpi.cpp 项目: grumpycoders/Igor
PlfRecord TPILookupTypeRecord(PHDR pHdr, ULONG typeIndex, ULONG *pdBase, ULONG *pdSize)
{
    ULONG dTypes = pHdr->tiMac - pHdr->tiMin;
    ULONG dBase = pHdr->cbHdr;
    PVOID pData = ((PUCHAR)pHdr + dBase);
    PlfRecord plr;

    for (ULONG i = 0; i < dTypes; i++)
    {
        ULONG dSize = *(PWORD)pData;
        dBase += sizeof(WORD);
        plr = (PlfRecord)((PUCHAR)pHdr + dBase);

        if (pHdr->tiMin + i == typeIndex)
        {
            if (pdBase) *pdBase = dBase;
            if (pdSize) *pdSize = dSize;
            return plr;
        }

        dBase += dSize;
        pData = SKIP(pHdr, dBase);
    }

    return NULL;
}
示例#23
0
int rfc2047::status_question_equal(const char* s, int n)
{
	if (m_stripSp)
		SKIP(s, n);
	if (n <= 0)
		return n;
	if (*s == '=')
	{
		m_status = rfc2047_status_next;
		m_pCurrentEntry = NULL;
		return n - 1;
	}

	size_t size = m_pCurrentEntry->pCharset->length()
		+ m_pCurrentEntry->pData->length()
		+ strlen("=???") + 1;
	acl::string* pBuf = NEW acl::string(size);

	*pBuf << "=?" << m_pCurrentEntry->pCharset->c_str()
		<< "?" << m_pCurrentEntry->coding << "?"
		<< m_pCurrentEntry->pData->c_str() << "?"
		<< *s;
	delete m_pCurrentEntry->pData;
	m_pCurrentEntry->pData = pBuf;
	m_status = rfc2047_status_data;
	return n - 1;
}
示例#24
0
int rfc2047::status_coding(const char* s, int n)
{
	if (m_stripSp)
		SKIP(s, n);
	if (n <= 0)
		return n;
	if (*s == 'B' || *s == 'b')
	{
		m_pCurrentEntry->coding = 'B';
		m_status = rfc2047_status_question_second;
		return n - 1;
	}
	else if (*s == 'Q' || *s == 'q')
	{
		m_pCurrentEntry->coding = 'Q';
		m_status = rfc2047_status_question_second;
		return n - 1;
	}
	
	*m_pCurrentEntry->pData << "=?"
		<< m_pCurrentEntry->pCharset->c_str()
		<< "?";
	m_pCurrentEntry->pCharset->clear();
	m_pCurrentEntry->coding = 0;
	return n - 1;
}
示例#25
0
gboolean
decode_vlc (GstBitReader * br, guint * res, const VLCTable * table,
    guint length)
{
  guint8 i;
  guint cbits = 0;
  guint32 value = 0;

  for (i = 0; i < length; i++) {
    if (cbits != table[i].cbits) {
      cbits = table[i].cbits;
      if (!gst_bit_reader_peek_bits_uint32 (br, &value, cbits)) {
        goto failed;
      }
    }

    if (value == table[i].cword) {
      SKIP (br, cbits);
      if (res)
        *res = table[i].value;

      return TRUE;
    }
  }

  GST_DEBUG ("Did not find code");

failed:
  {
    GST_WARNING ("Could not decode VLC returning");

    return FALSE;
  }
}
示例#26
0
gboolean
mpeg4_util_parse_VOS (GstBuffer * buf, Mpeg4VisualObjectSequence * vos)
{
  GstBitReader reader = GST_BIT_READER_INIT_FROM_BUFFER (buf);

  guint8 visual_object_sequence_start_code;

  /* start code prefix */
  SKIP (&reader, 24);

  READ_UINT8 (&reader, visual_object_sequence_start_code, 8);
  if (visual_object_sequence_start_code != MPEG4_PACKET_VOS)
    goto wrong_start_code;

  READ_UINT8 (&reader, vos->profile_and_level_indication, 8);

  return TRUE;

wrong_start_code:
  GST_WARNING ("got buffer with wrong start code");
  return FALSE;

error:
  GST_WARNING ("error parsing \"Visual Object\"");
  return FALSE;
}
示例#27
0
文件: main.cpp 项目: lubing521/acl-1
static bool check_dir(acl::scan_dir& scan, const char* to, int* ncopied)
{
	const char* rpath = scan.curr_path();
	if (rpath == false)
	{
		logger_error("get from's path error: %s, to: %s",
			acl::last_serror(), to);
		return false;
	}

	SKIP(rpath);

	acl::string to_path;
	to_path << to << SEP << rpath;
	// printf(">>to_path: %s, to: %s\r\n", to_path.c_str(), to);

	if (access(to_path.c_str(), 0) == 0)
		return true;
	else
	{
		int ret = acl_make_dirs(to_path.c_str(), 0755);
		if (ret == 0)
		{
			(*ncopied)++;
			return true;
		}
		else
		{
			logger_error("make dirs(%s) error: %s",
				to_path.c_str(), acl::last_serror());
			return false;
		}
	}
}
示例#28
0
static void
test_Close(TestBatchRunner *runner) {
    String *test_filename = SSTR_WRAP_C("_fstest");
    FSFileHandle *fh;

    S_remove(test_filename);
    fh = FSFH_open(test_filename,
                   FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
    TEST_TRUE(runner, FSFH_Close(fh), "Close returns true for write-only");
    DECREF(fh);

    // Simulate an OS error when closing the file descriptor.  This
    // approximates what would happen if, say, we run out of disk space.
    S_remove(test_filename);
    fh = FSFH_open(test_filename,
                   FH_CREATE | FH_WRITE_ONLY | FH_EXCLUSIVE);
#ifdef _MSC_VER
    SKIP(runner, 2, "LUCY-155");
#else
    int saved_fd = FSFH_Set_FD(fh, -1);
    Err_set_error(NULL);
    bool result = FSFH_Close(fh);
    TEST_FALSE(runner, result, "Failed Close() returns false");
    TEST_TRUE(runner, Err_get_error() != NULL,
              "Failed Close() sets global error");
    FSFH_Set_FD(fh, saved_fd);
#endif /* _MSC_VER */
    DECREF(fh);

    fh = FSFH_open(test_filename, FH_READ_ONLY);
    TEST_TRUE(runner, FSFH_Close(fh), "Close returns true for read-only");

    DECREF(fh);
    S_remove(test_filename);
}
示例#29
0
static void
garmin_pack_d1015 ( D1015 * lap, uint8 ** pos )
{
    PUTU16(lap->index);
    SKIP(2);
    PUTU32(lap->start_time);
    PUTU32(lap->total_time);
    PUTF32(lap->total_dist);
    PUTF32(lap->max_speed);
    PUTPOS(lap->begin);
    PUTPOS(lap->end);
    PUTU16(lap->calories);
    PUTU8(lap->avg_heart_rate);
    PUTU8(lap->max_heart_rate);
    PUTU8(lap->intensity);
    PUTU8(lap->avg_cadence);
    PUTU8(lap->trigger_method);

    /* Hopefully we'll know what this stuff actually is someday. */

    PUTU8(lap->unknown[0]);
    PUTU8(lap->unknown[1]);
    PUTU8(lap->unknown[2]);
    PUTU8(lap->unknown[3]);
    PUTU8(lap->unknown[4]);
}
示例#30
0
static void
garmin_pack_d152 ( D152 * wpt, uint8 ** pos )
{
    PUTSTR(wpt->ident);
    PUTPOS(wpt->posn);
    SKIP(4);
    PUTSTR(wpt->cmnt);
    PUTF32(wpt->dst);
    PUTSTR(wpt->name);
    PUTSTR(wpt->city);
    PUTSTR(wpt->state);
    PUTS16(wpt->alt);
    PUTSTR(wpt->cc);
    SKIP(1);
    PUTU8(wpt->wpt_class);
}