Annotation of 43BSDReno/contrib/isode-beta/others/rtf/rtfsbr.c, revision 1.1.1.1

1.1       root        1: /* rtfs.c - RT-file transfer utility -- common subroutines */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/others/rtf/RCS/rtfsbr.c,v 7.0 89/11/23 22:10:50 mrose Rel $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/others/rtf/RCS/rtfsbr.c,v 7.0 89/11/23 22:10:50 mrose Rel $
                      9:  *
                     10:  *
                     11:  * $Log:       rtfsbr.c,v $
                     12:  * Revision 7.0  89/11/23  22:10:50  mrose
                     13:  * Release 6.0
                     14:  * 
                     15:  */
                     16: 
                     17: /*
                     18:  *                               NOTICE
                     19:  *
                     20:  *    Acquisition, use, and distribution of this module and related
                     21:  *    materials are subject to the restrictions of a license agreement.
                     22:  *    Consult the Preface in the User's Manual for the full terms of
                     23:  *    this agreement.
                     24:  *
                     25:  */
                     26: 
                     27: 
                     28: #include "rtf.h"
                     29: #include <varargs.h>
                     30: #if    defined(SYS5) && !defined(HPUX)
                     31: #include <sys/times.h>
                     32: #define        TMS
                     33: #endif
                     34: 
                     35: /*    DATA */
                     36: 
                     37: static LLog _pgm_log = {
                     38:     "rtf.log", NULLCP, NULLCP, LLOG_FATAL | LLOG_EXCEPTIONS | LLOG_NOTICE,
                     39:     LLOG_FATAL, -1, LLOGCLS | LLOGCRT | LLOGZER, NOTOK
                     40: };
                     41: LLog *pgm_log = &_pgm_log;
                     42: 
                     43: /*  */
                     44: 
                     45: #define        RC_BASE 0x80
                     46: 
                     47: 
                     48: static char *reason_err0[] = {
                     49:     "no specific reason stated",
                     50:     "user receiving ability jeopardized",
                     51:     "reserved(1)",
                     52:     "user sequence error",
                     53:     "reserved(2)",
                     54:     "local SS-user error",
                     55:     "unreceoverable procedural error"
                     56: };
                     57: 
                     58: static int reason_err0_cnt = sizeof reason_err0 / sizeof reason_err0[0];
                     59: 
                     60: 
                     61: static char *reason_err8[] = {
                     62:     "demand data token"
                     63: };
                     64: 
                     65: static int reason_err8_cnt = sizeof reason_err8 / sizeof reason_err8[0];
                     66: 
                     67: 
                     68: char   *SReportString (code)
                     69: int    code;
                     70: {
                     71:     register int    fcode;
                     72:     static char buffer[BUFSIZ];
                     73: 
                     74:     if (code == SP_PROTOCOL)
                     75:        return "SS-provider protocol error";
                     76: 
                     77:     code &= 0xff;
                     78:     if (code & RC_BASE) {
                     79:        if ((fcode = code & ~RC_BASE) < reason_err8_cnt)
                     80:            return reason_err8[fcode];
                     81:     }
                     82:     else
                     83:        if (code < reason_err0_cnt)
                     84:            return reason_err0[code];
                     85: 
                     86:     (void) sprintf (buffer, "unknown reason code 0x%x", code);
                     87:     return buffer;
                     88: }
                     89: 
                     90: /*  */
                     91: 
                     92: void   rts_adios (rta, event)
                     93: register struct RtSAPabort *rta;
                     94: char   *event;
                     95: {
                     96:     rts_advise (rta, event);
                     97: 
                     98:     _exit (1);
                     99: }
                    100: 
                    101: 
                    102: void   rts_advise (rta, event)
                    103: register struct RtSAPabort *rta;
                    104: char   *event;
                    105: {
                    106:     char    buffer[BUFSIZ];
                    107: 
                    108:     if (rta -> rta_cc > 0)
                    109:        (void) sprintf (buffer, "[%s] %*.*s", RtErrString (rta -> rta_reason),
                    110:                rta -> rta_cc, rta -> rta_cc, rta -> rta_data);
                    111:     else
                    112:        (void) sprintf (buffer, "[%s]", RtErrString (rta -> rta_reason));
                    113: 
                    114:     advise (LLOG_NOTICE, NULLCP, "%s: %s", event, buffer);
                    115: }
                    116: 
                    117: /*  */
                    118: 
                    119: #ifndef        lint
                    120: void   adios (va_alist)
                    121: va_dcl
                    122: {
                    123:     va_list ap;
                    124: 
                    125:     va_start (ap);
                    126:     
                    127:     _ll_log (pgm_log, LLOG_FATAL, ap);
                    128: 
                    129:     va_end (ap);
                    130: 
                    131:     _exit (1);
                    132: }
                    133: #else
                    134: /* VARARGS */
                    135: 
                    136: void   adios (what, fmt)
                    137: char   *what,
                    138:        *fmt;
                    139: {
                    140:     adios (what, fmt);
                    141: }
                    142: #endif
                    143: 
                    144: 
                    145: #ifndef        lint
                    146: void   advise (va_alist)
                    147: va_dcl
                    148: {
                    149:     int            code;
                    150:     va_list ap;
                    151: 
                    152:     va_start (ap);
                    153:     
                    154:     code = va_arg (ap, int);
                    155: 
                    156:     _ll_log (pgm_log, code, ap);
                    157: 
                    158:     va_end (ap);
                    159: }
                    160: #else
                    161: /* VARARGS */
                    162: 
                    163: void   advise (code, what, fmt)
                    164: char   *what,
                    165:        *fmt;
                    166: int    code;
                    167: {
                    168:     advise (code, what, fmt);
                    169: }
                    170: #endif
                    171: 
                    172: 
                    173: #ifndef        lint
                    174: void   ryr_advise (va_alist)
                    175: va_dcl
                    176: {
                    177:     va_list ap;
                    178: 
                    179:     va_start (ap);
                    180: 
                    181:     _ll_log (pgm_log, LLOG_NOTICE, ap);
                    182: 
                    183:     va_end (ap);
                    184: }
                    185: #else
                    186: /* VARARGS */
                    187: 
                    188: void   ryr_advise (what, fmt)
                    189: char   *what,
                    190:        *fmt;
                    191: {
                    192:     ryr_advise (what, fmt);
                    193: }
                    194: #endif
                    195: 
                    196: /*  */
                    197: 
                    198: #ifdef lint
                    199: /* VARARGS4 */
                    200: 
                    201: int    rtsaplose (rti, reason, what, fmt)
                    202: struct RtSAPindication *rti;
                    203: int    reason;
                    204: char   *what,
                    205:        *fmt;
                    206: {
                    207:     return rtsaplose (rti, reason, what, fmt);
                    208: }
                    209: #endif
                    210: 
                    211: /*  */
                    212: 
                    213: #ifndef        NBBY
                    214: #define        NBBY    8
                    215: #endif
                    216: 
                    217: 
                    218: #ifndef        TMS
                    219: timer (cc)
                    220: int     cc;
                    221: {
                    222:     long    ms;
                    223:     float   bs;
                    224:     struct timeval  stop,
                    225:                     td;
                    226:     static struct timeval   start;
                    227: 
                    228:     if (cc == 0) {
                    229:        (void) gettimeofday (&start, (struct timezone *) 0);
                    230:        return;
                    231:     }
                    232:     else
                    233:        (void) gettimeofday (&stop, (struct timezone  *) 0);
                    234: 
                    235:     tvsub (&td, &stop, &start);
                    236:     ms = (td.tv_sec * 1000) + (td.tv_usec / 1000);
                    237:     bs = (((float) cc * NBBY * 1000) / (float) (ms ? ms : 1)) / NBBY;
                    238: 
                    239:     advise (LLOG_NOTICE, NULLCP,
                    240:            "transfer complete: %d bytes in %d.%02d seconds (%.2f Kbytes/s)",
                    241:            cc, td.tv_sec, td.tv_usec / 10000, bs / 1024);
                    242: }
                    243: 
                    244: 
                    245: static  tvsub (tdiff, t1, t0)
                    246: register struct timeval *tdiff,
                    247:                        *t1,
                    248:                        *t0;
                    249: {
                    250: 
                    251:     tdiff -> tv_sec = t1 -> tv_sec - t0 -> tv_sec;
                    252:     tdiff -> tv_usec = t1 -> tv_usec - t0 -> tv_usec;
                    253:     if (tdiff -> tv_usec < 0)
                    254:        tdiff -> tv_sec--, tdiff -> tv_usec += 1000000;
                    255: }
                    256: 
                    257: #else
                    258: long   times ();
                    259: 
                    260: 
                    261: static timer (cc)
                    262: int    cc;
                    263: {
                    264:     long    ms;
                    265:     float   bs;
                    266:     long    stop,
                    267:            td,
                    268:            secs,
                    269:            msecs;
                    270:     struct tms tm;
                    271:     static long start;
                    272: 
                    273:     if (cc == 0) {
                    274:        start = times (&tm);
                    275:        return;
                    276:     }
                    277:     else
                    278:        stop = times (&tm);
                    279: 
                    280:     td = stop - start;
                    281:     secs = td / 60, msecs = (td % 60) * 1000 / 60;
                    282:     ms = (secs * 1000) +  msecs;
                    283:     bs = (((float) cc * NBBY * 1000) / (float) (ms ? ms : 1)) / NBBY;
                    284:     
                    285:     advise (LLOG_NOTICE, NULLCP,
                    286:            "transfer complete: %d bytes in %d.%02d seconds (%.2f Kbytes/s)",
                    287:            cc, secs, msecs / 10, bs / 1024);
                    288: }
                    289: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.