#include <Qp0lstdi.h> Qlg_Path_Name_T *QlgGetPathFromFileID(Qlg_Path_Name_T *buf, size_t size,Qp0lFID_t fileid);Service Program Name: QP0LLIB2
The QlgGetPathFromFileID() function, like the Qp0lGetPathFromFileID() function, determines an absolute path name of the file identified by fileid and stores it in buf. The difference is that the QlgGetPathFromFileID() function points to a Qlg_Path_Name_T structure, while Qp0lGetPathFromFileID() points to a null-terminated character string.
Limited information on the buf parameter is provided here. For more information on the buf parameter and for a discussion of other parameters, authorities required, return values, and related information, see Qp0lGetPathFromFileID()--Get Path Name of Object from Its File ID.
See Code disclaimer information for information pertaining to code examples.
The following example determines the path name of a file, given its file ID. In this example, the fileid is hardcoded. More realistically, the fileid is obtained from the audit journal entry and passed to QlgGetPathFromFileID().
#include <Qp0lstdi.h> #include <stdio.h> #include <qtqiconv.h> void Path_Print(Qlg_Path_Name_T *); main() { Qp0lFID_t fileid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xCF, 0x00}; const char US_const[3]= "US"; const char Language_const[4]="ENU"; typedef struct pnstruct { Qlg_Path_Name_T qlg_struct; char pn[1024]; /* This size must be large enough */ /* to contain the path name. */ }; struct pnstruct path; /*******************************************************/ /* Initialize Qlg_Path_Name_T parameters */ /*******************************************************/ memset((void*)&path, 0x00, sizeof(struct pnstruct)); memcpy(path.qlg_struct.Country_ID,US_const,2); memcpy(path.qlg_struct.Language_ID,Language_const,3); if (QlgGetPathFromFileID((Qlg_Path_Name_T *)&path, sizeof(struct pnstruct), fileid) == NULL) perror("QlgGetPathFromFileID() error"); else { printf("Path retrieved successfully.\n"); Path_Print((Qlg_Path_Name_T *)&path); } } void Path_Print(Qlg_Path_Name_T *path_to_print_pointer) { /**************************************************************/ /* Print a path name that is in the Qlg_Path_Name_T format. */ /**************************************************************/ #define PATH_TYPE_POINTER 0x00000001 /* If flag is on, */ /* input structure contains a pointer */ /* to the path name, else the path */ /* name is in contiguous storage */ /* within the qlg structure. */ typedef union pn_input_type /* Format of input path name. */ { char pn_char_type[256]; /* in contiguous storage */ char *pn_ptr_type; /* a pointer */ }; typedef struct pnstruct { Qlg_Path_Name_T qlg_struct; union pn_input_type pn; }; struct pnstruct *pns; char *path_ptr; size_t insz; size_t outsz = 1000; char outbuf[1000]; char *outbuf_ptr; iconv_t cd; size_t ret_iconv; /* Indicates to convert from ccsid 13488 to 37. */ QtqCode_T toCode = {37,0,0,0,0,0}; QtqCode_T fromCode = {13488,0,0,1,0,0}; if (path_to_print_pointer != NULL) { /***********************************************************/ /* Point to and get the size of the path name. */ /***********************************************************/ pns = (struct pnstruct *)path_to_print_pointer; if (path_to_print_pointer->Path_Type & PATH_TYPE_POINTER) path_ptr = pns->pn.pn_ptr_type; else path_ptr = (char *)(pns->pn.pn_char_type); insz = pns->qlg_struct.Path_Length; /* Get path length.*/ /***********************************************************/ /* Initialize the print buffer. */ /***********************************************************/ outbuf_ptr = (char *)outbuf; memset(outbuf_ptr, 0x00, insz); /***********************************************************/ /* Use iconv to convert the CCSID. */ /***********************************************************/ cd = QtqIconvOpen(&toCode, &fromCode); /* Open a descriptor*/ if (cd.return_value == -1) { perror("Open conversion descriptor error"); return; } if (0 != ((iconv(cd, (char **)&(path_ptr), &insz, (char **)&(outbuf_ptr), &outsz)))) { ret_iconv= iconv_close(cd);/* Close conversion descriptor*/ perror("Conversion error"); return; } /***********************************************************/ /* Print the name and close the conversion descriptior. */ /***********************************************************/ printf("The file's path is: %s\n",outbuf); ret_iconv = iconv_close(cd); } /* path_to_print_pointer != NULL */ } /* Path_Print */
Output:
Path retrieved successfully. The file's path is: /myfile
Top | UNIX-Type APIs | APIs by category |