示例#1
0
int main(int argc, char **argv) {
  int i, j;
#define MAX_FRAME_SIZE 16384
#define MESSAGES_PER_FRAME (MAX_FRAME_SIZE / 5)
#define FRAME_SIZE (MESSAGES_PER_FRAME * 5)
#define SEND_SIZE (100 * 1024)
#define NUM_FRAMES (SEND_SIZE / FRAME_SIZE + 1)
  grpc_test_init(argc, argv);

  addbuf(PFX_STR, sizeof(PFX_STR) - 1);
  for (i = 0; i < NUM_FRAMES; i++) {
    uint8_t hdr[9] = {(uint8_t)(FRAME_SIZE >> 16),
                      (uint8_t)(FRAME_SIZE >> 8),
                      (uint8_t)FRAME_SIZE,
                      0,
                      0,
                      0,
                      0,
                      0,
                      1};
    addbuf(hdr, sizeof(hdr));
    for (j = 0; j < MESSAGES_PER_FRAME; j++) {
      uint8_t message[5] = {0, 0, 0, 0, 0};
      addbuf(message, sizeof(message));
    }
  }
  grpc_run_bad_client_test(verifier, g_buffer, g_count, 0);
  gpr_free(g_buffer);

  return 0;
}
int main(int argc, char **argv) {
  int i;
  grpc_test_init(argc, argv);

#define NUM_FRAMES 10
#define FRAME_SIZE 1000

  addbuf(prefix, sizeof(prefix) - 1);
  for (i = 0; i < NUM_FRAMES; i++) {
    uint8_t hdr[9] = {(uint8_t)(FRAME_SIZE >> 16),
                      (uint8_t)(FRAME_SIZE >> 8),
                      (uint8_t)FRAME_SIZE,
                      0,
                      0,
                      0,
                      0,
                      0,
                      3};
    uint8_t msg[FRAME_SIZE];
    memset(msg, 'a', sizeof(msg));
    addbuf(hdr, sizeof(hdr));
    addbuf(msg, FRAME_SIZE);
  }
  grpc_run_bad_client_test(verifier, NULL, g_buffer, g_count, 0);
  gpr_free(g_buffer);

  return 0;
}
示例#3
0
static a_token scan_typename( unsigned used )
{
    bufused = used;
    if( TYPENAME_FIRST_CHAR( ch ) ) {
        do {
            addbuf( ch );
            nextc();
        } while( TYPENAME_NEXT_CHAR( ch ) );
        token = TYPENAME;
    }
    addbuf( '\0' );
    value = 0;
    return( token );
}
示例#4
0
void
writec(int c)
{
	if (tflag)
		fancyc(c);
	else
		addbuf(c);
}
示例#5
0
int
decodeMP3 (struct mpstr *mp, char *in, int isize, char *out,
	   int osize, int *done)
{
  int len;

  gmp = mp;

  if (osize < 4608)
    {
      fprintf (stderr, "To less out space\n");
      return MP3_ERR;
    }

  if (in)
    {
      if (addbuf (mp, in, isize) == NULL)
	{
	  return MP3_ERR;
	}
    }

  /* First decode header */
  if (mp->framesize == 0)
    {
      if (mp->bsize < 4)
	{
	  return MP3_NEED_MORE;
	}
      read_head (mp);
      decode_header (&mp->fr, mp->header);
      mp->framesize = mp->fr.framesize;
    }

  if (mp->fr.framesize > mp->bsize)
    return MP3_NEED_MORE;

  wordpointer = mp->bsspace[mp->bsnum] + 512;
  mp->bsnum = (mp->bsnum + 1) & 0x1;
  bitindex = 0;

  len = 0;
  while (len < mp->framesize)
    {
      int nlen;
      int blen = mp->tail->size - mp->tail->pos;
      if ((mp->framesize - len) <= blen)
	{
	  nlen = mp->framesize - len;
	}
      else
	{
	  nlen = blen;
	}
      memcpy (wordpointer + len, mp->tail->pnt + mp->tail->pos, nlen);
      len += nlen;
      mp->tail->pos += nlen;
      mp->bsize -= nlen;
      if (mp->tail->pos == mp->tail->size)
	{
	  remove_buf (mp);
	}
    }

  *done = 0;
  if (mp->fr.error_protection)
    getbits (16);
  switch (mp->fr.lay)
    {
    case 3:
      do_layer3 (&mp->fr, (unsigned char *) out, done);
      break;
    }

  mp->fsizeold = mp->framesize;
  mp->framesize = 0;

  return MP3_OK;
}
示例#6
0
int decodeMP3(struct mpstr *mp, char *in, int isize,
              char *out, int osize, int *done)
{
    int len;

    if(osize < 4608) {
#ifndef BE_QUIET
        fprintf(stderr,"To less out space\n");
#endif
        return MP3_ERR;
    }

    if(in) {
        if(addbuf(mp, in, isize) == NULL) {
            return MP3_ERR;
        }
    }


    /* First decode header */
    if(mp->framesize == 0) {
        if(mp->bsize < 4) {
            return MP3_NEED_MORE;
        }
        read_head(mp);
        if(mp->tail)
            mp->ndatabegin = mp->tail->pos - 4;
        if (decode_header(mp, &mp->fr,mp->header) <= 0 )
            return MP3_ERR;

        mp->framesize = mp->fr.framesize;
    }

    /*	  printf(" fr.framesize = %i \n",mp->fr.framesize);
    	  printf(" bsize        = %i \n",mp->bsize);
    */

    if(mp->fr.framesize > mp->bsize) {
        return MP3_NEED_MORE;
    }
    mp->psd.wordpointer = mp->bsspace[mp->bsnum] + 512;
    mp->bsnum = (mp->bsnum + 1) & 0x1;
    mp->psd.bitindex = 0;

    len = 0;
    while(len < mp->framesize) {
        int nlen;
        int blen = mp->tail->size - mp->tail->pos;
        if( (mp->framesize - len) <= blen) {
            nlen = mp->framesize-len;
        }
        else {
            nlen = blen;
        }
        memcpy(mp->psd.wordpointer+len,mp->tail->pnt+mp->tail->pos,nlen);
        len += nlen;
        mp->tail->pos += nlen;
        mp->bsize -= nlen;
        if(mp->tail->pos == mp->tail->size) {
            remove_buf(mp);
        }
    }

    *done = 0;
    if(mp->fr.error_protection)
        getbits(&mp->psd, 16);

    // FOR mpglib.dll: see if error and return it
    if ((&mp->fr)->do_layer(&mp->psd, mp, &mp->fr, (unsigned char*) out, done) < 0)
        return MP3_ERR;

    mp->fsizeold = mp->framesize;
    mp->framesize = 0;
    return MP3_OK;
}