www.sas.com > Service and Support > Technical Support
 
Technical Support SAS - The power to know(tm)
  TS Home | Intro to Services | News and Info | Contact TS | Site Map | FAQ | Feedback


/*--------------------------------------------------------------------+
|                                                                     |
|              Copyright 1996 (c), SAS Institute Inc.                 |
|                Unpublished - All Rights Reserved                    |
|                                                                     |
|                     S A S / C  S A M P L E                          |
|                                                                     |
|       Name: L$UFSIO                                                 |
|                                                                     |
|   Language: C                                                       |
|                                                                     |
| EntryPoint: @DYNAMN                                                 |
|                                                                     |
| EntryType : C Linkage                                               |
|                                                                     |
| Files Note: 'prefix' is the installation defined high level         |
|             qualifier for the SAS/C product.                        |
|                                                                     |
|    Purpose: Sample datastream exit for FSSL.  This sample gathters  |
|             inbound/outbound datastream statistics.  At termination |
|             it writes the information to a disk file.               |
|                                                                     |
| MVS -                                                               |
|                                                                     |
|     Source: prefix.SAMPLE.C(L$UFSIO)                                |
|                                                                     |
|  Comp/Link: Use proc LC370CL, with parameter RENT and ENTRY=DYN.    |
|                                                                     |
|    Execute: See SAS/C FSSL User's Guide, section                    |
|             'Data Stream I/O Exits' for details.                    |
|                                                                     |
| CMS -                                                               |
|     Source: SAMPLC   MACLIB (L$UFSIO)                               |
|                                                                     |
|    Compile: global maclib lc370 l$fssl                              |
|             lc370 l$ufsio ( rent                                    |
|                                                                     |
|       Link: global txtlib lc370bas lc370std                         |
|             clink l$ufsio                                           |
|             load clink370 (rldsave                                  |
|             genmod l$ufsio                                          |
|             nucxload l$ufsio l$ufsio                                |
|                                                                     |
|    Execute: See SAS/C FSSL User's Guide, section                    |
|             'Data Stream I/O Exits' for details.                    |
|                                                                     |
|      Notes:                                                         |
|             - This is a sample FSSL 3270 Data Stream Exit, see      |
|               SAS/C Full-Screen Support Library User's Guide        |
|               for details on using this exit.                       |
|                                                                     |
|             - This exit was tested on TSO and CMS using the         |
|               CALENDAR example in prefix.SAMPLE.C.                  |
|                                                                     |
|                                                                     |
+--------------------------------------------------------------------*/
#include <stdio.h>
#include <fslib.h>
#include <dynam.h>
int _dynamn(int entry_code, void *work, int *ds_len,
            char *ds_iobuf, int *crab_user_words)
{
 struct FSUXWRK *fsuxwrk;
 struct DATASTREAM_STAT
 {
  unsigned int n_writes;
  unsigned int n_reads;
  unsigned int bytes_written;
  unsigned int bytes_read;
 } *stat;

 FILE *fp;

 if (entry_code < 0) return 16;    /* Avoid Debugger Entries */
 fsuxwrk = (struct FSUXWRK *)work; /* Map work area          */

 switch (entry_code)
 {
  case FSEXIT_INIT:  /* FSSL Initialization  */
   stat = (struct DATASTREAM_STAT *)
                calloc(1, sizeof(struct DATASTREAM_STAT));
   fsuxwrk->FSUXUSR2 = stat;
   return 0;
   break;

  case FSEXIT_SETFSON:  /* Set Terminal Fullscreen Mode On */
  case FSEXIT_READ:     /* Terminal data stream Read       */
    return 0;           /* No action                       */
    break;

  case FSEXIT_WRITE:    /* Terminal data stream Write      */
    stat = (struct DATASTREAM_STAT *) fsuxwrk->FSUXUSR2;
    stat->n_writes++;
    stat->bytes_written += *ds_len;
    return 0;
    break;

  case FSEXIT_POSTREAD:  /* Terminal data stream Post Read  */

    if (*ds_iobuf == 0x88)
      return 0; /* Don't count Query Reply Structured Field AID */

    stat = (struct DATASTREAM_STAT *) fsuxwrk->FSUXUSR2;
    stat->n_reads++;
    stat->bytes_read += *ds_len;
    return 0;
    break;

  case FSEXIT_TERM:      /* FSSL Termination                 */
    /*
     * The contents of the stat structure are formatted
     * and written to a file.
     */
    stat = (struct DATASTREAM_STAT *) fsuxwrk->FSUXUSR2;
    fp = fopen("TERMSTAT", "w");
    fprintf(fp,"\nNo. Writes     = %u, No. Reads  = %u"
               "\nBytes Written  = %u, Bytes Read = %u"
               "\nBytes/Write    = %#.2f, Bytes/Read = %#.2f\n",
               stat->n_writes, stat->n_reads,
               stat->bytes_written, stat->bytes_read,
      (double) stat->bytes_written/stat->n_writes,
      (double) stat->bytes_read/stat->n_reads);
    fclose(fp);
    free(fsuxwrk->FSUXUSR2);
    return 0;
    break;
 }

} /* End of Sample datastream exit.  */

Copyright (c) 2000 SAS Institute Inc. All Rights Reserved.
Terms of Use & Legal Information | Privacy Statement