From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 15-APR-1993 02:47:59.33
To:	info-vax@sri.com
CC:	
Subj:	Re: problem using $IDTOASC

David-Michael Lincke writes:
>I tried to get all Usernames at our site by using the $IDTOASC() system service
>in the following program but there must be something wrong with it and i really
>can't figure out what. Any help would be appreciated.
>
>						David
>
>#include <stdio.h>
>#include <starlet.h>
>#include <ssdef.h>
>
>char nambuf[13];
>
>main()
>{
>	short namlen = 12;
>	long id, resid, attrib;
>	unsigned long ctx = 0;
>
>	id = -1;
>	
>	while(sys$idtoasc(id, &namlen, nambuf, &resid, &attrib, &ctx) != SS$_NOSUCHID)
>			printf("ID: %s\n", nambuf);
>}
>
>-- 
>                                     David-Michael Lincke
>      \_\_              \_\_      Hochschule St. Gallen HSG      
>        \_\_              \_\_  email:  92636828s@sgcl1.unisg.ch
>	  \_\_		    \_\_        bwllibmod@sgcl1.unisg.ch	
>            \_\_\_\_\_\_\_\_  \_\_      lincke@ezinfo.vmsmail.ethz.ch
>	                                dlincke@nyx.cs.du.edu
>	              netmeg!m-net!lincke@destroyer.rs.itd.umich.edu
>		      x.400: S=92636828s O=UNISG P=SWITCH A=ARCOM C=CH		
>

    there's nothing wrong with idtoasc, but there is something wrong
    with your call to it. idtoasc expects nambuf to be passed by
    descriptor. also, there is no point in initializing namlen
    as it will be overwritten on every call. the correct code is as
    follows:

#include <stdio.h>
#include <starlet.h>
#include <ssdef.h>
#include <descrip.h>

char nambuf[32];

main()
{
	long status;
	short namlen;
	long id = -1, resid, attrib;
	unsigned long ctx = 0;
	struct dsc$descriptor_s nambufdsc = { sizeof(nambuf), DSC$K_DTYPE_T,
						DSC$K_CLASS_S, nambuf };

	while( (status = sys$idtoasc(id, &namlen, &nambufdsc,
					&resid, &attrib, &ctx)) & 1)
	    {
	    nambuf[namlen] = '\0';
	    printf("ID: %s\n", nambuf);
	    }

	return status;
}

    by the way, these are identifiers, not usernames, they are not limited
    to 12 charactes in length. also there may or may not be a correspondence
    between the identifiers returned and users on the system.

    colin sewell
    h.a.simons ltd.
    vancouver, bc
    "simons/g=colin/s=sewell"@mhs.attmail.com

