[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Sun, 20 Mar 2022 04:54:58 -0400 (EDT) |
branch: master
commit 886d283bf381a918f95375e047744564154cc591
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun May 5 19:00:17 2019 +0100
add a message type
---
js/wkinfo/extension.c | 11 +++++++++--
js/wkinfo/main.c | 24 +++++++++++++++++++++---
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/js/wkinfo/extension.c b/js/wkinfo/extension.c
index 122c6fbc85..b6f082d97d 100644
--- a/js/wkinfo/extension.c
+++ b/js/wkinfo/extension.c
@@ -116,6 +116,7 @@ document_loaded_callback (WebKitWebPage *web_page,
const char *q;
g_print ("current uri is |%s|\n", current_uri);
+ /* Set p to after the last '/'. */
while ((q = strchr (p, '/')))
{
q++;
@@ -129,9 +130,13 @@ document_loaded_callback (WebKitWebPage *web_page,
strcpy (next_link + (p - current_uri), href);
g_print ("saved ref |%s|\n", next_link);
+ char *message;
+ long len;
+ len = asprintf (&message, "%s\n%s\n", "next",
+ next_link);
+
ssize_t result;
- result = sendto (socket_id, next_link,
- strlen (next_link), 0,
+ result = sendto (socket_id, message, len, 0,
(struct sockaddr *) &main_name, main_name_size);
if (result == -1)
@@ -139,6 +144,8 @@ document_loaded_callback (WebKitWebPage *web_page,
g_print ("socket write failed: %s\n",
strerror(errno));
}
+
+ free (message);
}
}
}
diff --git a/js/wkinfo/main.c b/js/wkinfo/main.c
index 02f1c6d3a2..35a46f6f7e 100644
--- a/js/wkinfo/main.c
+++ b/js/wkinfo/main.c
@@ -51,10 +51,28 @@ socket_cb (GSocket *socket,
gtk_main_quit ();
}
- g_print ("Received le data: <%s>\n", buffer);
buffer[255] = '\0';
- free (next_link);
- next_link = strdup (buffer);
+ g_print ("Received le data: <%s>\n", buffer);
+
+ char *p, *q;
+ p = strchr (buffer, '\n');
+ if (!p)
+ break;
+ *p = 0;
+ if (!strcmp (buffer, "next"))
+ {
+ p++;
+ q = strchr (p, '\n');
+ if (!q)
+ break;
+ *q = 0;
+ free (next_link);
+ next_link = strdup (p);
+ }
+ else
+ {
+ g_print ("Unknown message type '%s'\n", buffer);
+ }
break;
case G_IO_ERR:
- master updated (cd0de30b76 -> ca0de032c7), Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject],
Gavin D. Smith <=
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20
- [no subject], Gavin D. Smith, 2022/03/20