displayMgr/src/displayMgrClient.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include "liberdm/erdm.h"

Go to the source code of this file.

Defines

#define ERDMG_LOGGING_ON   1
#define ERDMG_WARNING_ON   1
#define ERDMG_ERROR_ON   1
#define ERDMG_LOGPRINTF(x, args...)   fprintf(stderr, "(L)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)
#define ERDMG_WARNPRINTF(x, args...)   fprintf(stderr, "(W)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)
#define ERDMG_ERRORPRINTF(x, args...)   fprintf(stderr, "(E)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)

Functions

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


Define Documentation

#define ERDMG_ERROR_ON   1

Definition at line 35 of file displayMgrClient.c.

#define ERDMG_ERRORPRINTF ( x,
args...   )     fprintf(stderr, "(E)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)

Definition at line 50 of file displayMgrClient.c.

#define ERDMG_LOGGING_ON   1

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

Definition at line 33 of file displayMgrClient.c.

#define ERDMG_LOGPRINTF ( x,
args...   )     fprintf(stderr, "(L)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)

Definition at line 38 of file displayMgrClient.c.

#define ERDMG_WARNING_ON   1

Definition at line 34 of file displayMgrClient.c.

#define ERDMG_WARNPRINTF ( x,
args...   )     fprintf(stderr, "(W)" __FILE__ ":%d,%s() " x "\n", __LINE__, __func__ , ##args)

Definition at line 44 of file displayMgrClient.c.


Function Documentation

void displayHelp (  ) 

Definition at line 56 of file displayMgrClient.c.

00057 {
00058     printf("Usage: displayMgrClient -<option> <argument>\n");
00059     printf("  no arguments : send messages to local loop\n");
00060     printf("  -d <dotted decimal ip address> : send messages to ip address\n");
00061     printf("  -h : display this message\n");
00062     printf("  -p : test of partial update\n");
00063     printf("  -r <seconds> : repeat a full update every <seconds>\n");
00064     printf("  -t : update toolbar area\n");
00065 }

int main ( int  argc,
char **  argv 
)

Definition at line 67 of file displayMgrClient.c.

00068 {
00069     char    szDestination[INET_ADDRSTRLEN];
00070     char    szLocalLoop[] = "127.0.0.1";
00071     int     fUserAddress = 0;
00072     int     fRepeat = 0;
00073     int     fTest = 0;
00074     int     fToolbarUpdate = 0;
00075     int     nArg = 1;
00076     int     ret;
00077     int     nRepeatAfterSeconds = 0;
00078 
00079     // Send messages to local loop
00080     fUserAddress = 0;
00081 
00082     // Work our way through all possible options.
00083     // Currently options are of the form 
00084     // -option <argument>
00085     // -option
00086     while (nArg < argc)
00087     {
00088         if (argv[nArg][0] == '-')
00089         {
00090             switch (argv[nArg][1])
00091             {
00092             case 'h':
00093                 displayHelp();
00094                 return 0;
00095                 break;
00096 
00097             case 'd':
00098                 fUserAddress = 1;
00099                 // What address ?
00100                 if (++nArg >= argc)
00101                 {
00102                     // Not enough arguments supplied.
00103                     ERDMG_ERRORPRINTF("Supply a dotted decimal ip address after option -d");
00104                     displayHelp();
00105                     return -1;
00106                 }
00107                 else
00108                 {
00109                     strncpy(szDestination, argv[nArg], INET_ADDRSTRLEN);
00110                     nArg++;
00111                 }
00112                 break;
00113 
00114             case 'r':
00115                 fRepeat = 1;
00116                 // After how much seconds ?
00117                 if (++nArg >= argc)
00118                 {
00119                     // Not enough arguments supplied.
00120                     ERDMG_ERRORPRINTF("Supply seconds after option -r");
00121                     displayHelp();
00122                     return -1;
00123                 }
00124                 else
00125                 {
00126                     char   *pDummy;
00127                     long    lSeconds;
00128 
00129                     lSeconds = strtol(argv[nArg], &pDummy, 10);
00130                     if (pDummy == argv[nArg])
00131                     {
00132                         // Conversion failed.
00133                         ERDMG_ERRORPRINTF("Please specify a positive integer larger than 1 after -r option.");
00134                         displayHelp();
00135                         return -1;
00136                     }
00137                     else if (lSeconds < 1)
00138                     {
00139                         // Period too small
00140                         ERDMG_ERRORPRINTF("Please specify a positive integer larger than 0 after -r option.");
00141                         displayHelp();
00142                         return -1;
00143                     }
00144                     else
00145                     {
00146                         nRepeatAfterSeconds = (int) lSeconds;
00147                     }
00148                     nArg++;
00149                 }
00150                 break;
00151 
00152             case 'p':
00153                 fTest = 1;
00154                 nArg++;
00155                 break;
00156 
00157             case 't':
00158                 fToolbarUpdate = 1;
00159                 nArg++;
00160                 break;
00161 
00162             default:
00163                 ERDMG_ERRORPRINTF("Option %s not known.", argv[nArg]);
00164                 displayHelp();
00165                 return -1;
00166             }
00167         }
00168         else
00169         {
00170             ERDMG_ERRORPRINTF("Argument supplied not proceded by option.");
00171             displayHelp();
00172             return -1;
00173         }
00174     }
00175 
00176     if (fUserAddress == 1)
00177     {
00178         ERDMG_WARNPRINTF("Server address %s", szDestination);
00179     }
00180     else
00181     {
00182         strncpy(szDestination, szLocalLoop, INET_ADDRSTRLEN);
00183         ERDMG_WARNPRINTF("Server address %s", szDestination);
00184     }
00185 
00186     ret = dmMessageInit(szDestination);
00187     if (ret != 0)
00188     {
00189         ERDMG_ERRORPRINTF("Failed to initialize messaging.");
00190         return -1;
00191     }
00192 
00193     if (fTest == 1 || fToolbarUpdate == 1)
00194     {
00195         if (fTest == 1)
00196         {
00197             // Partial update test
00198             dmDisplayPartial(dmCmdPriorNormal, dmQFull, 100, 100, 300, 300);
00199             sleep(4);
00200             dmDisplayPartial(dmCmdPriorNormal, dmQFull, 500, 700, 700, 900);
00201             sleep(4);
00202         }
00203         if (fToolbarUpdate == 1)
00204         {
00205             // Update toolbar area
00206             dmDisplayPartial(dmCmdPriorNormal, dmQFull, 4, 996, 700, 1020);
00207             sleep(4);
00208         }
00209     }
00210     else
00211     {
00212         dmDisplay(dmCmdPriorNormal, dmQFull);
00213     }
00214 
00215     if (fRepeat == 1)
00216     {
00217         while (1)
00218         {
00219             dmDisplay(dmCmdPriorUrgent, dmQTyping);
00220             sleep(nRepeatAfterSeconds);
00221         }
00222     }
00223 
00224     return 0;
00225 }

Here is the call graph for this function:


Generated on Sun Dec 14 17:14:18 2008 by  doxygen 1.5.6