コード例 #1
0
ファイル: host-lib.c プロジェクト: Oldes/r3
*/	REBCHR *OS_List_Env(void)
/*
***********************************************************************/
{
	REBCHR *env = GetEnvironmentStrings();
	REBCNT n, len = 0;
	REBCHR *str;

	str = env;
	while (n = (REBCNT)LEN_STR(str)) {
		len += n + 1;
		str = env + len; // next
	}
	len++;

	str = OS_Make(len * sizeof(REBCHR));
	MOVE_MEM(str, env, len * sizeof(REBCHR));

	FreeEnvironmentStrings(env);

	return str;
}
コード例 #2
0
ファイル: host-stdio.c プロジェクト: RamchandraApte/rebol
static REBYTE *Get_Next_Line()
{
	REBYTE *bp = inbuf;
	REBYTE *out;
	REBCNT len;

	// Scan for line terminator or end:
	for (bp = inbuf; *bp != CR && *bp != LF && *bp != 0; bp++);

	// If found, copy the line and remove it from buffer:
	if (*bp) {
		if (*bp == CR && bp[1] == LF) bp++;
		len = bp - inbuf;
		out = OS_Make(len + 2);
		COPY_BYTES(out, inbuf, len+1);
		out[len+1] = 0;
		MOVE_MEM(inbuf, bp+1, 1+strlen(bp+1));
		return out;
	}

	return 0; // more input needed
}