예제 #1
0
파일: sbar.c 프로젝트: wol22/MotleyTools
void function (signed start, signed space, size_t length, flag_t flags) 

{ 
	signed c; 
	size_t column; 
	while ((c = getc (stdin)) != EOF) 
	{ 
		if (flags & SBAR_B_SHIFT) 
		{ 
			for (column = 0; isblank (c); column++) 
			{ 
				if (c == '\t') 
				{ 
					column -= column % 8; 
					column += 8; 
				} 
				c = getc (stdin); 
			} 
		} 
		if (c == start) 
		{ 
			putc (start, stdout); 
			c = getc (stdin); 
			if ((c == space) || (c == CUPPER) || (c == CLOWER)) 
			{ 
				putc (space, stdout); 
				c = getc (stdin); 
				if ((c == CUPPER) || (c == CLOWER)) 
				{ 
					column = length; 
					while (column-- > 0) 
					{ 
						putc (c, stdout); 
					} 
					while (nobreak (c)) 
					{ 
						c = getc (stdin); 
					} 
				} 
			} 
		} 
		else if (flags & SBAR_B_SHIFT) 
		{ 
			while (column-- > 0) 
			{ 
				putc (' ', stdout); 
			} 
		} 
		while (nobreak (c)) 
		{ 
			putc (c, stdout); 
			c = getc (stdin); 
		} 
		putc ('\n', stdout); 
	} 
	return; 
} 
예제 #2
0
int translatedpart3(int uid)
{
    char *ept;
    struct translatet *th;
    struct socketnodes *lkm;
    pcontext;
    th=gettranslate(uid);
    pcontext;
    if(th==NULL)
	return 0x0;
    lkm=getpsocketbysock(th->sock);
    if(lkm==NULL)
    {
	erasetranslate(uid);
	return 0x0;
    }
    pcontext;
    ept=nobreak(ircbuf);
    ept=strstr(ept,lngtxt(870));
    if(ept!=NULL)
    {
	ept=strchr(ept,'>');
	if(ept!=NULL)
	{
	    ept++;
	    th->translatedtext=strmcat(th->translatedtext,ept);
	    th->translatedtext=strmcat(th->translatedtext," ");
	}
	lkm->sock->handler=translatedpart4;
    } else {
	if(strstr(ircbuf,"</strong>")!=NULL)
	    lkm->sock->handler=translatedpart4;
    }
    return 0x0;
}
예제 #3
0
파일: offset.c 프로젝트: wol22/MotleyTools
static void efsu (flag_t flags) 

{ 
	extern unsigned lineno; 
	extern unsigned margin; 
	extern unsigned column; 
	extern unsigned origin; 
	extern unsigned offset; 
	extern unsigned length; 
	extern char * symbol; 
	extern char * string; 
	extern signed c; 
	lineno = 1; 
	origin = 0; 
	offset = 0; 
	length = 0; 
	while ((c = getc (stdin)) != EOF) 
	{ 
		if (isspace (c)) 
		{ 
			if (c == '\n') 
			{ 
				lineno++; 
			} 
			continue; 
		} 
		if ((c == '#') || (c == ';')) 
		{ 
			do 
			{ 
				c = getc (stdin); 
			} 
			while (nobreak (c)); 
			lineno++; 
			continue; 
		} 
		object (); 
		if (length) 
		{ 
			unsigned column = 0; 
			printf ("# %s\n", symbol); 
			while (column < length) 
			{ 
				putc ('0', stdout); 
				putc ('0', stdout); 
				putc (++ column % 16? ' ': '\n', stdout); 
			} 
			if (column % 16) 
			{ 
				putc ('\n', stdout); 
			} 
		} 
		offset += length; 
		lineno++; 
	} 
	return; 
} 
예제 #4
0
static void assemble (flag_t flags) 

{
	extern signed c;
	c = mygetc ();
	while (c != EOF) 
	{
		if (isspace (c)) 
		{
			do 
			{
				c = mygetc ();
			}
			while (isspace (c));
			continue;
		}
		if ((c == '#') || (c == ';')) 
		{
			do 
			{
				c = mygetc ();
			}
			while (nobreak (c));
			continue;
		}
		phy = integer (16);
		reg = integer (16);
		data = integer (16);
		mask = integer (16);
		instr = MDIO16_INSTR (1, 1, phy, reg, 2);
		write (STDOUT_FILENO, &instr, sizeof (instr));
		data = HTOLE16 (data & 0xFFFF);
		write (STDOUT_FILENO, &data, sizeof (data));
		mask = HTOLE16 (mask & 0xFFFF);
		write (STDOUT_FILENO, &mask, sizeof (mask));
		count++;
		if (_anyset (flags, MDIO_VERBOSE)) 
		{
			fprintf (stderr, "INSTR=0x%04X DATA=0x%04X MASK=0x%04X\n", instr, data, mask);
		}
		if ((c == ';') || (c == EOF)) 
		{
			c = mygetc ();
			continue;
		}
		if (_allclr (flags, MDIO_SILENCE)) 
		{
			error (1, 0, "Illegal character or missing terminator: line %d col %d", row, col);
		}
	}
	return;
}
예제 #5
0
static signed function (signed c, unsigned width)

{
	while (c != EOF)
	{
		unsigned count;
		while (isblank (c))
		{
			c = getc (stdin);
		}
		while (isxdigit (c))
		{
			c = getc (stdin);
		}
		while (isblank (c))
		{
			c = getc (stdin);
		}
		if (nobreak (c))
		{
			for (count = 0; count < width; count++)
			{
				putc (c, stdout);
				c = getc (stdin);
			}
		}
		while (nobreak (c))
		{
			c = getc (stdin);
		}
		if (c != EOF)
		{
			putc (c, stdout);
			c = getc (stdin);
		}
	}
	return (c);
}
예제 #6
0
signed fortran (signed c) 

{
	c = keep (c);
	while (nobreak (c)) 
	{
		if (c == '/') 
		{
			c = comment (c);
			continue;
		}
		c = escaped (c);
	}
	c = keep (c);
	return (c);
}
예제 #7
0
파일: offset.c 프로젝트: wol22/MotleyTools
static void tabs (flag_t flags) 

{ 
	extern unsigned lineno; 
	extern unsigned margin; 
	extern unsigned offset; 
	extern unsigned length; 
	extern char * symbol; 
	extern char * string; 
	extern signed c; 
	lineno = 1; 
	offset = 0; 
	length = 0; 
	while ((c = getc (stdin)) != EOF) 
	{ 
		if (isspace (c)) 
		{ 
			if (c == '\n') 
			{ 
				lineno++; 
			} 
			continue; 
		} 
		if ((c == '#') || (c == ';')) 
		{ 
			do 
			{ 
				c = getc (stdin); 
			} 
			while (nobreak (c)); 
			lineno++; 
			continue; 
		} 
		object (); 
		if (length) 
		{ 
			printf ("%08X\t%6d\t%s\t%s\n", offset, length, symbol, string); 
		} 
		else 
		{ 
			printf ("\n\t\t%s %s\n", symbol, string); 
		} 
		offset += length; 
		lineno++; 
	} 
	return; 
} 
예제 #8
0
파일: offset.c 프로젝트: wol22/MotleyTools
static void zero (flag_t flags) 

{ 
	signed c = getc (stdin); 
	while (c != EOF) 
	{ 
		while (isspace (c)) 
		{ 
			putc (c, stdout); 
			c = getc (stdin); 
		} 
		if ((c == '+') || (c == '-')) 
		{ 
			do 
			{ 
				putc (c, stdout); 
				c = getc (stdin); 
			} 
			while (isblank (c)); 
		} 
		while (c == '0') 
		{ 
			c = getc (stdin); 
			if (!isdigit (c)) 
			{ 
				putc ('0', stdout); 
				break; 
			} 
		} 
		while (nobreak (c)) 
		{ 
			putc (c, stdout); 
			c = getc (stdin); 
		} 
	} 
	return; 
} 
예제 #9
0
int translatedpart4(int uid)
{
    char *ept,*pt;
    struct translatet *th;
    struct socketnodes *lkm;
    pcontext;
    th=gettranslate(uid);
    pcontext;
    if(th==NULL)
	return 0x0;
    lkm=getpsocketbysock(th->sock);
    if(lkm==NULL)
    {
	erasetranslate(uid);
	return 0x0;
    }
    pcontext;
    ept=strstr(ircbuf,lngtxt(871));
    if(ept==NULL)
    {
	ept=strstr(ircbuf,"<p>");
    }
    if(ept!=NULL)
    {
	ept=strstr(th->translatedtext,lngtxt(872));
	if(ept!=NULL)
	{
	    ept=strchr(th->translatedtext,':');
	    if(ept==th->translatedtext) ept=strchr(ept+1,':');
	    if(ept!=NULL)
	    {
		*ept=0;
		th->translatedtext=strmcat(th->translatedtext,lngtxt(873));
	    }
	}
	ept=strstr(th->translatedtext,"<P>");
	if(ept!=NULL)
	{ 
	    *ept=0;
	}
	th->translatedtext=strmcat(th->translatedtext,"\r\n");
	if(th->direction==TR_TO)
	{
	    if(user(th->usern)->outstate==STD_CONN)
	    {
		writesock(user(th->usern)->outsock,th->translatedtext);
		if(user(th->usern)->instate>STD_NOCON)
		{
		    pt=strchr(th->translatedtext,':');
		    if(pt!=NULL)
		    {
			if(strchr("#!&+",*th->dest)!=NULL)
			{
			    ssnprintf(user(th->usern)->insock,lngtxt(874),user(th->usern)->nick,user(th->usern)->login,user(th->usern)->host,th->dest,pt);
			} else {
			    ssnprintf(user(th->usern)->insock,lngtxt(875),th->dest,user(th->usern)->nick,pt);
			}
		    }
		}
	    }
	} else {
	    if(user(th->usern)->instate>STD_NOCON)
	    {
		writesock(user(th->usern)->insock,th->translatedtext);
	    }
	}
	erasetranslate(uid); /* job done, socket gone */
    } else {    
	ept=nobreak(ircbuf);
	pt=strstr(ept,"<textarea");
	if(pt!=NULL)
	{
	    pt=strchr(pt,'>');
	    if(pt!=NULL)
	    {
		ept=pt+1;
	    }
	}
	while(*ept==' ' || *ept==9) ept++;
	if(*ept)
	{
	    th->translatedtext=strmcat(th->translatedtext,ept);
	    th->translatedtext=strmcat(th->translatedtext," ");
	}
    }
    return 0x0;
}
예제 #10
0
파일: offset.c 프로젝트: wol22/MotleyTools
static void text (flag_t flags) 

{ 
	extern unsigned lineno; 
	extern unsigned margin; 
	extern unsigned column; 
	extern unsigned origin; 
	extern unsigned offset; 
	extern unsigned length; 
	extern char * symbol; 
	extern char * string; 
	extern signed c; 
	lineno = 1; 
	origin = 0; 
	offset = 0; 
	length = 0; 
	while ((c = getc (stdin)) != EOF) 
	{ 
		if (isspace (c)) 
		{ 
			if (c == '\n') 
			{ 
				lineno++; 
			} 
			continue; 
		} 
		if ((c == '#') || (c == ';')) 
		{ 
			do 
			{ 
				c = getc (stdin); 
			} 
			while (nobreak (c)); 
			lineno++; 
			continue; 
		} 
		object (); 
		if (length) 
		{ 
			unsigned output = printf (" %08X %10d %s", offset, length, symbol); 
			while (output++ < column) 
			{ 
				putc (' ', stdout); 
			} 
			if (* string) 
			{ 
				printf (" (%s)", string); 
			} 
			printf ("\n"); 
		} 
		else 
		{ 
			if (offset) 
			{ 
				printf (" -------- %10d bytes\n\n", offset - origin); 
			} 
			printf (" -------- %10d %s %s\n", offset, symbol, string); 
			origin = offset; 
		} 
		offset += length; 
		lineno++; 
	} 
	if (offset) 
	{ 
		printf (" -------- %10d bytes\n\n", offset - origin); 
	} 
	printf (" %08X  %10d bytes\n", offset, offset); 
	return; 
} 
예제 #11
0
파일: offset.c 프로젝트: wol22/MotleyTools
static void html (char const * colors [], unsigned count, flag_t flags) 

{ 
	time_t now = time (& now); 
	static char datetime [LOGTIME_LEN]; 
	extern unsigned lineno; 
	extern unsigned margin; 
	extern unsigned offset; 
	extern unsigned length; 
	extern char * symbol; 
	extern char * string; 
	extern signed c; 
	strftime (datetime, sizeof (datetime), LOGTIME, localtime (& now)); 
	lineno = 1; 
	offset = 0; 
	length = 0; 
	if (_anyset (flags, OFFSET_PAGE)) 
	{ 
		indent (margin++, "<html>"); 
		indent (margin++, "<title>"); 
		indent (margin--, "</title>"); 
		indent (margin++, "<head>"); 
		indent (margin++, "<style>"); 
		margin = stylesheet (margin); 
		indent (margin--, "</style>"); 
		indent (margin--, "</head>"); 
		indent (margin++, "<body>"); 
		indent (0, "<!-- BEGIN CONTENT -->"); 
	} 
	while ((c = getc (stdin)) != EOF) 
	{ 
		unsigned index; 
		if (isspace (c)) 
		{ 
			if (c == '\n') 
			{ 
				lineno++; 
			} 
			continue; 
		} 
		if ((c == '#') || (c == ';')) 
		{ 
			do 
			{ 
				c = getc (stdin); 
			} 
			while (nobreak (c)); 
			lineno++; 
			continue; 
		} 
		index = object () % count; 
		if (!length) 
		{ 
			if (offset) 
			{ 
				indent (margin--, "</table>"); 
			} 
			indent (margin++, "<h2 class='%s'>", style); 
			indent (margin, "%s %s", symbol, string); 
			indent (margin--, "</h2>"); 
			indent (margin++, "<table class='%s'>", style); 
			indent (margin++, "<tr class='%s'>", style); 
			indent (margin++, "<th class='%s'>", style_offset); 
			indent (margin, "%s", label_offset); 
			indent (margin--, "</th>"); 
			indent (margin++, "<th class='%s'>", style_length); 
			indent (margin, "%s", label_length); 
			indent (margin--, "</th>"); 
			indent (margin++, "<th class='%s'>", style_symbol); 
			indent (margin, "%s", label_symbol); 
			indent (margin--, "</th>"); 
			indent (margin++, "<th class='%s'>", style_string); 
			indent (margin, "%s", label_string); 
			indent (margin--, "</th>"); 
			indent (margin--, "</tr>"); 
		} 
		else 
		{ 
			if (!offset) 
			{ 
				indent (margin++, "<h2 class='%s'>", style); 
				indent (margin, "No Title"); 
				indent (margin--, "</h2>"); 
				indent (margin++, "<table>"); 
				indent (margin++, "<table class='%s'>", style); 
				indent (margin++, "<tr class='%s'>", style); 
				indent (margin++, "<th class='%s'>", style_offset); 
				indent (margin, "%s", label_offset); 
				indent (margin--, "</th>"); 
				indent (margin++, "<th class='%s'>", style_length); 
				indent (margin, "%s", label_length); 
				indent (margin--, "</th>"); 
				indent (margin++, "<th class='%s'>", style_symbol); 
				indent (margin, "%s", label_symbol); 
				indent (margin--, "</th>"); 
				indent (margin++, "<th class='%s'>", style_string); 
				indent (margin, "%s", label_string); 
				indent (margin--, "</th>"); 
				indent (margin--, "</tr>"); 
			} 
			indent (margin++, "<tr class='%s'>", style); 
			indent (margin++, "<td class='%s' style='background: %s;'>", style_offset, colors [index]); 
			indent (margin, "%08X", offset); 
			indent (margin--, "</td>"); 
			indent (margin++, "<td class='%s' style='background: %s;'>", style_length, colors [index]); 
			indent (margin, "%6d", length); 
			indent (margin--, "</td>"); 
			indent (margin++, "<td class='%s' style='background: %s;'>", style_symbol, colors [index]); 
			indent (margin, "%s", * symbol? symbol: "&nbsp;"); 
			indent (margin--, "</td>"); 
			indent (margin++, "<td class='%s' style='background: %s;'>", style_string, colors [index]); 
			indent (margin, "%s", * string? string: "&nbsp;"); 
			indent (margin--, "</td>"); 
			indent (margin--, "</tr>"); 
		} 
		offset += length; 
		lineno++; 
	} 
	if (offset) 
	{ 
		indent (margin--, "</table>"); 
	} 
	indent (margin++, "<div class='%s'>", style_posted); 
	indent (margin, "Posted %s on %s by %s", datetime, hostname (), username (getuid ())); 
	indent (margin--, "</div>"); 
	indent (0, "<!-- END CONTENT -->"); 
	if (_anyset (flags, OFFSET_PAGE)) 
	{ 
		indent (margin--, "</body>"); 
		indent (margin--, "</html>"); 
	} 
	return; 
} 
예제 #12
0
파일: offset.c 프로젝트: wol22/MotleyTools
static unsigned object () 

{ 
	extern signed c; 
	extern unsigned lineno; 
	extern unsigned length; 
	extern char * symbol; 
	extern char * string; 
	unsigned count = 0; 
	char * sp; 
	char * cp; 
	length = 0; 
	if ((c == '+') || (c == '-')) 
	{ 
		do 
		{ 
			c = getc (stdin); 
		} 
		while (isblank (c)); 
	} 
	while (c == '0') 
	{ 
		c = getc (stdin); 
		count++; 
	} 
	while (isdigit (c)) 
	{ 
		length *= 10; 
		length += c - '0'; 
		c = getc (stdin); 
	} 
	while (isblank (c)) 
	{ 
		c = getc (stdin); 
	} 
	sp = symbol; 
	if (isalpha (c) || (c == '_')) 
	{ 
		do 
		{ 
			* sp++ = (char)(c); 
			c = getc (stdin); 
		} 
		while (isalnum (c) || (c == '_') || (c == '-') || (c == '.') || (c == ':')); 
	} 
	while (isblank (c)) 
	{ 
		c = getc (stdin); 
	} 
	if (c == '[') 
	{ 
		* sp++ = (char)(c); 
		c = getc (stdin); 
		while (isblank (c)) 
		{ 
			c = getc (stdin); 
		} 
		while (isdigit (c)) 
		{ 
			* sp++ = (char)(c); 
			c = getc (stdin); 
		} 
		while (isblank (c)) 
		{ 
			c = getc (stdin); 
		} 
		* sp = (char)(0); 
		if (c != ']') 
		{ 
			error (1, EINVAL, "Have '%s' but need ']' on line %d", symbol, lineno); 
		} 
		* sp++ = (char)(c); 
		c = getc (stdin); 
	} 
	* sp = (char)(0); 
	while (isblank (c)) 
	{ 
		c = getc (stdin); 
	} 
	sp = cp = string; 
	while (nobreak (c)) 
	{ 
		* cp++ = (char)(c); 
		if (!isspace (c)) 
		{ 
			sp = cp; 
		} 
		c = getc (stdin); 
	} 
	* sp = (char)(0); 
	return (count); 
} 
예제 #13
0
static void function (file const * file, off_t extent, flag_t flags)

{
	unsigned object = 0;
	unsigned lineno = 0;
	unsigned offset = 0;
	unsigned length = 0;
	char memory [_ADDRSIZE +  1];
	char symbol [_NAMESIZE];
	char string [_LINESIZE];
	char * sp;
	signed c;
	while ((c = getc (stdin)) != EOF)
	{
		if ((c == '#') || (c == ';'))
		{
			do 
			{
				c = getc (stdin);
			}
			while (nobreak (c));
			lineno++;
			continue;
		}
		if (isspace (c))
		{
			if (c == '\n')
			{
				lineno++;
			}
			continue;
		}
		length = 0;
		while (isdigit (c))
		{
			length *= 10;
			length += c - '0';
			c = getc (stdin);
		}
		while (isblank (c))
		{
			c = getc (stdin);
		}
		sp = symbol;
		if (isalpha (c) || (c == '_'))
		{
			do 
			{
				* sp++ = (char) (c);
				c = getc (stdin);
			}
			while (isident (c));
		}
		while (isblank (c))
		{
			c = getc (stdin);
		}
		if (c == '[')
		{
			* sp++ = (char) (c);
			c = getc (stdin);
			while (isblank (c))
			{
				c = getc (stdin);
			}
			while (isdigit (c))
			{
				* sp++ = (char) (c);
				c = getc (stdin);
			}
			while (isblank (c))
			{
				c = getc (stdin);
			}
			* sp = (char) (0);
			if (c != ']')
			{
				error (1, EINVAL, "Have '%s' without ']' on line %d", symbol, lineno);
			}
			* sp++ = (char) (c);
			c = getc (stdin);
		}
		* sp = (char) (0);
		while (isblank (c))
		{
			c = getc (stdin);
		}
		sp = string;
		while (nobreak (c))
		{
			* sp++ = (char) (c);
			c = getc (stdin);
		}
		* sp = (char) (0);
		if (length)
		{
			byte buffer [length];
			if (read (file->file, buffer, length) == (signed) (length))
			{
				if (! object++)
				{
					for (c = 0; c < _ADDRSIZE +  65; c++)
					{
						putc ('-', stdout);
					}
					putc ('\n', stdout);
				}
				printf ("%s %u %s\n", hexoffset (memory, sizeof (memory), offset), length, symbol);
				hexview (buffer, offset, length, stdout);
				for (c = 0; c < _ADDRSIZE +  65; c++)
				{
					putc ('-', stdout);
				}
				putc ('\n', stdout);
			}
		}
		offset += length;
		lineno++;
	}
	if (_allclr (flags, ODD_SILENCE))
	{
		if (offset != (unsigned) (extent))
		{
			error (0, 0, "%s has %u bytes, not " OFF_T_SPEC " bytes.", file->name, offset, extent);
		}
	}
	return;
}
예제 #14
0
unsigned function (char const * oldname, char const * newname)

{
	unsigned count = 0;
	signed c = getc (stdin);
	while (c != EOF)
	{
		if (isspace (c))
		{
			do 
			{
				putc (c, stdout);
				c = getc (stdin);
			}
			while (isspace (c));
			continue;
		}
		if (isalpha (c) || (c == '_'))
		{
			char string [255];
			char * sp = string;
			do 
			{
				* sp++ = (char) (c);
				c = getc (stdin);
			}
			while (isalnum (c) || (c == '_'));
			* sp = (char) (0);
			if (! strcmp (string, oldname))
			{
				count++;
				fputs (newname, stdout);
				continue;
			}
			fputs (string, stdout);
			continue;
		}
		if (isdigit (c))
		{
			do 
			{
				putc (c, stdout);
				c = getc (stdin);
			}
			while (isdigit (c) || (c == '.'));
			if ((c == 'x') || (c == 'X'))
			{
				do 
				{
					putc (c, stdout);
					c = getc (stdin);
				}
				while (isxdigit (c));
			}
			if ((c == 'e') || (c == 'E'))
			{
				putc (c, stdout);
				c = getc (stdin);
				if ((c == '+') || (c == '-'))
				{
					putc (c, stdout);
					c = getc (stdin);
				}
				while (isdigit (c))
				{
					putc (c, stdout);
					c = getc (stdin);
				}
			}
			continue;
		}
		if (isquote (c))
		{
			signed o;
			putc (c, stdout);
			o = getc (stdin);
			while (nomatch (o, c))
			{
				if ((char) (o) == '\\')
				{
					putc (o, stdout);
					o = getc (stdin);
				}
				putc (o, stdout);
				o = getc (stdin);
			}
			putc (c, stdout);
			c = getc (stdin);
			continue;
		}
		if (c == '/')
		{
			putc (c, stdout);
			c = getc (stdin);
			if (c == '/')
			{
				while (nobreak (c))
				{
					putc (c, stdout);
					c = getc (stdin);
				}
				putc ('\n', stdout);
				c = getc (stdin);
				continue;
			}
			if (c == '*')
			{
				while (nomatch (c, '/'))
				{
					while (nomatch (c, '*'))
					{
						putc (c, stdout);
						c = getc (stdin);
					}
					putc (c, stdout);
					c = getc (stdin);
				}
				putc ('/', stdout);
				c = getc (stdin);
				continue;
			}
			continue;
		}
		putc (c, stdout);
		c = getc (stdin);
	}
	return (count);
}
예제 #15
0
int main (int argc, char const * argv [])

{
	static char const * optv [] =
	{
		"write a message to the system logging facility",
		"[message]",
		"b:def:i:p:ns:t",
		"b s\tidentity is the basename of s ",
		"e\techo messages on stderr",
		"f s\tmessage filename",
		"i s\tidentity string",
		"p s\tpriority in facility.severity format",
		"n\tinclude PID number",
		"d\tuse datagrams",
		"s s\tsocket filename",
		"t\tsend test messages",
		(char const *) (0)
	};
	char message [TEXTLINE_MAX];
	char * bp = message;
	char const * socketname = (char *) (0);
	char const * identity = (char *) (0);
	int priority = SYSLOG_USER | SYSLOG_INFO;
	code_t sockettype = SOCK_STREAM;
	flag_t options = (flag_t) (0);
	file_t fd = (file_t) (-1);
	int c;
	while (~ (c = getoptv (argc, argv, optv)))
	{
		switch (c)
		{
		case 'b':
			for (identity = optarg; * optarg != (char) (0); optarg++)
			{
				if (* optarg == PATH_C_EXTENDER)
				{
					identity = optarg +  1;
				}
			}
			break;
		case 'd':
			sockettype = SOCK_DGRAM;
			break;
		case 'e':
			_setbits (options, SYSLOG_PERROR);
			break;
		case 'f':
			if (freopen (optarg, "rb", stdin) == (FILE *) (0))
			{
				error (1, errno, "%s", optarg);
			}
			break;
		case 'i':
			identity = optarg;
			break;
		case 'n':
			_setbits (options, SYSLOG_PROCESS);
			break;
		case 'p':
			priority = syslog_encode (optarg);
			break;
		case 's':
			socketname = optarg;
			break;
		case 't':
			mysyslogtest (priority);
			exit (0);
		default: 
			break;
		}
	}
	argc -= optind;
	argv += optind;
	fclose (stdout);
	if (socketname)
	{
		fd = myopenlog (socketname, sockettype);
	}
	else 
	{
		openlog (identity, options, priority);
	}
	if (! argc)
	{
		while ((c = getc (stdin)) != EOF)
		{
			if (nobreak (c))
			{
				if ((unsigned) (bp - message) < STRLEN (message))
				{
					* bp++ = c;
				}
			}
			else 
			{
				* bp = (char) (0);
				if (socketname)
				{
					mysyslog (fd, options, priority, identity, message);
				}
				else 
				{
					syslog (priority, "%s", message);
				}
				bp = message;
			}
		}
	}
	else 
	{
		for (bp = message; (argc) && (* argv); * bp++ = ' ')
		{
			char const * string;
			for (string = * argv; * string; string++)
			{
				if ((unsigned) (bp - message) < STRLEN (message))
				{
					* bp++ = * string;
				}
			}
			argc--;
			argv++;
		}
		if (bp > message)
		{
			bp--;
		}
		* bp = (char) (0);
		if (socketname)
		{
			mysyslog (fd, options, priority, identity, message);
		}
		else 
		{
			syslog (priority, "%s", message);
		}
	}
	if (socketname)
	{
		close (fd);
	}
	else 
	{
		closelog ();
	}
	exit (0);
}
예제 #16
0
TREE * define (TREE * tree) 

{
	char symbol [_MAXTOKEN];
	char string [_MAXTOKEN];
	char * sp,
	* cp;
	do 
	{
		c = getc (stdin);
	}
	while (isspace (c));
	for (sp = symbol; isalpha (c); c = getc (stdin)) 
	{
		* sp++ = c;
		* sp = (char) (0);
	}
	switch (svindex (symbol, sv_cproc, CPROC_O_NULL, strcmp)) 
	{
	case CPROC_O_DEFINE:
		while (isblank (c)) 
		{
			c = getc (stdin);
		}
		for (sp = symbol; isalnum (c) || (c == '_'); c = getc (stdin)) 
		{
			* sp++ = c;
		}
		* sp = (char) (0);
		while (isblank (c)) 
		{
			c = getc (stdin);
		}
		for (sp = cp = string; nobreak (c); c = getc (stdin)) 
		{
			* cp++ = c;
			if (!isblank (c)) 
			{
				sp = cp;
			}
		}
		* sp = (char) (0);
		tree = dictdefine (tree, symbol, string);
		break;
	case CPROC_O_UNDEF:
		while (isblank (c)) 
		{
			c = getc (stdin);
		}
		for (sp = symbol; isalnum (c) || (c == '_'); c = getc (stdin)) 
		{
			* sp++ = c;
		}
		* sp = (char) (0);
		tree = dictdefine (tree, symbol, string);
		break;
	default:
		break;
	}
	while (nobreak (c)) 
	{
		c = getc (stdin);
	}
	return (tree);
}
예제 #17
0
static void pibdump (struct _file_ const * file, char const * schema, unsigned extent, flag_t flags) 

{
	unsigned offset = 0;
	signed indent = 0;
	signed length = 0;
	unsigned lineno = 1;
	char symbol [0x0100];
	char string [0x0400];
	char * sp;
	signed c;
	output (indent++, "<%s xmlns:xsi='%s' xsi:noNamespaceSchemaLocation='%s'>", DATA_OBJECT, XML_NAMESPACE, schema);
	while ((c = getc (stdin)) != EOF) 
	{
		if ((c == '#') || (c == ';')) 
		{
			do 
			{
				c = getc (stdin);
			}
			while (nobreak (c));
		}
		if (isspace (c)) 
		{
			if (c == '\n') 
			{
				lineno++;
			}
			continue;
		}
		while (isdigit (c)) 
		{
			length *= 10;
			length += c - '0';
			c = getc (stdin);
		}
		while (isblank (c)) 
		{
			c = getc (stdin);
		}
		sp = symbol;
		if (isalpha (c) || (c == '_')) 
		{
			do 
			{
				*sp++ = (char)(c);
				c = getc (stdin);
			}
			while (isident (c));
		}
		*sp = (char)(0);
		while (isblank (c)) 
		{
			c = getc (stdin);
		}
		if (c == '[') 
		{

#if 0

			*sp++ = (char)(c);

#endif

			c = getc (stdin);
			while (isblank (c)) 
			{
				c = getc (stdin);
			}
			while (isdigit (c)) 
			{

#if 0

				*sp++ = (char)(c);

#endif

				c = getc (stdin);
			}
			while (isblank (c)) 
			{
				c = getc (stdin);
			}
			if (c != ']') 
			{
				error (1, EINVAL, "Have '%c' but need ']'", c);
			}

#if 0

			*sp++ = (char)(c);

#endif

			c = getc (stdin);
		}
		*sp = (char)(0);
		while (isblank (c)) 
		{
			c = getc (stdin);
		}
		sp = string;
		while (nobreak (c)) 
		{
			*sp++ = (char)(c);
			c = getc (stdin);
		}
		*sp = (char)(0);
		if (length > 0) 
		{

#if defined (WIN32)

			byte * buffer = (byte *)(emalloc (length));

#else

			byte buffer [length];

#endif

			if (read (file->file, buffer, length) == length) 
			{
				output (indent++, "<%s name='%s'>", DATA_MEMBER, symbol);

#if 0

				if (*string) 
				{
					output (indent++, "<text>");
					output (indent, "%s", string);
					output (indent--, "</text>");
				}

#endif

				output (indent++, "<%s>", DATA_OFFSET);
				output (indent, "%04X", offset);
				output (indent--, "</%s>", DATA_OFFSET);
				output (indent++, "<%s>", DATA_LENGTH);
				output (indent, "%d", length);
				output (indent--, "</%s>", DATA_LENGTH);
				output (indent++, "<%s>", DATA_MEMORY);
				for (c = 0; c < indent; c++) 
				{
					printf ("\t");
				}
				for (c = 0; c < length; c++) 
				{
					printf ("%02X", buffer [c]);
				}
				printf ("\n");
				output (indent--, "</%s>", DATA_MEMORY);
				output (indent--, "</%s>", DATA_MEMBER);
			}

#if defined (WIN32)

			free (buffer);

#endif

		}
		offset += length;
		length = 0;
	}
	output (indent--, "</%s>", DATA_OBJECT);
	if (_allclr (flags, PIB_SILENCE)) 
	{
		if (offset != extent) 
		{
			error (0, 0, "file %s is %d not %d bytes", file->name, extent, offset);
		}
	}
	return;
}
예제 #18
0
파일: z20.c 프로젝트: 5432935/crossbridge
void FlushGalley(OBJECT hd)
{ OBJECT dest;			/* the target galley hd empties into         */
  OBJECT dest_index;		/* the index of dest                         */
  OBJECT inners;		/* list of galleys and PRECEDES to flush     */
  OBJECT link, y;		/* for scanning through the components of hd */
  int dim;			/* direction of galley                       */
  CONSTRAINT dest_par_constr;	/* the parallel size constraint on dest      */
  CONSTRAINT dest_perp_constr;	/* the perpendicular size constraint on dest */
  int pb, pf, f;		/* candidate replacement sizes for dest      */

  OBJECT dest_encl;		/* the VCAT or ACAT enclosing dest, if any   */
  int    dest_side;		/* if dest_encl != nilobj, side dest is on   */
  BOOLEAN need_adjust;		/* TRUE as soon as dest_encl needs adjusting */
  FULL_LENGTH dest_back, dest_fwd; /* the current size of dest_encl or dest  */
  FULL_LENGTH frame_size;	/* the total constraint of dest_encl         */
  OBJECT prec_gap;		/* the gap preceding dest if any else nilobj */
  OBJECT prec_def;		/* the component preceding dest, if any      */
  OBJECT succ_gap;		/* the gap following dest if any else nilobj */
  OBJECT succ_def;		/* the component following dest, if any      */
  OBJECT stop_link;		/* most recently seen gap link of hd         */
  FULL_LENGTH stop_back;        /* back(dest_encl) incl all before stop_link */
  FULL_LENGTH stop_fwd;         /* fwd(dest_encl) incl. all before stop_link */
  FULL_LENGTH stop_perp_back;   /* back(dest_encl) in other direction        */
  FULL_LENGTH stop_perp_fwd;    /* fwd(dest_encl) in other direction         */
  BOOLEAN prnt_flush;		/* TRUE when the parent of hd needs a flush  */
  BOOLEAN target_is_internal;   /* TRUE if flushing into an internal target  */
  BOOLEAN headers_seen;		/* TRUE if a header is seen at all           */
  OBJECT zlink, z, tmp, prnt;  int attach_status;  BOOLEAN remove_target;
  OBJECT why;
  FULL_LENGTH perp_back, perp_fwd;  /* current perp size of dest_encl        */

  debug1(DGF, D, "[ FlushGalley %s (hd)", SymName(actual(hd)));
  prnt_flush = FALSE;
  dim = gall_dir(hd);

  RESUME:
  assert( type(hd) == HEAD, "FlushGalley: type(hd) != HEAD!" );
  debug1(DGF, D, "  resuming FlushGalley %s, hd =", SymName(actual(hd)));
  ifdebugcond(DGF, DD, actual(hd) == nilobj, DebugGalley(hd, nilobj, 4));
  assert( Up(hd) != hd, "FlushGalley: resume found no parent to hd!" );


  /*@@************************************************************************/
  /*                                                                         */
  /*  The first step is to examine the parent of galley hd to determine the  */
  /*  status of the galley.  If this is not suitable for flushing, we do     */
  /*  what we can to change the status.  If still no good, return; so if     */
  /*  this code does not return, then the galley is ready to flush into a    */
  /*  destination in the normal way, and the following variables are set:    */
  /*                                                                         */
  /*     dest_index   the parent of the galley and index of its destination  */
  /*     dest         the destination of the galley, a @Galley object        */
  /*                                                                         */
  /***************************************************************************/

  Parent(dest_index, Up(hd));
  switch( type(dest_index) )
  {

    case DEAD:
    
      /* the galley has been killed off while this process was sleeping */
      debug1(DGF, D, "] FlushGalley %s returning (DEAD)", SymName(actual(hd)));
      return;


    case UNATTACHED:
    
      /* the galley is currently not attached to a destination */
      attach_status = AttachGalley(hd, &inners, &y);
      debug1(DGF, DD, "  ex-AttachGalley inners: %s", DebugInnersNames(inners));
      Parent(dest_index, Up(hd));
      switch( attach_status )
      {

	case ATTACH_KILLED:

	  assert(inners==nilobj, "FlushGalley/ATTACH_KILLED: inners!=nilobj!");
	  debug1(DGF, D, "] FlushGalley %s returning (ATTACH_KILLED)",
	    SymName(actual(hd)));
	  debug1(DGF, D, "    prnt_flush = %s", bool(prnt_flush));
	  return;


	case ATTACH_INPUT:

	  ParentFlush(prnt_flush, dest_index, FALSE);
	  assert(inners==nilobj, "FlushGalley/ATTACH_INPUT: inners!=nilobj!");
	  debug1(DGF, D, "] FlushGalley %s returning (ATTACH_INPUT)",
	    SymName(actual(hd)));
	  return;


	case ATTACH_NOTARGET:

	  ParentFlush(prnt_flush, dest_index, FALSE);
	  assert(inners==nilobj, "FlushGalley/ATTACH_NOTARG: inners!=nilobj!");
	  debug1(DGF, D, "] FlushGalley %s returning (ATTACH_NOTARGET)",
	    SymName(actual(hd)));
	  return;


	case ATTACH_SUSPEND:

	  /* AttachGalley only returns inners here if they really need to */
	  /* be flushed; in particular the galley must be unsized before  */
	  if( inners != nilobj )
	  {
	    debug0(DGF, DD, "  calling FlushInners() from FlushGalley (a)");
	    FlushInners(inners, nilobj);
	    goto RESUME;
	  }
	  stop_link = nilobj;
	  goto SUSPEND;	/* nb y will be set by AttachGalley in this case */


	case ATTACH_NULL:

	  /* hd will have been linked to the unexpanded target in this case */
	  remove_target = (actual(actual(dest_index)) == whereto(hd));
          if( force_gall(hd) )
          {
            /* if hd is a forcing galley, close all predecessors */
	    debug3(DGA, D, "  forcing ATTACH_NULL case for %s into %s (%s)",
	      SymName(actual(hd)), SymName(whereto(hd)),
	      remove_target ? "remove_target" : "not remove_target");
	    Parent(prnt, Up(dest_index));
	    if( !non_blocking(dest_index) && remove_target )
	    {
	      /* ***
	      prnt_flush = TRUE;
	      *** */
	      prnt_flush = non_blocking(dest_index) = TRUE;
	    }
	    FreeGalley(prnt, Up(dest_index), &inners, Up(dest_index),
	      whereto(hd));
          }
          else
	  {
	    debug3(DGA, D, "  non-force ATTACH_NULL case for %s into %s (%s)",
	      SymName(actual(hd)), SymName(whereto(hd)),
	      remove_target ? "remove_target" : "not remove_target");
	    if( blocked(dest_index) && remove_target )  prnt_flush = TRUE;
	  }
	  DetachGalley(hd);
	  KillGalley(hd, TRUE);
          if( inners != nilobj )
	  {
	    debug0(DGF, DD, "  calling FlushInners() from FlushGalley (b)");
	    FlushInners(inners, nilobj);
	  }
	  else ParentFlush(prnt_flush, dest_index, remove_target);
	  debug0(DGF, D, "] FlushGalley returning ATTACH_NULL");
	  return;


	case ATTACH_ACCEPT:

          /* if hd is a forcing galley, or actual(dest_index) is   */
	  /* @ForceGalley, then close all predecessors             */
          if( force_gall(hd) || actual(actual(dest_index)) == ForceGalleySym )
          { Parent(prnt, Up(dest_index));
	    debug1(DGA, D, "  forcing ATTACH_ACCEPT case for %s",
	      SymName(actual(hd)));
	    /* debug0(DGA, DD, "  force: prnt ="); */
	    /* ifdebug(DGA, DD, DebugObject(prnt)); */
	    /* debug1(DGA, D,"  calling FreeGalley from FlushGalley(%s)", */
	    /*   SymName(actual(hd))); */
	    if( !non_blocking(dest_index) )  prnt_flush = TRUE; /* bug fix */
	    FreeGalley(prnt, Up(dest_index), &inners, Up(dest_index),
	      whereto(hd));
	    /* debug0(DGA, DD, "  force: after FreeGalley, prnt ="); */
	    /* ifdebug(DGA, DD, DebugObject(prnt)); */
          }
          else prnt_flush = prnt_flush || blocked(dest_index);
          debug1(DGF, DD, "    force: prnt_flush = %s", bool(prnt_flush));
          if( inners != nilobj )
	  {
	    debug0(DGF, DD, "  calling FlushInners() from FlushGalley (c)");
	    FlushInners(inners, nilobj);
	  }
          goto RESUME;


	default:

	  assert(FALSE, "FlushGalley: attach_status");
	  break;

      }
      break;


    case RECEIVING:
    
      if( actual(actual(dest_index)) == InputSym )
      { ParentFlush(prnt_flush, dest_index, FALSE);
	debug1(DGF, D, "] FlushGalley %s retn, input", SymName(actual(hd)));
	return;
      }
      break;


    default:
    
      assert1(FALSE, "FlushGalley: dest_index", Image(type(dest_index)));
      break;
  }
  dest = actual(dest_index);
  if( underline(dest) == UNDER_UNDEF )  underline(dest) = UNDER_OFF;
  target_is_internal =
    (dim==ROWM && !external_ver(dest)) || (dim==COLM && !external_hor(dest));
  headers_seen = FALSE;
  debug1(DGF, DD, "  dest_index: %s", EchoObject(dest_index));


  /*@@************************************************************************/
  /*                                                                         */
  /*  The second step is to examine the components of the galley one by one  */
  /*  to determine if they can be promoted.  Each component has the format   */
  /*                                                                         */
  /*    { <index> } <object>                                                 */
  /*                                                                         */
  /*  and is always followed by a gap object (except the last component).    */
  /*  An index indicates that the following object has some interesting      */
  /*  feature, and it points to that feature inside the object.  There are   */
  /*  two possible actions for each component, in addition to accepting it:  */
  /*                                                                         */
  /*    REJECT:   The component does not fit, so detach the galley           */
  /*    SUSPEND:  The component is incomplete; go to sleep and wait          */
  /*                                                                         */
  /***************************************************************************/

  stop_link = dest_encl = inners = nilobj;
  need_adjust = FALSE;

  /***************************************************************************/
  /*                                                                         */
  /*  Loop invariant                                                         */
  /*                                                                         */
  /*  The children of hd up to but not including Child(link) have been       */
  /*  examined and pronounced to be promotable, if unbreakable gaps are      */
  /*  ignored.  When unbreakable gaps are taken into account, the most       */
  /*  recent gap where a break is possible is at Child(stop_link), or        */
  /*  nowhere if stop_link == nilobj.                                        */
  /*                                                                         */
  /*  Case 1:  target_is_internal == FALSE                                   */
  /*                                                                         */
  /*  If this flag is FALSE, it means that the target of this galley is      */
  /*  external.  Consequently, there is no need to calculate sizes because   */
  /*  there is no constraint on them.  Also, a REJECT action is impossible   */
  /*  so unbreakable gaps are no impediment.  Variable dest_encl is nilobj.  */
  /*                                                                         */
  /*  Case 2:  target_is_internal == TRUE                                    */
  /*                                                                         */
  /*  If this flag is TRUE, it means that the target of this galley is       */
  /*  internal.  Consequently, sizes need to be calculated, and unbreakable  */
  /*  gaps need to be taken into account.  Variable dest_encl may be not     */
  /*  nilobj, in which case the following variables are defined:             */
  /*                                                                         */
  /*    dest_encl        the object enclosing dest (which must exist)        */
  /*    prec_gap         gap object preceding dest (which must exist)        */
  /*    prec_def         first definite object preceding dest (must exist)   */
  /*    dest_back        back(dest_encl) including effect of accepted compts */
  /*    dest_fwd         fwd(dest_encl) including effect of accepted compts  */
  /*    dest_side        BACK or FWD, i.e. which side of the mark dest is on */
  /*    dest_par_constr  the parallel size constraint on dest                */
  /*    dest_perp_constr the perpendicular size constraint on dest           */
  /*    frame_size       size of frame enclosing dest_encl                   */
  /*    perp_back        back(dest_encl) in other direction, incl accepteds  */
  /*    perp_fwd         fwd(dest_encl) in other direction,  incl accepteds  */
  /*                                                                         */
  /*  if dest_encl is nilobj, these variables are not defined.               */
  /*                                                                         */
  /*  If stop_link is non-nilobj, then in the internal case dest_encl must   */
  /*  be non-nilobj, and the following variables are defined:                */
  /*                                                                         */
  /*    stop_back        back(dest_encl) including all before stop_link      */
  /*    stop_fwd         fwd(dest_encl)  including all before stop_link      */
  /*    stop_perp_back   back(dest_encl) in other direction                  */
  /*    stop_perp_fwd    fwd(dest_encl) in other direction                   */
  /*                                                                         */
  /*  need_adjust is true if at least one definite component has been        */
  /*  accepted for promotion and the destination is internal; hence,         */
  /*  dest_encl is defined and its size needs to be adjusted.                */
  /*                                                                         */
  /*  inners is the set of all PRECEDES and UNATTACHED indexes found.        */
  /*                                                                         */
  /***************************************************************************/

  for( link = Down(hd);  link != hd;  link = NextDown(link) )
  {
    Child(y, link);
    if( type(y) == SPLIT )  Child(y, DownDim(y, dim));
    debug2(DGF, DD, "  examining %s %s", Image(type(y)), EchoObject(y));
    switch( type(y) )
    {

      case GAP_OBJ:

	underline(y) = underline(dest);
	prec_gap = y;
	if( target_is_internal )
	{
	  /* *** not necessarily true
	  assert( dest_encl != nilobj, "FlushGalley/GAP_OBJ: dest_encl!" );
	  *** */
	  if( dest_encl != nilobj && !nobreak(gap(prec_gap)) )
	  {
	    stop_link = link;
	    stop_back = dest_back;
	    stop_fwd  = dest_fwd;
	    stop_perp_back = perp_back;
	    stop_perp_fwd = perp_fwd;
	  }
	}
	else stop_link = link;
	if( !join(gap(y)) )  seen_nojoin(hd) = TRUE;
	break;


      case SCALE_IND:
      case COVER_IND:
      case EXPAND_IND:
      case GALL_PREC:
      case GALL_FOLL:
      case GALL_FOLL_OR_PREC:
      case GALL_TARG:
      case CROSS_PREC:
      case CROSS_FOLL:
      case CROSS_FOLL_OR_PREC:
      case CROSS_TARG:
      case PAGE_LABEL_IND:

	underline(y) = underline(dest);
	break;


      case PRECEDES:
      case UNATTACHED:
	  
	if( inners == nilobj )  New(inners, ACAT);
	Link(inners, y);
	break;


      case RECEIVING:
      case RECEPTIVE:
	  
	goto SUSPEND;


      case FOLLOWS:
	  
	Child(tmp, Down(y));
	if( Up(tmp) == LastUp(tmp) )
	{ link = PrevDown(link);
	  DisposeChild(NextDown(link));
	  break;
	}
	Parent(tmp, Up(tmp));
	assert(type(tmp) == PRECEDES, "Flush: PRECEDES!");
	switch( CheckComponentOrder(tmp, dest_index) )
	{
	  case CLEAR:	DeleteNode(tmp);
			link = PrevDown(link);
			DisposeChild(NextDown(link));
			break;

	  case PROMOTE:	break;

	  case BLOCK:	goto SUSPEND;

	  case CLOSE:	if( opt_components(hd) != nilobj )
			{ DisposeObject(opt_components(hd));
			  opt_components(hd) = nilobj;
			  debug2(DOG, D, "FlushGalley(%s) de-optimizing %s",
			    "(CLOSE problem)", SymName(actual(hd)));
			}
			debug1(DGF, DD, "  reject (a) %s", EchoObject(y));
			goto REJECT;
	}
	break;


      case BEGIN_HEADER:
      case END_HEADER:
      case SET_HEADER:
      case CLEAR_HEADER:

	/* do nothing except take note, until actually promoted out of here */
	headers_seen = TRUE;
	break;


      case NULL_CLOS:
      case PAGE_LABEL:
      case WORD:
      case QWORD:
      case ONE_COL:
      case ONE_ROW:
      case WIDE:
      case HIGH:
      case HSHIFT:
      case VSHIFT:
      case HSCALE:
      case VSCALE:
      case HCOVER:
      case VCOVER:
      case HCONTRACT:
      case VCONTRACT:
      case HLIMITED:
      case VLIMITED:
      case HEXPAND:
      case VEXPAND:
      case START_HVSPAN:
      case START_HSPAN:
      case START_VSPAN:
      case HSPAN:
      case VSPAN:
      case ROTATE:
      case BACKGROUND:
      case SCALE:
      case KERN_SHRINK:
      case INCGRAPHIC:
      case SINCGRAPHIC:
      case PLAIN_GRAPHIC:
      case GRAPHIC:
      case LINK_SOURCE:
      case LINK_DEST:
      case ACAT:
      case HCAT:
      case VCAT:
      case ROW_THR:
      case CLOSURE:
      case CROSS:
      case FORCE_CROSS:

	underline(y) = underline(dest);
	if( dim == ROWM )
	{
	  /* make sure y is not joined to a target below (vertical case only) */
	  for( zlink = NextDown(link); zlink != hd; zlink = NextDown(zlink) )
	  { Child(z, zlink);
	    switch( type(z) )
	    {
	      case RECEPTIVE:
	      case RECEIVING:	y = z;
				goto SUSPEND;

	      case GAP_OBJ:	if( !join(gap(z)) )  zlink = PrevDown(hd);
				break;

	      default:		break;
	    }
	  }

	  /* try vertical hyphenation before anything else */
	  if( type(y) == HCAT )  VerticalHyphenate(y);

	}

	/* check size constraint */
	if( target_is_internal )
	{
	  /* initialise dest_encl etc if not done yet */
	  if( dest_encl == nilobj )
	  { assert( UpDim(dest,1-dim) == UpDim(dest,dim), "FlushG: UpDims!" );
	    /* *** weird old code, trying for UpDim(dest, ROWM)?
	    Parent(dest_encl, NextDown(Up(dest)));
	    *** */
	    Parent(dest_encl, Up(dest));
	    debug4(DGF, DD, "  flush dest = %s %s, dest_encl = %s %s",
	      Image(type(dest)), EchoObject(dest),
	      Image(type(dest_encl)), EchoObject(dest_encl));
	    assert( (dim==ROWM && type(dest_encl)==VCAT) ||
	            (dim==COLM && type(dest_encl)==ACAT),
	      "FlushGalley: dest != VCAT or ACAT!" );
	    SetNeighbours(Up(dest), FALSE, &prec_gap, &prec_def,
	      &succ_gap, &succ_def, &dest_side);
	    assert(prec_gap != nilobj || is_indefinite(type(y)),
	      "FlushGalley: prec_gap == nilobj && !is_indefinite(type(y))!" );
	    assert(succ_gap == nilobj, "FlushGalley: succ_gap != nilobj!" );
	    assert(dest_side == FWD || is_indefinite(type(y)),
	      "FlushGalley: dest_side != FWD || !is_indefinite(type(y))!");
	    dest_back = back(dest_encl, dim);
	    dest_fwd  = fwd(dest_encl, dim);
	    perp_back = back(dest_encl, 1-dim);
	    perp_fwd  = fwd(dest_encl, 1-dim);
	    Constrained(dest_encl, &dest_par_constr, dim, &why);
	    Constrained(dest_encl, &dest_perp_constr, 1-dim, &why);
	    debug1(DGF, DD, "  setting dest_perp_constr = %s",
	      EchoConstraint(&dest_perp_constr));
	    frame_size = constrained(dest_par_constr) ? bfc(dest_par_constr) :0;
	  }

	  if( !is_indefinite(type(y)) )
	  {
	    ifdebugcond(DGF, DD,  mode(gap(prec_gap)) == NO_MODE,
	      DebugGalley(hd, y, 4));

	    /* calculate parallel effect of adding y to dest */
	    f = dest_fwd  + fwd(y, dim) - fwd(prec_def, dim) +
		  ActualGap(fwd(prec_def, dim), back(y, dim),
			fwd(y, dim), &gap(prec_gap), frame_size,
			dest_back + dest_fwd - fwd(prec_def, dim));
	    debug5(DGF, DD, "  f = %s + %s - %s + %s (prec_gap %s)",
	      EchoLength(dest_fwd), EchoLength(fwd(y, dim)),
	      EchoLength(fwd(prec_def, dim)), EchoLength(
		  ActualGap(fwd(prec_def, dim), back(y, dim),
			fwd(y, dim), &gap(prec_gap), frame_size,
			dest_back + dest_fwd - fwd(prec_def, dim))
	      ), EchoGap(&gap(prec_gap)));
	    debug3(DGF, DD, "  b,f: %s,%s;   dest_encl: %s",
			EchoLength(dest_back), EchoLength(f),
			EchoConstraint(&dest_par_constr));

	    /* check new size against parallel constraint */
	    if( (units(gap(prec_gap))==FRAME_UNIT && width(gap(prec_gap)) > FR)
	        || !FitsConstraint(dest_back, f, dest_par_constr)
		|| (opt_components(hd) != nilobj && opt_comps_permitted(hd)<=0)
	      )
	    {
	      if( opt_components(hd) != nilobj )
	      { OBJECT z;

		/* record the size of this just-completed target area for hd */
		New(z, WIDE);
		CopyConstraint(constraint(z), dest_par_constr);
		Link(opt_constraints(hd), z);
		ifdebug(DOG, D,
		  debug2(DOG, D, "FlushGalley(%s) adding constraint %s",
		    SymName(actual(hd)), EchoConstraint(&constraint(z)));
		  if( units(gap(prec_gap))==FRAME_UNIT &&
		      width(gap(prec_gap)) > FR ) 
		  { debug1(DOG, D, "  prec_gap = %s", EchoGap(&gap(prec_gap)));
		  }
		  if( !FitsConstraint(dest_back, f, dest_par_constr) )
		  { debug3(DOG, D, "  !FitsConstraint(%s, %s, %s)",
		      EchoLength(dest_back), EchoLength(f),
		      EchoConstraint(&dest_par_constr));
		  }
		  if( opt_comps_permitted(hd) <= 0 )
		  { debug1(DOG, D, "  opt_comps_permitted = %2d",
		      opt_comps_permitted(hd));
		  }
		  debug4(DOG, D, "prec_gap = %s;  y = %s (%s,%s):",
		    EchoGap(&gap(prec_gap)), Image(type(y)),
		    EchoLength(back(y, dim)), EchoLength(fwd(y, dim)));
		  DebugObject(y);
		)

		/* refresh the number of components permitted into the next target */
		if( opt_counts(hd) != nilobj && Down(opt_counts(hd)) != opt_counts(hd) )
		{ Child(z, Down(opt_counts(hd)));
		  opt_comps_permitted(hd) += comp_count(z) - 1;
		  DisposeChild(Up(z));
		}
		else opt_comps_permitted(hd) = MAX_FILES;  /* a large number */
		debug1(DOG, D, "  REJECT permitted = %2d", opt_comps_permitted(hd));
	      }
	      debug1(DGF, DD, "  reject (b) %s", EchoObject(y));
	      goto REJECT;
	    }

	    /* calculate perpendicular effect of adding y to dest */
	    if( seen_nojoin(hd) )
	    {
	      pb = 0;
	      pf = find_max(perp_fwd,  size(y, 1-dim));
	    }
	    else
	    {
	      pb = find_max(perp_back, back(y, 1-dim));
	      pf = find_max(perp_fwd,  fwd(y,  1-dim));
	    }

	    /* check new size against perpendicular constraint */
	    if( !FitsConstraint(pb, pf, dest_perp_constr) )
	    {
	      if( opt_components(hd) != nilobj )
	      { DisposeObject(opt_components(hd));
		opt_components(hd) = nilobj;
		debug1(DOG, D, "FlushGalley(%s) de-optimizing (perp problem)",
		  SymName(actual(hd)));
	      }
	      if( dim == ROWM )
	      {
		Error(20, 3, "component too wide for available space",
		  WARN, &fpos(y));
		debug6(DGF, DD, "  %s,%s [%s,%s] too wide for %s, y = %s",
		  EchoLength(pb), EchoLength(pf),
		  EchoLength(back(y, 1-dim)), EchoLength(fwd(y, 1-dim)),
		  EchoConstraint(&dest_perp_constr), EchoObject(y));
	      }
	      debug1(DGF, DD, "  reject (c) %s", EchoObject(y));
	      goto REJECT;
	    }

	    /* accept definite component */
	    dest_fwd = f;  prec_def = y;
	    perp_back = pb;  perp_fwd = pf;
	    need_adjust = TRUE;
	    if( opt_components(hd) != nilobj )
	    { opt_comps_permitted(hd)--;
	      debug1(DOG, D, "  ACCEPT permitted = %2d", opt_comps_permitted(hd));
	    }
	  }
	  /* accept indefinite component */
	} /* end if( target_is_internal ) */
예제 #19
0
파일: delta.c 프로젝트: wol22/MotleyTools
static void function (char const * file, unsigned width, flag_t flags) 

{ 
	char number [width + 1]; 
	unsigned prior = 0; 
	unsigned value = 0; 
	unsigned count = 0; 
	unsigned line = 1; 
	signed c = getc (stdin); 
	while (c != EOF) 
	{ 
		while (isspace (c)) 
		{ 
			if (c == '\n') 
			{ 
				line++; 
			} 
			c = getc (stdin); 
			continue; 
		} 
		if ((c == '#') || (c == ';')) 
		{ 
			do 
			{ 
				c = getc (stdin); 
			} 
			while (nobreak (c)); 
			continue; 
		} 
		if (!isdigit (c)) 
		{ 
			c = getc (stdin); 
			continue; 
		} 
		value = 0; 
		while (isdigit (c)) 
		{ 
			value *= 10; 
			value += c - '0'; 
			c = getc (stdin); 
		} 
		if (value < prior) 
		{ 
			error_on_line (1, ENOTSUP, file, line, "%d less than %d", value, prior); 
		} 
		if (count) 
		{ 
			unsigned digit = width; 
			unsigned delta = value - prior; 
			number [digit] = (char)(0); 
			while (digit) 
			{ 
				number [-- digit] = DIGITS_DEC [delta % 10]; 
				delta /= 10; 
			} 
			while (digit < width) 
			{ 
				putc (number [digit++], stdout); 
			} 
			putc ('\n', stdout); 
		} 
		prior = value; 
		count++; 
	} 
	return; 
} 
예제 #20
0
파일: cinc.c 프로젝트: wol22/MotleyTools
void function (char * fullpath, char const * vector []) 

{ 
	FILE * fp; 
	char buffer [CSOURCE]; 
	char * sp; 
	char * cp; 
	signed c; 
	if ((fp = efopen (fullpath, "rb"))) 
	{ 
		char pathname [FILENAME_MAX]; 
		for (sp = cp = strcpy (pathname, fullpath); * cp; ++ cp) 
		{ 
			if (* cp == '/') 
			{ 
				sp = cp; 
			} 
		} 
		* sp = (char)(0); 
		c = getc (fp); 
		while (c != EOF) 
		{ 
			sp = buffer; 
			if (isspace (c)) 
			{ 
				do 
				{ 
					putc (c, stdout); 
					c = getc (fp); 
				} 
				while (isspace (c)); 
				continue; 
			} 
			if (isalpha (c)) 
			{ 
				do 
				{ 
					putc (c, stdout); 
					c = getc (fp); 
				} 
				while (isalnum (c)); 
				continue; 
			} 
			if (isdigit (c)) 
			{ 
				do 
				{ 
					putc (c, stdout); 
					c = getc (fp); 
				} 
				while (isdigit (c)); 
				continue; 
			} 
			if (c == '#') 
			{ 
				* sp++ = (char)(c); 
				c = getc (fp); 
				while (isblank (c)) 
				{ 
					* sp++ = (char)(c); 
					c = getc (fp); 
				} 
				cp = sp; 
				while (isalpha (c)) 
				{ 
					* sp++ = (char) (c); 
					c = getc (fp); 
				} 
				* sp = (char)(0); 
				if (strcmp ("include", cp)) 
				{ 
					while (nobreak (c)) 
					{ 
						* sp++ = (char) (c); 
						c = getc (fp); 
					} 
					* sp++ = (char)(c); 
					for (cp = buffer; cp < sp; putc (* cp++, stdout)); 
					c = getc (fp); 
					continue; 
				} 
				while (isblank (c)) 
				{ 
					* sp++ = (char) (c); 
					c = getc (fp); 
				} 
				if (c == '\"') 
				{ 
					size_t index; 
					char filename [FILENAME_MAX]; 
					cp = filename; 
					c = getc (fp); 
					while ((c != '\"') && (c != EOF)) 
					{ 
						* cp++ = * sp++ = (char) (c); 
						c = getc (fp); 
					} 
					* cp = (char) (0); 
					makepath (fullpath, pathname, filename); 
					for (index = 0; vector [index] != (char *)(0); index++) 
					{ 
						if (!strcmp (fullpath, vector [index])) 
						{ 
							break; 
						} 
					} 
					if (vector [index] == (char *)(0)) 
					{ 
						vector [index++] = strdup (fullpath); 
						vector [index] = (char *)(0); 
						function (fullpath, vector); 
					} 
					while (nobreak (c)) 
					{ 
						* sp++ = (char) (c); 
						c = getc (fp); 
					} 
					* sp++ = (char) (c); 
				} 
				else 
				{ 
					while (nobreak (c)) 
					{ 
						* sp++ = (char) (c); 
						c = getc (fp); 
					} 
					* sp++ = (char) (c); 
					for (cp = buffer; cp < sp; putc (* cp++, stdout)); 
				} 
				c = getc (fp); 
				continue; 
			} 
			if (isquote (c)) 
			{ 
				signed o = getc (fp); 
				putc (c, stdout); 
				while ((o != c) && (c != EOF)) 
				{ 
					if (o == '\\') 
					{ 
						putc (o, stdout); 
						o = getc (fp); 
					} 
					putc (o, stdout); 
					o = getc (fp); 
				} 
				putc (c, stdout); 
				c = getc (fp); 
				continue; 
			} 
			if (c == '/') 
			{ 
				putc (c, stdout); 
				c = getc (fp); 
				if (c == '/') 
				{ 
					while (nobreak (c)) 
					{ 
						putc (c, stdout); 
						c = getc (fp); 
					} 
					putc ('\n', stdout); 
					c = getc (fp); 
					continue; 
				} 
				if (c == '*') 
				{ 
					while (nomatch (c, '/')) 
					{ 
						while (nomatch (c, '*')) 
						{ 
							putc (c, stdout); 
							c = getc (fp); 
						} 
						putc (c, stdout); 
						c = getc (fp); 
					} 
					putc ('/', stdout); 
					c = getc (fp); 
					continue; 
				} 
				putc (c, stdout); 
				c = getc (fp); 
				continue; 
			} 
			putc (c, stdout); 
			c = getc (fp); 
		} 
		fclose (fp); 
	} 
	return; 
} 
예제 #21
0
signed getargv (signed argc, char const * argv [])

{
	extern char const * program_name;
	static char string [1024];
	char const ** argp = argv;
	char * sp = string;
	signed c = getc (stdin);
	memset (string, 0, sizeof (string));
	memset ((char **)(argv), 0, argc * sizeof (char const *));
	while (nobreak (c))
	{
		if (isspace (c))
		{
			do
			{
				c = getc (stdin);
			}
			while (isspace (c));
		}
		if (c == '#')
		{
			do
			{
				c = getc (stdin);
			}
			while (nobreak (c));
			c = getc (stdin);
			continue;
		}
		*argp++ = program_name;
		*argp++ = sp = string;
		while (nobreak (c))
		{
			if (c == '#')
			{
				do
				{
					c = getc (stdin);
				}
				while (nobreak (c));
				break;
			}
			if (isblank (c))
			{
				c = (char)(0);
				*argp = sp + 1;
			}
			else if (sp == *argp)
			{
				if ((signed)(argp - argv) < argc)
				{
					argp++;
				}
			}
			*sp++ = (char)(c);
			c = getc (stdin);
		}
		*argp = (char const *)(0);
		*sp = (char)(0);
	}
	return ((unsigned)(argp - argv));
}
예제 #22
0
파일: offset.c 프로젝트: wol22/MotleyTools
static void fold (flag_t flags) 

{ 
	unsigned offset = 0; 
	unsigned extent = 0; 
	unsigned length = 0; 
	signed c = getc (stdin); 
	while (c != EOF) 
	{ 
		while (isspace (c)) 
		{ 
			c = getc (stdin); 
		} 
		if (c == '+') 
		{ 
			do 
			{ 
				c = getc (stdin); 
			} 
			while (isblank (c)); 
			while (isdigit (c)) 
			{ 
				length *= 10; 
				length += c - '0'; 
				c = getc (stdin); 
			} 
			if (extent) 
			{ 
				printf ("0%d RSVD\n", extent); 
				extent = 0; 
			} 
			printf ("%4d", length); 
			while (nobreak (c)) 
			{ 
				putc (c, stdout); 
				c = getc (stdin); 
			} 
			putc ('\n', stdout); 
			offset += length; 
			length = 0; 
			continue; 
		} 
		if (isdigit (c)) 
		{ 
			while (isdigit (c)) 
			{ 
				length *= 10; 
				length += c - '0'; 
				c = getc (stdin); 
			} 
			if (!length) 
			{ 
				if (_anyset (flags, OFFSET_HOLE)) 
				{ 
					if (extent) 
					{ 
						printf ("0%d RSVD\n", extent); 
						extent = 0; 
					} 
					if (offset) 
					{ 
						putc ('\n', stdout); 
					} 
					printf ("%4d", length); 
					while (nobreak (c)) 
					{ 
						putc (c, stdout); 
						c = getc (stdin); 
					} 
					putc ('\n', stdout); 
					continue; 
				} 
			} 
			while (nobreak (c)) 
			{ 
				c = getc (stdin); 
			} 
			extent += length; 
			offset += length; 
			length = 0; 
			continue; 
		} 
		while (nobreak (c)) 
		{ 
			putc (c, stdout); 
			c = getc (stdin); 
		} 
	} 
	if (extent) 
	{ 
		printf ("0%d RSVD\n", extent); 
		extent = 0; 
	} 
	return; 
} 
예제 #23
0
파일: psin.c 프로젝트: I2SE/open-plc-utils
static signed psin (struct _file_ * pib)

{
	unsigned index = 0;
	unsigned count = 0;
	unsigned limit = pibscalers (pib);
	uint32_t value = 0;
	signed c;
	if ((limit != INT_CARRIERS) && (limit != AMP_CARRIERS) && (limit != PLC_CARRIERS))
	{
		error (1, 0, "Don't understand this PIB's prescaler format");
	}
	if (limit == INT_CARRIERS)
	{
		if (lseek (pib->file, INT_PRESCALER_OFFSET, SEEK_SET) != INT_PRESCALER_OFFSET)
		{
			error (1, errno, FILE_CANTSEEK, pib->name);
		}
	}
	else if (limit == PLC_CARRIERS)
	{
		if (lseek (pib->file, QCA_PRESCALER_OFFSET, SEEK_SET) != QCA_PRESCALER_OFFSET)
		{
			error (1, errno, FILE_CANTSEEK, pib->name);
		}
	}
	while ((c = getc (stdin)) != EOF)
	{
		if (isspace (c))
		{
			continue;
		}
		if ((c == '#') || (c == ';'))
		{
			do
			{
				c = getc (stdin);
			}
			while (nobreak (c));
			continue;
		}
		index = 0;
		while (isdigit (c))
		{
			index *= 10;
			index += c - '0';
			c = getc (stdin);
		}
		if (index != count)
		{
			error (1, ECANCELED, "Carrier %d out of order", index);
		}
		if (index >= limit)
		{
			error (1, EOVERFLOW, "Too many prescalers");
		}
		while (isblank (c))
		{
			c = getc (stdin);
		}
		value = 0;
		while (isxdigit (c))
		{
			value *= 16;
			value += todigit (c);
			c = getc (stdin);
		}
		if (limit == INT_CARRIERS)
		{
			value = HTOLE32 (value);
			if (write (pib->file, &value, sizeof (value)) != sizeof (value))
			{
				error (1, errno, "Can't save %s", pib->name);
			}
		}
		else if (limit == AMP_CARRIERS)
		{
			if (value & ~0x03FF)
			{
				error (1, errno, "Position %d has invalid prescaler value", index);
			}
			if (ar7x00_psin (pib, value, index))
			{
				error (1, errno, "Can't update %s", pib->name);
			}
		}
		else if (limit == PLC_CARRIERS)
		{
			uint8_t tmp = value & 0xff;
			if (write (pib->file, &tmp, sizeof (tmp)) != sizeof (tmp))
			{
				error (1, errno, "Can't save %s", pib->name);
			}
		}

		while (nobreak (c))
		{
			c = getc (stdin);
		};
		count++;
	}
	return (0);
}
예제 #24
0
size_t hexload (void * memory, size_t extent, FILE * fp) 

{
	extern unsigned row;
	extern unsigned col;
	byte * origin = (uint8_t *)(memory);
	byte * offset = (uint8_t *)(memory);
	unsigned digits = sizeof (* offset) << 1;
	unsigned digit = 0;
	signed c = EOF;
	while ((extent) && ((c = fpgetc (fp)) != EOF) && (c != ';')) 
	{
		if (isspace (c)) 
		{
			continue;
		}
		if (c == '#') 
		{
			do 
			{
				c = fpgetc (fp);
			}
			while (nobreak (c));
			continue;
		}
		if (c == '/') 
		{
			c = fpgetc (fp);
			if (c == '/') 
			{
				do 
				{
					c = fpgetc (fp);
				}
				while (nobreak (c));
				continue;
			}
			if (c == '*') 
			{
				while ((c != '/') && (c != EOF)) 
				{
					while ((c != '*') && (c != EOF)) 
					{
						c = fpgetc (fp);
					}
					c = fpgetc (fp);
				}
				continue;
			}
			continue;
		}
		if ((c >= '0') && (c <= '9')) 
		{
			*offset *= 16;
			*offset += c - '0';
			if (!(++digit % digits)) 
			{
				offset++;
				extent--;
			}
			continue;
		}
		if ((c >= 'A') && (c <= 'F')) 
		{
			*offset *= 16;
			*offset += 10;
			*offset += c - 'A';
			if (!(++digit % digits)) 
			{
				offset++;
				extent--;
			}
			continue;
		}
		if ((c >= 'a') && (c <= 'f')) 
		{
			*offset *= 16;
			*offset += 10;
			*offset += c - 'a';
			if (!(++digit % digits)) 
			{
				offset++;
				extent--;
			}
			continue;
		}

#if 1

		error (1, ENOTSUP, "Unexpected character '%c': row %d: col %d", c, row, col);

#else

		return ((size_t)(-1));

#endif

	}
	if (digit & 1) 
	{

#if 1

		error (1, ENOTSUP, "Odd digit count (%d) in source", digit);

#else

		return ((size_t)(-1));

#endif

	}
	return (offset - origin);
}
예제 #25
0
static void function (char const * string, char const * comma, size_t column, flag_t flags)

{
	unsigned margin = 2;
	unsigned row;
	unsigned col;
	signed c;
	char field [_LINESIZE];
	char * cp;
	char * sp;
	if (_anyset (flags, CSV2HTML_PAGE))
	{
		margin = header (0, string);
	}
	indent (margin++, "<h1>");
	indent (margin, "%s", string);
	indent (margin--, "</h1>");
	indent (margin++, "<table class='box'>");
	for (row = 0; (c = getc (stdin)) != EOF; row++)
	{
		while (isspace (c))
		{
			c = getc (stdin);
		}
		if (c == '#')
		{
			do 
			{
				c = getc (stdin);
			}
			while (nobreak (c));
			continue;
		}
		indent (margin++, "<tr>");
		for (col = 0; nobreak (c); col++)
		{
			sp = cp = field;
			while (nobreak (c))
			{
				if (c == comma [0])
				{
					c = getc (stdin);
					break;
				}
				if (c == '\\')
				{
					c = getc (stdin);
					if (c != EOF)
					{
						* cp++ = (char) (c);
						c = getc (stdin);
						sp = cp;
					}
					continue;
				}
				if (c == '\\')
				{
					c = getc (stdin);
				}
				if ((c < 0x20) || (c > 0x7E))
				{
					c = ' ';
				}
				if (c == comma [1])
				{
					* cp++ = '<';
					* cp++ = 'b';
					* cp++ = 'r';
					* cp++ = '/';
					* cp++ = '>';
					c = getc (stdin);
				}
				* cp++ = (char) (c);
				if (c != ' ')
				{
					sp = cp;
				}
				c = getc (stdin);
			}
			* sp = (char) (0);
			if (sp == field)
			{
				strcpy (field, "&nbsp;");
			}
			if (! row)
			{
				indent (margin++, "<th class='%s'>", STYLE);
				indent (margin, "%s", field);
				indent (margin--, "</th>");
			}
			else 
			{
				indent (margin++, "<td class='%s'>", STYLE);
				indent (margin, "%s", field);
				indent (margin--, "</td>");
			}
			while (isblank (c))
			{
				c = getc (stdin);
			}
		}
		while (col++ < column)
		{
			if (! row)
			{
				indent (margin++, "<th class='%s'>", STYLE);
				indent (margin, "Column%d", col);
				indent (margin--, "</th>");
			}
			else 
			{
				indent (margin++, "<td class='%s'>", STYLE);
				indent (margin, "&nbsp;");
				indent (margin--, "</td>");
			}
		}
		indent (margin--, "</tr>");
	}
	indent (margin--, "</table>");
	if (_anyset (flags, CSV2HTML_PAGE))
	{
		margin = footer (margin, string);
	}
	return;
}