QlgAccessx()--Determine File Accessibility for a Class of Users (using NLS-enabled path name)


  Syntax
 #include <unistd.h>

 int QlgAccessx(const Qlg_Path_Name_T *path, int amode, int who);  
  Service Program Name: QP0LLIB1

  Default Public Authority: *USE

  Threadsafe: Conditional; see Usage Notes for accessx().

The QlgAccessx() function, like the accessx() function, determines whether a file can be accessed in a particular manner by a specified class of users. The difference is that the QlgAccessx() function takes a pointer to a Qlg_Path_Name_T structure, while accessx() takes a pointer to a character string.

Limited information on the path parameter is provided here. For more information on the path parameter and for a discussion of other parameters, authorities required, return values, and related information, see accessx()--Determine File Accessibility for a Class of Users.


Parameters

path
(Input) A pointer to a Qlg_Path_Name_T structure that contains a path name or a pointer to a path name for the file to be checked for accessibility. For more information on the Qlg_Path_Name_T structure, see Path name format.

Related Information


Example

The following example determines how a file is accessed.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#include <stdio.h>
#include <unistd.h>

main()
{

  /****************************************************************/
  /*   Defininitons                                               */
  /****************************************************************/
#define mypath "/myfile"
  const char US_const[3]= "US";
  const char Language_const[4] ="ENU";
  typedef struct pnstruct
  {
    Qlg_Path_Name_T qlg_struct;
    char pn[100]; /* This array size must be >= the  */
                  /* length of the path name or this must */
                  /* be a pointer to the path name.  */
  };
  struct pnstruct path;

  /****************************************************************/
  /*   Initialize Qlg_Path_Name_T parameters                      */
  /****************************************************************/
  memset((void*)&path, 0x00, sizeof(struct pnstruct));
  path.qlg_struct.CCSID = 37;
  memcpy(path.qlg_struct.Country_ID,US_const,2);
  memcpy(path.qlg_struct.Language_ID,Language_const,3);
  path.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
  path.qlg_struct.Path_Length = sizeof(mypath)-1;
  path.qlg_struct.Path_Name_Delimiter[0] = '/';
  memcpy(path.pn,mypath,sizeof(mypath)-1);

  if (QlgAccessx((Qlg_Path_Name_T *)&path, R_OK, ACC_OTHERS) == 0)
      printf("Someone besides the owner has read access to '%s'\n", mypath);
  if (QlgAccessx((Qlg_Path_Name_T *)&path, W_OK, ACC_OTHERS) == 0)
      printf("Someone besides the owner has write access to '%s'\n", mypath);
  if (QlgAccessx((Qlg_Path_Name_T *)&path, X_OK, ACC_OTHERS) == 0)
      printf("Someone besides the owner has search access to '%s'\n", mypath);
}

Output:

In this example QlgAccessx() was called on '/myfile'. The following would be the output if someone other than the owner has *R authority, someone besides the owner has *W authority, and noone other than the owner has *X authority.

Someone besides the owner has read access to '/'
Someone besides the owner has write access to '/'

API introduced: V5R2

[ Back to top | UNIX-Type APIs | APIs by category ]