smsclient-2.0.8z/0000755000175000017500000000000011007610112013571 5ustar noodlesnoodlessmsclient-2.0.8z/docs/0000755000175000017500000000000010127274501014533 5ustar noodlesnoodlessmsclient-2.0.8z/docs/sms_address.10000644000175000017500000000202010127274501017116 0ustar noodlesnoodles.TH sms_address 1 "22 March 2004" Linux "User Manuals" .SH NAME sms_address \- Lookup and expand an sms_client address. .SH SYNOPSIS .B sms_address [-v] .br .B sms_address [-l loglevel] [-d delimiter] name[,name] .br .SH DESCRIPTION A simple program to lookup names/aliases defined to sms_client. .SH OPTIONS .TP .IB -l All messages output are appended to /var/log/smsclient.log, there are several level of logging. The default .IB loglevel is STANDARD other logging levels provided include. .sp .RS +.2i .ta 1.0i .nf 1 - ERROR 2 - WARNING 3 - STANDARD 4 - VERBOSE 5 - EXTREMELY VERBOSE .fi .RE .sp .TP .IB -v Print version information. .TP .IB -d delimiter Change the delimiter used to separate the name/service/number details from the default of :. .TP .IB name[,name] The name(s) to lookup in the address book. .SH OUTPUT If the name is found in the address book it will be printed as: .IB name:service:number If the name is in fact an alias one line will be printed for each number that alias expands to. .SH VERSION 2.0.8z smsclient-2.0.8z/docs/sms_client.10000644000175000017500000000776510127274501016774 0ustar noodlesnoodles.TH sms_client 1 "19 Oct 1998" Linux "User Manuals" .SH NAME sms_client \- send messages to mobiles and pagers. .SH SYNOPSIS .B sms_client [-v] .br .B sms_client [-d] .br .B sms_client [-q] [-l loglevel] .br [service:]number|name[,[service:]number|name] .br [message] ... .SH DESCRIPTION A simple client implementation for the GSM Short Message Service (SMS) using TAP. Allowing you to send messages to mobile phones and pagers. Several drivers have also been written for providers who use protocols other than TAP. This client dials the Short Message Service centre and passes on your message addressed to the .IB number or .IB name you specified. Any .IB name you use is expanded to the .IB number from either the Local or Global resource files. The Local file is searched first then the Global file. A user can set up his own preferences to overide those set in the Global file. Information regarding the status of the call is displayed, along with the response given by the SMS centre as the message is transmitted. If no message is present, sms_client takes the message from standard input. .SH OPTIONS .TP .IB -q Quiet mode, no output. .TP .IB -l All messages output are appended to /var/log/smsclient.log, there are several level of loggin. The default .IB loglevel is STANDARD other loggin levels provided include. .sp .RS +.2i .ta 1.0i .nf 1 - ERROR 2 - WARNING 3 - STANDARD 4 - VERBOSE 5 - EXTREMELY VERBOSE .fi .RE .sp .TP .IB -v Print version information. .TP .IB -d Print all driver/protocols currently built into sms_client. .TP .IB [service:]number|name[,[service:]number|name] A name can be used instead of a number, if a name is used it is searched for in the Global and Local resource files and replaced by the number. You can group names and numbers but they must be seperated by a comma and must contain no whitespace. Numbers must be in International format. For UK Numbers remove leading 0 and add 44 prefix. If a number is prefixed with service: then that service is used in preference to the default service. .TP .IB [message] ... A Quoted message that you want to send. If this is absent the message is read from stdin. The maximum length of the message is currently set to a limit of 150 characters, if your message exceeds this length you will be notified with an error message. .SH RETURN VALUES On Success the return value is set to zero. Any other value indicates an error occurred. Each number dialed will have a corresponding output of the form: .IB [###] SERVICE:NUMBER Where ### is the delivery code, 000 indicates successful delivery other values can be found in sms_error.h .SH EXAMPLES .TP .IB "sms_client 123456 'Hello 123456'" Use default service and send message to 123456 .TP .IB "sms_client mike 'Hello mike'" Use default service and send message to number associated with name mike found in one of the resource files. .TP .IB "sms_client mike,angelo 'Hello mike and angelo'" Use default service and send message to number associated with names mike and angelo found in one of the resource files. .SH FILES .TP .IB /etc/smsclient/sms_addressbook The Global addressbook file. Containing names and numbers. .TP .IB ~/.sms_addressbook The Local addressbook file. Contains names and numbers which can override those in the Global resource file. .TP .IB /etc/smsclient/sms_config Containing default service and other sms_client defaults. .TP .IB /etc/smsclient/sms_services Containing service to protocol mappings. .TP .IB /etc/smsclient/sms_modem Containing default modem settings. .TP .IB /etc/smsclient/services Directory containing all services - Each service is denoted by filename (in UPPERCASE) and contains defaults for that service, such as telephone number of service centre, comms params etc. .TP .IB /var/lock/smslock Lockfile generated when smsclient is running. .TP .IB /var/log/smslog Log file where all messages that are produced are copied. .SH AUTHOR Angelo Masci changed by Michael Holzt for the Debian/GNU Linux Package .SH VERSION 2.0.7 smsclient-2.0.8z/docs/sms_protocol0000644000175000017500000000452610127274501017210 0ustar noodlesnoodles SMS Daemon protocol 1998-1999 v0.1 ================================== Proposal for SMS Daemon protocol. This is a TCP-based protocol. The SMS Daemon listens on port XXXX. All commands are 4 characters long and are case insensitive. Operands are seperated by a single ASCII space character. The end of the command is indicated with an ASCII line feed character. ---------------------------------------- - '\r\n' or '\n' USER - string HOST - string JOB ID - integer expressed in ascii LENGTH - integer expressed in ascii represents the number of bytes of data that are to follow DATA - 8 Bit Data QUEUE NAME - String, no whitespace STATUS - A string of character no containing a USER ADDR - rfc complient address of user to send mail when this message has been sent - sucessfully or unsucessfully ---------------------------------------- Note '<-- ' indicates direction of data from client to SMS Server '--> ' indicates direction of data from SMS Server to client <-- USERUSER - Receive User Name <-- HOSTHOST - Receive Host Name <-- MAILUSER ADDR - Mail to user when sent <-- DATALENGTHDATA <-- SEND - Send Current Job <-- SENJJOB ID - Send Job <-- SENQQUEUE NAME - Send all jobs in queue <-- SENA - Send all jobs in all queues <-- DESTQUEUE NAME - Select a queue for current job <-- DEFR - Deferr current Job <-- STAJJOB ID - Status of Job <-- STAQQUEUE NAME - Status of queue <-- STAT - Status of all jobs in all queues <-- QUIT - Exit <-- INFO <-- HELP - List commands --> 200SMS Gateway Ready. - Greeting from SMS --> 210Ok. --> 220Goodbye. --> 230 - Help --> 231 - Info --> 232 - Job Status --> 233 - Queue Status --> 234 - General Status --> 500 Error. --> 510 Error Connection Terminated. --> 511 Error Command not understood. XXX- indicates that the resulting Data will be split over serveral lines. End of data is signified by matching XXX without trailing '-' ---------------------------------------- smsclient-2.0.8z/docs/Makefile0000644000175000017500000000365610127274501016205 0ustar noodlesnoodles# This makefile was customized for the use by Debian/GNU Linux # customisation made by Michael Holzt # # -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id: Makefile,v 5.1 1998/02/01 07:12:35 root Exp $ # -------------------------------------------------------------------- include ../Makefile.config # -------------------------------------------------------------------- all: install: uninstall: #all: sms_client.$(MANEXT) # $(CP) sms_client.man sms_client.$(MANEXT) # #install: sms_client.$(MANEXT) # $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -d $(MANDIR)/man$(MANEXT) # $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 644 sms_client.$(MANEXT) $(MANDIR)/man$(MANEXT) # #uninstall: # $(RM) $(MANDIR)/man$(MANEXT)/sms_client.$(MANEXT) # # -------------------------------------------------------------------- smsclient-2.0.8z/Makefile.drivers0000644000175000017500000000560311007610111016711 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.devices # # Copyright (C) 1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # Drivers for several protocols have been written, # This file is automatically generated by running 'configure -drivers' # The drivers listed in the file 'drivers' is formatted and # appended to the bottom of this file. # # # TAP Standard SMS protocol # VODAFONE verbose UK/Australian Telenote protocol # ORANGE verbose UK protocol # PAGEONE verbose UK protocol # ONE2ONE verbose UK protocol # VODACOM verbose South African protocol # MTN verbose South African protocol # LIBERTEL verbose Dutch Libertel protocol # TIM verbose Italian Telecom Italia Mobile protocol # PROXIMUS Belgium protocol # VODAPAGE_BLOCK UK protocol # KPN verbose Dutch protocol # ANSWER verbose protocol # UCP # # SNPP - ALPHA experimental rfc1861 client # CIMD - ALPHA # GENERIC - ALPHA experimental # # -------------------------------------------------------------------- # -------------------------------------------------------------------- DRIVERS=TAP VODAFONE ORANGE PAGEONE ONE2ONE VODACOM MTN LIBERTEL TIM PROXIMUS VODAPAGE_BLOCK KPN ANSWER SNPP CIMD GENERIC UCP UCP_TCP MOBISTAR DRV_OBJ=mobistar.o ucp_tcp.o ucp.o generic.o cimd.o snpp.o answer.o kpn.o vodapage_block.o proximus.o tim.o libertel.o mtn.o vodacom.o one2one.o pageone.o orange.o vodafone.o tap.o DRV_DEF=-DMOBISTAR -DUCP_TCP -DUCP -DGENERIC -DCIMD -DSNPP -DANSWER -DKPN -DVODAPAGE_BLOCK -DPROXIMUS -DTIM -DLIBERTEL -DMTN -DVODACOM -DONE2ONE -DPAGEONE -DORANGE -DVODAFONE -DTAP # -------------------------------------------------------------------- smsclient-2.0.8z/drivers0000644000175000017500000000600110460427624015207 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # drivers # # Copyright (C) 1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # Drivers for several protocols have been written, # include them into the build simply by adding to the # uncommented list below and running 'configure -drivers' # This automatically generates a 'Makefile.drivers' for use # during the complete build. # # All lines starting with a '#' are treated as comments # and will be ignored. # # TAP Standard SMS protocol # VODAFONE verbose UK/Australian Telenote protocol # ORANGE verbose UK protocol # PAGEONE verbose UK protocol # ONE2ONE verbose UK protocol # VODACOM verbose South African protocol # MTN verbose South African protocol # LIBERTEL verbose Dutch Libertel protocol # TIM verbose Italian Telecom Italia Mobile protocol # PROXIMUS Belgium protocol # VODAPAGE_BLOCK UK protocol # KPN verbose Dutch protocol # ANSWER verbose protocol # UCP # ORANGE_WEB Orange's Web based service # CELLNET_WEB Genie's Cellnet Web based service # PROXIMUS_WEB Proximus Web based service # ATT_WEB AT&T Web based service # NEXTEL_WEB Nextel Web based service # PAGENET_WEB Pagenet Web based service # MOBISTAR # # SNPP - ALPHA experimental rfc1861 client # CIMD - ALPHA # GENERIC - ALPHA experimental # WWW - Skeleton for Web driver # UCP_TCP - Initial draft at UCP over LAN ( ALPHA ) # # -------------------------------------------------------------------- TAP VODAFONE ORANGE PAGEONE ONE2ONE VODACOM MTN LIBERTEL TIM PROXIMUS VODAPAGE_BLOCK KPN ANSWER SNPP CIMD GENERIC UCP UCP_TCP MOBISTAR # These are currently known to be broken #ORANGE_WEB #CELLNET_WEB #PROXIMUS_WEB #ATT_WEB #NEXTEL_WEB #PAGENET_WEB #-------------------------------------------------------------------- smsclient-2.0.8z/Changelog0000644000175000017500000004745510127274463015443 0ustar noodlesnoodles19 Mar 2000 Thanks to Shevek for the working Europolitan driver. I reformatted it a little and hope I haven't screwed it up. Added the eirpage service file, thanks to Stephen Farrell as I dont know what the protocol is I'm guessing at TAP please correct me if I'm wrong. -------------------------------------------------------------------- 8 Mar 2000 Added fixes for both the Vodafone and TIM drivers. -------------------------------------------------------------------- 15 Feb 2000 Fixed TAP driver to include german umlauts, thanks Michael Holzt I'm a little unsure if the checksum code also need fixing since I cant test it this end. Can you have a look Michael. -------------------------------------------------------------------- 26 Jan 2000 Started work on UCP over TCP/IP will build a UCP library and hopefully consolidate UCP drivers. Adding support for op51 which might make some people happy. Added new MOBISTAR driver thanks to Will integrate youre scripts and ideas about target installations. -------------------------------------------------------------------- 22 Jan 2000 Tom Barron added some code for draining data that may be present after a modem init. I made some changes and added it to this version. -------------------------------------------------------------------- 15 Jan 2000 Ross Golder added some files to help with RPM based systems. I haven't tried it out since I run Debian here but any feedback would be welcome. Take a look in 'contrib/RPM' Fix to FreeBSD Makefile. It Looks like some 'carriage returns' crept in when I copied it from outlook express folder in windoze. Added Michael Holzt to README for his work on the debian package. -------------------------------------------------------------------- 6 Jan 2000 Added support for HP-UX 11.00 in the configure and make scripts only a successful build report nonone has told me it works yet. Removed sms_strlen, sms_strcat and sms_strcpy will be updating the 'common' directory so that it contains my own printf and sprintf routines. Fixed Vodafone login check, they changed their banner again! Thanks Peter Greinig Fixed Pageone thanks for the info A. James Lewis and updated their new number. -------------------------------------------------------------------- 29 Nov 1999 Fixed vodafone driver so it find the expected NEW vodafone welcome banner, this may not work in australia, someone let me know. Solaris users, see 6 Nov fix. -------------------------------------------------------------------- 7 Nov 1999 Updated 'vodacom' service file so that it uses 8N1 instead of 7E1 Thanks Alf. I noticed that skytel provides an snpp service, can someone using skytel verify that my snpp driver works with this. -------------------------------------------------------------------- 6 Nov 1999 Updated 'src/comms/modem.c' so that DTR is toggled correctly on Solaris. It appears that the POSIX method doesn't seem to work. -------------------------------------------------------------------- 21 Oct 1999 2.0.8u Added ia5 conversion for 'ucp' driver, you should get reasonable character conversions now, thanks to Alexander Grapenthin . The fix was for 2.0.7 but I fitted into this release, as I cannot test this can someone please get back to me and let me know if this works or has broken something. This should make a lot of europeans happy. I would like to change the drivers so they have an extra function for converting messages based on different character sets and even further some regular expression replacement facilities too. -------------------------------------------------------------------- 15 Oct 1999 2.0.8t Added new service 'netcom', thanks to Bjorn Rogeberg. Fixed 'lock.c' so that it now uses stat() instead of access() to determine whether a file or directory exists, since their behaviour differs when used with setuid binaries. Needs testing. -------------------------------------------------------------------- 9 Oct 1999 2.0.8t Added service file for telia, thanks to both Jonas Borgström and Fredrik Björk for the information on this one. Updated the UCP driver, thanks to Chuck Hurd for a rewrite. This is untested with D2 and Swisscom and Telia, can someone get back to me with some feedback. -------------------------------------------------------------------- 6 Oct 1999 2.0.8s Added service file for digifone. Added a new option 'MDM_pause_after_connect' Simply uncomment it from the 'sms_modem' file and it'll cause sms_client to sleep for 3 seconds after receiving the connect string. -------------------------------------------------------------------- 26 Sep 1999 2.0.8r Think I've solved the problem with modem resetting. 'modem.c' c_flags needed 'CLOCAL" Fixed some error messages, now always bails out with EMALLOC on any malloc() failures. -------------------------------------------------------------------- 11 Sep 1999 2.0.8q Added New service files for 'skytel1' and 'skytel2' Thanks for submitting those Kal. Updated 'src/terminal/Makefile' it didn't include 'common.o' anywhere in the link lines for the final binaries. No one spotted this so I assum no one's using the terminal stuff yet. -------------------------------------------------------------------- 20 Aug 1999 Added fix to 'nextel_web' driver, this should now indicate when message have been successfull dispatched and when they cannot be sent for some other reason. -------------------------------------------------------------------- 18 Aug 1999 Removed many references to sprintf() now call sms_snprintf() which uses snprintf() if an implementation is available. Still a few left. Should go through source and check for strlen(), strcpy() and strcat() and do likewise. Working in the GS API making it a lot simpler to use. Must go through and fix as many places as possible that know about the internal parseer structure just to use the API functions. -------------------------------------------------------------------- 17 Aug 1999 Improve environment expansion so that it is possible to include variable in '"' double quoted strings, the syntax is ${ENVVAR} -------------------------------------------------------------------- 16 Aug 1999 2.0.8p Backfitted guard code from 2.0.7s-8 into SMS Client which ensure that the process is killed after a predefined timeout, 'SMS_service_timeout' this is default to 5 minutes. If a call remains connected for longer than this time the process is forcibly killed. This is ONLY a last ditch method as the client should timeout on ALL read/writes that are made. If your 'sms.log' file contains a message of the form "Forcibly Terminated Process" then I would be interested in hearing from you. This was quite an involved fix to 'src/client/sms_client.c' but it gave it a little facelift that I think it was beginning to need. Remember to update ALL web based interface so that they return useful error results. Looks like I missed the edit in 'sms/sms_modem' from 14-Aug-1999 I've readded the 'MDM_lock_platform = "SOLARIS"' option. Added Solaris hardware flow control option, 'c_cflag |= CRTSCTS' to 'src/comms/modem.c' I have no way of testing this. Added simple environment variable substitution to the parse. You can now have statements such as 'home = $HOME' in config files. -------------------------------------------------------------------- 15 Aug 1999 Updated FAQ. Updated 'src/comms/url.c' so that it doesn't core dump is pasted an empty url. Added NEW 'pagenet_web' and 'nextel_web' services. Again, any feedback appreciated. The pagenet service will require a valid terminal and I don't have any info on these yet. -------------------------------------------------------------------- 14 Aug 1999 Added NEW att_web service. Again, as with the proximus_web driver it hasn't been tested and I'd appreciate feedback. Added comment to 'sms/sms_modem' concerning solaris. If we want to have solaris compatible lockfiles we MUST set a flag in this file. Changed number for 'DETEMOBIL' to '0171 2521002' thanks norbert.wegener@sbs.de. Can someone verify that this is correct. Adding web based services is pretty simple, all I need is beta testers, web page addresses and a little time to write the drivers. The simplest way to do this is to build the 'snoop' tool found in 'src/terminal' just cd 'src/terminal' and 'make'. run it on your machine pointing it a http_proxy server. ./snoop 4040 proxyserver 8080 Where 8080 is the port your proxy listens on, set your browser to user a proxy and point it at 'localhost 4040' now all data is being past through 'snoop' which logs activity in 'logs/snoop.log' on sending a successful message you should have enough info to build your own driver or to send to myself who'll try to build one for you ;) Added NEW proximus_web service. This is currently untested and I need some betas testers. There are some fields that I'm unsure about on the web page so I left blank, this probably won't work without a little tweaking. Added driver update to 'tim.c' the Italian TIM service should now work again, thanks to adrieder@sbox.tu-graz.ac.at Split 'src/driver/driver.c' into two files driver.c driver_comms.c There was no real need to have comms specific in 'driver.c' starting to abstract transport by moving 'server, server_port' into 'device' this will be replaced by a 'pointer to driver' for which data can be extracted. Through calls to an interface, ie. 'get_info' -------------------------------------------------------------------- 11 Aug 1999 Added two NEW services 'cellnet_web' and 'orange_web' these both connect to web servers and pass data as though it were submitted via a browser. These require that you're connect to the internet to work. They will work through a proxy gateway but you must set and environment variable HTTP_PROXY=http://yourproxy:8080/ to be able to use it. You MUST obtain user account from these service before they can be used. I'll post the method for obtaining the cellnet info when I get a chance. The mechanism for handling different transport mediums need implementing as the above drivers look a little like a cludge, having properties to do with modems in them! I will eventually abstract the transport mechanism completely so we switch between different mechanisms more easily, honest. -------------------------------------------------------------------- 6 Aug 1999 2.0.8n Fix for 'proximus' driver. Added check for 'connected\r\n' preamble from 'proximus' service centre before sending any messages. It looks like this 'FEATURE' was added to proximus recently. Various edits in 'src/parser' to extend variables so that numbers as well as quoted strings can be assigned to them. The numbers MUST fit into a long, so it useful for things like flags, buad etc but NOT for telephone numbers. Use quoted strings for these. Updated service files so that value are only quoted for telephone numbers. Couple of small additions to the FAQ. Removed the '.sh' extenstion from the 'configure' script. Added version string to all drivers. Should help when having to identify problems. -------------------------------------------------------------------- 1 Aug 1999 2.0.8m Added new BT Message Master service, thanks to David Ockwell-Jenner. Make sure we get the version string correct the last one 2.0.8k was appearing as 2.0.8j. Looks like that orange hangup problem may have been at orange's end. minicom did the same, they appear to have set their timeouts ridiculously low, I couldn't type in my responses fast enough from minicom! It shouldn't take much work to generate scripts usable via the generic driver from this. Take a quick peek at 'sms/scripts/email' and you'll see what I mean. Tiny corrections to the FAQ. -------------------------------------------------------------------- 23 Jul 1999 version 2.0.8k Released previous version with an incomplete list of drivers in the 'drivers' file. Oooops. MDM_response routine confuses RINGING with RING. Placed RINGING before RING in your response_list array as per request from matt. Updated README to include matt, cheers. Re-ordered entries in this file so you don't have to scroll right to the bottom. Added message saying what locking mechanism was being used in 'modem.c' remember that to use solaris style locking under solaris you MUST change the file '/etc/sms/modems' see the comments in that file. SMS Client should now build with 'make's other than GNU now that some 'ifeq' conditions have been removed. Solaris has been tested, also the Makefile.config for solaris no longer defaults to gcc. You can override this with: make MAKE=gmake CC=gcc Added copyleft to file in 'src/terminal' and updated Makefile so that you can build them. Still commented out in the main make. These are to add a simple way of capturing protocol info and generating driver file automagically. Some of the way there, 'mdup' is a simple command line dialer which logs client/server data. Though it need attention, 'orange' hangs up after sending some data... -------------------------------------------------------------------- 20 Jul 1999 Version 2.0.8j Updated all makefiles so that make appears as $(MAKE) Updated ./configure.sh to include the generation of 'Makefile.drivers' This means that you don't need such a clever version of make as a script is used to generate the list of drivers to build instead of being done dynamically from withing the makefile. Placed dependencies on file 'drivers' and 'Makefile.drivers' such that any edits cause 'driver.a' to be subsequently rebuilt with the correct drivers. Hey this actually works!!! Change 'ar' to $(AR) and set value to 'ar -rc' for all platforms except NEXT where it appears as 'ar rc' Added RANLIB to Makefile.config for all platform except NEXT we just 'echo' I'm unsure whether it's strictly necessary to use ranlib and would welcome some feedback on this. The script 'configure.sh' can be used to modify aspects of the build such as drivers to include and modem library to build/link against. Usage: ./configure.sh [-help] [-drivers] [-modemlib [smsmodem|libmodem]] With no options the defaults 'ALL driver and smsmodem' are selected. After a build you can edit the file 'drivers' to remove unecessary drivers and simply rebuild wih 'make' the makefiles should take care of themselves. You can also specify a different modem library after a build and simply use 'make'. -------------------------------------------------------------------- 18 Jul 1999 Version 2.0.8i Fixed a bug in 'lock.c' which was introduced by last fix in 2.0.8h The code that was reading the pid was setting it to -1 even when it was valid! Also made some changes to the directory layout. Moving 'logfile' and 'common' into their own directories. This makes working on seperate projects that use these files simpler. Maybe I'll move 'error.h' too at somepoint. Reminder, don't prefix any defines with 'E' the 'bumper big boys book' on posix says this is a bad idea. -------------------------------------------------------------------- 02 Jul 1999 Version 2.0.8h Added new "nz" service for Telecom New Zealand. Cheers Robbie for that one. Fixed a bug in 'lock.c' which was never closing a file in the function resource_lock_pid()! Thanks Sergio. -------------------------------------------------------------------- 13 Jun 1999 Added new 'vodafone_tap' service for Mark Good Luck -------------------------------------------------------------------- 11 Jun 1999 Fix to 'gs_token.c' so that in compiles on the Linux REDHAT distribution. Anyone want to tell me what the problem was? -------------------------------------------------------------------- 05 Jun 1999 Fixed problem where switching from 7E1 to 8N1 and back again doesn't screws up parity settings for device. Edits to 'expect.c' prints 'Received Character:' and 'Received String:' message which is now less confusing. Added version info so I can see which version is being used when I get log dumps from people. -------------------------------------------------------------------- 27 Apr 1999 Terminal 'c_cflags' were not being cleared during initialisation. This meant that the flags used from last setting were being used, this ocurred most notibly by user switching from 8N1 to 7E1 and back between different services. Thanks to Gareth Abel for spotting this one. Added new options 'MDM_restore_terminal' to restore the orginal terminal settings on close. and 'MDM_pause_before_dial' to wait after initialisation before dialing, should fix some USR problems. -------------------------------------------------------------------- 24 Apr 1999 'smsd' now generates a lockfile in the '/var/spool/sms/locks' directory of the form 'smsd.pid' along with 'snppd' which now does the same. This falles in line with the queue daemons which also have 'SERVICE.pid' lockfiles. Started working on 'init.d/smsd' an init script for starting and stoping 'smsd' and associated queue daemons. Now that 'smsd' generates lockfiles along with the queue daemons it's easier to stop and start it. Note that to stop 'smsd' you should send it a TERM signal so that it can clean up after itself. -------------------------------------------------------------------- 22 Apr 1999 Ammended expect.c to use sigaction() instead of signal() and rewrote expread() and expwrite(), cheers chris. Added SCO definitions of NAME_MAX and PATH_MAX to 'expand.c' also changed SMS_open_local_smsrc() to allocate filename on the fly as NAME_MAX and PATH_MAX may be functions. -------------------------------------------------------------------- 20 Apr 1999 Ammended modem.c so that we can now uses new config options 'MDM_dtr_hangup_sleep' and 'MDM_dtr_init_sleep' Added call to toggle_DTR() prior to any initialisation. -------------------------------------------------------------------- 11 Feb 1999 Ammended Makefile.config to include PREFIX = SPOOLDIR = SMSUSER = SMSGROUP = -------------------------------------------------------------------- 08 Jan 1999 Changed ALL config files so that they use the NEW parser. This is quite a major change and hence the jump to 2.0.8 Config files are now in lower case and their format has changed considerably. -------------------------------------------------------------------- 07 Jan 1999 Created new 'comms' directory, moving all comms related functionality. Now builds to 'comms.a' -------------------------------------------------------------------- 05 Jan 1999 Added 'RINGING' detection code in 'src/client/sms_modem.c' New flags include 'MDM_max_rings' Changed files 'src/driver/driver.c' 'src/driver/driver.h' to further abstract driver code. The drivers are passed pointers to functions which provide access to the list of messages passed. Changed file 'src/client/sms_client.c' to use the NEW driver functionality by adding access_* functions. The main reason for this change is the queueing daemon will use the driver but processes it's message lists differently. Now the driver can handle either method, it just calls the functions passed to it to deal with getting first/next messages. -------------------------------------------------------------------- 04 Jan 1999 Added new flags to 'src/client/sms_modem.c' To allow support for lockfilesof serial devices on Solaris 2.5.1 New flags include 'MDM_lock_platform' setting it to 'SOLARIS' instead of 'TRADITIONAL' produces a dotted notation. -------------------------------------------------------------------- 22 Dec 1998 Added telephone numbers to 'sms/services/SWISSCOM' file. Changed 'src/drivers/ucp.c' so it responds to positive ACK correctly. -------------------------------------------------------------------- 01 Dec 1998 Changed 'src/drivers/ucp.c' parse UCP response code added. -------------------------------------------------------------------- smsclient-2.0.8z/.configured0000644000175000017500000000000011007610111015704 0ustar noodlesnoodlessmsclient-2.0.8z/TODO0000644000175000017500000000113410127274464014302 0ustar noodlesnoodlesSuggestion from 'Jeremy Laidman' Look at 'sysexits.h' making life simpler to live with sendmail. Everyone is asking me to look at using syslog() for loggin messages. Get characters translation scheme working for UCP and other services. Sort out smsmodem - toggle DTR on modem init. Finish queue daemon so that '-a' flag outputs all ENABLED services from the 'sms_daemons' file. Finish init.d script for smsd. Note 'smsd' is UNFINISHED. Place all source under CVS Get TAP vodafone service working Look into errno 5 on writes with solaris users. Setup meaningful return values for web interfaces. smsclient-2.0.8z/README.1ST0000644000175000017500000000157610127274463015111 0ustar noodlesnoodlesVersion 2.0.8 ============= Version 2.0.8 differs from 2.0.7 most noteable in that the configuration file syntax has changed. The service files are now all in lower case, the easiest way to install this version if you have 2.0.7 already installed is simply to move /etc/sms to /etc/sms.orig and install this version, the news files will be placed in /etc/sms leaving your originals alone. When calling a service use the lower case name, for example. sms_client minicall:angelo "SMS Client-2.0.8f Test EMAIL_ADDRESS" This version does not offer the same level of protect that 2.0.7s-7 has over forcefully hanging up by killing children that have been sitting waiting for too long. I'll fit the code as soon as I get a chance. 6 Jan 2000 - The code to force hanging up has been backfitted you can now consider the 2.0.8 releases as useable as the 2.0.7 releases. smsclient-2.0.8z/configure0000755000175000017500000001550710127274473015532 0ustar noodlesnoodles#!/bin/sh # -------------------------------------------------------------------- # -------------------------------------------------------------------- AWK=awk TR=tr TOUCH=touch # -------------------------------------------------------------------- if [ $# -ge 1 ] then case $1 in -drivers) shift if [ $# -ge 1 ] then echo "Usage: $0 [-help] [-drivers] [-modemlib [smsmodem|libmodem]]" 1>&2 exit 1 fi echo echo "Generating file 'Makefile.drivers' from file 'drivers'..." cp config/Makefile.drivers Makefile.drivers if [ $? -ne 0 ] then echo "ERROR: 'cp config/Makefile.drivers Makefile.drivers' failed" 1>&2 exit 1 fi drivers=`$AWK '!/^#/ && !/^$/ { print $1 }' drivers` drivers=`echo $drivers` for driver in $drivers do drv_def="-D$driver $drv_def" driver=`echo $driver | $TR '[A-Z]' '[a-z]'`.o drv_obj="$driver $drv_obj" done echo "# --------------------------------------------------------------------" >>Makefile.drivers echo >>Makefile.drivers echo "DRIVERS=$drivers" >>Makefile.drivers echo "DRV_OBJ=$drv_obj" >>Makefile.drivers echo "DRV_DEF=$drv_def" >>Makefile.drivers echo >>Makefile.drivers echo "# --------------------------------------------------------------------" >>Makefile.drivers echo "Done." exit 0 ;; -modemlib) libmodem=1 smsmodem=2 shift if [ $# -ge 1 ] then if [ $# -gt 1 ] then echo "Usage: $0 [-help] [-drivers] [-modemlib [smsmodem|libmodem]]" 1>&2 exit 1 fi modemlib=$1 else echo echo "SMS Client can optionally be compiled against:" echo echo echo " 1. Libmodem - A third party modem library" echo " 2. SMSModem - The internal modem library" echo modemlib= while [ "X-$modemlib" = "X-" ] do echo "Please make a selection [1,2]:" read selection case "$selection" in 1) modemlib=libmodem ;; 2) modemlib=smsmodem ;; *) echo "ERROR: Invalid selection" 1>&2 ;; esac done fi case $modemlib in libmodem) modemlib=$libmodem mlibs=-lmodem ;; smsmodem) modemlib=$smsmodem mlibs= ;; *) echo "Usage: $0 [-help] [-drivers] [-modemlib [smsmodem|libmodem]]" 1>&2 exit 1 esac echo echo "Generating file 'Makefile.modemlib'..." cp config/Makefile.modemlib Makefile.modemlib if [ $? -ne 0 ] then echo "ERROR: 'cp config/Makefile.modemlib Makefile.modemlib' failed" 1>&2 exit 1 fi echo "# --------------------------------------------------------------------" >>Makefile.modemlib echo >>Makefile.modemlib echo "SMSMODEM = $smsmodem" >>Makefile.modemlib echo "LIBMODEM = $libmodem" >>Makefile.modemlib echo >>Makefile.modemlib echo "# --------------------------------------------------------------------" >>Makefile.modemlib echo >>Makefile.modemlib echo "MODEMLIB = $modemlib" >>Makefile.modemlib echo "MLIBS = $mlibs" >>Makefile.modemlib echo >>Makefile.modemlib echo "# --------------------------------------------------------------------" >>Makefile.modemlib echo "Done." exit 0 ;; -h|-help) echo "Usage: $0 [-help] [-drivers] [-modemlib [smsmodem|libmodem]]" exit 0 ;; *) echo "Usage: $0 [-help] [-drivers] [-modemlib [smsmodem|libmodem]]" 1>&2 exit 1 esac fi if [ -f ".configured" ] then echo "" echo "You have already run 'configure'" echo "running it again will overwrite 'Makefile', 'Makefile.drivers'" echo "and 'Makefile.config'" echo "Are you sure you wish to continue [Y/N]?" read answer case "$answer" in Y*|y*) ;; *) exit 0 ;; esac fi # -------------------------------------------------------------------- sh $0 -drivers sh $0 -modemlib smsmodem # -------------------------------------------------------------------- UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown # -------------------------------------------------------------------- case $UNAME_SYSTEM in SunOS*) case $UNAME_RELEASE in 5.4) EXTENSION=solaris-2.4 ;; 5.5) EXTENSION=solaris-2.5 ;; 5.5.1) EXTENSION=solaris-2.5.1 ;; 5.6) EXTENSION=solaris-2.6 ;; 5.7) EXTENSION=solaris-2.7 ;; *) EXTENSION= ;; esac ;; Linux*) EXTENSION=linux ;; FreeBSD*) EXTENSION=freebsd ;; UnixWare*) EXTENSION=unixware ;; SCO*) EXTENSION=sco ;; HP-UX*) EXTENSION=hp-ux ;; OSF1*) EXTENSION= ;; unknown) ( hostinfo | grep NeXT ) 2>/dev/null >/dev/null if [ $? -eq 0 ] then EXTENSION=next else EXTENSION= fi ;; *) EXTENSION= ;; esac if [ "X-${EXTENSION}" = "X-" ] then echo "" echo "I Dont know how to build for '${UNAME_SYSTEM}'" echo "Copy a 'Makefile.config.OSTYPE' from the config directory" echo "which most closely resembles your platform into this" echo "directory and rename it 'Makefile.config'" echo "" echo "You may wish to edit Makefile.config for site specific dependencies" echo "When you have finished, to build and install sms_client run:" echo "" echo " make ; make install" echo "" exit 1 fi # -------------------------------------------------------------------- cp config/Makefile.config.${EXTENSION} Makefile.config if [ $? -ne 0 ] then echo "ERROR: 'cp config/Makefile.config.${EXTENSION} Makefile.config' failed" 1>&2 exit 1 fi cp config/Makefile Makefile if [ $? -ne 0 ] then echo "ERROR: 'cp config/Makefile Makefile' failed" 1>&2 exit 1 fi $TOUCH .configured if [ $? -ne 0 ] then echo "ERROR: '$TOUCH .configured' failed" 1>&2 exit 1 fi echo "" echo "Copying 'config/Makefile.config.${EXTENSION}' to 'Makefile.config'" echo "Configuration complete" echo "You may wish to edit Makefile.config for site specific dependencies" echo "When you have finished, to build and install sms_client run:" echo "" echo " make ; make install" echo "" exit 0 # -------------------------------------------------------------------- smsclient-2.0.8z/debian/0000755000175000017500000000000011007610112015013 5ustar noodlesnoodlessmsclient-2.0.8z/debian/rules0000755000175000017500000000323011007607643016110 0ustar noodlesnoodles#!/usr/bin/make -f # Made with the aid of dh_make, by Craig Small # Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. # Some lines taken from debmake, by Cristoph Lameter. # Customized for smsclient by Michael Holzt. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 build: build-stamp build-stamp: dh_testdir # Add here commands to compile the package. rm -f .configured ./configure $(MAKE) touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp install-stamp # Add here commands to clean up after the build process. rm -f .configured ./configure $(MAKE) clean rm -f Makefile rm -f Makefile.config dh_clean install: install-stamp install-stamp: build-stamp dh_testdir dh_testroot dh_clean -k dh_installdirs $(MAKE) install DESTDIR=`pwd`/debian/smsclient touch install-stamp # Build architecture-independent files here. binary-indep: build install # We have nothing to do by default. # Build architecture-dependent files here. binary-arch: build install # dh_testversion dh_testdir dh_testroot dh_installdebconf dh_installdocs dh_installchangelogs -a Changelog dh_installexamples contrib # dh_installmenu # dh_installemacsen # dh_installinit dh_installcron dh_installman docs/sms_address.1 docs/sms_client.1 dh_link dh_strip dh_compress -A dh_fixperms # dh_suidregister dh_installdeb dh_shlibdeps dh_gencontrol # dh_makeshlibs dh_md5sums dh_builddeb source diff: @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary smsclient-2.0.8z/debian/docs0000644000175000017500000000005510127274474015711 0ustar noodlesnoodlesFAQ README docs/sms_protocol README.1ST TODO smsclient-2.0.8z/debian/changelog0000644000175000017500000001524111007610104016671 0ustar noodlesnoodlessmsclient (2.0.8z-10) unstable; urgency=low * Remove debconf usage; all versions from sarge onwards haven't put service files in /etc/smsclient/services so no need of the debconf note any more. (closes: #414295) * Improve UCP parsing tolerance. Patch from Martin Schmid. (closes: #451486) * Stop Makefile install target from stripping binaries. (closes: #438028) * Lintian cleanups * Don't ignore "make clean" errors. * Clean up copyright file. * Bump Standards-Version to 3.7.3.0 (no further changes). -- Jonathan McDowell Mon, 05 May 2008 14:48:47 +0100 smsclient (2.0.8z-9) unstable; urgency=low * Add Catalan translation, thanks to Jordà Polo. (closes: #412302) * Add Galician translation, thanks to Jacobo Tarrio. (closes: #412239) * Cleanup grammar errors in debconf template. (closes: #412317) -- Jonathan McDowell Thu, 01 Mar 2007 13:52:44 +0000 smsclient (2.0.8z-8) unstable; urgency=low * Add Spanish translation, thanks to Jose Ignacio Méndez González and Javier Fernández-Sanguino Peña. (closes: #403539) * Updated German translation, thanks to Helge Kreutzmann (closes: #402048) * Add missing build-dep on po-debconf. -- Jonathan McDowell Thu, 22 Feb 2007 20:09:37 +0000 smsclient (2.0.8z-7) unstable; urgency=low * Updated French translation, thanks to Michel Grentzinger. (closes: #379469) * Updated Portuguese translation, thanks to Rui Branco. (closes: #381199) * Updated Swedish translation, thanks to Daniel Nylander. (closes: #387517) * Updated Dutch translation, thanks to Kurt De Bree. (closes: #389788) * Updated Czech translation, thanks to Martin Šín. (closes: #391545) -- Jonathan McDowell Tue, 14 Nov 2006 09:57:33 +0000 smsclient (2.0.8z-6) unstable; urgency=low * Add debian/compat to set debhelper compat level to 4. - Removed debian/conffiles as debhelper looks after the /etc files for us now. * Change dh_installmanpages usage to dh_installman. * Add Swedish translation, thanks to Daniel Nylander. (closes: #330614) * Add Portuguese translation, thanks to Rui Branco. (closes: #333598) * Clean up logfiles upon package purge. (closes: #330533) * Use /usr/share/smsclient for service definitions; there's no reason for these to go under /usr/lib/smsclient as they're architecture independent. * Remove non-working SMS web backends, thanks to Michael Dorrington. - att_web (closes: #121479) - cellnet_web - nextel_web - orange_web - pagenet_web - proximus_web * Various code cleanups to eliminate compiler warnings (mostly failing to include appropriate headers). * Bump Standards-Version to 3.7.2.0 (no changes). -- Jonathan McDowell Sat, 22 Jul 2006 14:23:34 +0100 smsclient (2.0.8z-5) unstable; urgency=low * Fix debconf dependancy (sorry for the delay Joey). * Added Dutch translation, thanks to Luk Claes. (closes: #274899) * Added Czech translation, thanks to Martin Šín. (closes: #311699) * Added Vietnamese translation, thanks to Clytie Siddall. (closes: #318598) -- Jonathan McDowell Thu, 01 Sep 2005 17:02:02 +0100 smsclient (2.0.8z-4) unstable; urgency=low * New maintainer. (closes: #216212) * Fixed cellnet/vodafone_tap numbers. (closes: #141685) * Fixed German D2 SMSc number. (closes: #156467) * Fixed Telstra SMS/TAP number. (closes: #232123) * Fixed UK Orange SMSc number. * Switch to gettext debconf templates. (closes: #202804) * Added German translation. (closes: #138597) * Added French translation. (closes: #202806) * Updated copyright info (upstream URL etc). * Added man page for sms_address. -- Jonathan McDowell Mon, 22 Mar 2004 20:33:00 +0000 smsclient (2.0.8z-3) unstable; urgency=low * Orphaning package and setting maintainer to Debian QA Group . Sorry for that. -- Michael Holzt Fri, 17 Oct 2003 12:03:15 +0200 smsclient (2.0.8z-2) unstable frozen; urgency=low * ahhh, ugggly bug :-) Nothing worth to be mentioned here, however. -- Michael Holzt Sun, 3 Mar 2002 17:12:53 +0100 smsclient (2.0.8z-1) unstable frozen; urgency=low * Changed UK numbers (closes: Bug#101103) * Changed Directory for services (closes: Bug#132112) -- Michael Holzt Sun, 3 Mar 2002 16:01:57 +0100 smsclient (2.0.8y-2) unstable frozen; urgency=low * Minor fixes. * Bug close again. (closes: Bug#97900, Bug#66403, Bug#63882, Bug#63883) -- Michael Holzt Sun, 10 Jun 2001 21:22:23 +0200 smsclient (2.0.8y-1) unstable frozen; urgency=low * New upstrem version 2.0.8y (closes #97900) * Several fixes (closes #66403, #63882, #63883) -- Michael Holzt Sun, 27 May 2001 14:58:09 +0200 smsclient (2.0.8r-7) unstable frozen; urgency=low * Fixed transmission of german character 'sz' (sharp s) to the correct value regarding GSM standard TS 03.38 (DeTeMobil's wrong documentation sucks!) (closes #59485) -- Michael Holzt Fri, 28 Apr 2000 00:34:49 +0200 smsclient (2.0.8r-6) unstable frozen; urgency=low * Changed call to logrotation (closes #57653), this also added creation of logfile when installing, which fixes #44745 in a much better way. -- Michael Holzt Fri, 28 Apr 2000 00:34:42 +0200 smsclient (2.0.8r-5) unstable frozen; urgency=low * Fixed bug with 8bit character handling in TAP (closes #57059) -- Michael Holzt Sun, 6 Feb 2000 02:21:16 +0100 smsclient (2.0.8r-4) unstable frozen; urgency=low * Fixed name of logfile in manpage (should close #52445) -- Michael Holzt Sun, 16 Jan 2000 22:20:38 +0100 smsclient (2.0.8r-3) unstable; urgency=low * Fixed directory for manpages -- Michael Holzt Sat, 16 Oct 1999 15:40:58 +0200 smsclient (2.0.8r-2) unstable; urgency=low * mostly cosmetic changes * fix for logfile rights (should close #44745) -- Michael Holzt Mon, 11 Oct 1999 14:12:49 +0200 smsclient (2.0.8r-1) unstable; urgency=low * new upstream version 2.0.8r -- Michael Holzt Sun, 10 Oct 1999 11:23:32 +0200 smsclient (2.0.7s3-6) unstable; urgency=low * corrected answer.c to include -- Michael Holzt Sat, 3 Jul 1999 00:18:37 +0200 smsclient (2.0.7s3-5) unstable; urgency=low * -fsigned-char added to compile options -- Michael Holzt Thu, 22 Apr 1999 01:17:35 +0200 smsclient (2.0.7s3-4) unstable; urgency=low * Initial Release. -- Michael Holzt Thu, 15 Apr 1999 00:13:16 +0200 Local variables: mode: debian-changelog End: smsclient-2.0.8z/debian/cron.weekly0000644000175000017500000000013310127274474017216 0ustar noodlesnoodles#!/bin/sh cd /var/log savelog -m 0664 -u root -g dialout -t -c 4 smsclient.log > /dev/null smsclient-2.0.8z/debian/postinst0000644000175000017500000000022011007607476016636 0ustar noodlesnoodles#!/bin/sh set -e if [ ! -f /var/log/smsclient.log ]; then install -g dialout -o root -m 0664 /dev/null /var/log/smsclient.log fi #DEBHELPER# smsclient-2.0.8z/debian/compat0000644000175000017500000000000210460423257016227 0ustar noodlesnoodles4 smsclient-2.0.8z/debian/copyright0000644000175000017500000000215611007576537017000 0ustar noodlesnoodlesThis package was debianized by Michael Holzt on Sat, 27 Mar 1999 00:33:47 +0100. It was downloaded from http://www.smsclient.org/ Upstream Authors: Until 2002 Angelo Masci Post 2002 Michael Holzt Copyright: 1997,1998,1999,2000 Angelo Masci This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. On Debian GNU/Linux systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL'. smsclient-2.0.8z/debian/postrm0000644000175000017500000000014610460426061016275 0ustar noodlesnoodles#!/bin/sh set -e case "$1" in purge) rm -f /var/log/smsclient.log* ;; esac #DEBHELPER# exit 0 smsclient-2.0.8z/debian/dirs0000644000175000017500000000004210460425225015706 0ustar noodlesnoodlesetc/smsclient usr/share/smsclient smsclient-2.0.8z/debian/control0000644000175000017500000000126211007607632016434 0ustar noodlesnoodlesSource: smsclient Section: comm Priority: optional Maintainer: Jonathan McDowell Build-Depends: debhelper (>= 4.1.16) Standards-Version: 3.7.3.0 Package: smsclient Architecture: any Depends: ${shlibs:Depends},${misc:Depends} Suggests: Description: A program for sending short messages (SM / SMS) smsclient is a tool for sending short messages (SM - often false named SMS). SM can be sent to mobile phones. Additional some paging systems are supported by this tool. smsclient supports the common protocols UCP, TAP and some other. Out of the box there is preconfigured support for many local services, but smsclient can be easily extended to support other systems. smsclient-2.0.8z/Makefile.modemlib0000644000175000017500000000372711007610111017030 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.modems # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # SMS_Client can be built to use the libmodem package or # its own internal modem routines. Currently the internal routines # are known to be unstable and are still considered to be in ALPHA # Valid Values for MYMODEMLIB are: # # -llibmodem - use the libmodem-1.0.0 packages with patches # - use the internal modem routines # # -------------------------------------------------------------------- # -------------------------------------------------------------------- SMSMODEM = 2 LIBMODEM = 1 # -------------------------------------------------------------------- MODEMLIB = 2 MLIBS = # -------------------------------------------------------------------- smsclient-2.0.8z/FAQ0000644000175000017500000001017210127274463014145 0ustar noodlesnoodles SMS_client FAQ 2.0.8 ==================== [Q]. When I try 'make', it complains bitterly, Why? [A]. Use GNU Make. Versions 2.0.8m and up have been updated significantly to work with non GNU makes. -------------------------------------------------------------------- [Q]. The binaries are huge, what's the deal? [A]. The binaries have been built with the '-g' options to include as many debug symbols as possible. You can run strip on the binaries to reduce their size considerably. When you run the install script the binaries are stripped before being copied to their destination. If you are still concerned you can reduce the size by editing the file 'drivers' and recompiling the to include only those drivers that you are going to use. -------------------------------------------------------------------- [Q]. I Have a PageOne Minicall pager, how do I find out my Pager ID? [A]. The number on the reverse of the pager is dialed to leave a message with an operator. Your Pager ID is the last 6 digits of this number. -------------------------------------------------------------------- [Q]. Is there a GUI available for X? [A]. Currently NO, although number of individuals have said they are working on such projects. -------------------------------------------------------------------- [Q]. Do I need any special hardware to send a messages to a mobile phone, must I connect my mobile to the computer somehow? [A]. No. SMS Client uses your modem to dial into a messages centre run by your provider, this relays the message to the phone or pager. Drivers are being implemented which interface with web based services hosted by some providers. In the case of these service it is assumed that you are connected to the internet and can contact then either directly or via a http proxy server. -------------------------------------------------------------------- [Q]. Can I receive SMS messages on my computer using this software. [A]. No. This software is intended only for sending SMS messages. Some free UNIX software for doing this is available for use with specialized equipment. For more information see: http://www.styx.demon.co.uk/smslink -------------------------------------------------------------------- [Q]. I've noticed that there's code in the 'src' directory that doesn't get built when I 'make' why is that? [A]. The additional code is still in development. Feel free to take a look and send me any feedback you may have. -------------------------------------------------------------------- [Q]. I have tried to send myself several messages but only one arrives, why? [A]. SMS Client Filters out any duplicate names if found. If you really want to send yourself several messages enter several versions of your name in the address book and specify these on the command line. -------------------------------------------------------------------- [Q]. I feel an overwhelming urge to pay for this software what should I do? [A]. You're out of luck, it's free. I do however appreciate picture postcards, they should be sent to: Angelo Masci 9B The Cathedral Green Llandaff Cardiff CF5 2EB United Kingdom I've changed my address as I'm beginning to believe they've been shredding all my mail ;) Believe it or not after all the email I've received, mailing list organisations and people I've helped, I'm still waiting to receive a single postcard :( Update As of November 7 1999 I've received a flood of 7 postcards! -------------------------------------------------------------------- [Q]. I'd like to give it a quick test, is there a test number I can try? [A]. If your from the UK Feel free to send your email address to my pager on minicall:252044 I'll try to mail you a reply back a soon as I get a chance. Remeber that this is a UK service and will cost you a lot if your dialing from outside the UK. Believe it or not, I'm quite sad and actually enjoy receiving test messages... smsclient-2.0.8z/src/0000755000175000017500000000000011007574600014373 5ustar noodlesnoodlessmsclient-2.0.8z/src/resource/0000755000175000017500000000000011007610111016206 5ustar noodlesnoodlessmsclient-2.0.8z/src/resource/test_file0000644000175000017500000000020210127274516020122 0ustar noodlesnoodles{ number_1 = "1234" number_2 = "5467" string_1 = "string A" string_2 = "string B" list = ( "fun", "in", "the", "sun" ) } smsclient-2.0.8z/src/resource/resource.c0000644000175000017500000001420210127274516020221 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* sms_resource.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include "error.h" #include "logfile/logfile.h" #include "resource.h" #include "common/common.h" #include "parser/gs_token.h" #include "parser/gs_translate.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void set_defaults(char *filename, RESOURCE *resource_list, TOKEN_HEAP *resource_heap); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void set_defaults(char *filename, RESOURCE *resource_list, TOKEN_HEAP *resource_heap) { RESOURCE *resource; char *str; resource = resource_list; while (resource->type != RESOURCE_NULL) { if (resource->name == NULL) { continue; } str = get_strvalue(resource_heap, resource->name); if (str != NULL) { /* Found item, set the resource value to it */ if (resource->type == RESOURCE_STRING) { resource->str_value = (char *)malloc(sizeof(char) * (strlen(str) +1)); if (resource->str_value == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } strcpy(resource->str_value, str); if (resource->default_warning) { lprintf(LOG_VERBOSE, "Parsing '%s' Found '%s', setting value to '%s'\n", filename, (resource->name != NULL)?(resource->name):("NULL"), resource->str_value); } } else if (resource->type == RESOURCE_NUMERIC) { resource->int_value = atoi(str); if (resource->default_warning) { lprintf(LOG_VERBOSE, "Parsing '%s' Found '%s', setting value to '%ld'\n", filename, (resource->name != NULL)?(resource->name):("NULL"), resource->int_value); } } } else { /* Didn't Find item, set the resource value to it's default */ if (resource->type == RESOURCE_STRING) { resource->str_value = resource->default_str_value; if (resource->default_warning) { lprintf(LOG_VERBOSE, "Parsing '%s' Could not find '%s', using default '%s'\n", filename, (resource->name != NULL)?(resource->name):("NULL"), (resource->str_value != NULL)?(resource->str_value):("NULL")); } } else if (resource->type == RESOURCE_NUMERIC) { resource->int_value = resource->default_int_value; if (resource->default_warning) { lprintf(LOG_VERBOSE, "Parsing '%s' Could not find '%s', using default '%ld'\n", filename, (resource->name != NULL)?(resource->name):("NULL"), resource->int_value); } } } /* Set the variable pointed to by the resource */ /* to the value of the resource. */ if (resource->type == RESOURCE_STRING) { if (resource->var != NULL) { *((char **)(resource->var)) = resource->str_value; } lprintf(LOG_VERBOSE, "%s %s = %s\n", filename, (resource->name != NULL)?(resource->name):("NULL"), (resource->str_value != NULL)?(resource->str_value):("NULL")); } else if (resource->type == RESOURCE_NUMERIC) { if (resource->var != NULL) { *((long *)(resource->var)) = resource->int_value; } lprintf(LOG_VERBOSE, "%s %s = %ld\n", filename, (resource->name != NULL)?(resource->name):("NULL"), resource->int_value); } else if (resource->type == RESOURCE_HEAP) { *((TOKEN_HEAP **)(resource->var)) = dup_varlist(resource_heap, resource->name); lprintf(LOG_VERBOSE, "%s %s = dup_heap()\n", filename, (resource->name != NULL)?(resource->name):("NULL")); } resource++; } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int read_resource_file(char *filename, RESOURCE *resource_list, int warnings) { TOKEN_HEAP *resource_heap; lprintf(LOG_VERBOSE, "Parsing Resource File '%s'\n", filename); resource_heap = gs_parse_file(filename); if (resource_heap == NULL) { lprintf(LOG_ERROR, "Parsing file '%s'\n", filename); return RESOURCE_FILE_ERROR; } set_defaults(filename, resource_list, resource_heap); free_heap(resource_heap); return RESOURCE_FILE_OK; } /* -------------------------------------------------------------------- */ /* Differs from read_resource_file() in that it returns the */ /* Token Heap which must be freed by calling free_heap() */ /* -------------------------------------------------------------------- */ TOKEN_HEAP *parse_resource_file(char *filename, RESOURCE *resource_list, int warnings) { TOKEN_HEAP *resource_heap; lprintf(LOG_VERBOSE, "Parsing Resource File '%s'\n", filename); resource_heap = gs_parse_file(filename); if (resource_heap == NULL) { lprintf(LOG_ERROR, "Failed to parse file '%s'\n", filename); return NULL; } set_defaults(filename, resource_list, resource_heap); return resource_heap; } smsclient-2.0.8z/src/resource/test_resource.c0000644000175000017500000001057010127274516021264 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* test_resource.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include #include #include "logfile/logfile.h" #include "common/common.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ #if !defined(MLOGFILE) #error "MLOGFILE undefined" #else #define LOGFILE MLOGFILE #endif #if !defined(MLOGLEVEL) #error "MLOGLEVEL undefined" #else #define LOGLEVEL MLOGLEVEL #endif /* -------------------------------------------------------------------- */ long number_1, number_2; char *string_1, *string_2; TOKEN_HEAP *heap = NULL; static RESOURCE resource_list[] = { { RESOURCE_NUMERIC, "number_1", 0, 1, NULL, 0, NULL, 66, &number_1 }, { RESOURCE_NUMERIC, "number_2", 0, 1, NULL, 0, NULL, 77, &number_2 }, { RESOURCE_STRING, "string_1", 0, 1, NULL, 0, "string_1", 0, &string_1 }, { RESOURCE_STRING, "string_2", 0, 1, NULL, 0, "string_2", 0, &string_2 }, { RESOURCE_HEAP, "list", 0, 1, NULL, 0, NULL, 0, &heap }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void usage(char *file) { lprintf(LOG_ERROR, "Usage: %s [-l loglevel] \n", file); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char *argv[]) { int c; char *ptr; /* ---------------------------- */ set_logfile(LOGFILE); set_loglevel(LOGLEVEL); set_consolelog(TRUE); /* ---------------------------- */ while ((c = getopt (argc, argv, "l:")) != -1) { switch (c) { case 'l': set_loglevel((int)strtol(optarg, &ptr, 10)); if (ptr == optarg) { lprintf(LOG_ERROR, "Option l requires an argument\n"); usage(argv[0]); exit(-1); } break; case '?': lprintf(LOG_ERROR, "Unknown option `-%c'\n", optopt); usage(argv[0]); exit(-1); default: abort (); } } if ((argc - optind) != 1) { usage(argv[0]); exit(-1); } /* ---------------------------- */ if (read_resource_file(argv[optind], resource_list, 1) == RESOURCE_FILE_ERROR) { lprintf(LOG_ERROR, "Failed to read resource file '%s'\n", argv[optind]); exit(-1); } printf("number_1 = %ld\n", number_1); printf("number_2 = %ld\n", number_2); printf("string_1 = %s\n", string_1); printf("string_2 = %s\n", string_2); if (heap != NULL) { dump_heap(heap, "list"); } return 0; } smsclient-2.0.8z/src/resource/resource.h0000600000175000017500000000473410127274516020227 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* sms_resource.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #if !defined(_RESOURCE_H) #define _RESOURCE_H 1 #include "parser/gs_token.h" /* -------------------------------------------------------------------- */ #define RESOURCE_NULL 0 #define RESOURCE_STRING 1 #define RESOURCE_NUMERIC 2 #define RESOURCE_HEAP 3 /* -------------------------------------------------------------------- */ #define RESOURCE_FILE_OK 0 #define RESOURCE_FILE_ERROR 1 /* -------------------------------------------------------------------- */ struct resource_struct { int type; char *name; int found, default_warning; char *str_value; long int_value; char *default_str_value; long default_int_value; void *var; }; typedef struct resource_struct RESOURCE; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int read_resource_file(char *filename, RESOURCE *resource_list, int warnings); TOKEN_HEAP *parse_resource_file(char *filename, RESOURCE *resource_list, int warnings); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #endif smsclient-2.0.8z/src/resource/Makefile0000644000175000017500000000477310127274516017702 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- include ../../Makefile.config # -------------------------------------------------------------------- all: resource.a clean: $(RM) *.o *.bak resource.a test_resource test: test_resource # -------------------------------------------------------------------- gs_parser: cd ../parser ; $(MAKE) gs_parser.a # -------------------------------------------------------------------- INCLUDE = -I.. -I../parser resource.a: resource.o $(RM) resource.a $(AR) resource.a resource.o $(RANLIB) resource.a resource.o: resource.c ../common/common.h ../logfile/logfile.h resource.h $(CC) $(CFLAGS) -c resource.c $(INCLUDE) test_resource.o: test_resource.c $(CC) $(CFLAGS) -c test_resource.c $(INCLUDE) -DMLOGLEVEL=3 -DMLOGFILE="\"test_log\"" test_resource: test_resource.o resource.a gs_parser ../common/common.o ../logfile/logfile.o $(CC) $(CFLAGS) test_resource.o -o test_resource resource.a ../parser/gs_parser.a ../common/common.o ../logfile/logfile.o # -------------------------------------------------------------------- ../logfile/logfile.o: ../logfile/logfile.c ../logfile/logfile.h cd ../logfile ; $(MAKE) logfile.o ../common/common.o: ../common/common.c ../common/common.h cd ../common ; $(MAKE) common.o # -------------------------------------------------------------------- smsclient-2.0.8z/src/comms/0000755000175000017500000000000011007610111015475 5ustar noodlesnoodlessmsclient-2.0.8z/src/comms/tcpip.c0000644000175000017500000000544710127274503017007 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* tcpip.c */ /* */ /* Copyright (C) 1997,1998, 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #if defined(SOLARIS) && !defined(SOLARIS_2_4) #include #endif #include "common/common.h" #include "logfile/logfile.h" #include "error.h" #include "tcpip.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int TCPIP_connect(char *host, int port) { int sockfd; struct hostent *he; struct sockaddr_in their_addr; /* connector's address information */ if ((he=gethostbyname(host)) == NULL) /* get the host info */ { lprintf(LOG_ERROR, "gethostbyname() failed\n"); return -1; } if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { lprintf(LOG_ERROR, "socket() failed\n"); return -1; } their_addr.sin_family = AF_INET; /* host byte order */ their_addr.sin_port = htons(port); /* short, network byte order */ their_addr.sin_addr = *((struct in_addr *)he->h_addr); bzero(&(their_addr.sin_zero[0]), 8); /* zero the rest of the struct */ if (connect(sockfd, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1) { lprintf(LOG_ERROR, "connect() failed\n"); return -1; } return sockfd; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int TCPIP_disconnect(int fd) { return close(fd); } smsclient-2.0.8z/src/comms/comms.h0000644000175000017500000000301410127274503016777 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* comms.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include "modem.h" #include "tcpip.h" #include "expect.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/comms/tcpip.h0000644000175000017500000000303110127274503016777 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* tcpip.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ int TCPIP_connect(char *host, int port); int TCPIP_disconnect(int fd); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/comms/http_tread.h0000644000175000017500000000032310127274503020017 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ int http_tread(int fd, char *buf, int len, int *timeout); /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/comms/http.c0000644000175000017500000002214110460430653016635 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* http.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include "url.h" #include "base64.h" #include "tcpip.h" #include "logfile/logfile.h" #include "common/common.h" #include "http_tread.h" #include "http_twrite.h" #include "error.h" /* -------------------------------------------------------------------- */ #define BLK_SIZE 4096 #define HTTP_WRITETIMEOUT NULL #define HTTP_READTIMEOUT NULL /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *slurp_data(int fd, int *filelen) { char *query_string; int total_read, len, max_len, bytes_read; query_string = (char *)malloc(sizeof(char) * (BLK_SIZE +1)); if (query_string == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } total_read = 0; len = BLK_SIZE; max_len = BLK_SIZE; bytes_read = http_tread(fd, &query_string[total_read], len, HTTP_READTIMEOUT); if (bytes_read == -1) { free(query_string); return NULL; } while(bytes_read != 0) { len -= bytes_read; total_read += bytes_read; if (len == 0) { query_string = (char *)realloc(query_string, sizeof(char) * (max_len + BLK_SIZE +1)); if (query_string == NULL) { return NULL; } len = BLK_SIZE; max_len += BLK_SIZE; } bytes_read = http_tread(fd, &query_string[total_read], len, HTTP_READTIMEOUT); if (bytes_read == -1) { free(query_string); return NULL; } } *filelen = total_read; return query_string; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *get_document(char *url, int *data_len, char *method, char *data, char *authentication) { char send_buf[1024], *proxy, *auth, *mdata; int sockfd, proxy_connect; URL tmp_url, proxy_url; lprintf(LOG_VERYVERBOSE, "----------------------------\n"); lprintf(LOG_VERYVERBOSE, "HTTP Document request '%s'\n", url); lprintf(LOG_VERYVERBOSE, "METHOD: '%s'\n", method); lprintf(LOG_VERYVERBOSE, "DATA: '%s'\n", (data == NULL?"NULL":data)); lprintf(LOG_VERYVERBOSE, "AUTH: '%s'\n", (authentication == NULL?"NULL":authentication)); lprintf(LOG_VERYVERBOSE, "----------------------------\n"); if (parse_url(url, &tmp_url) == -1) { lprintf(LOG_ERROR, "Parsing URL '%s'\n", url); return NULL; } lprintf(LOG_VERYVERBOSE, "----------------------------\n"); lprintf(LOG_VERYVERBOSE, "Decomposed URL \n"); lprintf(LOG_VERYVERBOSE, "----------------------------\n"); lprintf(LOG_VERYVERBOSE, "HOST: '%s'\n", tmp_url.host); lprintf(LOG_VERYVERBOSE, "PORT: '%s'\n", tmp_url.port); lprintf(LOG_VERYVERBOSE, "DOCUMENT: '%s'\n", tmp_url.document); lprintf(LOG_VERYVERBOSE, "DIRECTORY: '%s'\n", tmp_url.directory); lprintf(LOG_VERYVERBOSE, "FILENAME: '%s'\n", tmp_url.filename); lprintf(LOG_VERYVERBOSE, "----------------------------\n"); proxy_connect = FALSE; if ((proxy = getenv("HTTP_PROXY")) != NULL) { proxy_connect = TRUE; lprintf(LOG_VERBOSE, "Connecting using proxy '%s'\n", proxy); if (parse_url(proxy, &proxy_url) == -1) { lprintf(LOG_ERROR, "Parsing proxy URL '%s'\n", proxy); free_url(&tmp_url); return NULL; } sockfd = TCPIP_connect(proxy_url.host, atoi(proxy_url.port)); if (sockfd == -1) { lprintf(LOG_ERROR, "Connecting to '%s:%s'\n", proxy_url.host, proxy_url.port); free_url(&tmp_url); free_url(&proxy_url); return NULL; } free_url(&proxy_url); } else { sockfd = TCPIP_connect(tmp_url.host, atoi(tmp_url.port)); if (sockfd == -1) { lprintf(LOG_ERROR, "Connecting to '%s:%s'\n", tmp_url.host, tmp_url.port); free_url(&tmp_url); return NULL; } } /* ------------------------------------ */ /* Send the request for the page. */ /* Using HTTP protocol version 1.0 */ if (proxy_connect) { sms_snprintf(send_buf, 1024, "%s http://%s:%s%s HTTP/1.0\r\n", method, tmp_url.host, tmp_url.port, tmp_url.document); } else { sms_snprintf(send_buf, 1024, "%s %s HTTP/1.0\r\n", method, tmp_url.document); } http_twrite(sockfd, send_buf, strlen(send_buf), HTTP_WRITETIMEOUT); /* ------------------------------------ */ #if 1 /* At some point I need to build a complete */ /* http 1.0 compliant header. */ /* for now we'll skip some fields. */ sms_snprintf(send_buf, 1024, "Referer: %s\r\n", url); http_twrite(sockfd, send_buf, strlen(send_buf), HTTP_WRITETIMEOUT); sms_snprintf(send_buf, 1024, "Proxy-Connection: %s\r\n", "Keep-Alive"); http_twrite(sockfd, send_buf, strlen(send_buf), HTTP_WRITETIMEOUT); sms_snprintf(send_buf, 1024, "User-Agent: %s\r\n", "SMSClient"); http_twrite(sockfd, send_buf, strlen(send_buf), HTTP_WRITETIMEOUT); if (proxy != NULL) { /* Send proxy related data. */ sms_snprintf(send_buf, 1024, "Host: %s:%s\r\n", tmp_url.host, tmp_url.port); http_twrite(sockfd, send_buf, strlen(send_buf), HTTP_WRITETIMEOUT); } sms_snprintf(send_buf, 1024, "Accept: %s\r\n", "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"); http_twrite(sockfd, send_buf, strlen(send_buf), HTTP_WRITETIMEOUT); sms_snprintf(send_buf, 1024, "Content-type: %s\r\n", "application/x-www-form-urlencoded"); http_twrite(sockfd, send_buf, strlen(send_buf), HTTP_WRITETIMEOUT); #endif if (authentication != NULL) { /* Send Authentication. */ /* Base64 Encode 'username:password' */ auth = encodeBase64(authentication); if (auth != NULL) { lprintf(LOG_VERBOSE, "Using Authentication Basic '%s'\n", auth); sms_snprintf(send_buf, 1024, "Authorization: Basic %s\r\n", auth); http_twrite(sockfd, send_buf, strlen(send_buf), HTTP_WRITETIMEOUT); free(auth); } else { lprintf(LOG_ERROR, "Building authentication data\n"); free_url(&tmp_url); return NULL; } } if (data != NULL) { /* Send data appropriate to method. */ /* POST or GET */ if (strcmp(method, "GET") == 0) { lprintf(LOG_ERROR, "Data supplied whilst method is 'GET'\n"); free_url(&tmp_url); return NULL; } else if (strcmp(method, "POST") == 0) { sms_snprintf(send_buf, 1024, "Content-length: %d\r\n", strlen(data)); http_twrite(sockfd, send_buf, strlen(send_buf), HTTP_WRITETIMEOUT); } else { lprintf(LOG_ERROR, "Data supplied whilst using Unsupport Method '%s'\n", method); free_url(&tmp_url); return NULL; } } http_twrite(sockfd, "\r\n", strlen("\r\n"), HTTP_WRITETIMEOUT); /* ---------------------------- */ /* Ouput data for POST method */ if (data != NULL) { http_twrite(sockfd, data, strlen(data), HTTP_WRITETIMEOUT); } /* ---------------------------- */ mdata = slurp_data(sockfd, data_len); if (mdata == NULL) { lprintf(LOG_ERROR, "Receiving data from server\n"); } TCPIP_disconnect(sockfd); free_url(&tmp_url); return mdata; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *get_simple_document(char *url, int *data_len) { return get_document(url, data_len, "GET", NULL, NULL); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *escape_input(char *src) { char *buf, *dst, *table = "0123456789ABCDEF"; int high, low; buf = (char *)malloc(sizeof(char) * ((strlen(src) * 3) +1)); if (buf == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } dst = buf; while(*src != '\0') { if (isalnum(*src)) { *dst++ = *src; } else if (*src == ' ') { *dst++ = '+'; } else { low = *src % 16; high = ((int)(*src / 16 )) % 16; *dst++ = '%'; *dst++ = table[high]; *dst++ = table[low]; } src++; } *dst = '\0'; return buf; } smsclient-2.0.8z/src/comms/temp0000644000175000017500000000034210127274503016401 0ustar noodlesnoodles retry = 3; while (retry--) { if (tcgetattr(modem, &t_orig) == -1) { lprintf(LOG_WARNING, "MODEM: Failed tcgetattr()\n"); if (retry == 1) { close(modem); return -1; } } else { retry = 0; } } smsclient-2.0.8z/src/comms/http_tread.c0000644000175000017500000000347110460430766020026 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include "http_tread.h" /* -------------------------------------------------------------------- */ static int timeout_flag; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void timeout_func(int sig) { timeout_flag = 1; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int http_tread(int fd, char *buf, int len, int *timeout) { int using_timeout, bytes_read, total_read; time_t start_time, new_timeout; void (* orig_signal)(int); bytes_read = 0; total_read = 0; using_timeout = 0; timeout_flag = 0; start_time = 0; orig_signal = NULL; if ((timeout != NULL) && (*timeout != 0)) { using_timeout = 1; start_time = time(NULL); orig_signal = signal(SIGALRM, timeout_func); alarm(*timeout); } while (len > 0) { if (timeout_flag) { *timeout = 0; signal(SIGALRM, orig_signal); return bytes_read; } bytes_read = read(fd, &buf[total_read], len); if (bytes_read == -1) { if (errno != EINTR) { break; } } else if (bytes_read == 0) { break; } else { total_read += bytes_read; len -= bytes_read; } } if (using_timeout) { alarm(0); signal(SIGALRM, orig_signal); new_timeout = (*timeout - (time(NULL) - start_time)); if (new_timeout < 0) { new_timeout = 0; } *timeout = new_timeout; } return total_read; } smsclient-2.0.8z/src/comms/modem.c0000644000175000017500000007732710127274503016777 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* modem.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include #include #include #if defined(SOLARIS) #include #endif #include "modem.h" #include "logfile/logfile.h" #include "common/common.h" #include "expect.h" #include "lock/lock.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ #if !defined(MMODEMDIR) #error "MMODEMDIR undefined" #else #define MODEMDIR MMODEMDIR #endif /* -------------------------------------------------------------------- */ #define MDM_OK 1 #define MDM_CONNECT 2 #define MDM_BUSY 3 #define MDM_NO_DIALTONE 4 #define MDM_NO_ANSWER 5 #define MDM_RING 6 #define MDM_NO_CARRIER 7 #define MDM_ERROR 8 #define MDM_UNKNOWN_RESPONSE 9 #define MDM_DISCONNECTED 10 #define MDM_RINGING 11 /* -------------------------------------------------------------------- */ struct response_struct { char *response_str; int response_code; }; typedef struct response_struct RESPONSE; static RESPONSE response_list[] = { { "OK", MDM_OK }, { "CONNECT", MDM_CONNECT }, { "BUSY", MDM_BUSY }, { "NO DIALTONE", MDM_NO_DIALTONE }, { "NO DIAL TONE", MDM_NO_DIALTONE }, { "NO ANSWER", MDM_NO_ANSWER }, { "RINGING", MDM_RINGING }, { "RING", MDM_RING }, { "NO CARRIER", MDM_NO_CARRIER }, { "ERROR", MDM_ERROR }, { "UNKNOWN", MDM_UNKNOWN_RESPONSE }, { "CARRIER", MDM_CONNECT }, { NULL, 0 } }; /* -------------------------------------------------------------------- */ #define MODEM_OPEN 0 #define MODEM_CLOSED 1 #define MAX_BUFSIZE 1024 /* -------------------------------------------------------------------- */ static int modem_status = MODEM_CLOSED; /* -------------------------------------------------------------------- */ static struct termios t, t_orig; static long MDM_response_timeout, MDM_hangup_timeout, MDM_connect_timeout, MDM_write_timeout, MDM_echo_timeout, MDM_drain_timeout, MDM_test_echo_timeout, MDM_dtr_hangup_sleep, MDM_dtr_init_sleep, MDM_settle_time, MDM_max_rings, MDM_lock_retry_delay, MDM_pause_before_dial, MDM_pause_after_connect; static int modem_echo = TRUE; /* Is the modem echoing */ /* Characters? Default is YES */ static long soft_hangup_retries; /* Number of times I should */ /* continue sending +++ATH */ /* If 0 then don't bother */ /* and rely on lowering DTR */ static long guard_time; /* Escape Code Guard Time */ /* in microseconds */ static long test_guard_time; /* Echo Test Guard Time */ /* in microseconds */ static long esc_time; /* Time between sending each */ /* character of attention */ /* string in microseconds */ static char modem_file[512], modem_lockfile[512]; static char *device_dir, *device, *command_prefix, *command_suffix, *number_prefix, *dial_command, *hangup_command, *init_command, *attention_command, *response_prefix, *response_suffix, *set_local_echo_off, *lock_action, *flow_control, *lock_dir, *lock_prefix, *lock_platform, *lock_format, *MDM_disable_echo_test, *restore_terminal; static RESOURCE resource_list[] = { { RESOURCE_STRING, "MDM_device", 0, 1, NULL, 0, "modem", 0, &device }, { RESOURCE_STRING, "MDM_device_dir", 0, 0, NULL, 0, "/dev/", 0, &device_dir }, { RESOURCE_STRING, "MDM_lock_dir", 0, 0, NULL, 0, "/var/lock", 0, &lock_dir }, { RESOURCE_STRING, "MDM_lock_prefix", 0, 0, NULL, 0, "LCK..", 0, &lock_prefix }, { RESOURCE_STRING, "MDM_lock_platform", 0, 0, NULL, 0, "TRADITIONAL", 0, &lock_platform }, { RESOURCE_STRING, "MDM_lock_format", 0, 0, NULL, 0, "TRADITIONAL", 0, &lock_format }, { RESOURCE_STRING, "MDM_command_prefix", 0, 1, NULL, 0, "AT", 0, &command_prefix }, { RESOURCE_STRING, "MDM_flow_control", 0, 1, NULL, 0, "Hardware", 0, &flow_control }, { RESOURCE_STRING, "MDM_command_suffix", 0, 1, NULL, 0, "\r", 0, &command_suffix }, { RESOURCE_STRING, "MDM_number_prefix", 0, 1, NULL, 0, "", 0, &number_prefix }, { RESOURCE_STRING, "MDM_dial_command", 0, 1, NULL, 0, "DT", 0, &dial_command }, { RESOURCE_STRING, "MDM_hangup_command", 0, 1, NULL, 0, "H", 0, &hangup_command }, { RESOURCE_STRING, "MDM_init_command", 0, 1, NULL, 0, "Z", 0, &init_command }, { RESOURCE_STRING, "MDM_set_local_echo_off", 0, 0, NULL, 0, "E0", 0, &set_local_echo_off }, { RESOURCE_STRING, "MDM_response_prefix", 0, 1, NULL, 0, "\r\n", 0, &response_prefix }, { RESOURCE_STRING, "MDM_response_suffix", 0, 1, NULL, 0, "\r\n", 0, &response_suffix }, { RESOURCE_STRING, "MDM_attention_command", 0, 1, NULL, 0, "+++", 0, &attention_command }, { RESOURCE_NUMERIC, "MDM_soft_hangup_retries", 0, 0, NULL, 0, NULL, 3, &soft_hangup_retries }, { RESOURCE_NUMERIC, "MDM_guard_time", 0, 0, NULL, 0, NULL, 1750000, &guard_time }, { RESOURCE_NUMERIC, "MDM_test_guard_time", 0, 0, NULL, 0, NULL, 250000, &test_guard_time }, { RESOURCE_NUMERIC, "MDM_esc_time", 0, 0, NULL, 0, NULL, 125000, &esc_time }, { RESOURCE_STRING, "MDM_lock_action", 0, 1, NULL, 0, "NO_BLOCK", 0, &lock_action }, { RESOURCE_NUMERIC, "MDM_lock_retry_delay", 0, 1, NULL, 0, NULL, 5000000, &MDM_lock_retry_delay }, { RESOURCE_NUMERIC, "MDM_response_timeout", 0, 0, NULL, 0, NULL, 10, &MDM_response_timeout }, { RESOURCE_NUMERIC, "MDM_hangup_timeout", 0, 0, NULL, 0, NULL, 60, &MDM_hangup_timeout }, { RESOURCE_NUMERIC, "MDM_connect_timeout", 0, 0, NULL, 0, NULL, 60, &MDM_connect_timeout }, { RESOURCE_NUMERIC, "MDM_write_timeout", 0, 0, NULL, 0, NULL, 10, &MDM_write_timeout }, { RESOURCE_NUMERIC, "MDM_echo_timeout", 0, 0, NULL, 0, NULL, 10, &MDM_echo_timeout }, { RESOURCE_NUMERIC, "MDM_test_echo_timeout", 0, 0, NULL, 0, NULL, 10, &MDM_test_echo_timeout }, { RESOURCE_NUMERIC, "MDM_drain_timeout", 0, 0, NULL, 0, NULL, 2, &MDM_drain_timeout }, { RESOURCE_STRING, "MDM_disable_echo_test", 0, 0, NULL, 0, "NO", 0, &MDM_disable_echo_test }, { RESOURCE_STRING, "MDM_restore_terminal", 0, 0, NULL, 0, "YES", 0, &restore_terminal }, { RESOURCE_NUMERIC, "MDM_pause_before_dial", 0, 0, NULL, 0, NULL, 1000000, &MDM_pause_before_dial }, { RESOURCE_NUMERIC, "MDM_pause_after_connect", 0, 0, NULL, 0, NULL, 0, &MDM_pause_after_connect }, { RESOURCE_NUMERIC, "MDM_dtr_hangup_sleep", 0, 0, NULL, 0, NULL, 3000000, &MDM_dtr_hangup_sleep }, { RESOURCE_NUMERIC, "MDM_dtr_init_sleep", 0, 0, NULL, 0, NULL, 1000000, &MDM_dtr_init_sleep }, { RESOURCE_NUMERIC, "MDM_settle_time", 0, 0, NULL, 0, NULL, 1, &MDM_settle_time }, { RESOURCE_NUMERIC, "MDM_max_rings", 0, 0, NULL, 0, NULL, 4, &MDM_max_rings }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL }, }; /* -------------------------------------------------------------------- MDM_response_timeout Used as timeout for standard AT command responses ie. Waiting for OK MDM_hangup_timeout Used as timeout for standard ATH response Waiting for OK MDM_connect_timeout Used as timeout for connect string response. Includes time taken to dial, other party to answer and both modems to negotiate ie. CONNECT MDM_write_timeout Used as timeout for writes of commands to modem MDM_echo_timeout Used as timeout for echoing of commands written to modem MDM_drain_timeout Timeout period to watch modem and drain any leftover characters before sending init string MDM_test_echo_timeout Used as timeout for testing whether the modem is echoing commands we send it MDM_dtr_hangup_sleep How many seconds should we sleep after lowering DTR to ensure disconnect MDM_settle_time How many seconds should we sleep after receiving the lockfile -------------------------------------------------------------------- */ int MDM_send(int modem, char *str); int MDM_response(int modem, int timeout); void fcntl_set(int fd, int flags); void fcntl_clear(int fd, int flags); int MDM_init(char *modem_file, char data, char parity, char stop, char flow, long baud); int MDM_dial(char *number, char data, char parity, char stop, long baud); void MDM_release_lock(void); void MDM_obtain_lock(char *device); void MDM_hangup(int modem); int toggle_DTR(int modem, long sleep_period); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int SMS_dial(char *number, char *params, long baud) { int fd; lprintf(LOG_VERBOSE, "Using SMSmodem Package\n"); fd = MDM_dial(number, params[0], /* Bits */ params[1], /* Parity */ params[2], /* Stop */ baud); /* Baud */ return fd; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void SMS_hangup(int modem) { MDM_hangup(modem); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *get_response(int id) { RESPONSE *ptr; ptr = response_list; while (ptr->response_str != NULL) { if (ptr->response_code == id) { return ptr->response_str; } ptr++; } return "UNKOWN"; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int MDM_send(int modem, char *str) { char buf[1024]; int res; res = twrite(modem, str, strlen(str), MDM_write_timeout); if (res) { return(res); } if (modem_echo) { /* The modem is echoing our commands. So we */ /* should expect to read these back */ res = expnstr(modem, buf, str, strlen(str), MDM_echo_timeout); if (res) { return(res); } } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int MDM_response(int modem, int timeout) { int i; char buf[MAX_BUFSIZE]; int res; res = expstr(modem, buf, response_prefix, MAX_BUFSIZE, timeout); if (res) { if (res == -2) { return(MDM_DISCONNECTED); } return(res); } res = expstr(modem, buf, response_suffix, MAX_BUFSIZE, timeout); if (res) { if (res == -2) { return(MDM_DISCONNECTED); } return(res); } for(i=0; response_list[i].response_str != NULL; i++) { if (strncmp(buf, response_list[i].response_str, strlen(response_list[i].response_str)) == 0) { return(response_list[i].response_code); } } return(MDM_UNKNOWN_RESPONSE); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void fcntl_set(int fd, int flags) { int val; if ((val = fcntl(fd, F_GETFL, 0)) < 0) { lprintf(LOG_ERROR, "MODEM: fcntl F_GETFL\n"); exit(-1); } val |= flags; if (fcntl(fd, F_SETFL, val) < 0) { lprintf(LOG_ERROR, "MODEM: fcntl F_SETFL\n"); exit(-1); } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void fcntl_clear(int fd, int flags) { int val; if ((val = fcntl(fd, F_GETFL, 0)) < 0) { lprintf(LOG_ERROR, "MODEM: fcntl F_GETFL\n"); exit(-1); } val &= ~flags; if (fcntl(fd, F_SETFL, val) < 0) { lprintf(LOG_ERROR, "MODEM: fcntl F_SETFL\n"); exit(-1); } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void MDM_release_lock(void) { resource_unlock(modem_lockfile); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void MDM_obtain_lock(char *device) { int no_block, notify; resource_check_lockdir(modem_lockfile); /* Exit with message if lockdir */ /* does not exist or we dont */ /* have write permissions */ if (strcmp("NO_BLOCK", lock_action) == 0) { no_block = TRUE; } else if (strcmp("BLOCK", lock_action) == 0) { no_block = FALSE; } else { lprintf(LOG_WARNING, "MDM_lock_action invalid, defaulting to NO_BLOCK\n"); no_block = TRUE; } notify = TRUE; while(resource_lock(modem_lockfile)) { if (no_block) { lprintf(LOG_ERROR, "Could not obtain lock for modem device\n"); lprintf(LOG_STANDARD, "Another program is using the modem.\n"); exit(-1); } if (notify) { lprintf(LOG_VERBOSE, "Blocking on lockfile '%s'\n", modem_lockfile); lprintf(LOG_STANDARD, "Another program is using the modem.\n"); lprintf(LOG_STANDARD, "Waiting...\n"); notify = FALSE; } resource_wait(modem_lockfile, MDM_lock_retry_delay); } if (!notify) { lprintf(LOG_STANDARD, "Modem is now free.\n"); lprintf(LOG_STANDARD, "Continuing...\n"); } atexit(MDM_release_lock); /* Establish EXIT handler */ /* to release the lockfile if */ /* we leave prematurely */ sleep(MDM_settle_time); /* Allow modem to settle down */ /* I might have just obtained */ /* The lock on the device from */ /* another process */ } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int MDM_init(char *modem_file, char data, char parity, char stop, char flow, long baud) { int retry, modem, t_baud; modem = open(modem_file, O_RDWR|O_NONBLOCK); if (modem == -1) { lprintf(LOG_WARNING, "MODEM: Failed to open %s\n", modem_file); return -1; } /* ---------------------------- */ /* Toggle DTR to reset modem */ /* ---------------------------- */ if (toggle_DTR(modem, MDM_dtr_init_sleep)) { lprintf(LOG_WARNING, "MODEM: Failed to toggle DTR\n"); close(modem); return -1; } /* ---------------------------- */ /* Get terminal line state */ /* ---------------------------- */ retry = 3; while (retry--) { if (tcgetattr(modem, &t) == -1) { lprintf(LOG_WARNING, "MODEM: Failed tcgetattr() errno %d\n", errno); if (retry == 1) { close(modem); return -1; } sleep(1); } else { retry = 0; } } /* ---------------------------- */ /* Save original line state */ /* ---------------------------- */ retry = 3; while (retry--) { if (tcgetattr(modem, &t_orig) == -1) { lprintf(LOG_WARNING, "MODEM: Failed tcgetattr() errno %d\n", errno); if (retry == 1) { close(modem); return -1; } sleep(1); } else { retry = 0; } } /* ---------------------------- */ /* Set up terminal attributes */ /* for the device */ /* ---------------------------- */ t.c_cflag = 0; t.c_oflag = 0; /* Turn off all output processing */ t.c_iflag = 0; t.c_lflag = 0; /* Everything off in local flags, */ /* disables: */ /* canonical mode */ /* signal generation */ /* echo */ t.c_cc[VMIN] = 1; /* 1 Character buffer */ t.c_cc[VTIME] = 0; /* Block indefinitely */ t.c_cflag |= CREAD | /* Enable receiver */ CLOCAL | HUPCL; /* Lower modem lines on last close */ /* 1 stop bit (since CSTOPB off) */ /* ---------------------------- */ /* Set data bits 5 through 8 */ /* ---------------------------- */ t.c_cflag &= ~(CSIZE); /* Mask data size */ switch (data) { case '5': t.c_cflag |= CS5; /* Set 5 bits */ break; case '6': t.c_cflag |= CS6; /* Set 6 bits */ break; case '7': t.c_cflag |= CS7; /* Set 7 bits */ break; case '8': t.c_cflag |= CS8; /* Set 8 bits */ break; default: lprintf(LOG_ERROR, "MODEM: Number of bits must be either 5,6,7 or 8\n"); close(modem); return -1; } /* ---------------------------- */ /* Set parity Even, Odd or None */ /* ---------------------------- */ switch (parity) { case 'E': t.c_cflag |= PARENB; /* Enable parity */ break; case 'O': t.c_cflag |= PARENB; /* Enable parity */ t.c_cflag |= PARODD; /* set parity to odd */ break; case 'N': break; /* No parity DEFAULT */ default: lprintf(LOG_ERROR, "MODEM: Parity must be either E,O or N\n"); close(modem); return -1; } /* ---------------------------- */ /* Set stop bits 1 or 2 */ /* ---------------------------- */ switch (stop) { case '2': t.c_cflag |= CSTOPB; /* 2 Stop bits */ break; case '1': /* 1 Stop bits DEFAULT */ break; default: lprintf(LOG_ERROR, "MODEM: Stop bits must be either 1 or 2\n"); close(modem); return -1; } /* ---------------------------- */ /* Set flow control */ /* Hardware or Software */ /* ---------------------------- */ switch (flow) { #if defined(LINUX) || defined(SOLARIS) case 'H': t.c_cflag |= CRTSCTS; /* Hardware Flow */ /* control */ break; #endif case 'S': t.c_iflag |= IXON | /* Xon/Xoff Flow */ IXOFF | /* control */ IXANY; break; default: #if !defined(LINUX) && !defined(SOLARIS) lprintf(LOG_ERROR, "MODEM: Flow control must be S for this platform\n"); #else lprintf(LOG_ERROR, "MODEM: Flow control must be either H or S for this platform\n"); #endif close(modem); return -1; } /* ---------------------------- */ /* Set baud rate */ /* Convert from numeric to */ /* defines set in termios */ /* ---------------------------- */ if (baud >= 38400) { t_baud = B38400; } else if (baud >= 19200) { t_baud = B19200; } else if (baud >= 9600) { t_baud = B9600; } else if (baud >= 4800) { t_baud = B4800; } else if (baud >= 2400) { t_baud = B2400; } else if (baud >= 1200) { t_baud = B1200; } else { t_baud = B300; } if (cfsetispeed(&t, t_baud) == -1) /* Set Input Baud rate */ { lprintf(LOG_WARNING, "MODEM: Failed Trying to set Input baud to %ld\n", baud); close(modem); return -1; } if (cfsetospeed(&t, t_baud) == -1) /* Set output Baud rate */ { lprintf(LOG_WARNING, "MODEM: Failed Trying to set Output baud to %ld\n", baud); close(modem); return -1; } /* ---------------------------- */ /* Apply changes to modem */ /* device */ /* ---------------------------- */ if (tcflush(modem, TCIOFLUSH) == -1) { lprintf(LOG_WARNING, "MODEM: Failed tcflush()\n"); close(modem); return -1; } if (tcsetattr(modem,TCSANOW, &t) == -1) { lprintf(LOG_WARNING, "MODEM: Failed tcsetattr()\n"); close(modem); return -1; } /* ---------------------------- */ /* Reset mode to blocking */ /* ---------------------------- */ fcntl_clear(modem, O_NONBLOCK); if (toggle_DTR(modem, MDM_dtr_init_sleep)) { lprintf(LOG_WARNING, "MODEM: Failed to toggle DTR\n"); close(modem); return -1; } modem_status = MODEM_OPEN; return modem; } /* -------------------------------------------------------------------- */ /* Send AT string. Check if result contains AT. */ /* If command is echoed then set modem_echo flag. */ /* -------------------------------------------------------------------- */ int test_modem_echo(int modem) { char buf[MAX_BUFSIZE], str[MAX_BUFSIZE]; strcpy(str, command_prefix); strcat(str, command_suffix); if (twrite(modem, str, strlen(str), MDM_write_timeout)) { return(-1); } if (expstr(modem, buf, response_prefix, MAX_BUFSIZE, MDM_echo_timeout)) { return(-1); } if (strncmp(buf, str, strlen(str)) == 0) { modem_echo = TRUE; lprintf(LOG_VERBOSE, "MODEM: Modem echo is set to ON\n"); } else { modem_echo = FALSE; lprintf(LOG_VERBOSE, "MODEM: Modem echo is set to OFF\n"); } if (expstr(modem, buf, response_suffix, MAX_BUFSIZE, MDM_echo_timeout)) { return(-1); } if (strncmp(buf, "OK", strlen("OK"))) { return(-1); } return 0; } /* -------------------------------------------------------------------- */ /* Send ATE0 string to set local echo to off. */ /* -------------------------------------------------------------------- */ int set_local_echo(int modem) { char str[MAX_BUFSIZE]; int res; sms_usleep(test_guard_time); if (twrite(modem, "\r", strlen("\r"), MDM_write_timeout)) { return(-1); } sms_usleep(test_guard_time); if (twrite(modem, "\r", strlen("\r"), MDM_write_timeout)) { return(-1); } sms_usleep(test_guard_time); strcpy(str, command_prefix); strcat(str, set_local_echo_off); strcat(str, command_suffix); if (twrite(modem, str, strlen(str), MDM_write_timeout)) { return(-1); } if ((res = MDM_response(modem, MDM_response_timeout)) != MDM_OK) { return(-1); } lprintf(LOG_VERBOSE, "MODEM: Setting Local Modem Echo to OFF\n"); if (test_modem_echo(modem)) { return(-1); } if (modem_echo) { return(-1); } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int MDM_send_hangup(int modem) { char str[MAX_BUFSIZE], *ptr; int res, retry, hangup_status; hangup_status = FALSE; for (retry = soft_hangup_retries; retry > 0; retry--) { tcflush(modem, TCIOFLUSH); /* Flush all data */ sms_usleep(guard_time); /* Sleep for gaurd_time */ /* before transmitting */ /* any data */ for(ptr = attention_command; *ptr ;ptr++) { str[0] = *ptr; str[1] = '\0'; if (twrite(modem, str, strlen(str), MDM_write_timeout)) { break; } if (ptr[1] != '\0') { sms_usleep(esc_time); } } if (*ptr) { lprintf(LOG_WARNING, "MODEM: Failed to issue attention command - %s\n", attention_command); break; } sms_usleep(guard_time); /* Sleep for gaurd_time */ /* before transmitting */ /* any data */ res = MDM_response(modem, MDM_hangup_timeout); if (res != MDM_OK) { lprintf(LOG_WARNING, "MODEM: Expecting OK response - %s\n", get_response(res)); } sms_usleep(guard_time); /* Sleep for gaurd_time */ strcpy(str, command_prefix); strcat(str, command_suffix); twrite(modem, str, strlen(str), MDM_write_timeout); res = MDM_response(modem, MDM_hangup_timeout); if (res != MDM_OK) { lprintf(LOG_WARNING, "MODEM: Expecting OK response - %s\n", get_response(res)); } strcpy(str, command_prefix); strcat(str, hangup_command); strcat(str, command_suffix); twrite(modem, str, strlen(str), MDM_write_timeout); res = MDM_response(modem, MDM_hangup_timeout); if (res != MDM_OK) { if ((res == MDM_NO_CARRIER) || (res == MDM_DISCONNECTED)) { hangup_status = TRUE; break; } lprintf(LOG_WARNING, "MODEM: Expecting OK response - %s\n", get_response(res)); } else { hangup_status = TRUE; break; } } return hangup_status; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int toggle_DTR(int modem, long sleep_period) { #if defined(TIOCSDTR) lprintf(LOG_VERBOSE, "MODEM: Toggle DTR using ioctl() %ld Microseconds\n", sleep_period); if (ioctl(modem, TIOCCDTR, 0) == -1) { lprintf(LOG_WARNING, "MODEM: Failed ioctl() errno %d\n", errno); } sms_usleep(sleep_period); /* Allow things to */ /* Settle down DTR may */ /* need to be left */ /* lowered for a period */ /* of time */ if (ioctl(modem, TIOCSDTR, 0) == -1) { lprintf(LOG_WARNING, "MODEM: Failed ioctl() errno %d\n", errno); } #else int retry; struct termios t, ot; lprintf(LOG_VERBOSE, "MODEM: Toggle DTR %ld Microseconds\n", sleep_period); retry = 3; while (retry--) { if (tcgetattr(modem, &t) == -1) { lprintf(LOG_WARNING, "MODEM: Failed tcgetattr() errno %d\n", errno); if (retry == 1) { close(modem); return -1; } sleep(1); } else { retry = 0; } } retry = 3; while (retry--) { if (tcgetattr(modem, &ot) == -1) { lprintf(LOG_WARNING, "MODEM: Failed tcgetattr() errno %d\n", errno); if (retry == 1) { close(modem); return -1; } sleep(1); } else { retry = 0; } } if ((cfsetospeed(&t, B0) == -1) || /* B0 causes */ (cfsetispeed(&t, B0) == -1)) /* DTR to be lowered */ { lprintf(LOG_WARNING, "MODEM: Failed cfsetspeed() - B0 HANGUP\n"); return -1; } retry = 3; while (retry--) { if (tcsetattr(modem,TCSANOW, &t) == -1) { lprintf(LOG_WARNING, "MODEM: Failed tcsetattr() errno %d - B0 HANGUP\n", errno); if (retry == 1) { return -1; } sleep(1); } else { retry = 0; } } sms_usleep(sleep_period); /* Allow things to */ /* Settle down DTR may */ /* need to be left */ /* lowered for a period */ /* of time */ retry = 3; while (retry--) { if (tcsetattr(modem,TCSANOW, &ot) == -1) { lprintf(LOG_WARNING, "MODEM: Failed tcsetattr() errno %d - setting speed\n", errno); if (retry == 1) { return -1; } sleep(1); } else { retry = 0; } } #endif return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void MDM_hangup(int modem) { int retry; if (modem_status == MODEM_CLOSED) { return; } MDM_send_hangup(modem); toggle_DTR(modem, MDM_dtr_hangup_sleep); if (strcmp(restore_terminal, "YES") == 0) { lprintf(LOG_VERBOSE, "MODEM: Returning Terminal to original settings\n"); retry = 3; while (retry--) { if (tcsetattr(modem, TCSANOW, &t_orig) == -1) { /* Failed to return */ /* to original terminal */ /* settings */ lprintf(LOG_WARNING, "MODEM: Failed tcsetattr() errno %d - Trying to return modem device to original settting\n", errno); sleep(1); } else { retry = 0; } } } close(modem); modem_status = MODEM_CLOSED; lprintf(LOG_VERBOSE, "MODEM: Hangup Complete\n"); resource_unlock(modem_lockfile); /* Remove lock file */ /* on this device */ } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int MDM_dial(char *number, char data, char parity, char stop, long baud) { struct stat stat_buf; int modem, res, ring_count; char str[MAX_BUFSIZE], fname[MAX_BUFSIZE]; strcpy(fname, MODEMDIR); sms_filecat(fname, "sms_modem"); if (read_resource_file(fname, resource_list, TRUE) != RESOURCE_FILE_OK) { lprintf(LOG_ERROR, "MODEM: Unrecoverable Failure Parsing modem file '%s'\n", fname); exit(-1); } strcpy(modem_file, device_dir); strcat(modem_file, device); strcpy(modem_lockfile, lock_dir); sms_filecat(modem_lockfile, lock_prefix); if (stat(modem_file, &stat_buf) == -1) { lprintf(LOG_ERROR, "MODEM: stat() Failed\n"); lprintf(LOG_STANDARD, "\n"); lprintf(LOG_STANDARD, "Ensure that the device entry '%s' exists\n", modem_file); lprintf(LOG_STANDARD, "If you want to use a different device, change the\n"); lprintf(LOG_STANDARD, "value of 'MDM_device' in '%s' to that device.\n", MODEMDIR "/sms_modem"); lprintf(LOG_STANDARD, "\n"); exit(-1); } if (strcmp(lock_platform, "SOLARIS") == 0) { #if defined(SOLARIS) sms_snprintf(&modem_lockfile[strlen(modem_lockfile)], 64, "%03u.%03u.%03u", (unsigned int)(major(stat_buf.st_dev)), (unsigned int)(stat_buf.st_rdev >> 18), (unsigned int)(minor(stat_buf.st_rdev))); lprintf(LOG_VERBOSE, "Generating SOLARIS style lockfile '%s'\n", modem_lockfile); #else lprintf(LOG_ERROR, "SOLARIS style lockfiles only supported under SOLARIS\n"); exit(-1); #endif } else { if (strcmp(lock_platform, "TRADITIONAL") != 0) { lprintf(LOG_WARNING, "MODEM: MDM_lock_platform invalid using 'TRADITIONAL'\n"); } strcat(modem_lockfile, device); } if ((strcmp(flow_control, "Software") != 0) && (strcmp(flow_control, "Hardware") != 0)) { lprintf(LOG_ERROR, "MODEM: MDM_flow_control must be either 'Software' or 'Hardware'\n"); exit(-1); } MDM_obtain_lock(device); /* May Block until lock */ /* obtained. This is dependant */ /* on 'lock_action' set to */ /* BLOCK or NO_BLOCK */ modem = MDM_init(modem_file, data, parity, stop, flow_control[0], baud); if (modem < 0) { lprintf(LOG_ERROR, "MODEM: MDM_init() Failed\n"); exit(-1); } if (MDM_drain_timeout != 0) { /* Drain any pending chars from modem */ lprintf(LOG_VERBOSE, "MDM_send: Drain required.\n"); while (expdrain(modem, MDM_drain_timeout)) { lprintf(LOG_VERBOSE, "MDM_send: Draining."); } } if (strcmp(MDM_disable_echo_test, "NO") == 0) { if (set_local_echo(modem) == -1) { lprintf(LOG_ERROR, "MODEM: Setting Local echo Failed\n"); exit(-1); } } strcpy(str, command_prefix); strcat(str, init_command); strcat(str, command_suffix); lprintf(LOG_VERBOSE, "MODEM: Sending Initialization string %s to modem\n", str); if (MDM_send(modem, str) != 0) { lprintf(LOG_VERBOSE, "MODEM: Sending Initialization string\n"); exit(-1); } lprintf(LOG_VERBOSE, "MODEM: Waiting for Initialization to complete...\n"); if ((res = MDM_response(modem, MDM_response_timeout)) != MDM_OK) { lprintf(LOG_VERBOSE, "MODEM: Expecting OK response - %s\n", get_response(res)); exit(-1); } lprintf(LOG_VERBOSE, "MODEM: Initialization complete\n"); if (MDM_pause_before_dial) { lprintf(LOG_VERBOSE, "MODEM: Pause before dialing\n"); lprintf(LOG_VERBOSE, "MODEM: Sleeping for %ld Microseconds...\n", MDM_pause_before_dial); sms_usleep(MDM_pause_before_dial); } lprintf(LOG_VERBOSE, "MODEM: Dialing %s\n", number); strcpy(str, command_prefix); strcat(str, dial_command); strcat(str, number_prefix); strcat(str, number); strcat(str, command_suffix); lprintf(LOG_VERBOSE, "MODEM: Sending dial string %s to modem\n", str); if (MDM_send(modem, str) != 0) { lprintf(LOG_ERROR, "MODEM: Sending dial string\n"); exit(-1); } lprintf(LOG_VERBOSE, "MODEM: Waiting for Connection...\n"); ring_count = 0; while ((res = MDM_response(modem, MDM_connect_timeout)) == MDM_RINGING) { lprintf(LOG_VERBOSE, "MODEM: Ringing...\n"); ring_count++; if (ring_count > MDM_max_rings) { lprintf(LOG_WARNING, "MODEM: Expecting CONNECT within %ld rings\n", MDM_max_rings); break; } } if (res != MDM_CONNECT) { lprintf(LOG_VERBOSE, "MODEM: Expecting CONNECT response - %s\n", get_response(res)); exit(-1); } lprintf(LOG_VERBOSE, "MODEM: Connection Established.\n"); if (MDM_pause_after_connect != 0) { lprintf(LOG_VERBOSE, "MODEM: Pausing after connection...\n"); usleep(MDM_pause_after_connect); lprintf(LOG_VERBOSE, "MODEM: Continuing.\n"); } return modem; } smsclient-2.0.8z/src/comms/expect.c0000644000175000017500000002244410127274503017154 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* expect.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "error.h" /* -------------------------------------------------------------------- */ #define MAX_LINE 4096 volatile sig_atomic_t caught_alarm = 0; /* -------------------------------------------------------------------- */ static void signal_alarm(int); static int expread(int, char *); static int expwrite(int, char *); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void signal_alarm(int signo) { caught_alarm = 1; } /* -------------------------------------------------------------------- */ /* Ensure that read() and write() systems calls are */ /* not restarted automatically on receipt of a SIGALRM. */ /* -------------------------------------------------------------------- */ int starttimer(int duration) { struct sigaction act; act.sa_flags = 0; act.sa_handler = signal_alarm; sigemptyset(&act.sa_mask); #if defined(SA_INTERRUPT) act.sa_flags |= SA_INTERRUPT; #endif caught_alarm = 0; sigaction(SIGALRM, &act, NULL); return alarm(duration); } /* -------------------------------------------------------------------- */ /* Read explen characters from fd and copy to str, */ /* appending '\0'. Compare explen characters of str with expect_string. */ /* */ /* Return Values: */ /* */ /* 0 Expect_string is found before timeout expires */ /* -1 Error or Timeout exceeded */ /* */ /* -------------------------------------------------------------------- */ int expnstr(int fd, char *str, char *expect_string, int explen, int timeout) { int i; char *ptr; /* ---------------------------- */ starttimer(timeout); /* ---------------------------- */ ptr = str; for (i=0; i= maxlen) { alarm(0); return -1; } switch (expread(fd, ptr)) { case 1: { ptr++; len++; break; } case 0: { *ptr = '\0'; alarm(0); lprintf(LOG_WARNING, "EOF Detected\n"); return -1; } default: { /* Timeout */ *ptr = '\0'; alarm(0); lprintf(LOG_ERROR, "Timeout: searching for +%s+ failed after %d seconds\n", expect_string, timeout); lprintf(LOG_VERBOSE, "Received String: +%s+\n", str); return -1; } } } cmpptr = str; while (len < (maxlen -1)) { if (strncmp(cmpptr, expect_string, explen) == 0) { *ptr = '\0'; alarm(0); lprintf(LOG_VERBOSE, "Received String: +%s+\n", str); return 0; } cmpptr++; switch (expread(fd, ptr)) { case 1: { ptr++; len++; break; } case 0: { *ptr = '\0'; alarm(0); lprintf(LOG_WARNING, "EOF Detected\n"); return -1; } default: { /* Timeout */ *ptr = '\0'; alarm(0); lprintf(LOG_ERROR, "Timeout: searching for +%s+ failed after %d seconds\n", expect_string, timeout); lprintf(LOG_VERBOSE, "Received String: +%s+\n", str); return -1; } } } *ptr = '\0'; alarm(0); lprintf(LOG_ERROR, "Buffer Length exceeded: searching for +%s+ failed after reading %d bytes\n", expect_string, (maxlen -1)); lprintf(LOG_VERBOSE, "Received String: +%s+\n", str); return -1; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int expdrain(int fd, int timeout) { int n, drain; char c; /* ---------------------------- */ starttimer(timeout); /* ---------------------------- */ lprintf(LOG_VERYVERBOSE, "Draining any remaining data...\n"); drain = TRUE; n = 0; while (drain) { switch (expread(fd, &c)) { case 1: n++; break; case 0: lprintf(LOG_WARNING, "EOF Detected [338]\n"); drain = FALSE; break; default: /* Timeout */ drain = FALSE; break; } } lprintf(LOG_VERYVERBOSE, "Drain complete\n"); alarm(0); return n; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int expread(int fd, char *buf) { int len; do { if (caught_alarm) { lprintf(LOG_WARNING, "read() Timeout\n"); return -1; } len = read(fd, buf, 1); if (len == -1) { if (errno != EINTR) { lprintf(LOG_ERROR, "read() Failed with errno %d\n", errno); return -1; } } } while (len == -1); if (len == 1) { lprintf(LOG_VERYVERBOSE, "Received Character: +%c+\n", *buf); } else if (len == 0) { lprintf(LOG_VERBOSE, "read() Returned EOF\n"); } else { lprintf(LOG_WARNING, "read() Unexpected return value %d\n", len); } return len; } /* -------------------------------------------------------------------- */ /* Write len bytes of buf to fd, return prematurely on timeout */ /* Return Values: */ /* */ /* -1 On timeout */ /* 0 Success */ /* -------------------------------------------------------------------- */ int twrite(int fd, char *buf, int len, int timeout) { char *ptr, *line; int i; /* ---------------------------- */ starttimer(timeout); /* ---------------------------- */ ptr = buf; for (i=0; i #include #include "common/common.h" #include "logfile/logfile.h" #include "base64.h" #include "error.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char base64table[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *encodeBase64(char *str) { int data, count, value, i; char *ptr, *eptr, *encoded_data; encoded_data = (char *)malloc(sizeof(char) * (strlen(str) * 2)); if (encoded_data == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } data = 0; count = 0; ptr = str; eptr = encoded_data; while(*ptr != 0) { count++; data |= (*ptr << ((3 - count) * 8)); if (count == 3) { for(i=0; i<4; i++) { value = (data >> ((3 - i) * 6)) & 0x003F; *eptr++ = base64table[value]; } data = 0; count = 0; } ptr++; } if (count == 2) { /* = */ for(i=0; i<3; i++) { value = (data >> ((3 - i) * 6)) & 0x003F; *eptr++ = base64table[value]; } *eptr++ = '='; } if (count == 1) { /* == */ for(i=0; i<2; i++) { value = (data >> ((3 - i) * 6)) & 0x003F; *eptr++ = base64table[value]; } *eptr++ = '='; *eptr++ = '='; } *eptr = '\0'; return encoded_data; } smsclient-2.0.8z/src/comms/modem.h0000644000175000017500000000304710127274503016770 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* sms_modem.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ int SMS_dial(char *number, char *params, long baud); void SMS_hangup(int modem); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/comms/http.h0000644000175000017500000000314110127274503016641 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* http.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ char *slurp_data(int fd, int *filelen); char *get_document(char *url, int *data_len, char *method, char *data, char *authentication); char *get_simple_document(char *url, int *data_len); char *escape_input(char *src); /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/comms/url.c0000644000175000017500000001400410127274503016457 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* url.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include "url.h" #include "common/common.h" #include "logfile/logfile.h" #include "error.h" /* -------------------------------------------------------------------- */ #define PARSING_PROTOCOL 0 #define PARSING_HOST 1 #define PARSING_PORT 2 #define PARSING_DIRECTORY 3 #define PARSING_FILENAME 4 #define PARSING_COMPLETE 5 #define PARSING_ERROR -1 #define PARSING_ALLOC_ERROR -1 /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int parse_url(char *str, URL *url) { char *ptr, *buf; int state; if ((str == NULL) || (*str == '\0')) { return -1; } buf = (char *)malloc(sizeof(char) * (strlen(str) +1)); if (buf == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } state = PARSING_PROTOCOL; ptr = str; while ((state != PARSING_ERROR) && (state != PARSING_COMPLETE) && (state != PARSING_ALLOC_ERROR)) { switch (state) { case PARSING_PROTOCOL: /* Gobble 'http://' */ { if (strncasecmp(ptr, "http://", strlen("http://")) == 0) { ptr += strlen("http://"); state = PARSING_HOST; } else { state = PARSING_ERROR; } break; } case PARSING_HOST: /* Gobble 'host' */ { char *host_ptr; host_ptr = buf; while ((*host_ptr = *ptr)) { if (*ptr == '/') { state = PARSING_DIRECTORY; url->port = strdup("80"); if (url->port == NULL) { state = PARSING_ALLOC_ERROR; } break; } else if (*ptr == ':') { state = PARSING_PORT; ptr++; break; } host_ptr++; ptr++; } *host_ptr = '\0'; if (strlen(buf) == 0) { state = PARSING_ERROR; } url->host = strdup(buf); if (url->host == NULL) { state = PARSING_ALLOC_ERROR; } break; } case PARSING_PORT: /* Gobble 'port' */ { char *port_ptr; port_ptr = buf; while ((*port_ptr = *ptr)) { if (*ptr == '/') { state = PARSING_DIRECTORY; break; } port_ptr++; ptr++; } *port_ptr = '\0'; if (strlen(buf) == 0) { state = PARSING_ERROR; } url->port = strdup(buf); if (url->port == NULL) { state = PARSING_ALLOC_ERROR; } break; } case PARSING_DIRECTORY: /* Gobble 'directory' */ { char *last_seperator, *last_directory, *directory_ptr; last_seperator = NULL; last_directory = NULL; directory_ptr = buf; if (*ptr == '/') { while ((*directory_ptr = *ptr)) { if (*ptr == '/') { last_seperator = directory_ptr; last_directory = ptr; } directory_ptr++; ptr++; } *directory_ptr = '\0'; if (last_seperator == NULL) { state = PARSING_ERROR; } else { *last_seperator = '\0'; if (strlen(buf) == 0) { strcpy(buf, "/"); } url->directory = strdup(buf); if (url->directory == NULL) { state = PARSING_ALLOC_ERROR; } ptr = last_directory+1; state = PARSING_FILENAME; } } else { state = PARSING_ERROR; } break; } case PARSING_FILENAME: /* Gobble 'filename' */ { char *filename_ptr; filename_ptr = buf; while ((*filename_ptr = *ptr)) { filename_ptr++; ptr++; } *filename_ptr = '\0'; url->filename = strdup(buf); if (url->filename == NULL) { state = PARSING_ALLOC_ERROR; } state = PARSING_COMPLETE; break; } default: /* Failure */ { ; } } } if (state == PARSING_COMPLETE) { strcpy(buf, url->directory); if (buf[strlen(buf) -1] != '/') { strcat(buf, "/"); } strcat(buf, url->filename); url->document = strdup(buf); if (url->document == NULL) { state = PARSING_ALLOC_ERROR; } else { if (buf != NULL) { free(buf); } return 0; } } if (buf != NULL) { free(buf); } if (url->host != NULL) { free(url->host); } if (url->port != NULL) { free(url->port); } if (url->document != NULL) { free(url->document); } if (url->directory != NULL) { free(url->directory); } if (url->filename != NULL) { free(url->filename); } return -1; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void free_url(URL *url) { if (url->host != NULL) { free(url->host); } if (url->port != NULL) { free(url->port); } if (url->document != NULL) { free(url->document); } if (url->directory != NULL) { free(url->directory); } if (url->filename != NULL) { free(url->filename); } } smsclient-2.0.8z/src/comms/http_twrite.c0000644000175000017500000000360210460431023020224 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include "http_twrite.h" #include "logfile/logfile.h" /* -------------------------------------------------------------------- */ static int timeout_flag; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void timeout_func(int sig) { timeout_flag = 1; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int http_twrite(int fd, char *buf, int len, int *timeout) { int using_timeout, bytes_written, total_written; time_t start_time, new_timeout; void (* orig_signal)(int); bytes_written = 0; total_written = 0; using_timeout = 0; timeout_flag = 0; start_time = 0; orig_signal = NULL; if ((timeout != NULL) && (*timeout != 0)) { using_timeout = 1; start_time = time(NULL); orig_signal = signal(SIGALRM, timeout_func); alarm(*timeout); } lprintf(LOG_VERYVERBOSE, "http_write: '%s'\n", buf); while (len > 0 ) { if (timeout_flag) { *timeout = 0; signal(SIGALRM, orig_signal); return bytes_written; } bytes_written = write(fd, &buf[total_written], len); if (bytes_written == -1) { if (errno != EINTR) { break; } } else { total_written += bytes_written; len -= bytes_written; } } if (using_timeout) { alarm(0); signal(SIGALRM, orig_signal); new_timeout = (*timeout - (time(NULL) - start_time)); if (new_timeout < 0) { new_timeout = 0; } *timeout = new_timeout; } return total_written; } smsclient-2.0.8z/src/comms/Makefile0000644000175000017500000000450410127274503017155 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- include ../../Makefile.config # -------------------------------------------------------------------- all: comms.a clean: $(RM) *.o *.bak comms.a # -------------------------------------------------------------------- INCLUDE = -I.. comms.a: expect.o modem.o tcpip.o base64.o url.o http.o http_tread.o http_twrite.o $(RM) comms.a $(AR) comms.a expect.o modem.o tcpip.o base64.o url.o http.o http_tread.o http_twrite.o $(RANLIB) comms.a expect.o: expect.c $(CC) $(CFLAGS) -c expect.c $(INCLUDE) base64.o: base64.c base64.h $(CC) $(CFLAGS) -c base64.c $(INCLUDE) url.o: url.c url.h $(CC) $(CFLAGS) -c url.c $(INCLUDE) http.o: http.c http.h http_tread.h http_twrite.h $(CC) $(CFLAGS) -c http.c $(INCLUDE) http_tread.o: http_tread.c http_tread.h $(CC) $(CFLAGS) -c http_tread.c $(INCLUDE) http_twrite.o: http_twrite.c http_twrite.h $(CC) $(CFLAGS) -c http_twrite.c $(INCLUDE) modem.o: modem.c $(CC) $(CFLAGS) -c modem.c -DMMODEMDIR="\"$(MSERVICEDIR)\"" $(INCLUDE) tcpip.o: tcpip.c $(CC) $(CFLAGS) -c tcpip.c $(INCLUDE) # -------------------------------------------------------------------- smsclient-2.0.8z/src/comms/url.h0000644000175000017500000000343410127274503016471 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* url.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ struct url_struct { char *host, *port, *document, *directory, *filename; }; typedef struct url_struct URL; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int parse_url(char *str, URL *url); void free_url(URL *url); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/parser/0000755000175000017500000000000011007610111015653 5ustar noodlesnoodlessmsclient-2.0.8z/src/parser/gs_translate.c0000644000175000017500000001655710460430574020542 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_translate.c */ /* */ /* Copyright (C) 1997,1998 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "gs_token.h" #include "gs_list.h" #include "gs_translate.h" #include "gs_parser.h" #include "gs_io.h" #include "error.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *get_word(char *string, char **eptr); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN_HEAP *gs_parse_file(char *file) { TOKEN_HEAP *token_heap; TOKEN_ID token_id; init_builtin_heap(); token_heap = (TOKEN_HEAP *)malloc(sizeof(TOKEN_HEAP)); if (token_heap == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } token_heap->list = NULL; if (gs_open(file)) { return NULL; } if (parse_dictionary(token_heap)) { token_id = get_next_token(token_heap); if (token_id != eof_tok) { gs_close(); return NULL; } } else { gs_close(); return NULL; } if (gs_close()) { return NULL; } return token_heap; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *get_word(char *string, char **eptr) { static char word[1024], *word_ptr, *ptr; if (*string == '\0') { return NULL; } word_ptr = word; ptr = string; while (*ptr != '\0') { if (*ptr == '.') { break; } *word_ptr++ = *ptr++; } *word_ptr = '\0'; if (*ptr != '\0') { ptr++; } *eptr = ptr; return word; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *get_strvalue(TOKEN_HEAP *heap, char *variable) { char *ptr, *str, *word; TOKEN *token; lprintf(LOG_VERYVERBOSE, "Searching for variable '%s'\n", variable); str = NULL; word = get_word(variable, &ptr); while(word != NULL) { token = find_item(heap->list, word, T_IDENTIFIER); if (token == NULL) { return NULL; } if (get_token_type(heap, token) == T_IDENTIFIER) { if ((get_token_indirect_type(heap, token) == TP_STRING) || (get_token_indirect_type(heap, token) == TP_NUMERIC)) { str = get_token_indirect_strvalue(heap, token); } else if ((get_token_indirect_type(heap, token) == TP_DICTIONARY) || (get_token_indirect_type(heap, token) == TP_LIST)) { heap = get_token_indirect_dictionary(heap, token); } } else { return NULL; } word = get_word(ptr, &ptr); } return str; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN *get_var(TOKEN_HEAP *heap, char *variable) { char *ptr, *word; TOKEN *token = NULL; lprintf(LOG_VERYVERBOSE, "Searching for variable '%s'\n", variable); word = get_word(variable, &ptr); while(word != NULL) { token = find_item(heap->list, word, T_IDENTIFIER); if (token == NULL) { return NULL; } if (get_token_type(heap, token) == T_IDENTIFIER) { if ((get_token_indirect_type(heap, token) == TP_DICTIONARY) || (get_token_indirect_type(heap, token) == TP_LIST)) { heap = get_token_indirect_dictionary(heap, token); } } else { return NULL; } word = get_word(ptr, &ptr); } return token; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN_HEAP *get_varlist(TOKEN_HEAP *heap, char *variable) { char *ptr, *word; TOKEN *token; word = get_word(variable, &ptr); while(word != NULL) { token = find_item(heap->list, word, T_IDENTIFIER); if (token == NULL) { return NULL; } if (get_token_type(heap, token) == T_IDENTIFIER) { if ((get_token_indirect_type(heap, token) == TP_DICTIONARY) || (get_token_indirect_type(heap, token) == TP_LIST)) { heap = get_token_indirect_dictionary(heap, token); } else { return NULL; } } else { return NULL; } word = get_word(ptr, &ptr); } return heap; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN_HEAP *get_varlist_element(TOKEN_HEAP *heap, int index) { char var[64]; sms_snprintf(var, 64, "[%d]", index); return get_varlist(heap, var); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *get_strvalue_element(TOKEN_HEAP *heap, int index) { char var[64]; sms_snprintf(var, 64, "[%d]", index); return get_strvalue(heap, var); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN_HEAP *dup_varlist(TOKEN_HEAP *heap, char *variable) { char *ptr, *word; TOKEN *token; word = get_word(variable, &ptr); while(word != NULL) { token = find_item(heap->list, word, T_IDENTIFIER); if (token == NULL) { return NULL; } if (get_token_type(heap, token) == T_IDENTIFIER) { if ((get_token_indirect_type(heap, token) == TP_DICTIONARY) || (get_token_indirect_type(heap, token) == TP_LIST)) { heap = get_token_indirect_dictionary(heap, token); } else { return NULL; } } else { return NULL; } word = get_word(ptr, &ptr); } /* duplicate the heap */ /* and return it. */ if (heap != NULL) { heap = dup_heap(heap); } return heap; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *in_varlist(TOKEN_HEAP *heap, char *variable) { char var[64], *str; int i; i = 0; while(TRUE) { sms_snprintf(var, 64, "[%d]", i); str = get_strvalue(heap, var); if (str != NULL) { if (strcmp(str, variable) == 0) { return str; } } else { return NULL; } i++; } return NULL; } smsclient-2.0.8z/src/parser/gs_token.c0000644000175000017500000004566710460430533017664 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_token.c */ /* */ /* Copyright (C) 1997,1998 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "gs_token.h" #include "gs_list.h" #include "gs_io.h" #include "error.h" /* -------------------------------------------------------------------- */ TOKEN_ID null_tok, eof_tok, assignment_tok, lparen_tok, rparen_tok, lcurly_tok, rcurly_tok, comma_tok, dot_tok, semicolon_tok, true_tok, false_tok, yes_tok, no_tok; struct init_token_struct { TOKEN_ID *var; char *str; int type; int type_ptr; void *ptr; } init_token_table[] = { { &null_tok, "", T_SPECIAL, 0, NULL }, { &eof_tok, "", T_SPECIAL, 0, NULL }, { &assignment_tok, "=", T_SPECIAL, 0, NULL }, { &lparen_tok, "(", T_SPECIAL, 0, NULL }, { &rparen_tok, ")", T_SPECIAL, 0, NULL }, { &lcurly_tok, "{", T_SPECIAL, 0, NULL }, { &rcurly_tok, "}", T_SPECIAL, 0, NULL }, { &comma_tok, ",", T_SPECIAL, 0, NULL }, { &dot_tok, ".", T_SPECIAL, 0, NULL }, { &semicolon_tok, ";", T_SPECIAL, 0, NULL }, { &true_tok, "TRUE", T_STRING, 0, NULL }, { &false_tok, "FALSE", T_STRING, 0, NULL }, { &yes_tok, "YES", T_STRING, 0, NULL }, { &no_tok, "NO", T_STRING, 0, NULL }, { NULL, NULL, T_SPECIAL, 0, NULL } }; static TOKEN_ID token_pushed = NULL; static TOKEN_HEAP builtin = { NULL }; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int is_valid_first_identifier_character(int character); static int is_valid_identifier_character(int character); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void push_back_token(TOKEN_ID token) { token_pushed = token; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int is_valid_first_identifier_character(int character) { if ((isalpha(character)) || (character == '_')) { return TRUE; } return FALSE; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int is_valid_identifier_character(int character) { if ((isalnum(character)) || (character == '_')) { return TRUE; } return FALSE; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *expand_environment_variables(char *str) { static char data[1024], env_str[1024], *env_value, *env_ptr, *dst, *src; dst = data; src = str; while(*src != '\0') { if (*src == '$') { env_ptr = env_str; src++; if (*src == '{') { src++; while((*src != '}') && (*src != '\0')) { *env_ptr++ = *src++; } *env_ptr = '\0'; fprintf(stderr, "FOUND VAR: '%s'\n", env_str); if (*src == '}') { src++; env_value = getenv(env_str); if (env_value != NULL) { strcpy(dst, env_value); dst += strlen(env_value); } } else { return NULL; } } else { return NULL; } } else { *dst++ = *src++; } } *dst = '\0'; return data; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN_ID get_next_token(TOKEN_HEAP *heap) { char str[1024], *str_ptr, *env_str, *nstr; long value; int character; TOKEN_ID token_id; if (token_pushed != NULL) { token_id = token_pushed; token_pushed = NULL; return token_id; } character = get_next_character(); /* ---------------------------- */ /* Throw away any whitespace */ /* ---------------------------- */ while (isspace(character)) { character = get_next_character(); } /* ---------------------------- */ /* Identifier - */ /* A String without any quotes */ /* ---------------------------- */ if (is_valid_first_identifier_character(character)) { str_ptr = str; while (is_valid_identifier_character(character)) { *str_ptr++ = character; character = get_next_character(); } *str_ptr = '\0'; push_character(character); lprintf(LOG_VERYVERBOSE, "Found Identifier '%s'\n", str); /* This Identifier could be a special */ /* reserved String. */ /* If it has a matching builtin string */ /* then return this. */ /* Else add the token as an identifier */ token_id = find_item(builtin.list, str, T_STRING); if (token_id != NULL) { lprintf(LOG_VERYVERBOSE, "Overriding Identifier with Builtin String\n"); } else { token_id = add_token(heap, str, T_IDENTIFIER, TP_NULL, NULL); } } else if (character == '$') { character = get_next_character(); str_ptr = str; while ((!isspace(character)) && (character != EOF)) { *str_ptr++ = character; character = get_next_character(); } *str_ptr = '\0'; lprintf(LOG_VERYVERBOSE, "Found Environment Variable '%s'\n", str); /* this is an environment variable */ /* expand it if it exists, else */ /* set it to an empty string */ env_str = getenv(str); if (env_str == NULL) { strcpy(str, ""); } else { strcpy(str, env_str); } lprintf(LOG_VERYVERBOSE, "Shell variable, expanding Identifier to '%s'\n", str); token_id = add_token(heap, str, T_STRING, TP_NULL, NULL); } else if (character == '"') { character = get_next_character(); str_ptr = str; while ((character != '"') && (character != EOF)) { if (character == '\\') { *str_ptr++ = escape_char(); } else { *str_ptr++ = character; } character = get_next_character(); } *str_ptr = '\0'; if (character == '"') { lprintf(LOG_VERYVERBOSE, "Found Identifier '%s'\n", str); nstr = expand_environment_variables(str); if (nstr != NULL) { token_id = add_token(heap, nstr, T_STRING, TP_NULL, NULL); } else { token_id = null_tok; } } else { token_id = null_tok; } } else if (isdigit(character)) { value = character - '0'; str_ptr = str; *str_ptr++ = character; character = get_next_character(); while (isdigit(character) && (character != EOF)) { value *= 10; value += character - '0'; *str_ptr++ = character; character = get_next_character(); } *str_ptr = '\0'; token_id = add_token(heap, str, T_NUMERIC, TP_NULL, NULL); } else if (character == '\'') { character = get_next_character(); str_ptr = str; while ((character != '\'') && (character != EOF)) { *str_ptr++ = character; character = get_next_character(); } *str_ptr = '\0'; if (character == '\'') { lprintf(LOG_VERYVERBOSE, "Found Identifier '%s'\n", str); token_id = add_token(heap, str, T_STRING, TP_NULL, NULL); } else { token_id = null_tok; } } else if (character == '=') { token_id = assignment_tok; } else if (character == '(') { token_id = lparen_tok; } else if (character == ')') { token_id = rparen_tok; } else if (character == '{') { token_id = lcurly_tok; } else if (character == '}') { token_id = rcurly_tok; } else if (character == ',') { token_id = comma_tok; } else if (character == '.') { token_id = dot_tok; } else if (character == ';') { token_id = semicolon_tok; } else if (character == EOF) { token_id = eof_tok; } else { token_id = null_tok; } lprintf(LOG_VERYVERBOSE, "Token id = %p\n", (void *) token_id); return token_id; } /* -------------------------------------------------------------------- */ /* Add token searches the token heap for 'str' */ /* -------------------------------------------------------------------- */ TOKEN_ID add_token(TOKEN_HEAP *heap, char *str, int type, int ptr_type, void *ptr) { TOKEN_ID token; lprintf(LOG_VERYVERBOSE, "Entering add_token()\n"); heap->list = add_token_list_item(heap->list, &token, str, type, ptr_type, ptr); lprintf(LOG_VERYVERBOSE, "returning %p\n", (void *) token); return token; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *get_token_strvalue(TOKEN_HEAP *heap, TOKEN_ID token_id) { return token_id->str; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ long get_token_numvalue(TOKEN_HEAP *heap, TOKEN_ID token_id) { return token_id->value; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *get_token_strtype(TOKEN_HEAP *heap, TOKEN_ID token_id) { return "UNKNOWN"; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int get_token_type(TOKEN_HEAP *heap, TOKEN_ID token_id) { return token_id->type; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int get_token_indirect_type(TOKEN_HEAP *heap, TOKEN_ID token_id) { return token_id->ptr_type; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *get_token_indirect_strvalue(TOKEN_HEAP *heap, TOKEN_ID token_id) { return token_id->ptr; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ long get_token_indirect_numvalue(TOKEN_HEAP *heap, TOKEN_ID token_id) { return token_id->value; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN_HEAP *get_token_indirect_dictionary(TOKEN_HEAP *heap, TOKEN_ID token_id) { return (TOKEN_HEAP *)token_id->ptr; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN_HEAP *get_token_indirect_list(TOKEN_HEAP *heap, TOKEN_ID token_id) { return (TOKEN_HEAP *)token_id->ptr; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void token_assign_strvalue(TOKEN_HEAP *heap, TOKEN_ID token_id, char *string) { token_id->ptr_type = TP_STRING; token_id->ptr = string; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void token_assign_numvalue(TOKEN_HEAP *heap, TOKEN_ID token_id, long value) { token_id->ptr_type = TP_NUMERIC; token_id->value = value; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void token_assign_dictionary(TOKEN_HEAP *heap, TOKEN_ID token_id, TOKEN_HEAP *dictionary) { token_id->ptr_type = TP_DICTIONARY; token_id->ptr = dictionary; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void token_assign_list(TOKEN_HEAP *heap, TOKEN_ID token_id, TOKEN_HEAP *list) { token_id->ptr_type = TP_LIST; token_id->ptr = list; } /* -------------------------------------------------------------------- */ /* Add our reserved tokens to the reserved builtin heap. */ /* if builtin heap has been filled by an earlier call just */ /* return from this function. */ /* -------------------------------------------------------------------- */ void init_builtin_heap(void) { int i; if (builtin.list == NULL) { for (i=0; init_token_table[i].var != NULL; i++) { *(init_token_table[i].var) = add_token(&builtin, init_token_table[i].str, init_token_table[i].type, TP_NULL, init_token_table[i].ptr); } } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN_HEAP *init_heap(TOKEN_HEAP *heap) { heap->list = NULL; return heap; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN_HEAP *generate_new_heap(void) { TOKEN_HEAP *heap; heap = (TOKEN_HEAP *)malloc(sizeof(TOKEN_HEAP)); if (heap == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } return init_heap(heap); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void dump_heap(TOKEN_HEAP *heap, char *name) { dump_heaptofile(heap, name, stdout); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void dump_heaptofile_internal(TOKEN_HEAP *heap, char *name, FILE *fp, int level, int islist) { int i; TOKEN_LIST *item; TOKEN_ID token; if (heap == NULL) { return; } item = heap->list; while(item != NULL) { token = item->token; if (get_token_type(heap, token) == T_IDENTIFIER) { if (get_token_indirect_type(heap, token) == TP_STRING) { for(i=0; inext != NULL))?",":"")); } else if (get_token_indirect_type(heap, token) == TP_NUMERIC) { for(i=0; inext != NULL))?",":"")); } else if (get_token_indirect_type(heap, token) == TP_DICTIONARY) { for(i=0; inext != NULL))?",":"")); } else if (get_token_indirect_type(heap, token) == TP_LIST) { for(i=0; inext != NULL))?",":"")); } } item = item->next; } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void dump_heaptofile(TOKEN_HEAP *heap, char *name, FILE *fp) { fprintf(fp, "{\n"); dump_heaptofile_internal(heap, name, fp, 1, FALSE); fprintf(fp, "}\n"); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN_HEAP *dup_heap(TOKEN_HEAP *heap) { TOKEN_HEAP *new_heap, *list; TOKEN_LIST *item; TOKEN_ID token, new_token, identifier; char *str; if (heap == NULL) { return NULL; } new_heap = generate_new_heap(); item = heap->list; while(item != NULL) { token = item->token; if (get_token_type(heap, token) == T_IDENTIFIER) { identifier = add_token(new_heap, token->str, token->type, TP_NULL, NULL); if (get_token_indirect_type(heap, token) == TP_STRING) { str = get_token_indirect_strvalue(heap, token); new_token = add_token(new_heap, str, T_STRING, TP_NULL, NULL); str = get_token_strvalue(new_heap, new_token); token_assign_strvalue(new_heap, identifier, str); } else if ((get_token_indirect_type(heap, token) == TP_DICTIONARY) || (get_token_indirect_type(heap, token) == TP_LIST)) { list = dup_heap(get_token_indirect_dictionary(heap, token)); token_assign_list(new_heap, identifier, list); } } item = item->next; } return new_heap; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void free_heap(TOKEN_HEAP *heap) { TOKEN_LIST *item, *prev_item; TOKEN_ID token; item = heap->list; while(item != NULL) { token = item->token; if (get_token_type(heap, token) == T_IDENTIFIER) { if (get_token_indirect_type(heap, token) == TP_DICTIONARY) { free_heap(get_token_indirect_dictionary(heap, token)); } else if (get_token_indirect_type(heap, token) == TP_LIST) { free_heap(get_token_indirect_list(heap, token)); } } prev_item = item; item = item->next; free(prev_item->token->str); free(prev_item->token); free(prev_item); } } smsclient-2.0.8z/src/parser/gs_token.h0000644000175000017500000001035210127274515017656 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_token.h */ /* */ /* Copyright (C) 1997,1998 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #if !defined(_TOKEN_H_) #define _TOKEN_H_ 1 #include /* -------------------------------------------------------------------- */ /* Maximum number of tokens we can store in a */ /* heap. */ /* -------------------------------------------------------------------- */ #define MAX_TOKENS 1024 /* -------------------------------------------------------------------- */ struct token_struct { char *str; long value; /* Maybe we want numbers */ int type; int ptr_type; void *ptr; }; typedef struct token_struct TOKEN; /* -------------------------------------------------------------------- */ struct token_list_struct { TOKEN *token; struct token_list_struct *next; }; typedef struct token_list_struct TOKEN_LIST; /* -------------------------------------------------------------------- */ struct token_heap_struct { TOKEN_LIST *list; }; typedef struct token_heap_struct TOKEN_HEAP; /* -------------------------------------------------------------------- */ typedef TOKEN * TOKEN_ID; extern TOKEN_ID null_tok, eof_tok, assignment_tok, lparen_tok, rparen_tok, lcurly_tok, rcurly_tok, comma_tok, dot_tok, semicolon_tok; /* -------------------------------------------------------------------- */ #define T_NULL 0 #define T_IDENTIFIER 1 #define T_SPECIAL 2 #define T_STRING 3 #define T_NUMERIC 4 #define TP_NULL 0 #define TP_STRING 1 #define TP_DICTIONARY 2 #define TP_LIST 3 #define TP_NUMERIC 4 /* -------------------------------------------------------------------- */ TOKEN_ID get_next_token(TOKEN_HEAP *heap); TOKEN_ID add_token(TOKEN_HEAP *heap, char *str, int type, int ptr_type, void *ptr); char *get_token_strvalue(TOKEN_HEAP *heap, TOKEN_ID token_id); long get_token_numvalue(TOKEN_HEAP *heap, TOKEN_ID token_id); char *get_token_strtype(TOKEN_HEAP *heap, TOKEN_ID token_id); char *get_token_indirect_strvalue(TOKEN_HEAP *heap, TOKEN_ID token_id); void init_builtin_heap(void); void push_back_character(int character); void push_back_token(TOKEN_ID token); void dump_heap(TOKEN_HEAP *heap, char *name); void dump_heaptofile(TOKEN_HEAP *heap, char *name, FILE *fp); void token_assign_strvalue(TOKEN_HEAP *heap, TOKEN_ID token_id, char *string); void token_assign_numvalue(TOKEN_HEAP *heap, TOKEN_ID token_id, long value); void token_assign_dictionary(TOKEN_HEAP *heap, TOKEN_ID token_id, TOKEN_HEAP *dictionary); void token_assign_list(TOKEN_HEAP *heap, TOKEN_ID token_id, TOKEN_HEAP *dictionary); int get_token_type(TOKEN_HEAP *heap, TOKEN_ID token_id); int get_token_indirect_type(TOKEN_HEAP *heap, TOKEN_ID token_id); TOKEN_HEAP *generate_new_heap(void); TOKEN_HEAP *get_token_indirect_dictionary(TOKEN_HEAP *heap, TOKEN_ID token_id); TOKEN_HEAP *get_token_indirect_list(TOKEN_HEAP *heap, TOKEN_ID token_id); TOKEN_HEAP *dup_heap(TOKEN_HEAP *heap); TOKEN_HEAP *init_heap(TOKEN_HEAP *heap); void free_heap(TOKEN_HEAP *heap); /* -------------------------------------------------------------------- */ #endif smsclient-2.0.8z/src/parser/docs/0000755000175000017500000000000010127274514016622 5ustar noodlesnoodlessmsclient-2.0.8z/src/parser/docs/fig10000644000175000017500000000163710127274514017402 0ustar noodlesnoodles Token Heap List --------> Token ---------> Type T_IDENTIFIER /--- Next Str ----> "Name" | Ptr Type TP_STRING | Ptr ----------------------\ | | \--> Token ---------> Type T_IDENTIFIER | NULL Next Str ----> "Fred" <--/ Ptr Type NULL Ptr NULL The above diagram describes: { Name = "Fred" } NOTE - Looking at the above structures a few things Seem odd. Why is the Type field of the value 'Fred' T_IDENTIFIER Should we use T_STRING instead smsclient-2.0.8z/src/parser/docs/grammar0000644000175000017500000000144710127274514020201 0ustar noodlesnoodles GS Parser Grammar ----------------- = { } = = | = | = | = ( ) = = | = | = | , = | | = ' ' = " " = TRUE | FALSE | YES | NO smsclient-2.0.8z/src/parser/gs_parser.h0000644000175000017500000000341010127274515020027 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_parser.h */ /* */ /* Copyright (C) 1997,1998 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include "gs_token.h" /* -------------------------------------------------------------------- */ int parse_dictionary(TOKEN_HEAP *heap); int parse_list(TOKEN_HEAP *heap); int parse_list_items(TOKEN_HEAP *heap, int depth); int parse_dictionary_items(TOKEN_HEAP *heap); TOKEN_HEAP *gs_parse_file(char *file); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/parser/gs_io.c0000644000175000017500000001462110127274515017143 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_io.c */ /* */ /* Copyright (C) 1997,1998 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include "common/common.h" #include "gs_io.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #if 0 /* The Linux REDHAT distribution doesn't */ /* like this. Anyone using REDHAT like to */ /* spill the beans and tell me why? */ static FILE *parser_fp = stdin; #else static FILE *parser_fp = NULL; #endif /* -------------------------------------------------------------------- */ #define MAX_CHARACTER_STACK 512 static char character_stack[MAX_CHARACTER_STACK]; static int character_stack_top = -1; static int linenumber = 1; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int gs_open(char *file) { parser_fp = fopen(file, "r"); if (parser_fp == NULL) { return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int gs_close(void) { if (fileno(stdin) == fileno(parser_fp)) { return 0; } return fclose(parser_fp); } /* -------------------------------------------------------------------- */ /* If we have pushed back a character then return it, else */ /* return the next character. */ /* -------------------------------------------------------------------- */ int get_next_character(void) { int character; character = pop_character(); if (character != -1) { return character; } character = fgetc(parser_fp); if (character == '#') { character = fgetc(parser_fp); while (character != '\n') { character = fgetc(parser_fp); } } if (character == '\n') { linenumber++; } return character; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void init_linenumber(void) { linenumber = 1; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int get_linenumber(void) { return linenumber; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int push_character(int character) { if (character_stack_top +1 >= MAX_CHARACTER_STACK) { return -1; } character_stack_top++; character_stack[character_stack_top] = character; if (character == '\n') { linenumber--; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int pop_character(void) { int character; if (character_stack_top == -1) { return -1; } character = character_stack[character_stack_top]; character_stack_top--; if (character == '\n') { linenumber++; } return character; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int escape_char(void) { int character, escaped_character; character = get_next_character(); if (character == 'a') { escaped_character = '\f'; } else if (character == 'b') { escaped_character = '\b'; } else if (character == 'f') { escaped_character = '\f'; } else if (character == 'n') { escaped_character = '\n'; } else if (character == 'r') { escaped_character = '\r'; } else if (character == 't') { escaped_character = '\t'; } else if (character == 'v') { escaped_character = '\v'; } else if (character == 'x') { int low_nibble, high_nibble, high_character, low_character; character = get_next_character(); high_character = character; if (isxdigit(character)) { if ((character >= '0') && (character <= '9')) { high_nibble = (character - '0') << 4; } else if ((character >= 'a') && (character <= 'f')) { high_nibble = (10 + (character - 'a')) << 4; } else { high_nibble = (10 + (character - 'A')) << 4; } character = get_next_character(); low_character = character; if (isxdigit(character)) { if ((character >= '0') && (character <= '9')) { low_nibble = (character - '0'); } else if ((character >= 'a') && (character <= 'f')) { low_nibble = (10 + (character - 'a')); } else { low_nibble = (10 + (character - 'A')); } escaped_character = high_nibble + low_nibble; } else { /* Error */ push_character('x'); push_character(high_character); push_character(low_character); escaped_character = '\\'; } } else { /* Error */ push_character('x'); push_character(high_character); escaped_character = '\\'; } } else if (character == '\\') { escaped_character = '\\'; } else if (character == '\"') { escaped_character = '\"'; } else if (character == '\'') { escaped_character = '\''; } else { /* Error */ push_character(character); escaped_character = '\\'; } return escaped_character; } smsclient-2.0.8z/src/parser/gs_translate.h0000644000175000017500000000376010127274515020540 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_translate.h */ /* */ /* Copyright (C) 1997,1998 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include "gs_token.h" /* -------------------------------------------------------------------- */ TOKEN_HEAP *gs_parse_file(char *file); TOKEN_HEAP *get_varlist(TOKEN_HEAP *heap, char *variable); TOKEN_HEAP *dup_varlist(TOKEN_HEAP *heap, char *variable); TOKEN_HEAP *get_varlist_element(TOKEN_HEAP *heap, int index); char *get_strvalue_element(TOKEN_HEAP *heap, int index); char *get_strvalue(TOKEN_HEAP *heap, char *variable); char *in_varlist(TOKEN_HEAP *current_heap, char *variable); TOKEN *get_var(TOKEN_HEAP *heap, char *variable); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/parser/gs_parser.c0000644000175000017500000002107310127274515020027 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_parser.c */ /* */ /* Copyright (C) 1997,1998 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "gs_token.h" #include "gs_parser.h" #include "gs_io.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int parse_dictionary(TOKEN_HEAP *heap) { TOKEN_ID token_id; lprintf(LOG_VERYVERBOSE, "Entering parse_dictionary()\n"); token_id = get_next_token(heap); if (token_id == lcurly_tok) { if (parse_dictionary_items(heap)) { token_id = get_next_token(heap); if (token_id == rcurly_tok) { return TRUE; } else { lprintf(LOG_ERROR, "Line %d Expecting '}'\n", get_linenumber()); return FALSE; } } else { lprintf(LOG_ERROR, "Line %d Expecting Dictionary items\n", get_linenumber()); return FALSE; } } else { lprintf(LOG_ERROR, "Line %d Expecting '{'\n", get_linenumber()); return FALSE; } return TRUE; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int parse_list(TOKEN_HEAP *heap) { TOKEN_ID token_id; lprintf(LOG_VERYVERBOSE, "Entering parse_list()\n"); token_id = get_next_token(heap); if (token_id == lparen_tok) { if (parse_list_items(heap, 0)) { token_id = get_next_token(heap); if (token_id == rparen_tok) { return TRUE; } else { lprintf(LOG_ERROR, "Line %d Expecting ')'\n", get_linenumber()); return FALSE; } } else { lprintf(LOG_ERROR, "Line %d Expecting List items\n", get_linenumber()); return FALSE; } } else { lprintf(LOG_ERROR, "Line %d Expecting '('\n", get_linenumber()); return FALSE; } return TRUE; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int parse_list_items(TOKEN_HEAP *heap, int depth) { TOKEN_ID token_id, identifier; TOKEN_HEAP *dictionary, *list; long value; char buf[64], *string; lprintf(LOG_VERYVERBOSE, "Entering parse_list_items()\n"); sms_snprintf(buf, 64, "[%d]", depth); identifier = add_token(heap, buf, T_IDENTIFIER, TP_NULL, NULL); depth++; token_id = get_next_token(heap); if (token_id == lcurly_tok) { dictionary = generate_new_heap(); if (dictionary == NULL) { lprintf(LOG_ERROR, "Allocating memory\n"); return FALSE; } token_assign_dictionary(heap, identifier, dictionary); push_back_token(token_id); if (parse_dictionary(dictionary)) { token_id = get_next_token(heap); if (token_id == comma_tok) { return parse_list_items(heap, depth); } else { push_back_token(token_id); return TRUE; } } else { lprintf(LOG_ERROR, "Failed parsing Dictionary\n"); return FALSE; } } else if (token_id == lparen_tok) { list = generate_new_heap(); if (list == NULL) { lprintf(LOG_ERROR, "Allocating memory\n"); return FALSE; } token_assign_list(heap, identifier, list); push_back_token(token_id); if(parse_list(list)) { token_id = get_next_token(heap); if (token_id == comma_tok) { return parse_list_items(heap, depth); } else { push_back_token(token_id); return TRUE; } } else { lprintf(LOG_ERROR, "Failed parsing List\n"); return FALSE; } } else if (get_token_type(heap, token_id) == T_STRING) { string = get_token_strvalue(heap, token_id); token_assign_strvalue(heap, identifier, string); token_id = get_next_token(heap); if (token_id == comma_tok) { return parse_list_items(heap, depth); } else { push_back_token(token_id); return TRUE; } } else if (get_token_type(heap, token_id) == T_NUMERIC) { string = get_token_strvalue(heap, token_id); value = get_token_numvalue(heap, token_id); token_assign_strvalue(heap, identifier, string); token_assign_numvalue(heap, identifier, value); token_id = get_next_token(heap); if (token_id == comma_tok) { return parse_list_items(heap, depth); } else { push_back_token(token_id); return TRUE; } } else { lprintf(LOG_ERROR, "Line %d Expecting Identifier, Dictionary or List\n", get_linenumber()); return FALSE; } return TRUE; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int parse_dictionary_items(TOKEN_HEAP *heap) { TOKEN_ID token_id, identifier; TOKEN_HEAP *dictionary, *list; char *string; long value; lprintf(LOG_VERYVERBOSE, "Entering parse_dictionary_items()\n"); token_id = get_next_token(heap); if (get_token_type(heap, token_id) == T_IDENTIFIER) { identifier = token_id; token_id = get_next_token(heap); if (token_id == assignment_tok) { token_id = get_next_token(heap); if (token_id == lcurly_tok) { dictionary = generate_new_heap(); if (dictionary == NULL) { lprintf(LOG_ERROR, "Allocating memory\n"); return FALSE; } token_assign_dictionary(heap, identifier, dictionary); push_back_token(token_id); if (parse_dictionary(dictionary)) { token_id = get_next_token(heap); if (token_id != rcurly_tok) { push_back_token(token_id); return parse_dictionary_items(heap); } else { push_back_token(token_id); return TRUE; } } else { lprintf(LOG_ERROR, "Failed parsing Dictionary\n"); return FALSE; } } else if (token_id == lparen_tok) { list = generate_new_heap(); if (list == NULL) { lprintf(LOG_ERROR, "Allocating memory\n"); return FALSE; } token_assign_list(heap, identifier, list); push_back_token(token_id); if(parse_list(list)) { token_id = get_next_token(heap); if (token_id != rcurly_tok) { push_back_token(token_id); return parse_dictionary_items(heap); } else { push_back_token(token_id); return TRUE; } } else { lprintf(LOG_ERROR, "Failed parsing List\n"); return FALSE; } } else if (get_token_type(heap, token_id) == T_STRING) { string = get_token_strvalue(heap, token_id); token_assign_strvalue(heap, identifier, string); token_id = get_next_token(heap); if (token_id != rcurly_tok) { push_back_token(token_id); return parse_dictionary_items(heap); } else { push_back_token(token_id); return TRUE; } } else if (get_token_type(heap, token_id) == T_NUMERIC) { string = get_token_strvalue(heap, token_id); value = get_token_numvalue(heap, token_id); token_assign_strvalue(heap, identifier, string); token_assign_numvalue(heap, identifier, value); token_id = get_next_token(heap); if (token_id != rcurly_tok) { push_back_token(token_id); return parse_dictionary_items(heap); } else { push_back_token(token_id); return TRUE; } } else { lprintf(LOG_ERROR, "Line %d Expecting Identifier, Dictionary or List\n", get_linenumber()); return FALSE; } } else { lprintf(LOG_ERROR, "Line %d Expecting '='\n", get_linenumber()); return FALSE; } } else { lprintf(LOG_ERROR, "Line %d Expecting Identifier\n", get_linenumber()); return FALSE; } return TRUE; } smsclient-2.0.8z/src/parser/gs_io.h0000644000175000017500000000325010127274515017144 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_io.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ int gs_open(char *file); int gs_close(void); void init_linenumber(void); int get_linenumber(void); int get_next_character(void); int push_character(int character); int pop_character(void); int escape_char(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/parser/gs_api/0000755000175000017500000000000010127274515017135 5ustar noodlesnoodlessmsclient-2.0.8z/src/parser/gs_api/gs_save.c0000644000175000017500000000350710127274515020735 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_save.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include "gs_api.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int gs_savedictionarytofile(char *filename, TOKEN *dictionary) { FILE *fp; TOKEN_HEAP *heap; heap = get_token_indirect_dictionary(NULL, dictionary); if (heap == NULL) { return -1; } fp = fopen(filename, "w"); if (fp == NULL) { return -1; } dump_heaptofile(heap, "X", fp); fclose(fp); return 0; } smsclient-2.0.8z/src/parser/gs_api/gs_getdict.c0000644000175000017500000000503310127274514021415 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_getdict.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include "common/common.h" #include "gs_token.h" #include "gs_list.h" #include "gs_translate.h" #include "gs_parser.h" #include "gs_api.h" /* -------------------------------------------------------------------- */ /* */ /* Return Values: */ /* */ /* Token of type 'Identifier', 'Dictionary' or 'List' or */ /* NULL if an error ocuured. */ /* */ /* *ptr is set to NULL when we are at the end of the list. */ /* */ /* -------------------------------------------------------------------- */ TOKEN *gs_get_dictionary_next(TOKEN *item, TOKEN_LIST **ptr) { TOKEN_HEAP *heap; TOKEN_LIST *list; TOKEN *token; if (! gs_isdictionary(item)) { return NULL; } if (*ptr == NULL) { heap = (TOKEN_HEAP *)(item->ptr); if (heap == NULL) { return NULL; } list = (TOKEN_LIST *)(heap->list); if (list == NULL) { return NULL; } } else { list = *ptr; } while ((list != NULL) && (gs_isdata(list->token))) { /* Skip ALL items which are simply */ /* Data. We only want to return */ /* 'Identifiers', 'Dictionaries' or */ /* 'Lists' */ list = list->next; } token = list->token; if (token == NULL) { return NULL; } *ptr = list->next; return token; } smsclient-2.0.8z/src/parser/gs_api/gs_create.c0000644000175000017500000000336410127274514021242 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_create.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include "gs_list.h" #include "gs_api.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN *create_dictionary(char *name) { TOKEN_HEAP *dictionary; dictionary = generate_new_heap(); if (dictionary == NULL) { return NULL; } return new_token(name, T_STRING, TP_DICTIONARY, dictionary); } smsclient-2.0.8z/src/parser/gs_api/gs_type.c0000644000175000017500000000521310127274515020754 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_type.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "gs_api.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int gs_isidentifier(TOKEN *item) { if (item != NULL) { if (item->ptr_type == TP_STRING) { return TRUE; } } return FALSE; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int gs_isdictionary(TOKEN *item) { if (item != NULL) { if (item->ptr_type == TP_DICTIONARY) { return TRUE; } } return FALSE; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int gs_islist(TOKEN *item) { if (item != NULL) { if (item->ptr_type == TP_LIST) { return TRUE; } } return FALSE; } /* -------------------------------------------------------------------- */ /* Return Values: */ /* */ /* TRUE if Item is a simple data item */ /* FALSE if Item is an 'Identifier', 'Dictionary' or 'List' */ /* */ /* -------------------------------------------------------------------- */ int gs_isdata(TOKEN *item) { return (!(gs_isidentifier(item) || gs_isdictionary(item) || gs_islist(item))); } smsclient-2.0.8z/src/parser/gs_api/gs_getvar.c0000644000175000017500000000513610127274514021266 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_getvar.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include "gs_token.h" #include "gs_list.h" #include "gs_parser.h" #include "gs_translate.h" #include "gs_api.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN *gs_get_variable(TOKEN *dictionary, char *string) { TOKEN_HEAP *heap; if (! gs_isdictionary(dictionary)) { return NULL; } heap = get_token_indirect_dictionary(NULL, dictionary); if (heap == NULL) { return NULL; } return get_var(heap, string); } /* -------------------------------------------------------------------- */ /* Return Values: */ /* */ /* The string value assigned to this identifier. */ /* NULL on error */ /* */ /* -------------------------------------------------------------------- */ char *gs_get_strvalue(TOKEN *token) { if (! gs_isidentifier(token)) { return NULL; } return token->ptr; } /* -------------------------------------------------------------------- */ /* Return Values: */ /* */ /* The label/name of this 'Identfier', 'Dictionary' or 'List' */ /* NULL on error */ /* -------------------------------------------------------------------- */ char *gs_get_labelvalue(TOKEN *token) { return token->str; } smsclient-2.0.8z/src/parser/gs_api/README0000644000175000017500000000220010127274514020006 0ustar noodlesnoodles API For GS Parser ================= This is an attempt to encapsulate the GS Parser to provide a simple API with the following functions: /* ------------------------------------------------------------ */ /* Iterators */ /* ------------------------------------------------------------ */ gs_get_dictionary_next() gs_get_list_next() /* ------------------------------------------------------------ */ /* Tests */ /* ------------------------------------------------------------ */ gs_isidentifier() gs_isdictionary() gs_islist() gs_isdata() gs_get_strvalue() gs_get_labelvalue() gs_get_variable() gs_get_list_element() gs_get_list_length() /* ------------------------------------------------------------ */ /* I/O */ /* ------------------------------------------------------------ */ gs_loaddictionaryfromfile() gs_savedictionarytofile() /* ------------------------------------------------------------ */ /* Miscelaneous */ /* ------------------------------------------------------------ */ create_dictionary() /* ------------------------------------------------------------ */ smsclient-2.0.8z/src/parser/gs_api/gs_getlist.c0000644000175000017500000000610310127274514021444 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_getlist.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include "common/common.h" #include "gs_token.h" #include "gs_list.h" #include "gs_translate.h" #include "gs_parser.h" #include "gs_api.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN *gs_get_list_element(TOKEN *item, int index) { return NULL; } /* -------------------------------------------------------------------- */ /* Return Value: */ /* */ /* The numbers of items in the list or */ /* -1 to inidicate and error. */ /* -------------------------------------------------------------------- */ int gs_get_list_length(TOKEN *item) { TOKEN *token; TOKEN_LIST *eptr; int len; len = 0; eptr = NULL; while ((token = gs_get_list_next(item, &eptr)) != NULL) { if (! gs_isdata(token)) { len++; } if (eptr == NULL) { break; } } if (eptr != NULL) { return -1; } return len; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN *gs_get_list_next(TOKEN *item, TOKEN_LIST **ptr) { TOKEN_HEAP *heap; TOKEN_LIST *list; TOKEN *token; if (! gs_islist(item)) { return NULL; } if (*ptr == NULL) { heap = (TOKEN_HEAP *)(item->ptr); if (heap == NULL) { return NULL; } list = (TOKEN_LIST *)(heap->list); if (list == NULL) { return NULL; } } else { list = *ptr; } while ((list != NULL) && (gs_isdata(list->token))) { /* Skip ALL items which are simply */ /* Data. We only want to return */ /* 'Identifiers', 'Dictionaries' or */ /* 'Lists' */ list = list->next; } token = list->token; if (token == NULL) { return NULL; } *ptr = list->next; return token; } smsclient-2.0.8z/src/parser/gs_api/test/0000755000175000017500000000000010127274515020114 5ustar noodlesnoodlessmsclient-2.0.8z/src/parser/gs_api/test/test_api.c0000644000175000017500000000662210127274515022076 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* api_test.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "gs_token.h" #include "gs_list.h" #include "gs_translate.h" #include "gs_parser.h" #include "gs_io.h" #include "gs_api.h" /* -------------------------------------------------------------------- */ #define DICT_LOAD "myfile.load" #define DICT_SAVE "myfile.save" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char **argv) { TOKEN_LIST *eptr; TOKEN *item, *token; set_logfile(LOGFILE); set_loglevel(LOGLEVEL); set_consolelog(TRUE); /* ---------------------------------------- */ item = create_dictionary("dictionary"); if (gs_isdictionary(item)) { lprintf(LOG_STANDARD, "Item is Dictionary\n"); } else { lprintf(LOG_STANDARD, "Item is NOT Dictionary\n"); exit(1); } /* ---------------------------------------- */ if (gs_loaddictionaryfromfile(DICT_LOAD, item) == -1) { lprintf(LOG_ERROR, "Failed to load Dictionary '%s'\n", DICT_LOAD); exit(1); } else { lprintf(LOG_STANDARD, "Loaded Dictionary '%s'\n", DICT_LOAD); } /* ---------------------------------------- */ eptr = NULL; while ((token = gs_get_dictionary_next(item, &eptr)) != NULL) { if (gs_isidentifier(token)) { lprintf(LOG_STANDARD, "Identifier '%s'\n", gs_get_labelvalue(token)); } else if (gs_isdictionary(token)) { lprintf(LOG_STANDARD, "Dictionary '%s'\n", gs_get_labelvalue(token)); } else if (gs_islist(token)) { lprintf(LOG_STANDARD, "List '%s' len '%d'\n", gs_get_labelvalue(token), gs_get_list_length(token)); } else { lprintf(LOG_STANDARD, "Unknown\n"); } if (eptr == NULL) { break; } } if (eptr != NULL) { lprintf(LOG_ERROR, "Something went wrong!\n"); } /* ---------------------------------------- */ if (gs_savedictionarytofile(DICT_SAVE, item) == -1) { lprintf(LOG_ERROR, "Failed to Save Dictionary '%s'\n", DICT_SAVE); exit(1); } else { lprintf(LOG_STANDARD, "Saved Dictionary '%s'\n", DICT_SAVE); } return 0; } smsclient-2.0.8z/src/parser/gs_api/test/myfile.load0000644000175000017500000000013510127274515022241 0ustar noodlesnoodles{ lista = ( "b", "c", "d" ) this = "another one" many = "fun" dict = { test = "a" } } smsclient-2.0.8z/src/parser/gs_api/gs_load.c0000644000175000017500000000412310127274515020711 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_load.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include "gs_parser.h" #include "gs_io.h" #include "gs_api.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int gs_loaddictionaryfromfile(char *filename, TOKEN *dictionary) { TOKEN_HEAP *heap; TOKEN *token_id; if (! gs_isdictionary(dictionary)) { return -1; } init_builtin_heap(); heap = get_token_indirect_dictionary(NULL, dictionary); if (heap == NULL) { return -1; } if (gs_open(filename)) { return -1; } if (parse_dictionary(heap)) { token_id = get_next_token(heap); if (token_id != eof_tok) { gs_close(); return -1; } } else { gs_close(); return -1; } if (gs_close()) { return -1; } return 0; } smsclient-2.0.8z/src/parser/gs_api/gs_api.h0000644000175000017500000000436510127274514020557 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_api.h */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include "gs_token.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN *create_dictionary(char *name); TOKEN *gs_get_dictionary_next(TOKEN *item, TOKEN_LIST **ptr); TOKEN *gs_get_list_next(TOKEN *item, TOKEN_LIST **ptr); TOKEN *gs_get_list_element(TOKEN *item, int index); int gs_get_list_length(TOKEN *item); TOKEN *gs_get_variable(TOKEN *dictionary, char *string); char *gs_get_strvalue(TOKEN *token); char *gs_get_labelvalue(TOKEN *token); int gs_loaddictionaryfromfile(char *filename, TOKEN *dictionary); int gs_savedictionarytofile(char *filename, TOKEN *dictionary); int gs_isidentifier(TOKEN *item); int gs_isdictionary(TOKEN *item); int gs_islist(TOKEN *item); int gs_isdata(TOKEN *item); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/parser/gs_api/Makefile0000644000175000017500000000602310127274514020575 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- include ../../../Makefile.config # -------------------------------------------------------------------- all: gs_api.a test: test/test_api clean: rm -f *.o rm -f gs_api.a rm -f core log rm -f test/test_api test/test_log test/myfile.save # -------------------------------------------------------------------- INCLUDE = -I.. -I../.. # -------------------------------------------------------------------- ../../logfile/logfile.o: ../../logfile/logfile.c ../../logfile/logfile.h cd ../../logfile ; $(MAKE) logfile.o ../../common/common.o: ../../common/common.c ../../common/common.h cd ../../common ; $(MAKE) common.o gs_parser: cd ../ ; $(MAKE) gs_parser.a # -------------------------------------------------------------------- gs_api.a: gs_create.o gs_load.o gs_save.o gs_type.o gs_getvar.o gs_getlist.o gs_getdict.o $(AR) gs_api.a gs_create.o gs_load.o gs_save.o gs_type.o gs_getvar.o gs_getlist.o gs_getdict.o $(RANLIB) gs_api.a test/test_api: test/test_api.c gs_api.a ../../logfile/logfile.o ../../common/common.o gs_parser $(CC) $(CFLAGS) $(INCLUDE) test/test_api.c -o test/test_api gs_api.a ../../logfile/logfile.o ../../common/common.o ../gs_parser.a -DLOGLEVEL=3 -DLOGFILE="\"test_log\"" gs_create.o: gs_create.c gs_api.h $(CC) $(CFLAGS) $(INCLUDE) -c gs_create.c gs_load.o: gs_load.c gs_api.h $(CC) $(CFLAGS) $(INCLUDE) -c gs_load.c gs_save.o: gs_save.c gs_api.h $(CC) $(CFLAGS) $(INCLUDE) -c gs_save.c gs_type.o: gs_type.c gs_api.h $(CC) $(CFLAGS) $(INCLUDE) -c gs_type.c gs_getvar.o: gs_getvar.c gs_api.h $(CC) $(CFLAGS) $(INCLUDE) -c gs_getvar.c gs_getlist.o: gs_getlist.c gs_api.h $(CC) $(CFLAGS) $(INCLUDE) -c gs_getlist.c gs_getdict.o: gs_getdict.c gs_api.h $(CC) $(CFLAGS) $(INCLUDE) -c gs_getdict.c # -------------------------------------------------------------------- smsclient-2.0.8z/src/parser/test/0000755000175000017500000000000010127274515016652 5ustar noodlesnoodlessmsclient-2.0.8z/src/parser/test/test_file0000644000175000017500000000140510127274515020553 0ustar noodlesnoodles{ login = ( { send = "" expect = "ogin: " success = "Login prompt found" failure = "Login Failed - login prompt expected" }, { send = "angelom\n" expect = "assword: " success = "Password prompt found" failure = "Login Failed - password prompt expected" }, { send = "xxx\n" expect = "Last login:" success = "Login successful" failure = "Login Failed - Welcome message expected" } ) send = ( { send = "echo \"test\" | mail angelom\n" expect = "\n" success = "Successfully sent message" failure = "failed to send message" } ) disconnect = ( { send = "exit\n" expect = "\n" success = "Successfully diconnected" failure = "failed to disconnect gracefully" } ) } smsclient-2.0.8z/src/parser/test/test_fileY0000644000175000017500000000004610127274515020704 0ustar noodlesnoodles{ list = ( "C", "B", "A" ) } smsclient-2.0.8z/src/parser/test/test_file30000644000175000017500000000011410127274515020632 0ustar noodlesnoodles{ #this is too name_1 = "F\n\X20RED" # this is a test friend_1 = TRUE } smsclient-2.0.8z/src/parser/test/test_file20000644000175000017500000000021410127274515020632 0ustar noodlesnoodles{ name_1 = "FRED" friend_1 = TRUE friend_2 = FALSE friend_3 = YES friend_4 = NO my_list = ( TRUE, TRUE, TRUE, TRUE ) } smsclient-2.0.8z/src/parser/test/test_fileX0000644000175000017500000000047410127274515020710 0ustar noodlesnoodles{ list = ( "C", "B", "A" ) home = $SPODROD myhome1 = "${HOME}" myhome2 = "test ${HOME}" myhome3 = "${HOME} test" myhome4 = "test ${HOME} test" myhome5 = "${HOME}${HOME}" myhome6 = "test ${HOME} test ${HOME}" test = "fred" bill = 42 bob = 348888888 dave = 27 fun = { test2 = "A" } } smsclient-2.0.8z/src/parser/test/test_log0000644000175000017500000000314710127274515020422 0ustar noodlesnoodlesAug 16 13:57:49 [19487] ERROR: Line 12 Expecting Identifier Aug 16 13:57:49 [19487] ERROR: Line 12 Expecting Dictionary items Aug 16 13:57:49 [19487] ERROR: Parsing file 'test_fileX' Aug 17 09:10:12 [21182] : Entering add_token() Aug 17 09:10:12 [21182] : Adding token '' Aug 17 09:10:13 [21182] : Creating token '' Aug 17 09:10:13 [21182] : Updating , 2, 0, 0 Aug 17 09:10:13 [21182] : returning 2e468 Aug 17 09:10:13 [21182] : Entering add_token() Aug 17 09:10:13 [21182] : Adding token '' Aug 17 09:10:13 [21182] : Creating token '' Aug 17 09:10:13 [21182] : Updating , 2, 0, 0 Aug 17 09:10:13 [21182] : returning 2e488 Aug 17 09:11:00 [21200] : Entering add_token() Aug 17 09:11:00 [21200] : Adding token '' Aug 17 09:11:00 [21200] : Creating token '' Aug 17 09:11:00 [21200] : Updating , 2, 0, 0 Aug 17 09:11:00 [21200] : returning 2e488 Aug 17 09:11:01 [21200] : Entering add_token() Aug 17 09:11:01 [21200] : Adding token '' Aug 17 09:11:01 [21200] : Creating token '' Aug 17 09:11:01 [21200] : Updating , 2, 0, 0 Aug 17 09:11:01 [21200] : returning 2e4a8 Aug 17 09:11:01 [21200] : Entering add_token() Aug 17 09:11:01 [21200] : Adding token '=' Aug 17 09:11:01 [21200] : Creating token '=' Aug 17 09:11:01 [21200] : Updating =, 2, 0, 0 Aug 17 09:11:01 [21200] : returning 2e4c8 Aug 17 09:14:20 [21258] ERROR: Line 13 Expecting Identifier, Dictionary or List Aug 17 09:14:20 [21258] ERROR: Line 13 Expecting Dictionary items Aug 17 09:14:20 [21258] ERROR: Parsing file 'test_fileX' Aug 17 15:57:21 [23144] ERROR: Usage: ./test_parser [-l loglevel] smsclient-2.0.8z/src/parser/test/test_parser.c0000644000175000017500000000737610127274515021366 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* test_parser.c */ /* */ /* Copyright (C) 1997,1998 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #if defined(LINUX) #include #endif #include "common/common.h" #include "logfile/logfile.h" #include "gs_token.h" #include "gs_translate.h" /* -------------------------------------------------------------------- */ #if !defined(MLOGFILE) #error "MLOGFILE undefined" #else #define LOGFILE MLOGFILE #endif #if !defined(MLOGLEVEL) #error "MLOGLEVEL undefined" #else #define LOGLEVEL MLOGLEVEL #endif /* -------------------------------------------------------------------- */ static TOKEN_HEAP *global_heap; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void usage(char *file) { lprintf(LOG_ERROR, "Usage: %s [-l loglevel] \n", file); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char *argv[]) { int c; char *ptr, *str; /* ---------------------------- */ set_logfile(LOGFILE); set_loglevel(LOGLEVEL); set_consolelog(TRUE); /* ---------------------------- */ while ((c = getopt (argc, argv, "l:")) != -1) { switch (c) { case 'l': set_loglevel((int)strtol(optarg, &ptr, 10)); if (ptr == optarg) { lprintf(LOG_ERROR, "Option l requires an argument\n"); usage(argv[0]); exit(-1); } break; case '?': lprintf(LOG_ERROR, "Unknown option `-%c'\n", optopt); usage(argv[0]); exit(-1); default: abort (); } } if ((argc - optind) != 2) { usage(argv[0]); exit(-1); } /* ---------------------------- */ global_heap = gs_parse_file(argv[optind+1]); if (global_heap == NULL) { lprintf(LOG_ERROR, "Parsing file '%s'\n", argv[optind+1]); exit(-1); } dump_heap(global_heap, "global"); str = get_strvalue(global_heap, argv[optind]); if (str == NULL) { printf("Var '%s' Not Found\n", argv[optind]); } else { printf("Var '%s' Found\n", argv[optind]); printf("%s = %s\n", argv[optind], str); } free_heap(global_heap); return 0; } smsclient-2.0.8z/src/parser/gs_list.c0000644000175000017500000001065610127274515017513 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* gs_list.c */ /* */ /* Copyright (C) 1997,1998 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "gs_token.h" #include "error.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN *malloc_token(void) { TOKEN *token; token = (TOKEN *)malloc(sizeof(TOKEN)); if (token == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } return token; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN_LIST *malloc_token_list_item(void) { TOKEN_LIST *list_item; list_item = (TOKEN_LIST *)malloc(sizeof(TOKEN_LIST)); if (list_item == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } list_item->token = malloc_token(); list_item->next = NULL; return list_item; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN *update_token(TOKEN *token, char *str, int type, int ptr_type, void *ptr) { token->str = strdup(str); token->type = type; token->ptr_type = ptr_type; token->ptr = ptr; lprintf(LOG_VERYVERBOSE, "Updating %s, %d, %d, %p\n", str, type, ptr_type, ptr); return token; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN *new_token(char *str, int type, int ptr_type, void *ptr) { return update_token(malloc_token(), str, type, ptr_type, ptr); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ TOKEN *find_item(TOKEN_LIST *list, char *str, int type) { TOKEN_LIST *item; item = list; while(item != NULL) { if ((strcmp(item->token->str, str) == 0) && (item->token->type == type)) { return item->token; } item = item->next; } return NULL; } /* -------------------------------------------------------------------- */ /* Try to locate item if it already exists, update */ /* it and return list. */ /* If the item cannot be located, create a new item, */ /* insert at the start of the list and return the new list. */ /* If list is empty add item to list and return list */ /* -------------------------------------------------------------------- */ TOKEN_LIST *add_token_list_item(TOKEN_LIST *list, TOKEN **token, char *str, int type, int ptr_type, void *ptr) { TOKEN_LIST *list_item; TOKEN *item; lprintf(LOG_VERYVERBOSE, "Adding token '%s'\n", str); item = find_item(list, str, type); if (item != NULL) { lprintf(LOG_VERYVERBOSE, "Found token '%s'\n", str); update_token(item, str, type, ptr_type, ptr); *token = item; return list; } lprintf(LOG_VERYVERBOSE, "Creating token '%s'\n", str); list_item = malloc_token_list_item(); list_item->next = list; update_token(list_item->token, str, type, ptr_type, ptr); *token = list_item->token; return list_item; } smsclient-2.0.8z/src/parser/Makefile0000644000175000017500000000544310127274514017340 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1997,1998 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- include ../../Makefile.config # -------------------------------------------------------------------- all: gs_parser.a test: test/test_parser clean: $(RM) gs_parser.a $(RM) *.o $(RM) *.bak $(RM) test/test_parser # -------------------------------------------------------------------- INCLUDE = -I.. gs_parser.a: gs_list.o gs_parser.o gs_token.o gs_translate.o gs_io.o $(AR) gs_parser.a gs_list.o gs_parser.o gs_token.o gs_translate.o gs_io.o $(RANLIB) gs_parser.a gs_list.o: gs_list.c gs_token.h ../common/common.h $(CC) -g $(CFLAGS) $(INCLUDE) -c gs_list.c gs_io.o: gs_io.c gs_io.h ../common/common.h $(CC) -g $(CFLAGS) $(INCLUDE) -c gs_io.c gs_parser.o: gs_parser.c gs_token.h ../common/common.h gs_parser.h $(CC) -g $(CFLAGS) $(INCLUDE) -c gs_parser.c gs_token.o: gs_token.c gs_token.h ../common/common.h gs_list.h $(CC) -g $(CFLAGS) $(INCLUDE) -c gs_token.c gs_translate.o: gs_translate.c gs_token.h ../common/common.h gs_list.h $(CC) -g $(CFLAGS) $(INCLUDE) -c gs_translate.c test/test_parser: gs_parser.a test/test_parser.c ../logfile/logfile.o ../common/common.o $(CC) -g $(CFLAGS) $(INCLUDE) test/test_parser.c gs_parser.a -o test/test_parser ../common/common.o ../logfile/logfile.o -DMLOGLEVEL=3 -DMLOGFILE="\"test_log\"" # -------------------------------------------------------------------- ../logfile/logfile.o: ../logfile/logfile.c ../logfile/logfile.h cd ../logfile ; $(MAKE) logfile.o ../common/common.o: ../common/common.c ../common/common.h cd ../common ; $(MAKE) common.o # -------------------------------------------------------------------- smsclient-2.0.8z/src/parser/gs_list.h0000644000175000017500000000366310127274515017520 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* sms_list.h */ /* */ /* Copyright (C) 1997,1998 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include "gs_token.h" /* -------------------------------------------------------------------- */ TOKEN_LIST *add_token_list_item(TOKEN_LIST *list, TOKEN **token, char *str, int type, int ptr_type, void *ptr); TOKEN_LIST *malloc_token_list_item(void); TOKEN *malloc_token(void); TOKEN *new_token(char *str, int type, int ptr_type, void *ptr); void update_token(TOKEN *token, char *str, int type, int ptr_type, void *ptr); TOKEN *find_item(TOKEN_LIST *list, char *str, int type); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/client/0000755000175000017500000000000011007610111015635 5ustar noodlesnoodlessmsclient-2.0.8z/src/client/sms_address.c0000644000175000017500000001333110127274502020325 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* sms_address.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #if defined(LINUX) #include #endif #if defined(NEXT) #include #endif #include "error.h" #include "sms_list.h" #include "expand.h" #include "common/common.h" #include "logfile/logfile.h" #include "version.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ #if !defined(MVERSION) #error "MVERSION undefined" #else #define VERSION MVERSION #endif #if !defined(MLOGFILE) #error "MLOGFILE undefined" #else #define LOGFILE MLOGFILE #endif #if !defined(MLOGLEVEL) #error "MLOGLEVEL undefined" #else #define LOGLEVEL MLOGLEVEL #endif #if !defined(MSERVICEDIR) #error "MSERVICEDIR undefined" #else #define SERVICEDIR MSERVICEDIR #endif #define CONFIG_FILE (MSERVICEDIR "/sms_config") /* -------------------------------------------------------------------- */ static char *SMS_default_service; static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_default_service", 0, 1, NULL, 0, "CELLNET", 0, &SMS_default_service }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ void usage(char *file); int main(int, char *[]); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void usage(char *file) { printf("Usage: %s [-v]\n", file); printf(" %s [-l loglevel] [-L] [-d delimeter] name[,name]\n", file); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char *argv[]) { char *ptr; int c, long_flag, delimeter; SMS_list *node, *numbers; TOKEN_HEAP *global, *local; /* ---------------------------- */ set_logfile(LOGFILE); set_loglevel(LOGLEVEL); set_consolelog(TRUE); /* ---------------------------- */ delimeter = ':'; long_flag = FALSE; while ((c = getopt (argc, argv, "vl:d:L")) != -1) { switch (c) { case 'v': printf("%s %s\n", argv[0], VERSION); exit(0); case 'l': set_loglevel((int)strtol(optarg, &ptr, 10)); if (ptr == optarg) { lprintf(LOG_ERROR, "Option l requires an argument\n"); usage(argv[0]); exit(EUSAGE); } break; case 'L': long_flag = TRUE; break; case 'd': if (strlen(optarg) > 1) { fprintf(stderr, "Invalid delimeter `%s'\n", optarg); usage(argv[0]); exit(-1); } delimeter = optarg[0]; break; case '?': #if !defined(NEXT) fprintf(stderr, "Unknown option `-%c'\n", optopt); #endif usage(argv[0]); exit(-1); default: abort (); } } /* ---------------------------- */ if ((argc - optind) < 1) { usage(argv[0]); exit(EUSAGE); } /* ---------------------------- */ /* Get Default SERVICE */ if (read_resource_file(CONFIG_FILE, resource_list, TRUE) != RESOURCE_FILE_OK) { lprintf(LOG_ERROR, "Unrecoverable Failure Parsing file '%s'\n", CONFIG_FILE); exit(1); } /* ---------------------------- */ /* Get and expand NAMES|NUMBERS */ if (SMS_dual_openrc(&global, &local) == -1) { exit(-1); } numbers = SMS_expandnumber(global, local, "", argv[optind], SMS_default_service); SMS_dual_closerc(global, local); /* ---------------------------- */ /* Check NAMES|NUMBERS */ if (SMS_validate_expanded_numbers(numbers)) { fprintf(stderr, "ERROR: Expanding names\n"); exit(-1); } /* ---------------------------- */ node = get_first(numbers); while (node != NULL) { printf("%s%c%s%c%s\n", node->name, delimeter, node->service, delimeter, node->number); node = get_next(node); } free_list(numbers); return 0; } smsclient-2.0.8z/src/client/sms_list.h0000644000175000017500000000565210127274502017667 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* sms_list.h */ /* */ /* Copyright (C) 1997,1998 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #ifndef _SMSLIST_H #define _SMSLIST_H /* -------------------------------------------------------------------- */ struct SMS_list_struct { struct SMS_list_struct *next; char *name, *service, *number; int delivery; }; typedef struct SMS_list_struct SMS_list; /* -------------------------------------------------------------------- */ struct SMS_parent_list_struct { struct SMS_parent_list_struct *next; struct SMS_list_struct *child; }; typedef struct SMS_parent_list_struct SMS_parent_list; /* -------------------------------------------------------------------- */ SMS_list *insert_list(SMS_list *main_list, SMS_list *list); SMS_list *dupnode(SMS_list *node); SMS_list *get_first(SMS_list *node); SMS_list *get_next(SMS_list *node); char *get_number(SMS_list *node); char *get_name(SMS_list *node); char *get_service(SMS_list *node); void set_delivery(SMS_list *node, int delivery); int get_delivery(SMS_list *node); SMS_parent_list *add_item_parent(SMS_parent_list *list, SMS_list *child); SMS_parent_list *get_first_parent(SMS_parent_list *node); SMS_parent_list *get_next_parent(SMS_parent_list *node); SMS_list *get_child(SMS_parent_list *node); SMS_parent_list *find_list(SMS_parent_list *list, char *service); void free_list(SMS_list *list); SMS_list *find_number(SMS_list *list, char *str); SMS_list *dupnode(SMS_list *node); SMS_list *add_item(SMS_list *list, char *name, char *service, char *number); SMS_parent_list *gather(SMS_list *list); #endif /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/client/sms_list.c0000644000175000017500000002251410127274502017656 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* sms_list.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include "sms_list.h" #include "error.h" #include "logfile/logfile.h" #include "common/common.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #if 0 SMS_list *insert_list(SMS_list *main_list, SMS_list *list) { SMS_list *node; if (list == NULL) { return main_list; } if (main_list == NULL) { return list; } node = list; while(node->next != NULL) { node = node->next; } node->next = main_list->next; main_list->next = list; return main_list; } #else SMS_list *insert_list(SMS_list *main_list, SMS_list *list) { SMS_list *node; if (list == NULL) { return main_list; } if (main_list == NULL) { return list; } node = list; while(node->next != NULL) { node = node->next; } node->next = main_list; return list; } #endif /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ SMS_parent_list *find_list(SMS_parent_list *list, char *service) { SMS_parent_list *node; node = get_first_parent(list); while (node != NULL) { if (strcmp(node->child->service, service) == 0) { return node; } node = get_next_parent(node); } return NULL; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void free_node(SMS_list *node) { free(node->name); free(node->service); free(node->number); free(node); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ SMS_list *add_item(SMS_list *list, char *name, char *service, char *number) { SMS_list *node; node = (SMS_list *)malloc(sizeof(SMS_list)); if (node == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } node->name = (char *)malloc(sizeof(char) * (strlen(name) +1)); if (node->name == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } strcpy(node->name, name); node->service = (char *)malloc(sizeof(char) * (strlen(service) +1)); if (node->service == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } strcpy(node->service, service); node->number = (char *)malloc(sizeof(char) * (strlen(number) +1)); if (node->number == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } strcpy(node->number, number); node->delivery = -1; if (list == NULL) { node->next = NULL; return node; } node->next = list->next; list->next = node; return list; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ SMS_list *dupnode(SMS_list *node) { SMS_list *new_node; new_node = add_item(NULL, node->name, node->service, node->number); new_node->delivery = node->delivery; return new_node; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ SMS_list *get_first(SMS_list *node) { return node; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ SMS_list *get_next(SMS_list *node) { if (node == NULL) { return NULL; } return node->next; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ SMS_parent_list *add_item_parent(SMS_parent_list *list, SMS_list *child) { SMS_parent_list *node; node = (SMS_parent_list *)malloc(sizeof(SMS_parent_list)); if (node == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } node->child = child; if (list == NULL) { node->next = NULL; return node; } node->next = list->next; list->next = node; return list; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ SMS_parent_list *get_first_parent(SMS_parent_list *node) { return node; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ SMS_parent_list *get_next_parent(SMS_parent_list *node) { if (node == NULL) { return NULL; } return node->next; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ SMS_list *get_child(SMS_parent_list *node) { if (node == NULL) { return NULL; } return node->child; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *get_number(SMS_list *node) { if (node == NULL) { return NULL; } return node->number; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *get_name(SMS_list *node) { if (node == NULL) { return NULL; } return node->name; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *get_service(SMS_list *node) { if (node == NULL) { return NULL; } return node->service; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void set_delivery(SMS_list *node, int delivery) { if (node == NULL) { return; } node->delivery = delivery; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int get_delivery(SMS_list *node) { if (node == NULL) { return 0; } return node->delivery; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void free_list(SMS_list *list) { SMS_list *node, *next; node = list; while (node != NULL) { next = node->next; free_node(node); node = next; } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ SMS_list *find_number(SMS_list *list, char *str) { SMS_list *node; node = get_first(list); while (node != NULL) { if (strcmp(get_number(node), str) == 0) { return node; } node = get_next(node); } return NULL; } /* -------------------------------------------------------------------- */ /* Gather all items that contain identical */ /* services and generates a lists of lists containing */ /* identical items */ /* Example: */ /* */ /* |-- Type A */ /* |-- Type C */ /* |-- Type B */ /* |-- Type C */ /* |-- Type A */ /* |-- Type A */ /* */ /* Becomes: */ /* */ /* | */ /* |-------|-- Type A */ /* | |-- Type A */ /* | |-- Type A */ /* | */ /* |-------|-- Type B */ /* | */ /* |-------|-- Type C */ /* |-- Type C */ /* */ /* -------------------------------------------------------------------- */ SMS_parent_list *gather(SMS_list *list) { SMS_parent_list *parent_list, *found_list; SMS_list *node, *new_node; parent_list = NULL; node = get_first(list); while (node != NULL) { new_node = dupnode(node); found_list = find_list(parent_list, get_service(node)); if (found_list == NULL) { found_list = add_item_parent(NULL, new_node); found_list->next = parent_list; parent_list = found_list; } else { list = insert_list(found_list->child, new_node); found_list->child = list; } node = get_next(node); } return parent_list; } smsclient-2.0.8z/src/client/expand.h0000644000175000017500000000364610127274502017312 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* expand.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #ifndef _EXPAND_H #define _EXPAND_H #include "sms_list.h" #include "parser/gs_token.h" /* -------------------------------------------------------------------- */ int SMS_dual_openrc(TOKEN_HEAP **global, TOKEN_HEAP **local); void SMS_dual_closerc(TOKEN_HEAP *global, TOKEN_HEAP *local); SMS_list *SMS_expandnumber(TOKEN_HEAP *global, TOKEN_HEAP *local, char *id, char *number, char *default_service); int SMS_validate_expanded_numbers(SMS_list *numbers); #endif /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/client/expand.c0000644000175000017500000002400710127274502017277 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* expand.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include /* -------------------------------------------------------------------- */ /* The following should probably be moved to 'common/common.h' */ /* -------------------------------------------------------------------- */ #if defined(NEXT) #include #include #define NAME_MAX 255 #define PATH_MAX 1024 #else #include #endif #if defined(SOLARIS) #define NAME_MAX FILENAME_MAX #endif #if defined(AIX) #define NAME_MAX 512 #endif #if defined(SCO) #define NAME_MAX pathconf("/",_PC_NAME_MAX) #define PATH_MAX pathconf("/",_PC_PATH_MAX) #endif /* -------------------------------------------------------------------- */ #include "error.h" #include "logfile/logfile.h" #include "expand.h" #include "sms_list.h" #include "resource/resource.h" #include "driver/driver.h" #include "parser/gs_token.h" #include "parser/gs_translate.h" #include "common/common.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #if !defined(MLOCALSMSRC) #error "MLOCALSMSRC undefined" #else #define LOCALSMSRC MLOCALSMSRC #endif #if !defined(MGLOBALSMSRC) #error "MGLOBALSMSRC undefined" #else #define GLOBALSMSRC MGLOBALSMSRC #endif /* -------------------------------------------------------------------- */ SMS_list *search_list; /* -------------------------------------------------------------------- */ static TOKEN_HEAP *SMS_open_global_smsrc(void); static TOKEN_HEAP *SMS_open_local_smsrc(void); static SMS_list *expandnumber(TOKEN_HEAP *global, TOKEN_HEAP *local, char *id, char *str, char *default_service); static char *strdup_service(char *str); static char *strdup_number(char *str); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static TOKEN_HEAP *SMS_open_global_smsrc(void) { lprintf(LOG_VERBOSE, "Opening Global Addressbook File: %s\n", GLOBALSMSRC); return gs_parse_file(GLOBALSMSRC); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static TOKEN_HEAP *SMS_open_local_smsrc(void) { TOKEN_HEAP *heap; struct passwd *pentry; char *filename; filename = (char *)malloc(sizeof(char) * (PATH_MAX + NAME_MAX +1)); if (filename == NULL) { lprintf(LOG_ERROR, "malloc() Failed\n"); exit(EMALLOC); } pentry = getpwuid(getuid()); strcpy(filename, pentry->pw_dir); sms_filecat(filename, LOCALSMSRC); lprintf(LOG_VERBOSE, "Opening Local Addressbook File: %s\n", filename); heap = gs_parse_file(filename); free(filename); return heap; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void SMS_dual_closerc(TOKEN_HEAP *global, TOKEN_HEAP *local) { if (global != NULL) { free_heap(global); } if (local != NULL) { free_heap(local); } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int SMS_dual_openrc(TOKEN_HEAP **global, TOKEN_HEAP **local) { *local = SMS_open_local_smsrc(); if (*local == NULL) { lprintf(LOG_VERBOSE, "Failed to open local smsrc file\n"); } *global = SMS_open_global_smsrc(); if (*global == NULL) { lprintf(LOG_WARNING, "Failed to open global smsrc file\n"); SMS_dual_closerc(*global, *local); return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *strdup_service(char *str) { char *ptr, *dst, *service; service = (char *)malloc(sizeof(char) * (strlen(str) +1)); if (service == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } dst = service; ptr = str; while(*ptr != '\0') { if (*ptr == ':') { *dst = '\0'; break; } else { *dst = *ptr; } dst++; ptr++; } if (*ptr == '\0') { *service = '\0'; } return service; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *strdup_number(char *str) { char *ptr, *dst, *number; number = (char *)malloc(sizeof(char) * (strlen(str) +1)); if (number == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } dst = number; ptr = str; while(*ptr != '\0') { if (*ptr == ':') { dst = number; } else { *dst = *ptr; dst++; } ptr++; } *dst = '\0'; return number; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ SMS_list *add_number(SMS_list *list, char *id, char *number, char *default_service) { char *mnumber, *mservice; mnumber = strdup_number(number); mservice = strdup_service(number); if (strcmp(mservice, "") == 0) { list = add_item(list, id, default_service, mnumber); } else { list = add_item(list, id, mservice, mnumber); } free(mnumber); free(mservice); return list; } /* -------------------------------------------------------------------- */ /* Expand a single name into SERVICE:NUMBER */ /* -------------------------------------------------------------------- */ static SMS_list *expandnumber(TOKEN_HEAP *global, TOKEN_HEAP *local, char *id, char *str, char *default_service) { TOKEN_HEAP *heap; SMS_list *list = NULL, *sub_list; int i; char *value; if (str == NULL) { return NULL; } if (str[0] == '\0') { return NULL; } lprintf(LOG_VERBOSE, "Expanding '%s'\n", str); if ((local != NULL) && ((heap = get_varlist(local, str)) != NULL)) { lprintf(LOG_VERBOSE, "Local: List '%s' found\n", str); i = 0; while ((value = get_strvalue_element(heap, i)) != NULL) { sub_list = expandnumber(global, local, str, value, default_service); list = insert_list(list, sub_list); i++; } } else if ((local != NULL) && ((value = get_strvalue(local, str)) != NULL)) { lprintf(LOG_VERBOSE, "Local: Item '%s' found\n", str); list = add_number(list, str, value, default_service); } else if ((heap = get_varlist(global, str)) != NULL) { lprintf(LOG_VERBOSE, "Global: List '%s' found\n", str); i = 0; while ((value = get_strvalue_element(heap, i)) != NULL) { sub_list = expandnumber(global, local, str, value, default_service); list = insert_list(list, sub_list); i++; } } else if ((value = get_strvalue(global, str)) != NULL) { lprintf(LOG_VERBOSE, "Global: Item '%s' found\n", str); list = add_number(list, str, value, default_service); } else { lprintf(LOG_VERBOSE, "Item '%s' NOT found\n", str); list = add_number(list, id, str, default_service); } return list; } /* -------------------------------------------------------------------- */ /* Expand a comma seperated list of names into SERVICE:NUMBER */ /* -------------------------------------------------------------------- */ SMS_list *SMS_expandnumber(TOKEN_HEAP *global, TOKEN_HEAP *local, char *id, char *str, char *default_service) { char *ptr, *dst, buf[1024]; SMS_list *list, *sub_list; list = NULL; sub_list = NULL; dst = buf; ptr = str; while (*ptr != '\0') { if (*ptr == ',') { *dst = '\0'; sub_list = expandnumber(global, local, id, buf, default_service); list = insert_list(list, sub_list); dst = buf; ptr++; } else { *dst = *ptr; dst++; ptr++; } } *dst = '\0'; sub_list = expandnumber(global, local, id, buf, default_service); list = insert_list(list, sub_list); return list; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int SMS_validate_expanded_numbers(SMS_list *numbers) { DEVICE_ENTRY *device; char *id, *service, *protocol; int count; SMS_list *node; count = 0; node = get_first(numbers); while (node != NULL) { service = get_service(node); protocol = get_protocol(service); if (protocol == NULL) { lprintf(LOG_ERROR, "Service '%s' does not have a valid protocol entry\n", service); count++; } else { device = get_device(protocol); if (device == NULL) { lprintf(LOG_ERROR, "Driver for service %s NOT found\n", service); count++; } else { id = get_number(node); if (!((*device->validate_id)(id))) { lprintf(LOG_WARNING, "Invalid id: %s\n", id); count++; } } } node = get_next(node); } return count; } smsclient-2.0.8z/src/client/README0000644000175000017500000000011710127274502016530 0ustar noodlesnoodlesFix sms_client.c to use the same alarm mechanism as the 2.0.7s-6 sms_client.c smsclient-2.0.8z/src/client/sms_client.c0000644000175000017500000004744410127274502020172 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* sms_client.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include #if defined(LINUX) #include #endif #if defined(NEXT) #include #endif #include "error.h" #include "sms_list.h" #include "logfile/logfile.h" #include "expand.h" #include "driver/driver.h" #include "comms/comms.h" #include "common/common.h" #include "lock/lock.h" #include "resource/resource.h" #include "version.h" /* -------------------------------------------------------------------- */ #if !defined(MVERSION) #error "MVERSION undefined" #else #define VERSION MVERSION #endif #if !defined(MLOGFILE) #error "MLOGFILE undefined" #else #define LOGFILE MLOGFILE #endif #if !defined(MLOGLEVEL) #error "MLOGLEVEL undefined" #else #define LOGLEVEL MLOGLEVEL #endif #if !defined(MSERVICEDIR) #error "MSERVICEDIR undefined" #else #define SERVICEDIR MSERVICEDIR #endif #define CONFIG_FILE (MSERVICEDIR "/sms_config") #define SMSLOCK_FILE (MSERVICEDIR "/smslock") /* -------------------------------------------------------------------- */ static char *SMS_lock_action, *SMS_lockfile, *SMS_default_service; static char *current_message = NULL; static long SMS_lock_retry_delay, SMS_service_timeout; /* -------------------------------------------------------------------- */ #define MAXMESSAGELEN 150 #define MAXMESSAGES 256 #define SERVICETIMEOUT SMS_service_timeout /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_default_service", 0, 1, NULL, 0, "CELLNET", 0, &SMS_default_service }, { RESOURCE_STRING, "SMS_lock_action", 0, 1, NULL, 0, "BLOCK", 0, &SMS_lock_action }, { RESOURCE_NUMERIC, "SMS_lock_retry_delay", 0, 0, NULL, 0, NULL, 5000000, &SMS_lock_retry_delay }, { RESOURCE_STRING, "SMS_lockfile", 0, 1, NULL, 0, SMSLOCK_FILE, 0, &SMS_lockfile }, { RESOURCE_NUMERIC, "SMS_service_timeout", 0, 1, NULL, 0, NULL, 300, &SMS_service_timeout }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ void get_message(char *message); void usage(char *file); int main(int, char *[]); /* -------------------------------------------------------------------- */ static volatile sig_atomic_t child_flag, alarm_flag; int child_status; void trap_child(int signo) { child_flag = TRUE; } void trap_alarm(int signo) { alarm_flag = TRUE; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void get_message(char *message) { int i, c; if (isatty(fileno(stdin))) { printf("Enter your message and end with Control-D\n"); } for (i=0; iinit)(mservice, device) == -1) { lprintf(LOG_ERROR, "Driver Initialization Failed\n"); delivery_error = EDELIVERY; } else { access_set_message(NULL, message); (*device->main)(list, access_get_first, access_get_next, access_get_number, access_get_message, access_set_delivery, device->env); time(&driver_end_time); lprintf(LOG_STANDARD, "%s Service Time: %d Seconds\n", mservice, (int)(driver_end_time - driver_start_time)); delivered = list; while (delivered != NULL) { if (get_delivery(delivered)) { lprintf(LOG_WARNING, "Could not deliver message %d to %s on %s delivery code %d\n", message_num, get_name(delivered), get_number(delivered), get_delivery(delivered)); delivery_error = EDELIVERY; } lprintf(LOG_STANDARD, "[%03d] %s:%s \"%s\"\n", get_delivery(delivered), get_service(delivered), get_number(delivered), access_get_message(delivered)); delivered = get_next(delivered); } } return delivery_error; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char *argv[]) { DEVICE_ENTRY *device; char *mservice, message[MAXMESSAGES][MAXMESSAGELEN +1], *ptr, *protocol; int i, num_messages; SMS_parent_list *parent_node, *parent_list; SMS_list *list, *numbers; TOKEN_HEAP *global, *local; int num_args, nind, mind, c, delivery_error = 0; time_t start_time, end_time; pid_t pid; sigset_t newmask, zeromask, origmask, parentmask; void (* prev_sigalrm)(int); void (* prev_sigchld)(int); /* ---------------------------- */ set_logfile(LOGFILE); set_loglevel(LOGLEVEL); set_consolelog(TRUE); /* ---------------------------- */ while ((c = getopt (argc, argv, "vql:m:d")) != -1) { switch (c) { case 'q': set_consolelog(FALSE); break; case 'd': display_drivers(); exit(0); case 'v': lprintf(LOG_STANDARD, "%s %s\n", argv[0], VERSION); exit(0); case 'l': set_loglevel((int)strtol(optarg, &ptr, 10)); if (ptr == optarg) { lprintf(LOG_ERROR, "Option l requires an argument\n"); usage(argv[0]); exit(EUSAGE); } break; case '?': #if !defined(NEXT) lprintf(LOG_ERROR, "Unknown option `-%c'\n", optopt); #endif usage(argv[0]); exit(EUSAGE); default: abort (); } } /* ---------------------------- */ num_args = argc - optind; if (num_args < 1) { usage(argv[0]); exit(EUSAGE); } nind = optind; mind = optind +1; /* ---------------------------- */ lprintf(LOG_VERYVERBOSE, "Version Information: '%s'\n", VERSION); /* ---------------------------- */ if (read_resource_file(CONFIG_FILE, resource_list, TRUE) != RESOURCE_FILE_OK) { lprintf(LOG_ERROR, "Unrecoverable Failure Parsing file '%s'\n", CONFIG_FILE); exit(1); } /* ---------------------------- */ /* Get and expand NAMES|NUMBERS */ if (SMS_dual_openrc(&global, &local) == -1) { exit(-1); } numbers = SMS_expandnumber(global, local, "", argv[nind], SMS_default_service); SMS_dual_closerc(global, local); /* ---------------------------- */ /* Check NAMES|NUMBERS */ if (SMS_validate_expanded_numbers(numbers)) { lprintf(LOG_ERROR, "Expanding names\n"); exit(ENAMEEXPANSION); } /* ---------------------------- */ if (num_args >= 2) { for (i=mind; i MAXMESSAGELEN) { lprintf(LOG_ERROR, "Message %d too long\n", (i - mind +1)); exit(EMESSAGETOOLONG); } strcpy(message[i - mind], argv[i]); } num_messages = argc - mind; } else { get_message(message[0]); num_messages = 1; } /* ------------------------------------------------------------ */ /* If sms_lock_action is set to BLOCK any other instances of */ /* sms_client which are running will cause this one to block. */ /* When the other instances have finished executing and the */ /* lockfile has been released this instance can attemp to */ /* get the lockfile and run */ /* ------------------------------------------------------------ */ SMS_obtain_lock(SMS_lockfile); /* ------------------------------------------------------------ */ time(&start_time); parent_list = gather(numbers); for (parent_node = get_first_parent(parent_list); parent_node != NULL; parent_node = get_next_parent(parent_node)) { list = get_child(parent_node); mservice = get_service(list); protocol = get_protocol(mservice); if (protocol == NULL) { lprintf(LOG_ERROR, "Service '%s' does not have a valid protocol entry\n", mservice); continue; } device = get_device(protocol); if (device == NULL) { lprintf(LOG_ERROR, "Driver for service '%s' NOT found\n", mservice); } else { /* ------------------------------------ */ /* Add SIGCHLD to set of blocked */ /* signals. */ /* ------------------------------------ */ sigemptyset(&newmask); sigaddset(&newmask, SIGCHLD); lprintf(LOG_VERYVERBOSE, "SIGCHLD is being blocked\n"); if (sigprocmask(SIG_BLOCK, &newmask, &origmask) == -1) { exit(-1); } lprintf(LOG_VERYVERBOSE, "Installing signal handler for SIGCHLD\n"); prev_sigchld = signal(SIGCHLD, trap_child); if (prev_sigchld == SIG_ERR) { exit(-1); } /* ------------------------------------ */ lprintf(LOG_VERBOSE, "Forking process for service '%s'\n", mservice); pid = fork(); switch (pid) { case 0: /* Child */ { /* -------------------------------------------- */ /* Return child process' signal mask back */ /* to it's original state. */ /* -------------------------------------------- */ if (signal(SIGCHLD, prev_sigchld) == SIG_ERR) { exit(-1); } if (sigprocmask(SIG_SETMASK, &origmask, NULL) == -1) { exit(-1); } /* -------------------------------------------- */ lprintf(LOG_VERBOSE, "Started process for service '%s'\n", mservice); for (i=0; iversion.h # -------------------------------------------------------------------- sms_client.o: sms_client.c expand.h sms_list.h ../driver/driver.h ../logfile/logfile.h ../error.h ../../Makefile.config version.h $(CC) $(CFLAGS) -c sms_client.c -DMSERVICEDIR="\"$(MSERVICEDIR)\"" -DMLOGLEVEL=3 -DMLOGFILE="\"$(MLOGFILE)\"" $(INCLUDE) sms_address.o: sms_address.c expand.h sms_list.h ../../Makefile.config version.h $(CC) $(CFLAGS) -c sms_address.c -DMSERVICEDIR="\"$(MSERVICEDIR)\"" -DMLOGLEVEL=3 -DMLOGFILE="\"$(MLOGFILE)\"" $(INCLUDE) sms_list.o: sms_list.c sms_list.h ../error.h ../logfile/logfile.h $(CC) $(CFLAGS) -c sms_list.c $(INCLUDE) expand.o: ../logfile/logfile.h expand.h expand.c ../error.h sms_list.h ../driver/driver.h ../../Makefile.config $(CC) $(CFLAGS) -c expand.c -DMLOCALSMSRC="\"$(MLOCALSMSRC)\"" -DMGLOBALSMSRC="\"$(MGLOBALSMSRC)\"" $(INCLUDE) # -------------------------------------------------------------------- ../../bin/sms_client: sms_client.o expand.o ../logfile/logfile.o sms_list.o driver_lib lock ../common/common.o parser_lib comms resource ../../Makefile.modemlib $(CC) $(CFLAGS) -o ../../bin/sms_client sms_client.o expand.o $(MOBJS) ../logfile/logfile.o sms_list.o ../driver/sms_driver.a $(MLIBS) ../common/common.o $(XTRALIBS) ../parser/gs_parser.a ../comms/comms.a ../lock/lock.a ../resource/resource.a $(MLIBS) ../../bin/sms_address: sms_address.o expand.o sms_list.o driver_lib ../common/common.o parser_lib lock comms ../../Makefile.modemlib $(CC) $(CFLAGS) -o ../../bin/sms_address sms_address.o expand.o sms_list.o ../logfile/logfile.o $(MOBJS) ../driver/sms_driver.a $(MLIBS) ../common/common.o $(XTRALIBS) ../parser/gs_parser.a ../comms/comms.a ../lock/lock.a ../resource/resource.a $(MLIBS) # -------------------------------------------------------------------- ../logfile/logfile.o: ../logfile/logfile.c ../logfile/logfile.h cd ../logfile ; $(MAKE) logfile.o ../common/common.o: ../common/common.c ../common/common.h cd ../common ; $(MAKE) common.o # -------------------------------------------------------------------- smsclient-2.0.8z/src/server/0000755000175000017500000000000011007575270015705 5ustar noodlesnoodlessmsclient-2.0.8z/src/server/snppd.c0000644000175000017500000001573010127274516017204 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* snppd.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #if defined(LINUX) #include #endif #include "lock/lock.h" #include "server.h" #include "logfile/logfile.h" #include "common/common.h" #include "version.h" /* -------------------------------------------------------------------- */ #if !defined(MSNPPDLOGFILE) #error "MSNPPDLOGFILE undefined" #else #define LOGFILE MSNPPDLOGFILE #endif #if !defined(MSNPPDLOGLEVEL) #error "MSNPPDLOGLEVEL undefined" #else #define LOGLEVEL MSNPPDLOGLEVEL #endif #if !defined(MVERSION) #error "MVERSION undefined" #else #define VERSION MVERSION #endif /* -------------------------------------------------------------------- */ #define SNPP_PORT 444 /* Standard port number */ /* assigned for snpp traffic */ #define SNPPD_SPOOLDIR "/var/spool/sms" #define SNPPD_LOCKDIR "locks" #define SNPPD_LOCKFILE SNPPD_SPOOLDIR SNPPD_LOCKDIR "/snppd.pid" /* -------------------------------------------------------------------- */ #define ERROR_STATE -2 #define EXIT_STATE -1 #define LOGIN_STATE 0 #define PAGE_STATE 1 #define MESSAGE_STATE 2 #define SEND_STATE 3 #define HELP_STATE 4 /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void gateway(int new_fd) { char buf[MAX_STRING_LEN], host_name[512], ip_address[512]; int state; if (get_client_information(new_fd, host_name, ip_address) == 0) { lprintf(LOG_STANDARD, "Connection from %s [%s]\n", host_name, ip_address); } hprintf(new_fd, "220 SNPP Gateway Ready\n"); state = LOGIN_STATE; while ((state != EXIT_STATE) && (state != ERROR_STATE) && (hgets(buf, MAX_STRING_LEN, new_fd) != NULL)) { if (strncasecmp(buf, "PAGE", 4) == 0) { if (state == LOGIN_STATE) { hprintf(new_fd, "250 Pager ID Accepted\n"); state = PAGE_STATE; } else { state = ERROR_STATE; } } else if (strncasecmp(buf, "MESS", 4) == 0) { if (state == PAGE_STATE) { hprintf(new_fd, "250 Message OK\n"); state = MESSAGE_STATE; } else { state = ERROR_STATE; } } else if (strncasecmp(buf, "SEND", 4) == 0) { if (state == MESSAGE_STATE) { hprintf(new_fd, "250 Message Sent Successfully\n"); state = SEND_STATE; } else { state = ERROR_STATE; } } else if (strncasecmp(buf, "QUIT", 4) == 0) { hprintf(new_fd, "221 OK, Goodbye\n"); state = EXIT_STATE; } else if (strncasecmp(buf, "RESE", 4) == 0) { hprintf(new_fd, "250 RESET OK\n"); state = LOGIN_STATE; } else if (strncasecmp(buf, "HELP", 4) == 0) { hprintf(new_fd, "214 PAGE \n"); hprintf(new_fd, "214 MESS \n"); hprintf(new_fd, "214 SEND\n"); hprintf(new_fd, "214 QUIT\n"); hprintf(new_fd, "250 End of Help Information\n"); state = LOGIN_STATE; } else { state = ERROR_STATE; } if (state == ERROR_STATE) { hprintf(new_fd, "421 Error Connection Terminated\n"); } } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void usage(char *file) { lprintf(LOG_STANDARD, "Usage: %s [-l loglevel] [-p port]\n", file); lprintf(LOG_STANDARD, " %s -v\n", file); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void release_lock(void) { resource_unlock(SNPPD_LOCKFILE); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char *argv[]) { int c, port; char *ptr; struct sockaddr sa_client; /* ---------------------------- */ set_logfile(LOGFILE); set_loglevel(LOGLEVEL); set_consolelog(TRUE); /* ---------------------------- */ port = SNPP_PORT; while ((c = getopt (argc, argv, "p:l:v")) != -1) { switch (c) { case 'p': port = (int)strtol(optarg, &ptr, 10); break; case 'l': set_loglevel((int)strtol(optarg, &ptr, 10)); if (ptr == optarg) { lprintf(LOG_ERROR, "Option l requires an argument\n"); usage(argv[0]); exit(-1); } break; case 'v': lprintf(LOG_STANDARD, "%s %s\n", argv[0], VERSION); exit(0); case '?': lprintf(LOG_ERROR, "Unknown option `-%c'\n", optopt); usage(argv[0]); exit(-1); default: abort (); } } if ((argc - optind) != 0) { usage(argv[0]); exit(-1); } /* ---------------------------- */ c = sizeof(sa_client); if (getpeername(fileno(stdin), &sa_client, &c) < 0) { /* getpeername() fails if fd isn't a */ /* socket. If this is the case we can */ /* assume that we aren't running */ /* from inetd and should startup and */ /* as and run as a daemon ourselves. */ lprintf(LOG_STANDARD, "Starting SNPPD Standalone Server deamon...\n"); if (server_main(port, gateway, SNPPD_LOCKFILE) == -1) { lprintf(LOG_STANDARD, "Failed to start SNPPD Standalone Server deamon\n"); exit(-1); } } else { set_consolelog(FALSE); lprintf(LOG_STANDARD, "Starting SNPPD Server as an INETD service\n"); gateway(fileno(stdin)); } return 0; } smsclient-2.0.8z/src/server/version.h0000644000175000017500000000003210127274516017537 0ustar noodlesnoodles#define MVERSION "2.0.8u" smsclient-2.0.8z/src/server/server.c0000644000175000017500000002204010127274516017356 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* server.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "lock/lock.h" #include "server.h" #include "logfile/logfile.h" #include "common/common.h" /* -------------------------------------------------------------------- */ #if !defined(WNOHANG) #define WNOHANG 0 #endif /* -------------------------------------------------------------------- */ /* Read a complete '\n' terminated string from socket */ /* upto maxlen characters will be read and a '\0' is appended */ /* -------------------------------------------------------------------- */ char *hgets(char *buf, int maxlen, int fd) { int result, i; /* NOTE - */ /* As this function now uses recv instead of read */ /* it probably makes sense to use the MSG_PEEK functionality */ /* to read a block of data find the newline and then */ /* make another call to receive with the correct length */ /* of the line. */ i = 0; buf[0] = '\0'; while (i < (maxlen -1)) { result = read(fd, &buf[i], 1); if (result < 0) { if (errno != EINTR) { lprintf(LOG_ERROR, "read() failed\n"); exit(-1); } } else if (result == 0) { buf[i+1] = '\0'; if (i == 0) { return NULL; } break; } else { if (buf[i] == '\n') { i++; break; } i++; } } buf[i] = '\0'; return buf; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void hprintf(int fd, char *fmt, ...) { va_list args; int line_len, len; static char line[MAX_STRING_LEN]; char *line_ptr; /* ---------------------------- */ va_start(args, fmt); #if !defined(LINUX) vsprintf(line, fmt, args); #else vsnprintf(line, MAX_STRING_LEN, fmt, args); #endif va_end(args); line_len = strlen(line); line_ptr = line; while ((len = write(fd, line_ptr, line_len)) != line_len) { if (len < 0) { if (errno == EINTR) { continue; } else { lprintf(LOG_ERROR, "write() failed\n"); exit(-1); } } line_ptr += len; line_len -= len; } } /* -------------------------------------------------------------------- */ /* Reap child processes on receipt of SIGCHLD */ /* -------------------------------------------------------------------- */ #if defined(LINUX) || defined(SOLARIS) void sigchld_handler(int signum) { while (waitpid((pid_t)-1, NULL, WNOHANG) > 0) { /* Reap children */ } signal(SIGCHLD, sigchld_handler); /* Re-establish signal */ /* handler */ } #endif /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int server_init(int server_port) { int sockfd; /* listen on sock_fd */ struct sockaddr_in server_addr; /* my address information */ if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { lprintf(LOG_ERROR, "socket() failed\n"); return(-1); } server_addr.sin_family = AF_INET; /* host byte order */ server_addr.sin_port = htons(server_port); /* short, network byte order */ server_addr.sin_addr.s_addr = INADDR_ANY; /* auto-fill with my IP */ memset(&(server_addr.sin_zero), 0, 8); /* zero rest of struct */ if (bind(sockfd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) < 0) { switch (errno) { case EADDRINUSE: lprintf(LOG_ERROR, "bind() failed - Socket %d allready in use\n", server_port); break; case EACCES: lprintf(LOG_ERROR, "bind() failed - Socket %d protected port and not superuser\n", server_port); break; default: lprintf(LOG_ERROR, "bind() failed\n"); } return(-1); } if (listen(sockfd, MAX_BACKLOG) < 0) { lprintf(LOG_ERROR, "listen() failed\n"); return(-1); } lprintf(LOG_STANDARD, "Listening on port %d\n", server_port); return sockfd; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ extern void release_lock(void); int server_quit; void signal_term(int sig) { server_quit = TRUE; } void init_server_quit_handler(void) { struct sigaction act; act.sa_flags = 0; act.sa_handler = signal_term; sigemptyset(&act.sa_mask); #if defined(SA_INTERRUPT) act.sa_flags |= SA_INTERRUPT; #endif server_quit = FALSE; sigaction(SIGTERM, &act, NULL); } int server_main(int server_port, void (*handle_child)(int new_fd), char *lockfile) { pid_t pid; int sockfd, sin_size, new_fd; struct sockaddr_in client_addr; /* connector's address information */ if (deamon_init() != 0) { return(-11); } resource_check_lockdir(lockfile); if (resource_lock(lockfile)) { lprintf(LOG_ERROR, "smsd aborted, lockfile held by another smsd daemon\n"); return(-1); } sockfd = server_init(server_port); if (sockfd == -1) { release_lock(); return(-1); } #if defined(LINUX) || defined(SOLARIS) signal(SIGCHLD, sigchld_handler); #else signal(SIGCHLD, SIG_IGN); /* Automagically reap zombies */ /* under SYSV */ #endif set_consolelog(FALSE); /* No more login output */ /* to be sent to the console */ init_server_quit_handler(); while(! server_quit) { /* main accept() loop */ sin_size = sizeof(struct sockaddr_in); if ((new_fd = accept(sockfd, (struct sockaddr *)&client_addr, &sin_size)) < 0) { if (errno == EINTR) { continue; } else { lprintf(LOG_ERROR, "accept() failed\n"); release_lock(); exit(-1); } } pid = fork(); if (pid == 0) { (*handle_child)(new_fd); close(new_fd); exit(0); } else if (pid < 0) { lprintf(LOG_ERROR, "Trying to fork child process\n"); release_lock(); exit(-1); } close(new_fd); } release_lock(); return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void default_echo(int new_fd) { char buf[MAX_STRING_LEN]; while (hgets(buf, MAX_STRING_LEN, new_fd) != NULL) { printf("Received Data +%s+\n", buf); hprintf(new_fd, "Echo: +%s+\n", buf); } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int deamon_init(void) { pid_t pid; pid = fork(); if (pid == -1) { lprintf(LOG_ERROR, "fork() Failed with errno %d\n", errno); return(-1); } else if (pid != 0) { exit(0); /* Parent Exits */ } /* ------------------------------------ */ /* Child continues */ /* ------------------------------------ */ if (setsid() < 0) /* Become session leader */ { lprintf(LOG_ERROR, "setsid() Failed with errno %d\n", errno); return(-1); } if (chdir("/") < 0) /* Change working directory */ { lprintf(LOG_ERROR, "chdir() Failed with errno %d\n", errno); return(-1); } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int get_client_information(int fd, char *host_name, char *ip_address) { int sin_size; struct sockaddr_in client_addr; /* connector's address information */ struct hostent *host; u_long addr; sin_size = sizeof(struct sockaddr_in); if ((getpeername(fd, (struct sockaddr *)&client_addr, &sin_size)) < 0) { return -1; } strcpy(ip_address, inet_ntoa(client_addr.sin_addr)); addr = inet_addr(ip_address); host = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET); if (host != NULL) { strcpy(host_name, host->h_name); } else { strcpy(host_name, ""); } return 0; } smsclient-2.0.8z/src/server/smsd.c0000644000175000017500000007025110127274516017025 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* smsd.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include #include #if defined(LINUX) #include #endif #include "server.h" #include "logfile/logfile.h" #include "common/common.h" #include "resource/resource.h" #include "parser/gs_translate.h" #include "version.h" #include "lock/lock.h" #include "error.h" /* -------------------------------------------------------------------- */ #if !defined(MVERSION) #error "MVERSION undefined" #else #define VERSION MVERSION #endif #if !defined(MSMSDLOGFILE) #error "MSMSDLOGFILE undefined" #else #define LOGFILE MSMSDLOGFILE #endif #if !defined(MSMSDLOGLEVEL) #error "MSMSDLOGLEVEL undefined" #else #define LOGLEVEL MSMSDLOGLEVEL #endif #if !defined(MSERVICEDIR) #error "MSERVICEDIR undefined" #else #define SERVICEDIR MSERVICEDIR #endif #define DAEMONCONFIGFILE (MSERVICEDIR "/sms_daemons") /* -------------------------------------------------------------------- */ #define ERROR_STATE -2 #define EXIT_STATE -1 #define NULL_STATE 0 #define UNKNOWN_STATE 1 #define OK_STATE 2 /* -------------------------------------------------------------------- */ struct sms_control_data_struct { char *user, *host, *mail, *alen, *destination_service, *destination_id, *control_file, *data_file, *id; long len; }; typedef struct sms_control_data_struct SMS_CONTROL_DATA; struct sms_data_struct { char *data; }; typedef struct sms_data_struct SMS_DATA; /* -------------------------------------------------------------------- */ SMS_DATA sms_data; /* -------------------------------------------------------------------- */ static int smsd_port, smsd_maxid; static char smsd_lockfile[512]; static char *smsd_spool, *smsd_incoming, *smsd_services, *smsd_locks; static TOKEN_HEAP *smsd_services_heap; static RESOURCE resource_list[] = { { RESOURCE_NUMERIC, "server.port", 0, 1, NULL, 0, NULL, 4563, &smsd_port }, { RESOURCE_NUMERIC, "server.maxid", 0, 1, NULL, 0, NULL, 32000, &smsd_maxid }, { RESOURCE_STRING, "directories.spool", 0, 1, NULL, 0, "/var/spool/sms", 0, &smsd_spool }, { RESOURCE_STRING, "directories.incoming", 0, 1, NULL, 0, "incoming", 0, &smsd_incoming }, { RESOURCE_STRING, "directories.services", 0, 1, NULL, 0, "services", 0, &smsd_services }, { RESOURCE_STRING, "directories.locks", 0, 1, NULL, 0, "locks", 0, &smsd_locks }, { RESOURCE_HEAP, "services", 0, 1, NULL, 0, NULL, 0, &smsd_services_heap }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; #define SMS_PORT smsd_port /* Standard port number */ /* assigned for sms traffic */ #define SMS_SPOOLDIR smsd_spool #define SMS_LOCKDIR smsd_locks #define SMS_INCOMINGDIR smsd_incoming #define SMS_SERVICESDIR smsd_services #define SMS_MAXID smsd_maxid /* -------------------------------------------------------------------- */ #define SAFEOUTPUT(X) ((X == NULL)?(""):(X)) #define SAFECONTROLOUTPUT(X) ((X == NULL)?(""):(X)) /* -------------------------------------------------------------------- */ void cleanup_files(SMS_CONTROL_DATA *control_data); void display_current(int fd, SMS_CONTROL_DATA *control_data); void gateway(int new_fd); void usage(char *file); char *get_data(char *buf); int gen_controlfile(SMS_CONTROL_DATA *control_data); int copy_data(int dst_fd, int src_fd, long dlen); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void display_current(int fd, SMS_CONTROL_DATA *control_data) { hprintf(fd, " Current Control Record info:\r\n"); hprintf(fd, " Username: %s\r\n", SAFEOUTPUT(control_data->user)); hprintf(fd, " Hostname: %s\r\n", SAFEOUTPUT(control_data->host)); hprintf(fd, " Mail on Delivery: %s\r\n", SAFEOUTPUT(control_data->mail)); hprintf(fd, " Destination Service: %s\r\n", SAFEOUTPUT(control_data->destination_service)); hprintf(fd, " Destination ID: %s\r\n", SAFEOUTPUT(control_data->destination_id)); hprintf(fd, " Control File: %s\r\n", SAFEOUTPUT(control_data->control_file)); hprintf(fd, " Data File: %s\r\n", SAFEOUTPUT(control_data->data_file)); hprintf(fd, " ID: %s\r\n", SAFEOUTPUT(control_data->id)); hprintf(fd, " Length: %ld\r\n", control_data->len); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void write_control_data(SMS_CONTROL_DATA *control_data) { FILE *fp; fp = fopen(control_data->control_file, "w"); if (fp == NULL) { lprintf(LOG_ERROR, "Opening control_file '%s'\n", control_data->control_file); exit(-1); } fprintf(fp, "{\n"); fprintf(fp, " username = \"%s\"\n", SAFECONTROLOUTPUT(control_data->user)); fprintf(fp, " hostname = \"%s\"\n", SAFECONTROLOUTPUT(control_data->host)); fprintf(fp, " mail_on_delivery = \"%s\"\n", SAFECONTROLOUTPUT(control_data->mail)); fprintf(fp, " destination_service = \"%s\"\n", SAFECONTROLOUTPUT(control_data->destination_service)); fprintf(fp, " destination_id = \"%s\"\n", SAFECONTROLOUTPUT(control_data->destination_id)); fprintf(fp, " control_file = \"%s\"\n", SAFECONTROLOUTPUT(control_data->control_file)); fprintf(fp, " data_file = \"%s\"\n", SAFECONTROLOUTPUT(control_data->data_file)); fprintf(fp, " id = \"%s\"\n", SAFECONTROLOUTPUT(control_data->id)); fprintf(fp, " length = \"%ld\"\n", control_data->len); fprintf(fp, "}\n"); fclose(fp); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #define iseol(x) ((x == '\n') || (x == '\r')) char *get_field(char *buf, char **eptr) { char *new_buf, *ptr, *dst; int inword; /* ---------------------------------------- */ new_buf = NULL; inword = FALSE; ptr = buf; while(!iseol(*ptr) && (*ptr != '\0')) { if (!isspace(*ptr) && !inword) { new_buf = (char *)malloc(sizeof(char) * (strlen(buf) +1)); if (new_buf == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } inword = TRUE; dst = new_buf; } else if (isspace(*ptr)) { if (inword) { break; } inword = FALSE; } if (inword) { *dst++ = *ptr; } ptr++; } if (inword) { *dst = '\0'; } *eptr = ptr; return new_buf; } /* -------------------------------------------------------------------- */ /* Parse string of form: */ /* */ /* COMMANDDATA */ /* */ /* Copy data to newly allocated buffer and return */ /* a pointer to it. If no data available return NULL */ /* -------------------------------------------------------------------- */ #define iseol(x) ((x == '\n') || (x == '\r')) char *get_data(char *buf) { char *src, *dst, *data; int i, j, cmd; cmd = TRUE; src = buf; i = 0; j = 0; #if 0 while ((*src != '\n') && (*src != '\0') && (*src != '\r')) #else while ((!iseol(*src)) && (*src != '\0')) #endif { if ((cmd) && (*src == ' ')) { cmd = FALSE; j = i+1; i = 0; } else { i++; } src++; } if (j == 0) { return NULL; } data = (char *)malloc(sizeof(char) * (i +1)); if (dst == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } dst = data; src = &buf[j]; #if 0 while ((*src != '\n') && (*src != '\0') && (*src != '\r')) #else while ((!iseol(*src)) && (*src != '\0')) #endif { *dst++ = *src++; } *dst = '\0'; return data; } /* -------------------------------------------------------------------- */ /* Return Values: */ /* */ /* 0 - If the current control record is incomplete */ /* 1 - if the current control record is complete */ /* */ /* -------------------------------------------------------------------- */ int is_complete(SMS_CONTROL_DATA *control_data) { if ((control_data->user == NULL) || (control_data->host == NULL) || (control_data->mail == NULL) || (control_data->alen == NULL) || (control_data->id == NULL) || (control_data->destination_service == NULL) || (control_data->destination_id == NULL) || (control_data->control_file == NULL) || (control_data->data_file == NULL)) { return 0; } return 1; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ SMS_CONTROL_DATA *init_control_data(void) { SMS_CONTROL_DATA *control_data; control_data = (SMS_CONTROL_DATA *)malloc(sizeof(SMS_CONTROL_DATA)); if (control_data == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } control_data->user = NULL; control_data->host = NULL; control_data->mail = NULL; control_data->alen = NULL; control_data->id = NULL; control_data->destination_service = NULL; control_data->destination_id = NULL; control_data->control_file = NULL; control_data->data_file = NULL; control_data->len = 0; return control_data; } /* -------------------------------------------------------------------- */ /* Generate a control file in the incoming directory. */ /* The control file is empty. */ /* The control_data structure is updated to include the full path */ /* to the generated control file and it's corresponding data file. */ /* Note that memory is allocated for each of control_file, */ /* data_file and id. It is the responsibility of the caller to */ /* free this memory. */ /* */ /* Return Value: */ /* */ /* -1 error */ /* 0 Success */ /* -------------------------------------------------------------------- */ int gen_controlfile(SMS_CONTROL_DATA *control_data) { int n, fd; cleanup_files(control_data); control_data->id = (char *)malloc(sizeof(char) * 8); if (control_data->id == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } control_data->control_file = (char *)malloc(sizeof(char) * (strlen(SMS_SPOOLDIR) + strlen(SMS_INCOMINGDIR) + 10)); if (control_data->control_file == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } control_data->data_file = (char *)malloc(sizeof(char) * (strlen(SMS_SPOOLDIR) + strlen(SMS_INCOMINGDIR) + 10)); if (control_data->data_file == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } strcpy(control_data->control_file, SMS_SPOOLDIR); sms_filecat(control_data->control_file, SMS_INCOMINGDIR); sms_filecat(control_data->control_file, ""); strcpy(control_data->data_file, SMS_SPOOLDIR); sms_filecat(control_data->data_file, SMS_INCOMINGDIR); sms_filecat(control_data->data_file, ""); for (n = getpid(); n < SMS_MAXID; n++) { sprintf(control_data->id, "%05d", n); sprintf(control_data->control_file, "%scf%s", control_data->control_file, control_data->id); sprintf(control_data->data_file, "%sdf%s", control_data->data_file, control_data->id); if (access(control_data->control_file, F_OK) == 0) { continue; } else { fd = open(control_data->control_file, O_CREAT|O_WRONLY|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); if (fd == -1) { if (errno == EEXIST) { continue; } lprintf(LOG_WARNING, "Cannot create file %s\n", control_data->control_file); free(control_data->control_file); free(control_data->data_file); free(control_data->id); return -1; } else { close(fd); break; } } } if (n == SMS_MAXID) { lprintf(LOG_WARNING, "Cannot create file as MAXID exceeded\n"); free(control_data->control_file); free(control_data->data_file); free(control_data->id); return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void cleanup_files(SMS_CONTROL_DATA *control_data) { if (control_data->control_file != NULL) { unlink(control_data->control_file); free(control_data->control_file); control_data->control_file = NULL; } if (control_data->data_file != NULL) { unlink(control_data->data_file); free(control_data->data_file); control_data->data_file = NULL; } if (control_data->id != NULL) { free(control_data->id); control_data->id = NULL; } } char *strip_eol(char *buf) { char *ptr; ptr = buf; while (*ptr != '\0') { if (iseol(*ptr)) { *ptr = '\0'; break; } ptr++; } return buf; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void gateway(int new_fd) { char buf[MAX_STRING_LEN], host_name[512], ip_address[512], *tmp_buf, *ptr, *cmd, *job, *queue, *command; int state, data_fd; SMS_CONTROL_DATA *control_data; control_data = init_control_data(); if (get_client_information(new_fd, host_name, ip_address) == 0) { lprintf(LOG_STANDARD, "Connection from %s [%s]\n", host_name, ip_address); } hprintf(new_fd, "400 SMS Gateway Ready\r\n"); while ((state != EXIT_STATE) && (state != ERROR_STATE) && (hgets(buf, MAX_STRING_LEN, new_fd) != NULL)) { state = NULL_STATE; cmd = get_field(buf, &ptr); if (cmd == NULL) { hprintf(new_fd, "502 '%s': command not understood.\r\n", strip_eol(buf)); continue; } if (strcmp(cmd, "MAIL") == 0) { control_data->mail = get_field(ptr, &ptr); if (control_data->mail == NULL) { state = UNKNOWN_STATE; } else { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { /* Check this is a valid */ /* email address. */ state = OK_STATE; } } } else if (strcmp(cmd, "HOST") == 0) { control_data->host = get_field(ptr, &ptr); if (control_data->host == NULL) { state = UNKNOWN_STATE; } else { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { /* Check that this is a valid */ /* hostname. */ state = OK_STATE; } } } else if (strcmp(cmd, "DEST") == 0) { control_data->destination_service = get_field(ptr, &ptr); if (control_data->destination_service == NULL) { state = UNKNOWN_STATE; } else { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { /* Check that this is a valid */ /* destination-service. */ if (get_varlist(smsd_services_heap, control_data->destination_service) != NULL) { state = OK_STATE; } else { state = UNKNOWN_STATE; } } } } else if (strcmp(cmd, "ID") == 0) { control_data->destination_id = get_field(ptr, &ptr); if (control_data->destination_id == NULL) { state = UNKNOWN_STATE; } else { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { /* Check that this is a valid */ /* destination-id. */ state = OK_STATE; } } } else if (strcmp(cmd, "DATA") == 0) { /* The control file only gets generated when */ /* data is received. It is placed in incoming */ /* All required fields have been sent and */ /* are included. */ control_data->alen = get_field(ptr, &ptr); if (control_data->alen == NULL) { state = UNKNOWN_STATE; } else { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { control_data->len = atoi(control_data->alen); /* WARNING - use strtol and strict */ /* checks */ /* Read 'len' bytes of data from fd */ /* and copy to data_file */ /* Open up the data_file - */ /* ensure we have a control file and */ /* all locks are setup */ if (gen_controlfile(control_data) == -1) { state = ERROR_STATE; } else { data_fd = open(control_data->data_file, O_CREAT|O_WRONLY|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); if (data_fd < 0) { lprintf(LOG_ERROR, "Opening data_file '%s'\n", control_data->data_file); exit(-1); } if (copy_data(data_fd, new_fd, control_data->len) != 0) { lprintf(LOG_ERROR, "Copying data failed\n"); exit(-1); } close(data_fd); read(new_fd, &buf[0], 1); if (buf[0] == '\n') { state = OK_STATE; } else if (buf[0] == '\r') { read(new_fd, &buf[0], 1); if (buf[0] == '\n') { state = OK_STATE; } else { state = ERROR_STATE; } } else { state = ERROR_STATE; } } } } } else if (strcmp(cmd, "USER") == 0) { control_data->user = get_field(ptr, &ptr); if (control_data->user == NULL) { state = UNKNOWN_STATE; } else { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { /* Check that this is a valid */ /* user. */ state = OK_STATE; } } } else if (strcmp(cmd, "SEND") == 0) { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { if (is_complete(control_data)) { write_control_data(control_data); state = OK_STATE; } else { state = ERROR_STATE; } } } else if (strcmp(cmd, "SENJ") == 0) { job = get_field(ptr, &ptr); if (job == NULL) { state = UNKNOWN_STATE; } else { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { /* Check this is a valid */ /* job. */ if (is_complete(control_data)) { write_control_data(control_data); state = OK_STATE; } else { state = ERROR_STATE; } } free(job); } } else if (strcmp(cmd, "SENQ") == 0) { queue = get_field(ptr, &ptr); if (queue == NULL) { state = UNKNOWN_STATE; } else { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { /* Check this is a valid */ /* queue. */ if (is_complete(control_data)) { write_control_data(control_data); state = OK_STATE; } else { state = ERROR_STATE; } } free(queue); } } else if (strcmp(cmd, "SENA") == 0) { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { if (is_complete(control_data)) { write_control_data(control_data); state = OK_STATE; } else { state = ERROR_STATE; } } } else if (strcmp(cmd, "STAJ") == 0) { job = get_field(ptr, &ptr); if (job == NULL) { state = UNKNOWN_STATE; } else { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { state = UNKNOWN_STATE; } else { /* Check this is a valid */ /* job. */ state = OK_STATE; } free(job); } } else if (strcmp(cmd, "STAQ") == 0) { queue = get_field(ptr, &ptr); if (queue == NULL) { state = UNKNOWN_STATE; } else { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { /* Check this is a valid */ /* queue. */ state = OK_STATE; } free(queue); } } else if (strcmp(cmd, "STAT") == 0) { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { state = OK_STATE; } } else if (strcmp(cmd, "INFO") == 0) { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { hprintf(new_fd, "231- SMS Server info:\r\n"); hprintf(new_fd, " Version: 0.1\r\n"); display_current(new_fd, control_data); hprintf(new_fd, "231 End of Info.\r\n"); } } else if (strcmp(cmd, "QUIT") == 0) { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { hprintf(new_fd, "220 Goodbye.\r\n"); state = EXIT_STATE; } } else if (strcmp(cmd, "HELP") == 0) { command = get_field(ptr, &ptr); if (command == NULL) { hprintf(new_fd, "230- The following commands are recognized\r\n"); hprintf(new_fd, " USER DATA MAIL HOST DEST\r\n"); hprintf(new_fd, " SEND SENJ SENQ SENA \r\n"); hprintf(new_fd, " STAT STAJ STAQ ID \r\n"); hprintf(new_fd, " QUIT INFO HELP \r\n"); hprintf(new_fd, "230 End of Help.\r\n"); } else { tmp_buf = get_field(ptr, &ptr); if (tmp_buf != NULL) { free(tmp_buf); state = UNKNOWN_STATE; } else { if (strcmp(command, "USER") == 0) { hprintf(new_fd, "214 Syntax: USER username\r\n"); } else if (strcmp(command, "HOST") == 0) { hprintf(new_fd, "214 Syntax: HOST hostname\r\n"); } else if (strcmp(command, "DEST") == 0) { hprintf(new_fd, "214 Syntax: DEST service\r\n"); } else if (strcmp(command, "ID") == 0) { hprintf(new_fd, "214 Syntax: ID id\r\n"); } else if (strcmp(command, "DATA") == 0) { hprintf(new_fd, "214 Syntax: DATA len <\\r\\n> data <\\r\\n>\r\n"); } else if (strcmp(command, "MAIL") == 0) { hprintf(new_fd, "214 Syntax: MAIL address\r\n"); } else if (strcmp(command, "QUIT") == 0) { hprintf(new_fd, "214 Syntax: QUIT (terminate service)\r\n"); } else { hprintf(new_fd, "502 '%s': command unknown.\r\n", strip_eol(buf)); } } free(command); } } else { state = UNKNOWN_STATE; } if (state == ERROR_STATE) { hprintf(new_fd, "510 Error Connection Terminated.\r\n"); } else if (state == UNKNOWN_STATE) { hprintf(new_fd, "511 '%s': command not understood.\r\n", strip_eol(buf)); } else if (state == OK_STATE) { hprintf(new_fd, "210 Ok.\r\n"); } } if (state == ERROR_STATE) { cleanup_files(control_data); } free(control_data); } /* -------------------------------------------------------------------- */ /* Read 'len' bytes of data from src_fd and copy to 'dst_fd' */ /* Return Values */ /* */ /* 0 Success */ /* -1 Failure */ /* -------------------------------------------------------------------- */ int copy_data(int dst_fd, int src_fd, long dlen) { int len, sent; char *ptr; char *mbuf; mbuf = (char *)malloc(sizeof(char) * 1024); if (mbuf == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } { len = read(src_fd, mbuf, ((dlen<1024)?(dlen):(1024))); if (len < 0) { if (errno != EINTR) { lprintf(LOG_ERROR, "read() failed\n"); return(-1); } } } while (len < 0); while(len) { dlen -= len; ptr = mbuf; sent = 0; while (len - sent) { len -= sent; ptr += sent; { sent = write(dst_fd, ptr, len); if (sent < 0) { if (errno != EINTR) { lprintf(LOG_ERROR, "write() failed\n"); return(-1); } } } while (len < 0); if (sent == 0) { lprintf(LOG_ERROR, "write() failed\n"); return(-1); } } if (dlen <= 0) { break; } { len = read(src_fd, mbuf, ((dlen<1024)?(dlen):(1024))); if (len < 0) { if (errno != EINTR) { lprintf(LOG_ERROR, "read() failed\n"); return(-1); } } } while (len < 0); } free(mbuf); return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void usage(char *file) { lprintf(LOG_STANDARD, "Usage: %s [-l loglevel] [-p port]\n", file); lprintf(LOG_STANDARD, " %s -v\n", file); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void release_lock(void) { resource_unlock(smsd_lockfile); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char *argv[]) { int c, port; char *ptr; struct sockaddr sa_client; /* ---------------------------- */ set_logfile(LOGFILE); set_loglevel(LOGLEVEL); set_consolelog(TRUE); /* ---------------------------- */ port = 0; while ((c = getopt (argc, argv, "p:l:v")) != -1) { switch (c) { case 'p': port = (int)strtol(optarg, &ptr, 10); break; case 'l': set_loglevel((int)strtol(optarg, &ptr, 10)); if (ptr == optarg) { lprintf(LOG_ERROR, "Option l requires an argument\n"); usage(argv[0]); exit(-1); } break; case 'v': lprintf(LOG_STANDARD, "%s %s\n", argv[0], VERSION); exit(0); case '?': lprintf(LOG_ERROR, "Unknown option `-%c'\n", optopt); usage(argv[0]); exit(-1); default: abort (); } } /* ---------------------------- */ if (read_resource_file(DAEMONCONFIGFILE, resource_list, 1) == RESOURCE_FILE_ERROR) { lprintf(LOG_ERROR, "Failed to read resource file '%s'\n", DAEMONCONFIGFILE); exit(-1); } if (port != 0) { SMS_PORT = port; } /* ---------------------------- */ if ((argc - optind) != 0) { usage(argv[0]); exit(-1); } /* ---------------------------- */ c = sizeof(sa_client); if (getpeername(fileno(stdin), &sa_client, &c) < 0) { /* getpeername() fails if fd isn't a */ /* socket. If this is the case we can */ /* assume that we aren't running */ /* from inetd and should startup and */ /* run as a daemon ourselves. */ strcpy(smsd_lockfile, SMS_SPOOLDIR); sms_filecat(smsd_lockfile, SMS_LOCKDIR); sms_filecat(smsd_lockfile, "smsd.pid"); lprintf(LOG_STANDARD, "Starting SMSD Standalone Server deamon...\n"); if (server_main(SMS_PORT, gateway, smsd_lockfile) == -1) { lprintf(LOG_STANDARD, "Failed to start SMSD Standalone Server deamon\n"); exit(-1); } } else { set_consolelog(FALSE); lprintf(LOG_STANDARD, "Starting SMSD Server as an INETD service\n"); gateway(fileno(stdin)); } return 0; } smsclient-2.0.8z/src/server/server.h0000644000175000017500000000367210127274516017375 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* server.h */ /* */ /* */ /* Copyright (C) 1997 Angelo Masci */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /* This program is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- $Id$ -------------------------------------------------------------------- */ #define MAX_BACKLOG 10 /* Max connections to queue */ #define MAX_STRING_LEN 1024 /* -------------------------------------------------------------------- */ void sigchld_handler(int signum); char *hgets(char *buf, int maxlen, int fd); #if !defined(__GNUC__) void hprintf(int fd, char *fmt, ...); #else void hprintf(int fd, char *fmt, ...) __attribute__ ((format (printf, 2, 3))); #endif int server_main(int server_port, void (*handle_child)(int new_fd), char *lockfile); void default_echo(int new_fd); int server_init(int server_port); int deamon_init(void); int get_client_information(int fd, char *host_name, char *ip_address); /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/server/Makefile0000644000175000017500000000677411007575270017363 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- include ../../Makefile.config # -------------------------------------------------------------------- all: ../../bin/smsd ../../bin/snppd install: ../../bin/smsd ../../bin/snppd $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -d $(BINDIR) $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 ../../bin/smsd $(BINDIR) $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 ../../bin/snppd $(BINDIR) uninstall: $(RM) $(BINDIR)/smsd $(RM) $(BINDIR)/snppd clean: $(RM) *.o *.bak ../../bin/smsd ../../bin/snppd # -------------------------------------------------------------------- INCLUDE = -I.. gs_parser: cd ../parser ; $(MAKE) gs_parser.a lock: cd ../lock ; $(MAKE) lock.a resource: cd ../resource ; $(MAKE) resource.a # -------------------------------------------------------------------- version.h: ../../.version echo "#define MVERSION \"`awk '{ print $1 }' ../../.version`\"" >version.h # -------------------------------------------------------------------- server.o: server.c ../common/common.h ../logfile/logfile.h server.h $(CC) $(CFLAGS) -c server.c $(INCLUDE) snppd.o: snppd.c ../logfile/logfile.h server.h ../common/common.h ../../Makefile.config version.h $(CC) $(CFLAGS) -c snppd.c -DMSNPPDLOGLEVEL=3 -DMSNPPDLOGFILE="\"$(MSNPPDLOGFILE)\"" $(INCLUDE) smsd.o: smsd.c ../logfile/logfile.h server.h ../common/common.h ../../Makefile.config ../resource/resource.h version.h $(CC) $(CFLAGS) -c smsd.c -DMSERVICEDIR="\"$(MSERVICEDIR)\"" -DMSMSDLOGLEVEL=3 -DMSMSDLOGFILE="\"$(MSMSDLOGFILE)\"" $(INCLUDE) ../../bin/smsd: smsd.o server.o ../logfile/logfile.o ../common/common.o resource gs_parser lock $(CC) $(CFLAGS) -o ../../bin/smsd smsd.o server.o ../logfile/logfile.o ../common/common.o $(XTRALIBS) ../resource/resource.a ../lock/lock.a ../parser/gs_parser.a ../../bin/snppd: snppd.o server.o ../logfile/logfile.o ../common/common.o lock $(CC) $(CFLAGS) -o ../../bin/snppd snppd.o server.o ../logfile/logfile.o ../common/common.o ../lock/lock.a $(XTRALIBS) # -------------------------------------------------------------------- ../logfile/logfile.o: ../logfile/logfile.c ../logfile/logfile.h cd ../logfile ; $(MAKE) logfile.o ../common/common.o: ../common/common.c ../common/common.h cd ../common ; $(MAKE) common.o # -------------------------------------------------------------------- smsclient-2.0.8z/src/lock/0000755000175000017500000000000011007610111015307 5ustar noodlesnoodlessmsclient-2.0.8z/src/lock/lock.h0000644000175000017500000000317610127274514016436 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* lock.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ int resource_unlock(char *resource_lockfile); int resource_locked(char *resource_lockfile); int resource_lock(char *resource_lockfile); int resource_wait(char *resource_lockfile, long delay); void resource_check_lockdir(char *resource_lockfile); /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/lock/lock.c0000644000175000017500000001533410460430356016426 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* lock.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include #include "logfile/logfile.h" #include "lock.h" #include "common/common.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static pid_t resource_lock_pid(char *resource_lockfile) { int lock_fd, i, eof; pid_t pid; char buf[512], c; lock_fd = open(resource_lockfile, O_RDONLY); if (lock_fd == -1) { return(-1); } eof = FALSE; i = 0; while((i < 11) && (eof == FALSE)) { switch (read(lock_fd, &c, 1)) { case 1: buf[i] = c; i++; break; case -1: if (errno != EINTR) { lprintf(LOG_ERROR, "Reading pid from lockfile '%s'\n", resource_lockfile); exit(-1); } break; case 0: eof = TRUE; } } buf[i] = '\0'; if (sscanf(buf, "%10d\n", &pid) != 1) { pid = -1; } close(lock_fd); return pid; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int resource_unlock(char *resource_lockfile) { pid_t pid; pid = resource_lock_pid(resource_lockfile); if (pid == getpid()) { lprintf(LOG_VERBOSE, "Removing Lockfile '%s'\n", resource_lockfile); unlink(resource_lockfile); } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int file_exists(char *filename) { struct stat stat_buf; if (stat(filename, &stat_buf) == -1) { return -1; } if (! S_ISREG(stat_buf.st_mode)) { return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int directory_exists(char *filename) { struct stat stat_buf; if (stat(filename, &stat_buf) == -1) { return -1; } if (! S_ISDIR(stat_buf.st_mode)) { return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int resource_locked(char *resource_lockfile) { pid_t pid; #if 0 if (access(resource_lockfile, F_OK) == 0) #else if (file_exists(resource_lockfile) == 0) #endif { /* lockfile exists */ pid = resource_lock_pid(resource_lockfile); if (pid != -1) { /* Is there a process with this pid? */ if (kill(pid, 0) == 0) { return -1; /* Process exists */ } else { if (errno == EPERM) { return -1; /* Process exists */ } } /* Process does not exist */ /* we can unlink this lockfile as */ /* it is stale. */ lprintf(LOG_VERBOSE, "Removing Stale Lockfile '%s'\n", resource_lockfile); unlink(resource_lockfile); return 0; } else { /* Could not determine PID of */ /* owner of this lockfile! */ return -1; } } /* No process holds the lock */ return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int resource_lock(char *resource_lockfile) { int lock_fd, i, len; char buf[64]; if (resource_locked(resource_lockfile) == 0) { lock_fd = open(resource_lockfile, O_CREAT|O_WRONLY|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); if (lock_fd == -1) { if (errno == EEXIST) { /* Could not create lockfile */ /* A lockfile already exists */ /* The most likely reason for */ /* this is another process */ /* generating one after our */ /* call to resource_locked() */ return -1; } lprintf(LOG_ERROR, "Cannot create lockfile %s\n", resource_lockfile); exit(-1); } len = sms_snprintf(buf, 64, "%10d sms_client\n", (int)getpid()); i = 0; while(i < len) { switch (write(lock_fd, &buf[i], 1)) { case 1: i++; break; case -1: if (errno != EINTR) { lprintf(LOG_ERROR, "Reading pid from lockfile '%s'\n", resource_lockfile); exit(-1); } } } chmod(resource_lockfile, S_IRUSR|S_IRGRP|S_IROTH); close(lock_fd); /* Created lockfile with this pid */ lprintf(LOG_VERBOSE, "Created Lockfile '%s'\n", resource_lockfile); return 0; } /* Could not create lockfile */ return -1; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int resource_wait(char *resource_lockfile, long delay) { sms_usleep(delay); /* Sleep between checks on the */ /* lockfile. */ /* What would be really nice would */ /* be a way to block and return if */ /* the attributes on the lockfile */ /* change. */ return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void resource_check_lockdir(char *resource_lockfile) { char lock_dir[512], *dst, *ptr; ptr = lock_dir; dst = lock_dir; while (*resource_lockfile != '\0') { if (*resource_lockfile == '/') { ptr = dst; } *dst++ = *resource_lockfile++; } if (ptr == lock_dir) { *ptr++ = '.'; } *ptr = '\0'; #if 0 if (access(lock_dir, R_OK|W_OK|X_OK) < 0) #else if (directory_exists(lock_dir) == -1) #endif { lprintf(LOG_ERROR, "Cannot access lock directory '%s'\n", lock_dir); exit(-1); } } smsclient-2.0.8z/src/lock/Makefile0000644000175000017500000000373610127274514016777 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- include ../../Makefile.config # -------------------------------------------------------------------- all: lock.a clean: $(RM) *.o *.bak lock.a # -------------------------------------------------------------------- INCLUDE = -I.. -I../parser lock.a: lock.o $(RM) lock.a $(AR) lock.a lock.o $(RANLIB) lock.a lock.o: lock.c ../common/common.h ../logfile/logfile.h lock.h $(CC) $(CFLAGS) -c lock.c $(INCLUDE) # -------------------------------------------------------------------- ../logfile/logfile.o: ../logfile/logfile.c ../logfile/logfile.h cd ../logfile ; $(MAKE) logfile.o ../common/common.o: ../common/common.c ../common/common.h cd ../common ; $(MAKE) common.o # -------------------------------------------------------------------- smsclient-2.0.8z/src/common/0000755000175000017500000000000011007610111015647 5ustar noodlesnoodlessmsclient-2.0.8z/src/common/common.h0000644000175000017500000000444710127274502017335 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* common/common.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #if !defined(_COMMON_H) #define _COMMON_H 1 #include /* -------------------------------------------------------------------- */ #if !defined(FALSE) #define FALSE 0 #endif #if !defined(TRUE) #define TRUE (!FALSE) #endif #if defined(NEXT) typedef int ssize_t; typedef int pid_t; typedef unsigned short mode_t; typedef short nlink_t; #endif /* -------------------------------------------------------------------- */ #define MAXLINELEN 256 /* Commonly used for buffers */ /* -------------------------------------------------------------------- */ void sms_usleep(long microseconds); void sms_bzero(void *s, size_t n); char *sms_filecat(char *path, char *element); int sms_snprintf(char *dst, int len, const char *fmt, ...); /* -------------------------------------------------------------------- */ #endif /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/common/common.c0000644000175000017500000000602110127274502017316 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* common.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include "common/common.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void sms_usleep(long microseconds) { #if defined(LINUX) usleep(microseconds); #else struct timeval timeout; timeout.tv_usec = microseconds % 1000000; timeout.tv_sec = microseconds / 1000000; select(0, NULL, NULL, NULL, &timeout); #endif } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void sms_bzero(void *destination, size_t length) { #if defined(LINUX) bzero(destination, length); #else memset(destination, '\0', length); #endif } /* -------------------------------------------------------------------- */ /* Add a file/directory name to a pathname. If the path */ /* does not end with '/' append one before adding the other */ /* file/dir. */ /* -------------------------------------------------------------------- */ char *sms_filecat(char *path, char *element) { if (path[strlen(path)] != '/') { strcat(path, "/"); } return strcat(path, element); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int sms_snprintf(char *dst, int len, const char *fmt, ...) { va_list args; int res; va_start(args, fmt); #if !defined(LINUX) res = vsprintf(dst, fmt, args); #else res = vsnprintf(dst, len, fmt, args); #endif va_end(args); return res; } smsclient-2.0.8z/src/common/sprintf/0000755000175000017500000000000010127274503017351 5ustar noodlesnoodlessmsclient-2.0.8z/src/common/sprintf/vfprintf.c0000644000175000017500000000112510127274503021352 0ustar noodlesnoodles#include #include /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int copytoout(void *cfarg, char *str, int len) { int n; n = len; while (n--) { putc(*str, (FILE *)cfarg); str++; } return len; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int libport_vfprintf(FILE *fp, char *fmt, va_list args) { return format(copytoout, fp, -1, fmt, args); } smsclient-2.0.8z/src/common/sprintf/sprintf.c0000644000175000017500000000052710127274503021206 0ustar noodlesnoodles#include /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int libport_sprintf(char *buf, char *fmt, ...) { va_list args; int res; va_start(args, fmt); res = libport_vsprintf(buf, fmt, args); va_end(args); return res; } smsclient-2.0.8z/src/common/sprintf/fprintf.c0000644000175000017500000000055110127274503021166 0ustar noodlesnoodles#include #include /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int libport_fprintf(FILE *fp, char *fmt, ...) { va_list args; int res; va_start(args, fmt); res = libport_vfprintf(fp, fmt, args); va_end(args); return res; } smsclient-2.0.8z/src/common/sprintf/vsprintf.c0000644000175000017500000000043110127274503021366 0ustar noodlesnoodles#include /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int libport_vsprintf(char *buf, char *fmt, va_list args) { return libport_vsnprintf(buf, -1, fmt, args); } smsclient-2.0.8z/src/common/sprintf/format.h0000644000175000017500000000153610127274503021017 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #include #include int format(int (* copyfunc)(void *, char *, int), void *cfarg, int len, char *fmt, va_list args); int libport_vsnprintf(char *buf, int len, char *fmt, va_list args); int libport_snprintf(char *buf, int len, char *fmt, ...); int libport_vsprintf(char *buf, char *fmt, va_list args); int libport_sprintf(char *buf, char *fmt, ...); int libport_vfprintf(FILE *fp, char *fmt, va_list args); int libport_fprintf(FILE *fp, char *fmt, ...); int libport_vprintf(char *fmt, va_list args); int libport_printf(char *fmt, ...); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/common/sprintf/vprintf.c0000644000175000017500000000043410127274503021206 0ustar noodlesnoodles#include #include /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int libport_vprintf(char *fmt, va_list args) { return libport_vfprintf(stdout, fmt, args); } smsclient-2.0.8z/src/common/sprintf/printf.c0000644000175000017500000000054210127274503021020 0ustar noodlesnoodles#include #include /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int libport_printf(char *fmt, ...) { va_list args; int res; va_start(args, fmt); res = libport_vfprintf(stdout, fmt, args); va_end(args); return res; } smsclient-2.0.8z/src/common/sprintf/vsnprintf.c0000644000175000017500000000212510127274503021546 0ustar noodlesnoodles#include /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ struct charbuf_struct { char *buf, *ptr; int len; }; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int copytobuf(void *cfarg, char *str, int len) { struct charbuf_struct *cbuf; int n; cbuf = (struct charbuf_struct *)cfarg; n = 0; while (len--) { if (cbuf->len == -1) { *cbuf->ptr++ = *str++; n++; } else if (cbuf->len == 0) { *cbuf->ptr = '\0'; } else { cbuf->len--; *cbuf->ptr++ = *str++; n++; } } return n; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int libport_vsnprintf(char *buf, int len, char *fmt, va_list args) { struct charbuf_struct cbuf; cbuf.buf = buf; cbuf.ptr = buf; cbuf.len = len; return format(copytobuf, &cbuf, len, fmt, args); } smsclient-2.0.8z/src/common/sprintf/snprintf.c0000644000175000017500000000055010127274503021360 0ustar noodlesnoodles#include /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int libport_snprintf(char *buf, int len, char *fmt, ...) { va_list args; int res; va_start(args, fmt); res = libport_vsnprintf(buf, len, fmt, args); va_end(args); return res; } smsclient-2.0.8z/src/common/sprintf/test.c0000644000175000017500000000143110127274503020473 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #include "stdio.h" #include "format.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char **argv) { char buf[1024]; int res; printf("%3u\n", time(NULL)); res = libport_snprintf(buf, 30, "%s %c %3d this %d %3u is %% a test %s", "hey", 'c', 2, 218, time(NULL),"too"); libport_printf("string: +%s+\n", buf); libport_printf("len: %d\n", res); return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/common/sprintf/format.c0000644000175000017500000000572610127274503021017 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #include #include "format.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int format(int (* copyfunc)(void *, char *, int), void *cfarg, int len, char *fmt, va_list args) { int res, written, n, val; char *ptr, *optr, buf[64]; #define FALSE 0 #define TRUE (!FALSE) int width; char c; int signed_flag, long_flag; int int_val; unsigned int uint_val; long long_val; unsigned long ulong_val; written = 0; while (*fmt) { while ((*fmt) && (*fmt != '%')) { res = (*copyfunc)(cfarg, fmt, 1); if (res != 1) { goto finish; } written += res; fmt++; } signed_flag = TRUE; long_flag = FALSE; if (*fmt == '%') { fmt++; width = 0; while ((*fmt > '0') && (*fmt < '9')) { width *= 10; width += (*fmt - '0'); fmt++; } if (*fmt == 'l') { long_flag = TRUE; fmt++; } switch (*fmt) { case 'c': c = (char)(va_arg(args, int)); res = (*copyfunc)(cfarg, &c, 1); if (res != 1) { goto finish; } written += res; break; case 's': ptr = (char *)(va_arg(args, int)); optr = ptr; n = 0; while(*ptr++) { n++; } res = (*copyfunc)(cfarg, optr, n); if (res != n) { goto finish; } written += res; break; /* %d int */ /* %ld long int */ /* %u unsigned int */ /* %lu unsigned long int */ case 'u': signed_flag = FALSE; case 'd': optr = &buf[64]; if (long_flag) { if (signed_flag) { long_val = va_arg(args, long); do { *--optr = '0' + (long_val % 10); long_val = long_val / 10; } while (long_val); } else { ulong_val = (unsigned long)va_arg(args, long); do { *--optr = '0' + (ulong_val % 10); ulong_val = ulong_val / 10; } while (ulong_val); } } else { if (signed_flag) { int_val = va_arg(args, int); do { *--optr = '0' + (int_val % 10); int_val = int_val / 10; } while (int_val); } else { uint_val = (unsigned int)va_arg(args, int); do { *--optr = '0' + (uint_val % 10); uint_val = uint_val / 10; } while (uint_val); } } res = (*copyfunc)(cfarg, optr, (&buf[64] - optr)); if (res != (&buf[64] - optr)) { goto finish; } written += res; break; case '%': res = (*copyfunc)(cfarg, "%", 1); if (res != 1) { goto finish; } written += res; break; default: } fmt++; } } res = (*copyfunc)(cfarg, "", 1); if (res != 1) { goto finish; } finish: written += res; return written; } smsclient-2.0.8z/src/common/sprintf/Makefile0000644000175000017500000000161010127274503021007 0ustar noodlesnoodlesCC=gcc AR=ar all: test clean: $(RM) test $(RM) *.o $(RM) libport.a test: test.o libport.a $(CC) -o test test.o libport.a test.o: test.c $(CC) -o test.o -c test.c libport.a: format.o fprintf.o printf.o snprintf.o sprintf.o vfprintf.o vprintf.o vsnprintf.o vsprintf.o $(AR) -rc libport.a format.o fprintf.o printf.o snprintf.o sprintf.o vfprintf.o vprintf.o vsnprintf.o vsprintf.o format.o: format.c $(CC) -o format.o -c format.c fprintf.o: fprintf.c $(CC) -o fprintf.o -c fprintf.c printf.o: printf.c $(CC) -o printf.o -c printf.c snprintf.o: snprintf.c $(CC) -o snprintf.o -c snprintf.c sprintf.o: sprintf.c $(CC) -o sprintf.o -c sprintf.c vfprintf.o: vfprintf.c $(CC) -o vfprintf.o -c vfprintf.c vprintf.o: vprintf.c $(CC) -o vprintf.o -c vprintf.c vsnprintf.o: vsnprintf.c $(CC) -o vsnprintf.o -c vsnprintf.c vsprintf.o: vsprintf.c $(CC) -o vsprintf.o -c vsprintf.c smsclient-2.0.8z/src/common/Makefile0000644000175000017500000000316610127274502017331 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id: Makefile,v 5.1 1998/02/01 07:10:39 root Exp root $ # -------------------------------------------------------------------- include ../../Makefile.config # -------------------------------------------------------------------- all: common.o clean: $(RM) *.o # -------------------------------------------------------------------- common.o: common.c common.h $(CC) $(CFLAGS) -I.. -c common.c # -------------------------------------------------------------------- smsclient-2.0.8z/src/terminal/0000755000175000017500000000000011007610112016173 5ustar noodlesnoodlessmsclient-2.0.8z/src/terminal/logs/0000755000175000017500000000000010127274517017160 5ustar noodlesnoodlessmsclient-2.0.8z/src/terminal/terminal.c0000644000175000017500000000410210127274517020170 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* terminal.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include "terminal_io.h" #include "logfile_io.h" /* -------------------------------------------------------------------- */ #define LOGFILE "logfile" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char *argv[]) { int fdin, fdout; /* Usage: terminal */ fdin = open(argv[1], O_RDWR); if (fdin == -1) { fprintf(stderr, "Error: opening file '%s'\n", argv[1]); exit(-1); } fdout = fdin; init_logfile("logs/terminal.log"); setterm(); terminal_io(STDIN_FILENO, STDOUT_FILENO, fdin, fdout, -1); return 0; } smsclient-2.0.8z/src/terminal/terminal_io.h0000644000175000017500000000314610127274517020673 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* terminal_io.h */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ void resetterm(void); void setterm(void); void terminal_io(int client_fdin, int client_fdout, int server_fdin, int server_fdout, int terminal_fdout); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/terminal/client.c0000644000175000017500000000355010127274517017641 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* client.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include "terminal_io.h" #include "logfile_io.h" #include "client_lib.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char *argv[]) { int fdin, fdout; /* Usage: client */ fdin = client_connect(argv[1], atoi(argv[2])); fdout = fdin; init_logfile("logs/client.log"); setterm(); terminal_io(STDIN_FILENO, STDOUT_FILENO, fdin, fdout, -1); return 0; } smsclient-2.0.8z/src/terminal/client_lib.h0000644000175000017500000000277110127274517020500 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* client_lib.h */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ int client_connect(char *host, int port); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/terminal/server_lib.h0000644000175000017500000000305710127274517020526 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* server_lib.h */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ int server_init(int server_port); int server_accept(int sockfd); int server_connect(int port); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/terminal/snoop.c0000644000175000017500000000524510127274517017524 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* snoop.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include "terminal_io.h" #include "logfile_io.h" #include "server_lib.h" #include "client_lib.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char *argv[]) { int client_fdin, client_fdout, server_fdin, server_fdout, sockfd; /* Usage: snoop */ if (argc != 4) { fprintf(stderr, "Usage: snoop \n"); exit(-1); } sockfd = server_init(atoi(argv[1])); init_logfile("logs/snoop.log"); setterm(); while(1) { /* Loop for each client connection reconnect */ /* to the server */ client_fdin = server_accept(sockfd); client_fdout = client_fdin; server_fdin = client_connect(argv[2], atoi(argv[3])); server_fdout = server_fdin; #if !defined(INTEL_NT) terminal_io(client_fdin, client_fdout, server_fdin, server_fdout, STDOUT_FILENO); #else /* Select() only works on sockets so we can't use */ /* it to multiplex output to the terminal. */ terminal_io(client_fdin, client_fdout, server_fdin, server_fdout, -1); #endif #if !defined(INTEL_NT) close(client_fdin); close(server_fdin); #else closesocket(client_fdin); closesocket(server_fdin); #endif } return 0; } smsclient-2.0.8z/src/terminal/logfile_io.c0000644000175000017500000001041210460431075020460 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* logfile_io.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "logfile_io.h" #include "common/common.h" /* -------------------------------------------------------------------- */ #define INIT_SEND 0 #define CLIENT_SEND 1 #define SERVER_SEND 2 static int flog = -1; static int sender_state = INIT_SEND; static int new_paragraph = 0; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void init_logfile(char *logfile) { flog = open(logfile, O_WRONLY|O_TRUNC|O_CREAT, S_IRWXU|S_IRGRP|S_IROTH); if (flog == -1) { fprintf(stderr, "Error: opening file '%s'\n", logfile); exit(-1); } new_paragraph = 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void log_client_send(void) { if (flog != -1) { if (sender_state != CLIENT_SEND) { /* Just switched */ if ((sender_state != INIT_SEND) && (!new_paragraph)) { write(flog, "\"\n", strlen("\"\n")); } write(flog, "Client --> \"", strlen("Client --> \"")); new_paragraph = 0; } sender_state = CLIENT_SEND; } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void log_server_send(void) { if (flog != -1) { if (sender_state != SERVER_SEND) { /* Just switched */ if ((sender_state != INIT_SEND) && (!new_paragraph)) { write(flog, "\"\n", strlen("\"\n")); } write(flog, "Server --> \"", strlen("Server --> \"")); new_paragraph = 0; } sender_state = SERVER_SEND; } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void log_character(char c) { static char buf[16]; if (flog != -1) { if (new_paragraph) { write(flog, " \"", strlen(" \"")); new_paragraph = 0; } if (c == '\n') { write(flog, "\\n\"\n", strlen("\\n\"\n")); /* Ouput data to logfile */ new_paragraph = 1; } else if (c == '\r') { write(flog, "\\r", strlen("\\r")); /* Ouput data to logfile */ } else if ((int)c < 32) { sms_snprintf(buf, 16, "\\0%02X", (int)c); write(flog, buf, strlen(buf)); /* Ouput data to logfile */ } else { write(flog, &c, 1); /* Ouput data to logfile */ } } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void close_logfile(void) { if (flog != -1) { close(flog); } } smsclient-2.0.8z/src/terminal/mdup.c0000644000175000017500000000321510127274517017326 0ustar noodlesnoodles#include #include #include #include #include #include #include #include "terminal_io.h" #include "logfile_io.h" #include "logfile/logfile.h" #include "common/common.h" #include "comms/comms.h" #include "error.h" #define LOGFILE "logfile" int main(int argc, char **argv) { char *number, *comms_params; long baud; int fdin, fdout; #if 0 static struct termios t; #endif /* ---------------------------- */ set_logfile("./logfile"); set_loglevel(3); set_consolelog(TRUE); /* ---------------------------- */ if (argc != 4) { lprintf(LOG_ERROR, "Usage: mdup \n"); exit(1); } number = argv[1]; comms_params = argv[2]; baud = atoi(argv[3]); /* ---------------------------- */ lprintf(LOG_STANDARD, "Dialing SMSC %s...\n", number); fdin = SMS_dial(number, comms_params, baud); if (fdin < 0) { lprintf(LOG_WARNING, "Failed to connect\n"); return EDIAL; } lprintf(LOG_STANDARD, "Connection Established.\n"); fdout = fdin; init_logfile("logs/terminal.log"); setterm(); #if 0 if (tcgetattr(fdin, &t) == -1) { lprintf(LOG_WARNING, "MODEM: Failed tcgetattr()\n"); exit(1); } t.c_cc[VMIN] = (unsigned short)256; /* 4096 Character buffer */ t.c_cc[VTIME] = 0; /* Block indefinitely */ if (tcsetattr(fdin, TCSANOW, &t) == -1) { lprintf(LOG_WARNING, "MODEM: Failed tcsetattr()\n"); exit(1); } #endif terminal_io(STDIN_FILENO, STDOUT_FILENO, fdin, fdout, -1); SMS_hangup(fdin); return 0; } smsclient-2.0.8z/src/terminal/server_lib.c0000644000175000017500000000732310460431143020507 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* server_lib.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* -------------------------------------------------------------------- */ #define MAX_BACKLOG 5 /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int server_init(int server_port) { int sockfd; /* listen on sock_fd */ struct sockaddr_in server_addr; /* my address information */ if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { fprintf(stderr, "socket\n"); exit(1); } server_addr.sin_family = AF_INET; /* host byte order */ server_addr.sin_port = htons(server_port); /* short, network byte order */ server_addr.sin_addr.s_addr = INADDR_ANY; /* auto-fill with my IP */ memset(&(server_addr.sin_zero), 0, 8); /* zero rest of struct */ if (bind(sockfd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) < 0) { switch (errno) { case EADDRINUSE: fprintf(stderr, "bind - Socket %d allready in use\n", server_port); break; case EACCES: fprintf(stderr, "bind - Socket %d protected port and not superuser\n", server_port); break; default: fprintf(stderr, "bind\n"); } exit(1); } if (listen(sockfd, MAX_BACKLOG) < 0) { fprintf(stderr, "listen\n"); exit(1); } fprintf(stderr, "Listening on port %d\n", server_port); return sockfd; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int server_accept(int sockfd) { size_t sin_size; int new_sockfd; struct sockaddr_in client_addr; sin_size = sizeof(struct sockaddr_in); new_sockfd = accept(sockfd, (struct sockaddr *)&client_addr, &sin_size); fprintf(stderr, "Accepted connection.\n"); return new_sockfd; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int server_connect(int port) { int sockfd, new_sockfd; sockfd = server_init(port); new_sockfd = server_accept(sockfd); return new_sockfd; } smsclient-2.0.8z/src/terminal/logfile0000644000175000017500000000202010127274517017552 0ustar noodlesnoodlesJul 26 00:21:15 [336] : Dialing SMSC 0973100602... Jul 26 00:21:41 [336] : Connection Established. Jul 26 00:22:02 [336] WARNING: MODEM: Failed tcgetattr() Jul 26 00:22:02 [336] WARNING: MODEM: Failed tcsetattr() - Trying to return modem device to original settting Aug 01 14:37:58 [946] : Dialing SMSC (null)... Aug 01 14:39:35 [964] ERROR: Usage: mdup Aug 01 14:40:07 [965] : Dialing SMSC 0345581354... Aug 01 14:40:35 [965] : Connection Established. Aug 01 14:41:13 [965] WARNING: MODEM: Failed tcgetattr() Aug 01 14:41:13 [965] WARNING: MODEM: Failed tcsetattr() - Trying to return modem device to original settting Sep 26 20:22:01 [948] ERROR: Usage: mdup Sep 26 20:22:22 [949] : Dialing SMSC 07666699699... Sep 26 20:22:24 [949] ERROR: MODEM: Parity must be either E,O or N Sep 26 20:22:24 [949] ERROR: MODEM: MDM_init() Failed Sep 26 20:22:44 [950] : Dialing SMSC 07666699699... Sep 26 20:23:17 [951] : Dialing SMSC 07666699699... Sep 26 20:26:10 [952] : Dialing SMSC 09019050905... smsclient-2.0.8z/src/terminal/client_lib.c0000644000175000017500000000470110127274517020466 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* client_lib.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include #include #include "client_lib.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int client_connect(char *host, int port) { int sockfd; struct hostent *he; struct sockaddr_in their_addr; /* connector's address information */ if ((he=gethostbyname(host)) == NULL) { perror("Client gethostbyname"); exit(1); /* get the host info */ } if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror("Client socket"); exit(1); } their_addr.sin_family = AF_INET; /* host byte order */ their_addr.sin_port = htons(port); /* short, network byte order */ their_addr.sin_addr = *((struct in_addr *)he->h_addr); bzero(&(their_addr.sin_zero[0]), 8); /* zero the rest of the struct */ if (connect(sockfd, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1) { perror("Client connect"); exit(1); } return sockfd; } smsclient-2.0.8z/src/terminal/server.c0000644000175000017500000000353010127274517017667 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* server.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include "terminal_io.h" #include "logfile_io.h" #include "server_lib.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char *argv[]) { int fdin, fdout; /* Usage: server */ fdin = server_connect(atoi(argv[1])); fdout = fdin; init_logfile("logs/server.log"); setterm(); terminal_io(STDIN_FILENO, STDOUT_FILENO, fdin, fdout, -1); return 0; } smsclient-2.0.8z/src/terminal/logfile_io.h0000644000175000017500000000313710127274517020501 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* logfile_io.h */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ void init_logfile(char *logfile); void log_client_send(void); void log_server_send(void); void log_character(char c); void close_logfile(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/terminal/terminal_io.c0000644000175000017500000002433210127274517020666 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* terminal_io.c */ /* */ /* Copyright (C) 1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "terminal_io.h" #include "logfile_io.h" /* -------------------------------------------------------------------- */ #define FD_MAX(a,b) (((a)>(b))?(a):(b)) #define FD_MIN(a,b) (((a)<(b))?(a):(b)) struct termios current_term, original_term; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void resetterm(void) { /* Restore our old terminal settings */ tcsetattr(STDIN_FILENO, TCSANOW, &original_term); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void setterm(void) { if (isatty(STDIN_FILENO)) { /* If we're using a terminal for input */ /* we want it to be unbuffered. */ tcgetattr(STDIN_FILENO, ¤t_term); tcgetattr(STDIN_FILENO, &original_term); #if 0 current_term.c_lflag &= ~(ICANON | ECHO); #else current_term.c_lflag &= ~(ICANON); #endif current_term.c_cc[VMIN] = 1; current_term.c_cc[VTIME] = 0; tcsetattr(STDIN_FILENO, TCSANOW, ¤t_term); atexit(resetterm); } } /* -------------------------------------------------------------------- */ /* */ /* Terminal Terminal_io() Socket /dev/pts/? */ /* Client Server */ /* ----- 1. --------------- 3. ----- */ /* | |<---------------| <------+<-- |<------------| | */ /* | | | | | | | */ /* | | 2. | | | 4. | | */ /* | |--------------->| -->+---)--> |------------>| | */ /* ----- -----|---|----- ----- */ /* 6. | | */ /* Terminal <---------------+ | */ /* Client | | */ /* V V */ /* ----- */ /* | */ /* | */ /* V 5. */ /* -------------- */ /* | | Logfile */ /* -------------- */ /* */ /* 1. Client_fdout */ /* 2. Client_fdin */ /* 3. Server_fdout */ /* 4. Server_fdin */ /* 5. Flog */ /* 5. Terminal_fdout */ /* */ /* -------------------------------------------------------------------- */ void terminal_io(int client_fdin, int client_fdout, int server_fdin, int server_fdout, int terminal_fdout) { int select_res, read_res, write_res, client_fdout_data, server_fdout_data, terminal_fdout_data, read_data; int nfds; fd_set readfds, writefds; char c; /* ------------------------------------------------------------ */ if (terminal_fdout == client_fdout) { /* The terminal is set to echo data, if we */ /* allow data to be sent to the terminal also */ /* we'll end up with data being echoed twice */ terminal_fdout = -1; } /* ------------------------------------------------------------ */ FD_ZERO(&readfds); FD_ZERO(&writefds); nfds = FD_MAX(terminal_fdout, FD_MAX(FD_MAX(client_fdin, client_fdout), FD_MAX(server_fdin, server_fdout))) +1; client_fdout_data = 0; server_fdout_data = 0; terminal_fdout_data = 0; read_data = 1; do { /* -------------------------------------------- */ /* Set up FS_SET's we're interested in */ /* reading data from and writing data to. */ FD_SET(client_fdin, &readfds); FD_SET(server_fdin, &readfds); if (client_fdout_data) { /* We have data we want to output */ FD_SET(client_fdout, &writefds); } else { /* No data to output */ FD_CLR(client_fdout, &writefds); } if (terminal_fdout != -1) { if (terminal_fdout_data) { /* We have data we want to output */ FD_SET(terminal_fdout, &writefds); } else { /* No data to output */ FD_CLR(terminal_fdout, &writefds); } } if (server_fdout_data) { /* We have data we want to output */ FD_SET(server_fdout, &writefds); } else { /* No data to output */ FD_CLR(server_fdout, &writefds); } /* ---------------------------------------- */ do { select_res = select(nfds, &readfds, &writefds, NULL, NULL); } while ((select_res == -1) && (errno == EINTR)); if (select_res == -1) { exit(-1); } else if (select_res > 0) { if ((FD_ISSET(client_fdin, &readfds)) || (FD_ISSET(client_fdout, &writefds)) || ((terminal_fdout != -1) && (FD_ISSET(terminal_fdout, &writefds)))|| (FD_ISSET(server_fdin, &readfds)) || (FD_ISSET(server_fdout, &writefds))) { /* We've been alerted of some data */ /* being present on the lines we're */ /* interested in. */ if (FD_ISSET(client_fdin, &readfds)) { /* Something for us to READ from 'client_fdin' */ if ((client_fdout_data == 0) && (terminal_fdout_data == 0) && (server_fdout_data == 0)) { /* There aren't any characters left unsent */ /* Read a character */ do { read_res = read(client_fdin, &c, 1); } while ((read_res == -1) && (errno == EINTR)); if (read_res == -1) { exit(-1); } else if (read_res == 0) { /* EOF at our end - client */ #if 0 /* look at this */ fprintf(stderr, "Client sent EOF.\n"); read_data = 0; #endif } else { /* Character read */ #if 0 if ((int)c == '\004') /* CTR-D for EOF */ { fprintf(stderr, "Client sent EOF.\n"); read_data = 0; } #endif } /* Send data to 'client_fdout' and 'server_fdout' */ log_client_send(); log_character(c); if (terminal_fdout != -1) { terminal_fdout_data = 1; } server_fdout_data = 1; } } if (FD_ISSET(client_fdout, &writefds)) { /* Something for us to WRITE to 'client_fdout' */ assert(client_fdout_data); do { write_res = write(client_fdout, &c, 1); } while ((write_res == -1) && (errno == EINTR)); if (write_res == -1) { exit(-1); } else if (write_res == 0) { exit(-1); } else { /* Character written */ } client_fdout_data = 0; } if ((terminal_fdout != -1) && (FD_ISSET(terminal_fdout, &writefds))) { /* Something for us to WRITE to 'terminal_fdout' */ assert(terminal_fdout_data); do { write_res = write(terminal_fdout, &c, 1); } while ((write_res == -1) && (errno == EINTR)); if (write_res == -1) { exit(-1); } else if (write_res == 0) { exit(-1); } else { /* Character written */ } terminal_fdout_data = 0; } if (FD_ISSET(server_fdin, &readfds)) { /* Something for us to READ from 'server_fdin' */ if ((client_fdout_data == 0) && (terminal_fdout_data == 0) && (server_fdout_data == 0)) { /* There aren't any characters left unsent */ /* Read a character */ do { read_res = read(server_fdin, &c, 1); } while ((read_res == -1) && (errno == EINTR)); if (read_res == -1) { exit(-1); } else if (read_res == 0) { /* EOF at their end - server */ fprintf(stderr, "Server sent EOF.\n"); read_data = 0; } else { /* Character read */ } /* Send data to 'client_fdout' */ log_server_send(); log_character(c); if (terminal_fdout != -1) { terminal_fdout_data = 1; } client_fdout_data = 1; } } if (FD_ISSET(server_fdout, &writefds)) { /* Something for us to WRITE to 'server_fdout' */ assert(server_fdout_data); do { write_res = write(server_fdout, &c, 1); } while ((write_res == -1) && (errno == EINTR)); if (write_res == -1) { exit(-1); } else if (write_res == 0) { exit(-1); } else { /* Character written */ } server_fdout_data = 0; } } else { /* Something woke us and it wasn't */ /* 'client_fdin', 'client_fdout', */ /* 'server_fdin' or 'server_fdout' */ exit(-1); } } else { /* Timeout expired - we didn't set a timeout */ exit(-1); } } while (read_data); fprintf(stderr, "Connection terminated.\n"); } smsclient-2.0.8z/src/terminal/Makefile0000644000175000017500000000773010127274517017663 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- include ../../Makefile.config # -------------------------------------------------------------------- XINC = -I../ # -------------------------------------------------------------------- all: terminal client server snoop mdup clean: rm -f *.o rm -f terminal client server snoop mdup # -------------------------------------------------------------------- comms: cd ../comms ; $(MAKE) comms.a lock: cd ../lock ; $(MAKE) lock.a resource: cd ../resource ; $(MAKE) resource.a parser_lib: cd ../parser ; $(MAKE) # -------------------------------------------------------------------- terminal: terminal.o terminal_io.o logfile_io.o ../common/common.o $(CC) $(CFLAGS) terminal.o terminal_io.o logfile_io.o -o terminal ../common/common.o client: client.o client_lib.o terminal_io.o logfile_io.o ../common/common.o $(CC) $(CFLAGS) client.o client_lib.o terminal_io.o logfile_io.o -o client $(XTRALIBS) ../common/common.o server: server.o server_lib.o terminal_io.o logfile_io.o ../common/common.o $(CC) $(CFLAGS) server.o server_lib.o terminal_io.o logfile_io.o -o server $(XTRALIBS) ../common/common.o snoop: snoop.o server_lib.o client_lib.o terminal_io.o logfile_io.o ../common/common.o $(CC) $(CFLAGS) snoop.o server_lib.o client_lib.o terminal_io.o logfile_io.o -o snoop $(XTRALIBS) ../common/common.o # -------------------------------------------------------------------- mdup: mdup.o comms resource parser_lib lock ../common/common.o ../logfile/logfile.o terminal_io.o logfile_io.o $(CC) $(CFLAGS) mdup.o -o mdup ../comms/comms.a ../common/common.o ../logfile/logfile.o ../lock/lock.a ../resource/resource.a ../parser/gs_parser.a terminal_io.o logfile_io.o # -------------------------------------------------------------------- terminal.o: terminal.c terminal_io.h logfile_io.h $(CC) $(CFLAGS) $(XINC) -c terminal.c client.o: client.c terminal_io.h logfile_io.h client_lib.h $(CC) $(CFLAGS) $(XINC) -c client.c server.o: server.c terminal_io.h logfile_io.h server_lib.h $(CC) $(CFLAGS) $(XINC) -c server.c snoop.o: snoop.c terminal_io.h logfile_io.h server_lib.h client_lib.h $(CC) $(CFLAGS) $(XINC) -c snoop.c client_lib.o: client_lib.c client_lib.h $(CC) $(CFLAGS) $(XINC) -c client_lib.c server_lib.o: server_lib.c server_lib.h $(CC) $(CFLAGS) $(XINC) -c server_lib.c terminal_io.o: terminal_io.c terminal_io.h logfile_io.h $(CC) $(CFLAGS) $(XINC) -c terminal_io.c logfile_io.o: logfile_io.c logfile_io.h $(CC) $(CFLAGS) $(XINC) -c logfile_io.c mdup.o: mdup.c $(CC) $(CFLAGS) $(XINC) -c mdup.c # -------------------------------------------------------------------- ../logfile/logfile.o: ../logfile/logfile.c ../logfile/logfile.h cd ../logfile ; $(MAKE) logfile.o ../common/common.o: ../common/common.c ../common/common.h cd ../common ; $(MAKE) common.o smsclient-2.0.8z/src/driver/0000755000175000017500000000000011007610111015652 5ustar noodlesnoodlessmsclient-2.0.8z/src/driver/tim.c0000644000175000017500000002400610127274506016631 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* tim.c */ /* */ /* Copyright (C) 1997,1998,1999,2000 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* the author of this module */ /* massimo@nuvoli.to.it */ /* adapted by */ /* adrieder@sbox.tu-graz.ac.at */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ /* Modified by Shevek 2000-03-03 * * TIM change their protocol * * The system is essentially a dialup into a DUNIX box running Lynx, * * this driver must manipulate the lynx browser. */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static char ACK1[] = "ScripTIM"; /* S: This word is OK */ static char ACK2[] = "le frecce del terminale"; /* S: Bottom of form */ static char ACK3[] = "Non attivo"; /* S: Top of form */ static char ACK6[] = "Terminali abilitati"; /* S: Bottom of first */ static char ACK7[] = " per scollegarsi"; static char ACK8[] = "centri TIM"; static char ACKB[] = "MESSAGGIO INVIATO"; /* S: Delivery OK */ static char ACKC[] = "closed by foreign"; /* S: Hangup */ static char ARR_UP[] = "\033[A"; /* Up arrow for VT */ static char ARR_DN[] = "\033[B"; /* Down arrow for VT */ static char ARR_LT[] = "\033[D"; /* Left arrow for VT */ /* -------------------------------------------------------------------- */ static struct tim_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 20, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.max_deliver) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int TIM_login(void); static int TIM_sendmessage(char *msisdn, char *message); static int TIM_send_disconnect(void); static void TIM_hangup(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int TIM_login(void) { char buf[MAX_RESPONSE_BUFSIZE]; /* S: Recognise the top of the first web page */ if (expstr(FD, buf, ACK1, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Tim Service Login\n"); } else { lprintf(LOG_STANDARD, "No Tim Service Login\n"); TIM_hangup(); return ETIM_NORESPONSE; } /* Recognise the lower half of the first web page (terminal) */ if (expstr(FD, buf, ACK6, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Tim Service Login\n"); } else { lprintf(LOG_STANDARD, "No Tim Service Response\n"); TIM_hangup(); return ETIM_NORESPONSE; } /* S: on link to next page. */ twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); /* S */ /* S: Recognise the prompt on the bottom of the second page */ if (expstr(FD, buf, ACK7, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Tim Service Terminal\n"); } else { lprintf(LOG_STANDARD, "No Tim Service Response\n"); TIM_hangup(); return ETIM_NORESPONSE; } /* S: on link to next page. */ twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); /* S: Recognise the third web page with the phone number */ if (expstr(FD, buf, ACK8, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Tim Service Menu\n"); } else { lprintf(LOG_STANDARD, "No Tim Service Menu\n"); TIM_hangup(); return ETIM_NORESPONSE; } /* S: Accept the third web page */ twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); /* S: We should now be looking at a form we must fill in. */ if (expstr(FD, buf, ACK3, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Tim Service Terminal\n"); } else { lprintf(LOG_STANDARD, "No Tim Data Form (0)\n"); TIM_hangup(); return ETIM_NORESPONSE; } if (expstr(FD, buf, ACK2, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Tim Menu Request\n"); } else { lprintf(LOG_STANDARD, "No Tim Data Form (1)\n"); TIM_hangup(); return ETIM_NORESPONSE; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int TIM_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE]; /* S: Enter number into first form box */ twrite(FD, msisdn, strlen(msisdn), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); /* S: Skip four 'delay' fields, leaving them zero */ twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); /* S: Enter message into text box */ twrite(FD, message, strlen(message), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); /* S: Press 'Invio' button */ twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); if (expstr(FD, buf, ACKB, MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Delivery Response\n"); } else { lprintf(LOG_STANDARD, "No Message Delivery Response\n"); TIM_hangup(); return ETIM_NODELIVERY; } /* S: To get back, we should go 'left down down' */ twrite(FD, ARR_LT, strlen(ARR_LT), WRITETIMEOUT); if (expstr(FD, buf, ACK2, MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Delivery Response\n"); } else { lprintf(LOG_STANDARD, "No Tim Data Form (2)\n"); TIM_hangup(); return ETIM_NODELIVERY; } /* S: Get to the right button on the form (cycle) */ twrite(FD, ARR_DN, strlen(ARR_DN), WRITETIMEOUT); twrite(FD, ARR_DN, strlen(ARR_DN), WRITETIMEOUT); /* S: XXX There isn't much we can do here to check that we * are in the right place. Sending multiple messages with * TIM is therefore not guaranteed. */ return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int TIM_send_disconnect(void) { char buf[MAX_RESPONSE_BUFSIZE]; /* S: Get onto a button rather than a field. */ twrite(FD, ARR_UP, strlen(ARR_DN), WRITETIMEOUT); /* S: Quit lynx - 'Q' is quick quit. */ twrite(FD, "Q", strlen("Q"), WRITETIMEOUT); if (expstr(FD, buf, ACKC, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Disconnection Response\n"); } else { lprintf(LOG_STANDARD, "No Disconnection Response\n"); TIM_hangup(); return ETIM_NODISCONNECT; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void TIM_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY tim_device = { "TIM", "1.2", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, default_dial, default_hangup, TIM_send_disconnect, default_multiple_counted_deliver, TIM_sendmessage, TIM_login }; smsclient-2.0.8z/src/driver/libertel.c0000644000175000017500000001501310127274506017640 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* libertel.c */ /* */ /* Copyright (C) 1998,1999 Aart Koelewijn */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* jhwevers@telekabel.nl */ /* aart@mtack.xs4all.nl */ /* */ /* -------------------------------------------------------------------- */ /* $Id: libertel.c,v 0.1 1998/04/02 22:49:15 aart -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static char ACK1[] = "Welkom bij LIBERTEL Text-PC\r\n" "Als u vragen heeft over deze dienst kunt u bellen naar 0800-0560\r\n"; static char ACK2[] = "Typ het mobiele telefoonnummer in volgens het internationale formaat, \r\n" "bijvoorbeeld 31654XXXXXX, gevolgd door enter (of druk op enter om te stoppen)\r\n" ">"; static char ACK3[] = "Typ uw bericht in, (maximaal 160 tekens), gevolgd door enter\r\n" ">"; static char ACK4[] = "Bericht geaccepteerd\r\n"; /* -------------------------------------------------------------------- */ static struct libertel_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 1200, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.max_deliver) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static void LIBERTEL_hangup(void); static int LIBERTEL_sendmessage(char *msisdn, char *message); static int LIBERTEL_login(void); static int LIBERTEL_send_disconnect(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void LIBERTEL_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int LIBERTEL_login(void) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, ACK1, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Libertel Service Login\n"); } else { lprintf(LOG_STANDARD, "No Libertel Service Response\n"); LIBERTEL_hangup(); return ELIBERTEL_NORESPONSE; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int LIBERTEL_send_disconnect(void) { twrite(FD, "\r\n", strlen("\r\n"), TIMEOUT); return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int LIBERTEL_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, ACK2, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Number Request\n"); } else { lprintf(LOG_STANDARD, "No Number Request\n"); LIBERTEL_hangup(); return ELIBERTEL_NONUMBER; } twrite(FD, msisdn, strlen(msisdn), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); if (expstr(FD, buf, ACK3, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Request\n"); } else { lprintf(LOG_STANDARD, "No Message Request\n"); LIBERTEL_hangup(); return ELIBERTEL_NOMESSAGE; } twrite(FD, message, strlen(message), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); if (expstr(FD, buf, ACK4, MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Delivery Response\n"); } else { lprintf(LOG_STANDARD, "No Message Delivery Response\n"); LIBERTEL_hangup(); return ELIBERTEL_NODELIVERY; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY libertel_device = { "LIBERTEL", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, default_dial, default_hangup, LIBERTEL_send_disconnect, default_multiple_counted_deliver, LIBERTEL_sendmessage, LIBERTEL_login }; smsclient-2.0.8z/src/driver/snpp.c0000644000175000017500000001642510127274506017026 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* snpp.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static struct snpp_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_STRING, "SMS_server_name", 0, 1, NULL, 0, "localhost", 0, &(driver_env.def.server_name) }, { RESOURCE_NUMERIC, "SMS_server_port", 0, 1, NULL, 0, NULL, 444, &(driver_env.def.server_port) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int SNPP_login(void); static int SNPP_sendmessage(char *msisdn, char *message); static int SNPP_send_disconnect(void); static void SNPP_hangup(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int SNPP_login(void) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, "\n", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { if (strncmp(buf, "220", 3) == 0) { lprintf(LOG_STANDARD, "SNPP Service Login\n"); lprintf(LOG_VERBOSE, "SNPP Response: %s", buf); } else { lprintf(LOG_STANDARD, "SNPP Service Login Failed - Bad response\n"); SNPP_hangup(); return ESNPP_NORESPONSE; } } else { lprintf(LOG_STANDARD, "SNPP Service Login Failed\n"); SNPP_hangup(); return ESNPP_NORESPONSE; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int SNPP_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE]; twrite(FD, "PAGE ", strlen("PAGE "), WRITETIMEOUT); twrite(FD, msisdn, strlen(msisdn), WRITETIMEOUT); twrite(FD, "\n", strlen("\n"), WRITETIMEOUT); if (expstr(FD, buf, "\n", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { if (strncmp(buf, "250", 3) == 0) { lprintf(LOG_STANDARD, "Pager ID Accepted\n"); lprintf(LOG_VERBOSE, "SNPP Response: %s", buf); } else { lprintf(LOG_STANDARD, "Pager ID NOT Accepted\n"); SNPP_hangup(); return ESNPP_NONUMBER; } } else { lprintf(LOG_STANDARD, "Pager ID NOT Accepted\n"); SNPP_hangup(); return ESNPP_NONUMBER; } twrite(FD, "MESS ", strlen("MESS "), WRITETIMEOUT); twrite(FD, message, strlen(message), WRITETIMEOUT); twrite(FD, "\n", strlen("\n"), WRITETIMEOUT); if (expstr(FD, buf, "\n", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { if (strncmp(buf, "250", 3) == 0) { lprintf(LOG_STANDARD, "Message Accepted\n"); lprintf(LOG_VERBOSE, "SNPP Response: %s", buf); } else { lprintf(LOG_STANDARD, "Message NOT Accepted\n"); SNPP_hangup(); return ESNPP_NOMESSAGE; } } else { lprintf(LOG_STANDARD, "Message NOT Accepted\n"); SNPP_hangup(); return ESNPP_NOMESSAGE; } twrite(FD, "SEND\n", strlen("SEND\n"), WRITETIMEOUT); if (expstr(FD, buf, "\n", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { if (strncmp(buf, "250", 3) == 0) { lprintf(LOG_STANDARD, "Message Sent\n"); lprintf(LOG_VERBOSE, "SNPP Response: %s", buf); } else { lprintf(LOG_STANDARD, "Message NOT Sent\n"); SNPP_hangup(); return ESNPP_NODELIVERY; } } else { lprintf(LOG_STANDARD, "Message NOT Sent\n"); SNPP_hangup(); return ESNPP_NODELIVERY; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int SNPP_send_disconnect(void) { char buf[MAX_RESPONSE_BUFSIZE]; twrite(FD, "QUIT\n", strlen("QUIT\n"), WRITETIMEOUT); if (expstr(FD, buf, "\n", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { if (strncmp(buf, "221", 3) == 0) { lprintf(LOG_STANDARD, "Sent Diconnection\n"); lprintf(LOG_VERBOSE, "SNPP Response: %s", buf); } else { lprintf(LOG_STANDARD, "Failed to send Disconnection\n"); SNPP_hangup(); return ESNPP_NODISCONNECT; } } else { lprintf(LOG_STANDARD, "Failed to send Disconnection\n"); SNPP_hangup(); return ESNPP_NODISCONNECT; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void SNPP_hangup(void) { TCPIP_disconnect(FD); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY snpp_device = { "SNPP", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_always_true, default_tcpip_connect, default_tcpip_disconnect, SNPP_send_disconnect, default_single_deliver, SNPP_sendmessage, SNPP_login }; smsclient-2.0.8z/src/driver/ia5table.c0000644000175000017500000001551510127274506017533 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* ia5table.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include "ia5table.h" #include /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int ia5table[] = { /* [00] */ 0x20, /* [01] */ 0x20, /* [02] */ 0x20, /* [03] */ 0x20, /* [04] */ 0x20, /* [05] */ 0x20, /* [06] */ 0x20, /* [07] */ 0x20, /* [08] */ 0x20, /* [09] */ 0x20, /* [0A] # */ 0x0A, /* [0B] */ 0x20, /* [0C] */ 0x20, /* [0D] # */ 0x0D, /* [0E] */ 0x20, /* [0F] */ 0x20, /* [10] */ 0x20, /* [11] */ 0x20, /* [12] */ 0x20, /* [13] */ 0x20, /* [14] */ 0x20, /* [15] */ 0x20, /* [16] */ 0x20, /* [17] */ 0x20, /* [18] */ 0x20, /* [19] */ 0x20, /* [1A] */ 0x20, /* [1B] # */ 0x1B, /* [1C] */ 0x20, /* [1D] */ 0x20, /* [1E] */ 0x20, /* [1F] */ 0x20, /* [20] */ 0x20, /* [21] ! */ 0x21, /* [22] " */ 0x22, /* [23] # */ 0x23, /* [24] $ */ 0x24, /* [25] % */ 0x25, /* [26] & */ 0x26, /* [27] ' */ 0x27, /* [28] ( */ 0x28, /* [29] ) */ 0x29, /* [2A] * */ 0x2A, /* [2B] + */ 0x2B, /* [2C] , */ 0x2C, /* [2D] - */ 0x2D, /* [2E] . */ 0x2E, /* [2F] / */ 0x2F, /* [30] 0 */ 0x30, /* [31] 1 */ 0x31, /* [32] 2 */ 0x32, /* [33] 3 */ 0x33, /* [34] 4 */ 0x34, /* [35] 5 */ 0x35, /* [36] 6 */ 0x36, /* [37] 7 */ 0x37, /* [38] 8 */ 0x38, /* [39] 9 */ 0x39, /* [3A] : */ 0x3A, /* [3B] ; */ 0x3B, /* [3C] < */ 0x3C, /* [3D] = */ 0x3D, /* [3E] > */ 0x3E, /* [3F] ? */ 0x3F, /* [40] @ */ 0x40, /* [41] A */ 0x41, /* [42] B */ 0x42, /* [43] C */ 0x43, /* [44] D */ 0x44, /* [45] E */ 0x45, /* [46] F */ 0x46, /* [47] G */ 0x47, /* [48] H */ 0x48, /* [49] I */ 0x49, /* [4A] J */ 0x4A, /* [4B] K */ 0x4B, /* [4C] L */ 0x4C, /* [4D] M */ 0x4D, /* [4E] N */ 0x4E, /* [4F] O */ 0x4F, /* [50] P */ 0x50, /* [51] Q */ 0x51, /* [52] R */ 0x52, /* [53] S */ 0x53, /* [54] T */ 0x54, /* [55] U */ 0x55, /* [56] V */ 0x56, /* [57] W */ 0x57, /* [58] X */ 0x58, /* [59] Y */ 0x59, /* [5A] Z */ 0x5A, /* [5B] Ä */ 0x5B, /* [5C] Ö */ 0x5C, /* [5D] Ü */ 0x5D, /* [5E] § */ 0x5E, /* [5F] # */ 0x11, /* [60] */ 0x20, /* [61] a */ 0x61, /* [62] b */ 0x62, /* [63] c */ 0x63, /* [64] d */ 0x64, /* [65] e */ 0x65, /* [66] f */ 0x66, /* [67] g */ 0x67, /* [68] h */ 0x68, /* [69] i */ 0x69, /* [6A] j */ 0x6A, /* [6B] k */ 0x6B, /* [6C] l */ 0x6C, /* [6D] m */ 0x6D, /* [6E] n */ 0x6E, /* [6F] o */ 0x6F, /* [70] p */ 0x70, /* [71] q */ 0x71, /* [72] r */ 0x72, /* [73] s */ 0x73, /* [74] t */ 0x74, /* [75] u */ 0x75, /* [76] v */ 0x76, /* [77] w */ 0x77, /* [78] x */ 0x78, /* [79] y */ 0x79, /* [7A] z */ 0x7A, /* [7B] ä */ 0x7B, /* [7C] ö */ 0x7C, /* [7D] ü */ 0x7D, /* [7E] ß */ 0x7E, /* [7F] */ 0x20, /* [80] # */ 0x09, /* [81] # */ 0x10, /* [82] # */ 0x05, /* [83] */ 0x20, /* [84] # */ 0x7B, /* [85] # */ 0x7F, /* [86] # */ 0x0F, /* [87] */ 0x20, /* [88] */ 0x20, /* [89] */ 0x20, /* [8A] # */ 0x04, /* [8B] */ 0x20, /* [8C] */ 0x20, /* [8D] # */ 0x07, /* [8E] # */ 0x5B, /* [8F] # */ 0x0E, /* [90] # */ 0x1F, /* [91] # */ 0x1D, /* [92] # */ 0x1C, /* [93] */ 0x20, /* [94] # */ 0x7C, /* [95] # */ 0x08, /* [96] */ 0x20, /* [97] # */ 0x06, /* [98] */ 0x20, /* [99] # */ 0x5C, /* [9A] # */ 0x5E, /* [9B] */ 0x20, /* [9C] # */ 0x01, /* [9D] # */ 0x03, /* [9E] */ 0x20, /* [9F] */ 0x20, /* [A0] */ 0x20, /* [A1] ¡ */ 0x00, /* [A2] */ 0x20, /* [A3] £ */ 0x01, /* [A4] # */ 0x02, /* [A5] ¥ */ 0x03, /* [A6] */ 0x20, /* [A7] § */ 0x5E, /* [A8] # */ 0x60, /* [A9] */ 0x20, /* [AA] */ 0x20, /* [AB] */ 0x20, /* [AC] */ 0x20, /* [AD] # */ 0x40, /* [AE] */ 0x20, /* [AF] */ 0x20, /* [B0] */ 0x20, /* [B1] */ 0x20, /* [B2] */ 0x20, /* [B3] */ 0x20, /* [B4] */ 0x20, /* [B5] */ 0x20, /* [B6] */ 0x20, /* [B7] */ 0x20, /* [B8] */ 0x20, /* [B9] */ 0x20, /* [BA] */ 0x20, /* [BB] */ 0x20, /* [BC] */ 0x20, /* [BD] */ 0x20, /* [BE] */ 0x20, /* [BF] ¿ */ 0x60, /* [C0] */ 0x20, /* [C1] */ 0x20, /* [C2] */ 0x20, /* [C3] */ 0x20, /* [C4] Ä */ 0x5B, /* [C5] Å */ 0x0E, /* [C6] Æ */ 0x1C, /* [C7] Ç */ 0x09, /* [C8] */ 0x20, /* [C9] É */ 0x1F, /* [CA] */ 0x20, /* [CB] */ 0x20, /* [CC] */ 0x20, /* [CD] */ 0x20, /* [CE] */ 0x20, /* [CF] */ 0x20, /* [D0] */ 0x20, /* [D1] Ñ */ 0x5F, /* [D2] */ 0x20, /* [D3] */ 0x20, /* [D4] */ 0x20, /* [D5] */ 0x20, /* [D6] Ö */ 0x5C, /* [D7] */ 0x20, /* [D8] Ø */ 0x0B, /* [D9] */ 0x20, /* [DA] */ 0x20, /* [DB] */ 0x20, /* [DC] Ü */ 0x5D, /* [DD] */ 0x20, /* [DE] */ 0x20, /* [DF] ß */ 0x7E, /* [E0] à */ 0x7F, /* [E1] */ 0x20, /* [E2] */ 0x20, /* [E3] */ 0x20, /* [E4] ä */ 0x7B, /* [E5] å */ 0x0F, /* [E6] æ */ 0x1D, /* [E7] */ 0x20, /* [E8] è */ 0x04, /* [E9] é */ 0x05, /* [EA] */ 0x20, /* [EB] */ 0x20, /* [EC] ì */ 0x07, /* [ED] */ 0x20, /* [EE] */ 0x20, /* [EF] */ 0x20, /* [F0] */ 0x20, /* [F1] ñ */ 0x1E, /* [F2] ò */ 0x08, /* [F3] */ 0x20, /* [F4] */ 0x20, /* [F5] */ 0x20, /* [F6] ö */ 0x7C, /* [F7] */ 0x20, /* [F8] ø */ 0x0C, /* [F9] ù */ 0x06, /* [FA] */ 0x20, /* [FB] */ 0x20, /* [FC] ü */ 0x7D, /* [FD] */ 0x20, /* [FE] */ 0x20, /* [FF] */ 0x20 }; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int toia5(int c) { if (c < 0) { c += 256; } if ((c >= 0) && (c <= 255)) { return (ia5table[c]); } return 0x20; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/driver/broken/0000755000175000017500000000000010460426637017156 5ustar noodlesnoodlessmsclient-2.0.8z/src/driver/broken/proximus_web.c0000644000175000017500000001457210127274506022052 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* proximus_web.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "comms/http.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static struct proximus_web_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ char *url; } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 3, &(driver_env.def.max_deliver) }, { RESOURCE_STRING, "SMS_url", 0, 1, NULL, 0, "http://sms.advalvas.be/scripts/ProxiTextint.dll", 0, &(driver_env.url) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int PROXIMUS_WEB_dial(DRIVER_DEFAULT_ENV *env); static int PROXIMUS_WEB_sendmessage(char *msisdn, char *message); static void PROXIMUS_WEB_hangup(DRIVER_DEFAULT_ENV *env); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int PROXIMUS_WEB_dial(DRIVER_DEFAULT_ENV *env) { return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ struct intlprefix_struct { char *number, *intlprefix; } intlprefix_map[] = { { "075", "%2B3275" }, { "0476", "%2B32476" }, { "0477", "%2B32477" }, { NULL, NULL } }; static int PROXIMUS_WEB_sendmessage(char *msisdn, char *message) { int document_len, i; char data[1024], *document, *escaped_message, *selectedintlprefix, *prefix; /* ------------------------------------------------------------ */ for (i=0; intlprefix_map[i].number != NULL; i++) { if (strncmp(intlprefix_map[i].number, msisdn, strlen(intlprefix_map[i].number)) == 0) { break; } } if (intlprefix_map[i].intlprefix == NULL) { fprintf(stderr, "Number '%s' not supported\n", msisdn); exit(1); } else { selectedintlprefix = intlprefix_map[i].intlprefix; } escaped_message = escape_input(message); if (escaped_message == NULL) { exit(-1); } /* ------------------------------------------------------------ */ prefix = ""; sms_snprintf(data, 1024, "MfcISAPICommand=SendText&origin=adva&intlPrefix=%s&prefix=%s&tel=%s&bericht=%s&num=116&x=35&y=14", selectedintlprefix, prefix, msisdn, escaped_message); free(escaped_message); /* ------------------------------------------------------------ */ document = get_document(driver_env.url, &document_len, "POST", data, NULL); if (document != NULL) { lprintf(LOG_VERYVERBOSE, "%s\n", document); if (strstr(document, "spodrod") != NULL) { printf("Your message has been successfully queued for transmission\n"); } else if (strstr(document, "Your message could not be sent") != NULL) { fprintf(stderr, "Error: Trying to Deliver message - Proximus didn't like your submission\n"); return -1; } else { fprintf(stderr, "Error: Trying to Deliver message - Unexpected response\n"); return -1; } free(document); } else { lprintf(LOG_ERROR, "Trying to Deliver message - Failed to connect\n"); return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void PROXIMUS_WEB_hangup(DRIVER_DEFAULT_ENV *env) { } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY proximus_web_device = { "PROXIMUS_WEB", "0.1", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, PROXIMUS_WEB_dial, PROXIMUS_WEB_hangup, default_send_disconnect, default_single_deliver, PROXIMUS_WEB_sendmessage, default_login }; smsclient-2.0.8z/src/driver/broken/orange_web.c0000644000175000017500000001607710127274506021441 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* orange_web.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "comms/http.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static struct orange_web_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ char *url, *username, *password; } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 3, &(driver_env.def.max_deliver) }, { RESOURCE_STRING, "SMS_url", 0, 1, NULL, 0, "http://www.uk.orange.net/cgi-bin/register/sms.pl", 0, &(driver_env.url) }, { RESOURCE_STRING, "SMS_username", 0, 1, NULL, 0, "", 0, &(driver_env.username) }, { RESOURCE_STRING, "SMS_password", 0, 1, NULL, 0, "", 0, &(driver_env.password) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int ORANGE_WEB_dial(DRIVER_DEFAULT_ENV *env); static int ORANGE_WEB_sendmessage(char *msisdn, char *message); static void ORANGE_WEB_hangup(DRIVER_DEFAULT_ENV *env); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int ORANGE_WEB_dial(DRIVER_DEFAULT_ENV *env) { return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *messagetype[] = { "0973", "0976", "0966", "07967", "07970", "07971", "07974", "07977", "0941", NULL }; static int ORANGE_WEB_sendmessage(char *msisdn, char *message) { int document_len, i; char *src, *dst, data[1024], *document, *escaped_message, *short_number, *auth, *number_prefix; /* ------------------------------------------------------------ */ auth = (char *)malloc(sizeof(char) * (strlen(driver_env.username) + 1 + strlen(driver_env.password) +1)); if (auth == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } sms_snprintf(auth, (strlen(driver_env.username) + 1 + strlen(driver_env.password) +1), "%s:%s", driver_env.username, driver_env.password); /* ------------------------------------------------------------ */ short_number = strdup(msisdn); if (short_number == NULL) { exit(-1); } for (i=0; messagetype[i] != NULL; i++) { if (strncmp(messagetype[i], short_number, strlen(messagetype[i])) == 0) { break; } } if (messagetype[i] == NULL) { number_prefix = "Local"; } else { number_prefix = messagetype[i]; dst = short_number; src = short_number + strlen(messagetype[i]); while ((*dst = *src)) { dst++; src++; } } escaped_message = escape_input(message); if (escaped_message == NULL) { exit(-1); } /* ------------------------------------------------------------ */ sms_snprintf(data, 1024, "FRAMES=++&messagetype=%s&number=%s&message=%s", number_prefix, short_number, escaped_message); free(short_number); free(escaped_message); /* ------------------------------------------------------------ */ document = get_document(driver_env.url, &document_len, "POST", data, auth); if (document != NULL) { lprintf(LOG_VERYVERBOSE, "%s\n", document); if (strstr(document, "has been sent successfully") != NULL) { lprintf(LOG_STANDARD, "Your message has been successfully queued for transmission\n"); } else if (strstr(document, "your message could not be sent") != NULL) { lprintf(LOG_ERROR, "Trying to Deliver message - Orange didn't like your submission\n"); free(document); return -1; } else { lprintf(LOG_ERROR, "Trying to Deliver message - Unexpected response\n"); free(document); return -1; } free(document); } else { lprintf(LOG_ERROR, "Trying to Deliver message - Failed to connect\n"); return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void ORANGE_WEB_hangup(DRIVER_DEFAULT_ENV *env) { } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY orange_web_device = { "ORANGE_WEB", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, ORANGE_WEB_dial, ORANGE_WEB_hangup, default_send_disconnect, default_single_deliver, ORANGE_WEB_sendmessage, default_login }; smsclient-2.0.8z/src/driver/broken/nextel_web.c0000644000175000017500000001351610127274506021460 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* nextel_web.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "comms/http.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static struct nextel_web_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ char *url; } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 3, &(driver_env.def.max_deliver) }, { RESOURCE_STRING, "SMS_url", 0, 1, NULL, 0, "http://www.nextel.com/cgi-bin/sendPage.cgi", 0, &(driver_env.url) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int NEXTEL_WEB_dial(DRIVER_DEFAULT_ENV *env); static int NEXTEL_WEB_sendmessage(char *msisdn, char *message); static void NEXTEL_WEB_hangup(DRIVER_DEFAULT_ENV *env); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int NEXTEL_WEB_dial(DRIVER_DEFAULT_ENV *env) { return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int NEXTEL_WEB_sendmessage(char *msisdn, char *message) { int document_len; char data[1024], *document, *escaped_message; /* ------------------------------------------------------------ */ escaped_message = escape_input(message); if (escaped_message == NULL) { exit(-1); } /* ------------------------------------------------------------ */ sms_snprintf(data, 1024, "to01=%s&from=&subject=&message=%s&count=%d&email=&SEND=Send+Page&type=single&action=send&schedule=++", msisdn, escaped_message, strlen(escaped_message)); free(escaped_message); /* ------------------------------------------------------------ */ document = get_document(driver_env.url, &document_len, "POST", data, NULL); if (document != NULL) { lprintf(LOG_VERYVERBOSE, "%s\n", document); if (strstr(document, "Your message has been received by the Nextel Messaging Center") != NULL) { lprintf(LOG_STANDARD, "Your message has been submitted\n"); } else if (strstr(document, "Message could not be sent to the following phone numbers") != NULL) { lprintf(LOG_ERROR, "Your message could NOT be submitted\n"); free(document); return -1; } else { lprintf(LOG_ERROR, "Trying to Deliver message - Unexpected response\n"); free(document); return -1; } free(document); } else { lprintf(LOG_ERROR, "Trying to Deliver message - Failed to connect\n"); return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void NEXTEL_WEB_hangup(DRIVER_DEFAULT_ENV *env) { } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY nextel_web_device = { "NEXTEL_WEB", "0.2", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, NEXTEL_WEB_dial, NEXTEL_WEB_hangup, default_send_disconnect, default_single_deliver, NEXTEL_WEB_sendmessage, default_login }; smsclient-2.0.8z/src/driver/broken/att_web.c0000644000175000017500000001276710127274505020757 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* att_web.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "comms/http.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static struct att_web_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ char *url; } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 3, &(driver_env.def.max_deliver) }, { RESOURCE_STRING, "SMS_url", 0, 1, NULL, 0, "http://www.mobile.att.net/mc/mc_pagersend.cgi", 0, &(driver_env.url) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int ATT_WEB_dial(DRIVER_DEFAULT_ENV *env); static int ATT_WEB_sendmessage(char *msisdn, char *message); static void ATT_WEB_hangup(DRIVER_DEFAULT_ENV *env); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int ATT_WEB_dial(DRIVER_DEFAULT_ENV *env) { return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int ATT_WEB_sendmessage(char *msisdn, char *message) { int document_len; char data[1024], *document, *escaped_message; /* ------------------------------------------------------------ */ escaped_message = escape_input(message); if (escaped_message == NULL) { exit(-1); } /* ------------------------------------------------------------ */ sms_snprintf(data, 1024, "htmlsource=nonMsg.html&pin=%s&returnpage=default&from=&subject=&message=%s&sizebox=12&x=21&y=22", msisdn, escaped_message); free(escaped_message); /* ------------------------------------------------------------ */ document = get_document(driver_env.url, &document_len, "POST", data, NULL); if (document != NULL) { lprintf(LOG_VERYVERBOSE, "%s\n", document); if (strstr(document, "has been submitted") != NULL) { printf("Your message has been submitted\n"); } else { fprintf(stderr, "Error: Trying to Deliver message - Unexpected response\n"); return -1; } free(document); } else { lprintf(LOG_ERROR, "Trying to Deliver message - Failed to connect\n"); return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void ATT_WEB_hangup(DRIVER_DEFAULT_ENV *env) { } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY att_web_device = { "ATT_WEB", "0.1", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, ATT_WEB_dial, ATT_WEB_hangup, default_send_disconnect, default_single_deliver, ATT_WEB_sendmessage, default_login }; smsclient-2.0.8z/src/driver/broken/cellnet_web.c0000644000175000017500000001406610127274505021607 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* cellnet_web.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "comms/http.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static struct cellnet_web_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ char *url, *ac, *atmo, *rtmo; } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 3, &(driver_env.def.max_deliver) }, { RESOURCE_STRING, "SMS_url", 0, 1, NULL, 0, "http://www.genie.cellnet.co.uk:80/gm_ed/msg_check.nar", 0, &(driver_env.url) }, { RESOURCE_STRING, "SMS_ac", 0, 1, NULL, 0, "", 0, &(driver_env.ac) }, { RESOURCE_STRING, "SMS_atmo", 0, 1, NULL, 0, "", 0, &(driver_env.atmo) }, { RESOURCE_STRING, "SMS_rtmo", 0, 1, NULL, 0, "", 0, &(driver_env.rtmo) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int CELLNET_WEB_dial(DRIVER_DEFAULT_ENV *env); static int CELLNET_WEB_sendmessage(char *msisdn, char *message); static void CELLNET_WEB_hangup(DRIVER_DEFAULT_ENV *env); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int CELLNET_WEB_dial(DRIVER_DEFAULT_ENV *env) { return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int CELLNET_WEB_sendmessage(char *msisdn, char *message) { char *escaped_message, data[1024], *document; int document_len; escaped_message = escape_input(message); if (escaped_message == NULL) { exit(-1); } sms_snprintf(data, 1024, "FORM_ACTION=SEND_MESSAGE&ac=%s&atmo=%s&rtmo=%s&TO=%s" "&SUBJECT=&DATE=Monday&MSG_MESSAGE=%s&count=0&x=33&y=12", driver_env.ac, driver_env.atmo, driver_env.rtmo, msisdn, escaped_message); free(escaped_message); document = get_document(driver_env.url, &document_len, "POST", data, NULL); if (document != NULL) { lprintf(LOG_VERYVERBOSE, "%s\n", document); if (strstr(document, "Your message has been queued") != NULL) { lprintf(LOG_STANDARD, "Your message has been successfully queued for transmission\n"); } else if (strstr(document, "Genie couldn't send your message") != NULL) { lprintf(LOG_ERROR, "Trying to Deliver message - Genie didn't like your submission\n"); free(document); return -1; } else { lprintf(LOG_ERROR, "Trying to Deliver message - Unexpected response\n"); free(document); return -1; } free(document); } else { lprintf(LOG_ERROR, "Trying to Deliver message - Failed to connect\n"); return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void CELLNET_WEB_hangup(DRIVER_DEFAULT_ENV *env) { } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY cellnet_web_device = { "CELLNET_WEB", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, CELLNET_WEB_dial, CELLNET_WEB_hangup, default_send_disconnect, default_single_deliver, CELLNET_WEB_sendmessage, default_login }; smsclient-2.0.8z/src/driver/broken/pagenet_web.c0000644000175000017500000001327610127274506021607 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* pagenet_web.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "comms/http.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static struct pagenet_web_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ char *url; } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 3, &(driver_env.def.max_deliver) }, { RESOURCE_STRING, "SMS_url", 0, 1, NULL, 0, "http://www.pagenet.net/pagenet/page_gen", 0, &(driver_env.url) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int PAGENET_WEB_dial(DRIVER_DEFAULT_ENV *env); static int PAGENET_WEB_sendmessage(char *msisdn, char *message); static void PAGENET_WEB_hangup(DRIVER_DEFAULT_ENV *env); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int PAGENET_WEB_dial(DRIVER_DEFAULT_ENV *env) { return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int PAGENET_WEB_sendmessage(char *msisdn, char *message) { int document_len; char data[1024], *document, *escaped_message; /* ------------------------------------------------------------ */ escaped_message = escape_input(message); if (escaped_message == NULL) { exit(-1); } /* ------------------------------------------------------------ */ /* Currently absent field - Select+a+Paging+Terminal I need a betatester to find out what it should contain. */ sms_snprintf(data, 1024, "Response=pagenet%%2Fmail_sen.htm&Error=pagenet%%2Fpnet_err.htm&Partial=pagenet%%2Fpnet_err.htm&SysID=Select+a+Paging+Terminal&To=%s&Message=%s", msisdn, escaped_message); free(escaped_message); /* ------------------------------------------------------------ */ document = get_document(driver_env.url, &document_len, "POST", data, NULL); if (document != NULL) { lprintf(LOG_VERYVERBOSE, "%s\n", document); if (strstr(document, "spodrod") != NULL) { printf("Your message has been submitted\n"); } else { fprintf(stderr, "Error: Trying to Deliver message - Unexpected response\n"); return -1; } free(document); } else { lprintf(LOG_ERROR, "Trying to Deliver message - Failed to connect\n"); return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void PAGENET_WEB_hangup(DRIVER_DEFAULT_ENV *env) { } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY pagenet_web_device = { "PAGENET_WEB", "0.1", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, PAGENET_WEB_dial, PAGENET_WEB_hangup, default_send_disconnect, default_single_deliver, PAGENET_WEB_sendmessage, default_login }; smsclient-2.0.8z/src/driver/cimd.c0000644000175000017500000002354510127274505016762 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* cimd.c */ /* */ /* Copyright (C) 1997,1998,1999,2000 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* mattias */ /* shevek@anarres.org */ /* */ /* Much of the work for this driver has been contributed */ /* by shevek. */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "comms/comms.h" #include "error.h" #include "resource/resource.h" #include "ascii.h" /* -------------------------------------------------------------------- */ static struct cimd_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ char *login, *password, *message_terminator; long login_delay; } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 0, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 0, NULL, 0, "0708222901", 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 0, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 45, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 1, &(driver_env.def.max_deliver) }, { RESOURCE_STRING, "SMS_login", 0, 1, NULL, 0, "EURO_CIMD", 0, &(driver_env.login) }, { RESOURCE_STRING, "SMS_password", 0, 1, NULL, 0, "2062", 0, &(driver_env.password) }, { RESOURCE_STRING, "SMS_message_terminator", 0, 0, NULL, 0, "\n", 0, &(driver_env.message_terminator) }, { RESOURCE_NUMERIC, "SMS_login_delay", 0, 0, NULL, 0, NULL, 2000000, &(driver_env.login_delay) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define MSGTERM (driver_env.message_terminator) #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int CIMD_login(void); static int CIMD_sendmessage(char *msisdn, char *message); static int CIMD_send_disconnect(void); static void CIMD_hangup(void); static void calculate_checksum(char *checksum, char *ptr); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void calculate_checksum(char *checksum, char *ptr) { unsigned int sum, high, low; sum = 0; while (ptr != checksum) { sum += *ptr++; sum &= 0x00FF; } high = (sum >> 4) & 0x000F; low = (sum ) & 0x000F; if (high <10) { checksum[0] = '0' + high; } else { checksum[0] = 'A' + (high -10); } if (low <10) { checksum[1] = '0' + low; } else { checksum[1] = 'A' + (low -10); } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int CIMD_login(void) { char buf[MAX_RESPONSE_BUFSIZE], message[512]; if (expstr(FD, buf, "login: ", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received login request\n"); } else { lprintf(LOG_STANDARD, "No login request\n"); CIMD_hangup(); return -1; } lprintf(LOG_STANDARD, "Sending Service Login...\n"); twrite(FD, "sc3cimd1\n", strlen("sc3cimd1\n"), WRITETIMEOUT); if (expstr(FD, buf, "CIMD", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { if (expstr(FD, buf, "\n", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "CIMD Service Detected\n"); } else { lprintf(LOG_STANDARD, "No CIMD Service Detected\n"); CIMD_hangup(); return -1; } } else { lprintf(LOG_STANDARD, "No CIMD Service Detected\n"); CIMD_hangup(); return -1; } sms_usleep(driver_env.login_delay); sprintf(message, "%c%s%c%s%c%s%c%s%c%s", S_STX, "01", S_HT, driver_env.login, S_HT, driver_env.password, S_HT, "XX", S_ETX, MSGTERM); calculate_checksum(&message[strlen(message) - (3 + strlen(MSGTERM))], message); twrite(FD, message, strlen(message), WRITETIMEOUT); if (expstr(FD, buf, "\n", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { /* should check for: C:01chksum */ if ((buf[0] == S_STX) && (buf[1] == S_ACK)) { lprintf(LOG_STANDARD, "Completed CIMD Login\n"); } else { lprintf(LOG_STANDARD, "CIMD Login failed\n"); CIMD_hangup(); return -1; } } else { lprintf(LOG_STANDARD, "CIMD Login failed\n"); CIMD_hangup(); return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int CIMD_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE], nmessage[512]; sprintf(nmessage, "%c%s%c%s%c%s%c%s%c%s", S_STX, "03", S_HT, msisdn, S_HT, message, S_HT, "XX", S_ETX, MSGTERM); calculate_checksum(&nmessage[strlen(nmessage) - (3 + strlen(MSGTERM))], nmessage); twrite(FD, nmessage, strlen(nmessage), WRITETIMEOUT); if (expstr(FD, buf, "\n", MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0) { /* should check for: C:04statuserr_descdestsctstimechksum */ if ((buf[0] == S_STX) && (buf[1] == S_ACK)) { lprintf(LOG_STANDARD, "Received Message Delivery Response\n"); } else { lprintf(LOG_STANDARD, "No Message Delivery Response\n"); CIMD_hangup(); return -1; } } else { lprintf(LOG_STANDARD, "No Message Delivery Response\n"); CIMD_hangup(); return -1; } lprintf(LOG_STANDARD, "Sending Acknowledgment...\n"); sprintf(nmessage, "%c%c%c%s%c%s", S_STX, S_ACK, S_HT, "XX", S_ETX, MSGTERM); calculate_checksum(&nmessage[strlen(nmessage) - (3 + strlen(MSGTERM))], nmessage); twrite(FD, nmessage, strlen(nmessage), WRITETIMEOUT); return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int CIMD_send_disconnect(void) { char buf[MAX_RESPONSE_BUFSIZE], message[512]; sprintf(message, "%c%s%c%s%c%s", S_STX, "02", S_HT, "XX", S_ETX, MSGTERM); calculate_checksum(&message[strlen(message) - (3 + strlen(MSGTERM))], message); twrite(FD, message, strlen(message), WRITETIMEOUT); if (expstr(FD, buf, "\n", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { /* should check for: C:02time. Sess:time.Sub:n (M)chksum */ if ((buf[0] == S_STX) && (buf[1] == S_ACK)) { lprintf(LOG_STANDARD, "Received Disconnection Response\n"); } else { lprintf(LOG_STANDARD, "No Disconnection Response\n"); CIMD_hangup(); return -1; } } else { lprintf(LOG_STANDARD, "No Disconnection Response\n"); CIMD_hangup(); return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void CIMD_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY cimd_device = { "CIMD", "1.1", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, default_dial, default_hangup, CIMD_send_disconnect, default_multiple_counted_deliver, CIMD_sendmessage, CIMD_login }; smsclient-2.0.8z/src/driver/tap.c0000644000175000017500000004137710127274506016636 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* tap.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id: tap.c,v 5.1 1998/02/01 07:10:39 root Exp root $ -------------------------------------------------------------------- */ #include #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" #include "ascii.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static struct tap_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ long max_tries, login_timeout, init_login_sleep, login_sleep; char *select, *response, *disconnect; } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_login_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.login_timeout) }, { RESOURCE_NUMERIC, "SMS_login_sleep", 0, 0, NULL, 0, NULL, 2000000, &(driver_env.login_sleep) }, { RESOURCE_NUMERIC, "SMS_init_login_sleep", 0, 0, NULL, 0, NULL, 1500000, &(driver_env.init_login_sleep) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_tries", 0, 0, NULL, 0, NULL, 5, &(driver_env.max_tries) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.max_deliver) }, { RESOURCE_STRING, "SMS_tap_select", 0, 0, NULL, 0, "PG1", 0, &(driver_env.select) }, { RESOURCE_STRING, "SMS_tap_response", 0, 0, NULL, 0, "TRUE", 0, &(driver_env.response) }, { RESOURCE_STRING, "SMS_tap_disconnect", 0, 0, NULL, 0, "TRUE", 0, &(driver_env.disconnect) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define LOGINTIMEOUT (driver_env.login_timeout) #define LOGINSLEEP (driver_env.login_sleep) #define INITLOGINSLEEP (driver_env.init_login_sleep) #define WRITETIMEOUT (driver_env.def.write_timeout) #define TAP_SELECT (driver_env.select) #define TAP_RESPONSE (strcmp(driver_env.response, "TRUE") == 0) #define TAP_DISCONNECT (strcmp(driver_env.disconnect, "TRUE") == 0) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ #define MAX_TRIES (driver_env.max_tries) #define MAX_TAPMESSAGE 150 #define MAX_ENVELOPE 64 #define MAX_NUMBER 20 #define MAX_MOBILENUM 20 #define MAX_MESSAGE 512 /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char TAP_charset[] = { 0x20 /* 0x00 */, 0x20 /* 0x01 */, 0x20 /* 0x02 */, 0x20 /* 0x03 */, 0x20 /* 0x04 */, 0x20 /* 0x05 */, 0x20 /* 0x06 */, 0x20 /* 0x07 */, 0x20 /* 0x08 */, 0x20 /* 0x09 */, 0x0A /* 0x0A LF */, 0x20 /* 0x0B */, 0x20 /* 0x0C */, 0x0A /* 0x0D LF */, 0x20 /* 0x0E */, 0x20 /* 0x0F */, 0x20 /* 0x10 */, 0x20 /* 0x11 */, 0x20 /* 0x12 */, 0x20 /* 0x13 */, 0x20 /* 0x14 */, 0x20 /* 0x15 */, 0x20 /* 0x16 */, 0x20 /* 0x17 */, 0x20 /* 0x18 */, 0x20 /* 0x19 */, 0x20 /* 0x1A */, 0x20 /* 0x1B */, 0x20 /* 0x1C */, 0x20 /* 0x1D */, 0x20 /* 0x1E */, 0x20 /* 0x1F */, 0x20 /* 0x20 */, 0x21 /* 0x21 ! */, 0x22 /* 0x22 " */, 0x23 /* 0x23 # */, 0x24 /* 0x24 $ */, 0x25 /* 0x25 % */, 0x26 /* 0x26 & */, 0x27 /* 0x27 ' */, 0x28 /* 0x28 ( */, 0x29 /* 0x29 ) */, 0x2A /* 0x2A * */, 0x2B /* 0x2B + */, 0x2C /* 0x2C , */, 0x2D /* 0x2D - */, 0x2E /* 0x2E . */, 0x2F /* 0x2F / */, 0x30 /* 0x30 0 */, 0x31 /* 0x31 1 */, 0x32 /* 0x32 2 */, 0x33 /* 0x33 3 */, 0x34 /* 0x34 4 */, 0x35 /* 0x35 5 */, 0x36 /* 0x36 6 */, 0x37 /* 0x37 7 */, 0x38 /* 0x38 8 */, 0x39 /* 0x39 9 */, 0x3A /* 0x3A : */, 0x3B /* 0x3B ; */, 0x3C /* 0x3C < */, 0x3D /* 0x3D = */, 0x3E /* 0x3E > */, 0x3F /* 0x3F ? */, 0x40 /* 0x40 @ */, 0x41 /* 0x41 A */, 0x42 /* 0x42 B */, 0x43 /* 0x43 C */, 0x44 /* 0x44 D */, 0x45 /* 0x45 E */, 0x46 /* 0x46 F */, 0x47 /* 0x47 G */, 0x48 /* 0x48 H */, 0x49 /* 0x49 I */, 0x4A /* 0x4A J */, 0x4B /* 0x4B K */, 0x4C /* 0x4C L */, 0x4D /* 0x4D M */, 0x4E /* 0x4E N */, 0x4F /* 0x4F O */, 0x50 /* 0x50 P */, 0x51 /* 0x51 Q */, 0x52 /* 0x52 R */, 0x53 /* 0x53 S */, 0x54 /* 0x54 T */, 0x55 /* 0x55 U */, 0x56 /* 0x56 V */, 0x57 /* 0x57 W */, 0x58 /* 0x58 X */, 0x59 /* 0x59 Y */, 0x5A /* 0x5A Z */, 0x20 /* 0x5B */, 0x20 /* 0x5C */, 0x20 /* 0x5D */, 0x20 /* 0x5E */, 0x20 /* 0x5F */, 0x20 /* 0x60 */, 0x61 /* 0x61 a */, 0x62 /* 0x62 b */, 0x63 /* 0x63 c */, 0x64 /* 0x64 d */, 0x65 /* 0x65 e */, 0x66 /* 0x66 f */, 0x67 /* 0x67 g */, 0x68 /* 0x68 h */, 0x69 /* 0x69 i */, 0x6A /* 0x6A j */, 0x6B /* 0x6B k */, 0x6C /* 0x6C l */, 0x6D /* 0x6D m */, 0x6E /* 0x6E n */, 0x6F /* 0x6F o */, 0x70 /* 0x70 p */, 0x71 /* 0x71 q */, 0x72 /* 0x72 r */, 0x73 /* 0x73 s */, 0x74 /* 0x74 t */, 0x75 /* 0x75 u */, 0x76 /* 0x76 v */, 0x77 /* 0x77 w */, 0x78 /* 0x78 x */, 0x79 /* 0x79 y */, 0x7A /* 0x7A z */, 0x20 /* 0x7B */, 0x20 /* 0x7C */, 0x20 /* 0x7D */, 0x20 /* 0x7E */, 0x20 /* 0x7F */, 0x20 /* 0x80 */, 0x20 /* 0x81 */, 0x20 /* 0x82 */, 0x20 /* 0x83 */, 0x20 /* 0x84 */, 0x20 /* 0x85 */, 0x20 /* 0x86 */, 0x20 /* 0x87 */, 0x20 /* 0x88 */, 0x20 /* 0x89 */, 0x20 /* 0x8A */, 0x20 /* 0x8B */, 0x20 /* 0x8C */, 0x20 /* 0x8D */, 0x20 /* 0x8E */, 0x20 /* 0x8F */, 0x20 /* 0x90 */, 0x20 /* 0x91 */, 0x20 /* 0x92 */, 0x20 /* 0x93 */, 0x20 /* 0x94 */, 0x20 /* 0x95 */, 0x20 /* 0x96 */, 0x20 /* 0x97 */, 0x20 /* 0x98 */, 0x20 /* 0x99 */, 0x20 /* 0x9A */, 0x20 /* 0x9B */, 0x20 /* 0x9C */, 0x20 /* 0x9D */, 0x20 /* 0x9E */, 0x20 /* 0x9F */, 0x20 /* 0xA0 */, 0x20 /* 0xA1 */, 0x20 /* 0xA2 */, 0x20 /* 0xA3 */, 0x20 /* 0xA4 */, 0x20 /* 0xA5 */, 0x20 /* 0xA6 */, 0x20 /* 0xA7 */, 0x20 /* 0xA8 */, 0x20 /* 0xA9 */, 0x20 /* 0xAA */, 0x20 /* 0xAB */, 0x20 /* 0xAC */, 0x20 /* 0xAD */, 0x20 /* 0xAE */, 0x20 /* 0xAF */, 0x20 /* 0xB0 */, 0x20 /* 0xB1 */, 0x20 /* 0xB2 */, 0x20 /* 0xB3 */, 0x20 /* 0xB4 */, 0x20 /* 0xB5 */, 0x20 /* 0xB6 */, 0x20 /* 0xB7 */, 0x20 /* 0xB8 */, 0x20 /* 0xB9 */, 0x20 /* 0xBA */, 0x20 /* 0xBB */, 0x20 /* 0xBC */, 0x20 /* 0xBD */, 0x20 /* 0xBE */, 0x20 /* 0xBF */, 0x20 /* 0xC0 */, 0x20 /* 0xC1 */, 0x20 /* 0xC2 */, 0x20 /* 0xC3 */, 0x5B /* 0xC4 */, 0x20 /* 0xC5 */, 0x20 /* 0xC6 */, 0x20 /* 0xC7 */, 0x20 /* 0xC8 */, 0x20 /* 0xC9 */, 0x20 /* 0xCA */, 0x20 /* 0xCB */, 0x20 /* 0xCC */, 0x20 /* 0xCD */, 0x20 /* 0xCE */, 0x20 /* 0xCF */, 0x20 /* 0xD0 */, 0x20 /* 0xD1 */, 0x20 /* 0xD2 */, 0x20 /* 0xD3 */, 0x20 /* 0xD4 */, 0x20 /* 0xD5 */, 0x5C /* 0xD6 */, 0x20 /* 0xD7 */, 0x20 /* 0xD8 */, 0x20 /* 0xD9 */, 0x20 /* 0xDA */, 0x20 /* 0xDB */, 0x5D /* 0xDC */, 0x20 /* 0xDD */, 0x20 /* 0xDE */, 0x1E /* 0xDF */, 0x7E /* 0xE0 */, 0x20 /* 0xE1 */, 0x20 /* 0xE2 */, 0x20 /* 0xE3 */, 0x7B /* 0xE4 */, 0x20 /* 0xE5 */, 0x20 /* 0xE6 */, 0x20 /* 0xE7 */, 0x20 /* 0xE8 */, 0x20 /* 0xE9 */, 0x20 /* 0xEA */, 0x20 /* 0xEB */, 0x20 /* 0xEC */, 0x20 /* 0xED */, 0x20 /* 0xEE */, 0x20 /* 0xEF */, 0x20 /* 0xF0 */, 0x20 /* 0xF1 */, 0x20 /* 0xF2 */, 0x20 /* 0xF3 */, 0x20 /* 0xF4 */, 0x20 /* 0xF5 */, 0x7C /* 0xF6 */, 0x20 /* 0xF7 */, 0x20 /* 0xF8 */, 0x20 /* 0xF9 */, 0x20 /* 0xFA */, 0x20 /* 0xFB */, 0x7D /* 0xFC */, 0x20 /* 0xFD */, 0x20 /* 0xFE */, 0x20 /* 0xFF */ }; /* -------------------------------------------------------------------- */ static char ACK1[] = { 'I', 'D', '=', '\0' }; static char ACK2[] = { S_ACK, S_CR, '\0' }; static char ACK3[] = { S_ESC, '[', 'p', S_CR, '\0' }; static char ACK4[] = { S_CR, '\0' }; static char ACK5[] = { S_ACK, S_CR, '\0' }; static char ACK6[] = { S_NAK, S_CR, '\0' }; static char ACK7[] = { S_RS, S_CR, '\0' }; static char ACK8[] = { S_ESC, S_EOT, S_CR, '\0' }; static char REQ1[] = { S_CR, '\0' }; static char REQ2a[] = { S_ESC, '\0' }; static char REQ2b[] = { S_CR, '\0' }; static char REQ3[] = { S_STX, '\0' }; static char REQ4[] = { S_CR, '\0' }; static char REQ5[] = { S_CR, S_ETX, '\0' }; static char REQ6[] = { S_CR, '\0' }; static char REQ7[] = { S_EOT, S_CR, '\0' }; /* -------------------------------------------------------------------- */ static char buf[MAX_RESPONSE_BUFSIZE]; /* -------------------------------------------------------------------- */ static void TAP_checksum(char *); static void TAP_hangup(void); static void TAP_buildmessage(char *, char *, char *); static int TAP_send_disconnect(void); static int TAP_login(void); static int TAP_sendmessage(char *, char *); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void TAP_checksum(char *message) { int i, checksum; checksum = 0; for (i=0; i128 */ checksum += (unsigned char)message[i]; #endif } checksum = (checksum & 0x0FFF); /* Mask low 12Bits */ message[i] = (((checksum & 0x0F00) >> 8) | 0x30); message[i+1] = (((checksum & 0x00F0) >> 4) | 0x30); message[i+2] = (((checksum & 0x000F) ) | 0x30); message[i+3] = '\0'; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void TAP_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int TAP_send_disconnect(void) { lprintf(LOG_STANDARD, "Disconnect...\n"); if (TAP_DISCONNECT) { twrite(FD, REQ7, strlen(REQ7), WRITETIMEOUT); if (expstr(FD, buf, ACK8, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Disconnected from SMSC\n"); } else { lprintf(LOG_STANDARD, "Failed to disconnect from SMSC\n"); TAP_hangup(); return ETAP_NODISCONNECT; } } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int TAP_login(void) { int i; lprintf(LOG_STANDARD, "Login...\n"); /* Resend the S_CR every 2 seconds */ /* until ID= received, only try */ /* 5 times then give up. */ sms_usleep(INITLOGINSLEEP); for (i=0; i < MAX_TRIES; i++) { twrite(FD, REQ1, strlen(REQ1), WRITETIMEOUT); if (expstr(FD, buf, ACK1, MAX_RESPONSE_BUFSIZE, LOGINTIMEOUT) == 0) { lprintf(LOG_STANDARD, "SMSC Acknowledgment received\n"); break; } lprintf(LOG_STANDARD, "SMSC Retry for Acknowledgment\n"); sms_usleep(LOGINSLEEP); } if (i == MAX_TRIES) { lprintf(LOG_STANDARD, "Failed Acknowledgment %ld retries attempted\n", MAX_TRIES); TAP_hangup(); return ETAP_NOACK; } /* Send S_ESC S_CR and get back */ /* the acknowledgement S_ACK S_CR */ twrite(FD, REQ2a, strlen(REQ2a), WRITETIMEOUT); twrite(FD, TAP_SELECT, strlen(TAP_SELECT), WRITETIMEOUT); twrite(FD, REQ2b, strlen(REQ2b), WRITETIMEOUT); if (expstr(FD, buf, ACK2, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Login successful\n"); } else { lprintf(LOG_STANDARD, "Login failed\n"); TAP_hangup(); return ETAP_NOLOGIN; } if (expstr(FD, buf, ACK3, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Ready to receive message\n"); } else { lprintf(LOG_STANDARD, "SMSC NOT Ready to receive message\n"); TAP_hangup(); return ETAP_NOREADY; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void TAP_buildmessage(char *tap_message, char *msisdn, char *message) { int i; char *ptr; /* ---------------------------- */ tap_message[0] = '\0'; strcat(tap_message, REQ3); strcat(tap_message, msisdn); strcat(tap_message, REQ4); /* Convert message so that it contains */ /* only TAP valid characters */ /* any invalid characters will be */ /* mapped to a SPACE */ /* Add to tap_message */ ptr = tap_message; while(*ptr != '\0') { ptr++; } for (i=0; i HEADER DATA CHECKSUM */ /* */ /* Fields within HEADER and DATA are terminated by the char "/". */ /* Empty optional fields are indicated by two successive "/" */ /* separators. */ /* Bytes in alphanumeric message fields are encoded as */ /* two ascii characters (0-9,A-F) representing the hexidecimal */ /* value of the encoded byte ("hex encoding"). */ /* For example, ascii "A" is encoded as "41" */ /* Transparent data messages are also hex encoded, but 4 bits at */ /* a time, with each nyble being encoded as 1 ascii char 0-9,A-F. */ /* */ /* CHECKSUM: add up all of the bytes of HEADER and DATA, including */ /* the field separators. The checksum is the least */ /* significant byte (8 bits) of the sum. This byte is */ /* sent hex encoded (i.e., two ascii characters */ /* representing the hex value of the checksum.) */ /* */ /* HEADER FORMAT: */ /* */ /* TRN / LEN / ORC / OT / ("/" is literal field separator) */ /* */ /* TRN 2 numeric char Transaction reference number */ /* LEN 5 numeric char Total number of chars between */ /* STX & ETX, right justified, */ /* zero filled. */ /* ORC "O", "R", or "C" "Operation", "Result", or repeated */ /* operation */ /* OT 2 numeric char Operation Type */ /* OT=01: Call Input (message submission) */ /* */ /* An "Operation" message is sent (to the service center), and a */ /* "Result" is returned. If the "Result" is syntatically */ /* incorrect or does not arrive within a timeout period, the */ /* operation may be retried, with the same TRN and data, but with */ /* ORC set to "C" - to notify the service center that this */ /* operation is a possible duplicate. (Note: "C" is not */ /* available in the EMI extended subset.) */ /* */ /* */ /* examples: */ /* 01/00068/O/01/... Call input operation, reference 1, total */ /* length 68 */ /* 01/00042/R/01/... Call input result (response), reference 1, */ /* total length 42 */ /* */ /* */ /* DATA FORMAT for ORC="O", OT=01 "Call input operation" */ /* (submit message) */ /* */ /* AdC / OAdC / OAC / MT / ... additional parameters depending */ /* on MT */ /* */ /* additional parameters: */ /* MT = 1: (none) ("Tone-only") */ /* MT = 2: NM / (Numeric message) */ /* MT= 3: AM / (Alphanumeric ascii */ /* message) */ /* MT= 4: NB / TD / (Transparent data) */ /* MT= 6: AM / CS / (Alphanumeric, special */ /* character set) */ /* */ /* AdC string of numeric char Address code, recipient */ /* OAdC string of numeric char Address code, originator */ /* (optional) */ /* OAC string of char Authentication code, originator */ /* (optional) */ /* MT 1 numeric char (1-4,6) Message type */ /* NM string of numeric char Numeric Message (optional) */ /* AM hex encoded string Alphanumeric message (optional) */ /* TD hex encoded string Transparent data (optional) */ /* NB string of numeric char number of bits in TD message */ /* CS 2 numeric char (00-31) Character set number (optional) */ /* */ /* Note: the EMI extended subset is limited to MT = 2, 3 */ /* */ /* example: */ /* 0653328374///3/414243203132/ Alphanumeric message "ABC 12" */ /* for 0653328374 */ /* */ /* DATA FORMAT for ORC="R", OT=01 "Call input result" */ /* */ /* ACK / SM / (Positive result) */ /* NAC / EC / SM / (Negative result) */ /* */ /* ACK 1 character "A" Postive acknowledgement */ /* NAC 1 character "N" Negative acknowledgement */ /* SM string of char System Message (optional) */ /* EC 2 numeric char Error code - partial list: */ /* 01: checksum error */ /* 02: syntax error */ /* 03: operation not supported */ /* 04: operation not allowed */ /* 05: call barring active */ /* 06: recipient address code invalid */ /* 07: authentication failure */ /* 08: legitimisation code failure */ /* 23: message type not supported by system */ /* 24: message too long */ /* 26: message type invalid for pager type */ /* 28: invalid character set */ /* */ /* actual examples: */ /* A/0653328374:191098174717/ */ /* Positive result. In this case the "system message" is */ /* the AdC followed by :ddmmyyhhmmss date-time-stamp */ /* N/01/ Checksum error / */ /* Negative result */ /* */ /* EXAMPLE EXCHANGE: */ /* */ /* -> 00/00060/O/01/0653328374///3/54657374206D6573736167652031/B2 */ /* <- 00/00042/R/01/A/0653328374:191098174717/1E */ /* -> (hangs up) */ /* */ /* -------------------------------------------------------------------- */ #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "ascii.h" #include "ia5table.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static struct ucp_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 1, &(driver_env.def.max_deliver) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int UCP_sendmessage(char *msisdn, char *message); static int UCP_parse_response(char *string); static void UCP_hangup(void); /* -------------------------------------------------------------------- */ static char *UCP_header(int tranRefNo, char ORC, int opType, int dataLen ) { int msgLen; static char msgHead[20]; /* HEADER section */ msgLen = 14 + dataLen + 2; /* len(header+data+checksum) */ /* header: TRN/LEN/ORC/OT/ */ sprintf(msgHead, "%2.2d/%5.5d/%c/%2.2d/", tranRefNo, msgLen, ORC, opType); return msgHead; } /* -------------------------------------------------------------------- */ static char *UCP01_data(char *msisdn, char *message, int msgType) { static char msgData[800]; char *src; char *dest; int nc; /* DATA section */ msgType = 3; /* alphanumeric - others aren't implemented here*/ /* data: AdC/OAdc/OAC/MT/.. */ /* -> recipient///3/... */ nc = sprintf(msgData, "%s///%1.1d/", msisdn, msgType); /* ... additional parameters depending on MT */ /* For MT=3 (alphanumeric) this is hex coded */ /* message data */ dest = &msgData[nc]; for (src = message; *src; src++) { sprintf(dest, "%02X", *src); dest += 2; } sprintf( dest, "/" ); return msgData; } /* -------------------------------------------------------------------- */ static char *UCP_checksum(char *header, char *data ) { char *p; int sum; static char buf[3]; /* CHECKSUM section */ sum = 0; for (p = header; *p != '\0'; p++) { sum += (unsigned char) *p; sum &= 0xFF; } for (p = data; *p != '\0'; p++) { sum += (unsigned char) *p; sum &= 0xFF; } sprintf(buf, "%02X", sum); return buf; } /* -------------------------------------------------------------------- */ static char *UCP_CallInputOp(char *msisdn, char *message, int msgType) { char *msgHead, *msgData, *msgCksm, ORC; int tranRefNo, opType; static char buf[1024]; msgType = 3; /* alphanumeric - others aren't implemented here */ msgData = UCP01_data( msisdn, message, msgType ); msgHead = UCP_header( tranRefNo=1, ORC='O', opType=1, strlen(msgData) ); msgCksm = UCP_checksum( msgHead, msgData ); /* operational message: header data checksum */ sprintf(buf, "%c%s%s%s%c", S_STX, msgHead, msgData, msgCksm, S_ETX ); return buf; } /* -------------------------------------------------------------------- */ /* Return Values: */ /* 0 Positive ACK */ /* 1 Negative ACK */ /* -1 Error */ /* -------------------------------------------------------------------- */ static int UCP_parse_response(char *string) { int result; int tranRefNo, length, opType; char ORC, ack; /* ------------------------------------------------------------ */ /* Example: */ /* 01/00045/R/01/A/0041544180972:161298112313/A6 */ /* trn len orc ot a recip:time chksum */ /* ------------------------------------------------------------ */ /* * Filter any leading crud. */ while (*string && (*string != '\002')) string++; result = sscanf(string, "\002%02d/%05d/%c/%02d/%c", &tranRefNo, &length, &ORC, &opType, &ack ); if (result != 5 || ORC != 'R' || opType != 1 ) return -1; /* ---------------------------- */ if ( ack == 'A' ) result = 0; else if( ack == 'N' ) result = 1; else result = -1; return result; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int UCP_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE], *ucpMessage, *msg; int result; int msgType = 3; /*alphanumeric*/ /* ------------------------------------ */ /* Convert message to ia5 format */ /* This should be done prior to */ /* entering this function. */ /* ------------------------------------ */ msg = message; while (*msg != '\0') { *msg = toia5(*msg); msg++; } /* ------------------------------------ */ ucpMessage = UCP_CallInputOp(msisdn, message, msgType); twrite(FD, ucpMessage, strlen(ucpMessage), WRITETIMEOUT); if( expstr(FD, buf, "\03", MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0) { lprintf(LOG_STANDARD, "SMSC Respsonse: %s\n", buf); result = UCP_parse_response(buf); if (result == 0) { lprintf(LOG_STANDARD, "Message accepted\n"); } else if(result == 1) { lprintf(LOG_ERROR, "Message rejected\n"); UCP_hangup(); return EUCP_ACKFAILED; } else { lprintf(LOG_ERROR, "Bad message acknowledgement\n"); UCP_hangup(); return EUCP_BADACK; } } else { lprintf(LOG_ERROR, "No Message Response\n"); UCP_hangup(); return EUCP_NORESPONSE; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void UCP_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY ucp_device = { "UCP", "2.1", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, default_dial, default_hangup, default_send_disconnect, default_single_deliver, UCP_sendmessage, default_login }; smsclient-2.0.8z/src/driver/vodapage_block.c0000644000175000017500000001364510127274506021007 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* vodapage_block.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id: vodafone.c,v 5.1 1998/02/01 07:10:39 root Exp root $ -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static char ACK1[] = "Please Enter Required Pager Number - "; static char ACK2[] = "Paging Message Accepted \r\nNNNN\r\n"; /* -------------------------------------------------------------------- */ static struct vodapage_block_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "7E1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 1200, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.max_deliver) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int VODAPAGE_BLOCK_login(void); static int VODAPAGE_BLOCK_sendmessage(char *msisdn, char *message); static void VODAPAGE_BLOCK_hangup(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int VODAPAGE_BLOCK_login(void) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, ACK1, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Transfer Data Request\n"); } else { lprintf(LOG_STANDARD, "No Transfer Data Request\n"); VODAPAGE_BLOCK_hangup(); return EVODAPAGE_BLOCK_NONUMBER; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int VODAPAGE_BLOCK_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE]; twrite(FD, "ZCZC\r", strlen("ZCZC\r"), WRITETIMEOUT); twrite(FD, msisdn, strlen(msisdn), WRITETIMEOUT); twrite(FD, "\r", strlen("\r"), WRITETIMEOUT); twrite(FD, message, strlen(message), WRITETIMEOUT); twrite(FD, "\r", strlen("\r"), WRITETIMEOUT); twrite(FD, "NNNN\r", strlen("NNNN\r"), WRITETIMEOUT); if (expstr(FD, buf, "NNNN\r\n", MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0) { if (strlen(buf) >= strlen(ACK2)) { if (strcmp(&buf[strlen(buf) - strlen(ACK2)], ACK2) == 0) { lprintf(LOG_STANDARD, "Received Message Delivery Response\n"); } else { lprintf(LOG_STANDARD, "No Message Delivery Response\n"); VODAPAGE_BLOCK_hangup(); return EVODAPAGE_BLOCK_NODELIVERY; } } else { lprintf(LOG_STANDARD, "No Message Delivery Response\n"); VODAPAGE_BLOCK_hangup(); return EVODAPAGE_BLOCK_NODELIVERY; } } else { lprintf(LOG_STANDARD, "No Message Delivery Response\n"); VODAPAGE_BLOCK_hangup(); return EVODAPAGE_BLOCK_NODELIVERY; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void VODAPAGE_BLOCK_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY vodapage_block_device = { "VODAPAGE_BLOCK", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, default_dial, default_hangup, default_send_disconnect, default_multiple_counted_deliver, VODAPAGE_BLOCK_sendmessage, VODAPAGE_BLOCK_login }; smsclient-2.0.8z/src/driver/mtn_webtmp.c0000644000175000017500000001646210127274506020223 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include "url.h" #include "base64.h" #include "getopt.h" #include "sockets.h" #include "tslurp.h" #include "twrite.h" #include "tread.h" /* -------------------------------------------------------------------- */ #define FALSE 0 #define TRUE (!FALSE) /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *get_document(char *url, int *data_len, char *method, char *data, char *authentication, int *timeout) { char send_buf[4096], tmp_buf[1024], *proxy, *auth, *mdata; int sockfd, orig_timeout, send_buflen, bytes_written; URL *tmp_url, *proxy_url; if (timeout != NULL) { orig_timeout = *timeout; } tmp_url = create_url(); if (parse_url(url, tmp_url) == -1) { fprintf(stderr, "Error: Parsing URL '%s'\n", url); free_url(tmp_url); return NULL; } if ((proxy = getenv("HTTP_PROXY")) != NULL) { proxy_url = create_url(); if (parse_url(proxy, proxy_url) == -1) { fprintf(stderr, "Error: Parsing proxy URL '%s'\n", proxy); free_url(tmp_url); free_url(proxy_url); return NULL; } sockfd = client_tconnect(proxy_url->host, atoi(proxy_url->port), timeout); if (sockfd == -1) { if ((timeout != NULL) && (orig_timeout != *timeout) && (*timeout == 0)) { fprintf(stderr, "Error: Timeout expired connecting to '%s:%s'\n", proxy_url->host, proxy_url->port); } else { fprintf(stderr, "Error: connecting to '%s:%s'\n", proxy_url->host, proxy_url->port); } free_url(tmp_url); free_url(proxy_url); return NULL; } free_url(proxy_url); } else { sockfd = client_connect(tmp_url->host, atoi(tmp_url->port)); if (sockfd == -1) { if ((timeout != NULL) && (orig_timeout != *timeout) && (*timeout == 0)) { fprintf(stderr, "Error: Timeout expired connecting to '%s:%s'\n", tmp_url->host, tmp_url->port); } else { fprintf(stderr, "Error: connecting to '%s:%s'\n", tmp_url->host, tmp_url->port); } free_url(tmp_url); return NULL; } } /* Send the request for the page. */ /* Using HTTP protocol version 1.0 */ sprintf(tmp_buf, "%s http://%s:%s%s HTTP/1.0\r\n", method, tmp_url->host, tmp_url->port, tmp_url->document); strcat(send_buf, tmp_buf); #if 0 sprintf(tmp_buf, "User-Agent: %s\r\n", "unknown"); strcat(send_buf, tmp_buf); #endif #if 0 if (proxy != NULL) { /* Send proxy related data. */ sprintf(tmp_buf, "HOST: %s:%s\r\n", tmp_url->host, tmp_url->port); strcat(send_buf, tmp_buf); } #endif if (data != NULL) { /* Send data appropriate to method. */ /* POST or GET */ if (strcmp(method, "GET") == 0) { fprintf(stderr, "Error: Data supplied whilst method is 'GET'\n"); free_url(tmp_url); return NULL; } else if (strcmp(method, "POST") == 0) { sprintf(tmp_buf, "Content-length: %d\r\n", strlen(data)); strcat(send_buf, tmp_buf); } else { fprintf(stderr, "Error: Data supplied whilst using Unsupport Method '%s'\n", method); free_url(tmp_url); return NULL; } } if (authentication != NULL) { /* Send Authentication. */ /* Base64 Encode 'username:password' */ auth = encodeBase64(authentication); if (auth != NULL) { sprintf(tmp_buf, "Authorization: Basic %s\r\n", auth); strcat(send_buf, tmp_buf); free(auth); } else { fprintf(stderr, "Error: Building authentication data\n"); free_url(tmp_url); return NULL; } } strcat(send_buf, "\r\n"); if (data != NULL) { strcat(send_buf, data); } send_buflen = strlen(send_buf); bytes_written = twrite(sockfd, send_buf, send_buflen, timeout); if (bytes_written != send_buflen) { /* An error ocurred during write */ if ((timeout != NULL) && (orig_timeout != *timeout) && (*timeout == 0)) { fprintf(stderr, "Error: Timeout expired while Sending data to server\n"); } else { fprintf(stderr, "Error: Sending data to server\n"); } } else { mdata = tslurp(sockfd, data_len, timeout); if (mdata == NULL) { if ((timeout != NULL) && (orig_timeout != *timeout) && (*timeout == 0)) { fprintf(stderr, "Error: Timeout expired while Receiving data from server\n"); } else { fprintf(stderr, "Error: Receiving data from server\n"); } } } client_disconnect(sockfd); free_url(tmp_url); return mdata; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *escape_input(char *src) { char *buf, *dst, *table = "0123456789ABCDEF"; int high, low; buf = (char *)malloc(sizeof(char) * (strlen(src) +1)); if (buf == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } dst = buf; while(*src != '\0') { if (isalnum(*src)) { *dst++ = *src; } else if (*src == ' ') { *dst++ = '+'; } else { low = *src % 16; high = ((int)(*src / 16 )) % 16; *dst++ = '%'; *dst++ = table[high]; *dst++ = table[low]; } src++; } *dst = '\0'; return buf; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void usage(void) { fprintf(stderr,"Usage: message \n"); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ /* POST http://www.mtnsms.com/sms.asp HTTP/1.0 favs=&msgTo=%2B46709654321&msgText=this+is+a+test&msgCL=143&msgSig=0&butSUB=++++send++++&lenSSig=6&lenLSig=21&lenSysSig=11 */ int main(int argc, char *argv[]) { int document_len, i; char *src, *dst, *url, data[1024], *document, *ptr, *msg, num[512], *ac, *atmo, *rtmo, *prefix, *selectedintlprefix; if (argc != 3) { usage(); exit(1); } /* ---------------------------------------- */ url = "http://www.mtnsms.com/sms.asp"; /* ---------------------------------------- */ sprintf(num, "%%2B%s", argv[1]); msg = escape_input(argv[2]); if (msg == NULL) { exit(1); } sprintf(data, "favs=&msgTo=%s&msgText=%s&msgCL=143&msgSig=0&butSUB=++++send++++&lenSSig=6&lenLSig=21&lenSysSig=11", num, msg); free(num); free(msg); if (getenv("MTNDEBUG") != NULL) { fprintf(stderr, "DEBUG: Sending '%s'\n", data); } /* ---------------------------------------- */ document = get_document(url, &document_len, "POST", data, NULL, NULL); if (document != NULL) { if (getenv("MTNDEBUG") != NULL) { printf("%s", document); } if (strstr(document, "spodrod") != NULL) { printf("Your message has been successfully queued for transmission\n"); } else if (strstr(document, "spodrod") != NULL) { fprintf(stderr, "Error: Trying to Deliver message - didn't like your submission\n"); exit(1); } else { fprintf(stderr, "Error: Trying to Deliver message - Unexpected response\n"); exit(1); } free(document); } else { fprintf(stderr, "Error: Trying to Deliver message - Failed to connect\n"); exit(1); } return 0; } smsclient-2.0.8z/src/driver/answer.c0000644000175000017500000003277110127274505017346 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* answer.c */ /* */ /* Copyright (C) 1998,1999 Paul Andrew */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* paul.andrew@optimation.co.nz */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static struct answer_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ char *szPassword; } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 1200, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_STRING, "SMS_password", 0, 1, NULL, 0, "xxx", 0, &(driver_env.szPassword) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static char ANSWER_charset[] = { 0x20 /* 0x00 */, 0x20 /* 0x01 */, 0x20 /* 0x02 */, 0x20 /* 0x03 */, 0x20 /* 0x04 */, 0x20 /* 0x05 */, 0x20 /* 0x06 */, 0x20 /* 0x07 */, 0x20 /* 0x08 */, 0x20 /* 0x09 */, 0x0A /* 0x0A LF */, 0x20 /* 0x0B */, 0x20 /* 0x0C */, 0x0A /* 0x0D LF */, 0x20 /* 0x0E */, 0x20 /* 0x0F */, 0x20 /* 0x10 */, 0x20 /* 0x11 */, 0x20 /* 0x12 */, 0x20 /* 0x13 */, 0x20 /* 0x14 */, 0x20 /* 0x15 */, 0x20 /* 0x16 */, 0x20 /* 0x17 */, 0x20 /* 0x18 */, 0x20 /* 0x19 */, 0x20 /* 0x1A */, 0x20 /* 0x1B */, 0x20 /* 0x1C */, 0x20 /* 0x1D */, 0x20 /* 0x1E */, 0x20 /* 0x1F */, 0x20 /* 0x20 */, 0x21 /* 0x21 ! */, 0x22 /* 0x22 " */, 0x23 /* 0x23 # */, 0x24 /* 0x24 $ */, 0x25 /* 0x25 % */, 0x26 /* 0x26 & */, 0x27 /* 0x27 ' */, 0x28 /* 0x28 ( */, 0x29 /* 0x29 ) */, 0x2A /* 0x2A * */, 0x2B /* 0x2B + */, 0x2C /* 0x2C , */, 0x2D /* 0x2D - */, 0x2E /* 0x2E . */, 0x2F /* 0x2F / */, 0x30 /* 0x30 0 */, 0x31 /* 0x31 1 */, 0x32 /* 0x32 2 */, 0x33 /* 0x33 3 */, 0x34 /* 0x34 4 */, 0x35 /* 0x35 5 */, 0x36 /* 0x36 6 */, 0x37 /* 0x37 7 */, 0x38 /* 0x38 8 */, 0x39 /* 0x39 9 */, 0x3A /* 0x3A : */, 0x3B /* 0x3B ; */, 0x3C /* 0x3C < */, 0x3D /* 0x3D = */, 0x3E /* 0x3E > */, 0x3F /* 0x3F ? */, 0x40 /* 0x40 @ */, 0x41 /* 0x41 A */, 0x42 /* 0x42 B */, 0x43 /* 0x43 C */, 0x44 /* 0x44 D */, 0x45 /* 0x45 E */, 0x46 /* 0x46 F */, 0x47 /* 0x47 G */, 0x48 /* 0x48 H */, 0x49 /* 0x49 I */, 0x4A /* 0x4A J */, 0x4B /* 0x4B K */, 0x4C /* 0x4C L */, 0x4D /* 0x4D M */, 0x4E /* 0x4E N */, 0x4F /* 0x4F O */, 0x50 /* 0x50 P */, 0x51 /* 0x51 Q */, 0x52 /* 0x52 R */, 0x53 /* 0x53 S */, 0x54 /* 0x54 T */, 0x55 /* 0x55 U */, 0x56 /* 0x56 V */, 0x57 /* 0x57 W */, 0x58 /* 0x58 X */, 0x59 /* 0x59 Y */, 0x5A /* 0x5A Z */, 0x20 /* 0x5B */, 0x20 /* 0x5C */, 0x20 /* 0x5D */, 0x20 /* 0x5E */, 0x20 /* 0x5F */, 0x20 /* 0x60 */, 0x61 /* 0x61 a */, 0x62 /* 0x62 b */, 0x63 /* 0x63 c */, 0x64 /* 0x64 d */, 0x65 /* 0x65 e */, 0x66 /* 0x66 f */, 0x67 /* 0x67 g */, 0x68 /* 0x68 h */, 0x69 /* 0x69 i */, 0x6A /* 0x6A j */, 0x6B /* 0x6B k */, 0x6C /* 0x6C l */, 0x6D /* 0x6D m */, 0x6E /* 0x6E n */, 0x6F /* 0x6F o */, 0x70 /* 0x70 p */, 0x71 /* 0x71 q */, 0x72 /* 0x72 r */, 0x73 /* 0x73 s */, 0x74 /* 0x74 t */, 0x75 /* 0x75 u */, 0x76 /* 0x76 v */, 0x77 /* 0x77 w */, 0x78 /* 0x78 x */, 0x79 /* 0x79 y */, 0x7A /* 0x7A z */, 0x20 /* 0x7B */, 0x20 /* 0x7C */, 0x20 /* 0x7D */, 0x20 /* 0x7E */, 0x20 /* 0x7F */, 0x20 /* 0x80 */, 0x20 /* 0x81 */, 0x20 /* 0x82 */, 0x20 /* 0x83 */, 0x20 /* 0x84 */, 0x20 /* 0x85 */, 0x20 /* 0x86 */, 0x20 /* 0x87 */, 0x20 /* 0x88 */, 0x20 /* 0x89 */, 0x20 /* 0x8A */, 0x20 /* 0x8B */, 0x20 /* 0x8C */, 0x20 /* 0x8D */, 0x20 /* 0x8E */, 0x20 /* 0x8F */, 0x20 /* 0x90 */, 0x20 /* 0x91 */, 0x20 /* 0x92 */, 0x20 /* 0x93 */, 0x20 /* 0x94 */, 0x20 /* 0x95 */, 0x20 /* 0x96 */, 0x20 /* 0x97 */, 0x20 /* 0x98 */, 0x20 /* 0x99 */, 0x20 /* 0x9A */, 0x20 /* 0x9B */, 0x20 /* 0x9C */, 0x20 /* 0x9D */, 0x20 /* 0x9E */, 0x20 /* 0x9F */, 0x20 /* 0xA0 */, 0x20 /* 0xA1 */, 0x20 /* 0xA2 */, 0x20 /* 0xA3 */, 0x20 /* 0xA4 */, 0x20 /* 0xA5 */, 0x20 /* 0xA6 */, 0x20 /* 0xA7 */, 0x20 /* 0xA8 */, 0x20 /* 0xA9 */, 0x20 /* 0xAA */, 0x20 /* 0xAB */, 0x20 /* 0xAC */, 0x20 /* 0xAD */, 0x20 /* 0xAE */, 0x20 /* 0xAF */, 0x20 /* 0xB0 */, 0x20 /* 0xB1 */, 0x20 /* 0xB2 */, 0x20 /* 0xB3 */, 0x20 /* 0xB4 */, 0x20 /* 0xB5 */, 0x20 /* 0xB6 */, 0x20 /* 0xB7 */, 0x20 /* 0xB8 */, 0x20 /* 0xB9 */, 0x20 /* 0xBA */, 0x20 /* 0xBB */, 0x20 /* 0xBC */, 0x20 /* 0xBD */, 0x20 /* 0xBE */, 0x20 /* 0xBF */, 0x20 /* 0xC0 */, 0x20 /* 0xC1 */, 0x20 /* 0xC2 */, 0x20 /* 0xC3 */, 0x20 /* 0xC4 */, 0x20 /* 0xC5 */, 0x20 /* 0xC6 */, 0x20 /* 0xC7 */, 0x20 /* 0xC8 */, 0x20 /* 0xC9 */, 0x20 /* 0xCA */, 0x20 /* 0xCB */, 0x20 /* 0xCC */, 0x20 /* 0xCD */, 0x20 /* 0xCE */, 0x20 /* 0xCF */, 0x20 /* 0xD0 */, 0x20 /* 0xD1 */, 0x20 /* 0xD2 */, 0x20 /* 0xD3 */, 0x20 /* 0xD4 */, 0x20 /* 0xD5 */, 0x20 /* 0xD6 */, 0x20 /* 0xD7 */, 0x20 /* 0xD8 */, 0x20 /* 0xD9 */, 0x20 /* 0xDA */, 0x20 /* 0xDB */, 0x20 /* 0xDC */, 0x20 /* 0xDD */, 0x20 /* 0xDE */, 0x20 /* 0xDF */, 0x20 /* 0xE0 */, 0x20 /* 0xE1 */, 0x20 /* 0xE2 */, 0x20 /* 0xE3 */, 0x20 /* 0xE4 */, 0x20 /* 0xE5 */, 0x20 /* 0xE6 */, 0x20 /* 0xE7 */, 0x20 /* 0xE8 */, 0x20 /* 0xE9 */, 0x20 /* 0xEA */, 0x20 /* 0xEB */, 0x20 /* 0xEC */, 0x20 /* 0xED */, 0x20 /* 0xEE */, 0x20 /* 0xEF */, 0x20 /* 0xF0 */, 0x20 /* 0xF1 */, 0x20 /* 0xF2 */, 0x20 /* 0xF3 */, 0x20 /* 0xF4 */, 0x20 /* 0xF5 */, 0x20 /* 0xF6 */, 0x20 /* 0xF7 */, 0x20 /* 0xF8 */, 0x20 /* 0xF9 */, 0x20 /* 0xFA */, 0x20 /* 0xFB */, 0x20 /* 0xFC */, 0x20 /* 0xFD */, 0x20 /* 0xFE */, 0x20 /* 0xFF */ }; /* -------------------------------------------------------------------- */ static char *ACK2 = "PACNET"; static char *ACK3 = "PORT"; static char *ACK4 = "Welcome to AnswerPage"; static char *ACK5 = "ID"; static char *ACK6 = "?00"; static char *ACK7 = "or CLR to Exit"; static char *ACK8 = "?90"; static char *ACK9 = "?92"; static char *REQ2 = "-9700000301\r"; static char *REQ3 = "@"; static char *REQ4 = "CLR\r"; static char *REQ5 = "\r"; /* -------------------------------------------------------------------- */ static void ANSWER_buildmessage(char *, char *, char *); static int ANSWER_login(void); static int ANSWER_sendmessage(char *msisdn, char *message); static void ANSWER_hangup(void); static int ANSWER_send_disconnect(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void ANSWER_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int ANSWER_send_disconnect(void) { char buf[MAX_RESPONSE_BUFSIZE]; lprintf(LOG_STANDARD, "Disconnect...\n"); twrite(FD, REQ4, strlen(REQ4), TIMEOUT); if (expstr(FD, buf, ACK9, MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0) { lprintf(LOG_STANDARD, "Disconnected from answer services\n"); } else { lprintf(LOG_STANDARD, "Failed to disconnect from answer services\n"); ANSWER_hangup(); return EANSWER_NODISCONNECT; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int ANSWER_login(void) { char buf[MAX_RESPONSE_BUFSIZE]; lprintf(LOG_STANDARD, "Login...\n"); if (expstr(FD, buf, ACK2, MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) != 0 || expstr(FD, buf, ACK3, MAX_RESPONSE_BUFSIZE, TIMEOUT) != 0) { lprintf(LOG_STANDARD, "Pacnet prompt not received\n"); ANSWER_hangup(); return EANSWER_NOACK; } if (strcmp (driver_env.szPassword, "xxx") == 0) { strcpy (buf, "R"); } else { strcpy (buf, "N"); strcat (buf, driver_env.szPassword); } strcat (buf, REQ2); twrite(FD, buf, strlen(buf), TIMEOUT); if (expstr(FD, buf, ACK4, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0 && expstr(FD, buf, ACK5, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Login successful\n"); } else { lprintf(LOG_STANDARD, "Login failed\n"); ANSWER_hangup(); return EANSWER_NOLOGIN; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void ANSWER_buildmessage(char *answer_message, char *msisdn, char *message) { int i; char *ptr; /* ---------------------------- */ answer_message[0] = '\0'; strcat(answer_message, msisdn); strcat(answer_message, REQ3); /* Convert message so that it contains */ /* only ANSWER valid characters */ /* any invalid characters will be */ /* mapped to a SPACE */ /* Add to answer_message */ ptr = answer_message; while(*ptr != '\0') { ptr++; } for (i=0; i 4) { lprintf(LOG_STANDARD, "Pager number too long\n"); return EMESSAGETOOLONG; } if (strlen (message) > 160) { lprintf(LOG_STANDARD, "Pager message too long\n"); return EMESSAGETOOLONG; } ANSWER_buildmessage(req_message, msisdn, message); twrite(FD, req_message, strlen(req_message), TIMEOUT); if (expstr(FD, buf, ACK6, strlen (ACK6), DELIVERTIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Response\n"); } else { if (strncmp (buf, ACK8, strlen (ACK8)) == 0) { lprintf(LOG_STANDARD, "Invalid pager number\n"); } else { lprintf(LOG_STANDARD, "Pager message failed: %s\n", buf); ANSWER_hangup(); return EANSWER_NODELIVERY; } } if (expstr(FD, buf, ACK7, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received text too\n"); } else { lprintf(LOG_STANDARD, "Text not received\n"); } return 0; } /* -------------------------------------------------------------------- */ /* The following structure is used by core driver code. */ /* The diagram below shows the call sequence of the functions. */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY answer_device = { "ANSWER", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, /* Init */ default_main, /* Main */ default_validate_numeric_id, /* Validation */ default_dial, /* Dial */ default_hangup, /* Hangup */ ANSWER_send_disconnect, /* Disconnect */ default_single_deliver, /* Deliver */ ANSWER_sendmessage, /* Send */ ANSWER_login /* Login */ }; smsclient-2.0.8z/src/driver/sms.c0000644000175000017500000001571010127274506016644 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* snpp.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static struct sms_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_STRING, "SMS_server_name", 0, 1, NULL, 0, "localhost", 0, &(driver_env.def.server_name) }, { RESOURCE_NUMERIC, "SMS_server_port", 0, 1, NULL, 0, NULL, 444, &(driver_env.def.server_port) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int SMS_login(void); static int SMS_sendmessage(char *msisdn, char *message); static int SMS_send_disconnect(void); static void SMS_hangup(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int SMS_login(void) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, "\n", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { if (strncmp(buf, "200", 3) == 0) { lprintf(LOG_STANDARD, "SMS Service Login\n"); lprintf(LOG_VERBOSE, "SMS Response: %s", buf); } else { lprintf(LOG_STANDARD, "SMS Service Login Failed - Bad response\n"); SMS_hangup(); return ESMS_NORESPONSE; } } else { lprintf(LOG_STANDARD, "SMS Service Login Failed\n"); SMS_hangup(); return ESMS_NORESPONSE; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int SMS_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE]; twrite(FD, "USER test\n", strlen("USER test\n"), WRITETIMEOUT); if (expstr(FD, buf, "\n", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { if (strncmp(buf, "210", 3) == 0) { } else { SMS_hangup(); return ESMS_NONUMBER; } } else { SMS_hangup(); return ESMS_NONUMBER; } twrite(FD, "MESS ", strlen("MESS "), WRITETIMEOUT); twrite(FD, message, strlen(message), WRITETIMEOUT); twrite(FD, "\n", strlen("\n"), WRITETIMEOUT); if (expstr(FD, buf, "\n", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { if (strncmp(buf, "250", 3) == 0) { lprintf(LOG_STANDARD, "Message Accepted\n"); lprintf(LOG_VERBOSE, "SMS Response: %s", buf); } else { lprintf(LOG_STANDARD, "Message NOT Accepted\n"); SMS_hangup(); return ESMS_NOMESSAGE; } } else { lprintf(LOG_STANDARD, "Message NOT Accepted\n"); SMS_hangup(); return ESMS_NOMESSAGE; } twrite(FD, "SEND\n", strlen("SEND\n"), WRITETIMEOUT); if (expstr(FD, buf, "\n", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { if (strncmp(buf, "250", 3) == 0) { lprintf(LOG_STANDARD, "Message Sent\n"); lprintf(LOG_VERBOSE, "SMS Response: %s", buf); } else { lprintf(LOG_STANDARD, "Message NOT Sent\n"); SMS_hangup(); return ESMS_NODELIVERY; } } else { lprintf(LOG_STANDARD, "Message NOT Sent\n"); SMS_hangup(); return ESMS_NODELIVERY; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int SMS_send_disconnect(void) { char buf[MAX_RESPONSE_BUFSIZE]; twrite(FD, "QUIT\n", strlen("QUIT\n"), WRITETIMEOUT); if (expstr(FD, buf, "\n", MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { if (strncmp(buf, "221", 3) == 0) { lprintf(LOG_STANDARD, "Sent Diconnection\n"); lprintf(LOG_VERBOSE, "SMS Response: %s", buf); } else { lprintf(LOG_STANDARD, "Failed to send Disconnection\n"); SMS_hangup(); return ESMS_NODISCONNECT; } } else { lprintf(LOG_STANDARD, "Failed to send Disconnection\n"); SMS_hangup(); return ESMS_NODISCONNECT; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void SMS_hangup(void) { TCPIP_disconnect(FD); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY sms_device = { "SMS", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_always_true, default_tcpip_connect, default_tcpip_disconnect, SMS_send_disconnect, default_single_deliver, SMS_sendmessage, SMS_login }; smsclient-2.0.8z/src/driver/ucp_tcp.c0000644000175000017500000002106010127274506017472 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* ucp_tcp.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "ascii.h" #include "ia5table.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static struct ucp_tcp_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ char *ipaddress, *password; } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_STRING, "SMS_ipaddress", 0, 1, NULL, 0, "", 0, &(driver_env.ipaddress) }, { RESOURCE_STRING, "SMS_password", 0, 1, NULL, 0, "", 0, &(driver_env.password) }, { RESOURCE_STRING, "SMS_server_name", 0, 1, NULL, 0, "localhost", 0, &(driver_env.def.server_name) }, { RESOURCE_NUMERIC, "SMS_server_port", 0, 1, NULL, 0, NULL, 500, &(driver_env.def.server_port) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #include "libucp.c" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int UCP_TCP_init(char *mservice, DEVICE_ENTRY *device); static int UCP_TCP_login(void); static int UCP_TCP_sendmessage(char *msisdn, char *message); static void UCP_TCP_hangup(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int UCP_TCP_init(char *mservice, DEVICE_ENTRY *device) { char *ptr; int addr[4]; if ( default_init(mservice, device) == -1 ) { return -1; } if ( sscanf(driver_env.ipaddress, "%3d.%3d.%3d.%3d", &addr[0], &addr[1], &addr[2], &addr[3]) == 4 ) { sprintf(driver_env.ipaddress, "%3.3d%3.3d%3.3d%3.3d", addr[0], addr[1], addr[2], addr[3]); } else { lprintf(LOG_ERROR, "IP Address in incorrect format\n"); return -1; } /* ------------------------------------ */ /* Convert password to ia5 format */ /* ------------------------------------ */ ptr = driver_env.password; while (*ptr != '\0') { *ptr = toia5(*ptr); ptr++; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int UCP_TCP_login(void) { char buf[MAX_RESPONSE_BUFSIZE], *ucpMessage, *ptr; int result; /* ------------------------------------ */ /* Convert password to ia5 format */ /* ------------------------------------ */ ptr = driver_env.password; while (*ptr != '\0') { *ptr = toia5(*ptr); ptr++; } /* ------------------------------------ */ ucpMessage = UCP_CallInputOp60( driver_env.ipaddress, driver_env.password ); twrite(FD, ucpMessage, strlen(ucpMessage), WRITETIMEOUT); if( expstr(FD, buf, "\03", MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0) { lprintf(LOG_STANDARD, "SMSC Login Respsonse: %s\n", buf); result = UCP_parse_response(buf); if (result == 0) { lprintf(LOG_STANDARD, "Login accepted\n"); } else if(result == 1) { lprintf(LOG_ERROR, "Login rejected\n"); UCP_TCP_hangup(); return EUCP_ACKFAILED; } else { lprintf(LOG_ERROR, "Bad Login acknowledgement\n"); UCP_TCP_hangup(); return EUCP_BADACK; } } else { lprintf(LOG_ERROR, "No Login Response\n"); UCP_TCP_hangup(); return EUCP_NORESPONSE; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int UCP_TCP_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE], *ucpMessage, *msg; int result; /* ------------------------------------ */ /* Convert message to ia5 format */ /* This should be done prior to */ /* entering this function. */ /* ------------------------------------ */ msg = message; while (*msg != '\0') { *msg = toia5(*msg); msg++; } /* ------------------------------------ */ #if 0 ucpMessage = UCP_CallInputOp01(msisdn, message); #else ucpMessage = UCP_CallInputOp51(msisdn, message, driver_env.ipaddress); #endif twrite(FD, ucpMessage, strlen(ucpMessage), WRITETIMEOUT); if( expstr(FD, buf, "\03", MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0) { lprintf(LOG_STANDARD, "SMSC Respsonse: %s\n", buf); result = UCP_parse_response(buf); if (result == 0) { lprintf(LOG_STANDARD, "Message accepted\n"); } else if(result == 1) { lprintf(LOG_ERROR, "Message rejected\n"); UCP_TCP_hangup(); return EUCP_ACKFAILED; } else { lprintf(LOG_ERROR, "Bad message acknowledgement\n"); UCP_TCP_hangup(); return EUCP_BADACK; } } else { lprintf(LOG_ERROR, "No Message Response\n"); UCP_TCP_hangup(); return EUCP_NORESPONSE; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void UCP_TCP_hangup(void) { TCPIP_disconnect(FD); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY ucp_tcp_device = { "UCP_TCP", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), UCP_TCP_init, default_main, default_validate_always_true, default_tcpip_connect, default_tcpip_disconnect, default_send_disconnect, default_single_deliver, UCP_TCP_sendmessage, UCP_TCP_login }; smsclient-2.0.8z/src/driver/skeleton.c0000644000175000017500000001756710127274506017702 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* skeleton.c */ /* */ /* Copyright (C) 1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static char ACK1[] = "Welecome to Skeleton Server\r\n"; static char ACK2[] = "Enter you number\r\n"; static char ACK3[] = "Enter you message\r\n"; static char ACK4[] = "Thank You.\r\n"; /* -------------------------------------------------------------------- */ /* The 'env' structure contains Service level data to be used for */ /* sending a message. */ /* -------------------------------------------------------------------- */ static struct skeleton_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 1200, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.max_deliver) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ /* The following defines are used to signify errors */ /* occuring during the dialogue between the driver and the */ /* service centre. This number will be returned as the delivery */ /* value for the message that was aborted */ /* */ /* The defines MUST be placed in 'error.h' */ #define ESKELETON_NONUMBER 250 #define ESKELETON_NOMESSAGE 251 #define ESKELETON_NODELIVERY 252 /* -------------------------------------------------------------------- */ static void SKELETON_hangup(void); static int SKELETON_sendmessage(char *msisdn, char *message); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void SKELETON_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int SKELETON_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, ACK2, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Number Request\n"); } else { lprintf(LOG_STANDARD, "No Number Request\n"); SKELETON_hangup(); return ESKELETON_NONUMBER; } twrite(FD, msisdn, strlen(msisdn), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); if (expstr(FD, buf, ACK3, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Request\n"); } else { lprintf(LOG_STANDARD, "No Message Request\n"); SKELETON_hangup(); return ESKELETON_NOMESSAGE; } twrite(FD, message, strlen(message), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); if (expstr(FD, buf, ACK4, MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Delivery Response\n"); } else { lprintf(LOG_STANDARD, "No Message Delivery Response\n"); SKELETON_hangup(); return ESKELETON_NODELIVERY; } return 0; } /* -------------------------------------------------------------------- */ /* The following structure is used by core driver code. */ /* The diagram below shows the call sequence of the functions. */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY skeleton_device = { "SKELETON", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, /* Init */ default_main, /* Main */ default_validate_numeric_id, /* Validation */ default_dial, /* Dial */ default_hangup, /* Hangup */ default_send_disconnect, /* Disconnect */ default_single_deliver, /* Deliver */ SKELETON_sendmessage, /* Send */ default_login /* Login */ }; /* -------------------------------------------------------------------- */ /* */ /* ---------- */ /* | Main | */ /* ----+----- */ /* | */ /* | */ /* | For Each Addressed Message */ /* -----+----- */ /* | Deliver | */ /* -----+----- */ /* | */ /* +----+------+----------+-------------+--------------+ */ /* | | | | | */ /* ---+---- ----+---- ---+---- ------+------- ----+----- */ /* | Dial | | Login | | Send | | Disconnect | | Hangup | */ /* -------- --------- -------- -------------- ---------- */ /* */ /* */ /* Note. Your driver can supply functions to be used in place of */ /* all the default_driver functions. */ /* */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/driver/one2one.c0000644000175000017500000001513010127274506017403 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* one2one.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id: one2one.c,v 5.1 1998/02/01 07:10:39 root Exp root $ -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static char ACK1[] = "ID="; static char ACK2[] = "Welcome to the One 2 One Short Message Service\r\n"; static char ACK3[] = "Password: "; static char ACK4[] = "Please enter below the message you wish to send\r\n"; static char ACK5[] = "Enter the One 2 One phone number to receive your message: "; static char ACK6[] = "Goodbye (you should hangup now)"; /* -------------------------------------------------------------------- */ static struct one2one_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "7E1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 1200, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.max_deliver) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static void ONE2ONE_hangup(void); static int ONE2ONE_login(void); static int ONE2ONE_sendmessage(char *msisdn, char *message); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int ONE2ONE_login(void) { char buf[MAX_RESPONSE_BUFSIZE]; twrite(FD, "\r", strlen("\r"), WRITETIMEOUT); if (expstr(FD, buf, ACK1, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received one2one ID Request\n"); } else { lprintf(LOG_STANDARD, "No one2one ID Request\n"); ONE2ONE_hangup(); return EONE2ONE_NORESPONSE; } twrite(FD, "A\r", strlen("A\r"), WRITETIMEOUT); if (expstr(FD, buf, ACK2, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received one2one Welcome\n"); } else { lprintf(LOG_STANDARD, "No one2one Welcome\n"); ONE2ONE_hangup(); return EONE2ONE_NORESPONSE; } if (expstr(FD, buf, ACK3, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received one2one Password Request\n"); } else { lprintf(LOG_STANDARD, "No one2one Password Request\n"); ONE2ONE_hangup(); return EONE2ONE_NORESPONSE; } twrite(FD, "\r", strlen("\r"), WRITETIMEOUT); return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int ONE2ONE_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, ACK4, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received one2one Message Request\n"); } else { lprintf(LOG_STANDARD, "No one2one Message Request\n"); ONE2ONE_hangup(); return EONE2ONE_NONUMBER; } twrite(FD, message, strlen(message), WRITETIMEOUT); twrite(FD, "\r", strlen("\r"), WRITETIMEOUT); if (expstr(FD, buf, ACK5, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Number Request\n"); } else { lprintf(LOG_STANDARD, "No Number Request\n"); ONE2ONE_hangup(); return EONE2ONE_NOMESSAGE; } twrite(FD, msisdn, strlen(msisdn), WRITETIMEOUT); twrite(FD, "\r", strlen("\r"), WRITETIMEOUT); if (expstr(FD, buf, ACK6, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Delivery Response\n"); } else { lprintf(LOG_STANDARD, "No Message Delivery Response\n"); ONE2ONE_hangup(); return EONE2ONE_NODELIVERY; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void ONE2ONE_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY one2one_device = { "ONE2ONE", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, default_dial, default_hangup, default_send_disconnect, default_multiple_counted_deliver, ONE2ONE_sendmessage, ONE2ONE_login }; smsclient-2.0.8z/src/driver/driver.c0000644000175000017500000003056310460430317017332 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* driver.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id: driver.c,v 5.1 1998/02/01 07:10:39 root Exp $ -------------------------------------------------------------------- */ #include #include #include #include #if defined(MODEMLIB) && (MODEMLIB == LIBMODEM) #include #include #else #include "comms/comms.h" #endif #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "driver_comms.h" #include "error.h" #include "parser/gs_translate.h" /* -------------------------------------------------------------------- */ #if !defined(MSERVICEDIR) #error "MSERVICEDIR undefined" #else #define SERVICEDIR MSERVICEDIR #endif #if !defined(MLIBDIR) #error "MLIBDIR undefined" #else #define LIBDIR MLIBDIR #endif /* -------------------------------------------------------------------- */ /* The 'device_list' is simply and array of pointer to device entry */ /* structures. If you write a new device you MUST add it's */ /* device structure to this list. */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY *device_list[] = { #if defined(TAP) &tap_device, #endif #if defined(VODAFONE) &vodafone_device, #endif #if defined(ORANGE) &orange_device, #endif #if defined(PAGEONE) &pageone_device, #endif #if defined(VODACOM) &vodacom_device, #endif #if defined(MTN) &mtn_device, #endif #if defined(ONE2ONE) &one2one_device, #endif #if defined(LIBERTEL) &libertel_device, #endif #if defined(TIM) &tim_device, #endif #if defined(SNPP) &snpp_device, #endif #if defined(CIMD) &cimd_device, #endif #if defined(VODAPAGE_BLOCK) &vodapage_block_device, #endif #if defined(PROXIMUS) &proximus_device, #endif #if defined(KPN) &kpn_device, #endif #if defined(ANSWER) &answer_device, #endif #if defined(GENERIC) &generic_device, #endif #if defined(UCP) &ucp_device, #endif #if defined(UCP_TCP) &ucp_tcp_device, #endif #if defined(WWW) &www_device, #endif #if defined(ORANGE_WEB) &orange_web_device, #endif #if defined(CELLNET_WEB) &cellnet_web_device, #endif #if defined(PROXIMUS_WEB) &proximus_web_device, #endif #if defined(ATT_WEB) &att_web_device, #endif #if defined(NEXTEL_WEB) &nextel_web_device, #endif #if defined(PAGENET_WEB) &pagenet_web_device, #endif #if defined(MOBISTAR) &mobistar_device, #endif NULL }; /* -------------------------------------------------------------------- */ /* Return a device entry structure by supplying its name. */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY *get_device(char *name) { DEVICE_ENTRY **device; if (name == NULL) { return NULL; } device = device_list; while (*device != NULL) { if ((*device)->name != NULL) { if (strcmp((*device)->name, name) == 0) { lprintf(LOG_VERBOSE, "Device Found: %s\n", name); return *device; } } device++; } lprintf(LOG_VERBOSE, "Device NOT Found: %s\n", name); return NULL; } /* -------------------------------------------------------------------- */ /* List all the device entries currently compiled in. */ /* -------------------------------------------------------------------- */ void display_drivers(void) { DEVICE_ENTRY **device; device = device_list; if (*device == NULL) { lprintf(LOG_WARNING, "No drivers have been included!\n"); } while (*device != NULL) { lprintf(LOG_STANDARD, "%s %s\n", ((*device)->name != NULL)?(*device)->name:"", ((*device)->version_string != NULL)?(*device)->version_string:""); device++; } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int default_dial(DRIVER_DEFAULT_ENV *env) { lprintf(LOG_STANDARD, "Dialing SMSC %s...\n", env->centre_number); env->fd = SMS_dial(env->centre_number, env->comms_params, env->baud); if (env->fd < 0) { lprintf(LOG_WARNING, "Failed to connect\n"); return EDIAL; } lprintf(LOG_STANDARD, "Connection Established.\n"); return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int default_tcpip_connect(DRIVER_DEFAULT_ENV *env) { lprintf(LOG_STANDARD, "Connecting to Server %s:%ld...\n", env->server_name, env->server_port); env->fd = TCPIP_connect(env->server_name, env->server_port); if (env->fd < 0) { lprintf(LOG_WARNING, "Failed to Connect.\n"); return EDIAL; } lprintf(LOG_STANDARD, "Connection Established.\n"); return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void default_tcpip_disconnect(DRIVER_DEFAULT_ENV *env) { lprintf(LOG_STANDARD, "Disconnecting...\n"); TCPIP_disconnect(env->fd); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void default_hangup(DRIVER_DEFAULT_ENV *env) { lprintf(LOG_STANDARD, "Hangup...\n"); SMS_hangup(env->fd); env->connection_status = SERVICE_NOT_CONNECTED; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void default_main(void *list, void *(* get_first)(void *list), void *(* get_next)(void *list), char *(* get_number)(void *node), char *(* get_message)(void *node), void (* set_delivery)(void *node, int result), DRIVER_DEFAULT_ENV *env) { void *node; char *msisdn, *message; int result; lprintf(LOG_VERBOSE, "%s %s driver called\n", (env->device->name != NULL)?env->device->name:"", (env->device->version_string != NULL)?env->device->version_string:""); env->connection_status = SERVICE_NOT_CONNECTED; result = 0; node = (* get_first)(list); while (node != NULL) { msisdn = (* get_number)(node); message = (* get_message)(node); result = (* env->device->deliver)(msisdn, message, env); (* set_delivery)(node, result); if (result) { (* env->device->hangup)(env); env->connection_status = SERVICE_NOT_CONNECTED; } node = (* get_next)(node); } if ((result == 0) && (env->connection_status == SERVICE_CONNECTED)) { (* env->device->disconnect)(); (* env->device->hangup)(env); env->connection_status = SERVICE_NOT_CONNECTED; } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int default_multiple_deliver(char *msisdn, char *message, DRIVER_DEFAULT_ENV *env) { int error; if (env->connection_status == SERVICE_NOT_CONNECTED) { env->connection_status = SERVICE_CONNECTED; error = (* env->device->dial)(env); if (error) { return error; } error = (* env->device->login)(); if (error) { return error; } } error = (* env->device->sendmessage)(msisdn, message); if (error) { return error; } return 0; } /* -------------------------------------------------------------------- */ /* Send as many messages as we are allowed. */ /* Keep track of number of messages sent and compare against */ /* Max allowed, disconnecting when number sent reaches */ /* the max allowed. */ /* -------------------------------------------------------------------- */ int default_multiple_counted_deliver(char *msisdn, char *message, DRIVER_DEFAULT_ENV *env) { int error; if (env->connection_status == SERVICE_NOT_CONNECTED) { env->num_sent = 0; env->connection_status = SERVICE_CONNECTED; error = (* env->device->dial)(env); if (error) { return error; } error = (* env->device->login)(); if (error) { return error; } } error = (* env->device->sendmessage)(msisdn, message); if (error) { return error; } env->num_sent++; lprintf(LOG_VERBOSE, "Num sent = %ld\n", env->num_sent); lprintf(LOG_VERBOSE, "Max deliver = %ld\n", env->max_deliver); if ((env->max_deliver != 0) && (env->num_sent >= env->max_deliver)) { (* env->device->disconnect)(); (* env->device->hangup)(env); env->connection_status = SERVICE_NOT_CONNECTED; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int default_send_disconnect(void) { return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int default_single_deliver(char *msisdn, char *message, DRIVER_DEFAULT_ENV *env) { int error; env->connection_status = SERVICE_CONNECTED; error = (* env->device->dial)(env); if (error) { return error; } error = (* env->device->login)(); if (error) { return error; } error = (* env->device->sendmessage)(msisdn, message); if (error) { return error; } (* env->device->disconnect)(); (* env->device->hangup)(env); env->connection_status = SERVICE_NOT_CONNECTED; return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int default_validate_numeric_id(char *ptr) { while (*ptr != '\0') { if (!isdigit(*ptr)) { return FALSE; } ptr++; } return TRUE; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int default_validate_always_true(char *id) { return TRUE; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int default_init(char *mservice, DEVICE_ENTRY *device) { char fname[1024]; strcpy(fname, LIBDIR); sms_filecat(fname, "services"); sms_filecat(fname, mservice); if (read_resource_file(fname, device->resource_list, TRUE) != RESOURCE_FILE_OK) { lprintf(LOG_ERROR, "Unrecoverable Failure Parsing file '%s'\n", fname); return -1; } device->env->device = device; return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int default_login(void) { return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int default_sendmessage(char *msisdn, char *message) { return 0; } /* -------------------------------------------------------------------- */ /* Search 'sms_services' for 'service' and return 'protocol' */ /* -------------------------------------------------------------------- */ char *get_protocol(char *service) { char fname[1024], *protocol; TOKEN_HEAP *heap; strcpy(fname, SERVICEDIR); sms_filecat(fname, "sms_services"); heap = gs_parse_file(fname); if (heap == NULL) { lprintf(LOG_ERROR, "Parsing file '%s'\n", fname); exit(-1); } protocol = get_strvalue(heap, service); if (protocol == NULL) { lprintf(LOG_VERBOSE, "Service '%s' Not Found\n", service); free_heap(heap); return NULL; } lprintf(LOG_VERBOSE, "Service '%s' using protocol '%s'\n", service, protocol); return strdup(protocol); } smsclient-2.0.8z/src/driver/www.c0000644000175000017500000001152210127274506016663 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* www.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static struct www_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ char *url; } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 3, &(driver_env.def.max_deliver) }, { RESOURCE_STRING, "SMS_url", 0, 1, NULL, 0, "http://localhost:80/", 0, &(driver_env.url) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int WWW_sendmessage(char *msisdn, char *message); static void WWW_wrapper_hangup(DRIVER_DEFAULT_ENV *env); static void WWW_hangup(void); static int WWW_dial(DRIVER_DEFAULT_ENV *env); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int WWW_dial(DRIVER_DEFAULT_ENV *env) { return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int WWW_sendmessage(char *msisdn, char *message) { char *ptr; int data_len; ptr = get_document(driver_env.url, &data_len, "GET", NULL, NULL); if (ptr == NULL) { return -1; } /* Enter stateless code here */ return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void WWW_hangup(void) { } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void WWW_wrapper_hangup(DRIVER_DEFAULT_ENV *env) { WWW_hangup(); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY www_device = { "WWW", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_always_true, WWW_dial, WWW_wrapper_hangup, default_send_disconnect, default_single_deliver, WWW_sendmessage, default_login }; smsclient-2.0.8z/src/driver/orange.c0000644000175000017500000001621010127274506017311 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* orange.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id: orange.c,v 5.1 1998/02/01 07:10:39 root Exp root $ -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static char ACK1[] = "Welcome to Orange Dial-up Messaging\r\n"; static char ACK2[] = "Please choose an option (do not press return) : \r\n" "\r\n" " S :- Send a message\r\n" " H :- Help\r\n" " E :- Exit\r\n"; static char ACK3[] = "Enter destination Orange or Hutchison Pager number and press return\r\n" "\r\n" ":"; static char ACK4[] = "Type your message (160 characters max) and press return to send\r\n" "\r\n" ":"; static char ACK5[] = "Message accepted - thankyou\r\n" "\r\n"; static char ACK6[] = "Thanks for calling.\r\n" "\r\n" "The future's bright. The future's Orange."; /* -------------------------------------------------------------------- */ static struct orange_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 3, &(driver_env.def.max_deliver) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int ORANGE_login(void); static int ORANGE_sendmessage(char *msisdn, char *message); static int ORANGE_send_disconnect(void); static void ORANGE_hangup(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int ORANGE_login(void) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, ACK1, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Orange Service Login\n"); } else { lprintf(LOG_STANDARD, "No Orange Service Login\n"); ORANGE_hangup(); return EORANGE_NORESPONSE; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int ORANGE_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, ACK2, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Orange Service Request\n"); } else { lprintf(LOG_STANDARD, "No Orange Service Request\n"); ORANGE_hangup(); return EORANGE_NOSERVICE; } twrite(FD, "S", strlen("S"), WRITETIMEOUT); if (expstr(FD, buf, ACK3, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Number Request\n"); } else { lprintf(LOG_STANDARD, "No Number Request\n"); ORANGE_hangup(); return EORANGE_NONUMBER; } twrite(FD, msisdn, strlen(msisdn), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); if (expstr(FD, buf, ACK4, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Request\n"); } else { lprintf(LOG_STANDARD, "No Message Request\n"); ORANGE_hangup(); return EORANGE_NOMESSAGE; } twrite(FD, message, strlen(message), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); if (expstr(FD, buf, ACK5, MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Delivery Response\n"); } else { lprintf(LOG_STANDARD, "No Message Delivery Response\n"); ORANGE_hangup(); return EORANGE_NODELIVERY; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int ORANGE_send_disconnect(void) { char buf[MAX_RESPONSE_BUFSIZE]; twrite(FD, "E", strlen("E"), WRITETIMEOUT); if (expstr(FD, buf, ACK6, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Disconnection Response\n"); } else { lprintf(LOG_STANDARD, "No Disconnection Response\n"); ORANGE_hangup(); return EORANGE_NODISCONNECT; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void ORANGE_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY orange_device = { "ORANGE", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, default_dial, default_hangup, ORANGE_send_disconnect, default_multiple_counted_deliver, ORANGE_sendmessage, ORANGE_login }; smsclient-2.0.8z/src/driver/ascii.h0000644000175000017500000000405210127274505017133 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* ascii.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #define S_NUL 0x00 #define S_SOH 0x01 #define S_STX 0x02 #define S_ETX 0x03 #define S_EOT 0x04 #define S_ENQ 0x05 #define S_ACK 0x06 #define S_BEL 0x07 #define S_BS 0x08 #define S_HT 0x09 #define S_LF 0x0A #define S_VT 0x0B #define S_NP 0x0C #define S_CR 0x0D #define S_SO 0x0E #define S_SI 0x0F #define S_DLE 0x10 #define S_DC1 0x11 #define S_DC2 0x12 #define S_DC3 0x13 #define S_DC4 0x14 #define S_NAK 0x15 #define S_SYN 0x16 #define S_ETB 0x17 #define S_CAN 0x18 #define S_EM 0x19 #define S_SUB 0x1A #define S_ESC 0x1B #define S_FS 0x1C #define S_GS 0x1D #define S_RS 0x1E #define S_US 0x1F /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/driver/pageone.c0000644000175000017500000001363610127274506017465 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* pageone.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id: pageone.c,v 5.1 1998/02/01 07:10:39 root Exp root $ -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static char ACK1[] = "ID=\r\n"; static char ACK2[] = "ENTER SUBSCRIBER NUMBER\n\r"; static char ACK4[] = "ENTER MESSAGE: "; static char ACK5[] = "PAGE ACCEPTED\n\r"; /* -------------------------------------------------------------------- */ static struct pageone_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "7E1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.max_deliver) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int PAGEONE_login(void); static int PAGEONE_sendmessage(char *msisdn, char *message); static void PAGEONE_hangup(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int PAGEONE_login(void) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, ACK1, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Pageone ID Request\n"); } else { lprintf(LOG_STANDARD, "No Pageone ID Request\n"); PAGEONE_hangup(); return EPAGEONE_NORESPONSE; } #if 0 twrite(FD, "PG1\r", strlen("PG1\r"), WRITETIMEOUT); #else twrite(FD, "M\r", strlen("M\r"), WRITETIMEOUT); #endif return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int PAGEONE_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, ACK2, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Pageone Number Request\n"); } else { lprintf(LOG_STANDARD, "No Pageone Number Request\n"); PAGEONE_hangup(); return EPAGEONE_NONUMBER; } twrite(FD, msisdn, strlen(msisdn), WRITETIMEOUT); twrite(FD, "\r", strlen("\r"), WRITETIMEOUT); if (expstr(FD, buf, ACK4, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Request\n"); } else { lprintf(LOG_STANDARD, "No Message Request\n"); PAGEONE_hangup(); return EPAGEONE_NOMESSAGE; } twrite(FD, message, strlen(message), WRITETIMEOUT); twrite(FD, "\r", strlen("\r"), WRITETIMEOUT); if (expstr(FD, buf, ACK5, MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Delivery Response\n"); } else { lprintf(LOG_STANDARD, "No Message Delivery Response\n"); PAGEONE_hangup(); return EPAGEONE_NODELIVERY; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void PAGEONE_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY pageone_device = { "PAGEONE", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_always_true, default_dial, default_hangup, default_send_disconnect, default_multiple_counted_deliver, PAGEONE_sendmessage, PAGEONE_login }; smsclient-2.0.8z/src/driver/mobistar.c0000600000175000017500000001753110127274506017655 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* mobistar.c */ /* */ /* Copyright (C) 1999,2000 yves.seynaeve@eyc.be */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* yves.seynaeve@eyc.be */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static char ACK1[] = "\n"; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static struct proximus_env { DRIVER_DEFAULT_ENV def; } driver_env; static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.max_deliver) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ #define STX "\02" /* start character */ #define ETX "\03" /* stop character */ #define MAXPHONELEN 30 /* phone number maximum length */ #define MAXBUFLEN 300 /* maximum output buffer length */ #define MAXTEXTLEN 160 /* maximum SMS message length */ #define MODEM_NUMBER "026585382" #define MAX_BUFSIZE 1024 #define EMOBISTAR_NORESPONSE -1 #define CMDFORMAT "00/00000/O/51/%s/%s/////////////////3//%s///0//////////" /* -------------------------------------------------------------------- */ static char buf[MAX_BUFSIZE +1]; /* -------------------------------------------------------------------- */ static int MOBISTAR_login(void); static int MOBISTAR_strtohex(char * , char *); static int MOBISTAR_checksum(char *); static void MOBISTAR_buildmessage(char *, char *, char *, char *); static int MOBISTAR_sendmessage(char *, char *); static void MOBISTAR_hangup(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int MOBISTAR_login(void) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, ACK1, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Mobistar Service Login\n"); } else { lprintf(LOG_STANDARD, "No Mobistar Service Login\n"); MOBISTAR_hangup(); return EMOBISTAR_NORESPONSE; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void MOBISTAR_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* Convert a string to its hexadecimal representation */ /* Returns the length of the string */ /* -------------------------------------------------------------------- */ static int MOBISTAR_strtohex(char * strout , char * strin) { int i; for (i=0 ; i < strlen(strin); i++ ) { sms_snprintf(&strout[2*i],2,"%2X",strin[i]); } return strlen(strout); } /* -------------------------------------------------------------------- */ /* Compute checksum */ /* -------------------------------------------------------------------- */ static int MOBISTAR_checksum(char * msg) { int cpt; int i; cpt=0; for (i=0;i #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "resource/resource.h" #include "comms/comms.h" #include "gs_token.h" #include "gs_translate.h" /* -------------------------------------------------------------------- */ #if !defined(MSERVICEDIR) #error "MSERVICEDIR undefined" #else #define SERVICEDIR MSERVICEDIR #endif /* -------------------------------------------------------------------- */ /* The 'env' structure contains Service level data to be used for */ /* sending a message. */ /* -------------------------------------------------------------------- */ static struct generic_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ TOKEN_HEAP *heap; char *script_file, *dialer; } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 1200, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.max_deliver) }, { RESOURCE_STRING, "SMS_dialer", 0, 1, NULL, 0, "tcpip", 0, &(driver_env.dialer) }, { RESOURCE_STRING, "SMS_script_file", 0, 1, NULL, 0, NULL, 0, &(driver_env.script_file) }, { RESOURCE_STRING, "SMS_server_name", 0, 1, NULL, 0, "localhost", 0, &(driver_env.def.server_name) }, { RESOURCE_NUMERIC, "SMS_server_port", 0, 1, NULL, 0, NULL, 444, &(driver_env.def.server_port) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) #define SCRIPT_FILE (driver_env.script_file) /* -------------------------------------------------------------------- */ /* The following defines are used to signify errors */ /* occuring during the dialogue between the driver and the */ /* service centre. This number will be returned as the delivery */ /* value for the message that was aborted */ /* */ /* The defines MUST be placed in 'error.h' */ #define EGENERIC_NONUMBER 250 #define EGENERIC_NOMESSAGE 251 #define EGENERIC_NODELIVERY 252 /* -------------------------------------------------------------------- */ static char *generic_message = NULL, *generic_id = NULL; /* -------------------------------------------------------------------- */ static void GENERIC_hangup(void); static int GENERIC_login(void); static int GENERIC_send_disconnect(void); static int GENERIC_sendmessage(char *msisdn, char *message); static int GENERIC_dial(DRIVER_DEFAULT_ENV *env); static void GENERIC_wrapper_hangup(DRIVER_DEFAULT_ENV *env); static int using_modem_dialer(void); static int using_tcpip_dialer(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int using_modem_dialer(void) { return (strcmp(driver_env.dialer, "modem") == 0); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int using_tcpip_dialer(void) { return (strcmp(driver_env.dialer, "tcpip") == 0); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int GENERIC_dial(DRIVER_DEFAULT_ENV *env) { if (using_modem_dialer()) { return default_dial(env); } else if (using_tcpip_dialer()) { return default_tcpip_connect(env); } else { lprintf(LOG_ERROR, "dial() failed, using unsupported dialer '%s'\n", driver_env.dialer); return -1; } lprintf(LOG_STANDARD, "Connection Established.\n"); return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int GENERIC_init(char *mservice, DEVICE_ENTRY *device) { if (default_init(mservice, device) == -1) { return -1; } if (SCRIPT_FILE == NULL) { lprintf(LOG_ERROR, "Failed to initialize driver\n"); return -1; } driver_env.heap = gs_parse_file(SCRIPT_FILE); if (driver_env.heap == NULL) { lprintf(LOG_ERROR, "Unrecoverable Failure Parsing file '%s'\n", SCRIPT_FILE); return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int process_list(TOKEN_HEAP *current_heap) { int i, j; char *str, buf[1024]; TOKEN_HEAP *tmp_heap, *heap; i = 0; while(TRUE) { heap = get_varlist_element(current_heap, i); if (heap == NULL) { return 0; } str = get_strvalue(heap, "message"); if (str != NULL) { if (strlen(str) != 0) { lprintf(LOG_STANDARD, str); } } tmp_heap = get_varlist(heap, "send"); if (tmp_heap == NULL) { str = get_strvalue(heap, "send"); if (str != NULL) { if (strlen(str) != 0) { if (strcmp(str, "$MSG$") == 0) { if (generic_message != NULL) { twrite(FD, generic_message, strlen(generic_message), WRITETIMEOUT); } } else if (strcmp(str, "$ID$") == 0) { if (generic_id != NULL) { twrite(FD, generic_id, strlen(generic_id), WRITETIMEOUT); } } else { twrite(FD, str, strlen(str), WRITETIMEOUT); } } } } else { j = 0; while((str = get_strvalue_element(tmp_heap, j)) != NULL) { if (str != NULL) { if (strlen(str) != 0) { if (strcmp(str, "$MSG$") == 0) { if (generic_message != NULL) { twrite(FD, generic_message, strlen(generic_message), WRITETIMEOUT); } } else if (strcmp(str, "$ID$") == 0) { if (generic_id != NULL) { twrite(FD, generic_id, strlen(generic_id), WRITETIMEOUT); } } else { twrite(FD, str, strlen(str), WRITETIMEOUT); } } } j++; } } str = get_strvalue(heap, "expect"); if (str != NULL) { if (expstr(FD, buf, str, 1024, TIMEOUT) == 0) { tmp_heap = get_varlist(heap, "success"); if (tmp_heap == NULL) { str = get_strvalue(heap, "success"); if (str != NULL) { lprintf(LOG_STANDARD, str); } } else { if (process_list(tmp_heap)) { return -1; } } } else { tmp_heap = get_varlist(heap, "failure"); if (tmp_heap == NULL) { str = get_strvalue(heap, "failure"); if (str != NULL) { lprintf(LOG_STANDARD, str); } return -1; } else { if (process_list(tmp_heap)) { return -1; } } } } i++; } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int process_script_list(TOKEN_HEAP *current_heap, char *listname) { TOKEN_HEAP *heap; heap = get_varlist(current_heap, listname); if (heap == NULL) { return 0; } return process_list(heap); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int GENERIC_login(void) { return process_script_list(driver_env.heap, "login"); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int GENERIC_sendmessage(char *msisdn, char *message) { generic_message = message; generic_id = msisdn; return process_script_list(driver_env.heap, "send"); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int GENERIC_send_disconnect(void) { return process_script_list(driver_env.heap, "disconnect"); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void GENERIC_hangup(void) { if (using_modem_dialer()) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } else if (using_tcpip_dialer()) { TCPIP_disconnect(FD); } else { lprintf(LOG_ERROR, "hangup() failed, using unsupported dialer '%s'\n", driver_env.dialer); } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void GENERIC_wrapper_hangup(DRIVER_DEFAULT_ENV *env) { GENERIC_hangup(); } /* -------------------------------------------------------------------- */ /* The following structure is used by core driver code. */ /* The diagram below shows the call sequence of the functions. */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY generic_device = { "GENERIC", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), GENERIC_init, /* Init */ default_main, /* Main */ default_validate_always_true, /* Validation */ GENERIC_dial, /* Dial */ GENERIC_wrapper_hangup, /* Hangup */ GENERIC_send_disconnect, /* Disconnect */ default_single_deliver, /* Deliver */ GENERIC_sendmessage, /* Send */ GENERIC_login /* Login */ }; smsclient-2.0.8z/src/driver/vodacom.c0000644000175000017500000001430010127274506017464 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* vodacom.c */ /* */ /* Copyright (C) 1998,1999 Alf Stockton */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id: vodacom.c,v 5.1 1998/02/01 07:10:39 root Exp root $ -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static char ACK1[] = "followed by RETURN, (or RETURN to quit)"; static char ACK2[] = "Please type your message, (maximum 160 characters), followed by RETURN."; /* -------------------------------------------------------------------- */ static struct vodacom_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "7E1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 1200, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 45, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 15, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.max_deliver) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int VODACOM_sendmessage(char *msisdn, char *message); static int VODACOM_send_disconnect(void); static void VODACOM_hangup(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void VODACOM_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int VODACOM_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE]; char nmessage[1024]; if (expstr(FD, buf, ACK1, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Number Request\n"); } else { lprintf(LOG_STANDARD, "No Number Request\n"); VODACOM_hangup(); return EVODACOM_NORESPONSE; } twrite(FD, msisdn, strlen(msisdn), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); if (expstr(FD, buf, msisdn, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Number Returned\n"); } else { lprintf(LOG_STANDARD, "No Number Returned\n"); VODACOM_hangup(); return EVODACOM_NONUMBER; } if (expstr(FD, buf, ACK2, MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Request\n"); } else { lprintf(LOG_STANDARD, "No Message Request\n"); VODACOM_hangup(); return EVODACOM_NONUMBER; } twrite(FD, message, strlen(message), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); sms_snprintf(nmessage, 1024, "\r\n\r\n>%s", message); if (expstr(FD, buf, nmessage, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message back\n"); } else { lprintf(LOG_STANDARD, "No Message Returned\n"); VODACOM_hangup(); return EVODACOM_NOMESSAGE; } twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); if (expstr(FD, buf, ACK1, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Number Request\n"); } else { lprintf(LOG_STANDARD, "No Number Request\n"); VODACOM_hangup(); return EVODACOM_NOMESSAGE; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int VODACOM_send_disconnect(void) { twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY vodacom_device = { "VODACOM", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, default_dial, default_hangup, VODACOM_send_disconnect, default_single_deliver, VODACOM_sendmessage, default_login }; smsclient-2.0.8z/src/driver/driver_comms.h0000644000175000017500000000011710127274505020532 0ustar noodlesnoodlesint SMS_dial(char *number, char *params, long baud); void SMS_hangup(int fd); smsclient-2.0.8z/src/driver/README0000644000175000017500000000023410127274505016550 0ustar noodlesnoodles Writing Drivers =============== For an example of how to write your own driver take a look at 'skeleton.c' it's a lot easier than you might think. smsclient-2.0.8z/src/driver/libucp.c0000644000175000017500000001546711007574404017327 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *UCP_header(int tranRefNo, char ORC, int opType, int dataLen ); static char *UCP_checksum(char *header, char *data ); static char *UCP01_data(char *msisdn, char *message, int msgType); static char *UCP51_data(char *msisdn, char *message, int msgType, char *ipaddress); static char *UCP60_data(char *ipaddress, char *password ); static char *UCP_CallInputOp( char OCR, int opType, char *msgData ); char *UCP_CallInputOp01(char *msisdn, char *message ); char *UCP_CallInputOp51(char *msisdn, char *message, char *ipaddress); char *UCP_CallInputOp60(char *ipaddress, char *password ); int UCP_parse_response(char *string); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *UCP_header(int tranRefNo, char ORC, int opType, int dataLen ) { int msgLen; static char msgHead[20]; /* HEADER section */ msgLen = 14 + dataLen + 2; /* len(header+data+checksum) */ /* header: TRN/LEN/ORC/OT/ */ sprintf(msgHead, "%2.2d/%5.5d/%c/%2.2d/", tranRefNo, msgLen, ORC, opType); return msgHead; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *UCP_checksum(char *header, char *data ) { char *p; int sum; static char buf[3]; /* CHECKSUM section */ sum = 0; for (p = header; *p != '\0'; p++) { sum += (unsigned char) *p; sum &= 0xFF; } for (p = data; *p != '\0'; p++) { sum += (unsigned char) *p; sum &= 0xFF; } sprintf(buf, "%02X", sum); return buf; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *UCP01_data(char *msisdn, char *message, int msgType) { static char msgData[800]; char *src; char *dest; int nc; /* data: AdC/OAdc/OAC/MT/.. */ /* -> recipient///3/... */ nc = sprintf(msgData, "%s///%1.1d/", msisdn, msgType); /* ... additional parameters depending on MT */ /* For MT=3 (alphanumeric) this is hex coded */ /* message data */ dest = &msgData[nc]; for (src = message; *src; src++) { sprintf(dest, "%02X", *src); dest += 2; } sprintf( dest, "/" ); return msgData; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *UCP51_data(char *msisdn, char *message, int msgType, char *ipaddress) { static char msgData[800]; char *src; char *dest; int nc; nc = sprintf(msgData, "%s/%s/////////////////%1.1d//", msisdn, "originator", msgType ); dest = &msgData[nc]; for (src = message; *src; src++) { sprintf(dest, "%02X", *src); dest += 2; } sprintf(dest, "/////////////"); return msgData; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *UCP60_data(char *ipaddress, char *password) { static char msgData[800]; sprintf(msgData, "%s///1/%s//0100//////", ipaddress, password); return msgData; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *UCP_CallInputOp(char OCR, int opType, char *msgData) { char *msgHead, *msgCksm; static int tranRefNo = 1; static char buf[1024]; msgHead = UCP_header( tranRefNo, OCR, opType, strlen(msgData) ); msgCksm = UCP_checksum( msgHead, msgData ); /* operational message: header data checksum */ sprintf(buf, "%c%s%s%s%c", S_STX, msgHead, msgData, msgCksm, S_ETX ); tranRefNo++; return buf; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *UCP_CallInputOp01(char *msisdn, char *message) { return UCP_CallInputOp( 'O', 01, UCP01_data( msisdn, message, 3 ) ); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *UCP_CallInputOp51(char *msisdn, char *message, char *ipaddress) { return UCP_CallInputOp( 'O', 51, UCP51_data( msisdn, message, 3 , ipaddress) ); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *UCP_CallInputOp60(char *ipaddress, char *password) { return UCP_CallInputOp( 'O', 60, UCP60_data( ipaddress, password ) ); } /* -------------------------------------------------------------------- */ /* Return Values: */ /* 0 Positive ACK */ /* 1 Negative ACK */ /* -1 Error */ /* -------------------------------------------------------------------- */ int UCP_parse_response(char *string) { int result; int tranRefNo, length, opType; char ORC, ack; /* ------------------------------------------------------------ */ /* Example: */ /* 01/00045/R/01/A/0041544180972:161298112313/A6 */ /* trn len orc ot a recip:time chksum */ /* ------------------------------------------------------------ */ /* * Filter any leading crud. */ while (*string && (*string != '\002')) string++; result = sscanf(string, "\002%02d/%05d/%c/%02d/%c", &tranRefNo, &length, &ORC, &opType, &ack ); if (result != 5 || ORC != 'R' || opType != 1 ) return -1; /* ---------------------------- */ if ( ack == 'A' ) result = 0; else if( ack == 'N' ) result = 1; else result = -1; return result; } smsclient-2.0.8z/src/driver/driver_comms.c0000644000175000017500000000777610127274505020547 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* driver_comms.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #if defined(MODEMLIB) && (MODEMLIB == LIBMODEM) #include #include #else #include "comms/comms.h" #endif #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "driver_comms.h" /* -------------------------------------------------------------------- */ #if defined(MODEMLIB) && (MODEMLIB == LIBMODEM) static void LIBMODEM_setup_comm_params(int fd, char *params); static int LIBMODEM_dial(char *number, char *params, long baud); static int num2baud (long baud_num); #endif /* -------------------------------------------------------------------- */ /* The following functions are used as wrappers to */ /* The libmodem routine is you decide to link against it */ /* instead of the builtin smsmodem library. */ /* -------------------------------------------------------------------- */ #if defined(MODEMLIB) && (MODEMLIB == LIBMODEM) static void LIBMODEM_setup_comm_params(int fd, char *params) { struct termios trm; if (params == NULL) { return; } lprintf(LOG_VERBOSE, "Setting communications parameters: %s\n", params); if (strcmp(params, "8N1") == 0) { /* Default - No ACTION */ } else if (strcmp(params, "7E1") == 0) { tcgetattr(fd, &trm); trm.c_cflag &= ~(CSIZE|CSTOPB|PARODD); trm.c_cflag |= CS7|PARENB; tcsetattr(fd, TCSAFLUSH, &trm); } } static int num2baud(long baud) { switch (baud) { case 0: return B0; case 50: return B50; case 75: return B75; case 110: return B110; case 134: return B134; case 150: return B150; case 200: return B200; case 300: return B300; case 600: return B600; case 1200: return B1200; case 1800: return B1800; case 2400: return B2400; case 4800: return B4800; case 7200: case 9600: return B9600; case 12200: case 14400: case 16800: case 19200: return B19200; case 21600: case 24000: case 26400: case 28800: case 31200: case 33600: case 38400: return B38400; } return -1; } static int LIBMODEM_dial(char *number, char *params, long baud) { int fd, mbaud; lprintf(LOG_VERBOSE, "Using Libmodem Package\n"); mbaud = num2baud(baud); if (mbaud != -1) { fd = bdial(number, num2baud(baud)); } else { lprintf(LOG_WARNING, "Unknown baud %ld\n", baud); return -1; } /* Libmodem-1.0.0 does not supports */ /* cofiguration of modem parameters. */ /* Use own function to change them. */ if (fd >= 0) { LIBMODEM_setup_comm_params(fd, params); } return fd; } int SMS_dial(char *number, char *params, long baud) { return LIBMODEM_dial(number, params, baud); } void SMS_hangup(int fd) { hangup(fd); } #endif smsclient-2.0.8z/src/driver/driver.h0000644000175000017500000001316410127274505017342 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* driver.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #if !defined(_DRIVER_H_) #define _DRIVER_H_ #include "resource/resource.h" /* -------------------------------------------------------------------- */ typedef struct device_entry_struct DEVICE_ENTRY; typedef struct driver_default_env_struct DRIVER_DEFAULT_ENV; /* -------------------------------------------------------------------- */ struct driver_default_env_struct { char *comms_params, *flow_control, *centre_number, *server_name; int fd, connection_status; DEVICE_ENTRY *device; long baud, deliver_timeout, timeout, write_timeout, num_sent, max_deliver, server_port; }; /* -------------------------------------------------------------------- */ struct device_entry_struct { char *name, *version_string; RESOURCE *resource_list; DRIVER_DEFAULT_ENV *env; int (* init)(char *service, DEVICE_ENTRY *device); void (* main)(void *list, void *(* get_first)(void *list), void *(* get_next)(void *list), char *(* get_number)(void *node), char *(* get_message)(void *node), void (* set_delivery)(void *node, int result), DRIVER_DEFAULT_ENV *env); int (* validate_id)(char *id); int (* dial)(DRIVER_DEFAULT_ENV *env); void (* hangup)(DRIVER_DEFAULT_ENV *env); int (* disconnect)(void); int (* deliver)(char *msisdn, char *message, DRIVER_DEFAULT_ENV *env); int (* sendmessage)(char *msisdn, char *message); int (* login)(void); }; /* -------------------------------------------------------------------- */ extern DEVICE_ENTRY tap_device; extern DEVICE_ENTRY vodafone_device; extern DEVICE_ENTRY orange_device; extern DEVICE_ENTRY pageone_device; extern DEVICE_ENTRY vodacom_device; extern DEVICE_ENTRY mtn_device; extern DEVICE_ENTRY one2one_device; extern DEVICE_ENTRY libertel_device; extern DEVICE_ENTRY tim_device; extern DEVICE_ENTRY snpp_device; extern DEVICE_ENTRY cimd_device; extern DEVICE_ENTRY proximus_device; extern DEVICE_ENTRY vodapage_block_device; extern DEVICE_ENTRY kpn_device; extern DEVICE_ENTRY answer_device; extern DEVICE_ENTRY generic_device; extern DEVICE_ENTRY ucp_device; extern DEVICE_ENTRY ucp_tcp_device; extern DEVICE_ENTRY www_device; extern DEVICE_ENTRY orange_web_device; extern DEVICE_ENTRY cellnet_web_device; extern DEVICE_ENTRY proximus_web_device; extern DEVICE_ENTRY att_web_device; extern DEVICE_ENTRY nextel_web_device; extern DEVICE_ENTRY pagenet_web_device; extern DEVICE_ENTRY mobistar_device; /* -------------------------------------------------------------------- */ extern DEVICE_ENTRY *device_list[]; /* -------------------------------------------------------------------- */ #define SERVICE_NOT_CONNECTED 0 #define SERVICE_CONNECTED 1 /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #define MAX_RESPONSE_BUFSIZE 8096 /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY *get_device(char *name); void display_drivers(void); void default_main(void *list, void *(* get_first)(void *list), void *(* get_next)(void *list), char *(* get_number)(void *node), char *(* get_message)(void *node), void (* set_delivery)(void *node, int result), DRIVER_DEFAULT_ENV *env); int default_init(char *mservice, DEVICE_ENTRY *device); int default_dial(DRIVER_DEFAULT_ENV *env); int default_tcpip_connect(DRIVER_DEFAULT_ENV *env); int default_multiple_deliver(char *msisdn, char *message, DRIVER_DEFAULT_ENV *env); int default_single_deliver(char *msisdn, char *message, DRIVER_DEFAULT_ENV *env); int default_multiple_counted_deliver(char *msisdn, char *message, DRIVER_DEFAULT_ENV *env); int default_send_disconnect(void); int default_validate_numeric_id(char *ptr); int default_validate_always_true(char *id); int default_login(void); int default_sendmessage(char *msisdn, char *message); void default_hangup(DRIVER_DEFAULT_ENV *env); void default_tcpip_disconnect(DRIVER_DEFAULT_ENV *env); char *get_protocol(char *service); /* -------------------------------------------------------------------- */ #endif smsclient-2.0.8z/src/driver/kpn.c0000644000175000017500000002427010127274506016633 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* kpn.c */ /* */ /* Copyright (C) 1998,1999 Harold "Bo" Baur */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* bo@bikerider.com */ /* */ /* -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static struct kpn_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 20, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 2, &(driver_env.def.max_deliver) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static void KPN_hangup(void); static int found(char *description, char *match); static int KPN_login(void); static int KPN_sendmessage(char *msisdn, char *message); static int KPN_send_disconnect(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void KPN_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* This function is here to keep the functions readable. */ /* Timeout and buffersize settings are constants anyway. */ /* -------------------------------------------------------------------- */ static int found(char *description, char *match) { static char buf[MAX_RESPONSE_BUFSIZE]; lprintf(LOG_VERBOSE, "Waiting for %s\n", description ); if (expstr(FD, buf, match, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_VERYVERBOSE, "Ok, got '%s'\n", match ); return 1; } lprintf(LOG_ERROR, "Failed to match '%s'\n", match ); KPN_hangup(); return 0; } /* -------------------------------------------------------------------- */ /* Now follow the functions that implement the actual chat sequence. */ /* Rather than just prompting for a message and a phonenumber to */ /* sent it to, they present you with all kinds of menus which you */ /* have to traverse in order to get your message sent. If you */ /* are wondering why this is, here's a clue: the SMS service number */ /* charges you by the second, so the longer they can hold you on */ /* line, the more money they make. This is typical KPN behaviour. */ /* They also support sending "multiple" messages within one session, */ /* with a maximum of - yes - two. Count your blessings. It's not that */ /* they drop the connection after this, no, they still allow you to */ /* specify a phone number and a text, but after this you realise that */ /* the menu has undergone a subtle change. The option to actually SEND */ /* it has suddenly disappeared. You have to disconnect and call again */ /* so they can charge you the initial connection fee again. Are we */ /* having fun yet? Can you say "monopoly". End of rant, thank you for */ /* listening, I will shut up now, and talk about how this is coded. */ /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ /* This function performs the "login" before the actual message can */ /* be sent. Right after connecting we first have to choose a terminal */ /* type (I'm using "VT100"), then send a to get to Menu 2, */ /* wherethen select the (only available) option "1" to get to Menu 3 */ /* (yes, it really is absurd) where we can finally get some message */ /* sending done (but that's is handled by KPN_sendmessage). */ /* -------------------------------------------------------------------- */ static int KPN_login(void) { if ( !found("Welcome","KPN Telecom") ) return EKPN_NOWELCOME; if ( !found("Menu 1 Prompt",">: ") ) return EKPN_NOMENU1; /* select option 1 : VT100 */ twrite(FD, "1\r\n", strlen("1\r\n"), TIMEOUT); if ( !found("Press RETURN","verbreken.") ) return EKPN_NORETURN; /* just send a return */ twrite(FD, "\r\n", strlen("\r\n"), TIMEOUT); if ( !found("Menu 2 Prompt",">: ") ) return EKPN_NOMENU2; /* select option 1 : send a message */ twrite(FD, "1\r\n", strlen("1\r\n"), TIMEOUT); /* once we get the 3rd prompt, the "login" has succeeded */ if ( !found("Menu 3 Prompt",">: ") ) return EKPN_NOMENU3; return 0; } /* -------------------------------------------------------------------- */ /* The function that actually sends a message picks up were KPN_login */ /* ended, assuming that we are now in Menu 3. This one allows you to */ /* specify a phone number, a message, and an option to actually send */ /* send it (yaaaay!). Note that we specify the message only once (by */ /* checking wether driver_env.def.num_sent equals 0), even though the */ /* function is called again for each subsequent recipient. */ /* -------------------------------------------------------------------- */ static int KPN_sendmessage(char *msisdn, char *message) { /* specify message only if this is the first recipient */ if ( ! driver_env.def.num_sent ) { /* select option 7 : specify the message text */ twrite(FD, "7\r\n", strlen("7\r\n"), TIMEOUT); if ( !found("Message Prompt","karakters)") ) return EKPN_NOMESSAGE; /* send the message text */ twrite(FD, message, strlen(message), TIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), TIMEOUT); if ( !found("Menu 3 Prompt",">: ") ) return EKPN_NOMENU3; } /* select option 5 : specify the phone number */ twrite(FD, "5\r\n", strlen("5\r\n"), TIMEOUT); if ( !found("Number Prompt"," : ") ) return EKPN_NONUMBER; /* send the phone number */ twrite(FD, msisdn, strlen(msisdn), TIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), TIMEOUT); if ( !found("Menu 3 Prompt",">: ") ) return EKPN_NOMENU3; /* select option 10 : send the message */ twrite(FD, "10\r\n", strlen("10\r\n"), TIMEOUT); if ( !found("Confirm Send","N>: ") ) return EKPN_NOCONFIRM; /* send a "j" (for "yes" in dutch) */ twrite(FD, "j\r\n", strlen("j\r\n"), TIMEOUT); if ( !found("Message Sent","Bericht verzonden") ) return EKPN_NOSEND; if ( !found("Press Text","gaan.") ) return EKPN_NORETURN; /* just send a return */ twrite(FD, "\r\n", strlen("\r\n"), TIMEOUT); /* after this we should get the menu prompt back */ if ( !found("Menu 3 Prompt",">: ") ) return EKPN_NOMENU3; /* we leave the routine in "Menu 3" state. If another */ /* message needs to be sent, it's called all over again */ /* with the selection of option 5 (specify number). If */ /* the last message has been sent, we fall through to */ /* KPN_send_disconnect (implements the exit sequence). */ return 0; } /* ------------------------------------------------------------ */ /* We can bail out immediately after the message is sent, */ /* without attempting to traverse back through the menu */ /* answering questions like "do you want to disconnect?". */ /* This function implements the latter, but if you prefer */ /* to just drop the carrier, modify the DEVICE_ENTRY to use */ /* default_send_disconnect rather than KPN_send_disconnect. */ /* It could be argued they don't deserve better :-) */ /* ------------------------------------------------------------ */ static int KPN_send_disconnect(void) { /* last message - send a CTRL-Z to exit this menu */ twrite(FD, "", strlen(""), TIMEOUT); if ( !found("Menu 2 Prompt",">: ") ) return EKPN_NOMENU2; /* send a CTRL-Z to exit this menu */ twrite(FD, "", strlen(""), TIMEOUT); if ( !found("Confirm Disconnect",">: ") ) return EKPN_NOCONFIRM; /* send a "j" (for "yes" in dutch) */ twrite(FD, "j\r\n", strlen("j\r\n"), TIMEOUT); return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY kpn_device = { "KPN", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, default_dial, default_hangup, KPN_send_disconnect, default_multiple_counted_deliver, KPN_sendmessage, KPN_login }; smsclient-2.0.8z/src/driver/vodafone.c0000644000175000017500000001467310127274506017652 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* vodafone.c */ /* */ /* Copyright (C) 1997,1998,1999,2000 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* Suggested patch for Australian Telenotes support by */ /* Jeremy Laidman 13-Jan-1999 */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ #if 0 static char ACK1[] = "WELCOME TO THE VODAFONE PC TEXT MESSAGING SERVICE.\r\n"; #else static char ACK1[] = "WELCOME TO THE VODAFONE"; #endif static char ACK2[] = "FOLLOWED BY RETURN, (OR RETURN TO QUIT).\r\n" "\r\n" ">"; static char ACK3[] = "FOLLOWED BY RETURN.\r\n" "\r\n" ">"; static char ACK4[] = "MESSAGE ACCEPTED.\r\n"; /* -------------------------------------------------------------------- */ static struct vodafone_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "7E1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 1200, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 1, &(driver_env.def.max_deliver) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static int VODAFONE_login(void); static int VODAFONE_sendmessage(char *msisdn, char *message); static void VODAFONE_hangup(void); static int VODAFONE_send_disconnect(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int VODAFONE_login(void) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, ACK1, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Vodafone Service Login\n"); } else { lprintf(LOG_STANDARD, "No Vodafone Service Response\n"); VODAFONE_hangup(); return EVODAFONE_NORESPONSE; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int VODAFONE_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, ACK2, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Number Request\n"); } else { lprintf(LOG_STANDARD, "No Number Request\n"); VODAFONE_hangup(); return EVODAFONE_NONUMBER; } twrite(FD, msisdn, strlen(msisdn), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); if (expstr(FD, buf, ACK3, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Request\n"); } else { lprintf(LOG_STANDARD, "No Message Request\n"); VODAFONE_hangup(); return EVODAFONE_NOMESSAGE; } twrite(FD, message, strlen(message), WRITETIMEOUT); twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); if (expstr(FD, buf, ACK4, MAX_RESPONSE_BUFSIZE, DELIVERTIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Delivery Response\n"); } else { lprintf(LOG_STANDARD, "No Message Delivery Response\n"); VODAFONE_hangup(); return EVODAFONE_NODELIVERY; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int VODAFONE_send_disconnect(void) { twrite(FD, "\r\n", strlen("\r\n"), WRITETIMEOUT); return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void VODAFONE_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY vodafone_device = { "VODAFONE", "1.1", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, default_dial, default_hangup, VODAFONE_send_disconnect, default_single_deliver, VODAFONE_sendmessage, VODAFONE_login }; smsclient-2.0.8z/src/driver/test.c0000644000175000017500000000062610127274506017021 0ustar noodlesnoodles#include int main(int argc, char **argv) { int addr[4]; char ipaddress[512]; strcpy(ipaddress, argv[1]); if ( sscanf(ipaddress, "%3d.%3d.%3d.%3d", &addr[0], &addr[1], &addr[2], &addr[3]) == 4 ) { sprintf(ipaddress, "%3.3d%3.3d%3.3d%3.3d", addr[0], addr[1], addr[2], addr[3]); printf("%s\n", ipaddress); } else { fprintf(stderr, "Error: bad format\n"); } return 0; } smsclient-2.0.8z/src/driver/proximus.c0000600000175000017500000001643710127274506017727 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* proximus.c */ /* */ /* Copyright (C) 1998,1999 xavier@bru-noc.net */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* xavier@bru-noc.net */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static char ACK1[] = "connected\r\n"; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static struct proximus_env { DRIVER_DEFAULT_ENV def; } driver_env; static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 9600, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 30, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.max_deliver) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ #define MAX_ENVELOPE 64 #define MAX_NUMBER 20 #define MAX_MOBILENUM 20 #define MAX_MESSAGE 512 #define MAX_TAPMESSAGE 150 #define MAX_BUFSIZE 1024 #define EPROXIMUS_NORESPONSE -1 /* -------------------------------------------------------------------- */ static char buf[MAX_BUFSIZE +1]; /* -------------------------------------------------------------------- */ static int PROXIMUS_login(void); static void PROXIMUS_buildmessage(char *, int, char *, char *); static int PROXIMUS_sendmessage(char *, char *); static void PROXIMUS_hangup(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int PROXIMUS_login(void) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, ACK1, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Proximus Service Login\n"); } else { lprintf(LOG_STANDARD, "No Proximus Service Login\n"); PROXIMUS_hangup(); return EPROXIMUS_NORESPONSE; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void PROXIMUS_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void PROXIMUS_buildmessage(char *proximus_message, int max_proximus_message_len, char *msisdn, char *message) { int i, j, k; char buf [512]; char Originator[10]; /* Phone number of the originator, must be null */ char TextDest [256]; /* Test to be sent to the GSM */ char TelDest [20]; /* GSM number of the destination (3275695600) */ char Len2String[16]; char ChecksumString[512]; int TranNum; /* Integer which identifiy the message sequence */ char SendString[512]; /* String sent to the SMS-C */ char TextConv [512]; /* ---------------------------- */ proximus_message[0] = '\0'; Originator [0] = '\0'; TextConv [0] = '\0'; strcpy(TelDest, msisdn); strcpy(TextDest, message); /* Convert text */ for (i=0; i < strlen(TextDest); i++) { sms_snprintf(buf, 512, "%02X", TextDest[i]); strcat(TextConv, buf); } sms_snprintf(SendString, 512, "/O/01/%s/%s/proximus/3/%s/", TelDest, Originator, TextConv); /* Set length of message in a 5 digits string */ sms_snprintf(Len2String, 16, "%05d", strlen(SendString) + 10); /* Set message sequence in a 2 digites string */ TranNum = 1; sms_snprintf(ChecksumString, 512, "%02d/%s%s", TranNum, Len2String, SendString); /* Calculate checksum */ j = 0; for (i=0; i < strlen(ChecksumString); i++) { k = ChecksumString[i]; j += k; if (j >= 256) { j -= 256; } } sms_snprintf(buf, 512, "%02X", j); /* Compile string to be send */ sms_snprintf(proximus_message, max_proximus_message_len, "%c%s%s%c", 2, ChecksumString, buf, 3); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int PROXIMUS_sendmessage(char *msisdn, char *message) { char proximus_message[MAX_MESSAGE + MAX_ENVELOPE]; PROXIMUS_buildmessage(proximus_message, (MAX_MESSAGE + MAX_ENVELOPE), msisdn, message); twrite(FD, proximus_message, strlen(proximus_message), WRITETIMEOUT); if (expstr(FD, buf, "01/00019", MAX_BUFSIZE, DELIVERTIMEOUT) == 0) { lprintf(LOG_STANDARD, "Received Message Response\n" "SMSC Respsonse: %s\n", buf); } else { lprintf(LOG_STANDARD, "No Message Response\n"); PROXIMUS_hangup(); return EPROXIMUS_NORESPONSE; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY proximus_device = { "PROXIMUS", "1.1", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, default_dial, default_hangup, default_send_disconnect, default_single_deliver, PROXIMUS_sendmessage, PROXIMUS_login }; smsclient-2.0.8z/src/driver/mtn.c0000644000175000017500000001344110127274506016637 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* mtn.c */ /* */ /* Copyright (C) 1998,1999 Alf Stockton */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* stockton@fast.co.za */ /* */ /* -------------------------------------------------------------------- */ /* $Id: mtn.c,v 5.1 1998/02/01 07:10:39 root Exp root $ -------------------------------------------------------------------- */ #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "driver.h" #include "error.h" #include "comms/comms.h" #include "resource/resource.h" /* -------------------------------------------------------------------- */ static char ACK1[] = "Number : 083"; static char ACK3[] = "Please enter message :"; static char ACK4[] = "Wait for confirmation ? (Y/N)"; /* -------------------------------------------------------------------- */ static struct mtn_env { DRIVER_DEFAULT_ENV def; /* Place any extended driver */ /* variables here */ } driver_env; /* -------------------------------------------------------------------- */ static RESOURCE resource_list[] = { { RESOURCE_STRING, "SMS_comms_params", 0, 1, NULL, 0, "8N1", 0, &(driver_env.def.comms_params) }, { RESOURCE_STRING, "SMS_centre_number", 0, 1, NULL, 0, NULL, 0, &(driver_env.def.centre_number) }, { RESOURCE_NUMERIC, "SMS_baud", 0, 1, NULL, 0, NULL, 1200, &(driver_env.def.baud) }, { RESOURCE_NUMERIC, "SMS_deliver_timeout", 0, 0, NULL, 0, NULL, 60, &(driver_env.def.deliver_timeout) }, { RESOURCE_NUMERIC, "SMS_timeout", 0, 0, NULL, 0, NULL, 15, &(driver_env.def.timeout) }, { RESOURCE_NUMERIC, "SMS_write_timeout", 0, 0, NULL, 0, NULL, 10, &(driver_env.def.write_timeout) }, { RESOURCE_NUMERIC, "SMS_max_deliver", 0, 0, NULL, 0, NULL, 0, &(driver_env.def.max_deliver) }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; /* -------------------------------------------------------------------- */ #define DELIVERTIMEOUT (driver_env.def.deliver_timeout) #define TIMEOUT (driver_env.def.timeout) #define WRITETIMEOUT (driver_env.def.write_timeout) /* -------------------------------------------------------------------- */ #define FD (driver_env.def.fd) /* -------------------------------------------------------------------- */ static void MTN_hangup(void); static int MTN_sendmessage(char *msisdn, char *message); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void MTN_hangup(void) { default_hangup((DRIVER_DEFAULT_ENV *)(&driver_env)); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int MTN_sendmessage(char *msisdn, char *message) { char buf[MAX_RESPONSE_BUFSIZE]; if (expstr(FD, buf, ACK1, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "MTN Service Login\n"); } else { lprintf(LOG_STANDARD, "No MTN Service Response\n"); MTN_hangup(); return EMTN_NORESPONSE; } twrite(FD, msisdn, strlen(msisdn), WRITETIMEOUT); twrite(FD, "\n", strlen("\n"), WRITETIMEOUT); if (expstr(FD, buf, msisdn, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Number Returned\n"); } else { lprintf(LOG_STANDARD, "No Number Returned\n"); MTN_hangup(); return EMTN_NONUMBER; } if (expstr(FD, buf, ACK3, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Message Request Received \n"); } else { lprintf(LOG_STANDARD, "No Message Request\n"); MTN_hangup(); return EMTN_NONUMBER; } sleep(2); twrite(FD, message, strlen(message), WRITETIMEOUT); twrite(FD, "\n", strlen("\n"), WRITETIMEOUT); if (expstr(FD, buf, ACK4, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "Wait for confirmation Received \n"); } else { lprintf(LOG_STANDARD, "No Wait Confirmation Response\n"); MTN_hangup(); return EMTN_NODELIVERY; } twrite(FD, "n\n", strlen("n\n"), WRITETIMEOUT); if (expstr(FD, buf, ACK1, MAX_RESPONSE_BUFSIZE, TIMEOUT) == 0) { lprintf(LOG_STANDARD, "EXIT to exit Received \n"); } else { lprintf(LOG_STANDARD, "No EXIT to exit Response\n"); MTN_hangup(); return EMTN_NODELIVERY; } twrite(FD, "exit\n", strlen("exit\n"), WRITETIMEOUT); return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ DEVICE_ENTRY mtn_device = { "MTN", "1.0", resource_list, (DRIVER_DEFAULT_ENV *)(&driver_env), default_init, default_main, default_validate_numeric_id, default_dial, default_hangup, default_send_disconnect, default_single_deliver, MTN_sendmessage, default_login }; smsclient-2.0.8z/src/driver/Makefile0000644000175000017500000001137110127274505017334 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- include ../../Makefile.config include ../../Makefile.drivers include ../../Makefile.modemlib # -------------------------------------------------------------------- INCLUDE =-I.. -I../client -I../parser HDRS =../common/common.h ../logfile/logfile.h driver.h ../error.h ia5table.h # -------------------------------------------------------------------- all: ../../Makefile.drivers sms_driver.a ../../Makefile.drivers: ../../drivers cd ../.. ; sh configure -drivers $(MAKE) all clean: $(RM) *.o *.bak sms_driver.a # -------------------------------------------------------------------- sms_driver.a: $(DRV_OBJ) driver.o driver_comms.o ia5table.o ../../Makefile.drivers $(RM) sms_driver.a $(AR) sms_driver.a driver.o driver_comms.o ia5table.o $(DRV_OBJ) $(RANLIB) sms_driver.a driver.o: driver.c driver.h ../common/common.h ../logfile/logfile.h ../../Makefile.config ../../Makefile.drivers ../../Makefile.modemlib $(CC) $(INCLUDE) $(CFLAGS) -c driver.c $(DRV_DEF) \ -DMSERVICEDIR="\"$(MSERVICEDIR)\"" \ -DMLIBDIR="\"$(MLIBDIR)\"" \ -DMODEMLIB=$(MODEMLIB) \ -DLIBMODEM=$(LIBMODEM) \ -DSMSMODEM=$(SMSMODEM) driver_comms.o: driver_comms.c driver_comms.h ../common/common.h ../logfile/logfile.h ../../Makefile.config ../../Makefile.drivers ../../Makefile.modemlib $(CC) $(INCLUDE) $(CFLAGS) -c driver_comms.c $(DRV_DEF) \ -DMODEMLIB=$(MODEMLIB) \ -DLIBMODEM=$(LIBMODEM) \ -DSMSMODEM=$(SMSMODEM) # -------------------------------------------------------------------- tap.o: tap.c ascii.h $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c tap.c vodafone.o: vodafone.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c vodafone.c vodacom.o: vodacom.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c vodacom.c mtn.o: mtn.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c mtn.c orange.o: orange.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c orange.c pageone.o: pageone.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c pageone.c one2one.o: one2one.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c one2one.c libertel.o: libertel.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c libertel.c tim.o: tim.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c tim.c snpp.o: snpp.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c snpp.c cimd.o: cimd.c $(HDRS) ascii.h $(CC) $(INCLUDE) $(CFLAGS) -c cimd.c kpn.o: kpn.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c kpn.c www.o: www.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c www.c proximus.o: proximus.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c proximus.c answer.o: answer.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c answer.c ucp.o: ucp.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c ucp.c ucp_tcp.o: ucp_tcp.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c ucp_tcp.c vodapage_block.o: vodapage_block.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c vodapage_block.c skeleton.o: skeleton.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c skeleton.c generic.o: generic.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c generic.c -DMSERVICEDIR="\"$(MSERVICEDIR)\"" orange_web.o: orange_web.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c orange_web.c cellnet_web.o: cellnet_web.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c cellnet_web.c proximus_web.o: proximus_web.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c proximus_web.c mobistar.o: mobistar.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c mobistar.c att_web.o: att_web.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c att_web.c nextel_web.o: nextel_web.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c nextel_web.c pagenet_web.o: pagenet_web.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c pagenet_web.c ia5table.o: ia5table.c $(HDRS) $(CC) $(INCLUDE) $(CFLAGS) -c ia5table.c # -------------------------------------------------------------------- smsclient-2.0.8z/src/driver/ia5table.h0000644000175000017500000000275010127274506017535 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* ia5table.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ int toia5(int c); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/logfile/0000755000175000017500000000000011007610111016000 5ustar noodlesnoodlessmsclient-2.0.8z/src/logfile/logfile.c0000644000175000017500000001277310460430200017600 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* logfile.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include "logfile/logfile.h" #include "error.h" #include "common/common.h" /* -------------------------------------------------------------------- */ char *ctable[] = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }; #define asctostr(X) (ctable[(int)(X)]) /* -------------------------------------------------------------------- */ static int console_log = TRUE; static int current_loglevel = LOG_STANDARD; static char *current_logfile = NULL; static FILE *log_fp; /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void set_logfile(char *logfile) { current_logfile = logfile; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void set_loglevel(int loglevel) { current_loglevel = loglevel; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void set_consolelog(int send_to_console_log) { console_log = send_to_console_log; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void open_log(void) { if (current_logfile == NULL) { fprintf(stderr, "ERROR: logfile undefined\n"); exit(EOPENLOG); } log_fp = fopen(current_logfile, "a"); if (log_fp == NULL) { fprintf(stderr, "ERROR: Opening logfile: %s\n", current_logfile); fflush(stderr); exit(EOPENLOG); } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void close_log(void) { if (log_fp != NULL) { fclose(log_fp); } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *get_current_logtype(int loglevel) { switch (loglevel) { case LOG_ERROR: return "ERROR"; case LOG_WARNING: return "WARNING"; } return ""; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static char *get_current_date(void) { static char buf[128]; time_t ct; struct tm *ctm; time(&ct); ctm = localtime(&ct); strftime(buf, 64, "%b %d %H:%M:%S", ctm); return buf; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ void lprintf(int loglevel, const char *fmt, ...) { va_list args; static char line[MAX_LOG_LINE], nline[MAX_LOG_LINE * 5]; /* 5 is the maximum */ /* width of results */ /* from asctostr() */ char *ptr; int i, line_len; /* ---------------------------- */ if (loglevel > current_loglevel) return; open_log(); va_start(args, fmt); #if !defined(LINUX) vsprintf(line, fmt, args); #else vsnprintf(line, MAX_LOG_LINE, fmt, args); #endif va_end(args); line_len = strlen(line); ptr = nline; for (i=0; i= 0)) { if ((line[i] == '\n') && (i == (line_len -1))) { *ptr = '\n'; ptr++; } else { strcpy(ptr, asctostr(line[i])); ptr += strlen(asctostr(line[i])); } } else if (line[i] < 0) { *ptr = ' '; ptr++; } else { *ptr = line[i]; ptr++; } } *ptr = '\0'; if (console_log) { if (loglevel > LOG_WARNING) { fprintf(stdout, "%s", nline); fflush(stdout); } else { fprintf(stderr, "%s: %s", get_current_logtype(loglevel), nline); fflush(stderr); } } fprintf(log_fp, "%s [%d] %s: %s", get_current_date(), (int)getpid(), get_current_logtype(loglevel), nline); fflush(log_fp); close_log(); } smsclient-2.0.8z/src/logfile/logfile.h0000644000175000017500000000404210127274514017611 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* logfile/logfile.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #define LOG_OFF 0 #define LOG_ERROR 1 #define LOG_WARNING 2 #define LOG_STANDARD 3 #define LOG_VERBOSE 4 #define LOG_VERYVERBOSE 5 #define MAX_LOG_LINE 4096 /* -------------------------------------------------------------------- */ void open_log(void); void close_log(void); void set_logfile(char *logfile); void set_loglevel(int loglevel); void set_consolelog(int send_to_console_log); #if !defined(__GNUC__) void lprintf(int loglevel, const char *fmt, ...); #else void lprintf(int loglevel, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); #endif /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/logfile/Makefile0000644000175000017500000000330210127274514017455 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id: Makefile,v 5.1 1998/02/01 07:10:39 root Exp root $ # -------------------------------------------------------------------- include ../../Makefile.config # -------------------------------------------------------------------- all: logfile.o install: $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -d $(LOGDIR) clean: $(RM) *.o # -------------------------------------------------------------------- logfile.o: logfile.c logfile.h $(CC) $(CFLAGS) -I.. -c logfile.c # -------------------------------------------------------------------- smsclient-2.0.8z/src/error.h0000644000175000017500000001023310127274514015677 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* error.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #define UNDEFINED -1 /* -------------------------------------------------------------------- */ #define EMESSAGETOOLONG 1 #define EUSAGE 2 #define ENOSERVICE 3 #define ENAMEEXPANSION 4 #define ESIGERR 5 #define EOPENLOG 6 #define EMALLOC 7 #define EDIAL 8 /* -------------------------------------------------------------------- */ #define EDELIVERY 10 /* One or more messages were */ /* failed to be delivered */ /* -------------------------------------------------------------------- */ #define EVODAFONE_NORESPONSE 30 #define EVODAFONE_NONUMBER 31 #define EVODAFONE_NOMESSAGE 32 #define EVODAFONE_NODELIVERY 33 #define EORANGE_NORESPONSE 40 #define EORANGE_NOSERVICE 41 #define EORANGE_NONUMBER 42 #define EORANGE_NOMESSAGE 43 #define EORANGE_NODELIVERY 44 #define EORANGE_NODISCONNECT 45 #define EPAGEONE_NORESPONSE 50 #define EPAGEONE_NONUMBER 51 #define EPAGEONE_NOSERVICE 52 #define EPAGEONE_NOMESSAGE 53 #define EPAGEONE_NODELIVERY 54 #define EPAGEONE_ALPHA 55 #define ETAP_NOACK 60 #define ETAP_NOLOGIN 61 #define ETAP_NOREADY 62 #define ETAP_NOMESSAGE 63 #define ETAP_NODELIVERY 64 #define ETAP_NODISCONNECT 65 #define EVODACOM_NORESPONSE 70 #define EVODACOM_NONUMBER 71 #define EVODACOM_NOMESSAGE 72 #define EMTN_NORESPONSE 80 #define EMTN_NONUMBER 81 #define EMTN_NODELIVERY 82 #define EONE2ONE_NORESPONSE 90 #define EONE2ONE_NONUMBER 91 #define EONE2ONE_NOSERVICE 92 #define EONE2ONE_NOMESSAGE 93 #define EONE2ONE_NODELIVERY 94 #define EONE2ONE_ALPHA 95 #define ELIBERTEL_NORESPONSE 100 #define ELIBERTEL_NONUMBER 101 #define ELIBERTEL_NOMESSAGE 102 #define ELIBERTEL_NODELIVERY 103 #define ETIM_NORESPONSE 110 #define ETIM_NONUMBER 111 #define ETIM_NOSERVICE 112 #define ETIM_NOMESSAGE 113 #define ETIM_NODELIVERY 114 #define ETIM_ALPHA 115 #define ETIM_NODISCONNECT 116 #define EVODAPAGE_BLOCK_NOID 120 #define EVODAPAGE_BLOCK_NONUMBER 121 #define EVODAPAGE_BLOCK_NODELIVERY 122 #define ESNPP_NORESPONSE 130 #define ESNPP_NONUMBER 131 #define ESNPP_NOMESSAGE 132 #define ESNPP_NODELIVERY 133 #define ESNPP_NODISCONNECT 134 #define EKPN_NOWELCOME 140 #define EKPN_NORETURN 141 #define EKPN_NOMENU1 142 #define EKPN_NOMENU2 143 #define EKPN_NOMENU3 144 #define EKPN_NONUMBER 145 #define EKPN_NOMESSAGE 146 #define EKPN_NOCONFIRM 147 #define EKPN_NOSEND 149 #define EANSWER_NONUMBER 150 #define EANSWER_NOMESSAGE 151 #define EANSWER_NODELIVERY 152 #define EANSWER_NODISCONNECT 160 #define EANSWER_NOACK 161 #define EANSWER_NOLOGIN 162 #define EUCP_ACKFAILED 170 #define EUCP_BADACK 171 #define EUCP_NORESPONSE 172 /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/README0000644000175000017500000000137010127274502015254 0ustar noodlesnoodlesThe 'src' directory has been split to tidy things up. The server daemon is unfinished, currently all of the delivery is carried out by the client. The aim is to move the delivery from the client to the server, which will handle all of the queueing and allow for retries, batching and deferring jobs. The gs_parser has replaced the parser used in the client, it's a lot more powerful and flexible. Directory Notes ./ Common files ./client 'sms_client' 'sms_address' ./server 'smsd' 'snppd' ./driver ./parser ./lock ./resource ./queue 'queue' ./comms ./logfile ./common ./terminal 'terminal' 'client' 'server' 'snoop' 'mdup' smsclient-2.0.8z/src/queue/0000755000175000017500000000000011007575275015530 5ustar noodlesnoodlessmsclient-2.0.8z/src/queue/fread.c0000644000175000017500000000515510127274516016757 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* fread.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include "fread.h" #include "error.h" #include "logfile/logfile.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ char *slurp_file(char *filename, int *filelen) { FILE *fp; char *query_string; int total_read, len, max_len, bytes_read; fp = fopen(filename, "rb"); if (fp == NULL) { lprintf(LOG_ERROR, "Opening file '%s'\n", filename); return NULL; } query_string = (char *)malloc(sizeof(char) * (BLK_SIZE +1)); if (query_string == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } total_read = 0; len = BLK_SIZE; max_len = BLK_SIZE; bytes_read = fread(&query_string[total_read], 1, len, fp); while(bytes_read != 0) { len -= bytes_read; total_read += bytes_read; if (len == 0) { query_string = (char *)realloc(query_string, sizeof(char) * (max_len + BLK_SIZE +1)); if (query_string == NULL) { return NULL; } len = BLK_SIZE; max_len += BLK_SIZE; } bytes_read = fread(&query_string[total_read], 1, len, fp); } if (!feof(fp)) { lprintf(LOG_ERROR, "Expecting EOF\n"); free(query_string); return NULL; } fclose(fp); *filelen = total_read; return query_string; } smsclient-2.0.8z/src/queue/queue.c0000644000175000017500000002707510127274516017027 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* queue.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "npipe.h" #include "process.h" #include "resource/resource.h" #include "lock/lock.h" #include "parser/gs_translate.h" #include "driver/driver.h" #include "version.h" #include "parser/gs_api/gs_create.h" #include "parser/gs_api/gs_getdict.h" /* -------------------------------------------------------------------- */ #if !defined(MVERSION) #error "MVERSION undefined" #else #define VERSION MVERSION #endif #if !defined(MSMSDLOGFILE) #error "MSMSDLOGFILE undefined" #else #define LOGFILE MSMSDLOGFILE #endif #if !defined(MSMSDLOGLEVEL) #error "MSMSDLOGLEVEL undefined" #else #define LOGLEVEL MSMSDLOGLEVEL #endif /* -------------------------------------------------------------------- */ char queue_lockfile[512], queue_errordir[512], queue_queuedir[512]; char *queue_spool, *queue_incoming, *queue_services, *queue_errors, *queue_named_pipes, *queue_locks; TOKEN_HEAP *queue_services_heap; static RESOURCE resource_list[] = { { RESOURCE_STRING, "directories.spool", 0, 1, NULL, 0, "/var/spool/sms", 0, &queue_spool }, { RESOURCE_STRING, "directories.incoming", 0, 1, NULL, 0, "incoming", 0, &queue_incoming }, { RESOURCE_STRING, "directories.services", 0, 1, NULL, 0, "services", 0, &queue_services }, { RESOURCE_STRING, "directories.errors", 0, 1, NULL, 0, "errors", 0, &queue_errors }, { RESOURCE_STRING, "directories.named_pipes", 0, 1, NULL, 0, "named_pipes", 0, &queue_named_pipes }, { RESOURCE_STRING, "directories.locks", 0, 1, NULL, 0, "locks", 0, &queue_locks }, { RESOURCE_HEAP, "services", 0, 1, NULL, 0, NULL, 0, &queue_services_heap }, { RESOURCE_NULL, NULL, 0, 1, NULL, 0, NULL, 0, NULL } }; #define SPOOLDIR queue_spool #define LOCKDIR queue_locks #define ERRORDIR queue_errors #define INCOMINGDIR queue_incoming #define SERVICESDIR queue_services #define NAMEDPIPESDIR queue_named_pipes /* -------------------------------------------------------------------- */ #if !defined(MSERVICEDIR) #error "MSERVICEDIR undefined" #else #define SERVICEDIR MSERVICEDIR #endif #define DAEMONCONFIGFILE (MSERVICEDIR "/sms_daemons") /* -------------------------------------------------------------------- */ volatile int term_flag = FALSE; /* -------------------------------------------------------------------- */ static void exit_func(int sig); static void usage(char *file); static int deamon_init(void); static int install_sighandlers(void); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void exit_func(int sig) { term_flag = TRUE; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int install_sighandlers(void) { struct sigaction act, oact; act.sa_handler = exit_func; sigemptyset(&act.sa_mask); act.sa_flags = 0; if (sigaction(SIGTERM, &act, &oact) != 0) { return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int deamon_init(void) { pid_t pid; set_consolelog(FALSE); pid = fork(); if (pid < 0) { lprintf(LOG_ERROR, "fork() failed\n"); return -1; } else if (pid != 0) { exit(0); } if (setsid() < 0) /* Become session leader */ { lprintf(LOG_ERROR, "setsid() failed\n"); return -1; } if (chdir("/") < 0) /* Change working directory */ { lprintf(LOG_ERROR, "chdir() failed\n"); return -1; } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void usage(char *file) { lprintf(LOG_STANDARD, "Usage: %s [-l loglevel] service\n", file); lprintf(LOG_STANDARD, " %s -v\n", file); lprintf(LOG_STANDARD, " %s -a\n", file); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void release_lock(void) { resource_unlock(queue_lockfile); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int list_services(TOKEN_HEAP *heap) { /* unfinished */ return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char *argv[]) { DEVICE_ENTRY *device; int c, i, list_services_flag; char *ptr, service_pipe[512], *service, *protocol, *value; /* ---------------------------- */ set_logfile(LOGFILE); set_loglevel(LOGLEVEL); set_consolelog(TRUE); /* ---------------------------- */ list_services_flag = FALSE; while ((c = getopt (argc, argv, "l:va")) != -1) { switch (c) { case 'l': set_loglevel((int)strtol(optarg, &ptr, 10)); if (ptr == optarg) { lprintf(LOG_ERROR, "Option l requires an argument\n"); usage(argv[0]); return -1; } break; case 'v': lprintf(LOG_STANDARD, "queue %s\n", VERSION); return 0; case 'a': list_services_flag = TRUE; break; case '?': lprintf(LOG_ERROR, "Unknown option `-%c'\n", optopt); usage(argv[0]); return -1; default: return -1; } } /* -------------------------------------------------------------------- */ if (read_resource_file(DAEMONCONFIGFILE, resource_list, 1) == RESOURCE_FILE_ERROR) { lprintf(LOG_ERROR, "Failed to read resource file '%s'\n", DAEMONCONFIGFILE); return -1; } if (list_services_flag) { return list_services(queue_services_heap); } /* -------------------------------------------------------------------- */ if ((argc - optind) != 1) { usage(argv[0]); return -1; } service = argv[optind]; /* -------------------------------------------------------------------- */ if ((value = get_strvalue(queue_services_heap, service)) != NULL) { lprintf(LOG_VERBOSE, "Service '%s' Found\n", service); if (strcmp(value, "ENABLED") == 0) { lprintf(LOG_VERBOSE, "Service '%s' is enabled\n", service); } else { lprintf(LOG_WARNING, "Service '%s' is NOT enabled\n", service); return -1; } if ((protocol = get_protocol(service)) == NULL) { lprintf(LOG_ERROR, "Service '%s' has no entry for 'protocol'\n", service); return -1; } } else { lprintf(LOG_ERROR, "Service '%s' Not Found\n", service); return -1; } /* -------------------------------------------------------------------- */ strcpy(queue_queuedir, SPOOLDIR); sms_filecat(queue_queuedir, SERVICESDIR); sms_filecat(queue_queuedir, service); if (access(queue_queuedir, F_OK) == -1) { lprintf(LOG_ERROR, "Queue directory '%s' Not Found\n", queue_queuedir); return -1; } /* -------------------------------------------------------------------- */ strcpy(queue_errordir, SPOOLDIR); sms_filecat(queue_errordir, ERRORDIR); sms_filecat(queue_errordir, service); if (access(queue_errordir, F_OK) == -1) { lprintf(LOG_ERROR, "Queue Error directory '%s' Not Found\n", queue_errordir); return -1; } /* -------------------------------------------------------------------- */ /* Initialise the driver for this queue */ /* From here on we access the driver using the 'device' entry */ /* -------------------------------------------------------------------- */ device = get_device(protocol); if (device == NULL) { lprintf(LOG_ERROR, "Driver for service %s NOT found\n", service); return -1; } (*device->init)(service, device); /* -------------------------------------------------------------------- */ strcpy(queue_lockfile, SPOOLDIR); sms_filecat(queue_lockfile, LOCKDIR); sms_filecat(queue_lockfile, service); resource_check_lockdir(queue_lockfile); if (resource_lock(queue_lockfile)) { lprintf(LOG_ERROR, "Queue aborted, lockfile held by another queue daemon\n"); return -1; } atexit(release_lock); /* -------------------------------------------------------------------- */ #if 0 if (install_sighandlers() == -1) { return -1; } if (deamon_init() == -1) { return -1; } #endif /* -------------------------------------------------------------------- */ lprintf(LOG_STANDARD, "Starting SMS Queue for '%s'...\n", service); strcpy(service_pipe, SPOOLDIR); sms_filecat(service_pipe, NAMEDPIPESDIR); sms_filecat(service_pipe, service); lprintf(LOG_VERBOSE, "Creating pipe '%s'\n", service_pipe); if (create_named_pipe(service_pipe) == -1) { lprintf(LOG_ERROR, "create_named_pipe() failed\n"); return -1; } /* -------------------------------------------------------------------- */ #if 1 lprintf(LOG_VERBOSE, "Flushing queue...\n"); process_queue(queue_queuedir, queue_errordir, device); #endif while(!term_flag) { lprintf(LOG_VERBOSE, "Waiting on named pipe '%s'...\n", service_pipe); if (block_on_named_pipe(service_pipe) == -1) { if (errno == EINTR) { continue; } else { lprintf(LOG_ERROR, "block_on_named_pipe() failed\n"); return -1; } } lprintf(LOG_VERBOSE, "Woken by write to '%s'\n", service_pipe); lprintf(LOG_VERBOSE, "Processing queue '%s'...\n", queue_queuedir); process_queue(queue_queuedir, queue_errordir, device); } if (term_flag) { lprintf(LOG_STANDARD, "SMS Queue for '%s' received TERM signal\n", service_pipe); } lprintf(LOG_STANDARD, "Stopping SMS Queue for '%s'...\n", service_pipe); lprintf(LOG_VERBOSE, "Deleting named pipe '%s'\n", service_pipe); if (delete_named_pipe(service_pipe) == -1) { lprintf(LOG_ERROR, "delete_named_pipe() failed\n"); return -1; } resource_unlock(queue_lockfile); return 0; } smsclient-2.0.8z/src/queue/version.h0000644000175000017500000000003210127274516017355 0ustar noodlesnoodles#define MVERSION "2.0.8u" smsclient-2.0.8z/src/queue/fread.h0000644000175000017500000000323210127274516016756 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* fread.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #if !defined(_FREAD_H_) #define _FREAD_H_ #define BLK_SIZE 4096 /* -------------------------------------------------------------------- */ char *slurp_file(char *filename, int *filelen); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ #endif smsclient-2.0.8z/src/queue/process.h0000644000175000017500000000275110127274516017360 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* process.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include "driver/driver.h" int process_queue(char *queue, char *error, DEVICE_ENTRY *device); /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/queue/README0000644000175000017500000000070210127274516016403 0ustar noodlesnoodles At startup we must spawn a queueing daemon per queue. This is done from an rc script during the init process, and takes the form smsd_queues [start|stop] It must find out which queues are allowed and start each one or stop each one. The daemon should be shutdown by sending it a SIGTERM signal, this ensure that it can clean up any named pipes it may have created. Programs sms-queue (per Queue) sms-monitor sms-server (per Connection) smsclient-2.0.8z/src/queue/npipe.c0000644000175000017500000001200010127274516016774 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* npipe.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include #include "npipe.h" #include "common/common.h" #include "logfile/logfile.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int create_named_pipe(char *file) { int create_fifo; create_fifo = 1; while(create_fifo) { if (mkfifo(file, O_RDWR|O_CREAT|O_NONBLOCK) == -1) { if (errno == EEXIST) { lprintf(LOG_WARNING, "Named Pipe '%s' already exists.\n", file); lprintf(LOG_WARNING, "Deleting Named Pipe...\n"); if (unlink(file) == -1) { lprintf(LOG_WARNING, "Failed to delete Named Pipe...\n"); return -1; } lprintf(LOG_WARNING, "Done\n"); } else { return -1; } } else { create_fifo = 0; } } return 0; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int delete_named_pipe(char *file) { return unlink(file); } /* -------------------------------------------------------------------- */ /* Read one character from named pipe. */ /* If no character is available block. */ /* On receipt of 'signal' return with -1 and errno set to EINTR */ /* */ /* Return Values: */ /* 0 Data Present */ /* -1 Error or receipt of signal */ /* with 'errno' 0 indicates EOF */ /* -------------------------------------------------------------------- */ int block_on_named_pipe(char *file) { fd_set readfds, writefds, exceptfds; int nfds, rtval, fd, waiting, c, res; /* ---------------------------- */ fd = open(file, O_RDWR|O_NONBLOCK); if (fd == -1) { return -1; } nfds = fd +1; FD_ZERO(&writefds); FD_ZERO(&readfds); FD_ZERO(&exceptfds); waiting = TRUE; while(waiting) { FD_SET(fd,&readfds); if ((rtval = select(nfds, &readfds, NULL, NULL, NULL)) != 0) { if (rtval > 0) /* Select Woken on FDs */ { if (FD_ISSET(fd, &readfds)) { res = read(fd, &c, 1); while(res != 1) { if (res == -1) { close(fd); return -1; } else if (res == 0) { errno = 0; close(fd); return -1; } res = read(fd, &c, 1); } waiting = FALSE; } } else if (rtval == -1) /* Error Return Value */ { close(fd); return -1; } } } close(fd); return 0; } /* -------------------------------------------------------------------- */ /* Read one character from named pipe. */ /* If no character is available DO NOT block. */ /* */ /* Return Values: */ /* 1 Data Present */ /* 0 No Data Present */ /* -1 Error */ /* -------------------------------------------------------------------- */ int read_named_pipe(char *file) { int fd, c, res; /* ---------------------------- */ fd = open(file, O_RDWR|O_NONBLOCK); if (fd == -1) { return -1; } res = read(fd, &c, 1); if (res == -1) { if (errno == EAGAIN) { res = 0; /* Would have blocked */ } } close(fd); return res; } /* -------------------------------------------------------------------- */ /* Write one character to named pipe. */ /* -------------------------------------------------------------------- */ int write_to_named_pipe(char *file) { int fd, res, c; fd = open(file, O_RDWR|O_NONBLOCK); if (fd == -1) { return -1; } c = 'X'; res = write(fd, &c, 1); while(res != 1) { if (res == -1) { if (errno != EINTR) { return -1; } } res = write(fd, &c, 1); } close(fd); return 0; } smsclient-2.0.8z/src/queue/test_write.c0000644000175000017500000000366710127274516020075 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* test_write.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char **argv) { int fd; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(-1); } fd = open(argv[1], O_RDWR|O_NONBLOCK); if (fd == -1) { fprintf(stderr, "Error: Opening file '%s'\n", argv[1]); exit(-1); } if (write(fd, " ", 1) == -1) { fprintf(stderr, "Error: write() failed\n"); exit(-1); } close(fd); return 0; } smsclient-2.0.8z/src/queue/test_queue.c0000644000175000017500000000456510127274516020065 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* test_queue.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include "common/common.h" #include "npipe.h" #include "process.h" /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int main(int argc, char *argv[]) { /* ---------------------------- */ if (argc != 3) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(-1); } if (create_named_pipe(argv[1]) == -1) { fprintf(stderr, "Error: create_named_pipe() failed\n"); exit(-1); } fprintf(stdout, "Waiting on named pipe '%s'...\n", argv[1]); if (block_on_named_pipe(argv[1]) == -1) { fprintf(stderr, "Error: block_on_named_pipe() failed\n"); exit(-1); } fprintf(stdout, "Woken by write to '%s'\n", argv[1]); fprintf(stdout, "Processing queue '%s'...\n", argv[2]); process_queue(argv[2]); fprintf(stdout, "Done\n"); fprintf(stdout, "Deleting named pipe '%s'\n", argv[1]); if (delete_named_pipe(argv[1]) == -1) { fprintf(stderr, "Error: delete_named_pipe() failed\n"); exit(-1); } return 0; } smsclient-2.0.8z/src/queue/npipe.h0000644000175000017500000000307110127274516017011 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* npipe.h */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ int create_named_pipe(char *file); int delete_named_pipe(char *file); int block_on_named_pipe(char *file); int read_named_pipe(char *file); int write_to_named_pipe(char *file); /* -------------------------------------------------------------------- */ smsclient-2.0.8z/src/queue/process.c0000644000175000017500000004064510127274516017357 0ustar noodlesnoodles/* -------------------------------------------------------------------- */ /* SMS Client, send messages to mobile phones and pagers */ /* */ /* process.c */ /* */ /* Copyright (C) 1997,1998,1999 Angelo Masci */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Library General Public */ /* License as published by the Free Software Foundation; either */ /* version 2 of the License, or (at your option) any later version. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Library General Public License for more details. */ /* */ /* You should have received a copy of the GNU Library General Public */ /* License along with this library; if not, write to the Free */ /* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* */ /* You can contact the author at this e-mail address: */ /* */ /* angelo@styx.demon.co.uk */ /* */ /* -------------------------------------------------------------------- */ /* $Id$ -------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include "common/common.h" #include "logfile/logfile.h" #include "process.h" #include "parser/gs_token.h" #include "parser/gs_translate.h" #include "driver/driver.h" #include "fread.h" #include "error.h" /* -------------------------------------------------------------------- */ #define MAX_PATH 256 /* -------------------------------------------------------------------- */ #define TF_UNKNOWN 0 #define TF_CONTROL 1 #define TF_DATA 2 /* -------------------------------------------------------------------- */ struct file_list_struct { char *name, *data, *dest_id; int type, data_len; time_t mtime; TOKEN_HEAP *heap; struct file_list_struct *next; }; typedef struct file_list_struct FILE_LIST; /* -------------------------------------------------------------------- */ static FILE_LIST *add_front_file_item(FILE_LIST *list, char *name, time_t mtime, int type); static FILE_LIST *qsort_list(FILE_LIST *list); static FILE_LIST *get_first_control_file(FILE_LIST *list); static FILE_LIST *get_next_control_file(FILE_LIST *list); static void dump_list(FILE_LIST *list); static void free_list(FILE_LIST *list); static int reject_file(char *file, char *queue_dir, char *error_dir); static int remove_file(char *file, char *queue_dir, char *error_dir); static int num_items_in_list(FILE_LIST *list); static int file_item_compare(const void *item1, const void *item2); static FILE_LIST *generate_file_list(int *num, char *queue); /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static FILE_LIST *add_front_file_item(FILE_LIST *list, char *name, time_t mtime, int type) { FILE_LIST *item; item = (FILE_LIST *)malloc(sizeof(FILE_LIST)); if (item == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } item->name = (char *)malloc(sizeof(char) * (strlen(name) +1)); if (item->name == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } strcpy(item->name, name); item->mtime = mtime; item->type = type; item->next = list; item->heap = NULL; item->data = NULL; return item; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int num_items_in_list(FILE_LIST *list) { int count; FILE_LIST *item; count = 0; item = list; while(item != NULL) { count++; item = item->next; } return count; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static int file_item_compare(const void *item1, const void *item2) { time_t mtime_1, mtime_2; mtime_1 = (*(FILE_LIST **)item1)->mtime; mtime_2 = (*(FILE_LIST **)item2)->mtime; if (mtime_1 > mtime_2) { return 1; } if (mtime_1 < mtime_2) { return -1; } return strcmp((*(FILE_LIST **)item1)->name, (*(FILE_LIST **)item2)->name); } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static FILE_LIST *qsort_list(FILE_LIST *list) { int count, i; FILE_LIST **file_list_array, *item; if (list == NULL) { return NULL; } count = num_items_in_list(list); file_list_array = (FILE_LIST **)malloc(sizeof(FILE_LIST *) * count); if (file_list_array == NULL) { lprintf(LOG_ERROR, "malloc() failed\n"); exit(EMALLOC); } item = list; for (i=0; item != NULL; i++) { file_list_array[i] = item; item = item->next; } qsort(file_list_array, count, sizeof(FILE_LIST *), file_item_compare); list = file_list_array[0]; for (i=0; inext = file_list_array[i+1]; } file_list_array[i]->next = NULL; free(file_list_array); return list; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void dump_list(FILE_LIST *list) { FILE_LIST *item; char *stype; if (list == NULL) { return; } item = list; while(item != NULL) { if (item->type == TF_CONTROL) { stype = "CONTROL"; } else if (item->type == TF_DATA) { stype = "DATA"; } else { stype = "UNKNOWN"; } lprintf(LOG_VERBOSE, "%s %d %s\n", item->name, (int)item->mtime, stype); item = item->next; } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static FILE_LIST *get_first_control_file(FILE_LIST *list) { FILE_LIST *item; item = list; while (item != NULL) { if (strncmp(item->name, "cf", 2) == 0) { return item; } item = item->next; } return NULL; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static FILE_LIST *get_next_control_file(FILE_LIST *list) { FILE_LIST *item; if (list == NULL) { return NULL; } item = list->next; while (item != NULL) { if (strncmp(item->name, "cf", 2) == 0) { return item; } item = item->next; } return NULL; } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ static void free_list(FILE_LIST *list) { FILE_LIST *prev_item, *item; if (list == NULL) { return; } item = list; while(item != NULL) { prev_item = item; item = item->next; if (prev_item->heap != NULL) { free_heap(prev_item->heap); } free(prev_item->name); free(prev_item); } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ extern char queue_queuedir[], queue_errordir[]; static void *access_get_first(void *list); static void *access_get_next(void *node); static char *access_get_number(void *node); static char *access_get_message(void *node); static void *access_get_first(void *list) { /* check item is valid else get next*/ lprintf(LOG_VERYVERBOSE, "Getting first file\n"); return (void *)get_first_control_file((FILE_LIST *)list); } static void *access_get_next(void *node) { /* check item is valid else get next*/ FILE_LIST *item, *new_list; int num; item = get_next_control_file((FILE_LIST *)node); if (item == NULL) { /* ------------------------------------------------------------ */ /* We have processed all of the file in the list. */ /* We should now check that new files/items haven't been added */ /* while we were busy sending. If they were then we want to add */ /* them to out list of files left to process. */ /* */ /* NOTE - As files which contained error have been moved to the */ /* appropriate errors directory we needn't worry about */ /* processing the same file twice. */ /* ------------------------------------------------------------ */ lprintf(LOG_VERYVERBOSE, "Last item processed, checking for additional files...\n"); new_list = generate_file_list(&num, queue_queuedir); if (new_list == NULL) { if (num != 0) { lprintf(LOG_ERROR, "Generating file list\n"); exit(-1); } } else { lprintf(LOG_VERYVERBOSE, "Found %d additional files\n", num); } /* ------------------------------------------------------------ */ /* We must skip to the end of our list as the current */ /* item may not be the last! */ /* Now we append the new list if any. */ /* ------------------------------------------------------------ */ item = (FILE_LIST *)node; while(item->next != NULL) { item = item->next; } item->next = new_list; item = item->next; } return item; } static char *access_get_number(void *node) { return get_strvalue(((FILE_LIST *)node)->heap, "destination_id"); } static char *access_get_message(void *node) { #if 0 sleep(5); #endif return ((FILE_LIST *)node)->data; } static void access_set_delivery(void *node, int result) { FILE_LIST *item; item = (FILE_LIST *)node; /* if delivery successful, remove file. */ /* if failed move to error directory */ if (result == 0) { lprintf(LOG_VERBOSE, "Successfully delivered '%s'\n", item->name); if (remove_file(item->name, queue_queuedir, queue_errordir) == -1) { lprintf(LOG_WARNING, "Failed to Remove '%s'\n", item->name); exit(-1); } } else { lprintf(LOG_WARNING, "Failed to deliver '%s'\n", item->name); if (reject_file(item->name, queue_queuedir, queue_errordir) == -1) { lprintf(LOG_WARNING, "Failed to Move '%s'\n", item->name); exit(-1); } } } /* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */ int process_queue(char *queue, char *error, DEVICE_ENTRY *device) { FILE_LIST *file_list = NULL; int num; while ((file_list = generate_file_list(&num, queue)) != NULL) { /* ------------------------------------------------------------ */ /* Dispatch driver function to deliver messages. */ /* ------------------------------------------------------------ */ (*device->main)(file_list, access_get_first, access_get_next, access_get_number, access_get_message, access_set_delivery, device->env); lprintf(LOG_VERYVERBOSE, "Finished sending messages.\n"); /* ------------------------------------------------------------ */ free_list(file_list); } if (num == 0) { lprintf(LOG_VERBOSE, "No files to process.\n"); } else { lprintf(LOG_ERROR, "Processing queue '%s'.\n", queue); return -1; } return 0; } /* -------------------------------------------------------------------- */ /* Remove file from from 'queue' directory */ /* */ /* Return Values: */ /* 0 Success */ /* -1 Failure */ /* -------------------------------------------------------------------- */ static int remove_file(char *file, char *queue_dir, char *error_dir) { char nname[512], dname[512]; int dfres, cfres; if ((file[0] == 'c') && (file[1] == 'f')) { strcpy(dname, file); dname[0] = 'd'; dname[1] = 'f'; lprintf(LOG_VERBOSE, "Removing '%s'\n", dname); strcpy(nname, queue_dir); sms_filecat(nname, dname); dfres = unlink(nname); } lprintf(LOG_VERBOSE, "Removing '%s'\n", file); strcpy(nname, queue_dir); sms_filecat(nname, file); cfres = unlink(nname); return (dfres || cfres); } /* -------------------------------------------------------------------- */ /* Move file from from 'queue' directory into 'error' directory */ /* */ /* Return Values: */ /* 0 Success */ /* -1 Failure */ /* -------------------------------------------------------------------- */ static int reject_file(char *file, char *queue_dir, char *error_dir) { char nname[512], oname[512], dname[512]; int dfres, cfres; if ((file[0] == 'c') && (file[1] == 'f')) { strcpy(dname, file); dname[0] = 'd'; dname[1] = 'f'; lprintf(LOG_WARNING, "Moving '%s' to '%s'\n", dname, queue_errordir); strcpy(oname, queue_dir); sms_filecat(oname, dname); strcpy(nname, error_dir); sms_filecat(nname, dname); dfres = rename(oname, nname); } lprintf(LOG_WARNING, "Moving '%s' to '%s'\n", file, queue_errordir); strcpy(oname, queue_dir); sms_filecat(oname, file); strcpy(nname, error_dir); sms_filecat(nname, file); cfres = rename(oname, nname); return (dfres || cfres); } /* -------------------------------------------------------------------- */ /* Generate sorted list of entries in queue directory. */ /* Parse each entry and add a token_heap to it. */ /* */ /* Return Values: */ /* NULL and 'num' set to -1 on error */ /* -------------------------------------------------------------------- */ static FILE_LIST *generate_file_list(int *num, char *queue) { DIR *dir; struct dirent *entry; struct stat status; char cwd[MAX_PATH+1]; char dname[512], *data, *dest_id; FILE_LIST *file_list = NULL; int type, data_len; TOKEN_HEAP *heap; *num = 0; dir = opendir(queue); if (dir == NULL) { *num = -1; lprintf(LOG_ERROR, "Failed to open directory '%s'\n", queue); return NULL; } if (getcwd(cwd, MAX_PATH+1) == NULL) { *num = -1; lprintf(LOG_ERROR, "getcwd() failed\n"); return NULL; } if (chdir(queue) != 0) { *num = -1; lprintf(LOG_ERROR, "chdir() failed\n"); return NULL; } while((entry = readdir(dir)) != NULL) { if ((strcmp(entry->d_name, ".") != 0) && (strcmp(entry->d_name, "..") != 0)) { if (stat(entry->d_name, &status) != 0) { lprintf(LOG_ERROR, "stat() failed\n"); return NULL; } if (!S_ISDIR(status.st_mode)) { if (strncmp(entry->d_name, "cf", 2) == 0) { type = TF_CONTROL; } else if (strncmp(entry->d_name, "df", 2) == 0) { type = TF_DATA; } else { type = TF_UNKNOWN; } if (type != TF_UNKNOWN) { if (type == TF_CONTROL) { /* IF file is a control file parse it. */ /* IF control file is invalid DO NOT add it */ /* to the file list. */ heap = gs_parse_file(entry->d_name); if (heap == NULL) { lprintf(LOG_WARNING, "Rejecting file '%s'\n", entry->d_name); if (reject_file(entry->d_name, queue_queuedir, queue_errordir) == -1) { lprintf(LOG_WARNING, "Failed to Move '%s'\n", entry->d_name); exit(-1); } } else { /* validate entries in control file. */ /* IF not valid DO NOT add to list. */ /* It might be nice to slurp the contents */ /* of the data file into 'item' */ if ((dest_id = get_strvalue(heap, "destination_id")) == NULL) { lprintf(LOG_VERBOSE, "Could not find 'destination_id'\n"); if (reject_file(entry->d_name, queue_queuedir, queue_errordir) == -1) { lprintf(LOG_WARNING, "Failed to Move '%s'\n", entry->d_name); exit(-1); } } else { strcpy(dname, entry->d_name); dname[0] = 'd'; dname[1] = 'f'; lprintf(LOG_VERBOSE, "Reading Datafile '%s'\n", dname); data = slurp_file(dname, &data_len); if (data == NULL) { lprintf(LOG_VERBOSE, "Failed to read datafile '%s'\n", dname); if (reject_file(entry->d_name, queue_queuedir, queue_errordir) == -1) { lprintf(LOG_WARNING, "Failed to Move '%s'\n", entry->d_name); exit(-1); } } else { file_list = add_front_file_item(file_list, entry->d_name, status.st_mtime, type); file_list->heap = heap; file_list->data = data; file_list->data_len = data_len; file_list->dest_id = dest_id; *num = *num +1; } } } } } else { lprintf(LOG_WARNING, "Found file '%s', expecting Control or Data File\n", entry->d_name); } } } } if (closedir(dir) != 0) { *num = -1; lprintf(LOG_ERROR, "closedir() failed\n"); return NULL; } if (file_list != NULL) { file_list = qsort_list(file_list); } if (chdir(cwd) != 0) { *num = -1; lprintf(LOG_ERROR, "chdir() failed\n"); return NULL; } dump_list(file_list); return file_list; } smsclient-2.0.8z/src/queue/Makefile0000644000175000017500000001022511007575275017170 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- include ../../Makefile.config include ../../Makefile.modemlib # -------------------------------------------------------------------- all: ../../bin/queue install: ../../bin/queue $(INSTALL) -m 755 -d $(BINDIR) $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 ../../bin/queue $(BINDIR) uninstall: $(RM) $(BINDIR)/queue test: test_queue test_write clean: $(RM) *.o *.bak test_queue test_write ../../bin/queue # -------------------------------------------------------------------- INCLUDE = -I.. -I../parser # -------------------------------------------------------------------- gs_parser: cd ../parser ; $(MAKE) gs_parser.a gs_api: cd ../parser/gs_api ; $(MAKE) gs_api.a resource: cd ../resource ; $(MAKE) resource.a driver: cd ../driver ; $(MAKE) lock: cd ../lock ; $(MAKE) lock.a comms: cd ../comms ; $(MAKE) comms.a # -------------------------------------------------------------------- version.h: ../../.version echo "#define MVERSION \"`awk '{ print $1 }' ../../.version`\"" >version.h # -------------------------------------------------------------------- npipe.o: npipe.c ../common/common.h ../logfile/logfile.h npipe.h $(CC) $(CFLAGS) -c npipe.c $(INCLUDE) process.o: process.c ../common/common.h ../logfile/logfile.h process.h $(CC) $(CFLAGS) -c process.c $(INCLUDE) fread.o: fread.c $(CC) $(CFLAGS) -c fread.c $(INCLUDE) test_queue.o: test_queue.c ../common/common.h ../logfile/logfile.h npipe.h $(CC) $(CFLAGS) -c test_queue.c $(INCLUDE) queue.o: queue.c ../common/common.h ../logfile/logfile.h npipe.h version.h $(CC) $(CFLAGS) -c queue.c $(INCLUDE) -DMSERVICEDIR="\"$(MSERVICEDIR)\"" -DMSMSDLOGLEVEL=3 -DMSMSDLOGFILE="\"$(MSMSDLOGFILE)\"" test_write.o: test_write.c ../common/common.h ../logfile/logfile.h $(CC) $(CFLAGS) -c test_write.c $(INCLUDE) # -------------------------------------------------------------------- ../../bin/queue: queue.o fread.o npipe.o process.o ../logfile/logfile.o ../common/common.o gs_parser gs_api resource lock driver comms ../../Makefile.modemlib $(CC) $(CFLAGS) queue.o fread.o npipe.o process.o -o ../../bin/queue ../logfile/logfile.o ../common/common.o ../resource/resource.a ../parser/gs_parser.a ../parser/gs_api/gs_api.a ../lock/lock.a ../driver/sms_driver.a ../comms/comms.a $(MLIBS) $(XTRALIBS) # -------------------------------------------------------------------- test_queue: test_queue.o npipe.o process.o ../common/common.h ../logfile/logfile.h npipe.h process.h $(CC) $(CFLAGS) test_queue.o npipe.o process.o -o test_queue test_write: test_write.o ../common/common.h ../logfile/logfile.h npipe.h $(CC) $(CFLAGS) test_write.o -o test_write # -------------------------------------------------------------------- ../logfile/logfile.o: ../logfile/logfile.c ../logfile/logfile.h cd ../logfile ; $(MAKE) logfile.o ../common/common.o: ../common/common.c ../common/common.h cd ../common ; $(MAKE) common.o # -------------------------------------------------------------------- smsclient-2.0.8z/src/Makefile0000644000175000017500000000427510127274502016043 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id: Makefile,v 5.1 1998/02/01 07:10:39 root Exp root $ # -------------------------------------------------------------------- include ../Makefile.config # -------------------------------------------------------------------- all: cd common ; $(MAKE) cd logfile ; $(MAKE) cd driver ; $(MAKE) cd client ; $(MAKE) cd parser ; $(MAKE) # cd server ; $(MAKE) # cd queue ; $(MAKE) cd terminal ; $(MAKE) install: cd logfile ; $(MAKE) install cd client ; $(MAKE) install # cd server ; $(MAKE) install # cd queue ; $(MAKE) install uninstall: # cd queue ; $(MAKE) uninstall # cd server ; $(MAKE) uninstall cd client ; $(MAKE) uninstall cd logfile ; $(MAKE) uninstall clean: cd common ; $(MAKE) clean cd logfile ; $(MAKE) clean cd client ; $(MAKE) clean cd driver ; $(MAKE) clean cd parser ; $(MAKE) clean # cd server ; $(MAKE) clean # cd queue ; $(MAKE) clean cd comms ; $(MAKE) clean cd resource ; $(MAKE) clean cd lock ; $(MAKE) clean cd terminal ; $(MAKE) clean # -------------------------------------------------------------------- smsclient-2.0.8z/README0000644000175000017500000003222710127274463014500 0ustar noodlesnoodles Linux SMS Client 2.0.8 by (c) 1997,1998,1999,2000 Angelo Masci ============================================================== A simple UNIX client Allowing you to send SMS messages to mobile phones and pagers. The software currently supports a number of providers and protocols: +----------------------------------------------------------------------+ | Service Protocol Notes | +----------------------------------------------------------------------+ | CELLNET TAP Supports multiple sends (see NOTE) | | DETEMOBIL D1 TAP Supports multiple sends (see NOTE) | | D2 UCP | | EPLUS TAP Supports multiple sends (see NOTE) | | AZCOM TAP Supports multiple sends (see NOTE) | | CALLMAX TAP Supports multiple sends (see NOTE) | | TELSTRA TAP Supports multiple sends (see NOTE) | | VODAFONE proprietary UK/Australian Telenote services | | VODAFONE_TAP TAP UK | | ORANGE proprietary Supports multiple sends (see NOTE) | | Includes Hutchinson Pagers | | PAGEONE proprietary Supports multiple sends (see NOTE) | | MINICALL PAGEONE Supports multiple sends (see NOTE) | | ONE2ONE proprietary Supports multiple sends (see NOTE) | | VODAPAGE proprietary Block Mode supported | | VODACOM proprietary | | PTT/KPN Telcom proprietary Supports multiple sends (see NOTE) | | ANSWER proprietary | | MTN proprietary | | LIBERTEL proprietary Supports multiple sends (see NOTE) | | TIM proprietary Supports multiple sends (see NOTE) | | PROXIMUS proprietary | | AMPI TAP | | EUROPOLITAN CIMD Currently in ALPHA and testing | | BTEASYREACH TAP Currently in ALPHA and testing | | SWISSCOM UCP Currently in ALPHA and testing | | TELENOR UCP Currently in ALPHA and testing | | HELLO Currently in ALPHA and testing | | VOICESTREAM TAP Currently in ALPHA and testing | | TELECOM NZ TAP Currently in ALPHA and testing | | SKYTEL TAP Currently in ALPHA and testing | | TELECOM NZ TAP Currently in ALPHA and testing | | TELIA UCP Currently in ALPHA and testing | | NETCOM TAP Currently in ALPHA and testing | | MOBISTAR UCP Currently in ALPHA and testing | | EIRPAGE TAP Currently in ALPHA and testing | +----------------------------------------------------------------------+ | CELLNET_WEB proprietary Currently in ALPHA and testing | | ORANGE_WEB proprietary Currently in ALPHA and testing | | PROXIMUS_WEB proprietary Currently in ALPHA and testing | | ATT_WEB proprietary Currently in ALPHA and testing | | NEXTEL_WEB proprietary Currently in ALPHA and testing | | PAGENET_WEB proprietary Currently in ALPHA and testing | +----------------------------------------------------------------------+ | SNPP* Currently in ALPHA and testing | | GENERIC* Currently in ALPHA and testing | +----------------------------------------------------------------------+ Using an unlisted provider that allow TAP access should be quite straight forward. There are a large number of services that do not appear to use TAP but instead simple user interfaces for interactive use by a user dialing up with a modem. For several UK based services such as these I have written drivers, note that providers often offer more that one service and as such you may require a different driver for each one. NOTE - Services supporting 'multiple sends' allow the same message to be sent to several recipients with only a single connection having to be established, saving the cost of addition connection charges. It should be noted that ORANGE although allowing multiple sends does seem to limit them to a maximum of 3 messages per connection. Likewise, PTT/KPN Telcom has a limit of 2 messages per connection. NOTE - Protocols marked '*' are using ALPHA version drivers. SNPP support is limited as we don't currently have any SNPP servers to connect to other than 'snppd'. The GENERIC driver uses a script to connect to either modem based or tcp/ip based servers, it's still early days for this driver but is interesting to play with. SMS Client 2.0.7 can use the optional libmodem package written by Riccardo Facchetti. Prior to version 2.0.7 this package was a requirement to build and use the SMS Client. You can obtain it from sunsite.unc.edu in /pub/Linux/libs/ as libmodem-1.3.tar.gz NOTE - Prior to version 1.3 of libmodem a patch was required, this is no longer the case. To use libmodem instead of the builtin modem handling routines edit 'Makefile.config' To build the sms_client binary on Linux/Solaris: sh configure make ; make install NOTE - To build the sms_client binary under on a different Operating System copy the appropriate 'Makefile.config.OS' file from the config directory along with 'Makefile', rename the 'Makefile.config.OS' to 'Makefile.config' edit if necessary and run 'make ; make install' Example using the SMS Client: sms-client [SERVICE:]XXXXXXXX "Test Message 1" "Test Message 2" ... | | | | | +-- The message you | | want to send | | Maximum 150 Characters | | | +------------ Mobile or Pager ID | | For mobiles phones this is | usually the telephone number, | In some cases this must be | written in international format. | ie. For UK Numbers remove leading | 0 and add 44 prefix | +---------------------- Optional SERVICE name You can use a simple address book file called sms_addressbook This is your global resource file, it should contain the name of your default service and possibly commonly used numbers. See the sms_addressbook file for examples. Any user can also create a local version of this file which should be placed in their home directory as .sms_addressbook The names are searched for in the user's local resource file and and finally the global resource file, this is so a user can override global names. The sms/sms_services file contains a list of services and the protocols that should be used when sending a message via that service. Each service must have a corresponding SERVICE file in sms/services, this file instructs the software which settings to use for the specified service, the service centre number to dial and additional comms parameters. A number of these service files exist and can be found in the sms/services directory. Configuring Drivers: You may want of modify the number of services that are supported by sms_client, you can do this simply by editing Makefile.config and adding or removing drivers from the DRIVERS line. You must then rebuild and install the sms_client binary. To obtain a list of drivers currently built into your binary simply type: sms_client -d Writing Drivers: This is much more straight forward than you may think. Take a look at src/driver/skeleton.c for an example driver. Return Values: On error sms_client WILL return some useful error codes so that you can determine what went wrong. For each message sent you receive output in the form: [ERROR] SERVICE:NUMBER "MESSAGE" The ERROR is set to 000 for successful delivery any positive value indicates there was a problem in delivery. See sms_error.h for description of values. If all messages were delivered successfully then sms_client returns 0 any other value indcates one or more delivery problems occurred. Contributions: A New 'contrib' directory has been added which contains some useful scripts, at the moment we have: mail2sms (Andy Hawkins) - perl script for forwarding E-Mail via sms. www (David Usherwood) - WWW Frontend NOTE - These scripts were written for sms_client-2.0.5 and may not work correctly with this version as I have not tested them. Credits: I would like to express my thanks to the following individuals for their help in testing, hardware, debugging, support and general feedback: Mike Casella Guy William Hayton David Hill Chris Voce Frans Andersson Jonathan M. Hunter Geoff Peacock Harald Milz Job J. van Gorkum Nick Andrew Jon Laughton Michael Josephson Dimitri Brukakis Are Tysland Petter Reinholdtsen Chris Berrington Tim Ruehsen Gareth Abel Jeff Duffy Sergio Barresi matth David Ockwell-Jenner Chuck Hurd Jonas Borgstrom Fredrik Bjork Alexander Grapenthin Contrib Credits: Forward queries concerning 'mail2sms' perl script to the author: Andy Hawkins Forward queries concerning 'mail2sms' shell script to the author: Matt Foster Forward queries concerning 'smsweb' to the author: David Usherwood Driver Credits: Forward queries concerning Australian Telenote service using the VODAFONE driver to the patch contributor: Jeremy Laidman Forward queries concerning VODACOM and MTN to the author: Alf Stockton Forward queries concerning VODAPAGE 'verbose' to the author: Neil A. Hillard Forward queries concerning LIBERTEL to the authors: Henk Wevers Aart Koelewijn Forward queries concerning TIM to the authors: Massimo Nuvoli Forward queries concerning PROXIMUS to the author: Mario Brackeva Forward queries concerning AZCOM to the contributor: Brad Smith Forward queries concerning TELSTRA to the contributor: Paul Gampe Forward queries concerning PTT to the contributor: Harold Baur Forward queries concerning ANSWER to the contributor: Paul Andrew Forward queries concerning VSTREAM to the contributor: doughnut Forward queries concerning NZ to the contributor: Robbie Poharama Forward queries concerning SKYTEL to the contributor: Kal Kolberg Forward queries concerning FREEBSD to the contributor: Nick Hibma Forward queries concerning NETCOM to the contributor: Bjorn Rogeberg Forward queries concerning RPM Packages to the contributor: Ross Golder Forward queries concerning Debian Packages to the contributor: Michael Holzt Forward queries concerning MOBISTAR to the contributor: Contact information: This Software is still considered BETA release. If you have any comments, problems, patches and improvements, please contact the author: Angelo Masci WWW Sites: http://www.styx.demon.co.uk/ Mailing List: 'Mark Lewis' has kindly set up a mailing list for SMS Client. If you would like to join, send and email to 'majordomo@medusa.myth.co.uk' with the following text in the body of the message: subscribe sms_client Mark can be contacted via email at mark@mythic.net smsclient-2.0.8z/bin/0000755000175000017500000000000011007610111014340 5ustar noodlesnoodlessmsclient-2.0.8z/contrib/0000755000175000017500000000000010127274473015253 5ustar noodlesnoodlessmsclient-2.0.8z/contrib/mail2sms-shell/0000755000175000017500000000000010127274473020107 5ustar noodlesnoodlessmsclient-2.0.8z/contrib/mail2sms-shell/mail2sms.sh0000755000175000017500000000270510127274473022201 0ustar noodlesnoodles#!/bin/sh # # mail2sms a shell script # Matt Foster # matt@molnir.demon.co.uk # # Mail to SMS gateway script, version 1.0 # By Andy Hawkins (andy@gently.demon.co.uk) /usr/bin/cp /dev/null /tmp/header.$$ ELINE=0 while [ $ELINE -lt 3 ] do read LINE echo "$LINE" >> /tmp/header.$$ if [ "$LINE" = "" ] then ELINE=3 else ELINE=0 fi done SENDER=`head -n 1 /tmp/header.$$ | awk '{print $2}'` TARGET=`grep ^Subject: /tmp/header.$$ | awk '{print $2}'` ELINE=0 while [ $ELINE -lt 2 ] do read LINE echo "$LINE" >> /tmp/body.$$ if [ "$LINE" = "" ] then let ELINE=ELINE+1 else ELINE=0 fi done RETRY=5 SENT=0 while [ $RETRY -gt 1 ] && [ $SENT -eq 0 ] do MSG=`cat /tmp/body.$$` /usr/bin/sms_client $TARGET "$MSG" >> /tmp/sms.log case $? in 0) /bin/mailx -s "SMS success to $TARGET" $SENDER < /dev/null SENT=1;; 1) echo "Message too long" | \ /bin/mailx -s "SMS failure to $TARGET" $SENDER SENT=1;; 3) echo "Invalid Service Name" | \ /bin/mailx -s "SMS failure to $TARGET" $SENDER SENT=1;; 4) echo "Unknown number / name $TARGET" | \ /bin/mailx -s "SMS failure to $TARGET" $SENDER SENT=1;; *) sleep 10 let RETRY=RETRY-1;; esac done if [ $SENT -eq 0 ] then echo "Unable to send message after 5 attemps, please try later" | \ /bin/mailx -s "SMS failure to $TARGET" $SENDER exit fi rm /tmp/header.$$ rm /tmp/body.$$ smsclient-2.0.8z/contrib/smsweb/0000755000175000017500000000000010127274473016553 5ustar noodlesnoodlessmsclient-2.0.8z/contrib/smsweb/sms.pl0000444000175000017500000000243010127274473017707 0ustar noodlesnoodles#!/usr/bin/perl use CGI qw(:standard); $query = new CGI; print $query->header, start_html("Web Pager Gateway"), h1("Web Pager Gateway"), hr(); unless ($query->param) { &getnums; print $query->start_form( -name=>"Input"); print "Enter your message here:"; print $query->hr; print $query->textarea( -name=>'message', -rows=>2, -columns=>80); print $query->hr("Select the recipients (use the Control key to pick several)"); print $query->p; print $query->scrolling_list( -name=>'recipients', -values =>\@vals, -size=>8, -multiple=>'true' ) ; print $query->hr("Press this button to send"); print $query->p; print $query->submit(-value=>'Send Message'); print $query->end_html; } else { @names = $query->param; $message = $query->param('message'); @recipients = $query->param('recipients'); $recipientlist = join(",",@recipients); $recipientlist =~ s/ //go; $output = '/usr/bin/sms_client ' . $recipientlist . " \"" . $message . "\" >&smsout"; system $output; print "Message \"$message\" sent to: " ; print $recipientlist; print p; #print $output; print $query->end_html; } sub getnums { open SMSRC, '/etc/smsrc'; while () { next if /^#/; next if /^SMS_default_service/; ($name,$num) = split("="); chop $num; $code{$name} = $num if $num; } @vals = keys %code; } smsclient-2.0.8z/contrib/smsweb/README0000444000175000017500000000272610127274473017440 0ustar noodlesnoodlessms.pl - access sms_client via a web browser Author: David Usherwood (davidu@infocat.co.uk) This is a very simple perl script which allows text messages to be input and sent to multiple recipients. It reads the entries in /etc/smsrc and offers them up in a multi-select list. Please be kind - this is my first Web-related perl script. Installation The script should just install in your cgi-bin directory, and be accessible as http:///cgi-bin/sms.pl . It requires CGI.pm . If you have a fairly new perl (5.003 upwards), all the perl stuff should be there. But you will probably need to make some permission changes to your system. Again, I am not a Unix security guru, so there may be a better way to do this. sms.pl is run by your web server. Under Apache (which I used for testing), the sessions can be specified to run under a userid such as (say) www . sms.pl runs sms_client. Thus sms_client needs to be executable by www. But sms_client runs libmodem, and that needs access (read I assume) to /etc/modems. Thus make that readable by www (directly or via a group). Lastly, sms_client talks to the modem hardware - so whatever modem you want to access must be read/write to www. On my system it is /dev/ttyS1, ie COM2 to PC types like me. Then it should work. If it doesn't, I am interested to know why. And I can certainly envisage that the Web page itself could be greatly improved... And I am going to try to think up some sensible trapping of comms errors, too smsclient-2.0.8z/contrib/mail2sms-perl/0000755000175000017500000000000010127274473017742 5ustar noodlesnoodlessmsclient-2.0.8z/contrib/mail2sms-perl/README0000444000175000017500000000307610127274473020626 0ustar noodlesnoodlesE-mail to SMS gateway version 1.0 by Andy Hawkins ------------------------------------------------- This is a small perl script designed to provide an e-mail to SMS gateway, using the SMS client written by Angelo Masci (angelo@styx.demon.co.uk). INSTALLATION ------------ 1. Install sms_client such that it is possible to send SMS messages. 2. Create a user (for example sms) 3. Place the mail2sms perl script in that user's home directory 4. Create a .forward directory in the users home directory, containing: "| /path/to/mail2sms || exit 75" N.B. The exit 75 part tells sendmail to requeue the mail if the command returns a non-zero exit status. This should never happen, but is worth including to be safe. USAGE ----- To use the gateway, simply construct an e-mail message to the following criteria: 1. The message should be to the user created ni step 2 of the INSTALLATION procedures. 2. The subject of the message should contain the destination (either as an alias, or a SERVICE:number pair) 3. The main body of the message is the text to send. The text can be split across multiple lines. Processing of the text will end either with the word 'end' on a line by itself, or on finding the standard signature separator '-- ' (note the space is important. You should then receive an e-mail telling you if the message was sent successfully or not. If the message failed, an indication of common reasons for failure is given. If you have any questions regarding the usage of this software, please feel free to e-mail me at the address below. Andy Hawkins andy@gently.demon.co.uk smsclient-2.0.8z/contrib/mail2sms-perl/mail2sms.pl0000555000175000017500000000361610127274473022035 0ustar noodlesnoodles#!/usr/bin/perl # Mail to SMS gateway script, version 1.0 # By Andy Hawkins (andy@gently.demon.co.uk) # Set this to be the path to your mail program $MAILER="/usr/lib/sendmail -t"; # Set this to the maximum number of tries for a message $retries=5; $foundblank=0; $number=""; headerloop: while(<>) { chomp; if (/^From:\s(\S+)/) { $fromaddr=$1; } if (/^Subject:\s(\S+)/) { $number=$1; } if (/^$/) { $foundblank=1; last headerloop; } } $msg=""; messageloop: while (<>) { chomp; last messageloop if /^quit$/ or /^end$/; if ($msg) { $msg=$msg." ".$_; } else { $msg=$_; } } print "Message is to $number\n"; print "Message is ($msg)\n"; $success=0; $longmsg=0; $badservice=0; $badnumber=0; if ($number) { sendloop: while ($retries) { $retcode=system ("/usr/bin/sms_client $number \"$msg\"")/256; # $retcode=system ("exitstat.pl $number \"$msg\"")/256; if ($retcode==0) { $success=1; last sendloop; } else { print "Failed with retcode $retcode\n"; if ($retcode==1) { $longmsg=1; last sendloop; } if ($retcode==3) { $badservice=1; last sendloop; } if ($retcode==4) { $badnumber=1; last sendloop; } sleep 5; $retries--; } } } open MAIL,"|$MAILER"; #print MAIL "From: $MAIL_FROM\n"; print MAIL "To: $fromaddr\n"; if ($success) { print MAIL "Subject: SMS to $number sent successfully\n"; print MAIL "\n"; print MAIL "Your SMS to $number was sent successfully\n"; } else { print MAIL "Subject: SMS to $number failed\n"; print MAIL "\n"; print MAIL "Your SMS to $number failed\n"; unless ($number) { print MAIL "No number found in subject header\n"; } if ($longmsg) { print MAIL "Your message was too long\n"; } if ($badservice) { print MAIL "An invalid service was specified\n"; } if ($badnumber) { print MAIL "The number $number could not be expanded\n"; } } close MAIL; smsclient-2.0.8z/contrib/README0000644000175000017500000000210510127274473016131 0ustar noodlesnoodles Linux SMS Client 2.0.8 by (c) 1997,1998,1999,2000 Angelo Masci ============================================================== Contributions - At the moment we have: mail2sms-perl (Andy Hawkins) - Perl script for forwarding E-Mail via sms. smsweb (David Usherwood) - CGI Web interface in perl mail2sms-shell (Matt Foster) - Bourne Shell script for forwarding E-Mail via sms. RPM (Ross Golder) - Sample Package for installing on Systems using RPM format Any copyright for contributions are held by their respective authors unless otherwise stated. Any mail concerning these utils should be forwarded to their authors. NOTE. These contributions were originally made for version 2.0.5 and 2.0.7 of sms_client I cannot verify their functionality with 2.0.8 get in touch with the authors if you run into problems and ask them to forward any patches so I can update the master source. smsclient-2.0.8z/sms/0000755000175000017500000000000010460427354014413 5ustar noodlesnoodlessmsclient-2.0.8z/sms/scripts/0000755000175000017500000000000010127274501016074 5ustar noodlesnoodlessmsclient-2.0.8z/sms/scripts/email0000644000175000017500000000502510127274501017110 0ustar noodlesnoodles# -------------------------------------------------------------------- # Using the GENERIC driver. # It is possible build simple client interfaces to dialin networks # for delivering SMS messages. # # A Simple generic script consists of three sections: # # login # send # disconnect # # # Each sections is made up of a list of Actions. # Where each action is a dictionary consisting of # a number of entries, these include: # # message # send # expect # success # failure # # # The basic sequence of events is: # # 1. If 'message' is present output to console. # 2. If 'send' is present output to server. # 3. If 'expect' is present, check the input from # the server against the expect string. # 4. If the expect string matches output 'success' to console. # proceed to next entry and goto step 1. # 5. If the expect string does NOT match, output 'failure' to # console. do NOT proceed any further. # # -------------------------------------------------------------------- # # Example. # The script below sends an email by connecting # to an SMTP server. # # -------------------------------------------------------------------- { login = ( { message = "Connecting to server...\n" }, { expect = "220 " success = "Welcome prompt found\n" failure = "Welcome Failed - Welcome prompt expected\n" }, { expect = "\n" success = "Welcome prompt found\n" failure = "Welcome Failed - Welcome prompt expected\n" } ) send = ( { send = "MAIL FROM: bill.gates@microsoft.com\n" expect = "250 " success = "Successfully set Mail from\n" failure = "failed to set Mail from\n" }, { expect = "\n" success = "" failure = "" }, { send = ( "RCPT TO: ", '$ID$', "\n" ) expect = "250 " success = "Successfully set Mail to\n" failure = "failed to set Mail to\n" }, { expect = "\n" success = "" failure = "" }, { send = "DATA\n" expect = "354 " success = "Successfully initiating data transfer\n" failure = "failed initiating data transfer\n" }, { expect = "\n" success = "" failure = "" }, { send = ( '$MSG$', "\n", ".\n" ) expect = "250 " success = "Successfully set data\n" failure = "failed to set data\n" }, { expect = "\n" success = "" failure = "" } ) disconnect = ( { send = "QUIT\n" expect = "221" success = "Disconnect successful\n" failure = "Disconnect Failed\n" }, { expect = "\n" success = "" failure = "" } ) } smsclient-2.0.8z/sms/sms_modem.new0000644000175000017500000000463510127274502017114 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Modem Configuration file # -------------------------------------------------------------------- { # ------------------------------------------------------------ MDM_lock_dir = "#SMSLOCKDIR#" # Lock directory MDM_device = "#SMSMODEM#" # Modem Device Name # Modem Device Name Examples: # # MDM_device = "term/00m" # UNIXWARE # MDM_device = "ttyS0" # Linux COM1 # MDM_device = "ttyS1" # Linux COM2 # # MDM_device = "cua/a" # SOLARIS # MDM_lock_platform = "SOLARIS" # Set this so that we generate # Solaris compatible lock file # names # ------------------------------------------------------------ # MDM_pause_after_connect = 3000000 # Pause after the connection # string for 3 seconds # ------------------------------------------------------------ MDM_command_prefix = "AT" MDM_init_command = "Z" MDM_dial_command = "DT" MDM_number_prefix = "" # Number to dial to get an # external line. MDM_set_local_echo_off = "E0" MDM_disable_echo_test = NO # Test and Set local echo # YES/NO # ------------------------------------------------------------ MDM_dtr_hangup_sleep = 3000000 # How many microseconds should MDM_dtr_init_sleep = 1000000 # I lower DTR during # init/hangup # ------------------------------------------------------------ MDM_command_suffix = "\r" MDM_response_prefix = "\r\n" MDM_response_suffix = "\r\n" # ------------------------------------------------------------ MDM_flow_control = "Hardware" # Software or Hardware # ------------------------------------------------------------ MDM_hangup_command = "H" MDM_attention_command = "+++" MDM_soft_hangup_retries = 0 # Number of times I should # continue sending hangup code # If 0 then don't bother # and rely on lowering DTR MDM_guard_time = 1750000 # Microsecond delay before and # After transmitting attention command MDM_esc_time = 125000 # Microsecond delay between each # character of the attention command # ------------------------------------------------------------ MDM_lock_action = "BLOCK" MDM_lock_retry_delay = 5000000 # Microsecond delay to wait before # retrying for modem lock. } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/sms_addressbook0000644000175000017500000000171210127274502017514 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS addressbook # Names and Numbers follow # # Syntax: # NAME = "[SERVICE:]NUMBER|NAME[,[SERVICE:]NUMBER|NAME...]" # # Valid NAMEs can contain any combination of # alphanumeric and '_' characters. A Valid # name cannot begin with a digit. # # Valid NUMBERs can contain any combination of # numeric and ',' characters. Any NAMEs on the right # side of the '=' is expanded. # # -------------------------------------------------------------------- # Examples # -------------------------------------------------------------------- { angelo = "minicall:252044" # If your in the UK send me a # Test page including your email # address. User1 = "cellnet:123451" User2 = "12342" User3 = "orange:12343" User4 = "vodafone:12344" TeamA = ( "User1", "User2" ) TeamB = ( "User3", "User4" ) } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/sms_config0000644000175000017500000000100610127274502016455 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS config file # -------------------------------------------------------------------- { SMS_default_service = "minicall" # Used by numbers used # without SERVICE:XXXXXX # format SMS_lock_action = "BLOCK" SMS_lock_retry_delay = 5000000 SMS_lockfile = "/var/lock/smslock" # SMS_lockfile = "/var/opt/sms/smslock" # UNIXWARE } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/init.d/0000755000175000017500000000000010127274501015572 5ustar noodlesnoodlessmsclient-2.0.8z/sms/init.d/smsd0000755000175000017500000000242010127274501016464 0ustar noodlesnoodles#! /bin/sh # -------------------------------------------------------------------- QUEUES="cellnet bteasyreach minicall" # -------------------------------------------------------------------- SMSBINDIR=/usr/local/sbin SMSD=${SMSBINDIR}/smsd QUEUED=${SMSBINDIR}/queue PIDDIR=/var/spool/sms/locks PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # -------------------------------------------------------------------- if [ ! -f "$SMSD" ] then exit 0 fi if [ ! -f "$QUEUED" ] then exit 0 fi case "$1" in start) echo -n "Starting SMS Daemon: " if [ -f "$SMSD" ] then $SMSD 2>/dev/null >/dev/null echo -n "smsd" fi echo echo -n "Starting SMS Queue Daemons: " for queue in `$QUEUED -a` do echo -n "$queue " done echo ;; stop) echo -n "Stopping SMS Queue Daemons: " for queue in `$QUEUED -a` do if [ -f "${PIDDIR}/${queue}.pid" ] then SMSDPID=`cat ${PIDDIR}/${queue}.pid | awk '{ print \$1 }'` kill -TERM $SMSDPID echo -n "$queue " fi done echo echo -n "Stopping SMS Daemon: " if [ -f "${PIDDIR}/smsd.pid" ] then SMSDPID=`cat ${PIDDIR}/smsd.pid | awk '{ print \$1 }'` kill -TERM $SMSDPID echo -n "smsd" fi echo ;; *) echo "Usage: smsd {start|stop}" 1>&2 exit 1 ;; esac exit 0 smsclient-2.0.8z/sms/services/0000755000175000017500000000000010460427323016232 5ustar noodlesnoodlessmsclient-2.0.8z/sms/services/vstream0000644000175000017500000000120510127274502017633 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for VoiceStream Wireless (Portland OR USA) # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "18009378941" # VoiceStream number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/minicall0000644000175000017500000000117110127274501017743 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for PAGEONE MINICALL # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "0640900139" # UK PAGEONE MINICALL number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/detemobil0000644000175000017500000000113010127274501020112 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for DETEMOBIL / D1 # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "01712521002" } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/vodapage_block0000644000175000017500000000115010127274502021111 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for VODAPAGE # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "013991250" # UK VODAPAGE number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/broken/0000755000175000017500000000000010460427323017512 5ustar noodlesnoodlessmsclient-2.0.8z/sms/services/broken/att_web0000644000175000017500000000050310127274501021056 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for ATT_WEB # -------------------------------------------------------------------- { SMS_url = "http://www.mobile.att.net/mc/mc_pagersend.cgi" } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/broken/cellnet_web0000644000175000017500000000063310127274501021720 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for CELLNET_WEB # -------------------------------------------------------------------- { SMS_url = "http://www.genie.cellnet.co.uk:80/gm_ed/msg_check.nar" SMS_ac = "00000000000000" SMS_atmo = "XXXXXXX" SMS_rtmo = "XXXXXXX" } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/broken/proximus_web0000644000175000017500000000051210127274501022154 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for PROXIMUS_WEB # -------------------------------------------------------------------- { SMS_url = "http://sms.advalvas.be/scripts/ProxiTextint.dll" } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/broken/orange_web0000644000175000017500000000056010127274501021544 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for ORANGE_WEB # -------------------------------------------------------------------- { SMS_url = "http://www.uk.orange.net/cgi-bin/register/sms.pl" SMS_username = "" SMS_password = "" } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/broken/nextel_web0000644000175000017500000000050310127274501021565 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for NEXTEL_WEB # -------------------------------------------------------------------- { SMS_url = "http://www.nextel.com/cgi-bin/sendPage.cgi" } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/broken/pagenet_web0000644000175000017500000000047510127274501021721 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for ATT_WEB # -------------------------------------------------------------------- { SMS_url = "http://www.pagenet.net/pagenet/page_gen" } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/nz0000644000175000017500000000240010127274501016576 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for Telecom NZ # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 2400 # ------------------------------------------------------------ SMS_max_deliver = 1 SMS_tap_response = "FALSE" SMS_tap_disconnect = "FALSE" # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "0264001283" # ------------------------------------------------------------ # Setup: 300-28800 baud 7/e/1. 2400 works best, higher speeds # had errors, no error det/corr protocol. # # Pager numbers should not include the 026 prefix. # Alpha-Numeric pagers start with a 2 and are seven digits, # eg. 2345000 # # Numeric only pagers start with a 3 and are seven digits, # eg. 3654000. As long as the message is a number string numeric # only pagers work OK! # ------------------------------------------------------------ } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/vodafone0000644000175000017500000000115210127274502017754 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for VODAFONE # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 1200 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "07785499999" # UK VODAFONE number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/bteasyreach0000644000175000017500000000132010127274501020441 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for BTEASYREACH # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ SMS_tap_disconnect = "FALSE" # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "09011130000" # UK BTEASYREACH number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/mtn0000644000175000017500000000115010127274501016746 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for MTN # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 1200 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "0839009000" # South African MTN number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/btmessagemaster0000644000175000017500000000116710127274501021346 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for BTMESSAGEMASTER # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "0345581354" # UK BTMESSAGEMASTER number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/hello0000644000175000017500000000070510127274501017260 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS resource file for hello # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 300 # a screaming 300 bps SMS_centre_number = "6702000" # Hello's paging center, ID is # last 4 of pager number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/netcom0000644000175000017500000000124510127274501017442 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for NETCOM # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "92000890" # NETCOM SMSC Number # From Inside Norway } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/answer0000644000175000017500000000104010127274501017445 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for ANSWER # -------------------------------------------------------------------- { SMS_comms_params = "" SMS_baud = "" # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "" } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/libertel0000644000175000017500000000117110127274501017755 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for LIBERTEL # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 1200 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "0654545000" # NL Libertel number # van www } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/pageone0000644000175000017500000000115010127274501017566 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for PAGEONE # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "01523530300" # UK PAGEONE number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/telenor0000644000175000017500000000123710127274501017626 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for TELENOR # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "90002198" # TELENOR SMSC Number # From Inside Norway } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/callmax0000644000175000017500000000114310127274501017573 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for CALLMAX # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 1200 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "0660141414" # CALLMAX number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/vodafone_tap0000644000175000017500000000115710127274502020625 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for Vodafone TAP # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "07785499993" # UK Vodafone TAP number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/eirpage0000644000175000017500000000117310127274501017571 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for Esat Digifone - Ireland # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 2400 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "2784030" # Esat Digifone - Ireland } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/telia0000644000175000017500000000145710127274501017260 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for Telia Mobitel (Sweden) # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = 0740930000 # Telia SMSC Number # ------------------------------------------------------------ # +46 must be added for dialing from outside Sweden # ------------------------------------------------------------ } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/ucp_tcp0000644000175000017500000000062410127274501017612 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for UCP_TCP ( UCP Over TCP/IP ) # -------------------------------------------------------------------- { SMS_server_name = "XXX.XXX.XXX.XXX" # Hostname of your UCP server SMS_server_port = 555 # Port number for yout UCP server } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/swisscom0000644000175000017500000000130310127274501020017 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for SWISSCOM # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "0794998990" # SWISSCOM SMSC Number (Analog V.34) # SMS_centre_number = "0900900941" # SWISSCOM SMSC Number (ISDN V.120) } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/ampi0000644000175000017500000000174710127274501017112 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for AMPI # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 300 # ------------------------------------------------------------ # AMPI tries to be clever by supporting a propriatory text # entry system with TAP tacked on. The TAP doesn't seem to match # the spec, no ACK response, just a delivery ACK # ------------------------------------------------------------ SMS_max_deliver = 1 SMS_tap_response = "FALSE" SMS_tap_disconnect = "FALSE" # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "4600308" # US Alabama number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/kpn0000644000175000017500000000122210127274501016740 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for PTT/KPN Telcom # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "0653151515" # PTT/KPN Telcom service # centre number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/cellnet0000644000175000017500000000114510127274501017602 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for CELLNET # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "07860980480" # UK CELLNET number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/minicall_new0000644000175000017500000000065610127274501020623 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for PAGEONE MINICALL # -------------------------------------------------------------------- { transport = { type = "modem" params = "7E1" # 7 Data, Even Parity, 1 Stop Bit baud = 9600 number = "0640900139" # UK PAGEONE MINICALL number } } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/eplus0000644000175000017500000000126110127274501017303 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for EPLUS (EPlus Mobilfunk) # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "01771167" # EPLUS SMSC number # +49 must be used for dialing from outside germany } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/digifone0000644000175000017500000000117310127274501017741 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for Esat Digifone - Ireland # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "0868525352" # Esat Digifone - Ireland } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/d20000644000175000017500000000126110127274501016460 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for D2 (Mannesmann Mobilfunk) # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "01722278000" # D2 SMSC Number # +49 must be added for dialing from outside germany } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/proximus0000644000175000017500000000114310127274501020040 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for PROXIMUS # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "" # Belgium Proximus number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/vodafone_autralia0000644000175000017500000000115710127274502021643 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for VODAFONE # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "0414100200" # Australian VODAFONE number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/snpp0000644000175000017500000000057010127274501017135 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for SNPP # -------------------------------------------------------------------- { SMS_server_name = "localhost" # Hostname of your SNPP server SMS_server_port = 444 # Port number for yout SNPP server } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/skytel20000644000175000017500000000125510127274501017553 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for SKYTEL2 # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 1200 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "18006792778" # SKYTEL 2WAY PAGER ACCESS } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/mobistar0000644000175000017500000000115410127274501017774 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for MOBISTAR # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 2400 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "0495955205" # Belgium Mobistar number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/telstra0000644000175000017500000000122310127274501017627 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for TELSTRA # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 2400 SMS_tap_select = "PG1mnmail" # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "125107" # MobileNet SMS TAP-dialup service } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/d10000644000175000017500000000113010127274501016452 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for DETEMOBIL / D1 # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "01712521002" } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/generic0000644000175000017500000000073310127274501017572 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for GENERIC # -------------------------------------------------------------------- { SMS_dialer = "tcpip" # Connection method SMS_server_name = "localhost" # Hostname of your SMTP server SMS_server_port = 25 # Port number for your SMTP # server SMS_script_file = "/etc/sms/scripts/email" } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/one2one0000644000175000017500000000115010127274501017515 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for ONE2ONE # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 1200 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "0956201072" # UK ONE2ONE number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/vodacom0000644000175000017500000000116010127274502017602 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for VODACOM # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 1200 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "0822442244" # South African VODACOM number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/europolitan0000644000175000017500000000125510127274501020517 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for Europolitan # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 SMS_login = "EURO_CIMD" SMS_password = "2062" # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "0708222901" # Europolitan SMSC } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/azcom0000644000175000017500000000114210127274501017262 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for AZCOM # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 1200 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "5207906418" # US Azcom number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/orange0000644000175000017500000000114410127274501017426 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for ORANGE # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "07973100602" # UK ORANGE number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/skytel10000644000175000017500000000127110127274501017550 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for SKYTEL 1 way pagers # -------------------------------------------------------------------- { SMS_comms_params = "7E1" # 7 Data, Even Parity, 1 Stop Bit SMS_baud = 1200 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "18007596366" # SKYTEL 1WAY PAGER ACCESS } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/services/tim0000644000175000017500000000114610127274501016746 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS resource file for TIM # -------------------------------------------------------------------- { SMS_comms_params = "8N1" # 8 Data, No Parity, 1 Stop Bit SMS_baud = 9600 # ------------------------------------------------------------ # The SMSCnumber MUST be defined. # This is the number of your local message center. # ------------------------------------------------------------ SMS_centre_number = "03359609600" # IT TIM system number } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/sms_config.new0000644000175000017500000000100210127274502017241 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS config file # -------------------------------------------------------------------- { SMS_default_service = "minicall" # Used by numbers used # without SERVICE:XXXXXX # format SMS_lock_action = "BLOCK" SMS_lock_retry_delay = 5000000 SMS_lockfile = "#SMSLOCKFILE#" # SMS_lockfile = "/var/opt/sms/smslock" # UNIXWARE } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/sms_daemons0000644000175000017500000000203510127274502016641 0ustar noodlesnoodles# -------------------------------------------------------------------- # Server and Queue daemon related config # -------------------------------------------------------------------- { server = { port = 3000 } directories = { spool = "/var/spool/sms" incoming = "incoming" services = "services" named_pipes = "named_pipes" locks = "locks" } services = { # Which services should be # enabled. cellnet = "ENABLED" detemobil = "ENABLED" d1 = "ENABLED" azcom = "ENABLED" ampi = "ENABLED" telstra = "ENABLED" europolitan = "ENABLED" libertel = "ENABLED" mtn = "ENABLED" one2one = "ENABLED" orange = "ENABLED" pageone = "ENABLED" minicall = "ENABLED" snpp = "ENABLED" tim = "ENABLED" vodacom = "ENABLED" vodafone = "ENABLED" proximus = "ENABLED" vodapage_block = "ENABLED" kpn = "ENABLED" answer = "ENABLED" bteasyreach = "ENABLED" swisscom = "ENABLED" generic = "ENABLED" } } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/sms_services0000644000175000017500000000241210460427352017040 0ustar noodlesnoodles# -------------------------------------------------------------------- # Sample SMS services file # # = # # -------------------------------------------------------------------- { eplus = "TAP" d2 = "UCP" cellnet = "TAP" detemobil = "TAP" d1 = "TAP" azcom = "TAP" ampi = "TAP" callmax = "TAP" telstra = "TAP" europolitan = "CIMD" libertel = "LIBERTEL" mtn = "MTN" one2one = "ONE2ONE" orange = "ORANGE" pageone = "PAGEONE" minicall = "PAGEONE" snpp = "SNPP" tim = "TIM" vodacom = "VODACOM" vodafone = "VODAFONE" vodafone_australia = "VODAFONE" proximus = "PROXIMUS" vodapage_block = "VODAPAGE_BLOCK" kpn = "KPN" answer = "ANSWER" bteasyreach = "TAP" swisscom = "UCP" telenor = "UCP" generic = "GENERIC" vstream = "TAP" vodafone_tap = "TAP" nz = "TAP" btmessagemaster = "TAP" #orange_web = "ORANGE_WEB" #cellnet_web = "CELLNET_WEB" #proximus_web = "PROXIMUS_WEB" #att_web = "ATT_WEB" #nextel_web = "NEXTEL_WEB" #pagenet_web = "PAGENET_WEB" skytel = "TAP" skytel2 = "TAP" digifone = "TAP" telia = "UCP" netcom = "TAP" ucp_tcp = "UCP_TCP" mobistar = "MOBISTAR" eirpage = "TAP" } #-------------------------------------------------------------------- smsclient-2.0.8z/sms/sms_modem0000644000175000017500000000462510127274502016323 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Modem Configuration file # -------------------------------------------------------------------- { # ------------------------------------------------------------ MDM_lock_dir = "/var/lock" # Lock directory MDM_device = "ttyS0" # Modem Device Name # Modem Device Name Examples: # # MDM_device = "term/00m" # UNIXWARE # MDM_device = "ttyS0" # Linux COM1 # MDM_device = "ttyS1" # Linux COM2 # # MDM_device = "cua/a" # SOLARIS # MDM_lock_platform = "SOLARIS" # Set this so that we generate # Solaris compatible lock file # names # ------------------------------------------------------------ # MDM_pause_after_connect = 3000000 # Pause after the connection # string for 3 seconds # ------------------------------------------------------------ MDM_command_prefix = "AT" MDM_init_command = "Z" MDM_dial_command = "DT" MDM_number_prefix = "" # Number to dial to get an # external line. MDM_set_local_echo_off = "E0" MDM_disable_echo_test = NO # Test and Set local echo # YES/NO # ------------------------------------------------------------ MDM_dtr_hangup_sleep = 3000000 # How many microseconds should MDM_dtr_init_sleep = 1000000 # I lower DTR during # init/hangup # ------------------------------------------------------------ MDM_command_suffix = "\r" MDM_response_prefix = "\r\n" MDM_response_suffix = "\r\n" # ------------------------------------------------------------ MDM_flow_control = "Hardware" # Software or Hardware # ------------------------------------------------------------ MDM_hangup_command = "H" MDM_attention_command = "+++" MDM_soft_hangup_retries = 0 # Number of times I should # continue sending hangup code # If 0 then don't bother # and rely on lowering DTR MDM_guard_time = 1750000 # Microsecond delay before and # After transmitting attention command MDM_esc_time = 125000 # Microsecond delay between each # character of the attention command # ------------------------------------------------------------ MDM_lock_action = "BLOCK" MDM_lock_retry_delay = 5000000 # Microsecond delay to wait before # retrying for modem lock. } # -------------------------------------------------------------------- smsclient-2.0.8z/sms/Makefile0000644000175000017500000000652310127274501016053 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id: Makefile,v 5.1 1998/02/01 07:11:32 root Exp root $ # -------------------------------------------------------------------- include ../Makefile.config # -------------------------------------------------------------------- all: install: $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -d $(DESTDIR)$(MLIBDIR)/services $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -d $(DESTDIR)$(SPOOLDIR)/smsclient $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -d $(DESTDIR)$(SPOOLDIR)/smsclient/errors $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -d $(DESTDIR)$(SPOOLDIR)/smsclient/locks $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -d $(DESTDIR)$(SPOOLDIR)/smsclient/incoming $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -d $(DESTDIR)$(SPOOLDIR)/smsclient/named_pipes $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -d $(DESTDIR)$(SPOOLDIR)/smsclient/services $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -d $(DESTDIR)$(MSERVICEDIR)/scripts ( cd services ;\ for service in * ; do \ $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 644 $$service $(DESTDIR)$(MLIBDIR)/services; \ $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -d $(DESTDIR)$(SPOOLDIR)/smsclient/services/$$service ; \ $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 755 -d $(DESTDIR)$(SPOOLDIR)/smsclient/errors/$$service ; \ done ) $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 644 scripts/email $(DESTDIR)$(MSERVICEDIR)/scripts $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 644 sms_config $(DESTDIR)$(MSERVICEDIR) $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 644 sms_addressbook $(DESTDIR)$(MSERVICEDIR) $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 644 sms_modem $(DESTDIR)$(MSERVICEDIR) $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 644 sms_services $(DESTDIR)$(MSERVICEDIR) $(INSTALL) -o $(SMSUSER) -g $(SMSGROUP) -m 644 sms_daemons $(DESTDIR)$(MSERVICEDIR) uninstall: $(RM) $(DESTDIR)$(MLIBDIR)/services/* $(RM) $(DESTDIR)$(MSERVICEDIR)/sms_config $(RM) $(DESTDIR)$(MSERVICEDIR)/sms_addressbook $(RM) $(DESTDIR)$(MSERVICEDIR)/sms_modem $(RM) $(DESTDIR)$(MSERVICEDIR)/sms_services $(RM) $(DESTDIR)$(MSERVICEDIR)/sms_daemons $(RM) $(DESTDIR)$(MSERVICEDIR)/scripts/* # -------------------------------------------------------------------- smsclient-2.0.8z/config/0000755000175000017500000000000010460426173015054 5ustar noodlesnoodlessmsclient-2.0.8z/config/Makefile.config.hp-ux0000644000175000017500000000601010127274473021021 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.config # # Copyright (C) 1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # HP-UX 11.00 # -------------------------------------------------------------------- PLATFORM = -DHPUX CC = cc MAKE = /opt/local/bin/make CFLAGS = -Ae -I. $(PLATFORM) XTRALIBS = # -------------------------------------------------------------------- SMSUSER = root SMSGROUP = root # -------------------------------------------------------------------- PREFIX = /opt/local BINPREFIX = $(PREFIX) ETCPREFIX = $(PREFIX) MANPREFIX = $(PREFIX) SPOOLDIR = /var/spool LOGDIR = /var/adm MLOCALSMSRC = .sms_addressbook MGLOBALSMSRC = $(ETCPREFIX)/etc/sms/sms_addressbook MSERVICEDIR = $(ETCPREFIX)/etc/sms MLOGFILE = $(LOGDIR)/smslog MSNPPDLOGFILE = $(LOGDIR)/snppdlog MSMSDLOGFILE = $(LOGDIR)/smsdlog # -------------------------------------------------------------------- # SMS_Client can be built to use the libmodem package or # its own internal modem routines. Currently the internal routines # are known to be unstable and are still considered to be in ALPHA # Valid Values for MODEMLIB are: # # $(LIBMODEM) - use the libmodem-1.0.0 packages with patches # $(SMSMODEM) - use the internal modem routines LIBMODEM = 1 SMSMODEM = 2 MODEMLIB = $(SMSMODEM) # -------------------------------------------------------------------- BINDIR = $(BINPREFIX)/bin ETCDIR = $(ETCPREFIX)/etc MANDIR = $(MANPREFIX)/man MANEXT = 1 RM = /bin/rm -f CP = /bin/cp TR = /usr/bin/tr AR = /usr/bin/ar STRIP = /usr/bin/strip RANLIB = echo ranlib # -------------------------------------------------------------------- # SOLARIS # -------------------------------------------------------------------- INSTALL = /usr/ucb/install AR = /usr/ccs/bin/ar -rc # -------------------------------------------------------------------- smsclient-2.0.8z/config/Makefile.config.solaris-2.5.10000644000175000017500000000601410127274473022101 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.config # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # SOLARIS 2.5.1 # -------------------------------------------------------------------- PLATFORM = -DSOLARIS CC = cc MAKE = make CFLAGS = -g -I. $(PLATFORM) XTRALIBS = -lsocket -lnsl # -------------------------------------------------------------------- SMSUSER = root SMSGROUP = root # -------------------------------------------------------------------- PREFIX = BINPREFIX = $(PREFIX) ETCPREFIX = $(PREFIX) MANPREFIX = $(PREFIX) SPOOLDIR = /var/spool LOGDIR = /var/adm MLOCALSMSRC = .sms_addressbook MGLOBALSMSRC = $(ETCPREFIX)/etc/sms/sms_addressbook MSERVICEDIR = $(ETCPREFIX)/etc/sms MLOGFILE = $(LOGDIR)/smslog MSNPPDLOGFILE = $(LOGDIR)/snppdlog MSMSDLOGFILE = $(LOGDIR)/smsdlog # -------------------------------------------------------------------- # SMS_Client can be built to use the libmodem package or # its own internal modem routines. Currently the internal routines # are known to be unstable and are still considered to be in ALPHA # Valid Values for MODEMLIB are: # # $(LIBMODEM) - use the libmodem-1.0.0 packages with patches # $(SMSMODEM) - use the internal modem routines LIBMODEM = 1 SMSMODEM = 2 MODEMLIB = $(SMSMODEM) # -------------------------------------------------------------------- BINDIR = $(BINPREFIX)/bin ETCDIR = $(ETCPREFIX)/etc MANDIR = $(MANPREFIX)/man MANEXT = 1 RM = /bin/rm -f CP = /bin/cp TR = /usr/bin/tr AR = /usr/bin/ar STRIP = /usr/bin/strip RANLIB = echo ranlib # -------------------------------------------------------------------- # SOLARIS # -------------------------------------------------------------------- INSTALL = /usr/ucb/install AR = /usr/ccs/bin/ar -rc # -------------------------------------------------------------------- smsclient-2.0.8z/config/Makefile.drivers0000644000175000017500000000437010127274473020201 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.devices # # Copyright (C) 1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # Drivers for several protocols have been written, # This file is automatically generated by running 'configure -drivers' # The drivers listed in the file 'drivers' is formatted and # appended to the bottom of this file. # # # TAP Standard SMS protocol # VODAFONE verbose UK/Australian Telenote protocol # ORANGE verbose UK protocol # PAGEONE verbose UK protocol # ONE2ONE verbose UK protocol # VODACOM verbose South African protocol # MTN verbose South African protocol # LIBERTEL verbose Dutch Libertel protocol # TIM verbose Italian Telecom Italia Mobile protocol # PROXIMUS Belgium protocol # VODAPAGE_BLOCK UK protocol # KPN verbose Dutch protocol # ANSWER verbose protocol # UCP # # SNPP - ALPHA experimental rfc1861 client # CIMD - ALPHA # GENERIC - ALPHA experimental # # -------------------------------------------------------------------- smsclient-2.0.8z/config/Makefile.config.sco0000644000175000017500000000556110127274473020556 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.config # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # SCO Open Server 5 # -------------------------------------------------------------------- PLATFORM = -DSCO CC = gcc MAKE = make CFLAGS = -g -I. -Wall -pedantic $(PLATFORM) XTRALIBS = -lsocket # -------------------------------------------------------------------- SMSUSER = root SMSGROUP = root # -------------------------------------------------------------------- PREFIX = BINPREFIX = $(PREFIX) ETCPREFIX = $(PREFIX) MANPREFIX = $(PREFIX) SPOOLDIR = /var/spool LOGDIR = /var/adm MLOCALSMSRC = .sms_addressbook MGLOBALSMSRC = $(ETCPREFIX)/etc/sms/sms_addressbook MSERVICEDIR = $(ETCPREFIX)/etc/sms MLOGFILE = $(LOGDIR)/smslog MSNPPDLOGFILE = $(LOGDIR)/snppdlog MSMSDLOGFILE = $(LOGDIR)/smsdlog # -------------------------------------------------------------------- # SMS_Client can be built to use the libmodem package or # its own internal modem routines. Currently the internal routines # are known to be unstable and are still considered to be in ALPHA # Valid Values for MODEMLIB are: # # $(LIBMODEM) - use the libmodem-1.0.0 packages with patches # $(SMSMODEM) - use the internal modem routines LIBMODEM = 1 SMSMODEM = 2 MODEMLIB = $(SMSMODEM) # -------------------------------------------------------------------- BINDIR = $(BINPREFIX)/bin ETCDIR = $(ETCPREFIX)/etc MANDIR = $(MANPREFIX)/man MANEXT = 1 INSTALL = /etc/install RM = /bin/rm -f CP = /bin/cp TR = /usr/bin/tr AR = /usr/local/bin/ar -rc STRIP = /usr/local/bin/strip RANLIB = echo ranlib # -------------------------------------------------------------------- smsclient-2.0.8z/config/Makefile.config.freebsd0000644000175000017500000000554410127274473021405 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.config # # Copyright (C) 1997,1998,1999,2000 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # FreeBSD # -------------------------------------------------------------------- PLATFORM = -DFREEBSD CC = gcc MAKE = make CFLAGS = -g -I. -Wall -pedantic $(PLATFORM) XTRALIBS = # -------------------------------------------------------------------- SMSUSER = bin SMSGROUP = bin # -------------------------------------------------------------------- PREFIX = /usr/local BINPREFIX = $(PREFIX) ETCPREFIX = $(PREFIX) MANPREFIX = $(PREFIX) SPOOLDIR = /var/spool LOGDIR = /var/adm MLOCALSMSRC = .sms_addressbook MGLOBALSMSRC = $(ETCPREFIX)/etc/sms/sms_addressbook MSERVICEDIR = $(ETCPREFIX)/etc/sms MLOGFILE = $(LOGDIR)/smslog MSNPPDLOGFILE = $(LOGDIR)/snppdlog MSMSDLOGFILE = $(LOGDIR)/smsdlog # -------------------------------------------------------------------- # SMS_Client can be built to use the libmodem package or # its own internal modem routines. Currently the internal routines # are known to be unstable and are still considered to be in ALPHA # Valid Values for MODEMLIB are: # # $(LIBMODEM) - use the libmodem-1.0.0 packages with patches # $(SMSMODEM) - use the internal modem routines LIBMODEM = 1 SMSMODEM = 2 MODEMLIB = $(SMSMODEM) # -------------------------------------------------------------------- BINDIR = $(BINPREFIX)/bin ETCDIR = $(ETCPREFIX)/etc MANDIR = $(MANPREFIX)/man MANEXT = 1 INSTALL = /usr/bin/install -c RM = /bin/rm -f CP = /bin/cp TR = /usr/bin/tr AR = /usr/bin/ar -rc STRIP = /usr/bin/strip RANLIB = ranlib # -------------------------------------------------------------------- smsclient-2.0.8z/config/Makefile.config.next0000644000175000017500000000564210127274473020750 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.config # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # # Ken Turner # # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # NEXTSTEP 3.3 and OPENSTEP 4.2 # -------------------------------------------------------------------- PLATFORM = -DNEXT CC = cc CFLAGS = -g -I. -Wall -pedantic $(PLATFORM) XTRALIBS = -lposix # -------------------------------------------------------------------- SMSUSER = root SMSGROUP = root # -------------------------------------------------------------------- PREFIX = BINPREFIX = $(PREFIX) ETCPREFIX = $(PREFIX) MANPREFIX = $(PREFIX) SPOOLDIR = /var/spool LOGDIR = /var/adm MLOCALSMSRC = .sms_addressbook MGLOBALSMSRC = $(ETCPREFIX)/etc/sms/sms_addressbook MSERVICEDIR = $(ETCPREFIX)/etc/sms MLOGFILE = $(LOGDIR)/smslog MSNPPDLOGFILE = $(LOGDIR)/snppdlog MSMSDLOGFILE = $(LOGDIR)/smsdlog # -------------------------------------------------------------------- # SMS_Client can be built to use the libmodem package or # its own internal modem routines. Currently the internal routines # are known to be unstable and are still considered to be in ALPHA # Valid Values for MODEMLIB are: # # $(LIBMODEM) - use the libmodem-1.0.0 packages with patches # $(SMSMODEM) - use the internal modem routines LIBMODEM = 1 SMSMODEM = 2 MODEMLIB = $(SMSMODEM) # -------------------------------------------------------------------- BINDIR = $(BINPREFIX)/bin ETCDIR = $(ETCPREFIX)/etc MANDIR = $(MANPREFIX)/man MANEXT = 1 INSTALL = /usr/bin/install RM = /bin/rm -f CP = /bin/cp TR = /usr/bin/tr AR = /bin/ar rc STRIP = /bin/strip MAKE = /usr/bin/gmake RANLIB = ranlib # -------------------------------------------------------------------- smsclient-2.0.8z/config/Makefile.config.solaris-2.40000644000175000017500000000601010127274473021735 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.config # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # SOLARIS 2.4 # -------------------------------------------------------------------- PLATFORM = -DSOLARIS -DSOLARIS_2_4 CC = cc MAKE = make CFLAGS = -g -I. $(PLATFORM) XTRALIBS = -lsocket -lnsl # -------------------------------------------------------------------- SMSUSER = root SMSGROUP = root # -------------------------------------------------------------------- PREFIX = BINPREFIX = $(PREFIX) ETCPREFIX = $(PREFIX) MANPREFIX = $(PREFIX) SPOOLDIR = /var/spool LOGDIR = /var/adm MLOCALSMSRC = .sms_addressbook MGLOBALSMSRC = $(ETCPREFIX)/etc/sms/sms_addressbook MSERVICEDIR = $(ETCPREFIX)/etc/sms MLOGFILE = $(LOGDIR)/smslog MSNPPDLOGFILE = $(LOGDIR)/snppdlog MSMSDLOGFILE = $(LOGDIR)/smsdlog # -------------------------------------------------------------------- # SMS_Client can be built to use the libmodem package or # its own internal modem routines. Currently the internal routines # are known to be unstable and are still considered to be in ALPHA # Valid Values for MODEMLIB are: # # $(LIBMODEM) - use the libmodem-1.0.0 packages with patches # $(SMSMODEM) - use the internal modem routines LIBMODEM = 1 SMSMODEM = 2 MODEMLIB = $(SMSMODEM) # -------------------------------------------------------------------- BINDIR = $(BINPREFIX)/bin ETCDIR = $(ETCPREFIX)/etc MANDIR = $(MANPREFIX)/man MANEXT = 1 INSTALL = /usr/bin/install RM = /bin/rm -f CP = /bin/cp TR = /usr/bin/tr STRIP = /usr/bin/strip RANLIB = echo ranlib # -------------------------------------------------------------------- # SOLARIS # -------------------------------------------------------------------- AR = /usr/ccs/bin/ar -rc # -------------------------------------------------------------------- smsclient-2.0.8z/config/Makefile.config.aix0000644000175000017500000000547610127274473020560 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.config # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # AIX # -------------------------------------------------------------------- PLATFORM = -DAIX CC = cc MAKE = make CFLAGS = -I. $(PLATFORM) XTRALIBS = # -------------------------------------------------------------------- SMSUSER = root SMSGROUP = root # -------------------------------------------------------------------- PREFIX = BINPREFIX = $(PREFIX) ETCPREFIX = $(PREFIX) MANPREFIX = $(PREFIX) SPOOLDIR = /var/spool LOGDIR = /var/adm MLOCALSMSRC = .sms_addressbook MGLOBALSMSRC = $(ETCPREFIX)/etc/sms/sms_addressbook MSERVICEDIR = $(ETCPREFIX)/etc/sms MLOGFILE = $(LOGDIR)/smslog MSNPPDLOGFILE = $(LOGDIR)/snppdlog MSMSDLOGFILE = $(LOGDIR)/smsdlog # -------------------------------------------------------------------- # SMS_Client can be built to use the libmodem package or # its own internal modem routines. Currently the internal routines # are known to be unstable and are still considered to be in ALPHA # Valid Values for MODEMLIB are: # # $(LIBMODEM) - use the libmodem-1.0.0 packages with patches # $(SMSMODEM) - use the internal modem routines LIBMODEM = 1 SMSMODEM = 2 MODEMLIB = $(SMSMODEM) # -------------------------------------------------------------------- BINDIR = $(BINPREFIX)/bin ETCDIR = $(ETCPREFIX)/etc MANDIR = $(MANPREFIX)/man MANEXT = 1 INSTALL = /usr/bin/install RM = /bin/rm -f CP = /bin/cp TR = /usr/bin/tr AR = /usr/bin/ar -rc STRIP = /usr/bin/strip RANLIB = echo ranlib # -------------------------------------------------------------------- smsclient-2.0.8z/config/Makefile.config.linux0000644000175000017500000000614410460426173021123 0ustar noodlesnoodles# This Makefile was customized for the use by Debian GNU/Linux # customisation made by Michael Holzt # DESTDIR = # -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.config # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # Linux # -------------------------------------------------------------------- PLATFORM = -DLINUX CC = gcc MAKE = make CFLAGS = -O2 -g -I. -Wall -pedantic -fsigned-char $(PLATFORM) XTRALIBS = # -------------------------------------------------------------------- SMSUSER = root SMSGROUP = root # -------------------------------------------------------------------- PREFIX = BINPREFIX = $(PREFIX) ETCPREFIX = $(PREFIX) MANPREFIX = $(PREFIX) SPOOLDIR = /var/spool LOGDIR = /var/log MLOCALSMSRC = .sms_addressbook MGLOBALSMSRC = $(ETCPREFIX)/etc/smsclient/sms_addressbook MSERVICEDIR = $(ETCPREFIX)/etc/smsclient MLIBDIR = $(PREFIX)/usr/share/smsclient MLOGFILE = $(LOGDIR)/smsclient.log MSNPPDLOGFILE = $(LOGDIR)/smsclient.snppdlog MSMSDLOGFILE = $(LOGDIR)/smsclient.smsdlog # -------------------------------------------------------------------- # SMS_Client can be built to use the libmodem package or # its own internal modem routines. Currently the internal routines # are known to be unstable and are still considered to be in ALPHA # Valid Values for MODEMLIB are: # # $(LIBMODEM) - use the libmodem-1.0.0 packages with patches # $(SMSMODEM) - use the internal modem routines LIBMODEM = 1 SMSMODEM = 2 MODEMLIB = $(SMSMODEM) # -------------------------------------------------------------------- BINDIR = $(DESTDIR)/usr/bin ETCDIR = $(DESTDIR)/etc LIBDIR = $(DESTDIR)/usr/lib MANDIR = $(DESTDIR)/usr/share/man MANEXT = 1 INSTALL = /usr/bin/install RM = /bin/rm -f CP = /bin/cp TR = /usr/bin/tr AR = /usr/bin/ar -rc STRIP = /usr/bin/strip RANLIB = echo ranlib # -------------------------------------------------------------------- smsclient-2.0.8z/config/Makefile.modemlib0000644000175000017500000000331310127274473020307 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.modems # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # SMS_Client can be built to use the libmodem package or # its own internal modem routines. Currently the internal routines # are known to be unstable and are still considered to be in ALPHA # Valid Values for MYMODEMLIB are: # # -llibmodem - use the libmodem-1.0.0 packages with patches # - use the internal modem routines # # -------------------------------------------------------------------- smsclient-2.0.8z/config/Makefile.config.solaris-2.60000644000175000017500000000601210127274473021741 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.config # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # SOLARIS 2.6 # -------------------------------------------------------------------- PLATFORM = -DSOLARIS CC = cc MAKE = make CFLAGS = -g -I. $(PLATFORM) XTRALIBS = -lsocket -lnsl # -------------------------------------------------------------------- SMSUSER = root SMSGROUP = root # -------------------------------------------------------------------- PREFIX = BINPREFIX = $(PREFIX) ETCPREFIX = $(PREFIX) MANPREFIX = $(PREFIX) SPOOLDIR = /var/spool LOGDIR = /var/adm MLOCALSMSRC = .sms_addressbook MGLOBALSMSRC = $(ETCPREFIX)/etc/sms/sms_addressbook MSERVICEDIR = $(ETCPREFIX)/etc/sms MLOGFILE = $(LOGDIR)/smslog MSNPPDLOGFILE = $(LOGDIR)/snppdlog MSMSDLOGFILE = $(LOGDIR)/smsdlog # -------------------------------------------------------------------- # SMS_Client can be built to use the libmodem package or # its own internal modem routines. Currently the internal routines # are known to be unstable and are still considered to be in ALPHA # Valid Values for MODEMLIB are: # # $(LIBMODEM) - use the libmodem-1.0.0 packages with patches # $(SMSMODEM) - use the internal modem routines LIBMODEM = 1 SMSMODEM = 2 MODEMLIB = $(SMSMODEM) # -------------------------------------------------------------------- BINDIR = $(BINPREFIX)/bin ETCDIR = $(ETCPREFIX)/etc MANDIR = $(MANPREFIX)/man MANEXT = 1 RM = /bin/rm -f CP = /bin/cp TR = /usr/bin/tr AR = /usr/bin/ar STRIP = /usr/bin/strip RANLIB = echo ranlib # -------------------------------------------------------------------- # SOLARIS # -------------------------------------------------------------------- INSTALL = /usr/ucb/install AR = /usr/ccs/bin/ar -rc # -------------------------------------------------------------------- smsclient-2.0.8z/config/Makefile.config.unixware0000644000175000017500000000621410127274473021630 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.config # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # UNIXWARE # -------------------------------------------------------------------- PLATFORM = -DUNIXWARE CC = cc MAKE = make CFLAGS = -I. -Xa $(PLATFORM) XTRALIBS = -lsocket -lnsl # -------------------------------------------------------------------- SMSUSER = root SMSGROUP = root # -------------------------------------------------------------------- PREFIX = /opt/sms BINPREFIX = $(PREFIX) ETCPREFIX = /etc/opt/sms MANPREFIX = $(PREFIX) SPOOLDIR = /var/spool LOGDIR = /var/opt/sms MLOCALSMSRC = .sms_addressbook MLOGFILE = $(LOGDIR)/smslog MSNPPDLOGFILE = $(LOGDIR)/snppdlog MSMSDLOGFILE = $(LOGDIR)/smsdlog # -------------------------------------------------------------------- # UNIXWARE # -------------------------------------------------------------------- MGLOBALSMSRC = $(ETCPREFIX)/sms_addressbook MSERVICEDIR = $(ETCPREFIX) # -------------------------------------------------------------------- # SMS_Client can be built to use the libmodem package or # its own internal modem routines. Currently the internal routines # are known to be unstable and are still considered to be in ALPHA # Valid Values for MODEMLIB are: # # $(LIBMODEM) - use the libmodem-1.0.0 packages with patches # $(SMSMODEM) - use the internal modem routines LIBMODEM = 1 SMSMODEM = 2 MODEMLIB = $(SMSMODEM) # -------------------------------------------------------------------- MANEXT = 1 RM = /bin/rm -f CP = /bin/cp TR = /usr/bin/tr AR = /usr/bin/ar -rc STRIP = /usr/bin/strip RANLIB = echo ranlib # -------------------------------------------------------------------- # UNIXWARE # -------------------------------------------------------------------- BINDIR = $(BINPREFIX)/bin ETCDIR = $(ETCPREFIX) MANDIR = $(MANPREFIX)/man INSTALL = /usr/bin/install # -------------------------------------------------------------------- smsclient-2.0.8z/config/Makefile.config.solaris-2.50000644000175000017500000000601410127274473021742 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.config # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # SOLARIS 2.5.1 # -------------------------------------------------------------------- PLATFORM = -DSOLARIS CC = cc MAKE = make CFLAGS = -g -I. $(PLATFORM) XTRALIBS = -lsocket -lnsl # -------------------------------------------------------------------- SMSUSER = root SMSGROUP = root # -------------------------------------------------------------------- PREFIX = BINPREFIX = $(PREFIX) ETCPREFIX = $(PREFIX) MANPREFIX = $(PREFIX) SPOOLDIR = /var/spool LOGDIR = /var/adm MLOCALSMSRC = .sms_addressbook MGLOBALSMSRC = $(ETCPREFIX)/etc/sms/sms_addressbook MSERVICEDIR = $(ETCPREFIX)/etc/sms MLOGFILE = $(LOGDIR)/smslog MSNPPDLOGFILE = $(LOGDIR)/snppdlog MSMSDLOGFILE = $(LOGDIR)/smsdlog # -------------------------------------------------------------------- # SMS_Client can be built to use the libmodem package or # its own internal modem routines. Currently the internal routines # are known to be unstable and are still considered to be in ALPHA # Valid Values for MODEMLIB are: # # $(LIBMODEM) - use the libmodem-1.0.0 packages with patches # $(SMSMODEM) - use the internal modem routines LIBMODEM = 1 SMSMODEM = 2 MODEMLIB = $(SMSMODEM) # -------------------------------------------------------------------- BINDIR = $(BINPREFIX)/bin ETCDIR = $(ETCPREFIX)/etc MANDIR = $(MANPREFIX)/man MANEXT = 1 RM = /bin/rm -f CP = /bin/cp TR = /usr/bin/tr AR = /usr/bin/ar STRIP = /usr/bin/strip RANLIB = echo ranlib # -------------------------------------------------------------------- # SOLARIS # -------------------------------------------------------------------- INSTALL = /usr/ucb/install AR = /usr/ccs/bin/ar -rc # -------------------------------------------------------------------- smsclient-2.0.8z/config/user_group_install0000755000175000017500000000574310127274473020737 0ustar noodlesnoodles#!/usr/bin/sh # -------------------------------------------------------------------- # This script is used to install USER 'user' and GROUP 'group' # and ensure that the user has access to the callout devices # through supplementary membership to the 'uucp' group # -------------------------------------------------------------------- USER=sms GROUP=sms # -------------------------------------------------------------------- # User uucp traditionally has read/write permissions to callout # devices such as modems. # -------------------------------------------------------------------- uucp="uucp" # -------------------------------------------------------------------- # Add Group if it does not already exist # -------------------------------------------------------------------- echo "----------------------------------------" echo "Checking for group '$GROUP'..." group=`awk -F: "\\$1 == \"$GROUP\" { print \\$1 }" /etc/group` if [ "X-$group" = "X-" ] then echo "Group '$GROUP' NOT Found." echo "Do you whish to add group '$GROUP' [y/n] ?" read ans case $ans in y*|Y*) echo "Adding new group '$GROUP'..." /usr/sbin/groupadd $GROUP 2>/dev/null if [ $? -ne 0 ] then echo "Error: Could not add group '$GROUP'" exit 1 else echo "Added group '$GROUP'" fi ;; *) echo "Skipping..." ;; esac else echo "Group '$GROUP' Found" fi # -------------------------------------------------------------------- # Add User if it does not already exist # -------------------------------------------------------------------- echo "----------------------------------------" echo "Checking for user '$USER'..." user=`awk -F: "\\$1 == \"$USER\" { print \\$1 }" /etc/passwd` if [ "X-$user" = "X-" ] then echo "User '$USER' NOT Found." echo "Do you whish to add user '$USER' [y/n] ?" read ans case $ans in y*|Y*) echo "Adding new user '$USER'..." while : do nuucp=`awk -F: "\\$1 == \"$uucp\" { print \\$1 }" /etc/group` if [ "X-$nuucp" = "X-" ] then echo echo "Warning: Cannot find group '$uucp'" echo if [ "X-$uucp" = "X-uucp" ] then echo "Traditionally the group 'uucp' is given" echo "read/write access to callout devices such as modems" echo fi echo "If your system has another group that" echo "has read/write access to callout devices such" echo "as modems please enter it's name:" read uucp else break fi done /usr/sbin/useradd -g $GROUP -G $uucp $USER 2>/dev/null if [ $? -ne 0 ] then echo "Error: Could not add user '$USER'" exit 1 else echo "Added user '$USER'" echo echo "NOTE - User '$USER' was given supplementary membership to" echo " group '$uucp'. This has been done to allow read/write" echo " access to callout devices such as modems." fi ;; *) echo "Skipping..." ;; esac else echo "User '$USER' Found" fi # -------------------------------------------------------------------- echo "----------------------------------------" echo "Done." exit 0 smsclient-2.0.8z/config/Makefile.config.solaris-2.70000644000175000017500000000600010127274473021737 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile.config # # Copyright (C) 1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- # -------------------------------------------------------------------- # SOLARIS 2.7 # -------------------------------------------------------------------- PLATFORM = -DSOLARIS CC = cc MAKE = make CFLAGS = -g -I. $(PLATFORM) XTRALIBS = -lsocket -lnsl # -------------------------------------------------------------------- SMSUSER = root SMSGROUP = root # -------------------------------------------------------------------- PREFIX = BINPREFIX = $(PREFIX) ETCPREFIX = $(PREFIX) MANPREFIX = $(PREFIX) SPOOLDIR = /var/spool LOGDIR = /var/adm MLOCALSMSRC = .sms_addressbook MGLOBALSMSRC = $(ETCPREFIX)/etc/sms/sms_addressbook MSERVICEDIR = $(ETCPREFIX)/etc/sms MLOGFILE = $(LOGDIR)/smslog MSNPPDLOGFILE = $(LOGDIR)/snppdlog MSMSDLOGFILE = $(LOGDIR)/smsdlog # -------------------------------------------------------------------- # SMS_Client can be built to use the libmodem package or # its own internal modem routines. Currently the internal routines # are known to be unstable and are still considered to be in ALPHA # Valid Values for MODEMLIB are: # # $(LIBMODEM) - use the libmodem-1.0.0 packages with patches # $(SMSMODEM) - use the internal modem routines LIBMODEM = 1 SMSMODEM = 2 MODEMLIB = $(SMSMODEM) # -------------------------------------------------------------------- BINDIR = $(BINPREFIX)/bin ETCDIR = $(ETCPREFIX)/etc MANDIR = $(MANPREFIX)/man MANEXT = 1 RM = /bin/rm -f CP = /bin/cp TR = /usr/bin/tr AR = /usr/bin/ar STRIP = /usr/bin/strip RANLIB = echo ranlib # -------------------------------------------------------------------- # SOLARIS # -------------------------------------------------------------------- INSTALL = /usr/ucb/install AR = /usr/ccs/bin/ar -rc # -------------------------------------------------------------------- smsclient-2.0.8z/config/Makefile0000644000175000017500000000344010127274473016521 0ustar noodlesnoodles# -------------------------------------------------------------------- # SMS Client, send messages to mobile phones and pagers # # Makefile # # Copyright (C) 1997,1998,1999 Angelo Masci # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # You can contact the author at this e-mail address: # # angelo@styx.demon.co.uk # # -------------------------------------------------------------------- # $Id$ # -------------------------------------------------------------------- include Makefile.config # -------------------------------------------------------------------- all: cd src ; $(MAKE) clean: cd src ; $(MAKE) clean distclean: cd src ; $(MAKE) clean $(RM) Makefile.config $(RM) Makefile.drivers $(RM) Makefile.modemlib $(RM) .configured $(RM) Makefile install: cd src ; $(MAKE) install cd sms ; $(MAKE) install cd docs ; $(MAKE) install uninstall: cd src ; $(MAKE) uninstall cd sms ; $(MAKE) uninstall cd docs ; $(MAKE) uninstall # -------------------------------------------------------------------- smsclient-2.0.8z/.version0000644000175000017500000000001010127274463015267 0ustar noodlesnoodles2.0.8z