QlgOpen()--Open a File (using NLS-enabled path name)


  Syntax
 #include <fcntl.h>
 #include <stdio.h>
 #include <Qp0lstdi.h>

 int QlgOpen(Qlg_Path_Name_T *Path_Name,
 int oflag, . . .);  
  Service Program Name: QP0LLIB1

  Default Public Authority: *USE

  Threadsafe: Conditional; see Usage Notes for open() API.

The QlgOpen() function, like the open() function, opens a file or creates a new, empty file whose name is defined by path and returns a number called a file descriptor. The difference is that the QlgOpen() function takes a pointer to a Qlg_Path_Name_T structure, while open() 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, usage notes, return values, and related information, see open()--Open a File.

Note: The QlgOpen() function is implemented using either the Qp0lOpen() function or the QlgOpen64() function. When using ILE languages such as RPG, COBOL, and CL, developers need to specify Qp0lOpen or QlgOpen64 as the external name of the API, whichever is appropriate.


Parameters

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

Related Information


Example

The following example creates and opens an output file for exclusive access. This program was stored in a source file with CCSID 37, so the constant string "newfile" will be compiled in CCSID 37. Therefore, the language and country or region specified are United States English, and the CCSID specified is 37.

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

#include <fcntl.h>
#include <stdio.h>
#include <Qp0lstdi.h>

main()
{
  int fildes;

  const char US_const[3]= "US";
  const char Language_const[4]="ENU";

  struct pnstruct
    {
     Qlg_Path_Name_T  qlg_struct;
     char             pn[7];
    };
  struct pnstruct pns;
  struct pnstruct *pns_ptr = NULL;

  char fn[]="newfile";

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

  pns_ptr = &pns;
  if(fildes = QlgOpen((Qlg_Path_Name_T *)pns_ptr,
           O_WRONLY|O_CREAT|O_EXCL, S_IRWXU)) == -1)
  {
        perror("QlgOpen() error");
  }

}

API introduced: V5R1

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