static int
http_rxchunk(struct http *hp)
{
	char *q;
	int l, i;

	l = hp->prxbuf;
	do
		(void)http_rxchar(hp, 1, 0);
	while (hp->rxbuf[hp->prxbuf - 1] != '\n');
	vtc_dump(hp->vl, 4, "len", hp->rxbuf + l, -1);
	i = strtoul(hp->rxbuf + l, &q, 16);
	bprintf(hp->chunklen, "%d", i);
	if ((q == hp->rxbuf + l) ||
		(*q != '\0' && !vct_islws(*q))) {
		vtc_log(hp->vl, 0, "chunked fail %02x @ %d",
		    *q, q - (hp->rxbuf + l));
	}
	assert(q != hp->rxbuf + l);
	assert(*q == '\0' || vct_islws(*q));
	hp->prxbuf = l;
	if (i > 0) {
		(void)http_rxchar(hp, i, 0);
		vtc_dump(hp->vl, 4, "chunk",
		    hp->rxbuf + l, i);
	}
	l = hp->prxbuf;
	(void)http_rxchar(hp, 2, 0);
	if(!vct_iscrlf(hp->rxbuf[l]))
		vtc_log(hp->vl, 0,
		    "Wrong chunk tail[0] = %02x",
		    hp->rxbuf[l] & 0xff);
	if(!vct_iscrlf(hp->rxbuf[l + 1]))
		vtc_log(hp->vl, 0,
		    "Wrong chunk tail[1] = %02x",
		    hp->rxbuf[l + 1] & 0xff);
	hp->prxbuf = l;
	hp->rxbuf[l] = '\0';
	return (i);
}
Exemple #2
0
void tc0140_slave_comm_w(unsigned char d)
{
#ifdef logstuff
	bprintf(PRINT_NORMAL, "tc0140_slave_comm_w %x\n",d);
#endif
	switch (slave_mode)
	{
	case 0x00:
		master_data[slave_mode++]=d;
		irq_check();
		return;
	case 0x01:
		master_data[slave_mode++]=d;
		status|= TC0140SYT_PORT01_FULL_MASTER;
		irq_check();
		return;
	case 0x02: master_data[slave_mode ++] = d;
		irq_check();
		return;
	case 0x03: master_data[slave_mode ++] = d;
		status |= TC0140SYT_PORT23_FULL_MASTER;
		irq_check();
		return;
	case 0x04:
		irq_check();
		return;
	case 0x05:
		nmi_enabled =0;
		irq_check();
		return;
	case 0x06:
		nmi_enabled=1;
		irq_check();
		return;
	default:
		irq_check();
		return;
	}

}
Exemple #3
0
INT32 DACScan(INT32 nAction,INT32 *pnMin)
{
#if defined FBA_DEBUG
	if (!DebugSnd_DACInitted) bprintf(PRINT_ERROR, _T("DACScan called without init\n"));
#endif
	
	if (pnMin != NULL) {
		*pnMin = 0x029719;
	}
	
	struct dac_info *ptr;

	if (nAction & ACB_DRIVER_DATA) {
		for (INT32 i = 0; i < NumChips; i++) {
			ptr = &dac_table[i];

			SCAN_VAR(ptr->Output);
		}
	}

	return 0;
}
static void
parse_return_vcl(struct vcc *tl)
{
	struct symbol *sym;
	struct inifin *p;
	char buf[1024];

	ExpectErr(tl, '(');
	vcc_NextToken(tl);
	ExpectErr(tl, ID);
	sym = VCC_SymbolTok(tl, NULL, tl->t, SYM_VCL, 0);
	ERRCHK(tl);
	if (sym == NULL) {
		VSB_printf(tl->sb, "Not a VCL label:\n");
		vcc_ErrWhere(tl, tl->t);
		return;
	}
	if (sym->eval_priv == NULL) {
		VSB_printf(tl->fi, "%s VCL %.*s */\n",
		    VCC_INFO_PREFIX, PF(tl->t));

		bprintf(buf, "vgc_vcl_%u", tl->unique++);
		sym->eval_priv = strdup(buf);
		AN(sym->eval_priv);

		Fh(tl, 0, "static VCL_VCL %s;", buf);
		Fh(tl, 0, "\t/* VCL %.*s */\n", PF(tl->t));

		p = New_IniFin(tl);
		AN(p);
		VSB_printf(p->ini, "\t%s = VRT_vcl_lookup(\"%.*s\");",
		    buf, PF(tl->t));
	}
	Fb(tl, 1, "VRT_vcl_select(ctx, %s);\t/* %.*s */\n",
	    (const char*)sym->eval_priv, PF(tl->t));
	vcc_NextToken(tl);
	ExpectErr(tl, ')');
	vcc_NextToken(tl);
}
Exemple #5
0
	const char *
	ram_perc(void)
	{
		uintmax_t total, free, buffers, cached;

		if (pscanf("/proc/meminfo",
		           "MemTotal: %ju kB\n"
		           "MemFree: %ju kB\n"
		           "MemAvailable: %ju kB\n"
		           "Buffers: %ju kB\n"
		           "Cached: %ju kB\n",
		           &total, &free, &buffers, &buffers, &cached) != 5) {
			return NULL;
		}

		if (total == 0) {
			return NULL;
		}

		return bprintf("%d", 100 * ((total - free) - (buffers + cached))
                               / total);
	}
Exemple #6
0
static void SingleCommand (enum singleCommand command, int scheduled)
{
  if (!scheduled)
    bprintf(info, "Commands: Single command: %d (%s)\n", command,
        SName(command));

  /* Update CommandData structure with new info */

  switch (command) {
    case az_el_disable:
      CommandData.az_el.new_cmd = 1;
      CommandData.az_el.mode = AzElDisable;
      break;
    case xyzzy:
      break;
    default:
      bputs(warning, "Commands: ***Invalid Single Word Command***\n");
      return; /* invalid command - no write or update */
  }

  WritePrevStatus();
}
Exemple #7
0
void tc0140_comm_w(unsigned char d)
{
#ifdef logstuff
	bprintf(PRINT_NORMAL, "tc0140_comm_w %x\n",d);
#endif

	switch (main_mode)	{
	case 0x00:
		slave_data[main_mode++]=d;
		return;

	case 0x01:
		slave_data[main_mode++]=d;
		status |= TC0140SYT_PORT01_FULL;
		nmi_req=true;
		return;

	case 0x02:
		slave_data[main_mode++]=d;
		return;

	case 0x03:
		slave_data[main_mode++]=d;
		status |= TC0140SYT_PORT23_FULL;
		nmi_req=true;
		return;

	case 0x04:
		if (!d)
		{
			ZetReset();
		}
		return;
	default:
		return;

	}

}
Exemple #8
0
int Arm7Scan(int nAction)
{
#if defined FBA_DEBUG
	if (!DebugCPU_ARM7Initted) bprintf(PRINT_ERROR, _T("Arm7Scan called without init\n"));
#endif

	struct BurnArea ba;
	
	if (nAction & ACB_DRIVER_DATA) {
		memset(&ba, 0, sizeof(ba));
		ba.Data	  = (unsigned char*)&ARM7;
		ba.nLen	  = sizeof(ARM7);
		ba.szName = "All  Registers";
		BurnAcb(&ba);

		SCAN_VAR(ARM7_ICOUNT);
		SCAN_VAR(total_cycles);
		SCAN_VAR(curr_cycles);
	}

	return 0;
}
Exemple #9
0
static void
vcc_Eval_Regsub(struct vcc *tl, struct expr **e, const struct symbol *sym)
{
	struct expr *e2;
	int all = sym->eval_priv == NULL ? 0 : 1;
	const char *p;
	char buf[128];

	vcc_delete_expr(*e);
	SkipToken(tl, ID);
	SkipToken(tl, '(');

	vcc_expr0(tl, &e2, STRING);
	if (e2 == NULL)
		return;
	if (e2->fmt != STRING) {
		vcc_expr_tostring(tl, &e2, STRING);
		ERRCHK(tl);
	}

	SkipToken(tl, ',');
	ExpectErr(tl, CSTR);
	p = vcc_regexp(tl);
	vcc_NextToken(tl);

	bprintf(buf, "VRT_regsub(ctx, %d,\v+\n\v1,\n%s", all, p);
	*e = vcc_expr_edit(STRING, buf, e2, *e);

	SkipToken(tl, ',');
	vcc_expr0(tl, &e2, STRING);
	if (e2 == NULL)
		return;
	if (e2->fmt != STRING) {
		vcc_expr_tostring(tl, &e2, STRING);
		ERRCHK(tl);
	}
	*e = vcc_expr_edit(STRING, "\v1,\n\v2)\v-", *e, e2);
	SkipToken(tl, ')');
}
Exemple #10
0
void TimeKeeperWrite(INT32 offset, UINT8 data)
{
#if defined FBA_DEBUG
	if (!DebugDev_TimeKprInitted) bprintf(PRINT_ERROR, _T("TimeKeeperWrite called without init\n"));
#endif

	if( offset == Chip.offset_control )
	{
		if( ( Chip.control & CONTROL_W ) != 0 &&
			( data & CONTROL_W ) == 0 )
		{
			counters_from_ram();
		}
		Chip.control = data;
	}
	else if( (Chip.type == TIMEKEEPER_M48T58 || Chip.type == TIMEKEEPER_M48T35) && offset == Chip.offset_day )
	{
		Chip.day = ( Chip.day & ~DAY_CEB ) | ( data & DAY_CEB );
	}

	Chip.data[ offset ] = data;
}
Exemple #11
0
// mkzgoarch writes zgoarch_$GOARCH.go:
//
//	package runtime
//	const theGoarch = <goarch>
//
void
mkzgoarch(char *dir, char *file)
{
	Buf b, out;

	USED(dir);
	
	binit(&b);
	binit(&out);
	
	bwritestr(&out, bprintf(&b,
		"// auto generated by go tool dist\n"
		"\n"
		"package runtime\n"
		"\n"
		"const theGoarch = `%s`\n", goarch));

	writefile(&out, file, 0);
	
	bfree(&b);
	bfree(&out);
}
Exemple #12
0
void sbbs_t::show_msgattr(ushort attr)
{

	bprintf(text[MsgAttr]
		,attr&MSG_PRIVATE	? "Private  "   :nulstr
		,attr&MSG_READ		? "Read  "      :nulstr
		,attr&MSG_DELETE	? "Deleted  "   :nulstr
		,attr&MSG_KILLREAD	? "Kill  "      :nulstr
		,attr&MSG_ANONYMOUS ? "Anonymous  " :nulstr
		,attr&MSG_LOCKED	? "Locked  "    :nulstr
		,attr&MSG_PERMANENT ? "Permanent  " :nulstr
		,attr&MSG_MODERATED ? "Moderated  " :nulstr
		,attr&MSG_VALIDATED ? "Validated  " :nulstr
		,attr&MSG_REPLIED	? "Replied  "	:nulstr
		,attr&MSG_NOREPLY	? "NoReply  "	:nulstr
		,nulstr
		,nulstr
		,nulstr
		,nulstr
		,nulstr
		);
}
Exemple #13
0
void HiscoreReset()
{
	if (!CheckHiscoreAllowed() || !HiscoresInUse) return;
	
	if (nCpuType == -1) set_cpu_type();
	
	for (unsigned int i = 0; i < nHiscoreNumRanges; i++) {
		HiscoreMemRange[i].ApplyNextFrame = 0;
		HiscoreMemRange[i].Applied = APPLIED_STATE_NONE;
		
		if (HiscoreMemRange[i].Loaded) {
			cpu_open(HiscoreMemRange[i].nCpu);
			cpu_write_byte(HiscoreMemRange[i].Address, (unsigned char)~HiscoreMemRange[i].StartValue);
			if (HiscoreMemRange[i].NumBytes > 1) cpu_write_byte(HiscoreMemRange[i].Address + HiscoreMemRange[i].NumBytes - 1, (unsigned char)~HiscoreMemRange[i].EndValue);
			cpu_close();
			
#if 1 && defined FBA_DEBUG
			bprintf(PRINT_IMPORTANT, _T("Hi Score Memory Range %i Initted\n"), i);
#endif
		}
	}
}
Exemple #14
0
struct mempool *
MPL_New(const char *name,
    volatile struct poolparam *pp, volatile unsigned *cur_size)
{
	struct mempool *mpl;

	ALLOC_OBJ(mpl, MEMPOOL_MAGIC);
	AN(mpl);
	bprintf(mpl->name, "%s", name);
	mpl->param = pp;
	mpl->cur_size = cur_size;
	VTAILQ_INIT(&mpl->list);
	VTAILQ_INIT(&mpl->surplus);
	Lck_New(&mpl->mtx, lck_mempool);
	/* XXX: prealloc min_pool */
	mpl->vsc = VSM_Alloc(sizeof *mpl->vsc,
	    VSC_CLASS, VSC_type_mempool, mpl->name);
	AN(mpl->vsc);
	AZ(pthread_create(&mpl->thread, NULL, mpl_guard, mpl));
	AZ(pthread_detach(mpl->thread));
	return (mpl);
}
Exemple #15
0
void DACExit()
{
#if defined FBA_DEBUG
	if (!DebugSnd_DACInitted) bprintf(PRINT_ERROR, _T("DACExit called without init\n"));
#endif

	struct dac_info *ptr;

	for (INT32 i = 0; i < DAC_NUM; i++) {
		ptr = &dac_table[i];

		ptr->Initialized = 0;
		ptr->pSyncCallback = NULL;
	}

	NumChips = 0;
	
	DebugSnd_DACInitted = 0;

	BurnFree (lBuffer);
	BurnFree (rBuffer);
}
Exemple #16
0
void __fastcall Wc90b1Write2(UINT16 a, UINT8 d)
{
	switch (a) {
		case 0xfc00: {
			INT32 BankAddress;

			BankAddress = 0x10000 + ((d & 0xf8) << 8);
			ZetMapArea(0xf000, 0xf7ff, 0, Wc90b1Z80Rom2 + BankAddress);
			ZetMapArea(0xf000, 0xf7ff, 2, Wc90b1Z80Rom2 + BankAddress);
			return;
		}
		
		case 0xfd0c: {
			// ???
			return;
		}
		
		default: {
			bprintf(PRINT_NORMAL, _T("Z80 #2 Write => %04X, %02X\n"), a, d);
		}
	}
}
Exemple #17
0
/** @brief shows an exception content and the associated stack if available */
void xbt_ex_display(xbt_ex_t * e)
{
    char *thrower = NULL;

    if (e->remote)
        thrower = bprintf(" on host %s(%d)", e->host, e->pid);

    fprintf(stderr,
            "** SimGrid: UNCAUGHT EXCEPTION received on %s(%d): category: %s; value: %d\n"
            "** %s\n"
            "** Thrown by %s()%s\n",
            gras_os_myname(), (*xbt_getpid) (),
            xbt_ex_catname(e->category), e->value, e->msg,
            e->procname, thrower ? thrower : " in this process");
    XBT_CRITICAL("%s", e->msg);

    if (!e->remote && !e->bt_strings)
        xbt_ex_setup_backtrace(e);

#ifdef HAVE_BACKTRACE
    /* We have everything to build neat backtraces */
    {
        int i;

        if (!xbt_binary_name) {
            fprintf(stderr, "variable 'xbt_binary_name' set to NULL. Cannot compute the backtrace\n");
            return;
        }
        fprintf(stderr, "\n");
        for (i = 0; i < e->used; i++)
            fprintf(stderr, "%s\n", e->bt_strings[i]);

    }
#else
    fprintf(stderr, " at %s:%d:%s (no backtrace available on that arch)\n",
            e->file, e->line, e->func);
#endif
}
Exemple #18
0
void __fastcall Sf2mdtZ80Write(UINT16 a, UINT8 d)
{
	switch (a) {
		case 0xd800: {
			BurnYM2151SelectRegister(d);
			return;
		}
		
		case 0xd801: {
			BurnYM2151WriteRegister(d);
			return;
		}
		
		case 0xe000: {
			MSM5205SetRoute(0, (d & 0x20) ? 0 : 0.25, BURN_SND_ROUTE_BOTH);
			MSM5205SetRoute(1, (d & 0x10) ? 0 : 0.25, BURN_SND_ROUTE_BOTH);
			
			Sf2mdtZ80BankAddress = (d & Sf2mdtNumZ80Banks) * 0x4000;
			ZetMapArea(0x8000, 0xbfff, 0, CpsZRom + Sf2mdtZ80BankAddress);
			ZetMapArea(0x8000, 0xbfff, 2, CpsZRom + Sf2mdtZ80BankAddress);
			return;
		}
		
		case 0xe400: {
			Sf2mdtSampleBuffer1 = d;
			return;
		}
		
		case 0xe800: {
			Sf2mdtSampleBuffer2 = d;
			return;
		}
		
		default: {
			bprintf(PRINT_NORMAL, _T("Z80 #1 Write => %04X, %02X\n"), a, d);
		}
	}
}
Exemple #19
0
INT32 YMZ280BScan()
{
#if defined FBA_DEBUG
	if (!DebugSnd_YMZ280BInitted) bprintf(PRINT_ERROR, _T("YMZ280BScan called without init\n"));
#endif

	SCAN_VAR(nYMZ280BStatus);
	SCAN_VAR(nYMZ280BRegister);

	SCAN_VAR(bYMZ280BEnable);

	SCAN_VAR(bYMZ280BIRQEnable);
	SCAN_VAR(nYMZ280BIRQMask);
	SCAN_VAR(nYMZ280BIRQStatus);
	SCAN_VAR(nRamReadAddress);

	for (INT32 j = 0; j < 8; j++) {
		SCAN_VAR(YMZ280BChannelInfo[j]);
		YMZ280BSetSampleSize(j);
	}

	return 0;
}
Exemple #20
0
// mkzversion writes zversion.go:
//
//	package runtime
//	const defaultGoroot = <goroot>
//	const theVersion = <version>
//
void
mkzversion(char *dir, char *file)
{
	Buf b, out;
	
	USED(dir);

	binit(&b);
	binit(&out);
	
	bwritestr(&out, bprintf(&b,
		"// auto generated by go tool dist\n"
		"\n"
		"package runtime\n"
		"\n"
		"const defaultGoroot = `%s`\n"
		"const theVersion = `%s`\n", goroot_final, goversion));

	writefile(&out, file, 0);
	
	bfree(&b);
	bfree(&out);
}
Exemple #21
0
// mkzexperiment writes zaexperiment.h (sic):
//
//	#define GOEXPERIMENT "experiment string"
//
void
mkzexperiment(char *dir, char *file)
{
	Buf b, out, exp;
	
	USED(dir);

	binit(&b);
	binit(&out);
	binit(&exp);
	
	xgetenv(&exp, "GOEXPERIMENT");
	bwritestr(&out, bprintf(&b,
		"// auto generated by go tool dist\n"
		"\n"
		"#define GOEXPERIMENT \"%s\"\n", bstr(&exp)));

	writefile(&out, file, 0);
	
	bfree(&b);
	bfree(&out);
	bfree(&exp);
}
Exemple #22
0
static int
event_warm(VRT_CTX, const struct vmod_priv *priv)
{
	struct priv_vcl *priv_vcl;
	char buf[32];

	VSL(SLT_Debug, 0, "%s: VCL_EVENT_WARM", VCL_Name(ctx->vcl));

	AN(ctx->msg);
	if (cache_param->max_esi_depth == 42) {
		VSB_printf(ctx->msg, "max_esi_depth is not the answer.");
		return (-1);
	}

	CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC);
	AZ(priv_vcl->vcl);
	AZ(priv_vcl->vclref);

	bprintf(buf, "vmod-debug ref on %s", VCL_Name(ctx->vcl));
	priv_vcl->vcl = ctx->vcl;
	priv_vcl->vclref = VRT_ref_vcl(ctx, buf);
	return (0);
}
Exemple #23
0
jfieldID jxbt_get_sfield(JNIEnv * env, const char *classname,
                         const char *name, const char *signature)
{
  jclass cls = jxbt_get_class(env, classname);
  jfieldID id;

  if (!cls)
    return 0;

  id = (*env)->GetFieldID(env, cls, name, signature);

  if (!id) {
    char *m = bprintf("Cannot find field %s %s in %s", signature, name,
                      classname);

    jxbt_throw_jni(env, m);

    free(m);
    return 0;
  }

  return id;
}
Exemple #24
0
int smpi_shared_known_call(const char* func, const char* input) {
   char* loc = bprintf("%s:%s", func, input);
   xbt_ex_t ex;
   int known;

   if(!calls) {
      calls = xbt_dict_new_homogeneous(NULL);
   }
   TRY {
      xbt_dict_get(calls, loc); /* Succeed or throw */
      known = 1;
   }
   CATCH(ex) {
      if(ex.category == not_found_error) {
         known = 0;
         xbt_ex_free(ex);
      } else {
         RETHROW;
      }
   }
   free(loc);
   return known;
}
Exemple #25
0
void
macro_def(struct vtclog *vl, const char *instance, const char *name,
    const char *fmt, ...)
{
	char buf1[256];
	char buf2[256];
	struct macro *m;
	va_list ap;

	AN(fmt);

	if (instance != NULL) {
		bprintf(buf1, "%s_%s", instance, name);
		name = buf1;
	}

	AZ(pthread_mutex_lock(&macro_mtx));
	VTAILQ_FOREACH(m, &macro_list, list)
		if (!strcmp(name, m->name))
			break;
	if (m == NULL) {
		m = calloc(sizeof *m, 1);
		AN(m);
		REPLACE(m->name, name);
		VTAILQ_INSERT_TAIL(&macro_list, m, list);
	}
	AN(m);
	va_start(ap, fmt);
	free(m->val);
	m->val = NULL;
	vbprintf(buf2, fmt, ap);
	va_end(ap);
	m->val = strdup(buf2);
	AN(m->val);
	vtc_log(vl, 4, "macro def %s=%s", name, m->val);
	AZ(pthread_mutex_unlock(&macro_mtx));
}
Exemple #26
0
void dec_ctrl_writeword(unsigned int a, unsigned short d)
{
    switch (a)
    {
    case 0: // Playfield & Sprite priority
        //	dec0_priority_w(0,data,mem_mask);
        dec_pri_reg=d;
        printf("priority reg: %x,%x\n",a,d);
        break;
    case 2:// DMA flag
        //	dec0_update_sprites_w(0,0,mem_mask);
        //	printf("oh no, is dma: %x,%x\n",a,d);
        break;
    case 4: // 6502
        robocopSoundLatch = d & 0xFF;
        bprintf(PRINT_NORMAL, _T("sound code: %x\n"),d);
        m6502SetIRQ(M6502_NMI);
        break;
    case 6:
        printf("write to i8751 %x, %x\n",a,d);
        baddudes_i8751_write(d);
        SekSetIRQLine(5, SEK_IRQSTATUS_AUTO);
        break;
    case 8: //mame says int ack for vbl, but just ignores it???
        VBL_ACK = false;
        break;
    case 0xa:  // unknown
        break;
    case 0xc: // coin block?
        break;
    case 0xe: //reset i8751??
        i8751_return=0;
        break;
    default:
        printf("unknown dec_ctrl_writeword %x,%x\n",a,d);
    }
}
Exemple #27
0
static void YM2151RenderNormal(INT16* pSoundBuf, INT32 nSegmentLength)
{
#if defined FBA_DEBUG
	if (!DebugSnd_YM2151Initted) bprintf(PRINT_ERROR, _T("YM2151RenderNormal called without init\n"));
#endif

	nBurnPosition += nSegmentLength;

	pYM2151Buffer[0] = pBuffer;
	pYM2151Buffer[1] = pBuffer + nSegmentLength;

	YM2151UpdateOne(0, pYM2151Buffer, nSegmentLength);
	
	for (INT32 n = 0; n < nSegmentLength; n++) {
		INT32 nLeftSample = 0, nRightSample = 0;
		
		if ((YM2151RouteDirs[BURN_SND_YM2151_YM2151_ROUTE_1] & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) {
			nLeftSample += (INT32)(pYM2151Buffer[0][n] * YM2151Volumes[BURN_SND_YM2151_YM2151_ROUTE_1]);
		}
		if ((YM2151RouteDirs[BURN_SND_YM2151_YM2151_ROUTE_1] & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) {
			nRightSample += (INT32)(pYM2151Buffer[0][n] * YM2151Volumes[BURN_SND_YM2151_YM2151_ROUTE_1]);
		}
		
		if ((YM2151RouteDirs[BURN_SND_YM2151_YM2151_ROUTE_2] & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) {
			nLeftSample += (INT32)(pYM2151Buffer[1][n] * YM2151Volumes[BURN_SND_YM2151_YM2151_ROUTE_2]);
		}
		if ((YM2151RouteDirs[BURN_SND_YM2151_YM2151_ROUTE_2] & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) {
			nRightSample += (INT32)(pYM2151Buffer[1][n] * YM2151Volumes[BURN_SND_YM2151_YM2151_ROUTE_2]);
		}
		
		nLeftSample = BURN_SND_CLIP(nLeftSample);
		nRightSample = BURN_SND_CLIP(nRightSample);
			
		pSoundBuf[(n << 1) + 0] = nLeftSample;
		pSoundBuf[(n << 1) + 1] = nRightSample;
	}
}
static void
http_swallow_body(struct http *hp, char * const *hh, int body)
{
	char *p;
	int i, l, ll;

	hp->body = hp->rxbuf + hp->prxbuf;
	ll = 0;
	p = http_find_header(hh, "transfer-encoding");
	if (p != NULL && !strcasecmp(p, "chunked")) {
		while (http_rxchunk(hp) != 0)
			continue;
		vtc_dump(hp->vl, 4, "body", hp->body, ll);
		ll = hp->rxbuf + hp->prxbuf - hp->body;
		hp->bodyl = ll;
		sprintf(hp->bodylen, "%d", ll);
		return;
	}
	p = http_find_header(hh, "content-length");
	if (p != NULL) {
		l = strtoul(p, NULL, 10);
		(void)http_rxchar(hp, l, 0);
		vtc_dump(hp->vl, 4, "body", hp->body, l);
		hp->bodyl = l;
		bprintf(hp->bodylen, "%d", l);
		return;
	}
	if (body) {
		do  {
			i = http_rxchar(hp, 1, 1);
			ll += i;
		} while (i > 0);
		vtc_dump(hp->vl, 4, "rxeof", hp->body, ll);
	}
	hp->bodyl = ll;
	sprintf(hp->bodylen, "%d", ll);
}
Exemple #29
0
void
macro_undef(struct vtclog *vl, const char *instance, const char *name)
{
	char buf1[256];
	struct macro *m;

	if (instance != NULL) {
		bprintf(buf1, "%s_%s", instance, name);
		name = buf1;
	}

	AZ(pthread_mutex_lock(&macro_mtx));
	VTAILQ_FOREACH(m, &macro_list, list)
		if (!strcmp(name, m->name))
			break;
	if (m != NULL) {
		vtc_log(vl, 4, "macro undef %s", name);
		VTAILQ_REMOVE(&macro_list, m, list);
		free(m->name);
		free(m->val);
		free(m);
	}
	AZ(pthread_mutex_unlock(&macro_mtx));
}
Exemple #30
0
int client(int argc, char *argv[])
{
  int my_pid = MSG_process_get_PID(MSG_process_self());
  // use my pid as name of mailbox to contact me
  char *my_mailbox = bprintf("%d", my_pid);
  // request the CS 3 times, sleeping a bit in between
  int i;
  for (i = 0; i < CS_PER_PROCESS; i++) {
    XBT_INFO("Ask the request");
    MSG_task_send(MSG_task_create("request", 0, 1000, my_mailbox),
                  "coordinator");
    // wait the answer
    msg_task_t grant = NULL;
    MSG_task_receive(&grant, my_mailbox);
    MSG_task_destroy(grant);
    XBT_INFO("got the answer. Sleep a bit and release it");
    MSG_process_sleep(1);
    MSG_task_send(MSG_task_create("release", 0, 1000, NULL),
                  "coordinator");
    MSG_process_sleep(my_pid);
  }
  XBT_INFO("Got all the CS I wanted, quit now");
  return 0;
}