displaytest.c File Reference

#include "config.h"
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <arpa/inet.h>
#include "delta.h"
#include "log.h"
Include dependency graph for displaytest.c:

Go to the source code of this file.

Defines

#define DMPORT   50555
#define DMSERVER   "127.0.0.1"
#define MESSAGEFULL   "0,0,0,768,1024,0,1,1,displaytest"

Functions

void displayHelp (void)
int main (int argc, char **argv)

Define Documentation

#define DMPORT   50555

Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Definition at line 55 of file displaytest.c.

#define DMSERVER   "127.0.0.1"

Definition at line 56 of file displaytest.c.

#define MESSAGEFULL   "0,0,0,768,1024,0,1,1,displaytest"

Definition at line 57 of file displaytest.c.

Referenced by main().


Function Documentation

void displayHelp ( void   ) 

Definition at line 76 of file displaytest.c.

Referenced by main().

00077 {
00078     printf("Usage: displaytest -<option> <argument>\n");
00079     printf("  no arguments : send full display update message to local host\n");
00080     printf("  -m <formatted display string>  : message to send (x,y,width,height,is_window,window_type,widget_type)\n");
00081     printf("  -d <dotted decimal ip address> : destination IP address\n");
00082     printf("  -h : display this message\n");
00083 }

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 85 of file displaytest.c.

References displayHelp(), DMPORT, DMSERVER, ERRORPRINTF, fd, LOGPRINTF, MESSAGEFULL, and msg.

00086 {
00087     char    destination[INET_ADDRSTRLEN] = DMSERVER;
00088     char    message[256]                 = MESSAGEFULL;
00089     char    msg[256]                     = {0};
00090     struct  sockaddr_in server_addr      = {0};
00091     int     nArg = 1;
00092     int     fd   = 0;
00093 
00094     // work our way through all possible options
00095     while (nArg < argc)
00096     {
00097         if (argv[nArg][0] == '-')
00098         {
00099             switch (argv[nArg][1])
00100             {
00101             case 'h':
00102                 displayHelp();
00103                 return 0;
00104                 break;
00105 
00106             case 'd':
00107                 // What address ?
00108                 if (++nArg >= argc)
00109                 {
00110                     // not enough arguments supplied
00111                     ERRORPRINTF("Supply a dotted decimal IP address after option -d");
00112                     displayHelp();
00113                     return -1;
00114                 }
00115                 else
00116                 {
00117                     strncpy(destination, argv[nArg], INET_ADDRSTRLEN);
00118                     nArg++;
00119                 }
00120                 break;
00121 
00122             case 'm':
00123                 if (++nArg >= argc)
00124                 {
00125                     // not enough arguments supplied
00126                     ERRORPRINTF("Supply a message string after option -m");
00127                     displayHelp();
00128                     return -1;
00129                 }
00130                 else
00131                 {
00132                     strncpy(message, argv[nArg], sizeof(message));
00133                     nArg++;
00134                 }
00135                 break;
00136 
00137             default:
00138                 ERRORPRINTF("Option %s not known", argv[nArg]);
00139                 displayHelp();
00140                 return -1;
00141             }
00142         }
00143         else
00144         {
00145             ERRORPRINTF("Argument supplied not proceded by option");
00146             displayHelp();
00147             return -1;
00148         }
00149     }
00150 
00151     // create and bind socket
00152     fd = socket(PF_INET, SOCK_DGRAM, 0);
00153     server_addr.sin_family = AF_INET;
00154     server_addr.sin_port = htons(DMPORT);
00155     server_addr.sin_addr.s_addr = inet_addr(destination);
00156     memset(server_addr.sin_zero, '\0', sizeof(server_addr.sin_zero));
00157     
00158     // send display update message
00159     snprintf(msg, sizeof(msg)-1, "!I,%s", message);
00160     sendto(fd, msg, strlen(msg), 0, (struct sockaddr*) &server_addr, sizeof(server_addr));
00161 
00162     LOGPRINTF("Sent message: %s to %s", msg, destination);
00163     
00164     close(fd);
00165     
00166     return 0;
00167 }

Here is the call graph for this function:

Generated by  doxygen 1.6.2-20100208