From: JAMES=NEARING%50%WPNSTAC@FS.NWSCON.SEA06.NAVY.MIL
Newsgroups: bit.listserv.banyan-l
Subject: re: Associated Record '0' layout
Date: 15 Dec 92 13:56:24 GMT
Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU

Greg,
   Here is a program I wrote with the toolkit a while back.  It pulls
out the description.  Hope you can follow twisted logic.


#define INCL_ST
#include <vnsapi.h>
#include <streetta.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define PGM  "StrTalk"

void main ()
{
                              /*  reads streettalk and creates a file
*/
                              /*  with our names to upload to ddn
*/
FILE *navdir;
int rc;
int i,j;
int foo,bar,flag,bubs;
int done;
int name_length;
int group_len;
char *null="";
char *at_sign;
char *at_sign1;
char *ptr;
char *a_space=" ";
char *equal_sign="=";
char *percent_sign="%";
char *code="CODE";
char distinguished_name[40];
char first_initial[3];
char userid[64];
char *host="fs.nwscon.sea06.navy.mil";
char *site="WPNSTAC Concord, CA";
char *application="VINES";
char bldg[8];
char desc[64];
char name[64];
char first_name[15];
char last_name[25];
char nicename[64];
char group[6];
char organization[20];
char pattern[64]="*@*@wpnstac";
char oName[STNAMELEN];
unsigned short oNameLen;
char szAR[MAXASSOC];
unsigned short ARlen;
Cardinal etype,arnum;
ObjectClass class;
Catselect catsel;
Cardinal pass;
STRecord rec,rec1;
CallStatus stat;
char eos_record[19][64];
char
bad_pizza[12][8]={"60","PWMA","PRINTER","MAIL","PCP","ADMIN","SAMPLE","
TALCS","BAN","TACK","MRM","TEST"};
catsel.ExcludeFlag = 0;
catsel.cats.length = 0;
etype = 300;
arnum=0;
class = 1;
done = 0;
pass = 0;

printf("\n begin program \a%s: ",PGM);
if ((navdir=fopen("maildir","w"))==NULL)
{
 printf ("cannot open your output file, Jim \n");
 exit(1);
}

while (!done)
{
  st1retry:
   if((stat = VnsListStNames(pattern, etype, class, &catsel,&pass,
&rec))!=0)
     {
       switch(stat)
         {
           case ERSTENUMCONSIST:
                                printf ("\nST error, restarting \n");
                                goto st1retry;
                                break;
           case ERSTECOMPLETE:
                                printf ("\n list complete \n");
                                break;
           case ERSTEINCOMPLETE:
                                printf ("\n unreachable servers? \n");
                                break;
         }  /* switch */
      }     /* if     */
      if((pass==0)||(stat!=0))
         done = 1;
      else
         {
           for(i=0;i<rec.ENUM_case.length;i++)
            {
              strcpy (name,rec.ENUM_case.sequence[i]);
              at_sign = strchr(name,'@');
              at_sign1 = strstr(name,"@W");
              group_len = (at_sign1-at_sign)-1;
              name_length=(at_sign - name);
              strcpy (nicename,null);
              strncat (nicename,name,name_length);
              strcpy (group,null);
              strncat (group, (at_sign+1),group_len);
              strcat (group,null);
              foo=(VnsGetSStAssocRecord
(arnum,name,class,&rec1,oName,&oNameLen,szAR,&ARlen));
              strcpy (desc,rec1.USER_case.descrip);
              strcat (desc,'\0');

             /* now stop screwing around and build the record */
              for (foo=0;foo<19;foo++)
                 eos_record[foo][0]='\0';    /* empty out the record */
              ptr = strchr(nicename,' ');
              name_length=(ptr-nicename);
              strcpy (first_name,null);
              strncat (first_name,nicename,name_length);
              strcpy (last_name,null);
              strcat (last_name,(ptr+1));
              first_initial[0]=first_name[0];
              first_initial[1]=32;
              first_initial[2]='\0';
              strcpy (distinguished_name,null);
              strcat (distinguished_name,first_initial);
              strcat (distinguished_name,last_name);
              strcpy (userid,null);
              strcat (userid,first_name);
              strcat (userid,equal_sign);
              strcat (userid,last_name);
              strcpy (organization,null);

              /* before making the record, let's check for bad pizza */
              flag=0;
              for (foo=0;foo<12;foo++)
                  {
                    if (strstr(nicename,bad_pizza[foo]))
                       flag++;
                   }
              strcat (eos_record[1],distinguished_name);
              strcat (eos_record[2],userid);
              strcat (eos_record[2],percent_sign);
              strcat (eos_record[2],group);
              strcat (eos_record[2],percent_sign);
              strcat (eos_record[2],"WPNSTAC");
              strcat (eos_record[3],host);
              strcat (eos_record[4],application);
              strcat (eos_record[5],nicename);

/* the description in streettalk should be formatted as follows */
/* 523,E-98,x2659,Computer Specialist                           */
/* let's look for the commas to make sure                       */

              bubs=0;
              for (foo=0;desc[foo];foo++)
                 {
                    if (desc[foo]==0x2c)
                       bubs++;
                 }
              if (bubs>2)
                {
                  foo=0;
                  bar=0;
                  while (desc[foo]!=0x2c)
                   eos_record[6][bar++]=desc[foo++];
                  eos_record[6][bar]='\0';
                  foo++;
                  bar=0;
                  while (desc[foo]!=0x2c)
                   eos_record[8][bar++]=desc[foo++];
                  eos_record[8][bar]='\0';
                  foo++;
                  bar=0;
                  while (desc[foo]!=0x2c)
                   eos_record[7][bar++]=desc[foo++];
                  eos_record[7][bar]='\0';
                  foo++;
                  bar=0;
                  while (desc[foo])
                   eos_record[11][bar++]=desc[foo++];
                    eos_record[11][bar]='\0';
                }
              strcat (eos_record[10],site);
              strcat (eos_record[12],"0");



              if (!flag)
                {
                  for (foo=1;foo<19;foo++)
                    {
                      printf ("%s:",eos_record[foo]);
                      fprintf (navdir,"%s:",eos_record[foo]);
                    }
                  fprintf (navdir,"\n");
                  printf ("\n");
                }
             }   /* big if   */
          }      /* for loop */
} /* while !done */
fclose (navdir);
} /* end program */
Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU