Initial revision

master
MelwareDE 18 years ago
parent e5a74c85d6
commit fa6be5da46
  1. 25
      BUGREPORT
  2. 339
      COPYING.GPL
  3. 17
      COPYRIGHT
  4. 65
      Config
  5. 1
      INSTALL
  6. 65
      Makefile
  7. 113
      README
  8. 372
      asc.c
  9. 553
      cfg.c
  10. 134
      config.h
  11. 12
      contrib/Makefile
  12. 10
      contrib/README
  13. 60
      contrib/m2y.pl
  14. 122
      contrib/tap.sl
  15. 221
      cv.c
  16. 6
      data.c
  17. 442
      lua.c
  18. 207
      pager.h
  19. 189
      scr.c
  20. 41
      script.h
  21. 692
      slang.c
  22. 725
      tap.c
  23. 1132
      tty.c
  24. 1801
      ucp.c
  25. 596
      util.c
  26. 126
      valid.c
  27. 21
      valid.h
  28. 19
      yaps.1
  29. 2489
      yaps.c
  30. 910
      yaps.doc
  31. 883
      yaps.html
  32. 19
      yaps.lsm
  33. 370
      yaps.rc

@ -0,0 +1,25 @@
As this software is in the Alpha state, there are still some bugs or
problems. If you encountered one please include following informations when
reporting it:
- The version you are using.
- Your `Config', `config.h' and `yaps.rc' file.
- Call `yaps -V' and redirect the output into a file. Include this file.
- A command to reproduce the bug.
- The output with the highest verbosity. This can be
done by starting yaps with several -v's (at least 4) and
redirecting stdout and stderr into a file, e.g.:
yaps -vvvv [your options] &> bug [bash]
- or -
yaps -vvvv [your options] >bug 2>&1 [sh]
- or -
see your shell manual.
- If the program terminates recompile it with debug information
(if not already done). Reproduce the problem. Start the program
under the control of the debugger. Save the location and the stack
frame into a file. Send the file. If a core file is generated,
start the debugger on the program/core pair, print the location
and the stack frame into a file. Send the file.
- DO NOT SEND CORE FILES!!!
Send these information either to <yaps@nitmar.tnet.de> (preferred) or
<ud@cube.net>.

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
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.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

@ -0,0 +1,17 @@
Copyright (c) 1997 Ulrich Dessauer
All rights reserved.
You may distribute under the terms of the GNU General Public
License.
IN NO EVENT SHALL ULRICH DESSAUER BE LIABLE TO ANY PARTY FOR DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ULRICH DESSAUER
HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ULRICH DESSAUER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
BASIS, AND ULRICH DESSAUER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

@ -0,0 +1,65 @@
# -*- sh -*-
# SECTION A.) Global configuration
# Select compiler command
CC = gcc
#
CFLAGS = -Wall -Wno-parentheses -Wshadow -Wstrict-prototypes -Wmissing-prototypes
LDFLAGS =
EXLIBS =
#
# Select scripting language(s)
# SLang (ftp://space.mit.edu/pub/davis/slang/)
#SLANG = True
# LUA (ftp://ftp.icad.puc-rio.br/pub/lua/)
#LUA = True
#
# Define this to disable debugging
#NDEBUG = True
#
#
#
# SECTION B.) yaps configuration
# Name and location of global configuration file
YAPS_CFGFILE = /etc/yaps.rc
# Name of local configuration file (location is $HOME.)
YAPS_LCFGFILE = .yapsrc
# Directory for installing the binary
YAPS_BINDIR = /usr/local/bin
# Directory for optional support files
YAPS_LIBDIR = /usr/local/lib/yaps
# User/Group/Mode for yaps
YAPS_USER = bin
YAPS_GROUP = uucp
YAPS_MODE = 2711
# User/Group/Mode for global configuration file
YAPS_RCUSER = bin
YAPS_RCGROUP = bin
YAPS_RCMODE = 644
#
# End of Configuration, the rest is for automatic
# configuration depending on settings above
LDEFS =
LLIBS =
ifdef SLANG
LDEFS += -DSCRIPT_SLANG
LLIBS += -lslang
MATH = True
endif
ifdef LUA
LDEFS += -DSCRIPT_LUA
LLIBS += -llualib -llua
MATH = True
endif
ifdef MATH
LLIBS += -lm
endif
#
ifdef NDEBUG
DDEFS = -DNDEBUG
G = -O
else
G = -g
endif
#
CFLAGS := $G $(CFLAGS) $(LDEFS) $(DDEFS)
LDFLAGS := $G $(LDFLAGS)

@ -0,0 +1 @@
Read the Installation section in the README file!

@ -0,0 +1,65 @@
# -*- sh -*-
#
include Config
#
#CFLAGS := -include mem.h $(CFLAGS)
CFLAGS := $(CFLAGS)
#
DEFS = -DCFGFILE=\"$(YAPS_CFGFILE)\" -DLCFGFILE=\"$(YAPS_LCFGFILE)\" \
-DLIBDIR=\"$(YAPS_LIBDIR)\"
LIBS = -L. -lpager $(LLIBS)
OBJS = data.o util.o cfg.o tty.o cv.o asc.o scr.o tap.o ucp.o \
slang.o lua.o #mem.o
YOBJS = yaps.o valid.o
DSTFLE = $(YAPS_BINDIR)/yaps
all: yaps yaps.doc
@if [ -f contrib/Makefile ]; then \
$(MAKE) -C contrib all ; \
fi
yaps: libpager.a $(YOBJS)
$(CC) $(LDFLAGS) $(YOBJS) -o $@ $(LIBS)
libpager.a: $(OBJS)
rm -f $@
ar rc $@ $(OBJS)
ranlib $@
yaps.o: yaps.c pager.h
$(CC) $(CFLAGS) $(DEFS) $< -c -o $@
yaps.doc: yaps.html
lynx -cfg=/dev/null -nolist -dump $< > $@
install: $(DSTFLE) $(CFGFILE)
if [ ! -d $(YAPS_LIBDIR) ]; then \
install -d -m 755 -o $(YAPS_USER) -g $(YAPS_GROUP) $(YAPS_LIBDIR) ; \
fi
@if [ -f contrib/Makefile ]; then \
$(MAKE) -C contrib install ; \
fi
$(DSTFLE): yaps
install -o $(YAPS_USER) -g $(YAPS_GROUP) -m $(YAPS_MODE) -s yaps $@
$(CFGFILE): yaps.rc
@if [ ! -f $@ ]; then \
install -o $(YAPS_RCUSER) -g $(YAPS_RCGROUP) -m $(YAPS_RCMODE) -s yaps.rc $@ ; \
fi
clean:
rm -f *.[oa] *~ .*~ yaps core .depend
@if [ -f contrib/Makefile ]; then \
$(MAKE) -C contrib clean ; \
fi
depend:
$(CPP) $(CFLAGS) -MM *.c > .depend
@if [ -f contrib/Makefile ]; then \
$(MAKE) -C contrib depend ; \
fi
ifeq (.depend,$(wildcard .depend))
include .depend
endif

113
README

@ -0,0 +1,113 @@
yaps -or- Yet Another Pager Software
=====================================
This software is primary designed to send message to so called pager devices
including cellular phones which are able to receive textual messages
(sometimes called SMS, short message system/service.)
This is a simple command line driven program with a global and a personal
configuration file, but the protocol implementation is kept as a seperate
library, with which one may somedays write a client/server system.
Copyright:
~~~~~~~~~~
Copyright (c) 1997 Ulrich Dessauer
All rights reserved.
You may distribute under the terms of the GNU General Public
License.
IN NO EVENT SHALL ULRICH DESSAUER BE LIABLE TO ANY PARTY FOR DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ULRICH DESSAUER
HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ULRICH DESSAUER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
BASIS, AND ULRICH DESSAUER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
Installation:
~~~~~~~~~~~~~
You need a system supporting the Posix system calls and library functions
(every modern Unix like OS should have this support) and you need an install
program, otherwise you have to install the result by hand. Gnumake and GCC
are a plus, otherwise you may have to tweak the Makefile and some source
files a bit.
1.) Edit Config (which will be included by make) & edit config.h
1a.) If you do not have the SLang library installed, comment out
the line `SLANG = True' in Config or install it somewhere
the compiler can find it (/usr/local/{lib,include} seems to
be a not-to-bad place). READ THE ATTACHED COPYRIGHT NOTICE!
1b.) Dito for lua.
2.) Edit config.h. Comments should explain enough.
3.) `make depend'
4.) `make'
If the program compiles fine:
5.) `make install' as root (if you have permissons). If you do not have
an install program, install it by hand:
a.) Copy the executable `yaps' to somewhere in your path
b.) Install yaps.rc as /etc/yaps.rc or as ~/.yapsrc
6.) edit `/etc/yaps.rc' for global settings
7.) Optional edit ~/.yapsrc for your private settings
An example `yaps.rc' file is included and can be used directly for some
services available in Germany. Others may be added. See the `yaps.doc' file
for a complete description of the configuration files.
Implementation:
~~~~~~~~~~~~~~~
The current implementation allows sending messages to pager, where the
service company offers a modem gateway. Paging via Internet or other online
services is currently not supported, as they are mostly quite simple to
realize (sending an e-mail to a specific address, calling an URL, etc.)
Following protocols are implemented:
- ASCII based. This could also be handled by programs like `chat', but is
included for completness. You can use simple send/expect strings to define
the communication.
- SCRIPT based. This could be considered as an enhanced ASCII mode and
depends on the available scripting languages, that are integrated.
Currently SLang and Lua are supported, others may follow.
- TAP (Telocator Alphanumeric Protocol). This is the result of the earlier
used IXO and PET protocols. The documentation for this protocol is
available via the Web:
http://www.mot.com/MIMS/MSPG/pcia_protocols/tap_v1p8/table_of_contents.html
(Thanks a lot to Motorola!)
- UCP (Universal Computer Protocol). D2privat has kindly made the
description available to me, thanks a lot to Mannesmann Mobilfunk! Lots of
the protocol is NOT implemented, as this makes not much sense on dialup
lines.
ATTENTION: If someone has the complete documentation for any other used
protocol for pager like devices, I would be glad if she/he could make them
available for me. If I had a testing possibility I'll try to implement that
protocol.
Bugs, Problems, Comments:
~~~~~~~~~~~~~~~~~~~~~~~~~
Please send any bug report, any encountered problem (with a detailed
description as possible) and any comments to <yaps@nitmar.tnet.de> or
<ud@cube.net>.
Files:
~~~~~~
README: This file
COPYING.GPL, COPYRIGHT: About distributing the software
INSTALL: A pointer into the README file
BUGREPORT: How to report a bug
Makefile, Config: Make rules
yaps.rc: Sample configuration file
yaps.c: The driver program
valid.c, valid.h: Support routines for the driver program
remaining *.c, *.h: The paging library
yaps.html, yaps.doc: Documentation in HTML and plain text
yaps.1: A minimal manual page
yaps.lsm: The Linux Software Map entry
contrib/: Files not supported by the author

372
asc.c

@ -0,0 +1,372 @@
/* -*- mode: c; mode: fold -*- */
# include "config.h"
# include <stdio.h>
# include <stdlib.h>
# include <ctype.h>
# include <string.h>
# include "pager.h"
/*{{{ typedefs */
typedef struct {
# ifndef NDEBUG
# define MAGIC MKMAGIC('a', 's', 'c', '\0')
long magic;
# endif /* NDEBUG */
void *sp;
void *ctab;
void (*logger) (char, char *, ...);
char *callid;
int deftout;
char *alogin;
char *alogout;
char *apid;
char *amsg;
char *anext;
char *async;
date_t delay;
date_t expire;
Bool rds;
} asc;
/*}}}*/
/*{{{ convert */
static char *
escape_string (asc *a, char *str)
{
int c;
char ch, prev;
char *ret;
int n;
if (ret = malloc (strlen (str) * 2 + 16)) {
prev = '\0';
ch = '\0';
for (n = 0; *str; prev = ch) {
c = cv_conv (a -> ctab, (char_t) *str++);
if (c < 0)
continue;
ch = (char) c;
if ((ch == '<') && isspace (prev)) {
ret[n++] = '\\';
ret[n++] = '<';
} else if (ch == ' ') {
ret[n++] = '\\';
ret[n++] = 's';
} else if (ch == '\a') {
ret[n++] = '\\';
ret[n++] = 'a';
} else if (ch == '\b') {
ret[n++] = '\\';
ret[n++] = 'b';
} else if (ch == '\f') {
ret[n++] = '\\';
ret[n++] = 'f';
} else if (ch == '\n') {
ret[n++] = '\\';
ret[n++] = 'n';
} else if (ch == '\r') {
ret[n++] = '\\';
ret[n++] = 'r';
} else if (ch == '\t') {
ret[n++] = '\\';
ret[n++] = 't';
} else if (ch) {
if ((ch == '\\') || (ch == '^') || (ch == '%'))
ret[n++] = '\\';
ret[n++] = ch;
}
}
ret[n] = '\0';
}
return ret;
}
static char *
convert_asc (asc *a, char *pat, char *pid, char *msg)
{
char *str;
int siz, len;
char *ptr;
int plen;
char scr[32];
str = NULL;
siz = 0;
len = 0;
while (*pat) {
if (len + 2 >= siz) {
siz += 32;
if (! (str = Realloc (str, siz + 2)))
break;
}
if (*pat == '\\') {
++pat;
if (*pat) {
ptr = NULL;
switch (*pat) {
case 'C': ptr = a -> callid; break;
case 'P': ptr = pid; break;
case 'M': ptr = msg; break;
case 'R':
strcpy (scr, (a -> rds ? "1" : "0"));
ptr = scr;
break;
default:
str[len++] = '\\';
str[len++] = *pat;
break;
}
if (ptr && (ptr = escape_string (a, ptr))) {
if (plen = strlen (ptr)) {
if (len + plen + 2 >= siz) {
siz = len + plen + 32;
if (! (str = Realloc (str, siz)))
break;
}
strcpy (str + len, ptr);
len += plen;
}
free (ptr);
}
++pat;
}
} else if (! iscntrl (*pat))
str[len++] = *pat++;
else {
str[len++] = ' ';
++pat;
}
}
if (str)
str[len] = '\0';
return str;
}
/*}}}*/
/*{{{ general sending routine */
static int
do_send (asc *a, char *what, char *pat, char *pid, char *msg)
{
int ret;
char *str;
ret = ERR_FAIL;
if (a && a -> sp)
if (pat && *pat) {
if (str = convert_asc (a, pat, pid, msg)) {
if (tty_send_expect (a -> sp, a -> deftout, str, NULL) != -1) {
V (1, ("Ascii %s sent\n", what));
ret = NO_ERR;
} else
V (1, ("Unable to send %s\n", what));
free (str);
}
} else
ret = NO_ERR;
return ret;
}
/*}}}*/
/*{{{ login/logout/transmit/next/sync */
int
asc_login (void *ap, string_t *cid)
{
asc *a = (asc *) ap;
MCHK (a);
if (a) {
if (a -> callid)
free (a -> callid);
a -> callid = sextract (cid);
}
return a ? do_send (a, "login", a -> alogin, NULL, NULL) : ERR_ABORT;
}
int
asc_logout (void *ap)
{
asc *a = (asc *) ap;
MCHK (a);
return a ? do_send (a, "logout", a -> alogout, NULL, NULL) : ERR_FATAL;
}
int
asc_transmit (void *ap, char *pid, char *msg)
{
asc *a = (asc *) ap;
int n;
MCHK (a);
if (! a)
return ERR_FATAL;
if ((n = do_send (a, "pagerid", a -> apid, pid, NULL)) != NO_ERR)
return n;
return do_send (a, "message", a -> amsg, NULL, msg);
}
int
asc_next (void *ap)
{
asc *a = (asc *) ap;
MCHK (a);
return a ? do_send (a, "next", a -> anext, NULL, NULL) : ERR_FATAL;
}
int
asc_sync (void *ap)
{
asc *a = (asc *) ap;
MCHK (a);
return a ? do_send (a, "sync", a -> async, NULL, NULL) : ERR_FATAL;
}
/*}}}*/
/*{{{ config */
void
asc_config (void *ap, void (*logger) (char, char *, ...),
int deftout, char *alogin, char *alogout, char *apid, char *amsg, char *anext, char *async,
date_t *delay, date_t *expire, Bool rds)
{
asc *a = (asc *) ap;
MCHK (a);
if (a) {
a -> logger = logger;
if (deftout != -1)
a -> deftout = deftout;
if (alogin) {
if (a -> alogin)
free (a -> alogin);
a -> alogin = strdup (alogin);
}
if (alogout) {
if (a -> alogout)
free (a -> alogout);
a -> alogout = strdup (alogout);
}
if (apid) {
if (a -> apid)
free (a -> apid);
a -> apid = strdup (apid);
}
if (amsg) {
if (a -> amsg)
free (a -> amsg);
a -> amsg = strdup (amsg);
}
if (anext) {
if (a -> anext)
free (a -> anext);
a -> anext = strdup (anext);
}
if (async) {
if (a -> async)
free (a -> async);
a -> async = strdup (async);
}
if (delay)
a -> delay = *delay;
else
dat_clear (& a -> delay);
if (expire)
a -> expire = *expire;
else
dat_clear (& a -> expire);
a -> rds = rds;
}
}
void
asc_set_convtable (void *ap, void *ctab)
{
asc *a = (asc *) ap;
MCHK (a);
if (a) {
if (a -> ctab)
cv_free (a -> ctab);
a -> ctab = ctab;
}
}
void
asc_add_convtable (void *ap, void *ctab)
{
asc *a = (asc *) ap;
MCHK (a);
if (a) {
if (! a -> ctab)
a -> ctab = cv_new ();
if (a -> ctab)
cv_merge (a -> ctab, ctab, True);
}
}
/*}}}*/
/*{{{ new/free/etc */
void *
asc_new (void *sp)
{
asc *a;
if (a = (asc *) malloc (sizeof (asc))) {
# ifndef NDEBUG
a -> magic = MAGIC;
# endif /* NDEBUG */
a -> sp = sp;
a -> ctab = NULL;
a -> logger = NULL;
a -> callid = NULL;
a -> deftout = 10;
a -> alogin = NULL;
a -> alogout = NULL;
a -> apid = NULL;
a -> amsg = NULL;
a -> anext = NULL;
a -> async = NULL;
dat_clear (& a -> delay);
dat_clear (& a -> expire);
a -> rds = False;
}
return (void *) a;
}
void *
asc_free (void *ap)
{
asc *a = (asc *) ap;
MCHK (a);
if (a) {
if (a -> ctab)
cv_free (a -> ctab);
if (a -> callid)
free (a -> callid);
if (a -> alogin)
free (a -> alogin);
if (a -> alogout)
free (a -> alogout);
if (a -> apid)
free (a -> apid);
if (a -> amsg)
free (a -> amsg);
if (a -> anext)
free (a -> anext);
if (a -> async)
free (a -> async);
free (a);
}
return NULL;
}
int
asc_preinit (void)
{
return 0;
}
void
asc_postdeinit (void)
{
}
/*}}}*/

553
cfg.c

@ -0,0 +1,553 @@
/* -*- mode: c; mode: fold -*- */
# include "config.h"
# include <stdio.h>
# include <stdlib.h>
# include <ctype.h>
# include <string.h>
# include "pager.h"
/*{{{ typedefs */
typedef unsigned long hash_t;
typedef struct _entry {
hash_t hval;
char *var;
char *val;
struct _entry
*next;
} entry;
typedef struct _charc {
hash_t hval;
char *name;
struct _charc
*next;
} charc;
typedef struct _block {
# ifndef NDEBUG
# define MAGIC MKMAGIC ('c', 'f', 'g', '\0')
long magic;
# endif /* NDEBUG */
hash_t hval;
char *name;
charc *use;
Bool done;
entry *e;
char *sep;
int seplen;
struct _block
*next;
} block;
typedef struct _fifo {
void *dat;
struct _fifo
*next;
} fifo;
typedef struct _fpstack {
FILE *fp;
struct _fpstack
*up;
} fpstack;
/*}}}*/
/*{{{ support routines */
static hash_t
calc_hash (char *str)
{
hash_t hval;
for (hval = 0; *str; ) {
hval <<= 2;
hval += *str++ & 0xff;
hval >>= 1;
}
return hval;
}
static Bool
issame (hash_t h1, char *s1, hash_t h2, char *s2)
{
if (h1 == h2)
if ((! s1) && (! s2))
return True;
else if (s1 && s2 && (s1[0] == s2[0]) && (! strcmp (s1, s2)))
return True;
return False;
}
static block *
new_block (char *bname, hash_t hval, char *sep)
{
block *b;
if (b = (block *) malloc (sizeof (block))) {
b -> name = NULL;
if ((! bname) || (b -> name = strdup (bname))) {
b -> sep = NULL;
b -> seplen = 0;
if ((! sep) || (b -> sep = strdup (sep))) {
# ifndef NDEBUG
b -> magic = MAGIC;
# endif /* NDEBUG */
b -> hval = hval;
b -> use = NULL;
b -> done = False;
b -> e = NULL;
b -> next = NULL;
} else {
if (b -> name)
free (b -> name);
free (b);
b = NULL;
}
} else {
free (b);
b = NULL;
}
}
return b;
}
static void
add_entry (block *base, block *b, char *var, char *val)
{
hash_t hval;
entry *e, *etmp;
Bool add;
char *sav;
if (b && var) {
if (*var == '+') {
++var;
add = True;
} else
add = False;
hval = calc_hash (var);
for (e = b -> e; e; e = e -> next)
if (issame (hval, var, e -> hval, e -> var))
break;
if (e) {
if (e -> val)
if (add) {
if (val && *val) {
sav = e -> val;
if (e -> val = malloc (strlen (sav) + strlen (val) + base -> seplen + 2)) {
sprintf (e -> val, "%s%s%s", sav, (base -> sep ? base -> sep : ""), val);
free (sav);
val = NULL;
} else
e -> val = sav;
}
} else {
free (e -> val);
e -> val = NULL;
}
} else if (e = (entry *) malloc (sizeof (entry)))
if (e -> var = strdup (var)) {
e -> hval = hval;
e -> val = NULL;
e -> next = b -> e;
b -> e = e;
} else {
free (e);
e = NULL;
}
if (e && (! e -> val) && val && *val) {
if (add && (base != b)) {
for (etmp = base -> e; etmp; etmp = etmp -> next)
if (issame (hval, var, etmp -> hval, etmp -> var))
break;
if (etmp && etmp -> val)
if (e -> val = malloc (strlen (etmp -> val) + strlen (val) + base -> seplen + 2))
sprintf (e -> val, "%s%s%s", etmp -> val, (base -> sep ? base -> sep : ""), val);
}
if (! e -> val)
e -> val = strdup (val);
}
}
}
/*}}}*/
/*{{{ read configuration */
void *
cfg_new (char *sep)
{
return (void *) new_block (NULL, 0, sep);
}
void *
cfg_read (char *fname, void *bp, char *sep)
{
FILE *fp;
fpstack *fcur, *ftmp;
char *gline, *line;
char *ptr, *use;
charc *prv, *tmp;
block *base, *prev, *cur;
hash_t hval;
char *var, *val;
int plen;
Bool done;
int siz, len;
char *temp;
if (bp)
base = (block *) bp;
else
if (! (base = new_block (NULL, 0, sep)))
return NULL;
cur = base;
if (fp = fopen (fname, "r"))
if (fcur = (fpstack *) malloc (sizeof (fpstack))) {
fcur -> fp = fp;
fcur -> up = NULL;
while (fcur) {
while (gline = getline (fcur -> fp, True)) {
for (line = gline; isspace (*line); ++line)
;
if ((! *line) || (*line == '#')) {
free (gline);
continue;
}
if (*line == '[') {
use = NULL;
if (ptr = strchr (line, ']')) {
*ptr++ = '\0';
while (isspace (*ptr))
++ptr;
if (*ptr)
use = ptr;
}
ptr = line + 1;
if (! *ptr)
cur = base;
else {
hval = calc_hash (ptr);
for (cur = base, prev = NULL; cur; cur = cur -> next)
if (issame (hval, ptr, cur -> hval, cur -> name))
break;
else
prev = cur;
if ((! cur) && (cur = new_block (ptr, hval, NULL)))
if (prev)
prev -> next = cur;
if (cur && use) {
if (cur -> use)
for (prv = cur -> use; prv -> next; prv = prv -> next)
;
else
prv = NULL;
while (*use) {
ptr = use;
use = skipch (ptr, ',');
if (tmp = (charc *) malloc (sizeof (charc)))
if (tmp -> name = strdup (ptr)) {
tmp -> hval = 0;
tmp -> next = NULL;
if (prv)
prv -> next = tmp;
else
cur -> use = tmp;
prv = tmp;
} else
free (tmp);
}
}
}
if (! cur) {
free (gline);
break;
}
} else if (*line == '|') {
++line;
while (isspace (*line))
++line;
if (fp = fopen (line, "r"))
if (ftmp = (fpstack *) malloc (sizeof (fpstack))) {
ftmp -> fp = fp;
ftmp -> up = fcur;
fcur = ftmp;
} else
fclose (fp);
} else {
var = line;
val = skip (var);
if (var = strdup (var)) {
temp = NULL;
if ((*val == '{') && (! *(val + 1))) {
done = False;
siz = 0;
len = 0;
while (ptr = getline (fcur -> fp, False)) {
if ((*ptr != '}') || *(ptr + 1)) {
plen = strlen (ptr);
if (len + plen + 2 >= siz) {
siz = len + plen + 256;
if (! (temp = Realloc (temp, siz + 2))) {
siz = 0;
done = True;
}
}
if (len + plen < siz) {
if (len)
temp[len++] = '\n';
strcpy (temp + len, ptr);
len += plen;
}
} else
done = True;
free (ptr);
if (done)
break;
}
if (temp) {
temp[len] = '\0';
val = temp;
} else
val = NULL;
} else if (*val == '\\')
++val;
add_entry (base, cur, var, val);
if (temp)
free (temp);
free (var);
}
}
free (gline);
}
ftmp = fcur;
fcur = fcur -> up;
fclose (ftmp -> fp);
free (ftmp);
}
} else
fclose (fp);
return (void *) base;
}
/*}}}*/
/*{{{ add/change configuration */
void
cfg_modify (void *bp, char *bname, char *var, char *val)
{
block *base = (block *) bp;
block *use, *prv;
hash_t hval;
MCHK (base);
if (base) {
if (! bname)
use = base;
else {
hval = calc_hash (bname);
for (use = base -> next, prv = base; use; use = use -> next)
if (issame (hval, bname, use -> hval, use -> name))
break;
else
prv = use;
if (! use)
use = new_block (bname, hval, NULL);
}
if (use)
add_entry (base, use, var, val);
}
}
/*}}}*/
/*{{{ end (free up) configuration */
void *
cfg_end (void *bp)
{
block *b = (block *) bp;
block *tmp;
charc *run;
entry *e;
MCHK (b);
while (b) {
if (b -> name)
free (b -> name);
while (b -> use) {
run = b -> use;
b -> use = b -> use -> next;
if (run -> name)
free (run -> name);
free (run);
}
while (b -> e) {
e = b -> e;
b -> e = b -> e -> next;
if (e -> var)
free (e -> var);
if (e -> val)
free (e -> val);
free (e);
}
if (b -> sep)
free (b -> sep);
tmp = b;
b = b -> next;
free (tmp);
}
return NULL;
}
/*}}}*/
/*{{{ retrieving */
static char *
do_get (void *bp, char *bname, char *var, Bool glob, char *dflt)
{
block *b = (block *) bp;
block *run, *tmp;
entry *e;
fifo *f, *l, *ft;
charc *use;
char *ptr, *sav;
charc *vars, *vprv, *vtmp, *vrun;
Bool first;
hash_t hval;
MCHK (b);
if (! (var = strdup (var)))
return NULL;
vars = NULL;
vprv = NULL;
for (ptr = var; *ptr; ) {
sav = ptr;
ptr = skipch (ptr, ',');
if (vtmp = (charc *) malloc (sizeof (charc)))
if (vtmp -> name = strdup (sav)) {
vtmp -> hval = calc_hash (vtmp -> name);
vtmp -> next = NULL;
if (vprv)
vprv -> next = vtmp;
else
vars = vtmp;
vprv = vtmp;
} else
free (vtmp);
}
free (var);
if (! vars)
return NULL;
e = NULL;
f = NULL;
l = NULL;
first = True;
while ((! e) && bname) {
hval = calc_hash (bname);
for (run = b -> next; run; run = run -> next)
if (issame (hval, bname, run -> hval, run -> name))
break;
bname = NULL;
if (run && (first || (! run -> done))) {
for (vrun = vars; vrun; vrun = vrun -> next) {
for (e = run -> e; e; e = e -> next)
if (issame (vrun -> hval, vrun -> name, e -> hval, e -> var))
break;
if (e)
break;
}
if (! e) {
if (use = run -> use) {
if (first) {
for (tmp = b -> next; tmp; tmp = tmp -> next)
tmp -> done = False;
first = False;
}
for (; use; use = use -> next)
if (ft = (fifo *) malloc (sizeof (fifo))) {
ft -> dat = (void *) use;
ft -> next = NULL;
if (l)
l -> next = ft;