Esempio n. 1
0
/*
 *  Remove pipe/redirection stuff from the end of the command line.
 */ 
static void
strip_redirection(char *buf)
{
	char *p1, *p2;

	p1 = strstr_rightmost(buf, args[argcnt-1]);
	p2 = p1 + strlen(args[argcnt-1]);
	console("strip_redirection: [%s]\n", p2);

	if ((p1 = strpbrk(p2, "|!>")))
		*p1 = NULLCHAR;

	strip_ending_whitespace(buf);
}
Esempio n. 2
0
char *
get_extra_flags(char *filename, char *initial)
{
	FILE *fp;
	char inbuf[512];
	char buf[512];

	if (!file_exists(filename))
		return (initial ? initial : NULL);

	if ((fp = fopen(filename, "r")) == NULL) {
		perror(filename);
		return (initial ? initial : NULL);
	}

	if (initial)
		strcpy(buf, initial);
	else
		buf[0] = '\0';

	while (fgets(inbuf, 512, fp)) {
		strip_linefeeds(inbuf);
		strip_beginning_whitespace(inbuf);
		strip_ending_whitespace(inbuf);
		if (inbuf[0] == '#')
			continue;
		if (strlen(inbuf)) {
			if (strlen(buf))
				strcat(buf, " ");			
			strcat(buf, inbuf);
		}
	}

	fclose(fp);

	if (strlen(buf))
		return strdup(buf);
	else 
		return NULL;
}