Exemplo n.º 1
0
int main()
{
    char *resp = NULL;
    printf("s is :%s\n",resp);
    getresp(&resp);
    resp[2] = 'W';
    printf("%s\n", resp);
    printf("strlen is %s %d \n",resp, strlen(resp));
}
Exemplo n.º 2
0
static int
sdiocmd(u32int cmd, u32int arg, u32int *resp)
{
	int i, err;
	u32int c;
	u32int *r;

	assert(cmd < nelem(cmdinfo) && cmdinfo[cmd] != 0);
	i = GETTM(cmdinfo[cmd]);
	c = cmd<<Indexshift | GETCMD(cmdinfo[cmd]);
	if(c & Isdata)
		if(i & Card2host)
			i |= PIOread?  Hostpio: Hostdma;
		else
			i |= PIOwrite? Hostpio: Hostdma;
	WR(Tm, i);
	WR(ArgLSB, arg);
	WR(ArgMSB, arg>>16);
	WR(ErrIntr, ~0);
	WR(Cmd, c);

	r = (u32int*)AddrSdio;
	i = awaitdone(r, Cmddone, HZ);
	if((i & (Cmddone|Err)) != Cmddone){
		if((err = r[ErrIntr]) != Ctoerr)
			iprint("sdio: cmd %#ux error intr %#ux %#ux stat %#ux\n",
				c, i, err, r[Hoststat]);
		WR(ErrIntr, err);
		WR(Interrupt, i);
		error(Eio);
	}
	WR(Interrupt, i & ~Datadone);

	c &= Respmask;
	getresp(r, resp, c);
	if(c == Resp48busy)
		awaitresp48data(r, cmd);

	finishcmd(cmd, arg);
	return 0;
}
Exemplo n.º 3
0
void main(void) {
    unsigned char socket0status;
    unsigned char ip_addr[] = {192,168,1,182}; //{169,254,180,2}; //
    delay(100);
    printf("\nW5500 Test Mule Tweet\n");
    delay(500);
    wiz_Init(ip_addr); //initialize the wiznet chip
    socket0_client_init();

    while(1) { // Loop forever
        socket0status=wizGetCtl8(SnSR);
        printf("s0s=%cx ",socket0status);
        if (socket0status==SOCK_ESTABLISHED) { //we're connected
            sendreq();
            getresp();
            printf("stalling\n");
            while(1);//loop here
        }
        delay(100);
    }
}
Exemplo n.º 4
0
void
readinput(register pb_t *ppb)
{
	register int	i;
	resp_t		*rp;

	/*
	**  Top Loop.
	**	Executed once for each complete block read.  Normally
	**	only executed once, but can be more if an error
	**	block is read.
	**
	**	We mark Qbuf first, so we can free any parameters
	**	when they are no longer needed (such as when they
	**	are passed to another process).
	*/

	Ctx.ctx_pmark = markbuf(Qbuf);
#ifdef xCTR1
	if (tTf(10, 0))
		lprintf("readinput: mark %d, errfn %x, ppb %x\n", Ctx.ctx_pmark, Ctx.ctx_errfn, ppb);
#endif
	rp = getresp();
	for (;;) {
		/* prime the input (reads first block) */
		pb_prime(ppb, PB_NOTYPE);
#ifdef xCTR2
		if (tTf(10, 1))
			lprintf("readinput: type %d\n", ppb->pb_type);
#endif

		/* if this is a response block, return immediately */
		if (ppb->pb_type == PB_RESP) {
			i = pb_get(ppb, (char *) rp, sizeof(resp_t));
			if (i != sizeof(resp_t))
				syserr("readinput: resp_t sz %d", i);
/*
			read_arg(ppb, &rp->resp_rval);
*/
			break;
		}

		/*
		**  Parameter Loop.
		**	Wander through and start reading parameters.
		*/

		for (Ctx.ctx_pc = 0; Ctx.ctx_pc < PV_MAXPC; Ctx.ctx_pc++) {
			if (read_arg(ppb, &Ctx.ctx_pv[Ctx.ctx_pc]) == PV_EOF)
				break;
		}

		/* out of loop, check for vector overflow */
		if (Ctx.ctx_pc >= PV_MAXPC)
			syserr("readinput: overflow");

		/* check for error blocks */
		if (ppb->pb_type == PB_ERR) {
			proc_err(ppb, Ctx.ctx_pc, Ctx.ctx_pv);
			syserr("readinput: proc_err");
		}


		/* non-error block */
#ifdef xCM_DEBUG
		if (ppb->pb_type != PB_REG)
			syserr("readinput: pb_type %d", ppb->pb_type);
#endif
		Ctx.ctx_resp = ppb->pb_resp;
		break;
	}
#ifdef xCTR1
	if (tTf(10, 4)) {
		lprintf("readinput: ");
		pb_dump(ppb, FALSE);
	}
#endif
}
Exemplo n.º 5
0
int authsasl_plain(const char *method, const char *initresponse,
	char *(*getresp)(const char *),

	char **authtype,
	char **authdata)
{
char	*uid;
char	*pw;
char	*p;
int	n;
int	i;

	if (initresponse)
	{
		p=malloc(strlen(initresponse)+1);
		if (!p)
		{
			perror("malloc");
			return (AUTHSASL_ERROR);
		}
		strcpy(p, initresponse);
	}
	else
	{
		p=authsasl_tobase64("", -1);
		if (!p)
		{
			perror("malloc");
			return (AUTHSASL_ERROR);
		}
		uid=getresp(p);
		free(p);
		p=uid;
		if (!p)
		{
			perror("malloc");
			return (AUTHSASL_ERROR);
		}

		if (*p == '*')
		{
			free(p);
			return (AUTHSASL_ABORTED);
		}
	}

	if ((n=authsasl_frombase64(p)) < 0)
	{
		free(p);
		return (AUTHSASL_ABORTED);
	}
	p[n]=0;

	uid=pw=0;

	for (i=0; i<n; i++)
	{
		if (p[i] == 0)
		{
			++i;
			for (uid=p+i; i<n; i++)
				if (p[i] == 0)
				{
					pw=p+i+1;
					break;
				}
		}
	}

	if (pw == 0)
	{
		free(p);
		return (AUTHSASL_ABORTED);	/* Bad message */
	}

	if ( (*authtype=malloc(sizeof(AUTHTYPE_LOGIN))) == 0)
	{
		free(p);
		perror("malloc");
		return (AUTHSASL_ERROR);
	}

	strcpy( *authtype, AUTHTYPE_LOGIN);

	if ( (*authdata=malloc(strlen(uid)+strlen(pw)+3)) == 0)
	{
		free( *authtype );
		free(p);
		perror("malloc");
		return (AUTHSASL_ERROR);
	}

	strcat(strcat(strcat(strcpy(*authdata, uid), "\n"), pw), "\n");
	free(p);
	return (AUTHSASL_OK);
}