Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

xiner.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xinerama.h>

Go to the source code of this file.


Functions

int main (int argc, char *argv[])

Function Documentation

int main int    argc,
char *    argv[]
 

Definition at line 13 of file xiner.c.

References argc, dpy, and malloc.

00014 {
00015    Display * dpy ;
00016    char * dname=NULL ;
00017    int iarg , quiet=0 ;
00018    XineramaScreenInfo * xsi ; int nxsi ;
00019 
00020    /*-- help the pitiful user --*/
00021 
00022    if( argc > 1 && strcmp(argv[1],"-help") == 0 ){
00023       printf("Usage: xiner [-display host:num] [-q]\n"
00024              "Gets the Xinerama screen information from the X server,\n"
00025              "Writes a human-readable summary to stderr, and a simpler\n"
00026              "summary to stdout (for use with xrdb).\n"
00027              "If -q option is present, the stderr output is skipped.\n"
00028              "If Xinerama is not active, the exit status is 1, else 0.\n"
00029             ) ;
00030       exit(0);
00031    }
00032 
00033    /*-- scan the command line options --*/
00034 
00035    iarg = 1 ;
00036    while( iarg < argc && argv[iarg][0] == '-' ){
00037 
00038       if( strcmp(argv[iarg],"-display") == 0 ){
00039          dname = argv[++iarg] ; ++iarg ; continue ;
00040       }
00041 
00042       if( strcmp(argv[iarg],"-q") == 0 ){
00043          quiet++ ; iarg++ ; continue ;
00044       }
00045 
00046       fprintf(stderr,"**xiner: Unknown option: %s\n",argv[iarg]) ;
00047       exit(1) ;
00048    }
00049 
00050    /*-- see if we can connect --*/
00051 
00052    dpy = XOpenDisplay( dname ) ;
00053    if( dpy == NULL ){
00054       fprintf(stderr,"**xiner: Can't open display\n") ; exit(1) ;
00055    }
00056 
00057    /*-- see if AFNI.xinerama is already set --*/
00058 
00059    if( !quiet ){
00060       char * xdef = XGetDefault(dpy,"AFNI","xinerama") ;
00061       if( xdef != NULL ){
00062          fprintf(stderr,"AFNI.xinerama is now set=%s\n",xdef) ;
00063       }
00064    }
00065 
00066    /*-- Try to get the Xinerama info from the display --*/
00067 
00068    xsi = XineramaQueryScreens( dpy , &nxsi ) ;
00069 
00070    if( xsi == NULL || nxsi == 0 ){
00071       fprintf(stderr,"Xinerama not active on server\n") ;
00072       exit(1) ;  /* The premature end of a promising career */
00073    } else {
00074       int ii ; char *xp , *xstr ;
00075 
00076       xstr = (char *) malloc( sizeof(char) * (nxsi+1)*64 ) ;
00077       sprintf(xstr,"AFNI.xinerama: %d",nxsi) ;
00078 
00079       if(!quiet) fprintf(stderr,"Xinerama information from server:\n") ;
00080       for( ii=0 ; ii < nxsi ; ii++ ){
00081          if( !quiet )
00082           fprintf(stderr,
00083                   " Screen %2d: x origin=%4d y origin=%4d width=%4d height=%4d\n",
00084                   xsi[ii].screen_number ,
00085                   xsi[ii].x_org , xsi[ii].y_org ,
00086                   xsi[ii].width , xsi[ii].height ) ;
00087 
00088          sprintf( xstr + strlen(xstr) , " %d %d %d %d %d" ,
00089                     xsi[ii].screen_number ,
00090                     xsi[ii].x_org , xsi[ii].y_org ,
00091                     xsi[ii].width , xsi[ii].height ) ;
00092       }
00093 
00094       printf("%s\n",xstr) ;
00095    }
00096 
00097    /*-- Ciao, baby --*/
00098 
00099    exit(0) ;
00100 }
 

Powered by Plone

This site conforms to the following standards: