|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T X
Length: 1810 (0x712)
Types: TextFile
Names: »XParseGeom.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
└─⟦526ad3590⟧ »EUUGD11/gnu-31mar87/X.V10.R4.tar.Z«
└─⟦2109abc41⟧
└─⟦this⟧ »./X.V10R4/Xlib/XParseGeom.c«
#include <X/mit-copyright.h>
/* Copyright Massachusetts Institute of Technology 1985 */
/* $Header: XParseGeom.c,v 10.9 86/02/01 15:37:45 tony Rel $ */
#include "XlibInternal.h"
/*
*Returns pointer to first char ins search which is also in what, else NULL.
*/
static char *strscan (search, what)
char *search, *what;
{
int i, len = strlen (what);
char c;
while ((c = *(search++)) != NULL)
for (i = 0; i < len; i++)
if (c == what [i]) return (--search);
return (NULL);
}
/*
* XParseGeometry parses strings of the form
* "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
* width, height, xoffset, and yoffset are unsigned integers.
* Example: "=80x24+300-49"
* The equal sign is optional.
* It returns a bitmask that indicates which of the four values
* were actually found in the string. For each value found,
* the corresponding argument is updated; for each value
* not found, the corresponding argument is left unchanged.
*/
int XParseGeometry (string, x, y, width, height)
char *string;
int *x, *y, *width, *height; /* RETURN */
{
int mask = NoValue;
char *strind;
char *index();
if ( (string == NULL) || (*string == '\0')) return(mask);
if (*string == '=')
string++; /* ignore possible '=' at beginning of geometry spec */
strind = string;
if (*strind != '+' && *strind != '-' && *strind != 'x') {
*width = atoi (strind);
mask |= WidthValue;
}
if (strind = index (string, 'x')) {
*height = atoi (++strind);
mask |= HeightValue;
}
else strind = string;
if (strind = strscan (strind, "+-")) {
if (*strind == '-') mask |= XNegative;
*x = atoi (strind++);
mask |= XValue;
if (strind = strscan (strind, "+-")) {
if (*strind == '-') mask |= YNegative;
*y = atoi (strind);
mask |= YValue;
}
}
return (mask);
}