From 1aa09e7accb1e56533a9c5a4bcc7b66eff95280e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Tue, 16 Oct 2001 19:29:03 +0000 Subject: [PATCH] moved from ../rpc git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@686 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- rpcrig/Makefile.am | 44 +++ rpcrig/Makefile.in | 522 +++++++++++++++++++++++++++ rpcrig/rpc.rigd.8 | 93 +++++ rpcrig/rpcrig.h | 91 +++++ rpcrig/rpcrig.x | 54 +++ rpcrig/rpcrig_backend.c | 772 ++++++++++++++++++++++++++++++++++++++++ rpcrig/rpcrig_backend.h | 31 ++ rpcrig/rpcrig_clnt.c | 55 +++ rpcrig/rpcrig_proc.c | 83 +++++ rpcrig/rpcrig_svc.c | 71 ++++ rpcrig/rpcrig_xdr.c | 68 ++++ rpcrig/rpcrigd.c | 291 +++++++++++++++ 12 files changed, 2175 insertions(+) create mode 100644 rpcrig/Makefile.am create mode 100644 rpcrig/Makefile.in create mode 100644 rpcrig/rpc.rigd.8 create mode 100644 rpcrig/rpcrig.h create mode 100644 rpcrig/rpcrig.x create mode 100644 rpcrig/rpcrig_backend.c create mode 100644 rpcrig/rpcrig_backend.h create mode 100644 rpcrig/rpcrig_clnt.c create mode 100644 rpcrig/rpcrig_proc.c create mode 100644 rpcrig/rpcrig_svc.c create mode 100644 rpcrig/rpcrig_xdr.c create mode 100644 rpcrig/rpcrigd.c diff --git a/rpcrig/Makefile.am b/rpcrig/Makefile.am new file mode 100644 index 000000000..64f933583 --- /dev/null +++ b/rpcrig/Makefile.am @@ -0,0 +1,44 @@ +# rpcrig_xdr.c rpcrig_svc.c rpcrig_clnt.c and rpcrig.h are generated by rpcgen +# have to provide: rpcrig_proc.c rpcrigd.c rpcrig_backend.c +RPCRIG_SVC = rpcrig_xdr.c rpcrig_svc.c rpcrig_proc.c rpcrigd.c +RPCRIG_CLNT = rpcrig_xdr.c rpcrig_clnt.c rpcrig_backend.c + +# The RPC server +bin_PROGRAMS = rpc.rigd +LDADD = ../src/libhamlib.la ../lib/libmisc.a # -lnsl +DEPENDENCIES = ../src/libhamlib.la +rpc_rigd_SOURCES = $(RPCRIG_SVC) +man_MANS = rpc.rigd.8 + +# The RPC backend +lib_LTLIBRARIES = libhamlib-rpcrig.la +libhamlib_rpcrig_la_SOURCES = $(RPCRIG_CLNT) +libhamlib_rpcrig_la_LDFLAGS = -no-undefined -module -avoid-version -lnsl +libhamlib_rpcrig_la_LIBADD = ../src/libhamlib.la + +lib_LIBRARIES = libhamlib-rpcrig.a +libhamlib_rpcrig_a_SOURCES = $(RPCRIG_CLNT) +libhamlib_rpcrig_a_LIBADD = ../src/libhamlib.la # -lnsl + +noinst_HEADERS = rpcrig.h rpcrig_backend.h + +EXTRA_DIST = rpcrig.x $(man_MANS) + +RPCGEN = rpcgen + +rpcrig.h: rpcrig.x + rm -f $@ + $(RPCGEN) -h rpcrig.x -o $@ + +rpcrig_clnt.c: rpcrig.x + rm -f $@ + $(RPCGEN) -l rpcrig.x -o $@ + +rpcrig_svc.c: rpcrig.x + rm -f $@ + $(RPCGEN) -m rpcrig.x -o $@ + +rpcrig_xdr.c: rpcrig.x + rm -f $@ + $(RPCGEN) -c rpcrig.x -o $@ + diff --git a/rpcrig/Makefile.in b/rpcrig/Makefile.in new file mode 100644 index 000000000..d7cad1cfc --- /dev/null +++ b/rpcrig/Makefile.in @@ -0,0 +1,522 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# rpcrig_xdr.c rpcrig_svc.c rpcrig_clnt.c and rpcrig.h are generated by rpcgen +# have to provide: rpcrig_proc.c rpcrigd.c rpcrig_backend.c + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AMTAR = @AMTAR@ +AS = @AS@ +AWK = @AWK@ +BACKENDEPS = @BACKENDEPS@ +BACKENDLNK = @BACKENDLNK@ +BACKEND_LIST = @BACKEND_LIST@ +CC = @CC@ +CPP = @CPP@ +CXX = @CXX@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DLL_PRELOAD = @DLL_PRELOAD@ +ECHO = @ECHO@ +EXEEXT = @EXEEXT@ +INCLTDL = @INCLTDL@ +INCLUDES = @INCLUDES@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LIBHAMLIBTCL = @LIBHAMLIBTCL@ +LIBLTDL = @LIBLTDL@ +LIBOBJS = @LIBOBJS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTHAMLIBTCL = @LTHAMLIBTCL@ +NET = @NET@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +RIGMATRIX = @RIGMATRIX@ +STRIP = @STRIP@ +VERSION = @VERSION@ +am__include = @am__include@ +am__quote = @am__quote@ +hamlibdocdir = @hamlibdocdir@ +install_sh = @install_sh@ + +RPCRIG_SVC = rpcrig_xdr.c rpcrig_svc.c rpcrig_proc.c rpcrigd.c +RPCRIG_CLNT = rpcrig_xdr.c rpcrig_clnt.c rpcrig_backend.c + +# The RPC server +bin_PROGRAMS = rpc.rigd +LDADD = ../src/libhamlib.la ../lib/libmisc.a # -lnsl +DEPENDENCIES = ../src/libhamlib.la +rpc_rigd_SOURCES = $(RPCRIG_SVC) +man_MANS = rpc.rigd.8 + +# The RPC backend +lib_LTLIBRARIES = libhamlib-rpcrig.la +libhamlib_rpcrig_la_SOURCES = $(RPCRIG_CLNT) +libhamlib_rpcrig_la_LDFLAGS = -no-undefined -module -avoid-version -lnsl +libhamlib_rpcrig_la_LIBADD = ../src/libhamlib.la + +lib_LIBRARIES = libhamlib-rpcrig.a +libhamlib_rpcrig_a_SOURCES = $(RPCRIG_CLNT) +libhamlib_rpcrig_a_LIBADD = ../src/libhamlib.la # -lnsl + +noinst_HEADERS = rpcrig.h rpcrig_backend.h + +EXTRA_DIST = rpcrig.x $(man_MANS) + +RPCGEN = rpcgen +subdir = rpc +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/include/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(lib_LIBRARIES) + +libhamlib_rpcrig_a_AR = $(AR) cru +libhamlib_rpcrig_a_DEPENDENCIES = ../src/libhamlib.la +am_libhamlib_rpcrig_a_OBJECTS = rpcrig_xdr.$(OBJEXT) \ + rpcrig_clnt.$(OBJEXT) rpcrig_backend.$(OBJEXT) +libhamlib_rpcrig_a_OBJECTS = $(am_libhamlib_rpcrig_a_OBJECTS) +LTLIBRARIES = $(lib_LTLIBRARIES) + +libhamlib_rpcrig_la_DEPENDENCIES = ../src/libhamlib.la +am_libhamlib_rpcrig_la_OBJECTS = rpcrig_xdr.lo rpcrig_clnt.lo \ + rpcrig_backend.lo +libhamlib_rpcrig_la_OBJECTS = $(am_libhamlib_rpcrig_la_OBJECTS) +bin_PROGRAMS = rpc.rigd$(EXEEXT) +PROGRAMS = $(bin_PROGRAMS) + +am_rpc_rigd_OBJECTS = rpcrig_xdr.$(OBJEXT) rpcrig_svc.$(OBJEXT) \ + rpcrig_proc.$(OBJEXT) rpcrigd.$(OBJEXT) +rpc_rigd_OBJECTS = $(am_rpc_rigd_OBJECTS) +rpc_rigd_LDADD = $(LDADD) +rpc_rigd_DEPENDENCIES = ../src/libhamlib.la ../lib/libmisc.a +rpc_rigd_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/rpcrig_backend.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/rpcrig_backend.Po \ +@AMDEP_TRUE@ $(DEPDIR)/rpcrig_clnt.Plo $(DEPDIR)/rpcrig_clnt.Po \ +@AMDEP_TRUE@ $(DEPDIR)/rpcrig_proc.Po $(DEPDIR)/rpcrig_svc.Po \ +@AMDEP_TRUE@ $(DEPDIR)/rpcrig_xdr.Plo $(DEPDIR)/rpcrig_xdr.Po \ +@AMDEP_TRUE@ $(DEPDIR)/rpcrigd.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +DIST_SOURCES = $(libhamlib_rpcrig_a_SOURCES) \ + $(libhamlib_rpcrig_la_SOURCES) $(rpc_rigd_SOURCES) + +NROFF = nroff +MANS = $(man_MANS) +HEADERS = $(noinst_HEADERS) + +DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in +SOURCES = $(libhamlib_rpcrig_a_SOURCES) $(libhamlib_rpcrig_la_SOURCES) $(rpc_rigd_SOURCES) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu rpc/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status + +AR = ar +install-libLIBRARIES: $(lib_LIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + @$(POST_INSTALL) + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(RANLIB) $(DESTDIR)$(libdir)/$$p"; \ + $(RANLIB) $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + echo " rm -f $(DESTDIR)$(libdir)/$$p"; \ + rm -f $(DESTDIR)$(libdir)/$$p; \ + done + +clean-libLIBRARIES: + -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES) +libhamlib-rpcrig.a: $(libhamlib_rpcrig_a_OBJECTS) $(libhamlib_rpcrig_a_DEPENDENCIES) + -rm -f libhamlib-rpcrig.a + $(libhamlib_rpcrig_a_AR) libhamlib-rpcrig.a $(libhamlib_rpcrig_a_OBJECTS) $(libhamlib_rpcrig_a_LIBADD) + $(RANLIB) libhamlib-rpcrig.a +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(LIBTOOL) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) +libhamlib-rpcrig.la: $(libhamlib_rpcrig_la_OBJECTS) $(libhamlib_rpcrig_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libhamlib_rpcrig_la_LDFLAGS) $(libhamlib_rpcrig_la_OBJECTS) $(libhamlib_rpcrig_la_LIBADD) $(LIBS) +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo $$p1|sed '$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$f"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$f; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f $(DESTDIR)$(bindir)/$$f"; \ + rm -f $(DESTDIR)$(bindir)/$$f; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +rpc.rigd$(EXEEXT): $(rpc_rigd_OBJECTS) $(rpc_rigd_DEPENDENCIES) + @rm -f rpc.rigd$(EXEEXT) + $(LINK) $(rpc_rigd_LDFLAGS) $(rpc_rigd_OBJECTS) $(rpc_rigd_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rpcrig_backend.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rpcrig_backend.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rpcrig_clnt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rpcrig_clnt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rpcrig_proc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rpcrig_svc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rpcrig_xdr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rpcrig_xdr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rpcrigd.Po@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< +CCDEPMODE = @CCDEPMODE@ +uninstall-info-am: + +man8dir = $(mandir)/man8 +install-man8: $(man8_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(man8dir) + @list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.8*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst"; \ + $(INSTALL_DATA) $$file $(DESTDIR)$(man8dir)/$$inst; \ + done +uninstall-man8: + @$(NORMAL_UNINSTALL) + @list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.8*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f $(DESTDIR)$(man8dir)/$$inst"; \ + rm -f $(DESTDIR)$(man8dir)/$$inst; \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(PROGRAMS) $(MANS) \ + $(HEADERS) +install-binPROGRAMS: install-libLTLIBRARIES + + +installdirs: + $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) $(DESTDIR)$(man8dir) + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libLIBRARIES \ + clean-libLTLIBRARIES clean-libtool mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: install-man + +install-exec-am: install-binPROGRAMS install-libLIBRARIES \ + install-libLTLIBRARIES + +install-info: install-info-am + +install-man: install-man8 + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am \ + uninstall-libLIBRARIES uninstall-libLTLIBRARIES uninstall-man + +uninstall-man: uninstall-man8 + +.PHONY: GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libLIBRARIES clean-libLTLIBRARIES \ + clean-libtool distclean distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-libLIBRARIES \ + install-libLTLIBRARIES install-man install-man8 install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool tags uninstall \ + uninstall-am uninstall-binPROGRAMS uninstall-info-am \ + uninstall-libLIBRARIES uninstall-libLTLIBRARIES uninstall-man \ + uninstall-man8 + + +rpcrig.h: rpcrig.x + rm -f $@ + $(RPCGEN) -h rpcrig.x -o $@ + +rpcrig_clnt.c: rpcrig.x + rm -f $@ + $(RPCGEN) -l rpcrig.x -o $@ + +rpcrig_svc.c: rpcrig.x + rm -f $@ + $(RPCGEN) -m rpcrig.x -o $@ + +rpcrig_xdr.c: rpcrig.x + rm -f $@ + $(RPCGEN) -c rpcrig.x -o $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/rpcrig/rpc.rigd.8 b/rpcrig/rpc.rigd.8 new file mode 100644 index 000000000..aafa6ebdc --- /dev/null +++ b/rpcrig/rpc.rigd.8 @@ -0,0 +1,93 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH RIGD "8" "October 07, 2001" "Hamlib" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +rigd \- Hamlib rig service daemon +.SH SYNOPSIS +.B rpc.rigd +[\fIOPTION\fR]... +.SH DESCRIPTION +The \fBrigd\fP program is a Hamlib rig daemon that handles RPC client requests. +.PP +.\" TeX users may be more comfortable with the \fB\fP and +.\" \fI\fP escape sequences to invode bold face and italics, +.\" respectively. +Keep in mind that \fBHamlib\fP is still ALPHA level software. +A lof of stuff hasn't been tested thoroughly, and the API may change +without publicised notice. Please report bugs and feedback at +the e-mail address given in the REPORTING BUGS section. +.SH OPTIONS +This program follow the usual GNU command line syntax, with long +options starting with two dashes (`-'). +A summary of options is included below. +.TP +.B \-m, \-\-model=id +Select radio model number. See model list. +.TP +.B \-r, --rig-file=device +Use \fBdevice\fP as the file name of the radio to operate on. +.TP +.B \-p, --ptt-file=device +Use \fBdevice\fP as the file name of the Push-To-Talk device to operate on. +.TP +.B \-d, --dcd-file=device +Use \fBdevice\fP as the file name of the Data Carrier Detect device +to operate on. +.TP +.B \-p, --ptt-type=type +Use \fBtype\fP device as the kind of the Push-To-Talk device to operate on. +.TP +.B \-d, --dcd-type=type +Use \fBtype\fP device as the kind of the Data Carrier Detect device +to operate on. +.TP +.B \-c, --civaddr=id +Use \fBid\fP as the CI-V address to communicate with the rig. Only for Icom rigs. +.TP +.B \-v, \-\-verbose +Set verbose mode, cumulative. +.TP +.B \-h, \-\-help +Show summary of options and exit. +.TP +.B \-V, \-\-version +Show version of program and exit. + +.PP +Please note that the backend for the radio to be controlled, +or the radio itself may not support some commands. In that case, +the operation will fail with a standard error code. + +.SH AUTHOR +Written by Stephane Fillod. +.SH BUGS +Does'nt handle all the rig caps overriding. +.PP +This almost empty section... +.SH REPORTING BUGS +Report bugs to . +.br +I'm already aware of the bug in the previous section :-) +.SH COPYRIGHT +Copyright \(co 2000,2001 Stephane Fillod. +.br +This is free software; see the source for copying conditions. +There is NO warranty; not even for MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. +.SH SEE ALSO +.BR rigctl (1) + diff --git a/rpcrig/rpcrig.h b/rpcrig/rpcrig.h new file mode 100644 index 000000000..78a4a36f5 --- /dev/null +++ b/rpcrig/rpcrig.h @@ -0,0 +1,91 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _RPCRIG_H_RPCGEN +#define _RPCRIG_H_RPCGEN + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef u_int vfo_x; + +struct freq_s { + u_int f1; + u_int f2; +}; +typedef struct freq_s freq_s; + +typedef u_int model_x; + +struct freq_res { + int rigstatus; + union { + freq_s freq; + } freq_res_u; +}; +typedef struct freq_res freq_res; + +struct freq_arg { + vfo_x vfo; + freq_s freq; +}; +typedef struct freq_arg freq_arg; + +#define RIGPROG 0x20000099 +#define RIGVERS 1 + +#if defined(__STDC__) || defined(__cplusplus) +#define GETMODEL 1 +extern model_x * getmodel_1(void *, CLIENT *); +extern model_x * getmodel_1_svc(void *, struct svc_req *); +#define SETFREQ 10 +extern int * setfreq_1(freq_arg *, CLIENT *); +extern int * setfreq_1_svc(freq_arg *, struct svc_req *); +#define GETFREQ 11 +extern freq_res * getfreq_1(vfo_x *, CLIENT *); +extern freq_res * getfreq_1_svc(vfo_x *, struct svc_req *); +extern int rigprog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t); + +#else /* K&R C */ +#define GETMODEL 1 +extern model_x * getmodel_1(); +extern model_x * getmodel_1_svc(); +#define SETFREQ 10 +extern int * setfreq_1(); +extern int * setfreq_1_svc(); +#define GETFREQ 11 +extern freq_res * getfreq_1(); +extern freq_res * getfreq_1_svc(); +extern int rigprog_1_freeresult (); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_vfo_x (XDR *, vfo_x*); +extern bool_t xdr_freq_s (XDR *, freq_s*); +extern bool_t xdr_model_x (XDR *, model_x*); +extern bool_t xdr_freq_res (XDR *, freq_res*); +extern bool_t xdr_freq_arg (XDR *, freq_arg*); + +#else /* K&R C */ +extern bool_t xdr_vfo_x (); +extern bool_t xdr_freq_s (); +extern bool_t xdr_model_x (); +extern bool_t xdr_freq_res (); +extern bool_t xdr_freq_arg (); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPCRIG_H_RPCGEN */ diff --git a/rpcrig/rpcrig.x b/rpcrig/rpcrig.x new file mode 100644 index 000000000..18d962cad --- /dev/null +++ b/rpcrig/rpcrig.x @@ -0,0 +1,54 @@ +/* + * Hamlib Interface - RPC definitions + * Copyright (c) 2000,2001 by Stephane Fillod and Frank Singleton + * + * $Id: rpcrig.x,v 1.1 2001-10-16 19:29:03 f4cfe Exp $ + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +typedef unsigned int vfo_x; + +/* Too bad, there's no long long support in RPC language */ +struct freq_s { + unsigned int f1; + unsigned int f2; +}; + +typedef unsigned int model_x; + +union freq_res switch (int rigstatus) { +case 0: + freq_s freq; +default: + void; +}; + +struct freq_arg { + vfo_x vfo; + freq_s freq; +}; + +program RIGPROG { + version RIGVERS { + model_x GETMODEL(void) = 1; + /* string GETLIBVERSION(void) = 2 */ + int SETFREQ(freq_arg) = 10; + freq_res GETFREQ(vfo_x) = 11; + } = 1; +} = 0x20000099; + + diff --git a/rpcrig/rpcrig_backend.c b/rpcrig/rpcrig_backend.c new file mode 100644 index 000000000..99542e077 --- /dev/null +++ b/rpcrig/rpcrig_backend.c @@ -0,0 +1,772 @@ +/* + * Hamlib RPC backend - main file + * Copyright (c) 2001 by Stephane Fillod + * + * $Id: rpcrig_backend.c,v 1.1 2001-10-16 19:29:03 f4cfe Exp $ + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include /* Standard input/output definitions */ +#include /* String function definitions */ +#include /* UNIX standard function definitions */ +#include /* File control definitions */ +#include /* Error number definitions */ +#include /* POSIX terminal control definitions */ +#include +#include + +#if defined(__CYGWIN__) +# undef HAMLIB_DLL +# include +# include +# include +# define HAMLIB_DLL +# include +#else +# include +# include +# include +#endif + +#include +#include "rpcrig.h" + +#include "rpcrig_backend.h" + + +/********************************************************************/ +void freq_t2freq_s(freq_t freqt, freq_s *freqs) +{ + freqs->f1 = freqt & 0xffffffff; + freqs->f2 = (freqt>>32) & 0xffffffff; +} +freq_t freq_s2freq_t(freq_s *freqs) +{ + return freqs->f1 | ((freq_t)freqs->f2 << 32); +} + +struct rpcrig_priv_data { + CLIENT *cl; +}; + +static int rpcrig_init(RIG *rig) +{ + if (!rig || !rig->caps) + return -RIG_EINVAL; + + rig->state.priv = malloc(sizeof(struct rpcrig_priv_data)); + if (!rig->state.priv) { + /* whoops! memory shortage! */ + return -RIG_ENOMEM; + } + rig->state.rigport.type.rig = RIG_PORT_NONE; + + return RIG_OK; +} + +static int rpcrig_cleanup(RIG *rig) +{ + if (!rig) + return -RIG_EINVAL; + + if (rig->state.priv) + free(rig->state.priv); + + rig->state.priv = NULL; + + return RIG_OK; +} + +static int rpcrig_open(RIG *rig) +{ + struct rpcrig_priv_data *priv; + struct rig_state *rs; + model_x *result; + char *server = "localhost"; + rig_model_t model; + const struct rig_caps *caps; + int i; + + rs = &rig->state; + priv = (struct rpcrig_priv_data*)rs->priv; + + priv->cl = clnt_create(server, RIGPROG, RIGVERS, "udp"); + if (priv->cl == NULL) { + clnt_pcreateerror(server); + return -RIG_ECONF; + } + result = getmodel_1(NULL, priv->cl); + if (result == NULL) { + clnt_perror(priv->cl, server); + return -RIG_EPROTO; + } + model = *result; + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ ": model %d\n", model); + caps = rig_get_caps(model); + + /* + * TODO: get these from RPC instead + */ +#if 0 + rs->vfo_list = 0; + for (i=0; irx_range_list[i].start != 0 && + rs->rx_range_list[i].end != 0) + rs->vfo_list |= rs->rx_range_list[i].vfo; + if (rs->tx_range_list[i].start != 0 && + rs->tx_range_list[i].end != 0) + rs->vfo_list |= rs->tx_range_list[i].vfo; + } + + memcpy(rs->preamp, caps->preamp, sizeof(int)*MAXDBLSTSIZ); + memcpy(rs->attenuator, caps->attenuator, sizeof(int)*MAXDBLSTSIZ); + memcpy(rs->tuning_steps, caps->tuning_steps, + sizeof(struct tuning_step_list)*TSLSTSIZ); + memcpy(rs->filters, caps->filters, + sizeof(struct filter_list)*FLTLSTSIZ); + memcpy(rs->chan_list, caps->chan_list, sizeof(chan_t)*CHANLSTSIZ); + + rs->has_get_func = caps->has_get_func; + rs->has_set_func = caps->has_set_func; + rs->has_get_level = caps->has_get_level; + rs->has_set_level = caps->has_set_level; + rs->has_get_parm = caps->has_get_parm; + rs->has_set_parm = caps->has_set_parm; + + rs->max_rit = caps->max_rit; + rs->max_xit = caps->max_xit; + rs->max_ifshift = caps->max_ifshift; + rs->announces = caps->announces; +#endif + + return RIG_OK; +} + +static int rpcrig_close(RIG *rig) +{ + struct rpcrig_priv_data *priv; + + priv = (struct rpcrig_priv_data*)rig->state.priv; + + clnt_destroy(priv->cl); + + return RIG_OK; +} + +static int rpcrig_set_freq(RIG *rig, vfo_t vfo, freq_t freq) +{ + struct rpcrig_priv_data *priv; + struct rig_state *rs; + int *result; + freq_arg farg; + char *server = "localhost"; + + rs = &rig->state; + priv = (struct rpcrig_priv_data*)rs->priv; + + freq_t2freq_s(freq, &farg.freq); + result = setfreq_1(&farg, priv->cl); + if (result == NULL) { + clnt_perror(priv->cl, server); + return -RIG_EPROTO; + } + + return *result; +} + + +static int rpcrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) +{ + struct rpcrig_priv_data *priv; + struct rig_state *rs; + freq_res *fres; + vfo_x v; + char *server = "localhost"; + + rs = &rig->state; + priv = (struct rpcrig_priv_data*)rs->priv; + + v = vfo; + fres = getfreq_1(&v, priv->cl); + if (fres == NULL) { + clnt_perror(priv->cl, server); + return -RIG_EPROTO; + } + if (fres->rigstatus == RIG_OK) + *freq = freq_s2freq_t(&fres->freq_res_u.freq); + + return fres->rigstatus; +} + + +static int rpcrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_vfo(RIG *rig, vfo_t vfo) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_vfo(RIG *rig, vfo_t *vfo) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *rptr_shift) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t rptr_offs) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *rptr_offs) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_dcs_sql(RIG *rig, vfo_t vfo, unsigned int code) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_dcs_sql(RIG *rig, vfo_t vfo, unsigned int *code) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + +static int rpcrig_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + +static int rpcrig_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, pbwidth_t *tx_width) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + +static int rpcrig_set_split(RIG *rig, vfo_t vfo, split_t split) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_split(RIG *rig, vfo_t vfo, split_t *split) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + +static int rpcrig_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_power2mW(RIG *rig, unsigned int *mwpower, float power, freq_t freq, rmode_t mode) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_mW2power(RIG *rig, float *power, unsigned int mwpower, freq_t freq, rmode_t mode) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_powerstat(RIG *rig, powerstat_t status) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_powerstat(RIG *rig, powerstat_t *status) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_parm(RIG *rig, setting_t parm, value_t val) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_parm(RIG *rig, setting_t parm, value_t *val) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_ant(RIG *rig, vfo_t vfo, ant_t ant) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_ant(RIG *rig, vfo_t vfo, ant_t *ant) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_bank(RIG *rig, vfo_t vfo, int bank) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_mem(RIG *rig, vfo_t vfo, int ch) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_mem(RIG *rig, vfo_t vfo, int *ch) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + +static int rpcrig_set_channel(RIG *rig, const channel_t *chan) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_channel(RIG *rig, channel_t *chan) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_set_trn(RIG *rig, vfo_t vfo, int trn) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + +static int rpcrig_get_trn(RIG *rig, vfo_t vfo, int *trn) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + +static const char *rpcrig_get_info(RIG *rig) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return ""; +} + + +static int rpcrig_send_dtmf(RIG *rig, vfo_t vfo, const char *digits) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + +static int rpcrig_recv_dtmf(RIG *rig, vfo_t vfo, char *digits, int *length) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + +static int rpcrig_send_morse(RIG *rig, vfo_t vfo, const char *msg) +{ + rig_debug(RIG_DEBUG_VERBOSE,__FUNCTION__ " called\n"); + + return RIG_OK; +} + + + +/* + * Dummy rig capabilities. + */ + +#define RPCRIG_FUNC 0 +#define RPCRIG_SET_LEVEL (RIG_LEVEL_ATT | RIG_LEVEL_AF) +#define RPCRIG_LEVEL (RPCRIG_SET_LEVEL | RIG_LEVEL_STRENGTH) + +#define RPCRIG_MODES (RIG_MODE_AM | RIG_MODE_CW | \ + RIG_MODE_USB | RIG_MODE_LSB | RIG_MODE_FM | RIG_MODE_WFM) + +struct rig_caps rpcrig_caps = { + rig_model: RIG_MODEL_RPC, + model_name: "RPC rig", + mfg_name: "Hamlib", + version: "0.1", + copyright: "LGPL", + status: RIG_STATUS_NEW, + rig_type: RIG_TYPE_OTHER, + targetable_vfo: 0, + ptt_type: RIG_PTT_NONE, + dcd_type: RIG_DCD_NONE, + port_type: RIG_PORT_NONE, + has_get_func: RPCRIG_FUNC, + has_set_func: RPCRIG_FUNC, + has_get_level: RPCRIG_LEVEL, + has_set_level: RPCRIG_SET_LEVEL, + has_get_parm: RIG_PARM_NONE, /* FIXME */ + has_set_parm: RIG_PARM_NONE, /* FIXME */ + ctcss_list: NULL, /* FIXME */ + dcs_list: NULL, /* FIXME */ + chan_list: { RIG_CHAN_END, }, /* FIXME */ + transceive: RIG_TRN_OFF, + attenuator: { 10, 20, 30, RIG_DBLST_END, }, + rx_range_list2: { {start:kHz(150),end:MHz(1500),modes:RPCRIG_MODES, + low_power:-1,high_power:-1,RIG_VFO_A|RIG_VFO_B}, + RIG_FRNG_END, }, + tx_range_list2: { RIG_FRNG_END, }, + tuning_steps: { {RPCRIG_MODES,1}, RIG_TS_END, }, + priv: NULL, /* priv */ + + rig_init: rpcrig_init, + rig_cleanup: rpcrig_cleanup, + rig_open: rpcrig_open, + rig_close: rpcrig_close, + + set_freq: rpcrig_set_freq, + get_freq: rpcrig_get_freq, + set_mode: rpcrig_set_mode, + get_mode: rpcrig_get_mode, + set_vfo: rpcrig_set_vfo, + get_vfo: rpcrig_get_vfo, + + set_powerstat: rpcrig_set_powerstat, + get_powerstat: rpcrig_get_powerstat, + set_level: rpcrig_set_level, + get_level: rpcrig_get_level, + set_func: rpcrig_set_func, + get_func: rpcrig_get_func, + set_parm: rpcrig_set_parm, + get_parm: rpcrig_get_parm, + + get_info: rpcrig_get_info, + + + set_ptt: rpcrig_set_ptt, + get_ptt: rpcrig_get_ptt, + get_dcd: rpcrig_get_dcd, + set_rptr_shift: rpcrig_set_rptr_shift, + get_rptr_shift: rpcrig_get_rptr_shift, + set_rptr_offs: rpcrig_set_rptr_offs, + get_rptr_offs: rpcrig_get_rptr_offs, + set_ctcss_tone: rpcrig_set_ctcss_tone, + get_ctcss_tone: rpcrig_get_ctcss_tone, + set_dcs_code: rpcrig_set_dcs_code, + get_dcs_code: rpcrig_get_dcs_code, + set_ctcss_sql: rpcrig_set_ctcss_sql, + get_ctcss_sql: rpcrig_get_ctcss_sql, + set_dcs_sql: rpcrig_set_dcs_sql, + get_dcs_sql: rpcrig_get_dcs_sql, + set_split_freq: rpcrig_set_split_freq, + get_split_freq: rpcrig_get_split_freq, + set_split_mode: rpcrig_set_split_mode, + get_split_mode: rpcrig_get_split_mode, + set_split: rpcrig_set_split, + get_split: rpcrig_get_split, + set_rit: rpcrig_set_rit, + get_rit: rpcrig_get_rit, + set_xit: rpcrig_set_xit, + get_xit: rpcrig_get_xit, + set_ts: rpcrig_set_ts, + get_ts: rpcrig_get_ts, + power2mW: rpcrig_power2mW, + mW2power: rpcrig_mW2power, + set_ant: rpcrig_set_ant, + get_ant: rpcrig_get_ant, + set_bank: rpcrig_set_bank, + set_mem: rpcrig_set_mem, + get_mem: rpcrig_get_mem, + vfo_op: rpcrig_vfo_op, + send_dtmf: rpcrig_send_dtmf, + recv_dtmf: rpcrig_recv_dtmf, + send_morse: rpcrig_send_morse, + set_channel: rpcrig_set_channel, + get_channel: rpcrig_get_channel, + set_trn: rpcrig_set_trn, + get_trn: rpcrig_get_trn, +}; + +int init_rpcrig(void *be_handle) +{ + rig_debug(RIG_DEBUG_VERBOSE, "rpcrig: _init called\n"); + + rig_register(&rpcrig_caps); + + return RIG_OK; +} + + diff --git a/rpcrig/rpcrig_backend.h b/rpcrig/rpcrig_backend.h new file mode 100644 index 000000000..58c17920c --- /dev/null +++ b/rpcrig/rpcrig_backend.h @@ -0,0 +1,31 @@ +/* + * Hamlib RPC backend - main header + * Copyright (c) 2001 by Stephane Fillod + * + * $Id: rpcrig_backend.h,v 1.1 2001-10-16 19:29:03 f4cfe Exp $ + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef _RPCRIG_H +#define _RPCRIG_H 1 + + +extern const struct rig_caps rpcrig_caps; + +extern HAMLIB_EXPORT(int) init_rpcrig(void *be_handle); + +#endif /* _RPCRIG_H */ diff --git a/rpcrig/rpcrig_clnt.c b/rpcrig/rpcrig_clnt.c new file mode 100644 index 000000000..5929f84e4 --- /dev/null +++ b/rpcrig/rpcrig_clnt.c @@ -0,0 +1,55 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#include /* for memset */ +#include "rpcrig.h" + +/* Default timeout can be changed using clnt_control() */ +static struct timeval TIMEOUT = { 25, 0 }; + +model_x * +getmodel_1(void *argp, CLIENT *clnt) +{ + static model_x clnt_res; + + memset((char *)&clnt_res, 0, sizeof(clnt_res)); + if (clnt_call (clnt, GETMODEL, + (xdrproc_t) xdr_void, (caddr_t) argp, + (xdrproc_t) xdr_model_x, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +int * +setfreq_1(freq_arg *argp, CLIENT *clnt) +{ + static int clnt_res; + + memset((char *)&clnt_res, 0, sizeof(clnt_res)); + if (clnt_call (clnt, SETFREQ, + (xdrproc_t) xdr_freq_arg, (caddr_t) argp, + (xdrproc_t) xdr_int, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} + +freq_res * +getfreq_1(vfo_x *argp, CLIENT *clnt) +{ + static freq_res clnt_res; + + memset((char *)&clnt_res, 0, sizeof(clnt_res)); + if (clnt_call (clnt, GETFREQ, + (xdrproc_t) xdr_vfo_x, (caddr_t) argp, + (xdrproc_t) xdr_freq_res, (caddr_t) &clnt_res, + TIMEOUT) != RPC_SUCCESS) { + return (NULL); + } + return (&clnt_res); +} diff --git a/rpcrig/rpcrig_proc.c b/rpcrig/rpcrig_proc.c new file mode 100644 index 000000000..83ffece61 --- /dev/null +++ b/rpcrig/rpcrig_proc.c @@ -0,0 +1,83 @@ +/* + * Hamlib RPC server - procedures + * Copyright (c) 2001 by Stephane Fillod + * + * $Id: rpcrig_proc.c,v 1.1 2001-10-16 19:29:03 f4cfe Exp $ + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include /* Standard input/output definitions */ +#include /* String function definitions */ +#include /* UNIX standard function definitions */ +#include /* File control definitions */ +#include /* Error number definitions */ +#include + +#include +#include "rpcrig.h" +#include + +extern RIG *the_rpc_rig; + +void freq_t2freq_s(freq_t freqt, freq_s *freqs) +{ + freqs->f1 = freqt & 0xffffffff; + freqs->f2 = (freqt>>32) & 0xffffffff; +} +freq_t freq_s2freq_t(freq_s *freqs) +{ + return freqs->f1 | ((freq_t)freqs->f2 << 32); +} + +model_x *getmodel_1_svc(void *arg, struct svc_req *svc) +{ + static model_x res; + + /* free previous result */ + //xdr_free(xdr_model, &res); + + res = the_rpc_rig->caps->rig_model; + + return &res; +} + +int *setfreq_1_svc(freq_arg *farg, struct svc_req *svc) +{ + static int res; + + res = rig_set_freq(the_rpc_rig, farg->vfo, freq_s2freq_t(&farg->freq)); + + return &res; +} + +freq_res *getfreq_1_svc(vfo_x *vfo, struct svc_req *svc) +{ + static freq_res res; + freq_t f; + + res.rigstatus = rig_get_freq(the_rpc_rig, *vfo, &f); + freq_t2freq_s(f, &res.freq_res_u.freq); + + return &res; +} + + diff --git a/rpcrig/rpcrig_svc.c b/rpcrig/rpcrig_svc.c new file mode 100644 index 000000000..78ac74fd1 --- /dev/null +++ b/rpcrig/rpcrig_svc.c @@ -0,0 +1,71 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#include "rpcrig.h" +#include +#include +#include +#include +#include +#include +#include + +#ifndef SIG_PF +#define SIG_PF void(*)(int) +#endif + +void +rigprog_1(struct svc_req *rqstp, register SVCXPRT *transp) +{ + union { + freq_arg setfreq_1_arg; + vfo_x getfreq_1_arg; + } argument; + char *result; + xdrproc_t _xdr_argument, _xdr_result; + char *(*local)(char *, struct svc_req *); + + switch (rqstp->rq_proc) { + case NULLPROC: + (void) svc_sendreply (transp, (xdrproc_t) xdr_void, (char *)NULL); + return; + + case GETMODEL: + _xdr_argument = (xdrproc_t) xdr_void; + _xdr_result = (xdrproc_t) xdr_model_x; + local = (char *(*)(char *, struct svc_req *)) getmodel_1_svc; + break; + + case SETFREQ: + _xdr_argument = (xdrproc_t) xdr_freq_arg; + _xdr_result = (xdrproc_t) xdr_int; + local = (char *(*)(char *, struct svc_req *)) setfreq_1_svc; + break; + + case GETFREQ: + _xdr_argument = (xdrproc_t) xdr_vfo_x; + _xdr_result = (xdrproc_t) xdr_freq_res; + local = (char *(*)(char *, struct svc_req *)) getfreq_1_svc; + break; + + default: + svcerr_noproc (transp); + return; + } + memset ((char *)&argument, 0, sizeof (argument)); + if (!svc_getargs (transp, _xdr_argument, (caddr_t) &argument)) { + svcerr_decode (transp); + return; + } + result = (*local)((char *)&argument, rqstp); + if (result != NULL && !svc_sendreply(transp, _xdr_result, result)) { + svcerr_systemerr (transp); + } + if (!svc_freeargs (transp, _xdr_argument, (caddr_t) &argument)) { + fprintf (stderr, "%s", "unable to free arguments"); + exit (1); + } + return; +} diff --git a/rpcrig/rpcrig_xdr.c b/rpcrig/rpcrig_xdr.c new file mode 100644 index 000000000..a2ef3c4be --- /dev/null +++ b/rpcrig/rpcrig_xdr.c @@ -0,0 +1,68 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#include "rpcrig.h" + +bool_t +xdr_vfo_x (XDR *xdrs, vfo_x *objp) +{ + register int32_t *buf; + + if (!xdr_u_int (xdrs, objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_freq_s (XDR *xdrs, freq_s *objp) +{ + register int32_t *buf; + + if (!xdr_u_int (xdrs, &objp->f1)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->f2)) + return FALSE; + return TRUE; +} + +bool_t +xdr_model_x (XDR *xdrs, model_x *objp) +{ + register int32_t *buf; + + if (!xdr_u_int (xdrs, objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_freq_res (XDR *xdrs, freq_res *objp) +{ + register int32_t *buf; + + if (!xdr_int (xdrs, &objp->rigstatus)) + return FALSE; + switch (objp->rigstatus) { + case 0: + if (!xdr_freq_s (xdrs, &objp->freq_res_u.freq)) + return FALSE; + break; + default: + break; + } + return TRUE; +} + +bool_t +xdr_freq_arg (XDR *xdrs, freq_arg *objp) +{ + register int32_t *buf; + + if (!xdr_vfo_x (xdrs, &objp->vfo)) + return FALSE; + if (!xdr_freq_s (xdrs, &objp->freq)) + return FALSE; + return TRUE; +} diff --git a/rpcrig/rpcrigd.c b/rpcrig/rpcrigd.c new file mode 100644 index 000000000..ff4fb442f --- /dev/null +++ b/rpcrig/rpcrigd.c @@ -0,0 +1,291 @@ +/* + * rpcrigd - (C) Stephane Fillod 2001 + * + * This program let programs control a radio through + * the mean of RPC services using Hamlib. + * + * $Id: rpcrigd.c,v 1.1 2001-10-16 19:29:03 f4cfe Exp $ + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "rpcrig.h" +#include +#include +#include +#include +#include +#include +#include +#include + + +/* TODO: autoconf should check for getopt support, include libs otherwise */ +#include + +#include + + + +/* + * Prototypes + */ +void usage(); +void version(); +void rigd_exit(); + +void rigprog_1(struct svc_req *rqstp, register SVCXPRT *transp); + + +/* + * Reminder: when adding long options, + * keep up to date SHORT_OPTIONS, usage()'s output and man page. thanks. + * NB: do NOT use -W since it's reserved by POSIX. + * TODO: add an option to read from a file + */ +#define SHORT_OPTIONS "m:r:p:P:d:D:c:vhVl" +static struct option long_options[] = +{ + {"model", 1, 0, 'm'}, + {"rig-file", 1, 0, 'r'}, + {"ptt-file", 1, 0, 'p'}, + {"dcd-file", 1, 0, 'd'}, + {"ptt-type", 1, 0, 'P'}, + {"dcd-type", 1, 0, 'D'}, + {"civaddr", 1, 0, 'c'}, + {"list", 0, 0, 'l'}, + {"verbose", 0, 0, 'v'}, + {"help", 0, 0, 'h'}, + {"version", 0, 0, 'V'}, + {0, 0, 0, 0} +}; + + + +RIG *the_rpc_rig; + +int +main (int argc, char *argv[]) +{ + register SVCXPRT *transp; + + rig_model_t my_model = RIG_MODEL_DUMMY; + int retcode; /* generic return code from functions */ + + int verbose = 0; + const char *rig_file=NULL, *ptt_file=NULL, *dcd_file=NULL; + ptt_type_t ptt_type = RIG_PTT_NONE; + dcd_type_t dcd_type = RIG_DCD_NONE; + char *civaddr = NULL; /* NULL means no need to set conf */ + + /* Arguments parsing */ + + while(1) { + int c; + int option_index = 0; + + c = getopt_long (argc, argv, SHORT_OPTIONS, + long_options, &option_index); + if (c == -1) + break; + + switch(c) { + case 'h': + usage(); + exit(0); + case 'V': + version(); + exit(0); + case 'm': + if (!optarg) { + usage(); /* wrong arg count */ + exit(1); + } + my_model = atoi(optarg); + break; + case 'r': + if (!optarg) { + usage(); /* wrong arg count */ + exit(1); + } + rig_file = optarg; + break; + case 'p': + if (!optarg) { + usage(); /* wrong arg count */ + exit(1); + } + ptt_file = optarg; + break; + case 'd': + if (!optarg) { + usage(); /* wrong arg count */ + exit(1); + } + dcd_file = optarg; + break; + case 'P': + if (!optarg) { + usage(); /* wrong arg count */ + exit(1); + } + ptt_type = atoi(optarg); + break; + case 'D': + if (!optarg) { + usage(); /* wrong arg count */ + exit(1); + } + dcd_type = atoi(optarg); + break; + case 'c': + if (!optarg) { + usage(); /* wrong arg count */ + exit(1); + } + civaddr = optarg; + break; + case 'v': + verbose++; + break; + default: + usage(); /* unknown option? */ + exit(1); + } + } + if (verbose < 2) + rig_set_debug(RIG_DEBUG_WARN); + + + /* Opening the local rig */ + + the_rpc_rig = rig_init(my_model); + + if (!the_rpc_rig) { + fprintf(stderr, "Unknown rig num %d, or initialization error.\n", + my_model); + fprintf(stderr, "Please check with --list option.\n"); + exit(2); + } + + if (rig_file) + strncpy(the_rpc_rig->state.rigport.pathname, rig_file, FILPATHLEN); + + /* + * ex: RIG_PTT_PARALLEL and /dev/parport0 + */ + if (ptt_type != RIG_PTT_NONE) + the_rpc_rig->state.pttport.type.ptt = ptt_type; + if (dcd_type != RIG_DCD_NONE) + the_rpc_rig->state.dcdport.type.dcd = dcd_type; + if (ptt_file) + strncpy(the_rpc_rig->state.pttport.pathname, ptt_file, FILPATHLEN); + if (dcd_file) + strncpy(the_rpc_rig->state.dcdport.pathname, dcd_file, FILPATHLEN); + if (civaddr) + rig_set_conf(the_rpc_rig, rig_token_lookup(the_rpc_rig, "civaddr"), civaddr); + + + if ((retcode = rig_open(the_rpc_rig)) != RIG_OK) { + fprintf(stderr,"rig_open: error = %s \n", rigerror(retcode)); + exit(2); + } + + atexit(rigd_exit); + + if (verbose > 0) + printf("Opened rig model %d, '%s'\n", the_rpc_rig->caps->rig_model, + the_rpc_rig->caps->model_name); + + + /* Setup the RPC service and fire it up */ + + + pmap_unset (RIGPROG, RIGVERS); + + transp = svcudp_create(RPC_ANYSOCK); + if (transp == NULL) { + fprintf (stderr, "%s", "cannot create udp service."); + exit(1); + } + if (!svc_register(transp, RIGPROG, RIGVERS, rigprog_1, IPPROTO_UDP)) { + fprintf (stderr, "%s", "unable to register (RIGPROG, RIGVERS, udp)."); + exit(1); + } + + transp = svctcp_create(RPC_ANYSOCK, 0, 0); + if (transp == NULL) { + fprintf (stderr, "%s", "cannot create tcp service."); + exit(1); + } + if (!svc_register(transp, RIGPROG, RIGVERS, rigprog_1, IPPROTO_TCP)) { + fprintf (stderr, "%s", "unable to register (RIGPROG, RIGVERS, tcp)."); + exit(1); + } + + svc_run (); + fprintf (stderr, "%s", "svc_run returned"); + + /* the rig gets automatically closed in rigd_exit() */ + + exit (1); + /* NOTREACHED */ +} + + +void rigd_exit() +{ + rig_close(the_rpc_rig); + rig_cleanup(the_rpc_rig); +} + + + +void usage() +{ + printf("Usage: rpc.rigd [OPTION]... [COMMAND]...\n" + "Offer RPC services to remotely control a connected radio transceiver or receiver.\n\n"); + + printf( + " -m, --model=ID select radio model number. See model list\n" + " -r, --rig-file=DEVICE set device of the radio to operate on\n" + " -p, --ptt-file=DEVICE set device of the PTT device to operate on\n" + " -d, --dcd-file=DEVICE set device of the DCD device to operate on\n" + " -P, --ptt-type=TYPE set type of the PTT device to operate on\n" + " -D, --dcd-type=TYPE set type of the DCD device to operate on\n" + " -c, --civaddr=ID set CI-V address (for Icom rigs only)\n" + " -l, --list list all model numbers and exit\n" + " -v, --verbose set verbose mode, cumulative\n" + " -h, --help display this help and exit\n" + " -V, --version output version information and exit\n\n" + ); + + printf("\nReport bugs to .\n"); + +} + +void version() +{ + printf("rpcrigd, %s\n\n", hamlib_version); + printf("%s\n", hamlib_copyright); +} + +