diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | moc_library.c | 16 | 
2 files changed, 6 insertions, 12 deletions
@@ -30,7 +30,7 @@ mocicon: ${OBJ}  clean:  	@echo cleaning -	@rm -f mocicon moc_x11 *.o mocicon-${VERSION}.tar.gz +	rm -f mocicon moc_x11 *.o mocicon-${VERSION}.tar.gz  dist: clean  	@echo creating dist tarball diff --git a/moc_library.c b/moc_library.c index cdc1cf6..6b2441c 100644 --- a/moc_library.c +++ b/moc_library.c @@ -1,18 +1,12 @@  #include <stdio.h>  #include <stdlib.h> -#include <unistd.h>  //Header file for sleep(). man 3 sleep for details. +#include <unistd.h>  #include <errno.h>  #include <pthread.h>  #include <sys/socket.h>  #include <sys/un.h> -// A normal C function that is executed as a thread -// when its name is specified in pthread_create() -// - -char *moc_socket_path = "/home/calvin/.moc/socket2"; -  /* State of the server. */  #define STATE_PLAY	0x01  #define STATE_STOP	0x02 @@ -207,18 +201,18 @@ static int moc_server_connect ()  {    struct sockaddr_un sock_name;    int sock; -    /* Create a socket */    if ((sock = socket (PF_LOCAL, SOCK_STREAM, 0)) == -1)      return -1;    sock_name.sun_family = AF_LOCAL; -  strcpy (sock_name.sun_path, moc_socket_path); + +  snprintf(sock_name.sun_path, sizeof(sock_name.sun_path), "%s/.moc/socket2", getenv("HOME"));    if (connect(sock, (struct sockaddr *)&sock_name,          SUN_LEN(&sock_name)) == -1) {      close (sock); -    fprintf(stderr, "%s at (%s)\n", strerror(errno), moc_socket_path); +    fprintf(stderr, "%s at (%s)\n", strerror(errno), sock_name.sun_path);      return -1;    } @@ -313,7 +307,7 @@ void *moc_loop(void *input) {            pthread_mutex_unlock(&data->lock);          }          else { -          fprintf(stderr, "moc: shit i have data IDK what it is\n"); +          fprintf(stderr, "moc: UNKNOWN STATE\n");          }          last_cmd = -1;  | 
