#include <fcntl.h> #include <stdio.h> #include <Qp0lstdi.h> int QlgOpen(Qlg_Path_Name_T *Path_Name, int oflag, . . .);Service Program Name: QP0LLIB1
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.
See Code disclaimer information for information pertaining to code examples.
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.
#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"); } }
Top | UNIX-Type APIs | APIs by category |