X-Git-Url: https://git.jankratochvil.net/?p=gnokii.git;a=blobdiff_plain;f=common%2Fdata%2Fat-emulator.c;h=41445c844fe38d48665efd19cd48f7bfd9d8652a;hp=5f84b0bada58865c380a19ce1e8f3ea179b3034c;hb=0484268a27be1ab830d087847d830bc0ec734016;hpb=975a83d253eea8aa37bf3dfd7e026df3027db4ff diff --git a/common/data/at-emulator.c b/common/data/at-emulator.c index 5f84b0b..41445c8 100644 --- a/common/data/at-emulator.c +++ b/common/data/at-emulator.c @@ -14,8 +14,6 @@ */ -#include "config.h" - #define __data_at_emulator_c @@ -52,32 +50,28 @@ bool ATEM_Initialised = false; /* Set to true once initialised */ extern bool CommandMode; extern int ConnectCount; -static char ModelName[80]; /* This seems to be needed to avoid seg-faults */ -static char PortName[80]; +char ModelName[80]; /* This seems to be needed to avoid seg-faults */ +char PortName[80]; /* Local variables */ -extern int PtyRDFD; /* File descriptor for reading and writing to/from */ -extern int PtyWRFD; /* pty interface - only different in debug mode. */ - -static u8 ModemRegisters[MAX_MODEM_REGISTERS]; -static char CmdBuffer[MAX_CMD_BUFFERS][CMD_BUFFER_LENGTH]; -static int CurrentCmdBuffer; -static int CurrentCmdBufferIndex; -static bool VerboseResponse; /* Switch betweek numeric (4) and text responses (ERROR) */ -static char IncomingCallNo; -static int MessageFormat; /* Message Format (text or pdu) */ +int PtyRDFD; /* File descriptor for reading and writing to/from */ +int PtyWRFD; /* pty interface - only different in debug mode. */ -static void ATEM_ParseAT(char *cmd_buffer); +u8 ModemRegisters[MAX_MODEM_REGISTERS]; +char CmdBuffer[MAX_CMD_BUFFERS][CMD_BUFFER_LENGTH]; +int CurrentCmdBuffer; +int CurrentCmdBufferIndex; +bool VerboseResponse; /* Switch betweek numeric (4) and text responses (ERROR) */ +char IncomingCallNo; +int MessageFormat; /* Message Format (text or pdu) */ /* Current command parser */ -static void (*Parser)(char *); +void (*Parser)(char *); //void (*Parser)(char *) = ATEM_ParseAT; /* Current command parser */ -static GSM_MemoryType SMSType; -static int SMSNumber; - -static void ATEM_InitRegisters(void); +GSM_MemoryType SMSType; +int SMSNumber; /* If initialised in debug mode, stdin/out is used instead of ptys for interface. */ @@ -118,7 +112,7 @@ bool ATEM_Initialise(int read_fd, int write_fd, char *model, char *port) } /* Initialise the "registers" used by the virtual modem. */ -static void ATEM_InitRegisters(void) +void ATEM_InitRegisters(void) { ModemRegisters[REG_RINGATA] = 0; @@ -143,7 +137,6 @@ void ATEM_CallPassup(char c) } } -static void ATEM_StringOut(char *buffer); /* Handler called when characters received from serial port. calls state machine code to process it. */ @@ -184,13 +177,9 @@ void ATEM_HandleIncomingData(char *buffer, int length) } } -static bool ATEM_CommandPlusC(char **buf); -static bool ATEM_CommandPlusG(char **buf); -static int ATEM_GetNum(char **p); -static void ATEM_ParseSMS(char *cmd_buffer); /* Parser for standard AT commands. cmd_buffer must be null terminated. */ -static void ATEM_ParseAT(char *cmd_buffer) +void ATEM_ParseAT(char *cmd_buffer) { char *buf; char number[30]; @@ -376,10 +365,8 @@ static void ATEM_HandleSMS() return; } -static void ATEM_ParseDIR(char *cmd_buffer); - /* Parser for SMS interactive mode */ -static void ATEM_ParseSMS(char *buff) +void ATEM_ParseSMS(char *buff) { if (!strcasecmp(buff, "HELP")) { ATEM_StringOut(_("\n\rThe following commands work...\n\r")); @@ -404,7 +391,7 @@ static void ATEM_ParseSMS(char *buff) } /* Parser for DIR sub mode of SMS interactive mode. */ -static void ATEM_ParseDIR(char *buff) +void ATEM_ParseDIR(char *buff) { switch (toupper(*buff)) { case 'P': @@ -428,7 +415,7 @@ static void ATEM_ParseDIR(char *buff) /* Handle AT+C commands, this is a quick hack together at this stage. */ -static bool ATEM_CommandPlusC(char **buf) +bool ATEM_CommandPlusC(char **buf) { float rflevel; GSM_RFUnits rfunits = GRF_CSQ; @@ -528,7 +515,7 @@ static bool ATEM_CommandPlusC(char **buf) switch (**buf) { case '=': buf[0]++; - index = atoi(*buf); + sscanf(*buf, "%d", &index); buf[0] += strlen(*buf); error = ATEM_ReadSMS(index, SMSType, &message); @@ -612,7 +599,7 @@ static bool ATEM_CommandPlusC(char **buf) } /* AT+G commands. Some of these responses are a bit tongue in cheek... */ -static bool ATEM_CommandPlusG(char **buf) +bool ATEM_CommandPlusG(char **buf) { char buffer[MAX_LINE_LENGTH]; @@ -698,7 +685,7 @@ void ATEM_ModemResult(int code) /* Get integer from char-pointer, set pointer to end of number stolen basically verbatim from ISDN code. */ -static int ATEM_GetNum(char **p) +int ATEM_GetNum(char **p) { int v = -1; @@ -712,7 +699,7 @@ static int ATEM_GetNum(char **p) /* Write string to virtual modem port, either pty or STDOUT as appropriate. This function is only used during command mode - data pump is used when connected. */ -static void ATEM_StringOut(char *buffer) +void ATEM_StringOut(char *buffer) { int count = 0; char out_char;