home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xyzext.zip / xyz / clients / xyztest / xyztest.c < prev    next >
C/C++ Source or Header  |  1992-07-18  |  3KB  |  160 lines

  1.  
  2. #define NeedFunctionPrototypes 1
  3.  
  4. #include <stdio.h>
  5. #include <X11/Xlib.h>
  6. #include <X11/Xatom.h>
  7. #include <X11/Xproto.h>
  8. #include "xyzext.h"
  9.  
  10. Display *dpy;
  11.  
  12. StartConnectionToServer(argc, argv)
  13. int argc;
  14. char *argv[];
  15. {
  16.    char *display;
  17.  
  18.    display = NULL;
  19.    for(--argc, ++argv; argc; --argc, ++argv) {
  20.       if((*argv)[0] == '-') {
  21.      switch((*argv)[1]) {
  22.      case 'd':
  23.         display = argv[1];
  24.         ++argv; --argc;
  25.         break;
  26.      }
  27.       }
  28.    }
  29.    if(!(dpy = XOpenDisplay(display))) {
  30.       perror("Cannot open display");
  31.       exit(1);
  32.    }
  33. }
  34.  
  35. xyz_query_state()
  36. {
  37.    int instrument;
  38.    int trace;
  39.    int tracelevel;
  40.    int status;
  41.    char *string;
  42.    int rc;
  43.  
  44.    rc = XYZ_QueryState(dpy, &instrument, &trace, &tracelevel, &status);
  45.    if(rc) {
  46.       if(instrument) {
  47.      string  = "ON";
  48.       } else {
  49.      string  = "off";
  50.       }
  51.       printf("instrumentation = %s\n", string);
  52.       if(trace) {
  53.      string  = "ON";
  54.       } else {
  55.      string  = "off";
  56.       }
  57.       printf("tracing = %s\n", string);
  58.       printf("tracelevel = %d\n", tracelevel);
  59.       switch(status) {
  60.       case XYZ_NO_ERROR:
  61.      string = "no error";
  62.      break;
  63.       case XYZ_ERROR:
  64.      string = "ERROR";
  65.      break;
  66.       default:
  67.      string = "UNKNOWN";
  68.      break;
  69.       }
  70.       printf("state = %s\n", string);
  71.    } else {
  72.       printf("Query failed\n");
  73.    }
  74. }
  75.  
  76. xyz_get_tag(tagname)
  77. char *tagname;
  78. {
  79.    int value;
  80.    int tracelevel;
  81.    int rc;
  82.  
  83.    rc = XYZ_GetTag(dpy, tagname, &value, &tracelevel);
  84.    if(rc) {
  85.       printf("GetTag %s = %d (tracelevel = %d)\n", tagname, value, tracelevel);
  86.    } else {
  87.       printf("GetTag failed\n");
  88.    }
  89. }
  90.  
  91. xyz_list_values(pattern)
  92. char *pattern;
  93. {
  94.    XYZ_value *values;
  95.    int total;
  96.    int returned;
  97.    int i;
  98.  
  99.    int patlen = strlen(pattern);
  100.    values = XYZ_ListValues(dpy, 1, &pattern, &patlen, 255, &total, &returned);
  101.    if(values != NULL) {
  102.       printf("LISTING VALUES for %s ...\n", pattern);
  103.       printf("total = %d\n", total);
  104.       printf("returned = %d\n", returned);
  105.       for(i=0;i<returned;i++) {
  106.      printf("%s = %d\n", values[i].tagname, values[i].value);
  107.       }
  108.       XYZ_FreeValueList(values);
  109.    } else {
  110.       printf("ListValues RETURNED NULL\n");
  111.       if((total == -1) || (returned == -1)) {
  112.      printf("bad compile\n");
  113.       } else {
  114.      printf("just NULL\n");
  115.       }
  116.    }
  117. }
  118.  
  119. main(argc, argv)
  120. int argc;
  121. char *argv[];
  122. {
  123.    int rc;
  124.  
  125.    StartConnectionToServer(argc, argv);
  126.    rc = XYZ_QueryExtension(dpy);
  127.    if(rc) {
  128.       printf("XamineYourZerver extension present\n");
  129.       xyz_query_state();
  130.       XYZ_Instrument(dpy, True);
  131.       xyz_query_state();
  132.       XYZ_Trace(dpy, True);
  133.       xyz_query_state();
  134.       XYZ_Instrument(dpy, False);
  135.       XYZ_Trace(dpy, False);
  136.       XYZ_SetTraceLevel(dpy, "rexDrawMonoImage", 1);
  137.       XYZ_SetTraceLevel(dpy, 
  138.      "ProcXamineYourZerverQuery-entered", 2);
  139.       xyz_query_state();
  140.       xyz_get_tag("ProcXamineYourZerverQuery-entered");
  141.       XYZ_SetValue(dpy, "rexDrawMonoImage", 4);
  142.       xyz_get_tag("rexDrawMonoImage");
  143.       xyz_list_values("");
  144.       xyz_list_values("*");
  145.       xyz_list_values("Proc*");
  146.       xyz_list_values("P*");
  147.       xyz_list_values("rex?raw?ono?mage");
  148.       xyz_list_values("*-entered");
  149.       xyz_list_values("ProcXamineYourZerverQuery-en*");
  150.       XYZ_ResetValues(dpy);
  151.       XYZ_ResetTraceLevels(dpy);
  152.       xyz_get_tag("rexDrawMonoImage");
  153.    } else {
  154.       printf("XamineYourZerver extension NOT present\n");
  155.    }
  156.    XCloseDisplay(dpy);
  157.    exit(0);
  158. }
  159.  
  160.