summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2011-04-15 14:20:44 (GMT)
committer Jaromil <jaromil@dyne.org>2011-04-15 14:20:44 (GMT)
commit32fb81b2b31a328693ce3b3b850599a9429af622 (patch)
treecd87e293688f35c98bea09f4934c1f16ebbc59d6
parent41ec9b14bb0575ea3e68f47602a05b423ea51e31 (diff)
code cleanup and help documentation
-rw-r--r--configure.ac2
-rw-r--r--src/avremote.c30
-rw-r--r--src/avremote.h11
-rw-r--r--src/cmdline.c35
4 files changed, 42 insertions, 36 deletions
diff --git a/configure.ac b/configure.ac
index 49814d8..6110b72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@ dnl ==============================================================
dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
-AC_INIT([avremote],[0.1.0],[jaromil@nimk.nl],[avremote])
+AC_INIT([avremote],[0.1.0],[jaromil@nimk.nl],[AVRemote])
AC_CONFIG_MACRO_DIR([m4])
AC_CANONICAL_HOST
diff --git a/src/avremote.c b/src/avremote.c
index 6bb5ce0..9de74ec 100644
--- a/src/avremote.c
+++ b/src/avremote.c
@@ -56,7 +56,6 @@ upnp_t *create_upnp() {
upnp->res = (char*) calloc(1401,sizeof(char));
upnp->meta = (char*) calloc(1024,sizeof(char));
-
return(upnp);
}
@@ -75,21 +74,9 @@ void free_upnp(upnp_t *upnp) {
free(upnp);
}
-int check_upnp(upnp_t *upnp, const char *caller) {
- int res = 1;
- if(!upnp) {
- fprintf(stderr,"error: upnp object is NULL (%s)",caller);
- res = 0;
- }
- if(!upnp) {
- fprintf(stderr,"error: upnp is not connected (%s)",caller);
- res = 0;
- }
- return(res);
-}
-
int connect_upnp(upnp_t *upnp, char *hostname, int port) {
struct sockaddr_in serveraddr;
+ // const struct sockaddr *serveraddr;
struct hostent *host;
int sockfd;
@@ -120,7 +107,7 @@ int connect_upnp(upnp_t *upnp, char *hostname, int port) {
serveraddr.sin_port = htons(port);
/* connect: create a connection with the server */
- if (connect(sockfd, &serveraddr, sizeof(serveraddr)) < 0) {
+ if (connect(sockfd, (const struct sockaddr*)&serveraddr, sizeof(serveraddr)) < 0) {
fprintf(stderr,"error: can't connect (%s)\n",strerror(errno));
return(-1);
}
@@ -133,10 +120,8 @@ int connect_upnp(upnp_t *upnp, char *hostname, int port) {
}
void render_uri_meta(upnp_t *upnp, char *path) {
- char dir[1024];
- char *pdir;
- char file[1024];
- char *pfile;
+ char dir[1024], *pdir;
+ char file[1024], *pfile;
char url[1024];
size_t filesize;
@@ -200,10 +185,3 @@ int print_upnp(upnp_t *upnp) {
fprintf(stderr,"message (%u bytes):\n\n%s\n\n",upnp->msglen, upnp->msg);
}
-int load(upnp_t *upnp, char *file) {
- char meta[1024];
- if(!check_upnp(upnp, __PRETTY_FUNCTION__)) return(0);
- // render_file_meta(file, meta);
- // TODO
-}
-
diff --git a/src/avremote.h b/src/avremote.h
index 1ee9b6e..66e5347 100644
--- a/src/avremote.h
+++ b/src/avremote.h
@@ -18,6 +18,9 @@
*/
+#ifndef __AVREMOTE_H__
+#define __AVREMOTE_H__
+
// messages get rendered in this structure
// allocated and freed with create/free_upnp
typedef struct {
@@ -99,14 +102,10 @@ SetVolume <DesiredVolume> (allowed DesiredVolume = 1 to 100)
*/
void render_upnp(upnp_t *upnp, char *action, char *arg);
+void render_uri_meta(upnp_t *upnp, char *path);
int send_upnp(upnp_t *upnp);
int recv_upnp(upnp_t *upnp);
int print_upnp(upnp_t *upnp);
-
-
-
-
-
-int check_upnp(upnp_t *upnp, const char *caller);
+#endif
diff --git a/src/cmdline.c b/src/cmdline.c
index 5f7abf6..e507247 100644
--- a/src/cmdline.c
+++ b/src/cmdline.c
@@ -18,6 +18,8 @@
*/
+#include <config.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -57,8 +59,35 @@ void cmdline(int argc, char **argv) {
res = getopt(argc, argv, short_options);
switch(res) {
case 'h':
- fprintf(stderr,"usage: %s [options] command [file]\n",argv[0]);
- break;
+ fprintf(stderr,
+ "%s %s - send AVTransport commands to UPNP media services\n"
+ "\n"
+ " Copyright (C) 2011 Jaromil @ NIMk.nl Artlab , License GNU AGPL v3+\n"
+ " This is free software: you are free to change and redistribute it.\n"
+ " The latest AVTransport sourcecode is published on <%s>\n"
+ "\n"
+ "Syntax: avremote [options] command [file]\n"
+ "\n"
+ "Commands:\n"
+ "\n"
+ " load load a file and prepare it for playback\n"
+ " play start playing the selected file\n"
+ " pause pause currently running playback\n"
+ " stop stop playback and return to menu\n"
+ "\n"
+ "Options:\n"
+ " -s network address or hostname of the media server\n"
+ " -p port on which the UPNP AVTransport daemon is listening\n"
+ " -t dry run to test without a server (print out rendered xml)\n"
+ "\n"
+ " -h print this help\n"
+ " -v version information for this tool\n"
+ "\n"
+ "For more informations on AVRemote read the manual: man avremote\n"
+ "Please report bugs on <http://bugs.dyne.org>.\n",
+ PACKAGE, VERSION, PACKAGE_URL);
+ exit(0);
+
case 'v':
fprintf(stderr,"AVRemote - simple commandline tool to send AVTransport commands over UPNP\n"
"version 0.1 (Apr/2011) by Jaromil - Netherlands Media Art Institute\n"
@@ -180,7 +209,7 @@ int main(int argc, char **argv) {
else {
send_upnp(upnp);
recv_upnp(upnp);
- fprintf(stderr,"response:\n\n%s\n",upnp->res);
+ fprintf(stderr,"%s\n",upnp->res);
}
// TODO recv when needed