Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #777

Re: Announce: Aztec C Shell Utilities including No Slot Clock Examples

From "Bill Buckels" <bbuckels@mts.net>
Newsgroups comp.sys.apple2.programmer
Subject Re: Announce: Aztec C Shell Utilities including No Slot Clock Examples
Date 2013-07-25 20:05 -0500
Organization Aioe.org NNTP Server
Message-ID <kssi0l$57s$1@speranza.aioe.org> (permalink)
References <ks1pdv$pji$1@speranza.aioe.org> <962b3d52-d74d-428f-8d46-888e2945aac7@googlegroups.com>

Show all headers | View raw


Marco <mverpelli@libero.it> wrote:
> May I ask for the source code of findopen, findnext and findclose used in 
> lm.c ?

Hi Marco,

Changing the topic a little, I will be releasing a cross-compiler for the 
Aztec C DOS 3.3 Shell fairly soon.

One of the Aztec C DOS 3.3 shell program "demos" bundled with the compiler, 
DLIST, modifies the CATALOG command to list without pausing in a continuous 
block, then calls CATALOG and then scrapes the screen and prepares a list of 
the files on a DOS 3.3 disk. The DLIST program accepts command line 
arguments for filematching of extensions and for creating text file lists of 
the files on the DOS 3.3 disk, which is its primary function.

You'll probably want to look at the source for that one too. DOS 3.3's 
built-in catalog customization is limited. No setting exists to display the 
filename field only, nor to modify the length of the other fields.

The DOS 3.3 shell is not quite as robust as the Aztec C ProDOS Shell, just 
as DOS 3.3 is not as robust as ProDOS but it is older so that can be 
expected. However, the programs are tiny.

Here's a little of the code:)

x---snip---x

    /* catalog the disk */
    precat();
    catalog(6,1,254);
    postcat();
    /* scrape the screen */
    cnt = dlines();

    scr_clear();
 scr_curs(0,0);

    /* list the files */
    if (cnt > 0) {
  cnt = dlist();
  printf("%d file(s).\n",cnt);
 }
 else {
  printf("dlines returned %d.\n",cnt);
 }

x--- snip---x

And here's a little more:)

x---snip---x

/* buffer to save and restore catalog settings */
char savecat[6];

/* function precat() is called for two main purposes:

   1. To save default catalog settings.
   2. To set-up the custom catalog settings required by this program prior
   to making the catalog call

   Note: precat() must be called to save catalog listing settings before
   calling postcat()  */
precat()
{

  /* cancels carriage returns after catalog file names */
  char *crcat = (char*)0xAE22;
  /* cancels catalog pause */
  char *cancat = (char*)0xAE34;
  /* number of characters in catalog file name */
  char *lencat = (char *)0xAE17;

  char c = (char)234;
  int len;

  /* initialize screen-scraper buffer to 0's (NULL)
     and initialize extension field position to 127
     before calling the catalog function
  */
  clear(&dline[0],BUFLEN,(char)0);
  clear(&dext[0],CATMAX,(char)127);

  /* save previous settings for catalog function */
  savecat[0] = crcat[0];
  savecat[1] = crcat[1];
  savecat[2] = crcat[2];

  savecat[3] = cancat[0];
  savecat[4] = cancat[1];
  savecat[5] = cancat[2];

  /* cancel carriage returns for catalog */
  crcat[0] = c;
  crcat[1] = c;
  crcat[2] = c;

  /* cancel catalog pause */
  cancat[0] = c;
  cancat[1] = c;
  cancat[2] = c;

  lencat[0] = (char)16;

  /* clear screen and write "header tag" */
  len = strlen("\n");
  write(1,"\n",len);

  scr_clear();
  scr_curs(0,0);

  write(1,"****",4);


}

/*  function postcat() is called after making the catalog call to restore
 the default catalog settings saved by function precat().

    Note: precat() must be called to save catalog listing settings before
 calling postcat(). */
postcat()
{

  /* cancels carriage returns after catalog file names */
  char *crcat = (char*)0xAE22;
  /* cancels catalog pause */
  char *cancat = (char*)0xAE34;
  /* number of characters in catalog file name */
  char *lencat = (char *)0xAE17;

  int len;

  /* restore saved default catalog settings */
  crcat[0] = savecat[0];
  crcat[1] = savecat[1];
  crcat[2] = savecat[2];

  cancat[0] = savecat[3];
  cancat[1] = savecat[4];
  cancat[2] = savecat[5];

  lencat[0] = (char)29;

  /* write "footer tag" */
  len = strlen("\n");
  write(1,"**\n****",(len+6));

}

/* 80 column screen-scraper helper function for dlines

   scrapes a line of the catalog listing from screen memory into a buffer
   line. converts text from apple II high-ascii screen memory format to the
   normal ascii that we all know and love...

*/
drow(x,cnt)
{
  char *pgptr = (char *)0xC054;
  unsigned int crt;
  int i,j,k;

     j = (cnt * 80);
     k = j+1;

     crt = textbase[x];
     pgptr[1] = 0x00; /* aux mem */

     for (i = crt + 40;crt<i;crt++,j+=2)
   dline[j] = (char)(poke[crt] - 128);


     crt = textbase[x];
     pgptr[0] = 0x00; /* main mem */

     for (i = crt + 40;crt<i;crt++,k+=2)
   dline[k] = (char)(poke[crt] - 128);
}


dlines()
{
 int i, cnt = 0;
    char *ptr = (char *)0x400;
    unsigned int crt;

    /* if our "header tag" (double asterisks)
       at cursor position 0,0 has "scrolled-up" just fail ! */
    if (ptr[0] != (char)170 || ptr[1] != (char)170) return -1;

    /* otherwise file listings start at the 5th row of the screen */
 for (i = 4; i < 23; i++) {
  drow(i,cnt);
  cnt++;
  crt = textbase[i];
  ptr = (char *)&poke[crt];
  /* if our "footer tag" (double asterisks)
           has been reached, return the line count */
        if (ptr[0] == (char)170 && ptr[1] == (char)170) break;
 }

 return cnt;
}

dlist()
{
 int i, j=1, k, cnt = 0, len, n, epos, elen, f=0;
 char *name, *ext, ch;


    /* step 1 - walk through the catalog listings until we reach the end...

    the filetype field in the blank entry at the end of the listing will
    either begin with a whitespace or an asterisk... in either case we
    relace the first byte in the blank entry following the listing with
    an ascii 0 */

    for (i = 0; i < BUFLEN; i+= CATLEN,j+=CATLEN) {
  if (dline[j] == (char)32) dline[i] = (char)0;
  if (dline[j] == (char)42) dline[i] = (char)0;
  if (dline[i] == (char)0)break;
 }

    /* step 2 - command line options */

    /* open the output file if any */
    if (wild[0] != 0) {
  f = -1;
  fp = fopen(wild, "w");
        if (NULL != fp) f=1;
 }

    /* get extension length if any */
    elen = strlen(srch);

    /* step 3 - check for matching files. if file matches, increment counter
    and write formatted output to screen and if optional output
    file name was specified write file list to output file */

 len = strlen("\n");

 for (j = 0,i=0; j < CATMAX; j++,i+= CATLEN) {
  /* if the first character of the catalog structure entry is ascii 0
     we have reached the end of the listing */
  if (dline[i] == (char)0) break;

  /* offset to the name field in the catalog data structure */
  n = i + ONAME;
  name = (char *)&dline[n];
  /* truncate name field */
  name[16] = (char *)0;

        /* if the extension length is 0 then filematch is
           turned-off so list all files */
        if (elen == 0) {
   /* default - list all files to screen */
   write(1,name,16);
   if ((cnt % 4) == 3) write(1,"\n",len);
   else write(1," ",len);
   cnt++;
   /* if no output file then loop to next */
            if (f != 1) continue;
     }

        for (k = 0; k < 16; k++) {
     ch = name[k];
     if (ch == '.') dext[j] = (char)k;
     if (ch == 32) name[k] = (char)0;
  }

  if (elen == 0) {
   continue;
     }

  /* extension match from here, so...
     if filename has no extension
     then skip-it */
  k = (int)dext[j];
  if (k == 127) continue;
  ext = (char *)&name[k];

  for (k = 0; k < elen; k++) {
     if (ext[k] == srch[k]) continue;
     k = 127;
     break;
  }
        /* if extension does not match
           skip it */
  if (k == 127) continue;

  /* option - list matching files to screen */
  printf("%-16s",name);
  if ((cnt % 4) == 3) write(1,"\n",len);
  else write(1," ",len);
        cnt++;

     /* option - list match to file */
  if (f == 1) fprintf(fp,"%s\n",name);
 }

 write(1,"\n",len);
 if (f==1) {
  fclose(fp);
  if (cnt != 0) printf("%s created!\n",wild);
  else unlink(wild);
 }
 if (f == -1) printf("could not create %s!\n",wild);

 return cnt;
}


Back to comp.sys.apple2.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Announce: Aztec C Shell Utilities including No Slot Clock Examples "Bill Buckels" <bbuckels@mts.net> - 2013-07-15 16:26 -0500
  Re: Announce: Aztec C Shell Utilities including No Slot Clock Examples mverpelli@libero.it - 2013-07-24 04:35 -0700
    Re: Announce: Aztec C Shell Utilities including No Slot Clock Examples "Bill Buckels" <bbuckels@mts.net> - 2013-07-24 10:19 -0500
    Re: Announce: Aztec C Shell Utilities including No Slot Clock Examples "Bill Buckels" <bbuckels@mts.net> - 2013-07-24 10:32 -0500
      Re: Announce: Aztec C Shell Utilities including No Slot Clock Examples mverpelli@libero.it - 2013-07-24 09:01 -0700
    Re: Announce: Aztec C Shell Utilities including No Slot Clock Examples "Bill Buckels" <bbuckels@mts.net> - 2013-07-25 20:05 -0500
      Re: Announce: Aztec C Shell Utilities including No Slot Clock Examples mverpelli@libero.it - 2013-07-26 01:43 -0700
        Re: Announce: Aztec C Shell Utilities including No Slot Clock Examples "Bill Buckels" <bbuckels@mts.net> - 2013-07-26 05:12 -0500

csiph-web