URI:
       twinsize.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       twinsize.c (1290B)
       ---
            1 #include <u.h>
            2 #include <libc.h>
            3 #include <draw.h>
            4 #include <memdraw.h>
            5 #include <memlayer.h>
            6 #include <mouse.h>
            7 #include <cursor.h>
            8 #include <keyboard.h>
            9 #include <drawfcall.h>
           10 #include "devdraw.h"
           11 
           12 int
           13 parsewinsize(char *s, Rectangle *r, int *havemin)
           14 {
           15         char c, *os;
           16         int i, j, k, l;
           17 
           18         os = s;
           19         *havemin = 0;
           20         *r = Rect(0,0,0,0);
           21         if(!isdigit((uchar)*s))
           22                 goto oops;
           23         i = strtol(s, &s, 0);
           24         if(*s == 'x'){
           25                 s++;
           26                 if(!isdigit((uchar)*s))
           27                         goto oops;
           28                 j = strtol(s, &s, 0);
           29                 r->max.x = i;
           30                 r->max.y = j;
           31                 if(*s == 0)
           32                         return 0;
           33                 if(*s != '@')
           34                         goto oops;
           35 
           36                 s++;
           37                 if(!isdigit((uchar)*s))
           38                         goto oops;
           39                 i = strtol(s, &s, 0);
           40                 if(*s != ',' && *s != ' ')
           41                         goto oops;
           42                 s++;
           43                 if(!isdigit((uchar)*s))
           44                         goto oops;
           45                 j = strtol(s, &s, 0);
           46                 if(*s != 0)
           47                         goto oops;
           48                 *r = rectaddpt(*r, Pt(i,j));
           49                 *havemin = 1;
           50                 return 0;
           51         }
           52 
           53         c = *s;
           54         if(c != ' ' && c != ',')
           55                 goto oops;
           56         s++;
           57         if(!isdigit((uchar)*s))
           58                 goto oops;
           59         j = strtol(s, &s, 0);
           60         if(*s != c)
           61                 goto oops;
           62         s++;
           63         if(!isdigit((uchar)*s))
           64                 goto oops;
           65         k = strtol(s, &s, 0);
           66         if(*s != c)
           67                 goto oops;
           68         s++;
           69         if(!isdigit((uchar)*s))
           70                 goto oops;
           71         l = strtol(s, &s, 0);
           72         if(*s != 0)
           73                 goto oops;
           74         *r = Rect(i,j,k,l);
           75         *havemin = 1;
           76         return 0;
           77 
           78 oops:
           79         werrstr("bad syntax in window size '%s'", os);
           80         return -1;
           81 }