]> git.proxmox.com Git - spiceterm.git/blobdiff - screen.c
cleanup debugging code
[spiceterm.git] / screen.c
index e41bc914a86ff93ab109439981b2d6c466d7abe7..1dbbedba89b4591837c1506e13c0ea9731e7b498 100644 (file)
--- a/screen.c
+++ b/screen.c
 
 #include "spiceterm.h"
 
+static int debug = 0;
+    
+#define DPRINTF(x, format, ...) { \
+    if (x <= debug) { \
+        printf("%s: " format "\n" , __FUNCTION__, ## __VA_ARGS__); \
+    } \
+}
+
 #define MEM_SLOT_GROUP_ID 0
 
 #define NOTIFY_DISPLAY_BATCH (SINGLE_PART/2)
@@ -550,7 +558,7 @@ set_client_capabilities(QXLInstance *qin, uint8_t client_present,
 {
     SpiceScreen *spice_screen = SPICE_CONTAINEROF(qin, SpiceScreen, qxl_instance);
 
-    printf("%s: present %d caps %d\n", __func__, client_present, caps[0]);
+    DPRINTF(1, "%s: present %d caps %d", __func__, client_present, caps[0]);
 
     if (spice_screen->on_client_connected && client_present) {
         spice_screen->on_client_connected(spice_screen);
@@ -565,17 +573,17 @@ static int client_count = 0;
 static void 
 client_connected(SpiceScreen *spice_screen)
 {
-    printf("Client connected\n");
     client_count++;
+
+    DPRINTF(1, "%s: client_count = %d", __func__, client_count);
 }
 
 static void 
 client_disconnected(SpiceScreen *spice_screen)
 {    
-
     if (client_count > 0) {
         client_count--;
-        printf("Client disconnected\n");
+        DPRINTF(1, "%s: client_count = %d", __func__, client_count);
         exit(0); // fixme: cleanup?
     }
 }
@@ -586,7 +594,7 @@ do_conn_timeout(void *opaque)
     // SpiceScreen *spice_screen = opaque;
 
     if (client_count <= 0) {
-        printf("connection timeout\n");
+        printf("connection timeout - stopping server\n");
         exit (0); // fixme: cleanup?
     }
 }