133 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			C
		
	
	
	
			
		
		
	
	
			133 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			C
		
	
	
	
/*
 | 
						|
 * Copyright © 2004 David Reveman
 | 
						|
 * 
 | 
						|
 * Permission to use, copy, modify, distribute, and sell this software
 | 
						|
 * and its documentation for any purpose is hereby granted without
 | 
						|
 * fee, provided that the above copyright notice appear in all copies
 | 
						|
 * and that both that copyright notice and this permission notice
 | 
						|
 * appear in supporting documentation, and that the names of
 | 
						|
 * David Reveman not be used in advertising or publicity pertaining to
 | 
						|
 * distribution of the software without specific, written prior permission.
 | 
						|
 * David Reveman makes no representations about the suitability of this
 | 
						|
 * software for any purpose. It is provided "as is" without express or
 | 
						|
 * implied warranty.
 | 
						|
 *
 | 
						|
 * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
 | 
						|
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 | 
						|
 * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 | 
						|
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 | 
						|
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 
 | 
						|
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 | 
						|
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 | 
						|
 *
 | 
						|
 * Author: David Reveman <davidr@freedesktop.org>
 | 
						|
 */
 | 
						|
 | 
						|
#include "xgl.h"
 | 
						|
 | 
						|
char *
 | 
						|
xglParseFindNext (char *cur,
 | 
						|
		  char *delim,
 | 
						|
		  char *save,
 | 
						|
		  char *last)
 | 
						|
{
 | 
						|
    while (*cur && !strchr (delim, *cur))
 | 
						|
	*save++ = *cur++;
 | 
						|
    
 | 
						|
    *save = 0;
 | 
						|
    *last = *cur;
 | 
						|
    
 | 
						|
    if (*cur)
 | 
						|
	cur++;
 | 
						|
    
 | 
						|
    return cur;
 | 
						|
}
 | 
						|
 | 
						|
void
 | 
						|
xglParseScreen (xglScreenInfoPtr pScreenInfo,
 | 
						|
		char	         *arg)
 | 
						|
{
 | 
						|
    char delim;
 | 
						|
    char save[1024];
 | 
						|
    int	 i, pixels, mm;
 | 
						|
    
 | 
						|
    pScreenInfo->width    = 0;
 | 
						|
    pScreenInfo->height   = 0;
 | 
						|
    pScreenInfo->widthMm  = 0;
 | 
						|
    pScreenInfo->heightMm = 0;
 | 
						|
    
 | 
						|
    if (!arg)
 | 
						|
	return;
 | 
						|
    
 | 
						|
    if (strlen (arg) >= sizeof (save))
 | 
						|
	return;
 | 
						|
    
 | 
						|
    for (i = 0; i < 2; i++)
 | 
						|
    {
 | 
						|
	arg = xglParseFindNext (arg, "x/@XY", save, &delim);
 | 
						|
	if (!save[0])
 | 
						|
	    return;
 | 
						|
	
 | 
						|
	pixels = atoi (save);
 | 
						|
	mm = 0;
 | 
						|
	
 | 
						|
	if (delim == '/')
 | 
						|
	{
 | 
						|
	    arg = xglParseFindNext (arg, "x@XY", save, &delim);
 | 
						|
	    if (!save[0])
 | 
						|
		return;
 | 
						|
	    
 | 
						|
	    mm = atoi (save);
 | 
						|
	}
 | 
						|
	
 | 
						|
	if (i == 0)
 | 
						|
	{
 | 
						|
	    pScreenInfo->width   = pixels;
 | 
						|
	    pScreenInfo->widthMm = mm;
 | 
						|
	}
 | 
						|
	else
 | 
						|
	{
 | 
						|
	    pScreenInfo->height   = pixels;
 | 
						|
	    pScreenInfo->heightMm = mm;
 | 
						|
	}
 | 
						|
	
 | 
						|
	if (delim != 'x')
 | 
						|
	    return;
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
void
 | 
						|
xglUseMsg (void)
 | 
						|
{
 | 
						|
    ErrorF ("-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM] "
 | 
						|
	    "Specify screen characteristics\n");
 | 
						|
    ErrorF ("-fullscreen            Run fullscreen\n");
 | 
						|
}
 | 
						|
 | 
						|
int
 | 
						|
xglProcessArgument (xglScreenInfoPtr pScreenInfo,
 | 
						|
		    int		     argc,
 | 
						|
		    char	     **argv,
 | 
						|
		    int		     i)
 | 
						|
{
 | 
						|
    if (!strcmp (argv[i], "-screen"))
 | 
						|
    {
 | 
						|
	if ((i + 1) < argc)
 | 
						|
	{
 | 
						|
	    xglParseScreen (pScreenInfo, argv[i + 1]);
 | 
						|
	}
 | 
						|
	else
 | 
						|
	    return 1;
 | 
						|
	
 | 
						|
	return 2;
 | 
						|
    }
 | 
						|
 | 
						|
    if (!strcmp (argv[i], "-fullscreen"))
 | 
						|
    {
 | 
						|
	pScreenInfo->fullscreen = TRUE;
 | 
						|
	return 1;
 | 
						|
    }
 | 
						|
		    
 | 
						|
    return 0;
 | 
						|
}
 |