├── README ├── NEWS ├── etc ├── .gitignore ├── udev-usbserial-plptools.rules ├── psidump.1 ├── ttytap.c └── plptools.in ├── ncpd ├── .gitignore ├── main.h ├── mp_serial.h ├── Makefile.am ├── linkchan.h ├── socketchan.h ├── channel.h ├── packet.h ├── channel.cc ├── ncp.h ├── linkchan.cc └── mp_serial.c ├── plpfuse ├── .gitignore ├── Makefile.am ├── plpfuse.h └── rfsv_api.h ├── plpftp ├── .gitignore ├── Makefile.am └── ftp.h ├── AUTHORS ├── sisinstall ├── .gitignore ├── sisfilelink.cpp ├── sisfilelink.h ├── Makefile.am ├── fakepsion.h ├── psion.h ├── fakepsion.cpp ├── sisinstaller.h └── psion.cpp ├── doc ├── .gitignore ├── Makefile.am ├── sisinstall.man.in ├── plpftp.man.in ├── plpprintd.man.in ├── ncpd.man.in └── plpfuse.man.in ├── lib ├── .gitignore ├── plpintl.h ├── sislangrecord.cpp ├── sislangrecord.h ├── log.cc ├── rpcs16.h ├── rpcs16.cc ├── sisreqrecord.h ├── sistypes.h ├── Makefile.am ├── iowatch.h ├── iowatch.cc ├── rpcs32.h ├── Enum.cc ├── rpcsfactory.h ├── siscomponentrecord.h ├── rfsvfactory.h ├── sisreqrecord.cpp ├── psiprocess.cc ├── psibitmap.h ├── sisfileheader.h ├── sisfile.h ├── sisfilerecord.h ├── rpcsfactory.cc ├── psiprocess.h ├── sistypes.cpp ├── rfsvfactory.cc ├── siscomponentrecord.cpp ├── wprt.h ├── log.h ├── bufferarray.cc ├── wprt.cc ├── sisfile.cpp ├── bufferarray.h ├── sisfilerecord.cpp └── rclip.cc ├── plpprint ├── .gitignore ├── fontmap └── Makefile.am ├── po ├── sv.po ├── .gitignore ├── POTFILES.in └── Makevars ├── .editorconfig ├── .gitmodules ├── TODO ├── .gitignore ├── m4 ├── glibc2.m4 ├── glibc21.m4 ├── uintmax_t.m4 ├── .gitignore ├── ax_check_gnu_make.m4 └── longlong.m4 ├── .github └── workflows │ └── c-cpp.yml ├── Makefile.am ├── HISTORY ├── ChangeLog ├── README.md └── bootstrap.conf /README: -------------------------------------------------------------------------------- 1 | README.md -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | See release notes. -------------------------------------------------------------------------------- /etc/.gitignore: -------------------------------------------------------------------------------- 1 | /plptools 2 | -------------------------------------------------------------------------------- /ncpd/.gitignore: -------------------------------------------------------------------------------- 1 | /ncpd 2 | -------------------------------------------------------------------------------- /plpfuse/.gitignore: -------------------------------------------------------------------------------- 1 | /plpfuse -------------------------------------------------------------------------------- /plpftp/.gitignore: -------------------------------------------------------------------------------- 1 | /plpftp 2 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | See sources and documentation. -------------------------------------------------------------------------------- /sisinstall/.gitignore: -------------------------------------------------------------------------------- 1 | sisinstall 2 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | /*.man 2 | /*.8 3 | /*.1 4 | -------------------------------------------------------------------------------- /lib/.gitignore: -------------------------------------------------------------------------------- 1 | /*.la 2 | /*.lo 3 | /*.loT 4 | -------------------------------------------------------------------------------- /plpprint/.gitignore: -------------------------------------------------------------------------------- 1 | /plpprintd 2 | /prolog.ps 3 | -------------------------------------------------------------------------------- /po/sv.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rrthomas/plptools/HEAD/po/sv.po -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | -------------------------------------------------------------------------------- /etc/udev-usbserial-plptools.rules: -------------------------------------------------------------------------------- 1 | ACTION=="add", SUBSYSTEMS=="usb-serial", DRIVERS=="pl2303", RUN+="/etc/init.d/plptools start" 2 | ACTION=="remove", SUBSYSTEM=="usb-serial", RUN+="/etc/init.d/plptools stop" 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "gnulib"] 2 | path = gnulib 3 | url = git://git.sv.gnu.org/gnulib.git 4 | [submodule "gl-mod/bootstrap"] 5 | path = gl-mod/bootstrap 6 | url = https://github.com/gnulib-modules/bootstrap.git 7 | -------------------------------------------------------------------------------- /po/.gitignore: -------------------------------------------------------------------------------- 1 | /POTFILES 2 | /*.gmo 3 | /*.pot 4 | /stamp-po 5 | /remove-potcdate.sed 6 | /Makefile.in.in 7 | /Makevars.template 8 | /Rules-quot 9 | /boldquot.sed 10 | /en@boldquot.header 11 | /en@quot.header 12 | /insert-header.sin 13 | /quot.sed 14 | /remove-potcdate.sin 15 | /ChangeLog 16 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | ncpd: 2 | getty-style locking of the serial-line in a manner that it can be 3 | used with other devices/programs without stopping/starting ncpd 4 | all the time. 5 | 6 | plpprintd: 7 | Fix pattern stuff 8 | 9 | Sisinstall: 10 | - Use rpm-style arguments. 11 | - Check requisite records. 12 | - Check file crc. 13 | - Create a unique name of the residual sis file, if 14 | the provided name already exists. 15 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | lib/rfsv.cc 2 | lib/rpcs.cc 3 | lib/psitime.h 4 | lib/rpcsfactory.cc 5 | lib/plpdirent.cc 6 | lib/rfsvfactory.cc 7 | lib/siscomponentrecord.cpp 8 | lib/sisfile.cpp 9 | lib/sisfileheader.cpp 10 | lib/sisfilerecord.cpp 11 | lib/sislangrecord.cpp 12 | lib/sisreqrecord.cpp 13 | 14 | plpftp/main.cc 15 | plpftp/ftp.cc 16 | sisinstall/sismain.cpp 17 | ncpd/main.cc 18 | ncpd/link.cc 19 | plpfuse/main.cc 20 | plpprint/plpprintd.cc 21 | 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.o 3 | Makefile.in 4 | Makefile 5 | .deps 6 | .libs 7 | /aclocal.m4 8 | /autom4te.cache 9 | /libgnu 10 | /configure 11 | /config.guess 12 | /config.sub 13 | /libtool 14 | /config.status 15 | /config.status.lineno 16 | /config.cache 17 | /config.log 18 | /config.rpath 19 | /config.h 20 | /config.h.in 21 | /stamp-h.in 22 | /stamp-h1 23 | /plptools-*.tar.gz 24 | /ABOUT-NLS 25 | /ChangeLog 26 | /compile 27 | /depcomp 28 | /missing 29 | /install-sh 30 | /ltmain.sh 31 | /INSTALL 32 | -------------------------------------------------------------------------------- /plpprint/fontmap: -------------------------------------------------------------------------------- 1 | # This file specifies the font-mapping from Psion fonts 2 | # to PostScript fonts for plpprintd. 3 | # Format: 4 | # 5 | # FN:B:I:PSFN 6 | # 7 | # Where 8 | # FN is the Psion fontname 9 | # B is a flag for Bold (0 or 1) 10 | # I is a flag for Italic (0 or 1) 11 | # PSFN is the corresponding PostScript font to use 12 | # 13 | # Lines starting with a hash and empty lines are ignored. 14 | # 15 | Times New Roman:0:0:Times-Roman 16 | Times New Roman:1:0:Times-Bold 17 | Times New Roman:0:1:Times-Italic 18 | Times New Roman:1:1:Times-BoldItalic 19 | Arial:0:0:Helvetica 20 | Arial:1:0:Helvetica-Bold 21 | Arial:0:1:Helvetica-Oblique 22 | Arial:1:1:Helvetica-BoldOblique 23 | Courier New:0:0:Courier 24 | Courier New:1:0:Courier-Bold 25 | Courier New:0:1:Courier-Oblique 26 | Courier New:1:1:Courier-BoldOblique 27 | Swiss:0:0:Courier 28 | Swiss:1:0:Courier-Bold 29 | Swiss:0:1:Courier-Oblique 30 | Swiss:1:1:Courier-BoldOblique 31 | -------------------------------------------------------------------------------- /m4/glibc2.m4: -------------------------------------------------------------------------------- 1 | # glibc2.m4 serial 3 2 | dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation, 3 | dnl Inc. 4 | dnl This file is free software; the Free Software Foundation 5 | dnl gives unlimited permission to copy and/or distribute it, 6 | dnl with or without modifications, as long as this notice is preserved. 7 | 8 | # Test for the GNU C Library, version 2.0 or newer. 9 | # From Bruno Haible. 10 | 11 | AC_DEFUN([gt_GLIBC2], 12 | [ 13 | AC_CACHE_CHECK([whether we are using the GNU C Library 2 or newer], 14 | [ac_cv_gnu_library_2], 15 | [AC_EGREP_CPP([Lucky GNU user], 16 | [ 17 | #include 18 | #ifdef __GNU_LIBRARY__ 19 | #if (__GLIBC__ >= 2) && !defined __UCLIBC__ 20 | Lucky GNU user 21 | #endif 22 | #endif 23 | ], 24 | [ac_cv_gnu_library_2=yes], 25 | [ac_cv_gnu_library_2=no]) 26 | ] 27 | ) 28 | AC_SUBST([GLIBC2]) 29 | GLIBC2="$ac_cv_gnu_library_2" 30 | ] 31 | ) 32 | -------------------------------------------------------------------------------- /sisinstall/sisfilelink.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #include "config.h" 21 | 22 | #include "sisfilelink.h" 23 | 24 | SISFileLink::SISFileLink(SISFile* file) 25 | { 26 | m_file = file; 27 | m_next = 0; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /m4/glibc21.m4: -------------------------------------------------------------------------------- 1 | # glibc21.m4 serial 5 2 | dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation, 3 | dnl Inc. 4 | dnl This file is free software; the Free Software Foundation 5 | dnl gives unlimited permission to copy and/or distribute it, 6 | dnl with or without modifications, as long as this notice is preserved. 7 | 8 | # Test for the GNU C Library, version 2.1 or newer, or uClibc. 9 | # From Bruno Haible. 10 | 11 | AC_DEFUN([gl_GLIBC21], 12 | [ 13 | AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc], 14 | [ac_cv_gnu_library_2_1], 15 | [AC_EGREP_CPP([Lucky], 16 | [ 17 | #include 18 | #ifdef __GNU_LIBRARY__ 19 | #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) 20 | Lucky GNU user 21 | #endif 22 | #endif 23 | #ifdef __UCLIBC__ 24 | Lucky user 25 | #endif 26 | ], 27 | [ac_cv_gnu_library_2_1=yes], 28 | [ac_cv_gnu_library_2_1=no]) 29 | ] 30 | ) 31 | AC_SUBST([GLIBC21]) 32 | GLIBC21="$ac_cv_gnu_library_2_1" 33 | ] 34 | ) 35 | -------------------------------------------------------------------------------- /ncpd/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2002 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #ifndef _main_h_ 22 | #define _main_h_ 23 | 24 | #include 25 | 26 | extern std::ostream lout; 27 | extern std::ostream lerr; 28 | extern std::ostream linf; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /sisinstall/sisfilelink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | 21 | #ifndef _SISFILELINK_H 22 | #define _SISFILELINK_H 23 | 24 | class SISFile; 25 | 26 | class SISFileLink 27 | { 28 | public: 29 | SISFileLink(SISFile* file); 30 | 31 | SISFileLink* m_next; 32 | SISFile* m_file; 33 | }; 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /ncpd/mp_serial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #ifndef _mp_serial_h 22 | #define _mp_serial_h 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | int init_serial(const char *dev, int speed, int debug); 28 | void ser_exit(int fd); 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /plpftp/Makefile.am: -------------------------------------------------------------------------------- 1 | # plpftp/Makefile.am 2 | # 3 | # This file is part of plptools. 4 | # 5 | # Copyright (C) 1999-2002 Fritz Elfert 6 | # Copyright (C) 2007-2025 Reuben Thomas 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # along with this program; if not, see . 20 | 21 | bin_PROGRAMS = plpftp 22 | plpftp_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/libgnu -I$(top_builddir)/libgnu 23 | plpftp_CXXFLAGS = $(WARN_CXXFLAGS) 24 | plpftp_LDADD = $(LIB_PLP) $(INTLLIBS) $(SERVENT_LIB) $(top_builddir)/libgnu/libgnu.a 25 | plpftp_SOURCES = ftp.cc main.cc ftp.h 26 | -------------------------------------------------------------------------------- /plpfuse/Makefile.am: -------------------------------------------------------------------------------- 1 | # plpfuse/Makefile.am 2 | # 3 | # This file is part of plptools. 4 | # 5 | # Copyright (C) 2007-2025 Reuben Thomas 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License along 18 | # along with this program; if not, see . 19 | 20 | sbin_PROGRAMS = plpfuse 21 | plpfuse_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/libgnu -I$(top_builddir)/libgnu 22 | plpfuse_CFLAGS = $(FUSE_CFLAGS) $(WARN_CFLAGS) 23 | plpfuse_CXXFLAGS = $(FUSE_CFLAGS) $(WARN_CXXFLAGS) 24 | plpfuse_LDADD = $(LIB_PLP) $(INTLLIBS) $(FUSE_LIBS) $(top_builddir)/libgnu/libgnu.a 25 | plpfuse_SOURCES = main.cc fuse.c rfsv_api.h plpfuse.h 26 | -------------------------------------------------------------------------------- /m4/uintmax_t.m4: -------------------------------------------------------------------------------- 1 | # uintmax_t.m4 serial 12 2 | dnl Copyright (C) 1997-2004, 2007-2010 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Paul Eggert. 8 | 9 | AC_PREREQ([2.13]) 10 | 11 | # Define uintmax_t to 'unsigned long' or 'unsigned long long' 12 | # if it is not already defined in or . 13 | 14 | AC_DEFUN([gl_AC_TYPE_UINTMAX_T], 15 | [ 16 | AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) 17 | AC_REQUIRE([gl_AC_HEADER_STDINT_H]) 18 | if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then 19 | AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) 20 | test $ac_cv_type_unsigned_long_long_int = yes \ 21 | && ac_type='unsigned long long' \ 22 | || ac_type='unsigned long' 23 | AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type], 24 | [Define to unsigned long or unsigned long long 25 | if and don't define.]) 26 | else 27 | AC_DEFINE([HAVE_UINTMAX_T], [1], 28 | [Define if you have the 'uintmax_t' type in or .]) 29 | fi 30 | ]) 31 | -------------------------------------------------------------------------------- /.github/workflows/c-cpp.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: [ push, pull_request ] 4 | 5 | jobs: 6 | build: 7 | strategy: 8 | matrix: 9 | os: [ubuntu-latest, macos-latest] 10 | include: 11 | - os: ubuntu-latest 12 | env: 13 | ASAN: "yes" 14 | shell: bash 15 | - os: macos-latest 16 | shell: bash 17 | runs-on: ${{ matrix.os }} 18 | defaults: 19 | run: 20 | shell: ${{ matrix.shell }} {0} 21 | steps: 22 | - uses: actions/checkout@v4 23 | with: { submodules: true } 24 | - name: Install dependencies (Ubuntu) 25 | if: ${{ matrix.os == 'ubuntu-latest' }} 26 | run: sudo apt-get -y install libreadline-dev pkg-config gettext autopoint libfuse-dev libattr1-dev 27 | - name: Install dependencies (macOS) 28 | if: ${{ matrix.os == 'macos-latest' }} 29 | run: | 30 | brew install coreutils readline pkg-config libtool automake gettext macfuse 31 | echo "$(brew --prefix m4)/bin:/usr/local/opt/gettext/bin" >> $GITHUB_PATH 32 | echo "LDFLAGS=-L$(brew --prefix readline)/lib" >> "$GITHUB_ENV" 33 | echo "CPPFLAGS=-I$(brew --prefix readline)/include" >> "$GITHUB_ENV" 34 | - name: Build 35 | run: ./build-aux/build.sh 36 | -------------------------------------------------------------------------------- /plpprint/Makefile.am: -------------------------------------------------------------------------------- 1 | # plpprint/Makefile.am 2 | # 3 | # This file is part of plptools. 4 | # 5 | # Copyright (C) 2002 Fritz Elfert 6 | # Copyright (C) 2007-2025 Reuben Thomas 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # along with this program; if not, see . 20 | 21 | sbin_PROGRAMS = plpprintd 22 | plpprintd_CPPFLAGS = -DPKGDATADIR="\"$(pkgdatadir)\"" -I$(top_srcdir)/lib -I$(top_srcdir)/libgnu -I$(top_builddir)/libgnu 23 | plpprintd_CXXFLAGS = $(WARN_CXXFLAGS) 24 | plpprintd_LDADD = $(LIB_PLP) $(INTLLIBS) $(SERVENT_LIB) $(top_builddir)/libgnu/libgnu.a 25 | plpprintd_SOURCES = plpprintd.cc 26 | 27 | EXTRA_DIST = prolog.ps.in fontmap 28 | 29 | pkgdata_DATA = prolog.ps fontmap 30 | -------------------------------------------------------------------------------- /sisinstall/Makefile.am: -------------------------------------------------------------------------------- 1 | # sisinstall/Makefile.am 2 | # 3 | # This file is part of plptools. 4 | # 5 | # Copyright (C) 2002 Daniel Brahneborg 6 | # Copyright (C) 2007-2025 Reuben Thomas 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # along with this program; if not, see . 20 | 21 | bin_PROGRAMS = sisinstall 22 | sisinstall_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/libgnu -I$(top_builddir)/libgnu 23 | sisinstall_CXXFLAGS = $(WARN_CXXFLAGS) 24 | sisinstall_LDADD = ../lib/libplp.la $(INTLLIBS) $(SERVENT_LIB) $(top_builddir)/libgnu/libgnu.a 25 | sisinstall_SOURCES = psion.cpp sisinstaller.cpp sismain.cpp \ 26 | fakepsion.cpp sisfilelink.cpp sisfilelink.h \ 27 | psion.h sisinstaller.h fakepsion.h 28 | -------------------------------------------------------------------------------- /lib/plpintl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999-2002 Fritz Elfert 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #ifndef _PLPINTL_H_ 21 | #define _PLPINTL_H_ 22 | 23 | #include "config.h" 24 | 25 | /* libintl.h includes locale.h only if optimized. 26 | * however, we need LC_ALL ... 27 | */ 28 | #include 29 | 30 | #if defined(ENABLE_NLS) 31 | # include 32 | # define _(String) gettext (String) 33 | # define N_(String) (String) 34 | #else 35 | # define _(String) (String) 36 | # define N_(String) String 37 | # define textdomain(Domain) 38 | # define bindtextdomain(Package, Directory) 39 | #endif 40 | 41 | #endif /* _PLPINTL_H_ */ 42 | -------------------------------------------------------------------------------- /ncpd/Makefile.am: -------------------------------------------------------------------------------- 1 | # ncpd/Makefile.am 2 | # 3 | # This file is part of plptools. 4 | # 5 | # Copyright (C) 1999-2002 Fritz Elfert 6 | # Copyright (C) 2007-2024 Reuben Thomas 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # along with this program; if not, see . 20 | 21 | sbin_PROGRAMS = ncpd 22 | ncpd_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/libgnu -I$(top_builddir)/libgnu 23 | ncpd_CFLAGS = $(THREADED_CFLAGS) 24 | ncpd_CXXFLAGS = $(THREADED_CXXFLAGS) 25 | ncpd_LDADD = $(LIB_PLP) $(INTLLIBS) $(LIBPMULTITHREAD) $(LIBTHREAD) $(NANOSLEEP_LIB) $(PTHREAD_SIGMASK_LIB) $(SELECT_LIB) $(top_builddir)/libgnu/libgnu.a 26 | ncpd_SOURCES = channel.cc link.cc linkchan.cc main.cc \ 27 | ncp.cc packet.cc socketchan.cc mp_serial.c \ 28 | channel.h link.h linkchan.h main.h mp_serial.h ncp.h packet.h \ 29 | socketchan.h 30 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | # doc/Makefile.am 2 | # 3 | # This file is part of plptools. 4 | # 5 | # Copyright (C) 2000-2002 Fritz Elfert 6 | # Copyright (C) 2007-2014 Reuben Thomas 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # along with this program; if not, see . 20 | 21 | EXTRA_DIST = ncpd.man.in plpfuse.man.in plpftp.man.in sisinstall.man.in \ 22 | plpprintd.man.in 23 | 24 | man_MANS = ncpd.8 plpftp.1 sisinstall.1 plpprintd.8 25 | if BUILD_PLPFUSE 26 | man_MANS += plpfuse.8 27 | endif 28 | 29 | edit = sed \ 30 | -e 's|@MANDATE@|'`git log --pretty=format:"%ad" --date=short -1 $<.in`'|g' \ 31 | -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' 32 | 33 | %.1: %.man Makefile 34 | rm -f $@ $@.tmp 35 | $(edit) $< >$@.tmp 36 | mv $@.tmp $@ 37 | 38 | %.8: %.man Makefile 39 | rm -f $@ $@.tmp 40 | $(edit) $< >$@.tmp 41 | mv $@.tmp $@ 42 | 43 | distclean-local: 44 | rm -f *.1 *.8 45 | -------------------------------------------------------------------------------- /lib/sislangrecord.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | */ 19 | #include "config.h" 20 | 21 | #include "sislangrecord.h" 22 | #include "plpintl.h" 23 | 24 | #include 25 | 26 | SisRC 27 | SISLangRecord::fillFrom(uint8_t* buf, int* base, off_t len) 28 | { 29 | if (*base + 2 > len) 30 | return SIS_TRUNCATED; 31 | m_lang = read16(buf + *base); 32 | if (m_lang > 33) // Thai, last language 33 | return SIS_CORRUPTED; 34 | if (logLevel >= 2) 35 | printf(_("Got language %d (%s)\n"), m_lang, langTable[m_lang].m_name); 36 | if (logLevel >= 1) 37 | printf(_("%d .. %d (%d bytes): Language record for %s\n"), 38 | *base, *base + 2, 2, langTable[m_lang].m_name); 39 | *base += 2; 40 | return SIS_OK; 41 | } 42 | -------------------------------------------------------------------------------- /lib/sislangrecord.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | */ 19 | 20 | #ifndef _SISLANGRECORD_H 21 | #define _SISLANGRECORD_H 22 | 23 | #include "sistypes.h" 24 | 25 | /** 26 | * A simple language record, only containing the epoc specific 16 bit 27 | * language number. 28 | */ 29 | class SISLangRecord 30 | { 31 | public: 32 | 33 | /** 34 | * Populate the fields. 35 | * 36 | * @param buf The buffer to read from. 37 | * @param base The index to start reading from, which is updated 38 | * when the record is successfully read. 39 | * @param len The length of the buffer. 40 | */ 41 | SisRC fillFrom(uint8_t* buf, int* base, off_t len); 42 | 43 | /** 44 | * The language number. 45 | * 46 | * @see langTable 47 | */ 48 | uint16_t m_lang; 49 | 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /ncpd/linkchan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #ifndef _linkchan_h_ 22 | #define _linkchan_h_ 23 | 24 | #include "channel.h" 25 | #include "bufferarray.h" 26 | 27 | #define LINKCHAN_DEBUG_LOG 1 28 | #define LINKCHAN_DEBUG_DUMP 2 29 | 30 | class linkChan : public channel { 31 | public: 32 | linkChan(ncp *ncpController, int ncpChannel = -1); 33 | 34 | void ncpDataCallback(bufferStore &a); 35 | const char *getNcpRegisterName(); 36 | void ncpConnectAck(); 37 | void ncpConnectTerminate(); 38 | void ncpConnectNak(); 39 | void ncpRegisterAck() {} 40 | void Register(channel *); 41 | private: 42 | int registerSer; 43 | bufferArray registerStack; 44 | }; 45 | #endif 46 | -------------------------------------------------------------------------------- /doc/sisinstall.man.in: -------------------------------------------------------------------------------- 1 | .\" Manual page for sisinstall 2 | .\" 3 | .\" Process this file with 4 | .\" groff -man -Tascii sisinstall.1 for ASCII output, or 5 | .\" groff -man -Tps sisinstall.1 for Postscript output 6 | .\" 7 | .TH sisinstall 1 "@MANDATE@" "plptools @VERSION@" "User commands" 8 | .SH NAME 9 | sisinstall \- simple command line program for installing 10 | packaged programs or libraries on the Psion. 11 | .SH SYNOPSIS 12 | .B sisinstall 13 | .B [-h] 14 | .B [-V] 15 | .B [-n] 16 | .BI "[-v " level ] 17 | .BI [ long-options ] 18 | .B FILE 19 | 20 | .SH DESCRIPTION 21 | 22 | sisinstall installs a packaged program or library from a sis file to a 23 | Psion machine. 24 | It requires the ncpd to be running already to provide access to the 25 | Psion machine over the serial port. 26 | 27 | .SH OPTIONS 28 | 29 | .TP 30 | .B \-V, --version 31 | Display the version and exit 32 | .TP 33 | .B \-h, --help 34 | Display a short help text and exit. 35 | .TP 36 | .B \-n, --dryryn 37 | Just parse the sis file, don't touch the Psion machine. 38 | .TP 39 | .BI "\-v, --verbose=" level 40 | Specify the log level. 41 | 42 | Level 0 is the default, and is pretty quiet. 43 | 44 | Level 1 provides detailed information on the data that is read. 45 | 46 | Level 2 is rather verbose, and is mostly meant for debugging. 47 | 48 | .SH BUGS 49 | Ignores dependency records in the sis file. 50 | 51 | .SH SEE ALSO 52 | ncpd(8), plpfuse(8), plpprintd(8), plpftp(1) 53 | 54 | .SH AUTHOR 55 | Written by Daniel Brahneborg (basic@chello.se). 56 | .br 57 | Psion communication based on plpftp by Fritz Elfert (felfert@to.com). 58 | -------------------------------------------------------------------------------- /lib/log.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #include "config.h" 22 | 23 | #include "log.h" 24 | 25 | #include "ignore-value.h" 26 | 27 | #include 28 | 29 | logbuf::logbuf(int loglevel, int fd) { 30 | ptr = buf; 31 | len = 0; 32 | _on = true; 33 | _level = loglevel; 34 | _fd = fd; 35 | } 36 | 37 | int logbuf::overflow(int c) { 38 | if (c == '\n') { 39 | *ptr++ = '\n'; 40 | *ptr = '\0'; 41 | if (_on) 42 | syslog(_level, "%s", buf); 43 | else if (_fd != -1) 44 | ignore_value(write(_fd, buf, len + 1)); 45 | ptr = buf; 46 | len = 0; 47 | return 0; 48 | } 49 | if ((len + 2) >= sizeof(buf)) 50 | return EOF; 51 | *ptr++ = c; 52 | len++; 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /lib/rpcs16.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2002 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #ifndef _RPCS16_H_ 22 | #define _RPCS16_H_ 23 | 24 | #include "rpcs.h" 25 | 26 | class ppsocket; 27 | class bufferStore; 28 | class rpcsfactory; 29 | 30 | /** 31 | * This is the implementation of the @ref rpcs protocol for 32 | * Psion series 3 (SIBO) variant. You normally never create 33 | * objects of this class directly. Thus the constructor is 34 | * private. Use @ref rpcsfactory for creating an instance of 35 | * @ref rpcs . For a complete documentation, see @ref rpcs . 36 | */ 37 | class rpcs16 : public rpcs { 38 | friend class rpcsfactory; 39 | 40 | public: 41 | Enum getCmdLine(const char *, std::string &); 42 | 43 | private: 44 | rpcs16(ppsocket *); 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /lib/rpcs16.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Matt J. Gumbley 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #include "config.h" 22 | 23 | #include "rpcs16.h" 24 | #include "bufferstore.h" 25 | #include "bufferarray.h" 26 | #include "ppsocket.h" 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | using namespace std; 33 | 34 | rpcs16::rpcs16(ppsocket * _skt) 35 | { 36 | skt = _skt; 37 | mtCacheS5mx = 0; 38 | reset(); 39 | } 40 | 41 | Enum rpcs16:: 42 | getCmdLine(const char *process, string &ret) 43 | { 44 | bufferStore a; 45 | Enum res; 46 | 47 | a.addStringT(process); 48 | if (!sendCommand(rpcs::GET_CMDLINE, a)) 49 | return rfsv::E_PSI_FILE_DISC; 50 | if ((res = getResponse(a, true)) == rfsv::E_PSI_GEN_NONE) 51 | ret = a.getString(0); 52 | return res; 53 | } 54 | -------------------------------------------------------------------------------- /lib/sisreqrecord.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | */ 19 | 20 | #ifndef _SISREQRECORD_H 21 | #define _SISREQRECORD_H 22 | 23 | #include "sistypes.h" 24 | 25 | class SISFile; 26 | 27 | /** 28 | * Information about an application that must be installed prior to the 29 | * current one. 30 | */ 31 | class SISReqRecord 32 | { 33 | public: 34 | 35 | /** 36 | * Populate the fields. 37 | * 38 | * @param buf The buffer to read from. 39 | * @param base The index to start reading from, which is updated 40 | * when the record is successfully read. 41 | * @param len The length of the buffer. 42 | * @param sisFile The container SISFile. 43 | */ 44 | SisRC fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile); 45 | 46 | uint32_t m_uid; 47 | uint16_t m_major; 48 | uint16_t m_minor; 49 | uint32_t m_variant; 50 | uint32_t* m_nameLengths; 51 | uint32_t* m_namePtrs; 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /ncpd/socketchan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #ifndef _socketchan_h_ 22 | #define _socketchan_h_ 23 | 24 | #include "config.h" 25 | #include "channel.h" 26 | class ppsocket; 27 | 28 | class socketChan : public channel { 29 | public: 30 | socketChan(ppsocket* comms, ncp* ncpController); 31 | virtual ~socketChan(); 32 | 33 | void ncpDataCallback(bufferStore& a); 34 | const char* getNcpRegisterName(); 35 | void ncpConnectAck(); 36 | void ncpRegisterAck(); 37 | void ncpDoRegisterAck(int) {} 38 | void ncpConnectTerminate(); 39 | void ncpConnectNak(); 40 | 41 | bool isConnected() const; 42 | void socketPoll(); 43 | private: 44 | enum protocolVersionType { PV_SERIES_5 = 6, PV_SERIES_3 = 3 }; 45 | bool ncpCommand(bufferStore &a); 46 | ppsocket* skt; 47 | char* registerName; 48 | bool connected; 49 | int connectTry; 50 | int tryStamp; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /sisinstall/fakepsion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #ifndef _FAKEPSION_H 21 | #define _FAKEPSION_H 22 | 23 | #include "psion.h" 24 | 25 | /** 26 | * A dummy version of the Psion proxy, mainly for testing the installer. 27 | */ 28 | class FakePsion : public Psion 29 | { 30 | public: 31 | 32 | virtual ~FakePsion(); 33 | 34 | virtual bool connect(); 35 | 36 | virtual Enum copyToPsion(const char * const from, 37 | const char * const to, 38 | void *, cpCallback_t func); 39 | 40 | virtual Enum devinfo(const char drive, PlpDrive& plpDrive); 41 | 42 | virtual Enum devlist(uint32_t& devbits); 43 | 44 | virtual Enum dir(const char* dir, PlpDir& files); 45 | 46 | virtual bool dirExists(const char* name); 47 | 48 | virtual void disconnect(); 49 | 50 | virtual Enum mkdir(const char* dir); 51 | 52 | virtual void remove(const char* name); 53 | 54 | }; 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /doc/plpftp.man.in: -------------------------------------------------------------------------------- 1 | .\" Manual page for plpftp 2 | .\" 3 | .\" Process this file with 4 | .\" groff -man -Tascii plpftp.1 for ASCII output, or 5 | .\" groff -man -Tps plpftp.1 for Postscript output 6 | .\" 7 | .TH plpftp 1 "@MANDATE@" "plptools @VERSION@" "User commands" 8 | .SH NAME 9 | plpftp \- FTP-like program for manipulating files on the Psion. 10 | .SH SYNOPSIS 11 | .B plpftp 12 | .B [-h] 13 | .B [-V] 14 | .BI "[-p [" host :] port ] 15 | .BI [ long-options ] 16 | .BI "[ " FTP-command " [" parameters ]] 17 | 18 | .SH DESCRIPTION 19 | 20 | plpftp provides an FTP style interface for the psion. It requires the ncpd to 21 | be running already to provide access to the serial port. 22 | 23 | plpftp has online help. To see the available commands start the program and 24 | enter "help". 25 | 26 | .SH OPTIONS 27 | 28 | .TP 29 | .B \-V, --version 30 | Display the version and exit 31 | .TP 32 | .B \-h, --help 33 | Display a short help text and exit. 34 | .TP 35 | .BI "\-p, --port=[" host :] port 36 | Specify the host and port to connect to (e.g. The port where ncpd is 37 | listening on) - by default the host is 127.0.0.1 and the port is looked up 38 | in /etc/services. If it is not found there, a builtin value of @DPORT@ is used. 39 | .TP 40 | .I FTP-command parameters 41 | Allows you to specify an plpftp command on the command line. If specified, 42 | plpftp enters non interactive mode and terminates after executing the 43 | command. 44 | 45 | .SH SEE ALSO 46 | ncpd(8), plpfuse(8), plpprintd(8), sisinstall(1) 47 | 48 | .SH AUTHOR 49 | Fritz Elfert 50 | .br 51 | Heavily based on p3nfsd by Rudolf Koenig (rfkoenig@immd4.informatik.uni-erlangen.de) 52 | and 53 | plp_1_7 by Philip Proudman (phil@proudman51.freeserve.co.uk) 54 | .br 55 | Man page by John Lines (john+plpman@paladin.demon.co.uk) 56 | -------------------------------------------------------------------------------- /lib/sistypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | */ 19 | 20 | #ifndef _SISTYPES_H 21 | #define _SISTYPES_H 22 | 23 | #include 24 | #include 25 | 26 | /** 27 | * Return Codes. 28 | */ 29 | enum SisRC { 30 | SIS_OK = 0, 31 | SIS_TRUNCATED, 32 | SIS_TRUNCATEDDATA, 33 | SIS_CORRUPTED, 34 | SIS_FAILED, 35 | SIS_ABORTED, 36 | SIS_DIFFERENT_APP, 37 | SIS_VER_EARLIER, 38 | SIS_SAME_OR_LATER, 39 | SIS_OTHER_VARIANT 40 | }; 41 | 42 | extern uint16_t read16(uint8_t* p); 43 | 44 | extern uint32_t read32(uint8_t* p); 45 | 46 | extern void write16(uint8_t* p, int val); 47 | 48 | extern void createCRCTable(); 49 | 50 | extern uint16_t updateCrc(uint16_t crc, uint8_t value); 51 | 52 | extern int logLevel; 53 | 54 | /** 55 | * Holder of a language entry, translating from language numbers to 56 | * names. 57 | */ 58 | struct LangTableEntry 59 | { 60 | uint16_t m_no; 61 | char m_code[3]; 62 | const char* m_name; 63 | }; 64 | 65 | extern LangTableEntry langTable[]; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /lib/Makefile.am: -------------------------------------------------------------------------------- 1 | # lib/Makefile.am 2 | # 3 | # This file is part of plptools. 4 | # 5 | # Copyright (C) 1999-2002 Fritz Elfert 6 | # Copyright (C) 2007-2024 Reuben Thomas 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # along with this program; if not, see . 20 | 21 | AM_CPPFLAGS = -I$(top_srcdir)/libgnu -I$(top_builddir)/libgnu 22 | AM_CXXFLAGS = $(THREADED_CXXFLAGS) $(WARN_CXXFLAGS) 23 | LDADD = $(HOSTENT_LIB) $(LIBSOCKET) 24 | 25 | pkglib_LTLIBRARIES = libplp.la 26 | 27 | libplp_la_SOURCES = bufferarray.cc bufferstore.cc iowatch.cc ppsocket.cc \ 28 | rfsv16.cc rfsv32.cc rfsvfactory.cc log.cc rfsv.cc rpcs32.cc rpcs16.cc \ 29 | rpcs.cc rpcsfactory.cc psitime.cc Enum.cc plpdirent.cc wprt.cc \ 30 | rclip.cc siscomponentrecord.cpp sisfile.cpp sisfileheader.cpp \ 31 | sisfilerecord.cpp sislangrecord.cpp sisreqrecord.cpp sistypes.cpp \ 32 | psibitmap.cpp psiprocess.cc 33 | noinst_HEADERS = bufferarray.h bufferstore.h iowatch.h ppsocket.h \ 34 | rfsv.h rfsv16.h rfsv32.h rfsvfactory.h log.h rpcs32.h rpcs16.h rpcs.h \ 35 | rpcsfactory.h psitime.h Enum.h plpdirent.h wprt.h plpintl.h rclip.h \ 36 | siscomponentrecord.h sisfile.h sisfileheader.h sisfilerecord.h \ 37 | sislangrecord.h sisreqrecord.h sistypes.h psibitmap.h psiprocess.h 38 | -------------------------------------------------------------------------------- /plpfuse/plpfuse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2007-2024 Reuben Thomas 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #ifndef _plpfuse_h_ 21 | #define _plpfuse_h_ 22 | 23 | #include 24 | 25 | typedef struct p_inode { 26 | int inode; 27 | char *name; 28 | struct p_inode *nextnam, *nextnum; 29 | } p_inode; 30 | 31 | /** 32 | * Description of a Psion-Device 33 | */ 34 | typedef struct p_device { 35 | char *name; /* Volume-Name */ 36 | char letter; /* Drive-Letter */ 37 | long attrib; /* Device-Attribs */ 38 | long total; /* Total capacity in bytes */ 39 | long free; /* Free space in bytes */ 40 | struct p_device *next; 41 | } device; 42 | 43 | /* 44 | * Description of a Psion-File/Dir 45 | */ 46 | typedef struct p_dentry 47 | { 48 | char *name; 49 | long time; 50 | long attr; 51 | long size; 52 | long links; 53 | struct p_dentry *next; 54 | } dentry; 55 | 56 | extern int debug; 57 | 58 | extern void debuglog(const char *fmt, ...); 59 | 60 | #define BLOCKSIZE 512 61 | #define FID 7 /* File system id */ 62 | 63 | #endif 64 | 65 | extern struct fuse_operations plp_oper; 66 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # Top level Makefile.am. 2 | # 3 | # This file is part of plptools. 4 | # 5 | # Copyright (C) 1999-2002 Fritz Elfert 6 | # Copyright (C) 2007-2025 Reuben Thomas 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # along with this program; if not, see . 20 | 21 | ACLOCAL_AMFLAGS = -I m4 22 | 23 | SUBDIRS = po libgnu lib ncpd plpftp plpprint sisinstall doc 24 | if BUILD_PLPFUSE 25 | SUBDIRS += plpfuse 26 | endif 27 | 28 | EXTRA_DIST = AUTHORS COPYING INSTALL NEWS README TODO HISTORY ABOUT-NLS \ 29 | etc/plptools.in \ 30 | etc/ttytap.c etc/psidump etc/psidump.1 \ 31 | etc/udev-usbserial-plptools.rules \ 32 | m4/gnulib-cache.m4 33 | 34 | DISTCLEANFILES = etc/plptools 35 | 36 | uninstall-local: 37 | rm -f $(DESTDIR)$(initdir)/plptools 38 | 39 | install-exec-local: 40 | $(INSTALL) -d $(DESTDIR)$(initdir) 41 | $(INSTALL) $(top_builddir)/etc/plptools $(DESTDIR)$(initdir)/plptools 42 | 43 | # FIXME: Automatically revert .po files if they're actually clean 44 | # Currently, rather than run `git diff --exit-code', we simply show the 45 | # diff, and eyeball it to check there's nothing other than the datestamps on 46 | # the .po files. 47 | release: distcheck 48 | git diff && \ 49 | gh release create v$(VERSION) --title "Release v$(VERSION)" $(DIST_ARCHIVES) 50 | -------------------------------------------------------------------------------- /plpftp/ftp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * Copyright (C) 2025 Reuben Thomas 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * along with this program; if not, see . 20 | * 21 | */ 22 | #ifndef _ftp_h_ 23 | #define _ftp_h_ 24 | 25 | #include "config.h" 26 | 27 | #include 28 | 29 | #include "rfsv.h" 30 | #include "Enum.h" 31 | 32 | class rpcs; 33 | class bufferStore; 34 | class bufferArray; 35 | 36 | class ftp { 37 | public: 38 | ftp(); 39 | ~ftp(); 40 | int session(rfsv & a, rpcs & r, rclip & rc, ppsocket & rclipSocket, std::vector argv); 41 | bool canClip; 42 | 43 | private: 44 | std::vector getCommand(); 45 | void initReadline(void); 46 | int putClipText(rpcs & r, rfsv & a, rclip & rc, ppsocket & rclipSocket, const char *data); 47 | int getClipData(rpcs & r, rfsv & a, rclip & rc, ppsocket & rclipSocket, const char *file); 48 | bool checkClipConnection(rfsv &a, rclip & rc, ppsocket & rclipSocket); 49 | 50 | // utilities 51 | void resetUnixWd(); 52 | void usage(); 53 | 54 | char defDrive[9]; 55 | char *localDir; 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /HISTORY: -------------------------------------------------------------------------------- 1 | Fritz Elfert wrote plptools, heavily based on two other packages: 2 | 3 | - p3nfsd-5.4 by Rudolf Koenig (rfkoenig@immd4.informatik.uni-erlangen.de) 4 | an nfs daemon for Psion series 3 and 5 5 | - plp_1_7 by Philip Proudman (phil@proudman51.freeserve.co.uk) 6 | 7 | He writes: 8 | 9 | I want to thank both authors for their nice packages and for making 10 | these available under GPL which makes it possible for me to create 11 | this package (which of course is distributed under GPL as well). 12 | 13 | I modified and improved Philip's code to support more (nearly all?) 14 | rfsv32 commands and to gain speed (approx. 4 times) and stability 15 | (properly reconnects on lost serial link). 16 | 17 | Rudolf's code originally used a homegrown protocol which needs a 18 | separate program running on the Psion. I changed his code to use the 19 | socket-based client-code from Philip's rfsv program thus eliminating 20 | the need for any software beeing run on the Psion. The rfsv code and 21 | some other stuff went into a lib (both shared and static available). 22 | I also removed all Psion 3 related stuff, because a) I can't test it 23 | and b) Psion no longer supported SIBO. 24 | 25 | Support for the RPC mechanism was added in version 0.5. This support 26 | was only possible because of Alexander Thoukydides' excellent 27 | documentation: https://thoukydides.github.io/riscos-psifs/plp.html 28 | Thanks a lot for that. 29 | 30 | Psion 3 support was added by Matt Gumbley (matt@gumbley.demon.co.uk). 31 | 32 | Have fun. -Fritz 33 | 34 | Reuben Thomas has maintained plptools since version 0.13. He fixed 35 | many bugs, updated the KDE utilities to work with KDE 3, but finally 36 | removed them with the approach of KDE 4, enhanced plpftp and replaced 37 | the rather flaky plpnfsd with plpfuse. He has kept the build system 38 | working with newer versions of GNU autotools, and gradually cleaned up 39 | the code and simplified the build system. 40 | -------------------------------------------------------------------------------- /sisinstall/psion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | 21 | #ifndef _PSION_H 22 | #define _PSION_H 23 | 24 | #include 25 | #include "rfsv.h" 26 | 27 | class ppsocket; 28 | class rfsvfactory; 29 | class rpcsfactory; 30 | class rpcs; 31 | 32 | /** 33 | * Semi smart proxy for communicating with a Psion. 34 | */ 35 | class Psion 36 | { 37 | public: 38 | 39 | virtual ~Psion(); 40 | 41 | virtual bool connect(); 42 | 43 | virtual Enum copyFromPsion(const char * const from, int fd, 44 | cpCallback_t func); 45 | 46 | virtual Enum copyToPsion(const char * const from, 47 | const char * const to, 48 | void *, cpCallback_t func); 49 | 50 | virtual Enum devinfo(const char drive, PlpDrive& plpDrive); 51 | 52 | virtual Enum devlist(uint32_t& devbits); 53 | 54 | virtual Enum dir(const char* dir, PlpDir& files); 55 | 56 | virtual bool dirExists(const char* name); 57 | 58 | virtual void disconnect(); 59 | 60 | virtual Enum mkdir(const char* dir); 61 | 62 | virtual void remove(const char* name); 63 | 64 | private: 65 | 66 | ppsocket* m_skt; 67 | ppsocket* m_skt2; 68 | rfsvfactory* m_rfsvFactory; 69 | rpcsfactory* m_rpcsFactory; 70 | rpcs* m_rpcs; 71 | rfsv* m_rfsv; 72 | 73 | }; 74 | 75 | #endif 76 | 77 | -------------------------------------------------------------------------------- /sisinstall/fakepsion.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #include "config.h" 21 | 22 | #include "fakepsion.h" 23 | #include "sistypes.h" 24 | 25 | #include 26 | 27 | FakePsion::~FakePsion() 28 | { 29 | } 30 | 31 | bool 32 | FakePsion::connect() 33 | { 34 | return true; 35 | } 36 | 37 | Enum 38 | FakePsion::copyToPsion(const char * const from, const char * const to, 39 | void *, cpCallback_t func) 40 | { 41 | if (logLevel >= 1) 42 | printf(" -- Not really copying %s to %s\n", from, to); 43 | return rfsv::E_PSI_GEN_NONE; 44 | } 45 | 46 | Enum 47 | FakePsion::devinfo(const char drive, PlpDrive& plpDrive) 48 | { 49 | return rfsv::E_PSI_GEN_NONE; 50 | } 51 | 52 | Enum 53 | FakePsion::devlist(uint32_t& devbits) 54 | { 55 | return rfsv::E_PSI_GEN_FAIL; 56 | } 57 | 58 | Enum 59 | FakePsion::dir(const char* dir, PlpDir& files) 60 | { 61 | return rfsv::E_PSI_GEN_NONE; 62 | } 63 | 64 | bool 65 | FakePsion::dirExists(const char* name) 66 | { 67 | return true; 68 | } 69 | 70 | void 71 | FakePsion::disconnect() 72 | { 73 | } 74 | 75 | Enum 76 | FakePsion::mkdir(const char* dir) 77 | { 78 | if (logLevel >= 1) 79 | printf(" -- Not really creating dir %s\n", dir); 80 | return rfsv::E_PSI_GEN_NONE; 81 | } 82 | 83 | void 84 | FakePsion::remove(const char* name) 85 | { 86 | } 87 | 88 | -------------------------------------------------------------------------------- /lib/iowatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #ifndef _IOWATCH_H_ 22 | #define _IOWATCH_H_ 23 | 24 | /** 25 | * A simple wrapper for select() 26 | * 27 | * IOWatch is a simple wrapper for the select 28 | * system call. In particular, it takes care 29 | * of passing the maximum file descriptor 30 | * argument (arg 1) of select() correctly. 31 | * IOWatch handles select on read descriptors only. 32 | */ 33 | class IOWatch { 34 | public: 35 | /** 36 | * Creates a new instance. 37 | */ 38 | IOWatch(); 39 | 40 | /** 41 | * Destroys an instance. 42 | */ 43 | ~IOWatch(); 44 | 45 | /** 46 | * Adds a file descriptor to 47 | * the set of descriptors. 48 | * 49 | * @param fd The file descriptor to add. 50 | */ 51 | void addIO(const int fd); 52 | 53 | /** 54 | * Removes a file descriptor from the 55 | * set of descriptors. 56 | * 57 | * @param fd The file descriptor to remove. 58 | */ 59 | void remIO(const int fd); 60 | 61 | /** 62 | * Performs a select() call. 63 | * 64 | * @param secs Number of seconds to wait. 65 | * @param usecs Number of microseconds to wait. 66 | * 67 | * @return true, if any of the descriptors is 68 | * readable. 69 | */ 70 | bool watch(const long secs, const long usecs); 71 | 72 | private: 73 | int num; 74 | int *io; 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /lib/iowatch.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 2000, 2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #include "config.h" 22 | 23 | #include "iowatch.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | IOWatch::IOWatch() { 32 | num = 0; 33 | io = new int [FD_SETSIZE]; 34 | memset(io, -1, FD_SETSIZE); 35 | } 36 | 37 | IOWatch::~IOWatch() { 38 | delete [] io; 39 | } 40 | 41 | void IOWatch::addIO(const int fd) { 42 | int pos; 43 | for (pos = 0; pos < num && fd < io[pos]; pos++); 44 | if (io[pos] == fd) 45 | return; 46 | for (int i = num; i > pos; i--) 47 | io[i] = io[i-1]; 48 | io[pos] = fd; 49 | num++; 50 | } 51 | 52 | void IOWatch::remIO(const int fd) { 53 | int pos; 54 | for (pos = 0; pos < num && fd != io[pos]; pos++); 55 | if (pos != num) { 56 | num--; 57 | for (int i = pos; i 0) { 63 | int maxfd = 0; 64 | fd_set iop; 65 | FD_ZERO(&iop); 66 | for (int i = 0; i < num; i++) { 67 | FD_SET(io[i], &iop); 68 | if (io[i] > maxfd) 69 | maxfd = io[i]; 70 | } 71 | struct timeval t; 72 | t.tv_usec = usecs; 73 | t.tv_sec = secs; 74 | return (select(maxfd+1, &iop, NULL, NULL, &t) > 0); 75 | } 76 | sleep(secs); 77 | usleep(usecs); 78 | return false; 79 | } 80 | -------------------------------------------------------------------------------- /lib/rpcs32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2002 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #ifndef _RPCS32_H_ 22 | #define _RPCS32_H_ 23 | 24 | #include "rpcs.h" 25 | 26 | class ppsocket; 27 | class rpcsfactory; 28 | 29 | /** 30 | * This is the implementation of the @ref rpcs protocol for 31 | * Psion series 5 (EPOC) variant. You normally never create 32 | * objects of this class directly. Thus the constructor is 33 | * private. Use @ref rpcsfactory for creating an instance of 34 | * @ref rpcs . For a complete documentation, see @ref rpcs . 35 | */ 36 | class rpcs32 : public rpcs { 37 | friend class rpcsfactory; 38 | 39 | public: 40 | Enum getCmdLine(const char *, std::string &); 41 | Enum getMachineInfo(machineInfo &); 42 | Enum configRead(uint32_t, bufferStore &); 43 | Enum configWrite(bufferStore); 44 | Enum closeHandle(uint16_t); 45 | Enum regOpenIter(uint32_t uid, char *match, uint16_t &handle); 46 | Enum regReadIter(uint16_t handle); 47 | Enum setTime(time_t time); 48 | #if 0 49 | Enum regWrite(void); 50 | Enum regRead(void); 51 | Enum regDelete(void); 52 | Enum queryOpen(void); 53 | Enum queryRead(void); 54 | Enum quitServer(void); 55 | #endif 56 | 57 | protected: 58 | Enum configOpen(uint16_t &, uint32_t); 59 | 60 | private: 61 | rpcs32(ppsocket *); 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /lib/Enum.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2000 Henner Zeller 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #include "config.h" 21 | 22 | #include 23 | 24 | #include "Enum.h" 25 | 26 | using namespace std; 27 | 28 | void EnumBase::i2sMapper::add(long i, const char* s) { 29 | stringMap.insert(pair(i, s)); 30 | } 31 | 32 | string EnumBase::i2sMapper::lookup (long i) const { 33 | i2s_map_t::const_iterator searchPtr = stringMap.find(i); 34 | 35 | if (searchPtr == stringMap.end()) 36 | return "[OUT-OF-RANGE]"; 37 | /* 38 | * now combine the probably the multiple strings belonging to this 39 | * integer 40 | */ 41 | string result; 42 | for (i = stringMap.count(i); i > 0 ; --i, ++searchPtr) { 43 | // this should be the case: 44 | assert(searchPtr != stringMap.end()); 45 | if (result.length() != 0) 46 | result += string(","); 47 | result += string(searchPtr->second); 48 | } 49 | return result; 50 | } 51 | 52 | 53 | long EnumBase::i2sMapper::lookup (const char *s) const { 54 | /* 55 | * look up a specific string. 56 | * Since speed does not matter, we just do an exhaustive 57 | * search. 58 | * Otherwise we would have to maintain another map 59 | * mapping strings to ints .. but it's not worth the memory 60 | */ 61 | i2s_map_t::const_iterator run = stringMap.begin(); 62 | while (run != stringMap.end() && strcmp(s, run->second)) { 63 | ++run; 64 | } 65 | if (run == stringMap.end()) 66 | return -1; 67 | return run->first; 68 | } 69 | 70 | bool EnumBase::i2sMapper::inRange (long i) const { 71 | return (stringMap.find(i) != stringMap.end()); 72 | } 73 | -------------------------------------------------------------------------------- /lib/rpcsfactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #ifndef _RPCSFACTORY_H_ 22 | #define _RPCSFACTORY_H_ 23 | 24 | #include "rpcs.h" 25 | 26 | class ppsocket; 27 | 28 | /** 29 | * A factory for automatically instantiating the correct protocol 30 | * variant depending on the connected Psion. 31 | */ 32 | class rpcsfactory { 33 | public: 34 | 35 | /** 36 | * The known errors which can happen during @ref create . 37 | */ 38 | enum errs { 39 | FACERR_NONE = 0, 40 | FACERR_COULD_NOT_SEND = 1, 41 | FACERR_AGAIN = 2, 42 | FACERR_NOPSION = 3, 43 | FACERR_PROTVERSION = 4, 44 | FACERR_NORESPONSE = 5 45 | }; 46 | 47 | /** 48 | * Constructs a rpcsfactory. 49 | * 50 | * @param skt The socket to be used for connecting 51 | * to the ncpd daemon. 52 | */ 53 | rpcsfactory(ppsocket * skt); 54 | 55 | /** 56 | * Creates a new rpcs instance. 57 | * 58 | * @param reconnect Set to true, if automatic reconnect 59 | * should be performed on failure. 60 | * 61 | * @returns A pointer to a newly created rpcs instance or 62 | * NULL on failure. 63 | */ 64 | virtual rpcs * create(bool reconnect); 65 | 66 | /** 67 | * Retrieve an error code. 68 | * 69 | * @returns The error code, in case @ref create has 70 | * failed, 0 otherwise. 71 | */ 72 | virtual Enum getError() { return err; } 73 | 74 | private: 75 | /** 76 | * The socket to be used for connecting to the 77 | * ncpd daemon. 78 | */ 79 | ppsocket *skt; 80 | Enum err; 81 | }; 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /lib/siscomponentrecord.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | */ 19 | 20 | #ifndef _SISCOMPONENTRECORD_H 21 | #define _SISCOMPONENTRECORD_H 22 | 23 | #include "sistypes.h" 24 | 25 | class SISFile; 26 | 27 | /** 28 | * The name of the component in this SIS file. 29 | * A single instance holds the names for all languages. 30 | * 31 | * There is one name record for each language. 32 | * First comes the lengths of all the names, as 32 bit integers. 33 | * Second comes pointers to the names, as an index in the complete 34 | * SISFile. 35 | */ 36 | class SISComponentNameRecord 37 | { 38 | public: 39 | 40 | SISComponentNameRecord(); 41 | virtual ~SISComponentNameRecord(); 42 | 43 | /** 44 | * Populate the fields. 45 | * 46 | * @param buf The buffer to read data from. 47 | * @param base The index where we start reading data. 48 | * @param len The length of the buffer, for range checking. 49 | * @param sisFile The container sis file. 50 | */ 51 | SisRC fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile); 52 | 53 | /** 54 | * Find out the end position for the last name in the file. 55 | */ 56 | uint32_t getLastEnd(); 57 | 58 | /** 59 | * Return the name for the given language. 60 | * 61 | * @param no The sequence number in the list of language records in 62 | * the sis file. 63 | */ 64 | uint8_t* getName(int no); 65 | 66 | private: 67 | 68 | uint32_t* m_nameLengths; 69 | uint32_t* m_namePtrs; 70 | 71 | /** 72 | * The extracted names, as zero terminated strings. 73 | */ 74 | uint8_t** m_names; 75 | 76 | /** 77 | * The number of names, so we know how much to delete. 78 | */ 79 | int m_nameCount; 80 | 81 | }; 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /lib/rfsvfactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999 Matt J. Gumbley 6 | * Copyright (C) 1999-2001 Fritz Elfert 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * along with this program; if not, see . 20 | * 21 | */ 22 | #ifndef _RFSVFACTORY_H_ 23 | #define _RFSVFACTORY_H_ 24 | 25 | #include "rfsv.h" 26 | 27 | class ppsocket; 28 | 29 | /** 30 | * A factory for automatically instantiating the correct 31 | * @ref rfsv protocol variant depending on the connected Psion. 32 | */ 33 | class rfsvfactory { 34 | 35 | public: 36 | /** 37 | * The known errors which can happen during @ref create . 38 | */ 39 | enum errs { 40 | FACERR_NONE = 0, 41 | FACERR_COULD_NOT_SEND = 1, 42 | FACERR_AGAIN = 2, 43 | FACERR_NOPSION = 3, 44 | FACERR_PROTVERSION = 4, 45 | FACERR_NORESPONSE = 5 46 | }; 47 | 48 | /** 49 | * Constructs a rfsvfactory. 50 | * 51 | * @param skt The socket to be used for connecting 52 | * to the ncpd daemon. 53 | */ 54 | rfsvfactory(ppsocket * skt); 55 | 56 | /** 57 | * Creates a new @ref rfsv instance. 58 | * 59 | * @param reconnect Set to true, if automatic reconnect 60 | * should be performed on failure. 61 | * 62 | * @returns A pointer to a newly created rfsv instance or 63 | * NULL on failure. 64 | */ 65 | virtual rfsv * create(bool); 66 | 67 | /** 68 | * Retrieve an error code. 69 | * 70 | * @returns The error code, in case @ref create has 71 | * failed, 0 otherwise. 72 | */ 73 | virtual Enum getError() { return err; } 74 | 75 | private: 76 | /** 77 | * The socket to be used for connecting to the 78 | * ncpd daemon. 79 | */ 80 | ppsocket *skt; 81 | int serNum; 82 | Enum err; 83 | }; 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /doc/plpprintd.man.in: -------------------------------------------------------------------------------- 1 | .\" Manual page for plpprintd 2 | .\" 3 | .\" Process this file with 4 | .\" groff -man -Tascii plpprintd.1 for ASCII output, or 5 | .\" groff -man -Tps plpprintd.1 for Postscript output 6 | .\" 7 | .TH plpprintd 8 "@MANDATE@" "plptools @VERSION@" "System administration commands" 8 | .SH NAME 9 | plpprintd \- Daemon for printing via PC from a Psion. 10 | .SH SYNOPSIS 11 | .B plpprintd 12 | .B [-d] 13 | .B [-h] 14 | .B [-v] 15 | .B [-V] 16 | .BI [-s " spooldir" ] 17 | .BI [-c " print-cmd" ] 18 | .BI "[-p [" host :] port ] 19 | .BI [ long-options ] 20 | 21 | .SH DESCRIPTION 22 | 23 | plpprintd provides a print server for a Psion, connected to the PC. 24 | Using plpprintd, you can use the Psion's "Print via PC" feature to 25 | access any printer, available on your PC. When receiving a print job, 26 | the data is converted to Postscript\*[R] and then send to a printer. 27 | 28 | .SH OPTIONS 29 | 30 | .TP 31 | .B \-d, --debug 32 | Enable additional debug messages and stay in foreground (do not fork). 33 | .TP 34 | .B \-h, --help 35 | Display a short help text and exit. 36 | .TP 37 | .B \-v, --verbose 38 | Increase verbosity 39 | .TP 40 | .B \-V, --version 41 | Display the version and exit 42 | .TP 43 | .BI "\-s, --spooldir=" dir 44 | Specify a directory to use for temporary spool files. If this option is 45 | missing, a builtin default 46 | .I /var/spool/plpprint 47 | is used. 48 | .TP 49 | .BI "\-c, --printcmd=" cmd 50 | Specify a command for actually sending a print job to the printer. The 51 | specified command must receive the data from its standard input. If this 52 | option is missing, a builtin default 53 | .I lpr \-Ppsion 54 | is used. 55 | .TP 56 | .BI "\-p, --port=[" host :] port 57 | Specify the host and port to connect to (e.g. The port where ncpd is 58 | listening on) - by default the host is 127.0.0.1 and the port is looked up 59 | in /etc/services. If it is not found there, a builtin value of @DPORT@ is used. 60 | .TP 61 | 62 | .SH FILES 63 | .TP 64 | @pkgdatadir@/prolog.ps 65 | contains the Postscript(\*R) dictionary, needed for printing the jobs. 66 | .TP 67 | @pkgdatadir@/fontmap 68 | specifies the font mapping to be used. This file is used to convert the 69 | Psion's font names into valid Postscript(\*R) font names. Its format is 70 | described at the beginning of it. If a Psion font name is received which 71 | can not be found in this file, a builtin default Courier is used. 72 | 73 | .SH BUGS 74 | Using patterns in diagrams gives ugly results. 75 | 76 | .SH SEE ALSO 77 | ncpd(8), plpfuse(8), plpftp(1), sisinstall(1) 78 | 79 | .SH AUTHOR 80 | Fritz Elfert 81 | 82 | -------------------------------------------------------------------------------- /lib/sisreqrecord.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | */ 19 | #include "config.h" 20 | 21 | #include "sisreqrecord.h" 22 | #include "sisfile.h" 23 | #include "plpintl.h" 24 | 25 | #include 26 | 27 | SisRC 28 | SISReqRecord::fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile) 29 | { 30 | int n = sisFile->m_header.m_nlangs; 31 | if (*base + 12 + n * 4 * 2 > len) 32 | return SIS_TRUNCATED; 33 | 34 | uint8_t* p = buf + *base; 35 | int size = 0; 36 | 37 | m_uid = read32(p); 38 | m_major = read16(p + 4); 39 | m_minor = read16(p + 6); 40 | m_variant = read32(p + 8); 41 | m_nameLengths = new uint32_t[n]; 42 | m_namePtrs = new uint32_t[n]; 43 | if (logLevel >= 2) 44 | printf(_("Requisite: uid=%08x, version=%d.%d-%d.\n"), 45 | m_uid, m_major, m_minor, m_variant); 46 | 47 | // First read lengths. 48 | // 49 | size = 12; 50 | for (int i = 0; i < n; ++i) 51 | { 52 | m_nameLengths[i] = read32(p + size); 53 | if (logLevel >= 2) 54 | printf(_("Got namelength %d\n"), m_nameLengths[i]); 55 | size += 4; 56 | } 57 | 58 | // Then read ptrs. 59 | // 60 | for (int i = 0; i < n; ++i) 61 | { 62 | m_namePtrs[i] = read32(p + size); 63 | if (logLevel >= 2) 64 | printf(_("Got namepos %d\n"), m_namePtrs[i]); 65 | if (m_namePtrs[i] + m_nameLengths[i] > len) 66 | { 67 | printf(_("Position/length too large for req record %d.\n"), i); 68 | return SIS_CORRUPTED; 69 | } 70 | size += 4; 71 | if (logLevel >= 2) 72 | printf(_("Name of requisite for %s is %.*s\n"), 73 | sisFile->getLanguage(i)->m_name, 74 | m_nameLengths[i], 75 | buf + m_namePtrs[i]); 76 | } 77 | if (logLevel >= 1) 78 | printf(_("%d .. %d (%d bytes): Req record for uid %08x\n"), 79 | *base, *base + size, size, m_uid); 80 | *base += size; 81 | return SIS_OK; 82 | } 83 | -------------------------------------------------------------------------------- /plpfuse/rfsv_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999-2001 Fritz Elfert 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #ifndef _rfsv_api_h_ 21 | #define _rfsv_api_h_ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | #include "plpfuse.h" 28 | 29 | extern int psierr_to_errno(long psierr); 30 | extern int rfsv_dir(const char *name, dentry **e); 31 | extern int rfsv_mkdir(const char *name); 32 | extern int rfsv_rmdir(const char *name); 33 | extern int rfsv_remove(const char *name); 34 | extern int rfsv_rename(const char *oldname, const char *newname); 35 | extern int rfsv_open(const char *name, long mode, uint32_t *handle); 36 | extern int rfsv_fclose(long handle); 37 | extern int rfsv_fcreate(long attr, const char *name, uint32_t *handle); 38 | extern int rfsv_read(char *buf, long offset, long len, const char *name); 39 | extern int rfsv_write(const char *buf, long offset, long len, const char *name); 40 | extern int rfsv_getattr(const char *name, long *attr, long *size, long *time); 41 | extern int rfsv_setattr(const char *name, long sattr, long dattr); 42 | extern int rfsv_setsize(const char *name, long size); 43 | extern int rfsv_setmtime(const char *name, long time); 44 | extern int rfsv_drivelist(int *cnt, device **devlist); 45 | extern int rfsv_dircount(const char *name, long *count); 46 | extern int rfsv_isalive(void); 47 | 48 | /* File attributes, C-style */ 49 | #define PSI_A_RDONLY 0x0001 50 | #define PSI_A_HIDDEN 0x0002 51 | #define PSI_A_SYSTEM 0x0004 52 | #define PSI_A_DIR 0x0008 53 | #define PSI_A_ARCHIVE 0x0010 54 | #define PSI_A_VOLUME 0x0020 55 | #define PSI_A_NORMAL 0x0040 56 | #define PSI_A_TEMP 0x0080 57 | #define PSI_A_COMPRESSED 0x0100 58 | #define PSI_A_READ 0x0200 59 | #define PSI_A_EXEC 0x0400 60 | #define PSI_A_STREAM 0x0800 61 | #define PSI_A_TEXT 0x1000 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /ncpd/channel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #ifndef _channel_h_ 22 | #define _channel_h_ 23 | 24 | #include "config.h" 25 | #include 26 | 27 | class ncp; 28 | class bufferStore; 29 | class PcServer; 30 | class ppsocket; 31 | 32 | class channel { 33 | public: 34 | channel(ncp *ncpController); 35 | virtual ~channel() = 0; 36 | void newNcpController(ncp *ncpController); 37 | 38 | void setNcpChannel(int chan); 39 | int getNcpChannel(void); 40 | void ncpSend(bufferStore &a); 41 | void setVerbose(short int _verbose); 42 | short int getVerbose(); 43 | virtual void ncpDataCallback(bufferStore &a) = 0; 44 | virtual const char *getNcpRegisterName() = 0; 45 | void ncpConnect(); 46 | void ncpRegister(); 47 | void ncpDoRegisterAck(int ch, const char *name); 48 | virtual void ncpConnectAck() = 0; 49 | virtual void ncpConnectTerminate() = 0; 50 | virtual void ncpConnectNak() = 0; 51 | virtual void ncpRegisterAck() = 0; 52 | void ncpDisconnect(); 53 | short int ncpProtocolVersion(); 54 | const char *getNcpConnectName(); 55 | void setNcpConnectName(const char *); 56 | 57 | // The following two calls are used for destructing an instance 58 | bool terminate(); // Mainloop will terminate this class if true 59 | void terminateWhenAsked(); 60 | 61 | PcServer *ncpFindPcServer(const char *name); 62 | void ncpRegisterPcServer(ppsocket *skt, const char *name); 63 | void ncpUnregisterPcServer(PcServer *server); 64 | int ncpGetSpeed(); 65 | 66 | protected: 67 | short int verbose; 68 | const char *connectName; 69 | 70 | private: 71 | ncp *ncpController; 72 | int ncpChannel; 73 | bool _terminate; 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /lib/psiprocess.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999-2002 Fritz Elfert 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #include "config.h" 21 | 22 | #include "psiprocess.h" 23 | 24 | #include 25 | #include 26 | 27 | using namespace std; 28 | 29 | PsiProcess::PsiProcess() 30 | : pid(0), name(""), args(""), s5mx(false) { 31 | } 32 | 33 | PsiProcess::PsiProcess(const PsiProcess &p) { 34 | pid = p.pid; 35 | name = p.name; 36 | args = p.args; 37 | s5mx = p.s5mx; 38 | } 39 | 40 | PsiProcess::PsiProcess(int _pid, const char * const _name, 41 | const char * const _args, bool _s5mx) { 42 | pid = _pid; 43 | name = _name; 44 | args = _args; 45 | s5mx = _s5mx; 46 | } 47 | 48 | int PsiProcess:: 49 | getPID() { 50 | return pid; 51 | } 52 | 53 | const char *PsiProcess:: 54 | getName() { 55 | return name.c_str(); 56 | } 57 | 58 | const char *PsiProcess:: 59 | getArgs() { 60 | return args.c_str(); 61 | } 62 | 63 | const char *PsiProcess:: 64 | getProcId() { 65 | ostringstream tmp; 66 | 67 | if (s5mx) 68 | tmp << name << ".$" << setw(2) << setfill('0') << pid << '\0'; 69 | else 70 | tmp << name << ".$" << pid << '\0'; 71 | return tmp.str().c_str(); 72 | } 73 | 74 | void PsiProcess:: 75 | setArgs(string _args) { 76 | args = _args; 77 | } 78 | 79 | PsiProcess &PsiProcess:: 80 | operator=(const PsiProcess &p) { 81 | pid = p.pid; 82 | name = p.name; 83 | args = p.args; 84 | s5mx = p.s5mx; 85 | return *this; 86 | } 87 | 88 | ostream & 89 | operator<<(ostream &o, const PsiProcess &p) { 90 | ostream::fmtflags old = o.flags(); 91 | 92 | o << dec << setw(5) << setfill(' ') << p.pid << " " << setw(12) 93 | << setfill(' ') << setiosflags(ios::left) << p.name.c_str() 94 | << resetiosflags(ios::left) << " " << p.args; 95 | o.flags(old); 96 | return o; 97 | } 98 | -------------------------------------------------------------------------------- /lib/psibitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999-2001 Fritz Elfert 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | 21 | #ifndef _PSIBITMAP_H_ 22 | #define _PSIBITMAP_H_ 23 | 24 | #include "bufferstore.h" 25 | 26 | /** 27 | * This function is used by encodeBitmap for retrieving image data. 28 | * It must return a gray value between 0 and 255 where 0 is black and 29 | * 255 is white. 30 | * 31 | * @param x The x coordinate of the pixel to get (0 = left) 32 | * @param y The y coordinate of the pixel to get (0 = top) 33 | */ 34 | typedef int (*getPixelFunction_t)(int x, int y); 35 | 36 | /** 37 | * Convert an image into a bitmap in Psion format. 38 | * 39 | * @param width The width of the image to convert. 40 | * @param height The height of the image to convert. 41 | * @param getPixel Pointer to a function for retrieving pixel values. 42 | * @param rle Flag: Perform RLE compression (currently ignored). 43 | * @param out Output buffer; gets filled with the Psion representation 44 | * of the converted image. 45 | */ 46 | extern void 47 | encodeBitmap(int width, int height, getPixelFunction_t getPixel, 48 | bool rle, bufferStore &out); 49 | 50 | /** 51 | * Convert a Psion bitmap to a 8bit/pixel grayscale image. 52 | * 53 | * @param p Pointer to an input buffer which contains the Psion-formatted 54 | * bitmap to convert. Must start with a Psion bitmap header. 55 | * @param width On return, the image width in pixels is returned here. 56 | * @param height On return, the image height in pixels is returned here. 57 | * @param out Buffer which gets filled with the raw image data. Each pixel 58 | * is represented by a byte. The image data is organized in 59 | * height scanlines of width bytes, starting with the topmost 60 | * scanline. 61 | * 62 | * @returns true on success, false if input data is inconsistent. 63 | */ 64 | extern bool 65 | decodeBitmap(const unsigned char *p, int &width, int &height, bufferStore &out); 66 | 67 | #endif // !_PSIBITMAP_H_ 68 | -------------------------------------------------------------------------------- /sisinstall/sisinstaller.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | 21 | #ifndef _SISINSTALLER_H 22 | #define _SISINSTALLER_H 23 | 24 | #include "sistypes.h" 25 | 26 | #include 27 | 28 | class Psion; 29 | class SISFile; 30 | class SISFileLink; 31 | class SISFileRecord; 32 | 33 | /** 34 | * A minimal SIS installer. 35 | * Handles recursive sis files. 36 | */ 37 | class SISInstaller 38 | { 39 | public: 40 | 41 | SISInstaller(); 42 | 43 | virtual ~SISInstaller(); 44 | 45 | SisRC run(SISFile* file, uint8_t* buf, off_t len); 46 | 47 | SisRC run(SISFile* file, uint8_t* buf, off_t len, SISFile* parent); 48 | 49 | /** 50 | * Ask the user which drive to install to. 51 | */ 52 | void selectDrive(); 53 | 54 | /** 55 | * Set the base pointer to the list of already installed 56 | * applications, so we don't have to scan it for every sis 57 | * component. 58 | */ 59 | void setInstalled(SISFileLink* installed) 60 | { 61 | m_installed = installed; 62 | } 63 | 64 | /** 65 | * Set the Psion manager. 66 | */ 67 | void setPsion(Psion* psion); 68 | 69 | private: 70 | 71 | char m_drive; 72 | 73 | int m_fileNo; 74 | 75 | Psion* m_psion; 76 | 77 | uint8_t* m_buf; 78 | 79 | SISFile* m_file; 80 | 81 | SISFileLink* m_installed; 82 | 83 | int m_lastSisFile; 84 | 85 | bool m_ownInstalled; 86 | 87 | enum { 88 | FILE_OK, 89 | FILE_SKIP, 90 | FILE_ABORT, 91 | }; 92 | 93 | /** 94 | * Store the contents of a buffer in a file on the Psion. 95 | */ 96 | void copyBuf(const uint8_t* buf, int len, char* name); 97 | 98 | /** 99 | * Copy a file to the Psion. 100 | */ 101 | void copyFile(SISFileRecord* fileRecord); 102 | 103 | void createDirs(char* filename); 104 | 105 | int installFile(SISFileRecord* fileRecord); 106 | 107 | SisRC loadInstalled(); 108 | 109 | void loadPsionSis(const char* name); 110 | 111 | void removeFile(SISFileRecord* fileRecord); 112 | 113 | void uninstall(SISFile* sisFile); 114 | 115 | void uninstallFile(SISFileRecord* fileRecord); 116 | 117 | }; 118 | 119 | #endif 120 | 121 | -------------------------------------------------------------------------------- /lib/sisfileheader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | */ 19 | 20 | #ifndef _SISFILEHEADER_H 21 | #define _SISFILEHEADER_H 22 | 23 | #include "sistypes.h" 24 | 25 | /** 26 | * The first part of a SISFile. 27 | * 28 | * This file header is referenced from most other parts of the sis file, 29 | * mainly since it contains the list of languages. 30 | */ 31 | class SISFileHeader 32 | { 33 | public: 34 | 35 | /** 36 | * Compare uid and version number of this file, with another. 37 | */ 38 | SisRC compareApp(SISFileHeader* other); 39 | 40 | /** 41 | * Populate the fields. 42 | * 43 | * @param buf The buffer to read from. 44 | * @param base The index to start reading from, which is updated 45 | * when the header is successfully read. 46 | * @param len The length of the buffer. 47 | */ 48 | SisRC fillFrom(uint8_t* buf, int* base, off_t len); 49 | 50 | /** 51 | * Update the drive letter, and patch the parsed buffer. 52 | */ 53 | void setDrive(char drive); 54 | 55 | /** 56 | * Update the number of installed files, and patch the parsed buffer. 57 | */ 58 | void setFiles(int nFiles); 59 | 60 | enum FileOptions { 61 | op_isUnicode = 1, 62 | op_isDistributable = 2 63 | #ifdef EPOC6 64 | , 65 | op_noCompress = 8, 66 | op_shutdownApps = 16 67 | #endif 68 | }; 69 | 70 | enum FileType { 71 | FT_App = 0 72 | #ifdef EPOC6 73 | , 74 | FT_System = 1, 75 | FT_Option = 2, 76 | FT_Config = 3, 77 | FT_Patch = 4, 78 | FT_Upgrade = 5 79 | #endif 80 | }; 81 | 82 | uint32_t m_uid1; 83 | uint32_t m_uid2; 84 | uint32_t m_uid3; 85 | uint32_t m_uid4; 86 | uint16_t m_crc; 87 | uint16_t m_nlangs; 88 | uint16_t m_nfiles; 89 | uint16_t m_nreqs; 90 | uint16_t m_installationLanguage; 91 | uint16_t m_installationFiles; 92 | uint32_t m_installationDrive; 93 | uint32_t m_installerVersion; 94 | uint16_t m_options; 95 | uint16_t m_type; 96 | uint16_t m_major; 97 | uint16_t m_minor; 98 | uint32_t m_variant; 99 | uint32_t m_languagePtr; 100 | uint32_t m_filesPtr; 101 | uint32_t m_reqPtr; 102 | uint32_t m_unknown; 103 | uint32_t m_componentPtr; 104 | 105 | private: 106 | 107 | uint8_t* m_buf; 108 | 109 | }; 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | Changes since Version 0.9 2 | 3 | See release notes for each version, and git history. 4 | 5 | Changes from Version 0.7 to 0.8 6 | 7 | - Fixed lot of bugs, especially in nfs code 8 | - Series 3 _should_ work again. 9 | - Added support for KDE (KDE >= 2.1) 10 | - Added KDE Application "kpsion" 11 | 12 | Changes from Version 0.6 to 0.7 13 | 14 | - Changed timezone-stuff again. With S5, now the machine-info is 15 | evaluated. This info holds the Psion's time-offset so that we 16 | are able to calculate the offset correctly, regardless of the 17 | Psion's setting. All that is done in a new class PsiTime. 18 | For S3, a Fallback is provided using an Env-Variable "PSI_TZ" which 19 | can be set to the Psion's time-offset in seconds. 20 | - Added lots of rpc related stuff: 21 | - Implemented a procfs-like subdir in plpnfsd. Processes can 22 | be examined and misc. parameters can be examined/changed using 23 | the entries in /proc/ 24 | Several parameters can now be changed on the fly: 25 | attribute-cache timeout in seconds: proc/acache (rw) 26 | debuglevel: proc/debuglevel (rw) 27 | directory-cache timeout in seconds: proc/dcache (rw) 28 | Psion's owner-info: proc/owner (ro) 29 | Unix-owner of mounted directory: proc/unixowner (rw) 30 | 31 | Stopping of plpnfsd has now changed: 32 | Old: 33 | reference /mnt/psion/exit 34 | New: 35 | echo stop > /mnt/psion/proc/exit 36 | This should be safer than accidentally referencing a file. 37 | 38 | For every process running on the psion, a subdir in proc/ is 39 | created with two files "cmd" and "args" (both ro). cmd is the 40 | process-name, args is its commandline. 41 | 42 | - Added machinfo command in plpftp for displaying lot of interesting 43 | information about S5. (E.g. battery status etc.) 44 | - Added killsave and runrestore to plpftpd. Both take a unix file 45 | as argument. killsave kills all processes on the Psion and saves 46 | restart-information to the specified file. runrestore reads a file 47 | created by killsave and starts all processes saved in this file. 48 | -> Functionality similar to the behavior of PsiWin before/after backup. 49 | 50 | Changes from Version 0.5 to 0.6: 51 | 52 | - Maintenance release: bugfixes in plpnfsd and libs which make 53 | the mounted device writable again. 54 | 55 | Changes from Version 0.4 to 0.5: 56 | 57 | - merged all stuff from Matt Gumbley's plptools-0.4-mjg5 58 | see his README.mjg 59 | - Added a speedup-patch for plpnfsd from Rudol Koenig. This 60 | should also solve Olaf Flebbe's problems as a side effect. 61 | - Added command- and filename-completion to plpftp 62 | - Changed plpftp's default-drive to "AUTO". This triggers 63 | auto-detection of available drives and selecting the first one. 64 | - fixed various bugs in plpftp 65 | - added hash printing in plpftp. 66 | - Added new commands "ps", "kill" and "run" to plpftp (these should 67 | work at least for Series5. For Series3: INCOMPLETE) 68 | -------------------------------------------------------------------------------- /ncpd/packet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #ifndef _packet_h 22 | #define _packet_h 23 | 24 | #include "config.h" 25 | #include 26 | #include 27 | 28 | #include "bufferstore.h" 29 | #include "bufferarray.h" 30 | 31 | #define PKT_DEBUG_LOG 16 32 | #define PKT_DEBUG_DUMP 32 33 | #define PKT_DEBUG_HANDSHAKE 64 34 | 35 | extern "C" { 36 | static void *pump_run(void *); 37 | } 38 | 39 | class Link; 40 | 41 | class packet 42 | { 43 | public: 44 | packet(const char *fname, int baud, Link *_link, unsigned short verbose = 0); 45 | ~packet(); 46 | 47 | /** 48 | * Send a buffer out to serial line 49 | */ 50 | void send(bufferStore &b); 51 | 52 | void setEpoc(bool); 53 | void setVerbose(short int); 54 | short int getVerbose(); 55 | int getSpeed(); 56 | bool linkFailed(); 57 | void reset(); 58 | 59 | private: 60 | friend void * pump_run(void *); 61 | 62 | inline void addToCrc(unsigned char a, unsigned short *crc) { 63 | *crc = (*crc << 8) ^ crc_table[((*crc >> 8) ^ a) & 0xff]; 64 | } 65 | 66 | void findSync(); 67 | void opByte(unsigned char a); 68 | void opCByte(unsigned char a, unsigned short *crc); 69 | void realWrite(); 70 | void internalReset(); 71 | 72 | Link *theLINK; 73 | pthread_t datapump; 74 | pthread_t thisThread; 75 | unsigned int crc_table[256]; 76 | 77 | unsigned short crcOut; 78 | unsigned short crcIn; 79 | unsigned short receivedCRC; 80 | unsigned short inCRCstate; 81 | 82 | unsigned char *inBuffer; 83 | int inWrite; 84 | int inRead; 85 | 86 | unsigned char *outBuffer; 87 | int outWrite; 88 | int outRead; 89 | 90 | int startPkt; 91 | int lastSYN; 92 | 93 | bufferArray inQueue; 94 | bufferStore rcv; 95 | int foundSync; 96 | int fd; 97 | int serialStatus; 98 | int baud_index; 99 | int realBaud; 100 | short int verbose; 101 | bool esc; 102 | bool lastFatal; 103 | bool isEPOC; 104 | bool justStarted; 105 | 106 | char *devname; 107 | int baud; 108 | }; 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /doc/ncpd.man.in: -------------------------------------------------------------------------------- 1 | .\" Manual page for ncpd 2 | .\" 3 | .\" Process this file with 4 | .\" groff -man -Tascii ncpd.8 for ASCII output, or 5 | .\" groff -man -Tps ncpd.8 for Postscript output 6 | .\" 7 | .TH ncpd 8 "@MANDATE@" "plptools @VERSION@" "System administration commands" 8 | .SH NAME 9 | ncpd \- Daemon which handles the serial link to a Psion 10 | .SH SYNOPSIS 11 | .B ncpd 12 | .B [-V] 13 | .B [-h] 14 | .BI "[-v " log-class ] 15 | .B [-d] 16 | .B [-e] 17 | .BI "[-p [" host ":]" port ] 18 | .BI "[-s " device ] 19 | .BI "[-b " baud-rate ] 20 | .BI [ long-options ] 21 | 22 | .SH DESCRIPTION 23 | ncpd is the daemon which handles the serial link to your Psion. It 24 | listens at port @DPORT@ for local connections and provides basic 25 | PLP/NCP services for plpfuse and plpftp and other front-ends. It 26 | auto-connects to the psion, even after unplugging/switching off 27 | therefore it can run all the time if you can dedicate a serial device 28 | to it. 29 | 30 | .SH OPTIONS 31 | .TP 32 | .B \-V, --version 33 | Display the version and exit 34 | .TP 35 | .B \-h, --help 36 | Display a short help text and exit. 37 | .TP 38 | .B \-e, --autoexit 39 | Exit automatically if the device is disconnected. 40 | .TP 41 | .BI "\-v, --verbose=" log-class 42 | Increase the logging level of the program. the possible values for log-class 43 | are: 44 | .RS 45 | .TP 46 | .I nl 47 | Set NCP debug level to LOG 48 | .TP 49 | .I nd 50 | Set NCP debug level to DEBUG 51 | .TP 52 | .I ll 53 | Set Link debug level to LOG 54 | .TP 55 | .I ld 56 | Set Link debug level to DEBUG 57 | .TP 58 | .I pl 59 | Set Packet debug level to LOG 60 | .TP 61 | .I pd 62 | Set Packet debug level to DEBUG 63 | .TP 64 | .I ph 65 | Set Packet debug level to HANDSHAKE 66 | .TP 67 | .I m 68 | Set overall debug level to verbose 69 | .TP 70 | .I all 71 | Turn on all the above logging on. 72 | .RE 73 | .TP 74 | .B "\-d, --dontfork" 75 | Do not background the daemon. 76 | .TP 77 | .BI "\-p, --port=[" host: ] port 78 | Specify the port to listen on - by default the value for the host is 79 | 127.0.0.1 and the value for the port is looked up in /etc/services using 80 | the key 81 | .B psion/tcp. 82 | If it is not found there, a default value of @DPORT@ is used. 83 | .TP 84 | .BI "\-s, --serial=" device 85 | Specify the serial device to use to connect to the Psion - this defaults to 86 | @DDEV@ 87 | .TP 88 | .BI "\-b, --baudrate=" baud-rate 89 | Specify the baud rate to use for the serial connection. If the word 90 | .B auto 91 | is specified, ncpd cycles through baud-rates of 115200, 57600, 38400, 19200 92 | and 9600 baud. Default setting is @DSNAME@. 93 | 94 | .SH SEE ALSO 95 | plpfuse(8), plpprintd(8), plpftp(1), sisinstall(1) 96 | 97 | .SH AUTHOR 98 | Fritz Elfert 99 | .br 100 | Heavily based on p3nfsd by Rudolf Koenig (rfkoenig@immd4.informatik.uni-erlangen.de) 101 | and 102 | plp_1_7 by Philip Proudman (phil@proudman51.freeserve.co.uk) 103 | .br 104 | Patches from Matt Gumbley (matt@gumbley.demon.co.uk) 105 | .br 106 | Man page by John Lines (john+plpman@paladin.demon.co.uk) 107 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # plptools 2 | 3 | https://github.com/plptools/plptools/ 4 | 5 | plptools is a suite of programs for transferring files to and from EPOC 6 | (Psion) devices, as well as backing them up, installing software, and 7 | setting the clock. See below for build instructions and HISTORY for some 8 | history. 9 | 10 | plptools is free software; you can redistribute it and/or modify it under 11 | the terms of the GNU General Public License as published by the Free 12 | Software Foundation; either version 2 of the License, or (at your option) 13 | any later version. 14 | 15 | See the man pages for documentation: ncpd(8), plpftp(1), sisinstall(1), 16 | plpprintd(8), and, where installed, plpfuse(8). 17 | 18 | 19 | ## Building from source 20 | 21 | To build plpfuse, the following packages are required: 22 | 23 | * GNU Make 24 | * FUSE: https://github.com/libfuse/libfuse (MacFUSE on macOS) 25 | * libattr: https://savannah.nongnu.org/projects/attr (not required on macOS or BSD) 26 | 27 | For command-line editing and history support in plpftp, Readline 4.3 or later or a compatible library is required. 28 | 29 | Providing detailed instructions on how to install these packages for different operating systems is beyond the scope of this README, but see the [GitHub CI workflow](.github/workflows/c-cpp.yml) for the necessary install and configuration steps for Ubuntu/Debian and macOS. 30 | 31 | If building from a git checkout, you’ll need the following packages installed: automake, autoconf, pkg-config. 32 | 33 | Then run: 34 | 35 | ``` 36 | ./bootstrap --skip-po 37 | ``` 38 | 39 | Some extra packages are needed; `bootstrap` will tell you what you need to install if anything is lacking. 40 | 41 | plptools uses GNU autotools, so the usual sequence of commands works: 42 | 43 | ``` 44 | ./configure 45 | make 46 | make install 47 | ``` 48 | 49 | In addition to the usual options, `configure` understands the following: 50 | 51 |
52 |
--with-serial=/dev/sometty
53 |
sets the default serial device for ncpd. Without this option, ncpd tries automagically to find a serial device.
54 |
--with-speed=baudrate
55 |
sets the default serial speed (normally 115200 baud).
56 |
--with-port=portnum
57 |
sets the default port on which ncpd listens and to which plpftp and plpfuse connect (default 7501).
58 |
--with-drive=drivespec
59 |
sets the default drive for plpftp. The default AUTO triggers a drive-scan on the psion and sets the drive to the first drive found. If you don't want that, specify C: for example.
60 |
--with-basedir=dirspec
61 |
overrides the default directory for plpftp. The default is \, which means the root directory. Note: since backslashes need to be doubled once for C escaping and once for shell escaping, this value is actually supplied as \\\\.
62 | 63 | 64 | ## Information for developers 65 | 66 | The git repository can be cloned with: 67 | 68 | git clone https://github.com/plptools/plptools.git 69 | 70 | To make a release you need gh: https://cli.github.com 71 | -------------------------------------------------------------------------------- /etc/psidump.1: -------------------------------------------------------------------------------- 1 | .\" Manual page for psidump 2 | .TH psidump 1 "2001/1/15" "psidump 0.1" "System Administration" 3 | .SH NAME 4 | psidump \- This is an example of a sample man page 5 | .SH SYNOPSIS 6 | .B psidump 7 | .B [-Vvfi] 8 | .BI "[-D " disk ] 9 | .BI "[-m " mount_dir ] 10 | .BI "[-d " dump_dir ] 11 | 12 | .SH DESCRIPTION 13 | .I psidump 14 | is a command to back up files from an EPOC device to your PC. 15 | By default, it will only backup those files that have changed since it 16 | was last backed up. 17 | 18 | All backups are stored in their own separate files, and a directory is 19 | maintained which contains the latest version of all files on the system. 20 | 21 | .SH OPTIONS 22 | .TP 23 | .B \-V 24 | Display the version and exit 25 | .TP 26 | .B \-v 27 | Produce verbose logging output. 28 | .TP 29 | .B \-f 30 | This option forces a full back up to be done, rather than just backing up 31 | the files that have changed since the last backup. 32 | .TP 33 | .B \-i 34 | Performs an incremental back up - only backs up the files that have 35 | changed since the last backup. This is the default. 36 | .TP 37 | .BI "\-D " disk(s) 38 | Specify the EPOC disks to be backed up. This defaults to the 'C' and 39 | 'D' drives. For reasons of completeness, the 'Z' (ROM drive) can also 40 | be specified for backup (but there probably isn't any need to - unless 41 | you plan to do unspeakable things to the insides of your PDA!). 42 | .TP 43 | .BI "\-m " mount_dir 44 | Specify the mount directory. This defaults to the directory specified 45 | is your plptools configuration - usually /mnt/epoc. 46 | .TP 47 | .BI "\-d " dump_dir 48 | Specify the dump directory. This defaults to $HOME/epoc/backups. 49 | 50 | .SH ENVIRONMENT 51 | .TP 52 | $HOME/epoc 53 | Default directory where configuration and dump information 54 | is stored. 55 | .TP 56 | $HOME/epoc/etc 57 | Configuration information about your PDA(s) is stored here. 58 | .TP 59 | $HOME/epoc/backups 60 | All backups are stored under this directory. 61 | 62 | .SH FILES 63 | All files that are used are located in $HOME/epoc. The directories 64 | are: 65 | .TP 66 | $HOME/epoc/etc/plptab 67 | This file is a table of the different EPOC machines which have connected 68 | to this machine. The first entry is the machine id, and the second 69 | entry is the machine name. 70 | Note that there must be a between the two fields! 71 | Any lines starting with a '#' are comments. 72 | .TP 73 | $HOME/epoc/backups 74 | Executable files 75 | .TP 76 | $HOME/epoc/man 77 | Man pages 78 | 79 | .SH AUTHOR 80 | Alain Trembleau 81 | 82 | .SH COPYRIGHT 83 | Copyright (C) 2001 Alain Trembleau. 84 | 85 | .I psidump 86 | is open source software; you can redistribute it and/or modify 87 | it under the terms of the GNU General Public License as published 88 | by the Free Software Foundation; either version 2, or 89 | (at your option) any later version. 90 | 91 | .I psidump 92 | is distributed in the hope that it will be useful, but 93 | WITHOUT ANY WARRANTY; without even the implied warranty of 94 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 95 | See the GNU General Public License for more details. 96 | -------------------------------------------------------------------------------- /etc/ttytap.c: -------------------------------------------------------------------------------- 1 | /* plpfuse/Makefile.am 2 | * 3 | * This file is part of plptools. 4 | * 5 | * Copyright (C) 2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | static void usage(void) { 34 | fprintf(stderr, "usage: ttytap -q|\n"); 35 | exit(1); 36 | } 37 | 38 | int main(int argc, char **argv) { 39 | int fd; 40 | tapheader th; 41 | int i; 42 | int r; 43 | int major; 44 | int minor; 45 | int lastdir = -1; 46 | struct stat stbuf; 47 | char tbuf[256]; 48 | unsigned char buf[4096]; 49 | 50 | 51 | if (argc != 2) 52 | usage(); 53 | if (strcmp(argv[1], "-q")) { 54 | if (stat(argv[1], &stbuf)) { 55 | perror(argv[1]); 56 | exit(-1); 57 | } 58 | if (!S_ISCHR(stbuf.st_mode)) { 59 | fprintf(stderr, "%s is not a char device\n", argv[1]); 60 | exit(1); 61 | } 62 | major = MAJOR(stbuf.st_rdev); 63 | minor = MINOR(stbuf.st_rdev); 64 | } else { 65 | minor = 0; 66 | major = 0; 67 | } 68 | fd = open("/proc/ttytap", O_RDONLY); 69 | if (fd == -1) { 70 | perror("/proc/ttytap"); 71 | exit(-1); 72 | } 73 | if (ioctl(fd, TTYTAP_SETDEV, (major << 8) | minor)) { 74 | perror("ioctl /proc/ttytap"); 75 | exit(-1); 76 | } 77 | if ((minor == 0) && (major == 0)) { 78 | printf("Serial tapping switched off\n"); 79 | exit(0); 80 | } 81 | if (ioctl(fd, TTYTAP_GETQLEN, &i)) { 82 | perror("ioctl /proc/ttytap"); 83 | exit(-1); 84 | } 85 | fprintf(stderr, "Queue length is %d\n", i); 86 | while (1) { 87 | r = read(fd, &th, sizeof(th)); 88 | if (r != sizeof(th)) { 89 | perror("read /proc/ttytap"); 90 | exit(-1); 91 | } 92 | strftime(tbuf, 255, "%H:%M:%S", localtime(&th.stamp.tv_sec)); 93 | printf("%s.%06ld %c (%04d) ", tbuf, 94 | (unsigned long)th.stamp.tv_usec, 95 | (th.io) ? '<' : '>', th.len); 96 | r = read(fd, buf, th.len); 97 | if (r != th.len) { 98 | perror("read /proc/ttytap"); 99 | exit(-1); 100 | } 101 | for (i = 0; i < th.len; i++) 102 | printf("%02x ", buf[i] & 255); 103 | for (i = 0; i < th.len; i++) 104 | printf("%c", isprint(buf[i]) ? buf[i] : '.'); 105 | printf("\n"); fflush(stdout); 106 | } 107 | return 0; 108 | } 109 | -------------------------------------------------------------------------------- /etc/plptools.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # plptools Starts ncpd/plpfuse. 4 | # 5 | # chkconfig: 2345 45 10 6 | # description: This facility enables connectivity to an EPOC PDA. 7 | # 8 | # This file is part of plptools. 9 | # 10 | # Copyright (C) 1999-2002 Fritz Elfert 11 | # Copyright (C) 2007-2008 Reuben Thomas 12 | # 13 | # This program is free software; you can redistribute it and/or modify 14 | # it under the terms of the GNU General Public License as published by 15 | # the Free Software Foundation; either version 2 of the License, or 16 | # (at your option) any later version. 17 | # 18 | # This program is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | # GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License along 24 | # along with this program; if not, see . 25 | 26 | 27 | # Source function library. 28 | . /etc/rc.d/init.d/functions 29 | 30 | [ -f @prefix@/sbin/ncpd ] || exit 0 31 | [ -f @prefix@/sbin/plpfuse ] || exit 0 32 | [ -f @prefix@/sbin/plpprintd ] || exit 0 33 | [ -f /etc/sysconfig/plptools ] || exit 0 34 | . /etc/sysconfig/plptools 35 | 36 | start() { 37 | echo "Starting EPOC support ..." 38 | RETVAL=0 39 | if test "$START_NCPD" = "yes" ; then 40 | echo -n " ncpd: " 41 | daemon @prefix@/sbin/ncpd $NCPD_ARGS 42 | RETVAL=$? 43 | echo 44 | fi 45 | if [ $RETVAL -eq 0 ] ; then 46 | if test "$START_PLPFUSE" = "yes" ; then 47 | echo -n " plpfuse: " 48 | daemon @prefix@/sbin/plpfuse $PLPFUSE_ARGS 49 | RETVAL=$? 50 | echo 51 | fi 52 | fi 53 | if [ $RETVAL -eq 0 ] ; then 54 | if test "$START_PLPPRINTD" = "yes" ; then 55 | echo -n " plpprintd: " 56 | daemon @prefix@/sbin/plpprintd $PLPPRINTD_ARGS 57 | RETVAL=$? 58 | echo 59 | fi 60 | fi 61 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/plptools 62 | return $RETVAL 63 | } 64 | 65 | stop() { 66 | echo "Stopping EPOC support ..." 67 | RETVAL=0 68 | if test "$START_PLPPRINTD" = "yes" ; then 69 | echo -n " plpprintd: " 70 | killproc plpprintd 71 | echo 72 | fi 73 | if test "$START_PLPFUSE" = "yes" ; then 74 | echo -n " plpfuse: " 75 | fusermount -u /mnt/epoc 76 | echo 77 | fi 78 | if test "$START_NCPD" = "yes" ; then 79 | echo -n " ncpd: " 80 | killproc ncpd 81 | RETVAL=$? 82 | echo 83 | fi 84 | [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/plptools 85 | return $RETVAL 86 | } 87 | 88 | restart() { 89 | stop 90 | start 91 | } 92 | 93 | # See how we were called. 94 | case "$1" in 95 | start) 96 | start 97 | ;; 98 | stop) 99 | stop 100 | ;; 101 | status) 102 | status ncpd 103 | status plpprintd 104 | ;; 105 | restart|reload) 106 | restart 107 | ;; 108 | condrestart) 109 | test -f /var/lock/subsys/plptools && restart || : 110 | ;; 111 | *) 112 | echo "Usage: plptools {start|stop|status|restart|reload|condrestart}" 113 | exit 1 114 | esac 115 | 116 | exit $? 117 | 118 | -------------------------------------------------------------------------------- /lib/sisfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | */ 19 | 20 | #ifndef _SISFILE_H 21 | #define _SISFILE_H 22 | 23 | #include "sistypes.h" 24 | #include "sisfileheader.h" 25 | #include "siscomponentrecord.h" 26 | 27 | class SISLangRecord; 28 | class SISFileRecord; 29 | class SISReqRecord; 30 | 31 | /** 32 | * The top level container of a SIS file. 33 | * Based on documentation by Alexander Thoukydides . 34 | */ 35 | class SISFile 36 | { 37 | public: 38 | 39 | SISFile(); 40 | 41 | virtual ~SISFile(); 42 | 43 | /** 44 | * Compare uid and version number of this file, with another. 45 | * 46 | * @see SISFileHeader::compareApp() 47 | */ 48 | SisRC compareApp(SISFile* other); 49 | 50 | /** 51 | * Populate the fields. 52 | * 53 | * @param buf The buffer to read from. 54 | * @param len The length of the buffer. 55 | */ 56 | SisRC fillFrom(uint8_t* buf, off_t len); 57 | 58 | /** 59 | * Return the currently selected installation language. 60 | */ 61 | int getLanguage(); 62 | 63 | /** 64 | * Find a language entry, based on the sequence number in the SISLangRecord 65 | * part of the file. 66 | */ 67 | LangTableEntry* getLanguage(int i); 68 | 69 | /** 70 | * Get the name of this component, in the selected language. 71 | */ 72 | uint8_t* getName(); 73 | 74 | /** 75 | * Get the number of bytes that should be copied to the residual sis 76 | * file on the psion. 77 | */ 78 | uint32_t getResidualEnd() 79 | { 80 | return m_end; 81 | } 82 | 83 | void ownBuffer() 84 | { 85 | m_ownBuffer = true; 86 | } 87 | 88 | /** 89 | * Is this the same application? 90 | */ 91 | bool sameApp(SISFile* other); 92 | 93 | /** 94 | * Set the installed drive. 95 | */ 96 | void setDrive(char drive); 97 | 98 | /** 99 | * Set the number of installed files. 100 | */ 101 | void setFiles(int nFiles); 102 | 103 | /** 104 | * Set the selected installation language. 105 | */ 106 | void setLanguage(int lang); 107 | 108 | SISFileHeader m_header; 109 | SISLangRecord* m_langRecords; 110 | SISFileRecord* m_fileRecords; 111 | SISReqRecord* m_reqRecords; 112 | 113 | private: 114 | 115 | SISComponentNameRecord m_componentRecord; 116 | 117 | bool m_ownBuffer; 118 | 119 | uint8_t* m_buf; 120 | 121 | uint32_t m_end; 122 | 123 | void updateEnd(uint32_t pos); 124 | 125 | }; 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /lib/sisfilerecord.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | */ 19 | 20 | #ifndef _SISFILERECORD_H 21 | #define _SISFILERECORD_H 22 | 23 | #include "sistypes.h" 24 | 25 | class SISFile; 26 | 27 | /** 28 | * Information about a file component in a SIS file. 29 | * 30 | * The file can be for multiple languages, in which case a single 31 | * instance holds pointers to contents for all languages. 32 | */ 33 | class SISFileRecord 34 | { 35 | public: 36 | 37 | /** 38 | * Populate the fields. 39 | * 40 | * @param buf The buffer to read from. 41 | * @param base The index to start reading from, which is updated 42 | * when the record is successfully read. 43 | * @param len The length of the buffer. 44 | * @param sisFile The container SISFile. 45 | */ 46 | SisRC fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile); 47 | 48 | uint8_t* getDestPtr() 49 | { 50 | return m_destPtr < m_len ? &m_buf[m_destPtr] : 0; 51 | } 52 | 53 | /** 54 | * Return a pointer to the file data for the file for the specified 55 | * language. 56 | */ 57 | uint8_t* getFilePtr(int fileNo); 58 | 59 | void setMainDrive(char drive); 60 | 61 | /** 62 | * 1 if multiple language versions, otherwise 0. 63 | */ 64 | uint32_t m_flags; 65 | 66 | /** 67 | * Type of file. 68 | * 69 | * - 0. Standard file. 70 | * - 1. Text file to display during installation. 71 | * - 2. SIS component. 72 | * - 3. File to run during installation/removal. 73 | * - 4. Does not exist yet, but will be created when app is run, so 74 | * it should not be removed during an upgrade. 75 | */ 76 | uint32_t m_fileType; 77 | 78 | /** 79 | * If file type is 1: 80 | * 81 | * - 0. Continue. 82 | * - 1. Yes, No (skip next file). 83 | * - 2. Yes, No (abort installation). 84 | * 85 | * If file type is 3: 86 | * 87 | * - 0. Run during installation. 88 | * - 1. Run during removal. 89 | * - 2. Run during both installation and removal. 90 | */ 91 | uint32_t m_fileDetails; 92 | 93 | uint32_t m_sourceLength; 94 | uint32_t m_sourcePtr; 95 | uint32_t m_destLength; 96 | uint32_t* m_fileLengths; 97 | 98 | private: 99 | 100 | uint32_t m_destPtr; 101 | uint32_t* m_filePtrs; 102 | 103 | /** 104 | * The buffer we belong to. 105 | * Used for updating the destination file name. 106 | */ 107 | uint8_t* m_buf; 108 | 109 | int m_len; 110 | 111 | }; 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /lib/rpcsfactory.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2000-2001 Fritz Elfert 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #include "config.h" 21 | 22 | #include "rpcs16.h" 23 | #include "rpcs32.h" 24 | #include "rpcsfactory.h" 25 | #include "bufferstore.h" 26 | #include "ppsocket.h" 27 | #include "Enum.h" 28 | 29 | #include 30 | #include 31 | 32 | ENUM_DEFINITION_BEGIN(rpcsfactory::errs, rpcsfactory::FACERR_NONE) 33 | stringRep.add(rpcsfactory::FACERR_NONE, N_("no error")); 34 | stringRep.add(rpcsfactory::FACERR_COULD_NOT_SEND, N_("could not send version request")); 35 | stringRep.add(rpcsfactory::FACERR_AGAIN, N_("try again")); 36 | stringRep.add(rpcsfactory::FACERR_NOPSION, N_("no EPOC device connected")); 37 | stringRep.add(rpcsfactory::FACERR_PROTVERSION, N_("wrong protocol version")); 38 | stringRep.add(rpcsfactory::FACERR_NORESPONSE, N_("no response from ncpd")); 39 | ENUM_DEFINITION_END(rpcsfactory::errs) 40 | 41 | rpcsfactory::rpcsfactory(ppsocket *_skt) 42 | { 43 | err = FACERR_NONE; 44 | skt = _skt; 45 | } 46 | 47 | rpcs * rpcsfactory::create(bool reconnect) 48 | { 49 | // skt is connected to the ncp daemon, which will have (hopefully) seen 50 | // an INFO exchange, where the protocol version of the remote Psion was 51 | // sent, and noted. We have to ask the ncp daemon which protocol it saw, 52 | // so we can instantiate the correct rpcs protocol handler for the 53 | // caller. We announce ourselves to the NCP daemon, and the relevant 54 | // rpcs module will also announce itself. 55 | 56 | bufferStore a; 57 | 58 | err = FACERR_NONE; 59 | a.addStringT("NCP$INFO"); 60 | if (!skt->sendBufferStore(a)) { 61 | if (!reconnect) 62 | err = FACERR_COULD_NOT_SEND; 63 | else { 64 | skt->closeSocket(); 65 | skt->reconnect(); 66 | err = FACERR_AGAIN; 67 | } 68 | return NULL; 69 | } 70 | if (skt->getBufferStore(a) == 1) { 71 | if (a.getLen() > 8 && !strncmp(a.getString(), "Series 3", 8)) { 72 | return new rpcs16(skt); 73 | } 74 | else if (a.getLen() > 8 && !strncmp(a.getString(), "Series 5", 8)) { 75 | return new rpcs32(skt); 76 | } 77 | if ((a.getLen() > 8) && !strncmp(a.getString(), "No Psion", 8)) { 78 | skt->closeSocket(); 79 | skt->reconnect(); 80 | err = FACERR_NOPSION; 81 | return NULL; 82 | } 83 | // Invalid protocol version 84 | err = FACERR_PROTVERSION; 85 | } else 86 | err = FACERR_NORESPONSE; 87 | 88 | // No message returned. 89 | return NULL; 90 | } 91 | -------------------------------------------------------------------------------- /lib/psiprocess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999-2002 Fritz Elfert 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #ifndef _PSIPROCESS_H_ 21 | #define _PSIPROCESS_H_ 22 | 23 | #include 24 | #include 25 | 26 | class rpcs; 27 | 28 | /** 29 | * A class, describing a Process on the Psion. 30 | * Objects of this type are used by @ref rpcs::queryPrograms 31 | * for returning the currently running processes. 32 | * 33 | * @author Fritz Elfert 34 | */ 35 | class PsiProcess { 36 | 37 | public: 38 | /** 39 | * Default constructor 40 | */ 41 | PsiProcess(); 42 | 43 | /** 44 | * A copy constructor. 45 | * Mainly used by STL container classes. 46 | * 47 | * @param p The object to be used as initializer. 48 | */ 49 | PsiProcess(const PsiProcess &p); 50 | 51 | /** 52 | * Initializing Constructor 53 | */ 54 | PsiProcess(const int, const char * const, const char * const, bool); 55 | 56 | /** 57 | * Default destructor. 58 | */ 59 | ~PsiProcess() {}; 60 | 61 | /** 62 | * Retrieves the PID of a process. 63 | * 64 | * @returns The PID of this instance. 65 | */ 66 | int getPID(); 67 | 68 | /** 69 | * Retrieve the file name of a process. 70 | * 71 | * @returns The name of this instance. 72 | */ 73 | const char *getName(); 74 | 75 | /** 76 | * Retrieve the file name of a process. 77 | * 78 | * @returns The arguments of this instance. 79 | */ 80 | const char *getArgs(); 81 | 82 | /** 83 | * Retrieve the file name and PID of a process. 84 | * 85 | * @returns The name and PID this instance in the format 86 | * name.$pid . 87 | */ 88 | const char *getProcId(); 89 | 90 | /** 91 | * Assignment operator 92 | * Mainly used by STL container classes. 93 | * 94 | * @param p The new value to assign. 95 | * 96 | * @returns The modified object. 97 | */ 98 | PsiProcess &operator=(const PsiProcess &p); 99 | 100 | /** 101 | * Prints the object contents. 102 | * The output is in human readable similar to the 103 | * output of a "ls" command. 104 | */ 105 | friend std::ostream &operator<<(std::ostream &o, const PsiProcess &p); 106 | 107 | private: 108 | friend class rpcs; 109 | 110 | void setArgs(std::string _args); 111 | 112 | int pid; 113 | std::string name; 114 | std::string args; 115 | bool s5mx; 116 | }; 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /lib/sistypes.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | */ 19 | #include "config.h" 20 | 21 | #include "sistypes.h" 22 | 23 | static unsigned int s_crcTable[256]; 24 | 25 | int logLevel = 0; 26 | 27 | void createCRCTable() 28 | { 29 | const unsigned int polynomial = 0x1021; 30 | unsigned int index; 31 | s_crcTable[0] = 0; 32 | for (index = 0; index < 128; index++) 33 | { 34 | unsigned int carry = s_crcTable[index] & 0x8000; 35 | unsigned int temp = (s_crcTable[index] << 1) & 0xffff; 36 | s_crcTable[index * 2 + (carry ? 0 : 1)] = temp ^ polynomial; 37 | s_crcTable[index * 2 + (carry ? 1 : 0)] = temp; 38 | } 39 | } 40 | 41 | uint16_t updateCrc(uint16_t crc, uint8_t value) 42 | { 43 | return (crc << 8) ^ s_crcTable[((crc >> 8) ^ value) & 0xff]; 44 | } 45 | 46 | uint16_t calcCRC(uint8_t* data, int len) 47 | { 48 | uint16_t crc = 0; 49 | for (int i = 0; i < len; ++i) 50 | { 51 | uint8_t value = data[i]; 52 | crc = (crc << 8) ^ s_crcTable[((crc >> 8) ^ value) & 0xff]; 53 | } 54 | return crc; 55 | } 56 | 57 | uint16_t read16(uint8_t* p) 58 | { 59 | return p[0] | (p[1] << 8); 60 | } 61 | 62 | uint32_t read32(uint8_t* p) 63 | { 64 | return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); 65 | } 66 | 67 | void write16(uint8_t* p, int val) 68 | { 69 | p[0] = val & 255; 70 | p[1] = (val >> 8) & 255; 71 | } 72 | 73 | LangTableEntry langTable[] = 74 | { 75 | { 0, "", "Test" }, 76 | { 1, "EN", "UK English" }, 77 | { 2, "FR", "French" }, 78 | { 3, "GE", "German" }, 79 | { 4, "SP", "Spanish" }, 80 | { 5, "IT", "Italian" }, 81 | { 6, "SW", "Swedish" }, 82 | { 7, "DA", "Danish" }, 83 | { 8, "NO", "Norwegian" }, 84 | { 9, "FI", "Finnish" }, 85 | { 10, "AM", "American English" }, 86 | { 11, "SF", "Swiss French" }, 87 | { 12, "SG", "Swiss German" }, 88 | { 13, "PO", "Portuguese" }, 89 | { 14, "TU", "Turkish" }, 90 | { 15, "IC", "Icelandic" }, 91 | { 16, "RU", "Russian" }, 92 | { 17, "HU", "Hungarian" }, 93 | { 18, "DU", "Dutch" }, 94 | { 19, "BL", "Belgian Flemish" }, 95 | { 20, "AU", "Australian English" }, 96 | { 21, "BG", "Belgian French" }, 97 | { 22, "AS", "Austrian German" }, 98 | { 23, "NZ", "New Zealand" }, 99 | { 24, "IF", "International French" }, 100 | { 25, "CS", "Czech" }, 101 | { 26, "SK", "Slovak" }, 102 | { 27, "PL", "Polish" }, 103 | { 28, "SL", "Slovenian" }, 104 | { 29, "TC", "Taiwan Chinese" }, 105 | { 30, "HK", "Hong Kong" }, 106 | { 31, "ZH", "PRC Chinese" }, 107 | { 32, "JA", "Japanese" }, 108 | { 33, "TH", "Thai" }, 109 | }; 110 | -------------------------------------------------------------------------------- /lib/rfsvfactory.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Matt J. Gumbley 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #include "config.h" 21 | 22 | #include "rfsv.h" 23 | #include "rfsv16.h" 24 | #include "rfsv32.h" 25 | #include "rfsvfactory.h" 26 | #include "bufferstore.h" 27 | #include "ppsocket.h" 28 | #include "Enum.h" 29 | 30 | #include 31 | #include 32 | 33 | using namespace std; 34 | 35 | ENUM_DEFINITION_BEGIN(rfsvfactory::errs, rfsvfactory::FACERR_NONE) 36 | stringRep.add(rfsvfactory::FACERR_NONE, N_("no error")); 37 | stringRep.add(rfsvfactory::FACERR_COULD_NOT_SEND, N_("could not send version request")); 38 | stringRep.add(rfsvfactory::FACERR_AGAIN, N_("try again")); 39 | stringRep.add(rfsvfactory::FACERR_NOPSION, N_("no EPOC device connected")); 40 | stringRep.add(rfsvfactory::FACERR_PROTVERSION, N_("wrong protocol version")); 41 | stringRep.add(rfsvfactory::FACERR_NORESPONSE, N_("no response from ncpd")); 42 | ENUM_DEFINITION_END(rfsvfactory::errs) 43 | 44 | rfsvfactory::rfsvfactory(ppsocket *_skt) : serNum(0) 45 | { 46 | err = FACERR_NONE; 47 | skt = _skt; 48 | } 49 | 50 | rfsv * rfsvfactory::create(bool reconnect) 51 | { 52 | // skt is connected to the ncp daemon, which will have (hopefully) seen 53 | // an INFO exchange, where the protocol version of the remote Psion was 54 | // sent, and noted. We have to ask the ncp daemon which protocol it saw, 55 | // so we can instantiate the correct RFSV protocol handler for the 56 | // caller. We announce ourselves to the NCP daemon, and the relevant 57 | // RFSV module will also announce itself. 58 | 59 | bufferStore a; 60 | 61 | err = FACERR_NONE; 62 | a.addStringT("NCP$INFO"); 63 | if (!skt->sendBufferStore(a)) { 64 | if (!reconnect) 65 | err = FACERR_COULD_NOT_SEND; 66 | else { 67 | skt->closeSocket(); 68 | serNum = 0; 69 | skt->reconnect(); 70 | err = FACERR_AGAIN; 71 | } 72 | return NULL; 73 | } 74 | if (skt->getBufferStore(a) == 1) { 75 | if (a.getLen() > 8 && !strncmp(a.getString(), "Series 3", 8)) { 76 | return new rfsv16(skt); 77 | } 78 | else if (a.getLen() > 8 && !strncmp(a.getString(), "Series 5", 8)) { 79 | return new rfsv32(skt); 80 | } 81 | if ((a.getLen() > 8) && !strncmp(a.getString(), "No Psion", 8)) { 82 | skt->closeSocket(); 83 | serNum = 0; 84 | skt->reconnect(); 85 | err = FACERR_NOPSION; 86 | return NULL; 87 | } 88 | // Invalid protocol version 89 | err = FACERR_PROTVERSION; 90 | } else 91 | err = FACERR_NORESPONSE; 92 | 93 | return NULL; 94 | } 95 | -------------------------------------------------------------------------------- /lib/siscomponentrecord.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | */ 19 | #include "config.h" 20 | 21 | #include "siscomponentrecord.h" 22 | #include "sisfile.h" 23 | #include "plpintl.h" 24 | 25 | #include 26 | #include 27 | 28 | SISComponentNameRecord::SISComponentNameRecord() 29 | { 30 | m_names = NULL; 31 | } 32 | 33 | SISComponentNameRecord::~SISComponentNameRecord() 34 | { 35 | if (m_names) 36 | { 37 | for (int i = 0; i < m_nameCount; ++i) 38 | delete[] m_names[i]; 39 | delete[] m_names; 40 | } 41 | } 42 | 43 | SisRC 44 | SISComponentNameRecord::fillFrom(uint8_t* buf, int* basePos, off_t len, 45 | SISFile* sisFile) 46 | { 47 | int n = sisFile->m_header.m_nlangs; 48 | int base = *basePos; 49 | int entrySize = 8 + n * 4 * 2; 50 | if (base + entrySize > len) 51 | return SIS_TRUNCATED; 52 | *basePos += entrySize; 53 | 54 | uint8_t* p = buf + base; 55 | int size = 0; 56 | 57 | m_nameLengths = new uint32_t[n]; 58 | m_namePtrs = new uint32_t[n]; 59 | 60 | // First read lengths. 61 | // 62 | for (int i = 0; i < n; ++i) 63 | { 64 | m_nameLengths[i] = read32(p + size); 65 | if (m_nameLengths[i] > len) 66 | { 67 | printf(_("Length too large for name record %d.\n"), i); 68 | return SIS_TRUNCATED; 69 | } 70 | size += 4; 71 | } 72 | 73 | // Then read ptrs. 74 | // 75 | m_names = new uint8_t*[n]; 76 | m_nameCount = n; 77 | for (int i = 0; i < n; ++i) 78 | { 79 | m_namePtrs[i] = read32(p + size); 80 | if (m_namePtrs[i] + m_nameLengths[i] > len) 81 | { 82 | printf(_("Position/length too large for name record %d.\n"), i); 83 | return SIS_TRUNCATED; 84 | } 85 | size += 4; 86 | if (logLevel >= 2) 87 | printf(_("Name %d (for %s) is %.*s\n"), 88 | i, 89 | sisFile->getLanguage(i)->m_name, 90 | m_nameLengths[i], 91 | buf + m_namePtrs[i]); 92 | int nlen = m_nameLengths[i]; 93 | m_names[i] = new uint8_t[nlen + 1]; 94 | memcpy(m_names[i], buf + m_namePtrs[i], nlen); 95 | m_names[i][nlen] = 0; 96 | } 97 | if (logLevel >= 1) 98 | printf(_("%d .. %d (%d bytes): Name records\n"), base, base + size, size); 99 | return SIS_OK; 100 | } 101 | 102 | uint32_t 103 | SISComponentNameRecord::getLastEnd() 104 | { 105 | uint32_t last = 0; 106 | for (int i = 0; i < m_nameCount; ++i) 107 | { 108 | uint32_t pos = m_namePtrs[i] + m_nameLengths[i]; 109 | if (last < pos) 110 | last = pos; 111 | } 112 | return last; 113 | } 114 | 115 | uint8_t* 116 | SISComponentNameRecord::getName(int no) 117 | { 118 | return m_names[no]; 119 | } 120 | -------------------------------------------------------------------------------- /doc/plpfuse.man.in: -------------------------------------------------------------------------------- 1 | .\" Manual page for plpfuse 2 | .\" 3 | .\" Process this file with 4 | .\" groff -man -Tascii plpfuse.8 for ASCII output, or 5 | .\" groff -man -Tps plpfuse.8 for Postscript output 6 | .\" 7 | .TH plpfuse 8 "@MANDATE@" "plptools @VERSION@" "System administration commands" 8 | .SH NAME 9 | plpfuse \- Daemon to mount an EPOC device as a file system 10 | .SH SYNOPSIS 11 | .B plpfuse 12 | .B [-V] 13 | .B [-d] 14 | .B [-h] 15 | .BI "[-p [" HOST :] PORT ] 16 | .BI [ LONG-OPTIONS ] 17 | .BI MOUNTPOINT 18 | 19 | .SH DESCRIPTION 20 | plpfuse is a file system which provides file system access to your EPOC device. 21 | It mounts the EPOC device's file systems in your computer's file system. 22 | Like the other front-ends, this program 23 | auto-reconnects after a link failure, so you can keep the 24 | EPOC device mounted all the time, even when it is not connected. 25 | Due to Rudolf Koenig's clever error handling, you don't need to 26 | worry about blocked I/O processes if the psion isn't available. 27 | You will simply get a "device not configured" error, when 28 | accessing a file on a previously connected psion which has been 29 | disconnected. After that, the mount point will appear with the 30 | drives missing. As soon as the psion is connected again, the 31 | subdirectories will reappear (possibly with a few seconds' delay). 32 | 33 | EPOC file attributes are mapped as follows: readable on the EPOC 34 | device is mapped to user-readable on UNIX; read-only is inverted and 35 | mapped to user-writable; system, hidden and archived are mapped to 36 | the extended user attribute 37 | .B user.psion 38 | as the single characters `s', `h' and `a'. The extended attribute can 39 | therefore be up to three characters long. An attempt to read or write 40 | any other extended attribute will give an error. 41 | 42 | .SH OPTIONS 43 | .TP 44 | .B \-V, --version 45 | Display the version and exit 46 | .TP 47 | .B \-h, --help 48 | Display a short help text and exit. 49 | .TP 50 | .B \-d, --debug 51 | Produce debugging logs. Can be specified more than once to increase the 52 | debug level (up to 3 times). 53 | .TP 54 | .BI "\-p, --port=[" host :] port 55 | Specify the host and port to connect to (e.g. the port where ncpd is listening 56 | on) - by default the host is 127.0.0.1 and the port is looked up in 57 | /etc/services. If it is not found there, a fall-back builtin of 58 | .I @DPORT@. 59 | 60 | .SH BUGS 61 | Because UNIX file names are simply byte strings, if your EPOC device 62 | uses a different character set from the computer to which it is 63 | connected, which is highly likely, then characters which are 64 | differently encoded between the two characters sets will not translate 65 | between the two systems. it is usually safe to use 7-bit ASCII 66 | characters, avoiding colon (invalid on EPOC) and slash (invalid on 67 | UNIX). This problem may be fixed in future. 68 | 69 | .SH SEE ALSO 70 | ncpd(8), plpprintd(8), plpftp(1), sisinstall(1), fusermount(1) 71 | 72 | .SH AUTHOR 73 | Reuben Thomas, based on plpnfsd by Fritz Elfert, and FUSE example code by Miklos Szeredi (miklos@szeredi.hu). 74 | .br 75 | plpnfsd itself was heavily based on p3nfsd by Rudolf Koenig (rfkoenig@immd4.informatik.uni-erlangen.de) 76 | and plp_1_7 by Philip Proudman (phil@proudman51.freeserve.co.uk), with patches from Matt Gumbley (matt@gumbley.demon.co.uk). 77 | .br 78 | Man page by Reuben Thomas , based on the man page for plpnfsd by John Lines (john+plpman@paladin.demon.co.uk). 79 | -------------------------------------------------------------------------------- /lib/wprt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999-2001 Fritz Elfert 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #ifndef _WPRT_H_ 21 | #define _WPRT_H_ 22 | 23 | #include "rfsv.h" 24 | #include "Enum.h" 25 | 26 | class ppsocket; 27 | class bufferStore; 28 | class bufferArray; 29 | 30 | /** 31 | * Remote Print services via PLP 32 | * 33 | */ 34 | class wprt { 35 | public: 36 | wprt(ppsocket *); 37 | 38 | /** 39 | * Virtual destructor. 40 | */ 41 | ~wprt(); 42 | 43 | /** 44 | * Initializes a connection to the remote 45 | * machine. 46 | */ 47 | void reset(); 48 | 49 | /** 50 | * Attempts to re-establish a remote 51 | * connection by first closing the socket, 52 | * then connecting again to the ncpd daemon 53 | * and finally calling @ref reset. 54 | */ 55 | void reconnect(); 56 | 57 | /** 58 | * Retrieves the current status of the 59 | * connection. 60 | * 61 | * @returns The connection status. 62 | */ 63 | Enum getStatus(); 64 | 65 | /** 66 | * Get Print Data 67 | */ 68 | Enum getData(bufferStore &buf); 69 | 70 | /** 71 | * Init Printer 72 | */ 73 | Enum initPrinter(); 74 | 75 | /** 76 | * Cancels a running job. 77 | */ 78 | Enum cancelJob(); 79 | 80 | /** 81 | * Stops the WPRT server. 82 | */ 83 | bool stop(); 84 | 85 | protected: 86 | /** 87 | * The possible commands. 88 | */ 89 | enum commands { 90 | WPRT_INIT = 0x00, 91 | WPRT_GET = 0xf0, 92 | WPRT_CANCEL = 0xf1, 93 | WPRT_STOP = 0xff 94 | }; 95 | 96 | /** 97 | * The socket, used for communication 98 | * with ncpd. 99 | */ 100 | ppsocket *skt; 101 | 102 | /** 103 | * The current status of the connection. 104 | */ 105 | Enum status; 106 | 107 | /** 108 | * Sends a command to the remote side. 109 | * 110 | * If communication fails, a reconnect is triggered 111 | * and a second attempt to transmit the request 112 | * is attempted. If that second attempt fails, 113 | * the function returns an error an sets rpcs::status 114 | * to E_PSI_FILE_DISC. 115 | * 116 | * @param cc The command to execute on the remote side. 117 | * @param data Additional data for this command. 118 | * 119 | * @returns true on success, false on failure. 120 | */ 121 | bool sendCommand(enum commands cc, bufferStore &data); 122 | 123 | Enum getResponse(bufferStore &data); 124 | const char *getConnectName(); 125 | 126 | }; 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /ncpd/channel.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #include "config.h" 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "channel.h" 28 | #include "ncp.h" 29 | 30 | channel::channel(ncp * _ncpController) 31 | { 32 | verbose = 0; 33 | ncpChannel = 0; 34 | connectName = 0; 35 | ncpController = _ncpController; 36 | _terminate = false; 37 | } 38 | 39 | channel::~channel() 40 | { 41 | if (connectName) 42 | free((void *)connectName); 43 | } 44 | 45 | void channel:: 46 | ncpSend(bufferStore & a) 47 | { 48 | ncpController->send(ncpChannel, a); 49 | } 50 | 51 | bool channel:: 52 | terminate() 53 | { 54 | return _terminate; 55 | } 56 | 57 | void channel:: 58 | terminateWhenAsked() 59 | { 60 | _terminate = true; 61 | } 62 | 63 | void channel:: 64 | ncpConnect() 65 | { 66 | ncpController->connect(this); 67 | } 68 | 69 | void channel:: 70 | ncpRegister() 71 | { 72 | ncpController->Register(this); 73 | } 74 | 75 | void channel:: 76 | ncpDoRegisterAck(int ch, const char *name) 77 | { 78 | ncpController->RegisterAck(ch, name); 79 | } 80 | 81 | void channel:: 82 | ncpDisconnect() 83 | { 84 | ncpController->disconnect(ncpChannel); 85 | } 86 | 87 | PcServer *channel:: 88 | ncpFindPcServer(const char *name) 89 | { 90 | return ncpController->findPcServer(name); 91 | } 92 | 93 | void channel:: 94 | ncpRegisterPcServer(ppsocket *skt, const char *name) 95 | { 96 | ncpController->registerPcServer(skt, name); 97 | } 98 | 99 | void channel:: 100 | ncpUnregisterPcServer(PcServer *server) 101 | { 102 | ncpController->unregisterPcServer(server); 103 | } 104 | 105 | int channel:: 106 | ncpGetSpeed() 107 | { 108 | return ncpController->getSpeed(); 109 | } 110 | 111 | short int channel:: 112 | ncpProtocolVersion() 113 | { 114 | return ncpController->getProtocolVersion(); 115 | } 116 | 117 | void channel:: 118 | setNcpChannel(int chan) 119 | { 120 | ncpChannel = chan; 121 | } 122 | 123 | int channel:: 124 | getNcpChannel() 125 | { 126 | return ncpChannel; 127 | } 128 | 129 | void channel:: 130 | newNcpController(ncp * _ncpController) 131 | { 132 | ncpController = _ncpController; 133 | } 134 | 135 | void channel:: 136 | setVerbose(short int _verbose) 137 | { 138 | verbose = _verbose; 139 | } 140 | 141 | short int channel:: 142 | getVerbose() 143 | { 144 | return verbose; 145 | } 146 | 147 | const char * channel:: 148 | getNcpConnectName() 149 | { 150 | return connectName; 151 | } 152 | 153 | void channel:: 154 | setNcpConnectName(const char *name) 155 | { 156 | if (name) { 157 | if (connectName) 158 | free((void *)connectName); 159 | connectName = strdup(name); 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /ncpd/ncp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #ifndef _ncp_h_ 22 | #define _ncp_h_ 23 | 24 | #include "config.h" 25 | 26 | #include 27 | 28 | #include "bufferstore.h" 29 | #include "linkchan.h" 30 | #include "ppsocket.h" 31 | 32 | class Link; 33 | class channel; 34 | 35 | #define NCP_DEBUG_LOG 1 36 | #define NCP_DEBUG_DUMP 2 37 | 38 | /** 39 | * Representation of a server process on the PC 40 | * A dummy which does not allow connects for now. 41 | */ 42 | class PcServer { 43 | public: 44 | PcServer(ppsocket *, std::string _name) { name = _name; } 45 | ~PcServer() {} 46 | bool clientConnect(int, int) { return false; } 47 | std::string getName() { return name; } 48 | PcServer *self() { return this; } 49 | private: 50 | std::string name; 51 | }; 52 | 53 | class ncp { 54 | public: 55 | ncp(const char *fname, int baud, unsigned short _verbose = 0); 56 | ~ncp(); 57 | 58 | int connect(channel *c); // returns channel, or -1 if failure 59 | void Register(channel *c); 60 | void RegisterAck(int, const char *); 61 | void disconnect(int channel); 62 | void send(int channel, bufferStore &a); 63 | void reset(); 64 | int maxLinks(); 65 | bool stuffToSend(); 66 | bool hasFailed(); 67 | bool gotLinkChannel(); 68 | 69 | PcServer *findPcServer(const char *name); 70 | void registerPcServer(ppsocket *skt, const char *name); 71 | void unregisterPcServer(PcServer *server); 72 | 73 | void setVerbose(unsigned short); 74 | unsigned short getVerbose(); 75 | short int getProtocolVersion(); 76 | int getSpeed(); 77 | 78 | private: 79 | friend class Link; 80 | 81 | enum c { MAX_LEN = 200, LAST_MESS = 1, NOT_LAST_MESS = 2 }; 82 | enum interControllerMessageType { 83 | // Inter controller message types 84 | NCON_MSG_DATA_XOFF=1, 85 | NCON_MSG_DATA_XON=2, 86 | NCON_MSG_CONNECT_TO_SERVER=3, 87 | NCON_MSG_CONNECT_RESPONSE=4, 88 | NCON_MSG_CHANNEL_CLOSED=5, 89 | NCON_MSG_NCP_INFO=6, 90 | NCON_MSG_CHANNEL_DISCONNECT=7, 91 | NCON_MSG_NCP_END=8 92 | }; 93 | enum protocolVersionType { PV_SERIES_5 = 6, PV_SERIES_3 = 3 }; 94 | void receive(bufferStore s); 95 | int getFirstUnusedChan(); 96 | bool isValidChannel(int); 97 | void decodeControlMessage(bufferStore &buff); 98 | void controlChannel(int chan, enum interControllerMessageType t, bufferStore &command); 99 | const char * ctrlMsgName(unsigned char); 100 | 101 | Link *l; 102 | unsigned short verbose; 103 | channel **channelPtr; 104 | bufferStore *messageList; 105 | int *remoteChanList; 106 | bool failed; 107 | short int protocolVersion; 108 | linkChan *lChan; 109 | int maxChannels; 110 | std::vector pcServers; 111 | int lastSentChannel; 112 | }; 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /po/Makevars: -------------------------------------------------------------------------------- 1 | # Makefile variables for PO directory in any package using GNU gettext. 2 | 3 | # Usually the message domain is the same as the package name. 4 | DOMAIN = $(PACKAGE) 5 | 6 | # These two variables depend on the location of this directory. 7 | subdir = po 8 | top_builddir = .. 9 | 10 | # These options get passed to xgettext. 11 | XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ \ 12 | --flag=_:1:pass-c-format \ 13 | --flag=N_:1:pass-c-format \ 14 | $${end_of_xgettext_options+} 15 | 16 | # This is the copyright holder that gets inserted into the header of the 17 | # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding 18 | # package. (Note that the msgstr strings, extracted from the package's 19 | # sources, belong to the copyright holder of the package.) Translators are 20 | # expected to transfer the copyright for their translations to this person 21 | # or entity, or to disclaim their copyright. The empty string stands for 22 | # the public domain; in this case the translators are expected to disclaim 23 | # their copyright. 24 | COPYRIGHT_HOLDER = plptools developers 25 | 26 | # This tells whether or not to prepend "GNU " prefix to the package 27 | # name that gets inserted into the header of the $(DOMAIN).pot file. 28 | # Possible values are "yes", "no", or empty. If it is empty, try to 29 | # detect it automatically by scanning the files in $(top_srcdir) for 30 | # "GNU packagename" string. 31 | PACKAGE_GNU = 32 | 33 | # This is the email address or URL to which the translators shall report 34 | # bugs in the untranslated strings: 35 | # - Strings which are not entire sentences, see the maintainer guidelines 36 | # in the GNU gettext documentation, section 'Preparing Strings'. 37 | # - Strings which use unclear terms or require additional context to be 38 | # understood. 39 | # - Strings which make invalid assumptions about notation of date, time or 40 | # money. 41 | # - Pluralisation problems. 42 | # - Incorrect English spelling. 43 | # - Incorrect formatting. 44 | # It can be your email address, or a mailing list address where translators 45 | # can write to without being subscribed, or the URL of a web page through 46 | # which the translators can contact you. 47 | MSGID_BUGS_ADDRESS = plptools-developers@lists.sourceforge.net 48 | 49 | # This is the list of locale categories, beyond LC_MESSAGES, for which the 50 | # message catalogs shall be used. It is usually empty. 51 | EXTRA_LOCALE_CATEGORIES = 52 | 53 | # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt' 54 | # context. Possible values are "yes" and "no". Set this to yes if the 55 | # package uses functions taking also a message context, like pgettext(), or 56 | # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument. 57 | USE_MSGCTXT = no 58 | 59 | # These options get passed to msgmerge. 60 | # Useful options are in particular: 61 | # --previous to keep previous msgids of translated messages, 62 | # --quiet to reduce the verbosity. 63 | MSGMERGE_OPTIONS = 64 | 65 | # These options get passed to msginit. 66 | # If you want to disable line wrapping when writing PO files, add 67 | # --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and 68 | # MSGINIT_OPTIONS. 69 | MSGINIT_OPTIONS = 70 | 71 | # This tells whether or not to regenerate a PO file when $(DOMAIN).pot 72 | # has changed. Possible values are "yes" and "no". Set this to no if 73 | # the POT file is checked in the repository and the version control 74 | # program ignores timestamps. 75 | PO_DEPENDS_ON_POT = yes 76 | 77 | # This tells whether or not to forcibly update $(DOMAIN).pot and 78 | # regenerate PO files on "make dist". Possible values are "yes" and 79 | # "no". Set this to no if the POT file and PO files are maintained 80 | # externally. 81 | DIST_DEPENDS_ON_UPDATE_PO = yes 82 | -------------------------------------------------------------------------------- /ncpd/linkchan.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #include "config.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "bufferstore.h" 28 | #include "bufferarray.h" 29 | 30 | #include "linkchan.h" 31 | #include "ncp.h" 32 | #include "main.h" 33 | 34 | using namespace std; 35 | 36 | linkChan::linkChan(ncp * _ncpController, int _ncpChannel):channel(_ncpController) 37 | { 38 | registerSer = 0x1234; 39 | if (_ncpChannel != -1) 40 | setNcpChannel(_ncpChannel); 41 | ncpConnect(); 42 | } 43 | 44 | void linkChan:: 45 | ncpDataCallback(bufferStore & a) 46 | { 47 | int len = a.getLen(); 48 | if (verbose & LINKCHAN_DEBUG_LOG) { 49 | lout << "linkchan: << msg "; 50 | if (verbose & LINKCHAN_DEBUG_DUMP) 51 | lout << a << endl; 52 | else 53 | lout << len << endl; 54 | } 55 | 56 | if ((len >= 5) && (a.getByte(0) == 1)) { 57 | char srvName[20]; 58 | unsigned int ser = a.getWord(1); 59 | int res = a.getWord(3); 60 | // int dontknow = a.getWord(5); 61 | bufferArray newStack; 62 | bufferStore se; 63 | 64 | 65 | strncpy(srvName, a.getString(7), 17); 66 | if (verbose & LINKCHAN_DEBUG_LOG) 67 | lout << "linkchan: received registerAck: ser=0x" << hex << setw(4) 68 | << setfill('0') << ser << " res=" << res << " srvName=\"" 69 | << srvName << "\"" << endl; 70 | 71 | while (!registerStack.empty()) { 72 | se = registerStack.pop(); 73 | if (se.getWord(0) == ser) { 74 | if (verbose & LINKCHAN_DEBUG_LOG) 75 | lout << "linkchan: found ser=0x" << hex << setw(4) << 76 | setfill('0') << se.getWord(0) << 77 | " on stack -> callBack to waiting chan" << endl; 78 | if (strlen(srvName) < 4) 79 | strcat(srvName, ".*"); 80 | ncpDoRegisterAck((int)se.getWord(2), srvName); 81 | } else 82 | newStack += se; 83 | } 84 | registerStack = newStack; 85 | return; 86 | } 87 | lerr << "linkchan: unknown message " << a.getByte(0) << endl; 88 | } 89 | 90 | const char *linkChan:: 91 | getNcpRegisterName() 92 | { 93 | return "LINK"; 94 | } 95 | 96 | void linkChan:: 97 | ncpConnectAck() 98 | { 99 | if (verbose & LINKCHAN_DEBUG_LOG) 100 | lout << "linkchan: << cack" << endl; 101 | } 102 | 103 | void linkChan:: 104 | ncpConnectTerminate() 105 | { 106 | if (verbose & LINKCHAN_DEBUG_LOG) 107 | lout << "linkchan: << ctrm" << endl; 108 | terminateWhenAsked(); 109 | } 110 | 111 | void linkChan:: 112 | ncpConnectNak() 113 | { 114 | ncpConnectTerminate(); 115 | } 116 | 117 | void linkChan:: 118 | Register(channel *ch) 119 | { 120 | bufferStore a; 121 | bufferStore stack; 122 | 123 | stack.addWord(registerSer); 124 | stack.addWord(ch->getNcpChannel()); 125 | registerStack += stack; 126 | a.addByte(0); 127 | a.addWord(registerSer++); 128 | a.addString(ch->getNcpRegisterName()); 129 | a.addByte(0); 130 | ncpSend(a); 131 | } 132 | -------------------------------------------------------------------------------- /lib/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #ifndef _LOG_H_ 22 | #define _LOG_H_ 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | /** 30 | * A streambuffer, logging via syslog 31 | * 32 | * logbuf can be used, if you want to use syslog for 33 | * logging but don't want to change all your nice 34 | * C++-style output statements in your code. 35 | * 36 | * Here is an example showing the usage of logbuf: 37 | * 38 | *
 39 |  *	openlog("myDaemon", LOG_CONS|LOG_PID, LOG_DAEMON);
 40 |  *	logbuf ebuf(LOG_ERR, 2);
 41 |  *	ostream lerr(&ebuf);
 42 |  *
 43 |  *	... some code ...
 44 |  *
 45 |  *	lerr << "Whoops, got an error" << endl;
 46 |  * 
47 | * 48 | * The second optional argument of the constructor can be used 49 | * to switch the output destination between syslog and some 50 | * file. If it is omitted or set to -1, logging can be switched on 51 | * or off. The initial state is on. 52 | */ 53 | class logbuf : public std::streambuf { 54 | public: 55 | 56 | /** 57 | * Constructs a new instance. 58 | * 59 | * @param loglevel The log level for this instance. 60 | * see syslog(3) for symbolic names to use. 61 | * @param fd An optional file descriptor to use 62 | * if switched off. 63 | */ 64 | logbuf(int loglevel, int fd = -1); 65 | 66 | /** 67 | * Switches loggin on or off. 68 | * 69 | * @param newstate The desired state. 70 | */ 71 | void setOn(bool newstate) { _on = newstate; } 72 | 73 | /** 74 | * Modifies the loglevel of this instance. 75 | * 76 | * @param newlevel The new loglevel. 77 | */ 78 | void setLevel(int newlevel) { _level = newlevel; } 79 | 80 | /** 81 | * Retrieve the current state. 82 | * 83 | * @returns The current state. 84 | */ 85 | bool on() { return _on; } 86 | 87 | /** 88 | * Retrieves the current loglevel. 89 | * 90 | * @returns The current loglevel. 91 | */ 92 | int level() { return _level; } 93 | 94 | /** 95 | * Called by the associated 96 | * ostream to write a character. 97 | * Stores the character in a buffer 98 | * and calls syslog(level, buffer) 99 | * whenever a LF is seen. 100 | */ 101 | int overflow(int c = EOF); 102 | 103 | private: 104 | 105 | /** 106 | * Pointer to next char in buffer. 107 | */ 108 | char *ptr; 109 | 110 | /** 111 | * Current length of buffer. 112 | */ 113 | unsigned int len; 114 | 115 | /** 116 | * The log level to use with syslog. 117 | */ 118 | int _level; 119 | 120 | /** 121 | * File descriptor to use when switched off. 122 | * If this is -1, don't output anything. 123 | */ 124 | int _fd; 125 | 126 | /** 127 | * Log flag. 128 | */ 129 | bool _on; 130 | 131 | /** 132 | * The internal buffer for holding 133 | * messages. 134 | */ 135 | char buf[1024]; 136 | }; 137 | 138 | #endif 139 | -------------------------------------------------------------------------------- /sisinstall/psion.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #include "config.h" 21 | 22 | #include "psion.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | #include 37 | 38 | Psion::~Psion() 39 | { 40 | disconnect(); 41 | } 42 | 43 | bool 44 | Psion::connect() 45 | { 46 | int sockNum = DPORT; 47 | 48 | #if 0 49 | setlocale (LC_ALL, ""); 50 | textdomain(PACKAGE); 51 | #endif 52 | 53 | struct servent *se = getservbyname("psion", "tcp"); 54 | endservent(); 55 | if (se != 0L) 56 | sockNum = ntohs(se->s_port); 57 | 58 | #if 0 59 | // Command line parameter processing 60 | if ((argc > 2) && !strcmp(argv[1], "-p")) { 61 | sockNum = atoi(argv[2]); 62 | argc -= 2; 63 | for (int i = 1; i < argc; i++) 64 | argv[i] = argv[i + 2]; 65 | } 66 | #endif 67 | 68 | m_skt = new ppsocket(); 69 | if (!m_skt->connect(NULL, sockNum)) { 70 | return false; 71 | } 72 | m_skt2 = new ppsocket(); 73 | if (!m_skt2->connect(NULL, sockNum)) { 74 | return false; 75 | } 76 | m_rfsvFactory = new rfsvfactory(m_skt); 77 | m_rpcsFactory = new rpcsfactory(m_skt2); 78 | m_rfsv = m_rfsvFactory->create(true); 79 | m_rpcs = m_rpcsFactory->create(true); 80 | if ((m_rfsv != NULL) && (m_rpcs != NULL)) 81 | return true; 82 | return false; 83 | } 84 | 85 | Enum 86 | Psion::copyFromPsion(const char * const from, int fd, 87 | cpCallback_t func) 88 | { 89 | return m_rfsv->copyFromPsion(from, fd, func); 90 | } 91 | 92 | Enum 93 | Psion::copyToPsion(const char * const from, const char * const to, 94 | void *, cpCallback_t func) 95 | { 96 | Enum res; 97 | res = m_rfsv->copyToPsion(from, to, NULL, func); 98 | // printf("Returned to Psion\n"); 99 | return res; 100 | } 101 | 102 | Enum 103 | Psion::devinfo(const char drive, PlpDrive& plpDrive) 104 | { 105 | return m_rfsv->devinfo(drive, plpDrive); 106 | } 107 | 108 | Enum 109 | Psion::devlist(uint32_t& devbits) 110 | { 111 | Enum res; 112 | res = m_rfsv->devlist(devbits); 113 | return res; 114 | } 115 | 116 | Enum 117 | Psion::dir(const char* dir, PlpDir& files) 118 | { 119 | return m_rfsv->dir(dir, files); 120 | } 121 | 122 | bool 123 | Psion::dirExists(const char* name) 124 | { 125 | rfsvDirhandle handle; 126 | Enum res; 127 | bool exists = false; 128 | res = m_rfsv->opendir(rfsv::PSI_A_ARCHIVE, name, handle); 129 | if (res == rfsv::E_PSI_GEN_NONE) 130 | exists = true; 131 | res = m_rfsv->closedir(handle); 132 | return exists; 133 | } 134 | 135 | void 136 | Psion::disconnect() 137 | { 138 | delete m_rfsv; 139 | delete m_rpcs; 140 | delete m_skt; 141 | delete m_skt2; 142 | delete m_rfsvFactory; 143 | delete m_rpcsFactory; 144 | } 145 | 146 | Enum 147 | Psion::mkdir(const char* dir) 148 | { 149 | return m_rfsv->mkdir(dir); 150 | } 151 | 152 | void 153 | Psion::remove(const char* name) 154 | { 155 | m_rfsv->remove(name); 156 | } 157 | 158 | -------------------------------------------------------------------------------- /lib/bufferarray.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 2000, 2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #include "config.h" 22 | 23 | #include "bufferstore.h" 24 | #include "bufferarray.h" 25 | 26 | bufferArray::bufferArray() 27 | { 28 | len = 0; 29 | lenAllocd = ALLOC_MIN; 30 | buff = new bufferStore[lenAllocd]; 31 | } 32 | 33 | bufferArray::bufferArray(const bufferArray & a) 34 | { 35 | len = a.len; 36 | lenAllocd = a.lenAllocd; 37 | buff = new bufferStore[lenAllocd]; 38 | for (int i = 0; i < len; i++) 39 | buff[i] = a.buff[i]; 40 | } 41 | 42 | bufferArray::~bufferArray() 43 | { 44 | delete []buff; 45 | } 46 | 47 | bufferStore bufferArray:: 48 | pop() 49 | { 50 | bufferStore ret; 51 | if (len > 0) { 52 | ret = buff[0]; 53 | len--; 54 | for (long i = 0; i < len; i++) { 55 | buff[i] = buff[i + 1]; 56 | } 57 | } 58 | return ret; 59 | } 60 | 61 | void bufferArray:: 62 | append(const bufferStore & b) 63 | { 64 | if (len == lenAllocd) { 65 | lenAllocd += ALLOC_MIN; 66 | bufferStore *nb = new bufferStore[lenAllocd]; 67 | for (long i = 0; i < len; i++) { 68 | nb[i] = buff[i]; 69 | } 70 | delete []buff; 71 | buff = nb; 72 | } 73 | buff[len++] = b; 74 | } 75 | 76 | void bufferArray:: 77 | push(const bufferStore & b) 78 | { 79 | if (len == lenAllocd) 80 | lenAllocd += ALLOC_MIN; 81 | bufferStore *nb = new bufferStore[lenAllocd]; 82 | for (long i = len; i > 0; i--) { 83 | nb[i] = buff[i - 1]; 84 | } 85 | nb[0] = b; 86 | delete[]buff; 87 | buff = nb; 88 | len++; 89 | } 90 | 91 | long bufferArray:: 92 | length(void) 93 | { 94 | return len; 95 | } 96 | 97 | void bufferArray:: 98 | clear(void) 99 | { 100 | len = 0; 101 | lenAllocd = ALLOC_MIN; 102 | delete []buff; 103 | buff = new bufferStore[lenAllocd]; 104 | } 105 | 106 | bufferArray &bufferArray:: 107 | operator =(const bufferArray & a) 108 | { 109 | delete []buff; 110 | len = a.len; 111 | lenAllocd = a.lenAllocd; 112 | buff = new bufferStore[lenAllocd]; 113 | for (int i = 0; i < len; i++) 114 | buff[i] = a.buff[i]; 115 | return *this; 116 | } 117 | 118 | bufferStore &bufferArray:: 119 | operator [](const unsigned long index) 120 | { 121 | return buff[index]; 122 | } 123 | 124 | bufferArray bufferArray:: 125 | operator +(const bufferStore &s) 126 | { 127 | bufferArray res = *this; 128 | res += s; 129 | return res; 130 | } 131 | 132 | bufferArray bufferArray:: 133 | operator +(const bufferArray &a) 134 | { 135 | bufferArray res = *this; 136 | res += a; 137 | return res; 138 | } 139 | 140 | bufferArray &bufferArray:: 141 | operator +=(const bufferArray &a) 142 | { 143 | lenAllocd += a.lenAllocd; 144 | bufferStore *nb = new bufferStore[lenAllocd]; 145 | for (int i = 0; i < len; i++) 146 | nb[len + i] = buff[i]; 147 | for (int i = 0; i < a.len; i++) 148 | nb[len + i] = a.buff[i]; 149 | len += a.len; 150 | delete []buff; 151 | buff = nb; 152 | return *this; 153 | } 154 | 155 | bufferArray &bufferArray:: 156 | operator +=(const bufferStore &s) 157 | { 158 | append(s); 159 | return *this; 160 | } 161 | -------------------------------------------------------------------------------- /lib/wprt.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999-2001 Fritz Elfert 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #include "config.h" 21 | 22 | #include "wprt.h" 23 | #include "bufferstore.h" 24 | #include "ppsocket.h" 25 | #include "bufferarray.h" 26 | #include "Enum.h" 27 | 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | using namespace std; 34 | 35 | wprt::wprt(ppsocket * _skt) 36 | { 37 | skt = _skt; 38 | reset(); 39 | } 40 | 41 | wprt::~wprt() 42 | { 43 | skt->closeSocket(); 44 | } 45 | 46 | // 47 | // public common API 48 | // 49 | void wprt:: 50 | reconnect(void) 51 | { 52 | //skt->closeSocket(); 53 | skt->reconnect(); 54 | reset(); 55 | } 56 | 57 | void wprt:: 58 | reset(void) 59 | { 60 | bufferStore a; 61 | status = rfsv::E_PSI_FILE_DISC; 62 | a.addStringT(getConnectName()); 63 | if (skt->sendBufferStore(a)) { 64 | if (skt->getBufferStore(a) == 1) { 65 | if (!strcmp(a.getString(0), "Ok")) 66 | status = rfsv::E_PSI_GEN_NONE; 67 | } 68 | } 69 | } 70 | 71 | Enum wprt:: 72 | getStatus(void) 73 | { 74 | return status; 75 | } 76 | 77 | const char *wprt:: 78 | getConnectName(void) 79 | { 80 | return "SYS$WPRT"; 81 | } 82 | 83 | // 84 | // protected internals 85 | // 86 | bool wprt:: 87 | sendCommand(enum commands cc, bufferStore & data) 88 | { 89 | if (status == rfsv::E_PSI_FILE_DISC) { 90 | reconnect(); 91 | if (status == rfsv::E_PSI_FILE_DISC) 92 | return false; 93 | } 94 | bool result; 95 | bufferStore a; 96 | a.addByte(cc); 97 | a.addBuff(data); 98 | result = skt->sendBufferStore(a); 99 | if (!result) { 100 | reconnect(); 101 | result = skt->sendBufferStore(a); 102 | if (!result) 103 | status = rfsv::E_PSI_FILE_DISC; 104 | } 105 | return result; 106 | } 107 | 108 | Enum wprt:: 109 | initPrinter() { 110 | Enum ret; 111 | 112 | bufferStore a; 113 | a.addByte(2); // Major printer version 114 | a.addByte(0); // Minor printer version 115 | sendCommand(WPRT_INIT, a); 116 | if ((ret = getResponse(a)) != rfsv::E_PSI_GEN_NONE) 117 | cerr << "WPRT ERR:" << a << endl; 118 | else { 119 | if (a.getLen() != 3) 120 | ret = rfsv::E_PSI_GEN_FAIL; 121 | if ((a.getByte(0) != 0) || (a.getWord(1) != 2)) 122 | ret = rfsv::E_PSI_GEN_FAIL; 123 | } 124 | return ret; 125 | } 126 | 127 | Enum wprt:: 128 | getData(bufferStore &buf) { 129 | Enum ret; 130 | 131 | sendCommand(WPRT_GET, buf); 132 | if ((ret = getResponse(buf)) != rfsv::E_PSI_GEN_NONE) 133 | cerr << "WPRT ERR:" << buf << endl; 134 | return ret; 135 | } 136 | 137 | Enum wprt:: 138 | cancelJob() { 139 | Enum ret; 140 | bufferStore a; 141 | 142 | sendCommand(WPRT_CANCEL, a); 143 | if ((ret = getResponse(a)) != rfsv::E_PSI_GEN_NONE) 144 | cerr << "WPRT ERR:" << a << endl; 145 | return ret; 146 | } 147 | 148 | bool wprt:: 149 | stop() { 150 | bufferStore a; 151 | return sendCommand(WPRT_STOP, a); 152 | } 153 | 154 | Enum wprt:: 155 | getResponse(bufferStore & data) 156 | { 157 | Enum ret = rfsv::E_PSI_GEN_NONE; 158 | if (skt->getBufferStore(data) == 1) 159 | return ret; 160 | else 161 | status = rfsv::E_PSI_FILE_DISC; 162 | return status; 163 | } 164 | -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- 1 | !/ax_*.m4 2 | /*.m4/00gnulib.m4 3 | /codeset.m4 4 | /extern-inline.m4 5 | /fcntl-o.m4 6 | /gettext.m4 7 | /gnulib-cache.m4 8 | /gnulib-common.m4 9 | /gnulib-comp.m4 10 | /gnulib-tool.m4 11 | /iconv.m4 12 | /intdiv0.m4 13 | /intl.m4 14 | /intldir.m4 15 | /intlmacosx.m4 16 | /intmax.m4 17 | /inttypes_h.m4 18 | /inttypes-pri.m4 19 | /lcmessage.m4 20 | /lib-ld.m4 21 | /lib-link.m4 22 | /lib-prefix.m4 23 | /libtool.m4 24 | /lock.m4 25 | /ltoptions.m4 26 | /ltsugar.m4 27 | /ltversion.m4 28 | /lt~obsolete.m4 29 | /nls.m4 30 | /po.m4 31 | /printf-posix.m4 32 | /progtest.m4 33 | /size_max.m4 34 | /stdint_h.m4 35 | /threadlib.m4 36 | /visibility.m4 37 | /xsize.m4 38 | /wchar_t.m4 39 | /wint_t.m4 40 | /zzgnulib.m4 41 | /00gnulib.m4 42 | /largefile.m4 43 | /absolute-header.m4 44 | /errno_h.m4 45 | /extensions.m4 46 | /hostent.m4 47 | /include_next.m4 48 | /msvc-inval.m4 49 | /msvc-nothrow.m4 50 | /off_t.m4 51 | /pid_t.m4 52 | /socketlib.m4 53 | /sockets.m4 54 | /socklen.m4 55 | /sockpfaf.m4 56 | /ssize_t.m4 57 | /stdalign.m4 58 | /stddef_h.m4 59 | /sys_socket_h.m4 60 | /sys_types_h.m4 61 | /sys_uio_h.m4 62 | /unistd_h.m4 63 | /warn-on-use.m4 64 | /manywarnings-c++.m4 65 | /manywarnings.m4 66 | /warnings.m4 67 | /locale_h.m4 68 | /alloca.m4 69 | /assert_h.m4 70 | /atomic-cas.m4 71 | /c-bool.m4 72 | /dup2.m4 73 | /gettimeofday.m4 74 | /limits-h.m4 75 | /multiarch.m4 76 | /nanosleep.m4 77 | /pselect.m4 78 | /pthread-cond.m4 79 | /pthread-mutex.m4 80 | /pthread-once.m4 81 | /pthread-rwlock.m4 82 | /pthread-spin.m4 83 | /pthread-thread.m4 84 | /pthread-tss.m4 85 | /pthread_h.m4 86 | /pthread_mutex_timedlock.m4 87 | /pthread_sigmask.m4 88 | /raise.m4 89 | /sched_h.m4 90 | /select.m4 91 | /signal_h.m4 92 | /signalblocking.m4 93 | /std-gnu11.m4 94 | /stdint.m4 95 | /sys_select_h.m4 96 | /sys_time_h.m4 97 | /time_h.m4 98 | /chdir-long.m4 99 | /close.m4 100 | /closedir.m4 101 | /d-ino.m4 102 | /dirent_h.m4 103 | /dirfd.m4 104 | /double-slash-root.m4 105 | /dup.m4 106 | /eealloc.m4 107 | /error.m4 108 | /error_h.m4 109 | /fchdir.m4 110 | /fcntl.m4 111 | /fcntl_h.m4 112 | /fdopendir.m4 113 | /filenamecat.m4 114 | /free.m4 115 | /fstat.m4 116 | /fstatat.m4 117 | /getcwd-abort-bug.m4 118 | /getcwd-path-max.m4 119 | /getcwd.m4 120 | /getdtablesize.m4 121 | /getpagesize.m4 122 | /getprogname.m4 123 | /inttypes.m4 124 | /locale-fr.m4 125 | /lstat.m4 126 | /malloc.m4 127 | /malloca.m4 128 | /memchr.m4 129 | /mempcpy.m4 130 | /memrchr.m4 131 | /mmap-anon.m4 132 | /mode_t.m4 133 | /musl.m4 134 | /open-cloexec.m4 135 | /open-slash.m4 136 | /open.m4 137 | /openat.m4 138 | /opendir.m4 139 | /pathmax.m4 140 | /pipe.m4 141 | /readdir.m4 142 | /realloc.m4 143 | /rewinddir.m4 144 | /save-cwd.m4 145 | /stat-time.m4 146 | /stat.m4 147 | /stdio_h.m4 148 | /stdlib_h.m4 149 | /strdup.m4 150 | /strerror.m4 151 | /string_h.m4 152 | /sys_stat_h.m4 153 | /unistd-safer.m4 154 | /vararrays.m4 155 | /wchar_h.m4 156 | /calloc.m4 157 | /exponentd.m4 158 | /float_h.m4 159 | /intmax_t.m4 160 | /locale-ja.m4 161 | /locale-zh.m4 162 | /math_h.m4 163 | /mbrtowc.m4 164 | /mbstate_t.m4 165 | /minmax.m4 166 | /printf.m4 167 | /reallocarray.m4 168 | /stdarg.m4 169 | /vasnprintf.m4 170 | /vasprintf.m4 171 | /xalloc.m4 172 | /xvasprintf.m4 173 | /exponentf.m4 174 | /exponentl.m4 175 | /fpieee.m4 176 | /frexp.m4 177 | /frexpl.m4 178 | /isnand.m4 179 | /isnanf.m4 180 | /isnanl.m4 181 | /ldexpl.m4 182 | /nocrash.m4 183 | /printf-frexp.m4 184 | /printf-frexpl.m4 185 | /signbit.m4 186 | /vsnprintf-posix.m4 187 | /vsnprintf.m4 188 | /__inline.m4 189 | /btowc.m4 190 | /builtin-expect.m4 191 | /ctype_h.m4 192 | /flexmember.m4 193 | /fnmatch.m4 194 | /fnmatch_h.m4 195 | /inline.m4 196 | /isblank.m4 197 | /iswblank.m4 198 | /iswctype.m4 199 | /iswdigit.m4 200 | /iswpunct.m4 201 | /iswxdigit.m4 202 | /libunistring-base.m4 203 | /localcharset.m4 204 | /mbrtoc32.m4 205 | /mbsinit.m4 206 | /mbsrtowcs.m4 207 | /mbtowc.m4 208 | /setlocale_null.m4 209 | /strnlen.m4 210 | /uchar_h.m4 211 | /unicase_h.m4 212 | /unictype_h.m4 213 | /uninorm_h.m4 214 | /wctype.m4 215 | /wctype_h.m4 216 | /wmemchr.m4 217 | /wmempcpy.m4 218 | /getdelim.m4 219 | /getline.m4 220 | /langinfo_h.m4 221 | /localeconv.m4 222 | /nl_langinfo.m4 223 | /pthread_rwlock_rdlock.m4 224 | /regex.m4 225 | /rpmatch.m4 226 | /wcrtomb.m4 227 | /yesno.m4 228 | /servent.m4 229 | /strsep.m4 230 | -------------------------------------------------------------------------------- /m4/ax_check_gnu_make.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # https://www.gnu.org/software/autoconf-archive/ax_check_gnu_make.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_GNU_MAKE([run-if-true],[run-if-false]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # This macro searches for a GNU version of make. If a match is found: 12 | # 13 | # * The makefile variable `ifGNUmake' is set to the empty string, otherwise 14 | # it is set to "#". This is useful for including a special features in a 15 | # Makefile, which cannot be handled by other versions of make. 16 | # * The makefile variable `ifnGNUmake' is set to #, otherwise 17 | # it is set to the empty string. This is useful for including a special 18 | # features in a Makefile, which can be handled 19 | # by other versions of make or to specify else like clause. 20 | # * The variable `_cv_gnu_make_command` is set to the command to invoke 21 | # GNU make if it exists, the empty string otherwise. 22 | # * The variable `ax_cv_gnu_make_command` is set to the command to invoke 23 | # GNU make by copying `_cv_gnu_make_command`, otherwise it is unset. 24 | # * If GNU Make is found, its version is extracted from the output of 25 | # `make --version` as the last field of a record of space-separated 26 | # columns and saved into the variable `ax_check_gnu_make_version`. 27 | # * Additionally if GNU Make is found, run shell code run-if-true 28 | # else run shell code run-if-false. 29 | # 30 | # Here is an example of its use: 31 | # 32 | # Makefile.in might contain: 33 | # 34 | # # A failsafe way of putting a dependency rule into a makefile 35 | # $(DEPEND): 36 | # $(CC) -MM $(srcdir)/*.c > $(DEPEND) 37 | # 38 | # @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND))) 39 | # @ifGNUmake@ include $(DEPEND) 40 | # @ifGNUmake@ else 41 | # fallback code 42 | # @ifGNUmake@ endif 43 | # 44 | # Then configure.in would normally contain: 45 | # 46 | # AX_CHECK_GNU_MAKE() 47 | # AC_OUTPUT(Makefile) 48 | # 49 | # Then perhaps to cause gnu make to override any other make, we could do 50 | # something like this (note that GNU make always looks for GNUmakefile 51 | # first): 52 | # 53 | # if ! test x$_cv_gnu_make_command = x ; then 54 | # mv Makefile GNUmakefile 55 | # echo .DEFAULT: > Makefile ; 56 | # echo \ $_cv_gnu_make_command \$@ >> Makefile; 57 | # fi 58 | # 59 | # Then, if any (well almost any) other make is called, and GNU make also 60 | # exists, then the other make wraps the GNU make. 61 | # 62 | # LICENSE 63 | # 64 | # Copyright (c) 2008 John Darrington 65 | # Copyright (c) 2015 Enrico M. Crisostomo 66 | # 67 | # Copying and distribution of this file, with or without modification, are 68 | # permitted in any medium without royalty provided the copyright notice 69 | # and this notice are preserved. This file is offered as-is, without any 70 | # warranty. 71 | 72 | #serial 12 73 | 74 | AC_DEFUN([AX_CHECK_GNU_MAKE],dnl 75 | [AC_PROG_AWK 76 | AC_CACHE_CHECK([for GNU make],[_cv_gnu_make_command],[dnl 77 | _cv_gnu_make_command="" ; 78 | dnl Search all the common names for GNU make 79 | for a in "$MAKE" make gmake gnumake ; do 80 | if test -z "$a" ; then continue ; fi ; 81 | if "$a" --version 2> /dev/null | grep GNU 2>&1 > /dev/null ; then 82 | _cv_gnu_make_command=$a ; 83 | AX_CHECK_GNU_MAKE_HEADLINE=$("$a" --version 2> /dev/null | grep "GNU Make") 84 | ax_check_gnu_make_version=$(echo ${AX_CHECK_GNU_MAKE_HEADLINE} | ${AWK} -F " " '{ print $(NF); }') 85 | break ; 86 | fi 87 | done ;]) 88 | dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise 89 | AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifGNUmake], ["#"])], [AS_VAR_SET([ifGNUmake], [""])]) 90 | AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifnGNUmake], [""])], [AS_VAR_SET([ifnGNUmake], ["#"])]) 91 | AS_VAR_IF([_cv_gnu_make_command], [""], [AS_UNSET(ax_cv_gnu_make_command)], [AS_VAR_SET([ax_cv_gnu_make_command], [${_cv_gnu_make_command}])]) 92 | AS_VAR_IF([_cv_gnu_make_command], [""],[$2],[$1]) 93 | AC_SUBST([ifGNUmake]) 94 | AC_SUBST([ifnGNUmake]) 95 | ]) 96 | -------------------------------------------------------------------------------- /lib/sisfile.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | */ 19 | #include "config.h" 20 | 21 | #include "sisfile.h" 22 | #include "sislangrecord.h" 23 | #include "sisfilerecord.h" 24 | #include "sisreqrecord.h" 25 | #include "plpintl.h" 26 | 27 | #include 28 | 29 | SISFile::SISFile() 30 | { 31 | m_buf = 0; 32 | m_ownBuffer = false; 33 | } 34 | 35 | SISFile::~SISFile() 36 | { 37 | if (m_ownBuffer) 38 | delete[] m_buf; 39 | } 40 | 41 | SisRC 42 | SISFile::compareApp(SISFile* other) 43 | { 44 | return m_header.compareApp(&other->m_header); 45 | } 46 | 47 | SisRC 48 | SISFile::fillFrom(uint8_t* buf, off_t len) 49 | { 50 | m_end = 0; 51 | int ix = 0; 52 | m_buf = buf; 53 | SisRC rc = m_header.fillFrom(buf, &ix, len); 54 | if (rc != SIS_OK) 55 | { 56 | printf(_("Could not read header, rc = %d\n"), rc); 57 | return rc; 58 | } 59 | if (logLevel >= 2) 60 | printf(_("Ate header, got ix = %d\n"), ix); 61 | int n; 62 | 63 | // Read languages. 64 | // 65 | n = m_header.m_nlangs; 66 | m_langRecords = new SISLangRecord[n]; 67 | ix = m_header.m_languagePtr; 68 | for (int i = 0; i < n; ++i) 69 | { 70 | if (ix >= len) 71 | return SIS_TRUNCATED; 72 | rc = m_langRecords[i].fillFrom(buf, &ix, len); 73 | if (rc != SIS_OK) 74 | { 75 | printf(_("Problem reading language record %d, rc = %d.\n"), i, rc); 76 | return rc; 77 | } 78 | } 79 | updateEnd(ix); 80 | 81 | // Read requisites. 82 | // 83 | n = m_header.m_nreqs; 84 | m_reqRecords = new SISReqRecord[n]; 85 | ix = m_header.m_reqPtr; 86 | for (int i = 0; i < n; ++i) 87 | { 88 | if (ix >= len) 89 | return SIS_TRUNCATED; 90 | rc = m_reqRecords[i].fillFrom(buf, &ix, len, this); 91 | if (rc != SIS_OK) 92 | { 93 | printf(_("Problem reading requisite record %d, rc = %d.\n"), i, rc); 94 | return rc; 95 | } 96 | } 97 | updateEnd(ix); 98 | 99 | // Read component names, by language. 100 | // 101 | ix = m_header.m_componentPtr; 102 | rc = m_componentRecord.fillFrom(buf, &ix, len, this); 103 | updateEnd(ix); 104 | updateEnd(m_componentRecord.getLastEnd()); 105 | if (rc != SIS_OK) 106 | { 107 | printf(_("Problem reading the name record, rc = %d.\n"), rc); 108 | return rc; 109 | } 110 | 111 | // Read files. 112 | // 113 | n = m_header.m_nfiles; 114 | m_fileRecords = new SISFileRecord[n]; 115 | ix = m_header.m_filesPtr; 116 | SisRC myrc = SIS_OK; 117 | for (int i = 0; i < n; ++i) 118 | { 119 | if (ix >= len) 120 | return SIS_TRUNCATED; 121 | rc = m_fileRecords[i].fillFrom(buf, &ix, len, this); 122 | if (rc != SIS_OK) 123 | { 124 | printf(_("Problem reading file record %d, rc = %d.\n"), i, rc); 125 | if (rc == SIS_TRUNCATEDDATA) 126 | myrc = rc; 127 | else 128 | return rc; 129 | } 130 | } 131 | updateEnd(ix); 132 | 133 | return SIS_OK; 134 | } 135 | 136 | int 137 | SISFile::getLanguage() 138 | { 139 | return m_header.m_installationLanguage; 140 | } 141 | 142 | LangTableEntry* 143 | SISFile::getLanguage(int i) 144 | { 145 | return &langTable[m_langRecords[i].m_lang]; 146 | } 147 | 148 | uint8_t* 149 | SISFile::getName() 150 | { 151 | return m_componentRecord.getName(m_header.m_installationLanguage); 152 | } 153 | 154 | void 155 | SISFile::setDrive(char drive) 156 | { 157 | m_header.setDrive(drive); 158 | } 159 | 160 | void 161 | SISFile::setFiles(int nFiles) 162 | { 163 | m_header.setFiles(nFiles); 164 | } 165 | 166 | void 167 | SISFile::setLanguage(int lang) 168 | { 169 | m_header.m_installationLanguage = lang; 170 | } 171 | 172 | void 173 | SISFile::updateEnd(uint32_t pos) 174 | { 175 | if (m_end < pos) 176 | m_end = pos; 177 | } 178 | -------------------------------------------------------------------------------- /bootstrap.conf: -------------------------------------------------------------------------------- 1 | # bootstrap.conf 2 | # 3 | # Copyright (c) 2024 Reuben Thomas 4 | # 5 | # This file is part of plptools. 6 | # 7 | # This program is free software; you can redistribute it and/or modify it 8 | # under the terms of the GNU General Public License as published by the Free 9 | # Software Foundation; either version 3, or (at your option) any later 10 | # version. 11 | # 12 | # This program is distributed in the hope that it will be useful, but 13 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 | # for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License along 18 | # with this program; if not, see . 19 | 20 | ## -------------- ## 21 | ## Configuration. ## 22 | ## -------------- ## 23 | 24 | # File that should exist relative to the top directory of a checked out 25 | # hierarchy, but not in a distribution tarball. 26 | checkout_only_file=.gitignore 27 | 28 | # List of programs, minimum versions, and software urls required to 29 | # bootstrap, maintain and release. 30 | 31 | # Build prerequisites 32 | buildreq=' 33 | git 1.5.5 https://git-scm.com 34 | gpg 1.4.11 https://www.gnupg.org 35 | perl 5.5 https://perl.com 36 | tar - https://www.gnu.org/s/tar 37 | pkg-config - https://www.freedesktop.org/wiki/Software/pkg-config/ 38 | ' 39 | 40 | # Non-default gnulib directory options. 41 | source_base=libgnu 42 | local_gl_path=gl:gl-mod/bootstrap 43 | gnulib_git_submodules=gl-mod/bootstrap 44 | gnulib_clone_since=2024-02-26 45 | 46 | # Additional gnulib-tool options to use. 47 | gnulib_tool_options=' 48 | --no-libtool 49 | --no-changelog 50 | ' 51 | 52 | # gnulib modules used by this package. 53 | gnulib_modules=' 54 | bootstrap 55 | fnmatch 56 | getcwd 57 | hostent 58 | ignore-value 59 | largefile 60 | locale 61 | manywarnings 62 | pthread 63 | socket 64 | servent 65 | string-buffer 66 | strsep 67 | xalloc 68 | xvasprintf 69 | yesno 70 | ' 71 | 72 | # Extra gnulib files that are not in modules, which override files of 73 | # the same name installed by other bootstrap tools. 74 | gnulib_non_module_files="$gnulib_non_module_files"' 75 | ' 76 | 77 | 78 | ## -------------------- ## 79 | ## Resource management. ## 80 | ## -------------------- ## 81 | 82 | # require_source_base 83 | # ------------------- 84 | # Ensure any source_base setting in this file or `gnulib-cache.m4` 85 | # is used for $source_base. If both are the empty string before 86 | # call this function, $source_base will still be the empty string 87 | # afterwards. Use ${source_base-lib} if you are looking at files 88 | # inside the gnulib directory. 89 | require_source_base=plptools_require_source_base 90 | plptools_require_source_base () 91 | { 92 | $debug_cmd 93 | 94 | test -n "$source_base" || { 95 | $require_gnulib_cache 96 | $require_macro_dir 97 | 98 | func_extract_trace "gl_SOURCE_BASE" "$gnulib_cache" 99 | source_base="$func_extract_trace_result" 100 | 101 | test -n "$source_base" && func_verbose "source_base='$source_base'" 102 | } 103 | 104 | require_source_base=: 105 | } 106 | 107 | # Copyright holder 108 | copyright_holder="plptools developers" 109 | 110 | ## --------------- ## 111 | ## Hook functions. ## 112 | ## --------------- ## 113 | 114 | # plptools_ignore_gnulib_ignore 115 | # ---------------------------- 116 | # gnulib-tool updates m4/.gitignore and lib/.gitignore, and keeping 117 | # generated files under version control does not make sense. Since 118 | # lib is entirely ignored, we only need to prepopulate the m4 ignore 119 | # files with generated files not tracked by gnulib-tool. 120 | plptools_ignore_gnulib_ignore () 121 | { 122 | $debug_cmd 123 | 124 | $require_macro_dir 125 | 126 | if test -f "$macro_dir/.gitignore" ; then 127 | : 128 | else 129 | func_verbose "creating initial \`$macro_dir/.gitignore'" 130 | cat > $macro_dir/.gitignore <<\EOF 131 | # files created by bootstrap, but that gnulib doesn't track 132 | *~ 133 | /.gitignore 134 | /gnulib-comp.m4 135 | EOF 136 | fi 137 | } 138 | func_add_hook func_prep plptools_ignore_gnulib_ignore 139 | 140 | 141 | # Local variables: 142 | # mode: shell-script 143 | # sh-indentation: 2 144 | # End: 145 | -------------------------------------------------------------------------------- /lib/bufferarray.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999 Philip Proudman 5 | * Copyright (C) 1999-2001 Fritz Elfert 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * along with this program; if not, see . 19 | * 20 | */ 21 | #ifndef _BUFFERARRAY_H_ 22 | #define _BUFFERARRAY_H_ 23 | 24 | #include "config.h" 25 | 26 | class bufferStore; 27 | 28 | /** 29 | * An array of bufferStores 30 | */ 31 | class bufferArray { 32 | public: 33 | /** 34 | * constructs a new bufferArray. 35 | * A minimum of @ref ALLOC_MIN 36 | * elements is allocated. 37 | */ 38 | bufferArray(); 39 | 40 | /** 41 | * Constructs a new bufferArray. 42 | * 43 | * @param a The initial contents for this array. 44 | */ 45 | bufferArray(const bufferArray &a); 46 | 47 | /** 48 | * Destroys the bufferArray. 49 | */ 50 | ~bufferArray(); 51 | 52 | /** 53 | * Copys the bufferArray. 54 | */ 55 | bufferArray &operator =(const bufferArray &a); 56 | 57 | /** 58 | * Checks if this bufferArray is empty. 59 | * 60 | * @return true if the bufferArray is empty. 61 | */ 62 | bool empty() const; 63 | 64 | /** 65 | * Retrieves the bufferStore at given index. 66 | * 67 | * @return The bufferStore at index. 68 | */ 69 | bufferStore &operator [](const unsigned long index); 70 | 71 | /** 72 | * Appends a bufferStore to a bufferArray. 73 | * 74 | * @param s The bufferStore to be appended. 75 | * 76 | * @returns A new bufferArray with bufferStore appended to. 77 | */ 78 | bufferArray operator +(const bufferStore &s); 79 | 80 | /** 81 | * Concatenates two bufferArrays. 82 | * 83 | * @param a The bufferArray to be appended. 84 | * 85 | * @returns A new bufferArray consisting with a appended. 86 | */ 87 | bufferArray operator +(const bufferArray &a); 88 | 89 | /** 90 | * Appends a bufferStore to current instance. 91 | * 92 | * @param s The bufferStore to append. 93 | * 94 | * @returns A reference to the current instance with s appended. 95 | */ 96 | bufferArray &operator +=(const bufferStore &s); 97 | 98 | /** 99 | * Appends a bufferArray to current instance. 100 | * 101 | * @param a The bufferArray to append. 102 | * 103 | * @returns A reference to the current instance with a appended. 104 | */ 105 | bufferArray &operator +=(const bufferArray &a); 106 | 107 | /** 108 | * Removes the first bufferStore. 109 | * 110 | * @return The removed bufferStore. 111 | */ 112 | bufferStore pop(void); 113 | 114 | /** 115 | * Inserts a bufferStore at index 0. 116 | * 117 | * @param b The bufferStore to be inserted. 118 | */ 119 | void push(const bufferStore& b); 120 | 121 | /** 122 | * Appends a bufferStore. 123 | * 124 | * @param b The bufferStore to be appended. 125 | */ 126 | void append(const bufferStore& b); 127 | 128 | /** 129 | * Evaluates the current length. 130 | * 131 | * @return The current number of bufferStores 132 | */ 133 | long length(void); 134 | 135 | /** 136 | * Empties the bufferArray. 137 | */ 138 | void clear(void); 139 | 140 | private: 141 | /** 142 | * Minimum number of bufferStores to 143 | * allocate. 144 | */ 145 | static const long ALLOC_MIN = 5; 146 | 147 | /** 148 | * The current number of bufferStores in 149 | * this bufferArray. 150 | */ 151 | long len; 152 | 153 | /** 154 | * The current number of bufferStores 155 | * allocated. 156 | */ 157 | long lenAllocd; 158 | 159 | /** 160 | * The content. 161 | */ 162 | bufferStore* buff; 163 | }; 164 | 165 | inline bool bufferArray::empty() const { return len == 0; } 166 | 167 | #endif 168 | -------------------------------------------------------------------------------- /lib/sisfilerecord.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 2002 Daniel Brahneborg 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | */ 19 | #include "config.h" 20 | 21 | #include "sisfilerecord.h" 22 | #include "sisfile.h" 23 | #include "plpintl.h" 24 | 25 | #include 26 | 27 | SisRC 28 | SISFileRecord::fillFrom(uint8_t* buf, int* base, off_t len, SISFile* sisFile) 29 | { 30 | if (*base + 28 + 4 * 2 > len) 31 | return SIS_TRUNCATED; 32 | 33 | SisRC rc = SIS_OK; 34 | m_buf = buf; 35 | m_len = len; 36 | uint8_t* p = buf + *base; 37 | int size = 0; 38 | m_flags = read32(p); 39 | if (logLevel >= 2) 40 | printf(_("Got flags %d\n"), m_flags); 41 | m_fileType = read32(p + 4); 42 | if (logLevel >= 2) 43 | printf(_("Got file type %d\n"), m_fileType); 44 | m_fileDetails = read32(p + 8); 45 | if (logLevel >= 2) 46 | printf(_("Got file details %d\n"), m_fileDetails); 47 | m_sourceLength = read32(p + 12); 48 | m_sourcePtr = read32(p + 16); 49 | // printf(_("Got source length = %d, source name ptr = %d\n"), 50 | // m_sourceLength, m_sourcePtr); 51 | if (logLevel >= 2) 52 | if (m_sourceLength > 0) 53 | printf(_("Got source name %.*s\n"), m_sourceLength, buf + m_sourcePtr); 54 | m_destLength = read32(p + 20); 55 | m_destPtr = read32(p + 24); 56 | // printf(_("Got dest length = %d, dest name ptr = %d\n"), 57 | // m_destLength, m_destPtr); 58 | if (logLevel >= 2) 59 | printf(_("Got destination name %.*s\n"), m_destLength, buf + m_destPtr); 60 | size = 28; 61 | switch (m_flags) 62 | { 63 | case 0: // Only one file. 64 | m_fileLengths = new uint32_t[1]; 65 | m_filePtrs = new uint32_t[1]; 66 | m_fileLengths[0] = read32(p + size); 67 | m_filePtrs[0] = read32(p + size + 4); 68 | size += 8; 69 | if (logLevel >= 2) 70 | printf(_("File is %d bytes long (at %d) (to %d)\n"), 71 | m_fileLengths[0], m_filePtrs[0], 72 | m_fileLengths[0] + m_filePtrs[0]); 73 | if (logLevel >= 1) 74 | printf(_("%d .. %d (%d bytes): Single file record type %d, %.*s\n"), 75 | m_filePtrs[0], 76 | m_filePtrs[0] + m_fileLengths[0], 77 | m_fileLengths[0], 78 | m_fileType, 79 | m_destLength, buf + m_destPtr); 80 | break; 81 | 82 | case 1: // One file per language. 83 | { 84 | int n = sisFile->m_header.m_nlangs; 85 | m_fileLengths = new uint32_t[n]; 86 | m_filePtrs = new uint32_t[n]; 87 | if (*base + size + n * 8 > len) 88 | return SIS_TRUNCATED; 89 | for (int i = 0; i < n; ++i) 90 | { 91 | m_fileLengths[i] = read32(p + size); 92 | // if (m_fileLengths[i] > len) 93 | // rc = SIS_TRUNCATEDDATA; 94 | size += 4; 95 | } 96 | for (int i = 0; i < n; ++i) 97 | { 98 | m_filePtrs[i] = read32(p + size); 99 | int fileLen = m_fileLengths[i]; 100 | // if (m_filePtrs[i] + fileLen > len) 101 | // rc = SIS_TRUNCATEDDATA; 102 | size += 4; 103 | if (logLevel >= 2) 104 | printf(_("File %d (for %s) is %d bytes long (at %d)\n"), 105 | i, 106 | sisFile->getLanguage(i)->m_name, 107 | fileLen, 108 | m_filePtrs[i]); 109 | if (logLevel >= 1) 110 | printf(_("%d .. %d (%d bytes): File record (%s) for %.*s\n"), 111 | m_filePtrs[i], 112 | m_filePtrs[i] + fileLen, 113 | fileLen, 114 | sisFile->getLanguage(i)->m_name, 115 | m_destLength, buf + m_destPtr); 116 | } 117 | break; 118 | } 119 | 120 | default: 121 | if (logLevel >= 2) 122 | printf(_("Unknown file flags %d\n"), m_flags); 123 | } 124 | *base += size; 125 | return rc; 126 | } 127 | 128 | uint8_t* 129 | SISFileRecord::getFilePtr(int fileNo) 130 | { 131 | if (fileNo < 0) 132 | return 0; 133 | if (m_filePtrs[fileNo] >= m_len) 134 | return 0; 135 | return &m_buf[m_filePtrs[fileNo]]; 136 | } 137 | 138 | void 139 | SISFileRecord::setMainDrive(char drive) 140 | { 141 | if (m_buf[m_destPtr] == '!') 142 | m_buf[m_destPtr] = drive; 143 | } 144 | -------------------------------------------------------------------------------- /lib/rclip.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of plptools. 3 | * 4 | * Copyright (C) 1999-2001 Fritz Elfert 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * along with this program; if not, see . 18 | * 19 | */ 20 | #include "config.h" 21 | 22 | #include "rclip.h" 23 | #include "bufferstore.h" 24 | #include "ppsocket.h" 25 | #include "bufferarray.h" 26 | #include "Enum.h" 27 | 28 | #include 29 | #include 30 | 31 | rclip::rclip(ppsocket * _skt) 32 | { 33 | skt = _skt; 34 | reset(); 35 | } 36 | 37 | rclip::~rclip() 38 | { 39 | skt->closeSocket(); 40 | } 41 | 42 | // 43 | // public common API 44 | // 45 | void rclip:: 46 | reconnect(void) 47 | { 48 | //skt->closeSocket(); 49 | skt->reconnect(); 50 | reset(); 51 | } 52 | 53 | void rclip:: 54 | reset(void) 55 | { 56 | bufferStore a; 57 | status = rfsv::E_PSI_FILE_DISC; 58 | a.addStringT(getConnectName()); 59 | if (skt->sendBufferStore(a)) { 60 | if (skt->getBufferStore(a) == 1) { 61 | if (!strcmp(a.getString(0), "NAK")) 62 | status = rfsv::E_PSI_GEN_NSUP; 63 | if (!strcmp(a.getString(0), "Ok")) 64 | status = rfsv::E_PSI_GEN_NONE; 65 | } 66 | } 67 | } 68 | 69 | Enum rclip:: 70 | getStatus(void) 71 | { 72 | return status; 73 | } 74 | 75 | const char *rclip:: 76 | getConnectName(void) 77 | { 78 | return "CLIPSVR.RSY"; 79 | } 80 | 81 | // 82 | // protected internals 83 | // 84 | bool rclip:: 85 | sendCommand(enum commands cc) 86 | { 87 | if (status == rfsv::E_PSI_FILE_DISC) { 88 | reconnect(); 89 | if (status == rfsv::E_PSI_FILE_DISC) 90 | return false; 91 | } 92 | if (status != rfsv::E_PSI_GEN_NONE) 93 | return false; 94 | 95 | bool result; 96 | bufferStore a; 97 | a.addByte(cc); 98 | switch (cc) { 99 | case RCLIP_INIT: 100 | a.addWord(0x100); 101 | break; 102 | case RCLIP_NOTIFY: 103 | a.addByte(0); 104 | } 105 | result = skt->sendBufferStore(a); 106 | if (!result) { 107 | reconnect(); 108 | result = skt->sendBufferStore(a); 109 | if (!result) 110 | status = rfsv::E_PSI_FILE_DISC; 111 | } 112 | return result; 113 | } 114 | 115 | Enum rclip:: 116 | sendListen() { 117 | if (sendCommand(RCLIP_LISTEN)) 118 | return rfsv::E_PSI_GEN_NONE; 119 | else 120 | return status; 121 | } 122 | 123 | Enum rclip:: 124 | checkNotify() { 125 | Enum ret; 126 | bufferStore a; 127 | 128 | int r = skt->getBufferStore(a, false); 129 | if (r < 0) { 130 | ret = status = rfsv::E_PSI_FILE_DISC; 131 | } else { 132 | if (r == 0) 133 | ret = rfsv::E_PSI_FILE_EOF; 134 | else { 135 | if ((a.getLen() != 1) || (a.getByte(0) != 0)) 136 | ret = rfsv::E_PSI_GEN_FAIL; 137 | } 138 | } 139 | return ret; 140 | } 141 | 142 | Enum rclip:: 143 | waitNotify() { 144 | Enum ret; 145 | 146 | bufferStore a; 147 | sendCommand(RCLIP_LISTEN); 148 | if ((ret = getResponse(a)) == rfsv::E_PSI_GEN_NONE) { 149 | if ((a.getLen() != 1) || (a.getByte(0) != 0)) 150 | ret = rfsv::E_PSI_GEN_FAIL; 151 | } 152 | return ret; 153 | } 154 | 155 | Enum rclip:: 156 | notify() { 157 | Enum ret; 158 | bufferStore a; 159 | 160 | sendCommand(RCLIP_NOTIFY); 161 | if ((ret = getResponse(a)) == rfsv::E_PSI_GEN_NONE) { 162 | if ((a.getLen() != 1) || (a.getByte(0) != RCLIP_NOTIFY)) 163 | ret = rfsv::E_PSI_GEN_FAIL; 164 | } 165 | return ret; 166 | } 167 | 168 | Enum rclip:: 169 | initClipbd() { 170 | Enum ret; 171 | bufferStore a; 172 | 173 | if (status != rfsv::E_PSI_GEN_NONE) 174 | return status; 175 | 176 | sendCommand(RCLIP_INIT); 177 | if ((ret = getResponse(a)) == rfsv::E_PSI_GEN_NONE) { 178 | if ((a.getLen() != 3) || (a.getByte(0) != RCLIP_INIT) || 179 | (a.getWord(1) != 0x100)) 180 | ret = rfsv::E_PSI_GEN_FAIL; 181 | } 182 | return ret; 183 | } 184 | 185 | Enum rclip:: 186 | getResponse(bufferStore & data) 187 | { 188 | Enum ret = rfsv::E_PSI_GEN_NONE; 189 | 190 | if (status == rfsv::E_PSI_GEN_NSUP) 191 | return status; 192 | 193 | if (skt->getBufferStore(data) == 1) 194 | return ret; 195 | else 196 | status = rfsv::E_PSI_FILE_DISC; 197 | return status; 198 | } 199 | -------------------------------------------------------------------------------- /ncpd/mp_serial.c: -------------------------------------------------------------------------------- 1 | /* 2 | // PLP - An implementation of the PSION link protocol 3 | // 4 | // The code in this file was written by Rudolf Koenig 5 | // (rfkoenig@immd4.informatik.uni-erlangen.de). (from his p3nfs code) 6 | // The Copyright remains his. 7 | // 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation; either version 2 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // This program is distributed in the hope that it will be useful, 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License along 19 | // along with this program; if not, see . 20 | // 21 | // e-mail philip.proudman@btinternet.com 22 | */ 23 | #include "config.h" 24 | 25 | #include 26 | #include 27 | #include /* for usleep() */ 28 | #include /* for bzero() */ 29 | #include 30 | #if defined(linux) || defined(_IBMR2) || \ 31 | (defined(__APPLE__) && defined(__MACH__)) || \ 32 | defined(__NetBSD__) || defined(__FreeBSD__) 33 | #include /* for ioctl() */ 34 | #endif 35 | #include 36 | #ifdef sun 37 | #include /* sun has TIOCEXCL there */ 38 | #endif 39 | #include 40 | 41 | #ifdef hpux 42 | #include 43 | #include 44 | #endif 45 | 46 | #include "mp_serial.h" 47 | 48 | 49 | #ifdef __sgi 50 | #define CRTSCTS CNEW_RTSCTS 51 | #endif 52 | 53 | #ifndef O_NOCTTY 54 | #define O_NOCTTY 0 55 | #endif 56 | 57 | int 58 | init_serial(const char *dev, int speed, int debug) 59 | { 60 | int fd, baud; 61 | int uid, euid; 62 | struct termios ti; 63 | #ifdef hpux 64 | struct termiox tx; 65 | #endif 66 | static struct baud { 67 | int speed, baud; 68 | } btable[] = { 69 | { 9600, B9600 }, 70 | #ifdef B19200 71 | { 19200, B19200 }, 72 | #else 73 | #ifdef EXTA 74 | { 19200, EXTA }, 75 | #endif 76 | #endif 77 | #ifdef B38400 78 | { 38400, B38400 }, 79 | #else 80 | #ifdef EXTB 81 | { 38400, EXTB }, 82 | #endif 83 | #endif 84 | #ifdef B57600 85 | { 57600, B57600 }, 86 | #endif 87 | #ifdef B115200 88 | { 115200, B115200 }, 89 | #endif 90 | { 4800, B4800 }, 91 | { 2400, B2400 }, 92 | { 1200, B1200 }, 93 | { 300, B300 }, 94 | { 75, B75 }, 95 | { 50, B50 }, 96 | { 0, 0 } 97 | }, *bptr; 98 | 99 | if (speed) { 100 | for (bptr = btable; bptr->speed; bptr++) 101 | if (bptr->speed == speed) 102 | break; 103 | if (!bptr->baud) { 104 | fprintf(stderr, "Cannot match selected speed %d\n", speed); 105 | exit(1); 106 | } 107 | baud = bptr->baud; 108 | } else 109 | baud = 0; 110 | 111 | if (debug) 112 | printf("using %s...\n", dev); 113 | euid = geteuid(); 114 | uid = getuid(); 115 | 116 | #ifdef hpux 117 | #define seteuid(a) setresuid(-1, a, -1) 118 | #endif 119 | 120 | if (seteuid(uid)) { 121 | perror("seteuid"); 122 | exit(1); 123 | } 124 | if ((fd = open(dev, O_RDWR | O_NOCTTY, 0)) < 0) { 125 | perror(dev); 126 | exit(1); 127 | } 128 | if (seteuid(euid)) { 129 | perror("seteuid back"); 130 | exit(1); 131 | } 132 | if (debug) 133 | printf("open done\n"); 134 | #ifdef TIOCEXCL 135 | ioctl(fd, TIOCEXCL, (char *) 0); /* additional open() calls shall fail */ 136 | #else 137 | fprintf(stderr, "WARNING: opened %s non-exclusive!\n", dev); 138 | #endif 139 | 140 | memset(&ti, 0, sizeof(struct termios)); 141 | ti.c_cflag = CS8 | HUPCL | CLOCAL | CREAD; 142 | #if defined(sun) || defined(linux) || defined(__sgi) || \ 143 | (defined(__APPLE__) && defined(__MACH__)) || \ 144 | defined(__NetBSD__) || defined(__FreeBSD__) 145 | ti.c_cflag |= CRTSCTS; 146 | ti.c_iflag = IGNBRK | IGNPAR; 147 | ti.c_cc[VMIN] = 1; 148 | ti.c_cc[VTIME] = 0; 149 | #endif 150 | cfsetispeed(&ti, baud); 151 | cfsetospeed(&ti, baud); 152 | 153 | if (tcsetattr(fd, TCSADRAIN, &ti) < 0) 154 | perror("tcsetattr TCSADRAIN"); 155 | 156 | #ifdef hpux 157 | bzero(&tx, sizeof(struct termiox)); 158 | tx.x_hflag = RTSXOFF | CTSXON; 159 | if (ioctl(fd, TCSETXW, &tx) < 0) 160 | perror("TCSETXW"); 161 | #endif 162 | #if defined(_IBMR2) 163 | ioctl(fd, TXDELCD, "dtr"); 164 | ioctl(fd, TXDELCD, "xon"); 165 | ioctl(fd, TXADDCD, "rts"); /* That's how AIX does CRTSCTS */ 166 | #endif 167 | 168 | return fd; 169 | } 170 | 171 | void 172 | ser_exit(int fd) 173 | { 174 | struct termios ti; 175 | 176 | #ifdef TIOCNXCL 177 | ioctl(fd, TIOCNXCL, (char *) 0); 178 | #endif 179 | if (tcgetattr(fd, &ti) < 0) 180 | perror("tcgetattr"); 181 | ti.c_cflag &= ~CRTSCTS; 182 | if (tcsetattr(fd, TCSANOW, &ti) < 0) 183 | perror("tcsetattr"); 184 | (void) close(fd); 185 | } 186 | -------------------------------------------------------------------------------- /m4/longlong.m4: -------------------------------------------------------------------------------- 1 | # longlong.m4 serial 17 2 | dnl Copyright (C) 1999-2007, 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Paul Eggert. 8 | 9 | # Define HAVE_LONG_LONG_INT if 'long long int' works. 10 | # This fixes a bug in Autoconf 2.61, and can be faster 11 | # than what's in Autoconf 2.62 through 2.68. 12 | 13 | # Note: If the type 'long long int' exists but is only 32 bits large 14 | # (as on some very old compilers), HAVE_LONG_LONG_INT will not be 15 | # defined. In this case you can treat 'long long int' like 'long int'. 16 | 17 | AC_DEFUN([AC_TYPE_LONG_LONG_INT], 18 | [ 19 | AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) 20 | AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], 21 | [ac_cv_type_long_long_int=yes 22 | if test "x${ac_cv_prog_cc_c99-no}" = xno; then 23 | ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int 24 | if test $ac_cv_type_long_long_int = yes; then 25 | dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. 26 | dnl If cross compiling, assume the bug is not important, since 27 | dnl nobody cross compiles for this platform as far as we know. 28 | AC_RUN_IFELSE( 29 | [AC_LANG_PROGRAM( 30 | [[@%:@include 31 | @%:@ifndef LLONG_MAX 32 | @%:@ define HALF \ 33 | (1LL << (sizeof (long long int) * CHAR_BIT - 2)) 34 | @%:@ define LLONG_MAX (HALF - 1 + HALF) 35 | @%:@endif]], 36 | [[long long int n = 1; 37 | int i; 38 | for (i = 0; ; i++) 39 | { 40 | long long int m = n << i; 41 | if (m >> i != n) 42 | return 1; 43 | if (LLONG_MAX / 2 < m) 44 | break; 45 | } 46 | return 0;]])], 47 | [], 48 | [ac_cv_type_long_long_int=no], 49 | [:]) 50 | fi 51 | fi]) 52 | if test $ac_cv_type_long_long_int = yes; then 53 | AC_DEFINE([HAVE_LONG_LONG_INT], [1], 54 | [Define to 1 if the system has the type 'long long int'.]) 55 | fi 56 | ]) 57 | 58 | # Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. 59 | # This fixes a bug in Autoconf 2.61, and can be faster 60 | # than what's in Autoconf 2.62 through 2.68. 61 | 62 | # Note: If the type 'unsigned long long int' exists but is only 32 bits 63 | # large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT 64 | # will not be defined. In this case you can treat 'unsigned long long int' 65 | # like 'unsigned long int'. 66 | 67 | AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT], 68 | [ 69 | AC_CACHE_CHECK([for unsigned long long int], 70 | [ac_cv_type_unsigned_long_long_int], 71 | [ac_cv_type_unsigned_long_long_int=yes 72 | if test "x${ac_cv_prog_cc_c99-no}" = xno; then 73 | AC_LINK_IFELSE( 74 | [_AC_TYPE_LONG_LONG_SNIPPET], 75 | [], 76 | [ac_cv_type_unsigned_long_long_int=no]) 77 | fi]) 78 | if test $ac_cv_type_unsigned_long_long_int = yes; then 79 | AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1], 80 | [Define to 1 if the system has the type 'unsigned long long int'.]) 81 | fi 82 | ]) 83 | 84 | # Expands to a C program that can be used to test for simultaneous support 85 | # of 'long long' and 'unsigned long long'. We don't want to say that 86 | # 'long long' is available if 'unsigned long long' is not, or vice versa, 87 | # because too many programs rely on the symmetry between signed and unsigned 88 | # integer types (excluding 'bool'). 89 | AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET], 90 | [ 91 | AC_LANG_PROGRAM( 92 | [[/* For now, do not test the preprocessor; as of 2007 there are too many 93 | implementations with broken preprocessors. Perhaps this can 94 | be revisited in 2012. In the meantime, code should not expect 95 | #if to work with literals wider than 32 bits. */ 96 | /* Test literals. */ 97 | long long int ll = 9223372036854775807ll; 98 | long long int nll = -9223372036854775807LL; 99 | unsigned long long int ull = 18446744073709551615ULL; 100 | /* Test constant expressions. */ 101 | typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) 102 | ? 1 : -1)]; 103 | typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 104 | ? 1 : -1)]; 105 | int i = 63;]], 106 | [[/* Test availability of runtime routines for shift and division. */ 107 | long long int llmax = 9223372036854775807ll; 108 | unsigned long long int ullmax = 18446744073709551615ull; 109 | return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) 110 | | (llmax / ll) | (llmax % ll) 111 | | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) 112 | | (ullmax / ull) | (ullmax % ull));]]) 113 | ]) 114 | --------------------------------------------------------------------------------