Cleanup and documentation updates:

- Remove shared/str.h where not used.
- Remove shared/debug.h from all files as it has been completely replaced
  by shared/report.h (it will be removed later).
- Add more doxygen comments to shared/* and clients/lcdproc/*.
- Include static functions in doxygen output.
This commit is contained in:
mmdolze
2010-02-02 23:20:29 +00:00
parent e914ee3d72
commit 66023939a1
49 changed files with 929 additions and 590 deletions
+23 -14
View File
@@ -1,4 +1,4 @@
/** \file LL.c
/** \file shared/LL.c
* Define routines to deal with doubly linked lists
*/
@@ -91,7 +91,7 @@ LL_Destroy(LinkedList *list)
}
/* Move to another entry in the list.
/** Move to another entry in the list.
* Set list's \c current pointer to the node denoted to by \c whereto.
* \param list List object.
* \param whereto Direction where to set the list's \c current pointer
@@ -127,7 +127,7 @@ LL_GoTo(LinkedList *list, Direction whereto)
}
/* Return to the beginning of the list.
/** Return to the beginning of the list.
* Set list's \c current pointer to the first node in the list.
* \param list List object.
* \retval <0 error: no list given
@@ -530,7 +530,7 @@ LL_Remove(LinkedList *list, void *data, Direction whereto)
* \retval 0 success
*/
int
LL_Push(LinkedList *list, void *add) // Add node to end of list
LL_Push(LinkedList *list, void *add)
{
if (!list)
return -1;
@@ -550,7 +550,7 @@ LL_Push(LinkedList *list, void *add) // Add node to end of list
* \return Pointer to data of deleted node; \c NULL on error.
*/
void *
LL_Pop(LinkedList *list) // Remove node from end of list
LL_Pop(LinkedList *list)
{
if (!list)
return NULL;
@@ -568,7 +568,7 @@ LL_Pop(LinkedList *list) // Remove node from end of list
* \return Pointer to last node's data; \c NULL on error.
*/
void *
LL_Top(LinkedList *list) // Peek at end node
LL_Top(LinkedList *list)
{
return LL_GetLast(list);
}
@@ -580,7 +580,7 @@ LL_Top(LinkedList *list) // Peek at end node
* \return Pointer to data of deleted node; \c NULL on error.
*/
void *
LL_Shift(LinkedList *list) // Remove node from start of list
LL_Shift(LinkedList *list)
{
if (!list)
return NULL;
@@ -598,7 +598,7 @@ LL_Shift(LinkedList *list) // Remove node from start of list
* \return Pointer to first node's data; \c NULL on error.
*/
void *
LL_Look(LinkedList *list) // Peek at first node
LL_Look(LinkedList *list)
{
return LL_GetFirst(list);
}
@@ -612,7 +612,7 @@ LL_Look(LinkedList *list) // Peek at first node
* \retval 0 success
*/
int
LL_Unshift(LinkedList *list, void *add) // Add node to beginning of list
LL_Unshift(LinkedList *list, void *add)
{
if (!list)
return -1;
@@ -625,9 +625,14 @@ LL_Unshift(LinkedList *list, void *add) // Add node to beginning of list
}
//////////////////////////////////////////////////////////////////////
// Add an item to the end of its "priority group"
// The list is assumed to be sorted already...
/** Add an item to the end of its "priority group"
* The list is assumed to be sorted already.
* \param list List object.
* \param add Pointer to new node's data.
* \param compare Pointer to a comparison function.
* \retval <0 error
* \retval 0 success
*/
int
LL_PriorityEnqueue(LinkedList *list, void *add, int (*compare)(void *, void *))
{
@@ -661,9 +666,13 @@ LL_PriorityEnqueue(LinkedList *list, void *add, int (*compare)(void *, void *))
}
//////////////////////////////////////////////////////////////////////
/** Switch two nodes positions.
* \param one First list object.
* \param two Second list object.
* \return -1 on error, 0 on success
*/
int
LL_SwapNodes(LL_node *one, LL_node *two) // Switch two nodes positions...
LL_SwapNodes(LL_node *one, LL_node *two)
{
LL_node *firstprev, *firstnext;
LL_node *secondprev, *secondnext;
+4
View File
@@ -1,3 +1,7 @@
/** \file shared/LL.h
* Define routines to deal with doubly linked lists
*/
#ifndef LL_H
#define LL_H
+8 -7
View File
@@ -1,6 +1,10 @@
/*
/** \file shared/report.c
* Contains reporting functions.
*/
/*-
* report.c
* This file is part of LCDd, the lcdproc server.
* This file is part of LCDproc.
*
* This file is released under the GNU General Public License. Refer to the
* COPYING file distributed with this package.
@@ -8,14 +12,9 @@
* Copyright (c) 1999, William Ferrell, Scott Scriven
* 2001, Joris Robijn
* 2005, Peter Marschall
*
* Contains reporting functions
*
*/
#include <stdlib.h>
#include "report.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
@@ -25,6 +24,8 @@
# include <windows.h>
#endif
#include "report.h"
static int report_level = RPT_INFO;
static int report_dest = RPT_DEST_STORE;
+8 -2
View File
@@ -1,4 +1,8 @@
/*
/** \file shared/report.h
* Contains reporting functions.
*/
/*-
* report.h
* This file is part of LCDd, the lcdproc server.
*
@@ -13,7 +17,8 @@
#ifndef REPORT_H
#define REPORT_H
/* DEBUGGING / REPORTING
/** DEBUGGING / REPORTING
*\verbatim
*
* To enable the debug() function on all of the software, just type:
* ./configure --enable-debug
@@ -53,6 +58,7 @@
* function.
* The code that this function generates will not be in the executable when
* compiled without debugging. This way memory and CPU cycles are saved.
*\endverbatim
*/
#ifdef HAVE_CONFIG_H
+76 -20
View File
@@ -1,3 +1,13 @@
/** \file shared/sockets.c
* Socket functions available to server and clients.
*/
/*-
* This file is part of LCDproc.
*
* Feel free to use this in your own clients... :)
*/
#include <unistd.h>
#include <stddef.h>
#include <stdio.h>
@@ -24,17 +34,18 @@
#include "report.h"
#include "sockets.h"
/**************************************************
LCDproc client sockets code...
Feel free to use this in your own clients... :)
**************************************************/
// Length of longest transmission allowed at once...
#define MAXMSG 8192
typedef struct sockaddr_in sockaddr_in;
/**
* Tries to resolve a resolve a hostname.
* \param name Pointer to resolves IP-address
* \param hostname Hostname or IP-address (as string)
* \param port Port number
* \return 0 on success, -1 on error.
*/
static int
sock_init_sockaddr (sockaddr_in *name, const char *hostname, unsigned short int port)
{
@@ -51,10 +62,14 @@ sock_init_sockaddr (sockaddr_in *name, const char *hostname, unsigned short int
name->sin_addr = *(struct in_addr *) hostinfo->h_addr;
return 0;
}
// Client functions...
/**
* Connect to server.
* \param host Hostname or IP-address
* \param port Port number
* \return socket file descriptor on success, -1 on error
*/
int
sock_connect (char *host, unsigned short int port)
{
@@ -102,6 +117,11 @@ sock_connect (char *host, unsigned short int port)
return sock;
}
/**
* Disconnect from server.
* \param fd Socket file descriptor
* \return 0 on success, -1 on error.
*/
int
sock_close (int fd)
{
@@ -115,7 +135,13 @@ sock_close (int fd)
}
/** send printf-like formatted output */
/**
* Send printf-like formatted output.
* \param fd Socket file descriptor
* \param format Format string
* \param ... Arguments to the format string
* \return Number of bytes sent.
*/
int
sock_printf(int fd, const char *format, .../*args*/ )
{
@@ -137,14 +163,26 @@ sock_printf(int fd, const char *format, .../*args*/ )
return sock_send_string(fd, buf);
}
// Send/receive lines of text
/**
* Send lines of text.
* \param fd Socket file descriptor
* \param string Pointer to the string to send.
* \return Number of bytes sent.
*/
int
sock_send_string (int fd, char *string)
{
return sock_send(fd, string, strlen(string));
}
// Recv gives only one line per call...
/**
* Receive a line of text.
* Recv gives only one line per call...
* \param fd Socket file descriptor
* \param dest Pointer to buffer to store the received data
* \param maxlen Number of bytes to read at most (size of buffer)
* \return Number of bytes received.
*/
int
sock_recv_string (int fd, char *dest, size_t maxlen)
{
@@ -198,7 +236,13 @@ sock_recv_string (int fd, char *dest, size_t maxlen)
return recvBytes;
}
// Send/receive raw data
/**
* Send raw data.
* \param fd Socket file descriptor
* \param src Buffer holding the data to send
* \param size Number of bytes to send at most
* \return Number of bytes sent.
*/
int
sock_send (int fd, void *src, size_t size)
{
@@ -235,6 +279,13 @@ sock_send (int fd, void *src, size_t size)
return offset;
}
/**
* Receive raw data.
* \param fd Socket file descriptor
* \param dest Pointer to buffer to store the received data
* \param maxlen Number of bytes to read at most (size of buffer)
* \return Number of bytes received.
*/
int
sock_recv (int fd, void *dest, size_t maxlen)
{
@@ -262,6 +313,10 @@ sock_recv (int fd, void *dest, size_t maxlen)
/*****************************************************************************/
/**
* Return the error message for the last error occured.
* \return Error message string
*/
char*
sock_geterror(void)
{
@@ -295,21 +350,22 @@ sock_geterror(void)
#endif
}
/** prints error to logfile and sends it to the client.
* @param fd socket
* @param message the message to send (without the "huh? ") */
/**
* Send an already formatted error message to the client.
* \param fd socket
* \param message the message to send (without the "huh? ") */
int sock_send_error(int fd, char* message)
{
// simple: performance penalty isn't worth more work...
return sock_printf_error(fd, message);
}
/** prints printf-like formatted output to logfile and sends it to the
* client.
* @note don't add a the "huh? " to the message. This is done by this
/**
* Print printf-like formatted output to logfile and sends it to the client.
* \note don't add a the "huh? " to the message. This is done by this
* method
* @param fd socket
* @param format a printf format */
* \param fd socket
* \param format a printf format */
int
sock_printf_error(int fd, const char *format, .../*args*/ )
{
+16 -66
View File
@@ -1,3 +1,7 @@
/** \file shared/sockets.h
* Socket functions available to server and clients.
*/
#ifndef SOCKETS_H
#define SOCKETS_H
@@ -15,81 +19,27 @@
# define SHUT_RDWR 2
#endif
/*
Socket functions available to server and clients...
(ignore the rest of the comments... I was babbling out random ideas)
This should have stuff to read/write sockets, open/close them, etc...
*/
// Client functions...
/** Connect to server on host, port */
int sock_connect (char *host, unsigned short int port);
/** Disconnect from server */
int sock_close (int fd);
// Send/receive lines of text
/** Send printf-like formatted output */
int sock_printf (int fd, const char *format, .../*args*/);
/** Send lines of text */
int sock_send_string (int fd, char *string);
// Recv gives only one line per call...
int sock_recv_string (int fd, char *dest, size_t maxlen);
// Send/receive raw data
/** Send raw data */
int sock_send (int fd, void *src, size_t size);
/** Receive a line of text */
int sock_recv_string (int fd, char *dest, size_t maxlen);
/** Receive raw data */
int sock_recv (int fd, void *dest, size_t maxlen);
/* Return error message string for the socket function */
/** Return the error message for the last error occured */
char *sock_geterror(void);
/** Send an already formatted error message to the client */
int sock_send_error(int fd, char* message);
/** Print printf-like formatted output to logfile and send it to the client */
int sock_printf_error(int fd, const char *format, .../*args*/);
// Er, ignore the rest of this file. I'll clean it up sometime...
/*****************************************************************
LCDproc command line interface?: (while running)
-command
Tells LCDproc to interpret stdin as raw commands to send through
the socket. Input must be formatted as above, in socket interface.
-function f
Runs LCDproc external function f, where f is one of the predefined
functions which can be assigned to keypad keys. (like NEXTMODE, etc)
-key x
Simulates keypad press of key 'x', where 'x' is (A-Z).
-print [time]
Prints stdin on LCD one line at a time, with no line-wrapping (raw),
with [time] frames between updates (lines).
-wrap [time]
Prints stdin as with "-print", but with line wrapping when possible.
-contrast xxx
Sets contrast to xxx (decimal)
-backlight [on/off]
Turns backlight [on/off/auto], or toggles it.
If [off], stays off.
If [on], stays on.
If [auto], LCDproc controls backlight based on load, etc...
-exit
-quit
Duh... :)
******************************************************************/
/*****************************************************************
LCDproc stuff supported in config file (loose approximation):
Grammar is tcl-style. I.e., "command arg1 arg2 ...".
Spaces are used as argument separators, *until* it thinks it has the final
argument. So, "function thing shell myprogram arg1 arg2 arg3" would be
split into "function", "thing", "shell", and "myprogram arg1 arg2 arg3".
User-definable functions (use built-in's to create new ones?):
Function mp3NextSong Shell /usr/local/bin/mp3player -next
Function MySequence Sequence cpu mem xload
Function OtherSequence Sequence time cd xload
Keypad keys can be bound to any _function_:
Key A mp3NextSong
Key B HaltSystem
Key C Menu
Key D Next/+
Key E OtherSequence
******************************************************************/
#endif
+23 -4
View File
@@ -1,10 +1,29 @@
/** \file shared/str.c
* Commmand / argument parsing functions (for use in clients).
*/
/*-
* This file is part of LCDproc.
*
* This file is released under the GNU General Public License.
* Refer to the COPYING file distributed with this package.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "debug.h"
#include "report.h"
#include "str.h"
/** Split elements of a string into an array of strings.
* Elements are typically commands and arguments.
* \param **argv Pointer to the array which will store the arguments
* \param *str The string to be parsed
* \param max_args Number of arguments to parse (typically the size of argv)
* \retval <0 Error.
* \retval >=0 The number of arguments parsed.
*/
int
get_args (char **argv, char *str, int max_args)
{
@@ -19,11 +38,11 @@ get_args (char **argv, char *str, int max_args)
if (max_args < 1)
return 0;
//debug("get_args(%i): string=%s", max_args, str);
debug(RPT_DEBUG, "get_args(%i): string=%s", max_args, str);
// Parse the command line...
/* Parse the command line... */
for (item = strtok (str, delimiters); item; item = strtok (NULL, delimiters)) {
//debug("get_args: item=%s", item);
debug(RPT_DEBUG, "get_args: item=%s", item);
if (i < max_args) {
argv[i] = item;
i++;
+4
View File
@@ -1,3 +1,7 @@
/** \file shared/str.h
* Commmand / argument parsing functions (for use in clients).
*/
#ifndef STR_H
#define STR_H