#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <ctype.h>
#include "eripc.h"
#include "eripcclient.h"
#include "eripcconnect.h"
#include "eripcparser.h"
Go to the source code of this file.
Functions | |
int | cnGotoPage (erClientChannel_t channel, int page) |
int | cnParseCommand (char *szCommand, erIpcCmd_t *pCmd) |
int cnGotoPage | ( | erClientChannel_t | channel, | |
int | page | |||
) |
Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.
Definition at line 40 of file eripcconnect.c.
00041 { 00042 erIpcCmd_t cmd; 00043 00044 strcpy(cmd.name, "cnGotoPage"); 00045 cmd.cc = (int) ccCnGotoPage; 00046 cmd.nArg = 1; 00047 sprintf(cmd.arg[0], "%d", page); 00048 00049 return erIpcSndCommand(channel, &cmd); 00050 }
int cnParseCommand | ( | char * | szCommand, | |
erIpcCmd_t * | pCmd | |||
) |
Definition at line 56 of file eripcconnect.c.
00057 { 00058 int i; 00059 char *pChar; 00060 int cmdcode; 00061 char szToken[TB_MAXCHARONLINE]; 00062 int nReqArgs = 0; 00063 00064 pCmd->cc = (int) ccCnUndefined; 00065 for (i = 0; i < TB_N_ARG; i++) 00066 { 00067 strcpy(pCmd->arg[i], ""); 00068 } 00069 00070 // Parse Command 00071 pChar = szCommand; 00072 i = 0; 00073 while (*pChar != '\0') 00074 { 00075 szToken[i] = '\0'; 00076 if (*pChar == ',') 00077 { 00078 pChar++; 00079 break; 00080 } 00081 szToken[i] = *pChar++; 00082 i++; 00083 szToken[i] = '\0'; 00084 } 00085 00086 // We have found the command Token. Figure out what the command is. 00087 // TODO: stop doing this hardcoded, rely on a smart datastructure instead. 00088 00089 if (isdigit(szToken[0])) 00090 { 00091 cmdcode = atoi(szToken); 00092 } 00093 else 00094 { 00095 cmdcode = -1; 00096 } 00097 00098 if (!strcmp(szToken, "cnGotoPage") || !strcmp(szToken, "0")) 00099 { 00100 strcpy(pCmd->name, szToken); 00101 pCmd->cc = (int) ccCnGotoPage; 00102 nReqArgs = 1; 00103 pCmd->nArg = 1; 00104 } 00105 else if (strcmp(szToken, "cnToolbar") == 0 || cmdcode == ccCnToolbar) 00106 { 00107 strcpy(pCmd->name, szToken); 00108 pCmd->cc = (int) ccCnToolbar; 00109 nReqArgs = 2; 00110 pCmd->nArg = 2; 00111 } 00112 else if (strcmp(szToken, "cnToolbarSync") == 0 || cmdcode == ccCnToolbarSync) 00113 { 00114 strcpy(pCmd->name, szToken); 00115 pCmd->cc = (int) ccCnToolbarSync; 00116 nReqArgs = 0; 00117 pCmd->nArg = 0; 00118 } 00119 else 00120 { 00121 strcpy(pCmd->name, "Undefined"); 00122 pCmd->cc = (int) ccCnUndefined; 00123 fprintf(stderr, "%s: Command %s \n", __FUNCTION__, szToken); 00124 fprintf(stderr, "Error parsing (%s). Command undefined\n", szCommand); 00125 pCmd->nArg = -1; 00126 return -1; 00127 } 00128 00129 if (nReqArgs > 0) 00130 { 00131 erIpcGetArgs(pChar, pCmd, nReqArgs); 00132 } 00133 return 0; 00134 }