Exemple #1
0
int
acl_fromtext(const char *acltextp, acl_t **ret_aclp)
{
	int error;
	char *buf;

	buf = malloc(strlen(acltextp) + 2);
	if (buf == NULL)
		return (EACL_MEM_ERROR);
	strcpy(buf, acltextp);
	strcat(buf, "\n");

	(void) mutex_lock(&yymutex);
	yybuf = buf;
	yyreset();
	error = yyparse();
	free(buf);

	if (yyacl) {
		if (error == 0)
			*ret_aclp = yyacl;
		else {
			acl_free(yyacl);
		}
		yyacl = NULL;
	}
	(void) mutex_unlock(&yymutex);

	return (error);
}
Exemple #2
0
int yylexer::yycreate(yyparser YYFAR* parserptr)
{
	yyparserptr = parserptr;

	size_t textcharsize;
	size_t statebufcharsize;
	size_t unputbufcharsize;

	// get sizes first
	textcharsize = yystext_size + 1;	// include the '\0'
	if (textcharsize <= (size_t)yystext_size) {
		return 0;		// integer overflow
	}
	if (yystext_size != 0) {
		statebufcharsize = yystext_size * sizeof(int);
		if ((int)(statebufcharsize / sizeof(int)) != yystext_size) {
			return 0;		// integer overflow
		}
	}
	else {
		statebufcharsize = 0;
	}
	if (yysunput_size != 0) {
		unputbufcharsize = yysunput_size * sizeof(int);
		if ((int)(unputbufcharsize / sizeof(int)) != yysunput_size) {
			return 0;		// integer overflow
		}
	}
	else {
		unputbufcharsize = 0;
	}

	// allocate the memory if necessary
	yystext = (char YYFAR*)malloc(textcharsize);
	if (yystext == NULL) {
		return 0;
	}
	if (statebufcharsize != 0) {
		yysstatebuf = (int YYFAR*)malloc(statebufcharsize);
		if (yysstatebuf == NULL) {
			free(yystext);
			return 0;
		}
	}
	else {
		yysstatebuf = NULL;
	}
	if (unputbufcharsize != 0) {
		yysunputbufptr = (int YYFAR*)malloc(unputbufcharsize);
		if (yysunputbufptr == NULL) {
			free(yystext);
			free(yysstatebuf);
			return 0;
		}
	}
	else {
		yysunputbufptr = NULL;
	}

	// assign any other variables
	yytext_size = yystext_size;
	yytext = yystext;
	yystatebuf = yysstatebuf;
	yyunput_size = yysunput_size;
	yyunputbufptr = yysunputbufptr;

	// makes sure we are ready to go
	yyreset();

	return 1;
}