diff options
author | VMiklos <vmiklos@frugalware.org> | 2007-08-21 20:20:59 +0200 |
---|---|---|
committer | VMiklos <vmiklos@frugalware.org> | 2007-08-21 20:20:59 +0200 |
commit | dfec37e7eac14102c6d127b77484cf0eb717eea0 (patch) | |
tree | 4676bcdeb0a7af832680ee07340867fb1e340dc1 | |
parent | cd3022cce128e4ff995bd7d76b3013d1909b3332 (diff) |
add a simple skyped client for testing purposes
-rw-r--r-- | skype/Makefile | 2 | ||||
-rw-r--r-- | skype/client.c | 43 |
2 files changed, 45 insertions, 0 deletions
diff --git a/skype/Makefile b/skype/Makefile index 1f682f7c..00cc533f 100644 --- a/skype/Makefile +++ b/skype/Makefile @@ -4,6 +4,8 @@ LDFLAGS += $(shell pkg-config --libs bitlbee) skype.so: skype.c gcc -o skype.so -shared skype.c $(CFLAGS) +client: client.c + clean: rm -f skype.so diff --git a/skype/client.c b/skype/client.c new file mode 100644 index 00000000..66a3f770 --- /dev/null +++ b/skype/client.c @@ -0,0 +1,43 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <arpa/inet.h> +#include <sys/types.h> +#include <netinet/in.h> +#include <sys/socket.h> + +#define MESSAGE_LEN 1023 +#define PORTNUM 2727 + +char *invoke(int sock, char *cmd) +{ + char buf[MESSAGE_LEN+1]; + int len; + + write(sock, cmd, strlen(cmd)); + len = recv(sock, buf, MESSAGE_LEN, 0); + buf[len] = '\0'; + return strdup(buf); +} + +int main(int argc, char *argv[]) +{ + int sock; + struct sockaddr_in dest; + char *ptr; + + sock = socket(AF_INET, SOCK_STREAM, 0); + + memset(&dest, 0, sizeof(dest)); + dest.sin_family = AF_INET; + dest.sin_addr.s_addr = inet_addr("127.0.0.1"); + dest.sin_port = htons(PORTNUM); + + connect(sock, (struct sockaddr *)&dest, sizeof(struct sockaddr)); + + ptr = invoke(sock, "SET USER foo ISAUTHORIZED FALSE"); + printf("ptr: '%s'\n", ptr); + close(sock); + return(0); +} |