Annotation of 43BSD/contrib/X/Xlib/XParseGeom.c, revision 1.1

1.1     ! root        1: #include <X/mit-copyright.h>
        !             2: 
        !             3: /* Copyright   Massachusetts Institute of Technology  1985 */
        !             4: /* $Header: XParseGeom.c,v 10.9 86/02/01 15:37:45 tony Rel $ */
        !             5: #include "XlibInternal.h"
        !             6: 
        !             7: /* 
        !             8:  *Returns pointer to first char ins search which is also in what, else NULL.
        !             9:  */
        !            10: static char *strscan (search, what)
        !            11: char *search, *what;
        !            12: {
        !            13:        int i, len = strlen (what);
        !            14:        char c;
        !            15: 
        !            16:        while ((c = *(search++)) != NULL)
        !            17:        for (i = 0; i < len; i++)
        !            18:        if (c == what [i]) return (--search);
        !            19:        return (NULL);
        !            20: }
        !            21: 
        !            22: /*
        !            23:  *    XParseGeometry parses strings of the form
        !            24:  *   "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
        !            25:  *   width, height, xoffset, and yoffset are unsigned integers.
        !            26:  *   Example:  "=80x24+300-49"
        !            27:  *   The equal sign is optional.
        !            28:  *   It returns a bitmask that indicates which of the four values
        !            29:  *   were actually found in the string.  For each value found,
        !            30:  *   the corresponding argument is updated;  for each value
        !            31:  *   not found, the corresponding argument is left unchanged. 
        !            32:  */
        !            33: 
        !            34: int XParseGeometry (string, x, y, width, height)
        !            35: char *string;
        !            36: int *x, *y, *width, *height;    /* RETURN */
        !            37: {
        !            38:        int mask = NoValue;
        !            39:        char *strind;
        !            40:        char *index();
        !            41: 
        !            42:        if ( (string == NULL) || (*string == '\0')) return(mask);
        !            43:        if (*string == '=')
        !            44:        string++;  /* ignore possible '=' at beginning of geometry spec */
        !            45: 
        !            46:        strind = string;
        !            47:        if (*strind != '+' && *strind != '-' && *strind != 'x') {
        !            48:                *width = atoi (strind);
        !            49:                mask |= WidthValue;
        !            50:        }
        !            51: 
        !            52:        if (strind = index (string, 'x')) {
        !            53:                *height = atoi (++strind);
        !            54:                mask |= HeightValue;
        !            55:        }
        !            56:        else strind = string;
        !            57: 
        !            58:        if (strind = strscan (strind, "+-")) {
        !            59:                if (*strind == '-') mask |= XNegative;
        !            60:                *x = atoi (strind++);
        !            61:                mask |= XValue;
        !            62:                if (strind = strscan (strind, "+-")) {
        !            63:                        if (*strind == '-') mask |= YNegative;
        !            64:                        *y = atoi (strind);
        !            65:                        mask |= YValue;
        !            66:                }
        !            67:        }
        !            68:        return (mask);
        !            69: }
        !            70: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.