Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/ekermit/dist Import ekermit-1.7 from



details:   https://anonhg.NetBSD.org/src/rev/f94230956602
branches:  trunk
changeset: 798087:f94230956602
user:      apb <apb%NetBSD.org@localhost>
date:      Fri Aug 08 19:20:38 2014 +0000

description:
Import ekermit-1.7 from
http://www.kermitproject.org/ftp/kermit/archives/ek17.tar

EK (Embedded Kermit, E-Kermit) is an implementation of the Kermit file
transfer protocol written in ANSI C and designed for embedding in
devices or firmware, use in realtime applications, or for construction
of DLLs and libraries.  A sample calling environment and i/o support are
provided for Unix.

diffstat:

 external/bsd/ekermit/dist/COPYING    |    35 +
 external/bsd/ekermit/dist/cdefs.h    |    33 +
 external/bsd/ekermit/dist/debug.h    |    40 +
 external/bsd/ekermit/dist/kermit.c   |  1619 ++++++++++++++++++++++++++++++++++
 external/bsd/ekermit/dist/kermit.h   |   423 ++++++++
 external/bsd/ekermit/dist/main.c     |   447 +++++++++
 external/bsd/ekermit/dist/makefile   |    69 +
 external/bsd/ekermit/dist/platform.h |    12 +
 external/bsd/ekermit/dist/unix.h     |    12 +
 external/bsd/ekermit/dist/unixio.c   |   627 +++++++++++++
 10 files changed, 3317 insertions(+), 0 deletions(-)

diffs (truncated from 3357 to 300 lines):

diff -r e6a294c24016 -r f94230956602 external/bsd/ekermit/dist/COPYING
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/ekermit/dist/COPYING Fri Aug 08 19:20:38 2014 +0000
@@ -0,0 +1,35 @@
+
+  E-Kermit 1.7 -- Embedded Kermit
+
+  Author:  Frank da Cruz
+  License: Revised 3-Clause BSD License
+
+  Copyright (C) 1995, 2011, 
+  Trustees of Columbia University in the City of New York.
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are met:
+
+  * Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+
+  * Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+  * Neither the name of Columbia University nor the names of its contributors
+    may be used to endorse or promote products derived from this software
+    without specific prior written permission.
+  
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+  POSSIBILITY OF SUCH DAMAGE.
diff -r e6a294c24016 -r f94230956602 external/bsd/ekermit/dist/cdefs.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/ekermit/dist/cdefs.h Fri Aug 08 19:20:38 2014 +0000
@@ -0,0 +1,33 @@
+#ifndef __CDEFS_H__
+#define __CDEFS_H__
+
+/*
+  By default, the internal routines of kermit.c are not static,
+  because this is not allowed in some embedded environments.
+  To have them declared static, define STATIC=static on the cc
+  command line.
+*/
+#ifdef XAC  /* HiTech's XAC cmd line is small */
+#define STATIC static
+#else /* XAC */
+#ifndef STATIC
+#define STATIC
+#endif /* STATIC */
+#endif /* XAC */
+
+/*
+  By default we assume the compiler supports unsigned char and
+  unsigned long.  If not you can override these definitions on
+  the cc command line.
+*/
+#ifndef HAVE_UCHAR
+typedef unsigned char UCHAR;
+#endif /* HAVE_UCHARE */
+#ifndef HAVE_ULONG
+typedef unsigned long ULONG;
+#endif /* HAVE_ULONG */
+#ifndef HAVE_USHORT
+typedef unsigned short USHORT;
+#endif /* HAVE_USHORT */
+
+#endif /* __CDEFS_H__ */
diff -r e6a294c24016 -r f94230956602 external/bsd/ekermit/dist/debug.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/ekermit/dist/debug.h Fri Aug 08 19:20:38 2014 +0000
@@ -0,0 +1,40 @@
+#ifndef NODEBUG                                /* NODEBUG inhibits debugging */
+#ifndef DEBUG                          /* and if DEBUG not already defined */
+#ifndef MINSIZE                                /* MINSIZE inhibits debugging */
+#ifndef DEBUG
+#define DEBUG
+#endif /* DEBUG */
+#endif /* MINSIZE */
+#endif /* DEBUG */
+#endif /* NODEBUG */
+
+#ifdef DEBUG                           /* Debugging included... */
+/* dodebug() function codes... */
+#define DB_OPN 1                       /* Open log */
+#define DB_LOG 2                       /* Write label+string or int to log */
+#define DB_MSG 3                       /* Write message to log */
+#define DB_CHR 4                       /* Write label + char to log */
+#define DB_PKT 5                       /* Record a Kermit packet in log */
+#define DB_CLS 6                       /* Close log */
+
+void dodebug(int, UCHAR *, UCHAR *, long); /* Prototype */
+/*
+  dodebug() is accessed throug a macro that:
+   . Coerces its args to the required types.
+   . Accesses dodebug() directly or thru a pointer according to context.
+   . Makes it disappear entirely if DEBUG not defined.
+*/
+#ifdef KERMIT_C
+/* In kermit.c we debug only through a function pointer */
+#define debug(a,b,c,d) \
+if(*(k->dbf))(*(k->dbf))(a,(UCHAR *)b,(UCHAR *)c,(long)(d))
+
+#else  /* KERMIT_C */
+/* Elsewhere we can call the debug function directly */
+#define debug(a,b,c,d) dodebug(a,(UCHAR *)b,(UCHAR *)c,(long)(d))
+#endif /* KERMIT_C */
+
+#else  /* Debugging not included... */
+
+#define debug(a,b,c,d)
+#endif /* DEBUG */
diff -r e6a294c24016 -r f94230956602 external/bsd/ekermit/dist/kermit.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/ekermit/dist/kermit.c        Fri Aug 08 19:20:38 2014 +0000
@@ -0,0 +1,1619 @@
+#define KERMIT_C
+/*
+  Embedded Kermit protocol module
+  Version: 1.7
+  Most Recent Update: Mon Jun  6 15:36:26 2011
+
+  No stdio or other runtime library calls, no system calls, no system 
+  includes, no static data, and no global variables in this module.
+
+  Warning: you can't use debug() in any routine whose argument list
+  does not include "struct k_data * k".  Thus most routines in this
+  module include this arg, even if they don't use it.
+
+  Author: Frank da Cruz.
+  As of version 1.6 of 30 March 2011, E-Kermit is Open Source software under
+  the Revised 3-Clause BSD license which follows.  E-Kermit 1.6 is identical
+  to version 1.51 except for the new license.
+
+  Author: Frank da Cruz.
+
+  Copyright (C) 1995, 2011, 
+  Trustees of Columbia University in the City of New York.
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are met:
+
+  * Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+
+  * Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+  * Neither the name of Columbia University nor the names of its contributors
+    may be used to endorse or promote products derived from this software
+    without specific prior written permission.
+  
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+  POSSIBILITY OF SUCH DAMAGE.
+*/
+#include "cdefs.h"                     /* C language defs for all modules */
+#include "debug.h"                     /* Debugging */
+#include "kermit.h"                    /* Kermit protocol definitions */
+
+#define zgetc() \
+((--(k->zincnt))>=0)?((int)(*(k->zinptr)++)&0xff):(*(k->readf))(k)
+
+/* See cdefs.h for meaning of STATIC, ULONG, and UCHAR */
+
+STATIC ULONG stringnum(UCHAR *, struct k_data *);
+STATIC UCHAR * numstring(ULONG, UCHAR *, int, struct k_data *);
+int STATIC spkt(char, short, int, UCHAR *, struct k_data *);
+int STATIC ack(struct k_data *, short, UCHAR * text);
+int STATIC nak(struct k_data *, short, short);
+int STATIC chk1(UCHAR *, struct k_data *);
+STATIC USHORT chk2(UCHAR *, struct k_data *);
+#ifdef F_CRC
+STATIC USHORT chk3(UCHAR *, struct k_data *);
+#endif /* F_CRC */
+void STATIC spar(struct k_data *, UCHAR *, int);
+int STATIC rpar(struct k_data *, char);
+int STATIC decode(struct k_data *, struct k_response *, short, UCHAR *);
+#ifdef F_AT
+int STATIC gattr(struct k_data *, UCHAR *, struct k_response *);
+int STATIC sattr(struct k_data *, struct k_response *);
+#endif /* F_AT */
+#ifndef RECVONLY
+int STATIC sdata(struct k_data *, struct k_response *);
+#endif /* RECVONLY */
+void STATIC epkt(char *, struct k_data *);
+int STATIC getpkt(struct k_data *, struct k_response *);
+int STATIC encstr(UCHAR *, struct k_data *, struct k_response *);
+void STATIC decstr(UCHAR *, struct k_data *, struct k_response *);
+void STATIC encode(int, int, struct k_data *);
+int STATIC nxtpkt(struct k_data *);
+int STATIC resend(struct k_data *);
+#ifdef DEBUG
+int xerror(void);
+#endif /* DEBUG */
+
+int                                    /* The kermit() function */
+kermit(short f,                                /* Function code */
+       struct k_data *k,               /* The control struct */
+       short r_slot,                   /* Received packet slot number */
+       int len,                                /* Length of packet in slot */
+       char *msg,                      /* Message for error packet */
+       struct k_response *r) {         /* Response struct */
+
+    int i, j, rc;                      /* Workers */
+    int datalen;                        /* Length of packet data field */
+    UCHAR *p;                           /* Pointer to packet data field */
+    UCHAR *q;                           /* Pointer to data to be checked */
+    UCHAR *s;                          /* Worker string pointer */
+    UCHAR c, t;                         /* Worker chars */
+    UCHAR pbc[4];                       /* Copy of packet block check */
+    short seq, prev;                   /* Copies of sequence numbers */
+    short chklen;                       /* Length of packet block check */
+#ifdef F_CRC
+    unsigned int crc;                   /* 16-bit CRC */
+#endif /* F_CRC */
+    int ok;
+
+    debug(DB_MSG,"----------",0,0);    /* Marks each entry */
+    debug(DB_LOG,"f",0,f);
+    debug(DB_LOG,"state",0,k->state);
+    debug(DB_LOG,"zincnt",0,(k->zincnt));
+
+    if (f == K_INIT) {                 /* Initialize packet buffers etc */
+
+       k->version = (UCHAR *)VERSION;  /* Version of this module */
+        r->filename[0] = '\0';         /* No filename yet. */
+        r->filedate[0] = '\0';         /* No filedate yet. */
+        r->filesize = 0L;               /* No filesize yet. */
+       r->sofar = 0L;                  /* No bytes transferred yet */
+
+        for (i = 0; i < P_WSLOTS; i++) { /* Packet info for each window slot */
+           freerslot(k,i);
+           freesslot(k,i);
+       }
+#ifdef F_TSW
+        for (i = 0; i < 64; i++) {     /* Packet finder array */
+           k->r_pw[i] = -1;            /* initialized to "no packets yet" */
+           k->s_pw[i] = -1;            /* initialized to "no packets yet" */
+       }
+#endif /* F_TSW */
+
+/* Initialize the k_data structure */    
+
+       for (i = 0; i < 6; i++)
+         k->s_remain[i] = '\0';
+
+        k->state    = R_WAIT;          /* Beginning protocol state */
+       r->status   = R_WAIT;
+       k->what     = W_RECV;           /* Default action */
+       k->s_first  = 1;                /* Beginning of file */
+        k->r_soh    = k->s_soh = SOH;  /* Packet start */
+        k->r_eom    = k->s_eom = CR;   /* Packet end */
+        k->s_seq    = k->r_seq =  0;   /* Packet sequence number */
+        k->s_type   = k->r_type = 0;   /* Packet type */
+        k->r_timo   = P_R_TIMO;                /* Timeout interval for me to use */
+        k->s_timo   = P_S_TIMO;                /* Timeout for other Kermit to use */
+        k->r_maxlen = P_PKTLEN;         /* Maximum packet length */
+        k->s_maxlen = P_PKTLEN;         /* Maximum packet length */
+        k->window   = P_WSLOTS;                /* Maximum window slots */
+        k->wslots   = 1;               /* Current window slots */
+       k->zincnt   = 0;
+       k->dummy    = 0;
+       k->filename = (UCHAR *)0;
+
+        /* Parity must be filled in by the caller */
+
+        k->retry  = P_RETRY;            /* Retransmission limit */
+        k->s_ctlq = k->r_ctlq = '#';    /* Control prefix */
+        k->ebq    = 'Y';               /* 8th-bit prefix negotiation */
+       k->ebqflg = 0;                  /* 8th-bit prefixing flag */
+        k->rptq   = '~';               /* Send repeat prefix */
+        k->rptflg = 0;                  /* Repeat counts negotiated */
+       k->s_rpt  = 0;                  /* Current repeat count */
+        k->capas  = 0                   /* Capabilities */
+#ifdef F_LP
+          | CAP_LP                      /* Long packets */
+#endif /* F_LP */
+#ifdef F_SW
+            | CAP_SW                    /* Sliding windows */
+#endif /* F_SW */
+#ifdef F_AT



Home | Main Index | Thread Index | Old Index