/* This is largely stolen from the source code for the hesinfo program. */

#include <stdio.h>
#include <string.h>
#include <hesiod.h>

void main(argc, argv)
char *argv[];
int argc;
{
  char **cpp;
  char *identifier;

  if (argc != 2) {
    fprintf(stderr,"Usage: %s identifier\n",argv[0]);
    exit(2);
  }
  identifier = argv[1];

  cpp = hes_resolve(identifier, "filsys");
  if (cpp) {
    char* hesi = *cpp;  /* we only look at the first locker entry */
    if (hesi && !strncmp(hesi,"AFS ",4)) {
      char *spc;

      hesi += 4;           /* skip "AFS " */
	    if (!strcmp(hesi,"/afs/athena.mit.edu"))
	      hesi += 19;        /* skip "/afs/athena.mit.edu" */

      spc = strchr(hesi, 32);
      if (spc) *spc='\0';

      printf("%s\n", hesi);
    }
  }
}

