Enlightenment CVS committal

Author  : sarajervi
Project : misc
Module  : erss

Dir     : misc/erss/src


Modified Files:
        erss.c 


Log Message:
more debugging, more checks, display connection information on first connect
===================================================================
RCS file: /cvsroot/enlightenment/misc/erss/src/erss.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- erss.c      25 Dec 2003 22:46:43 -0000      1.6
+++ erss.c      26 Dec 2003 01:54:45 -0000      1.7
@@ -17,11 +17,26 @@
 char *last_time;
 
 int bufsize = 0;
+int waiting_for_reply = FALSE;
+int total_connects = 0;
 
 
 int erss_connect (void *data)
 {
+
+       if (waiting_for_reply) {
+               fprintf (stderr, "%s warning: client has not recived all information 
", 
+                               PACKAGE);
+               fprintf (stderr, "from the last connection attempt yet! \n");
+               return TRUE;
+       }
+       
        server = NULL;
+       
+       if (last_time)
+               free (last_time);
+       else
+               printf ("%s info: connecting to '%s' ...\n", PACKAGE, cfg->url);
 
        if (cfg->proxy) {
                if (!strcasecmp (cfg->proxy, "")) {
@@ -47,11 +62,7 @@
                exit (-1);
        }
 
-       if (last_time)
-               free (last_time);
-       else
-               printf ("%s: conneting to %s\n", PACKAGE, cfg->url);
-       
+       total_connects++;
        last_time = strdup (time_format ());
        set_time (NULL);
        
@@ -177,11 +188,17 @@
        /*
         * We want to be connected before sending the request.
         */
+       
+       if (total_connects == 1)
+               printf ("%s info: sending HTTP request ...\n", PACKAGE);
+
        snprintf (c, sizeof (c), "GET %s HTTP/1.0\r\n", cfg->url);
        ecore_con_server_send (server, c, strlen (c));
        snprintf (c, sizeof (c), "Host: %s \r\n\r\n", cfg->hostname);
        ecore_con_server_send (server, c, strlen (c));
 
+       waiting_for_reply = TRUE;
+
        return 1;
 }
 
@@ -189,6 +206,9 @@
 {
        Ecore_Con_Event_Server_Data *e = event;
 
+       if (total_connects == 1)
+               printf ("%s info: reciving data ...\n", PACKAGE);
+
        /* 
         * Read everything we recive into one big buffer, and handle
         * that buffer when the server disconnects.
@@ -205,6 +225,9 @@
        Ecore_Con_Event_Server_Del *e = event;
        char *leader;
 
+       if (total_connects == 1)
+               printf ("%s info: disconnecting ...\n", PACKAGE);
+
        /*
         * Now split our main buffer in each newline and then parse 
         * the line.
@@ -231,16 +254,27 @@
        ecore_con_server_del (e->server);
        server = NULL;
        
-       if (!list) {
-               printf ("Erss: error parsing data\n");
-               printf ("------------------------\n");
-               printf ("%s\n", main_buffer);
+       if (ewd_list_is_empty (list)) {
+               printf ("\n%s error: parsing data\n", PACKAGE);
+               if (main_buffer) 
+                       printf ("%s\n", main_buffer);
+               else 
+                       printf ("%s error: could not connect to '%s'\n", PACKAGE, 
cfg->url);
+               
+               exit (-1);
        }
 
-       if (main_buffer)
+       if (main_buffer) {
                free (main_buffer);
+               main_buffer = NULL;
+       }
 
        bufsize = 0;
+       waiting_for_reply = FALSE;
+
+       if (total_connects == 1)
+               printf ("%s info: connection information only displays on first 
connect.\n", 
+                               PACKAGE);
 
        return 1;
 }




-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to