예제 #1
0
파일: HTVMSUtils.c 프로젝트: kotohvost/yui
/* PUBLIC							HTVMS_getpwnam()
**		getpwnam routine
** ON ENTRY:
**	username	Username specification
**	
**
** ON EXIT:
**	NULL		error
**	
*/
PUBLIC struct passwd *HTVMS_getpwnam ARGS1(
	CONST char *, username)
{
long Result;
struct dsc$descriptor_s UserNameDesc;
ItemStruct ItemList[3];
unsigned long DeviceLength;
char Device[33];
unsigned long DirLength;
char Dir[64];
char VMSName[100];
static struct passwd pw;
static char pw_dir[100];

   /* make sure pointers are correct */
   pw.pw_dir = pw_dir;

   /* construct UserName */
   UserNameDesc.dsc$w_length = strlen(username);
   UserNameDesc.dsc$b_dtype = DSC$K_DTYPE_T;
   UserNameDesc.dsc$b_class = DSC$K_CLASS_S;
   UserNameDesc.dsc$a_pointer = username;

   /* Default Device */
   ItemList[0].BufferLength = 33;
   ItemList[0].BufferAddress = Device;
   ItemList[0].ReturnLengthAddress = &DeviceLength;
   ItemList[0].ItemCode = UAI$_DEFDEV;

   /* Default Directory */
   ItemList[1].BufferLength = 64;
   ItemList[1].BufferAddress = Dir;
   ItemList[1].ReturnLengthAddress = &DirLength;
   ItemList[1].ItemCode = UAI$_DEFDIR;

   /* terminate list */
   ItemList[2].ItemCode = 0;
   ItemList[2].BufferLength = 0;

   /* get info */
   Result = SYS$GETUAI(0,0,&UserNameDesc,ItemList,0,0,0);
   if (Result != SS$_NORMAL)
      return(NULL);

   /* create vms name */
   strncpy(VMSName,&(Device[1]),Device[0]);
   VMSName[Device[0]] = '\0';
   strncat(VMSName,&(Dir[1]),Dir[0]);
   VMSName[Device[0]+Dir[0]] = '\0';
   
   /* convert it into www name */
   strcpy(pw_dir,HTVMS_wwwName(VMSName));

   return(&pw);
}
예제 #2
0
PRIVATE struct dirent *HTVMSreaddir(DIR *dirp)
{
static struct dirent entry;
long status;
struct dsc$descriptor_s entryname_desc;
char *space, *slash;
char VMSentry[256];
char *UnixEntry;

   entryname_desc.dsc$w_length = 255;
   entryname_desc.dsc$b_dtype = DSC$K_DTYPE_T;
   entryname_desc.dsc$b_class = DSC$K_CLASS_S;
   entryname_desc.dsc$a_pointer = VMSentry;

   status = lib$find_file(&(dirp->dirname_desc),
			  &entryname_desc,
			  &(dirp->context),
			  0,0,0,0);
   if (status == RMS$_NMF)
   { /* no more files */
      return(NULL);
   }
   else
   { /* ok */
      if (!(status & 0x01)) return(0);
      if (HTVMSFileVersions)
	  space = strchr(VMSentry,' ');
      else
	  space = strchr(VMSentry,';');
      if (space)
	 *space = '\0';

      /* convert to unix style... */
      UnixEntry = HTVMS_wwwName(VMSentry);
      slash = strrchr(UnixEntry,'/') + 1;
      strcpy(entry.d_name,slash);
      entry.d_namlen = strlen(entry.d_name);
      entry.d_fileno = 1;
      return(&entry);
   }
}