IFS_UNLINK production readiness
cesco via RPG400-L <[email protected]> Tue, 21 Jul 2026 15:15:42 +0000 (UTC)
| Newsgroups | gmane.comp.lang.as400.rpg |
|---|---|
| Message-ID | <[email protected]> |
I've fashioned a quick PHP running on the ibmi to let the user interact with only its own profile home directory fast, to ease some transfer and for quick automation and avoid opening more complex protocols, all done via SQL interface (in order to run all operation with the correct user authority).
I quickly noticed that , while other "IFS" sql functions are in Q* libs, IFS_UNLINK is meant as example per doc and it is in fact in SYSTOOLS;
the problem that its implementation can bite you when operating with files in IFS that usually can contain unicode in the names... and compared to other functions is asymmetric because it forces ccsid job default (while the other IBM production functions are properly specified as ccsid 1200 in the parameter)
Also IFS_RENAME seems limited... am I missing something, shouldn't IBM provide those primitives with full compatibility and symmetry?
In any case, using the same way of C embedding of the stock function, I've introduced a custom function like below, in case someone hit the problem (hoping that IBM will promote those to full production in future), below as reference
ciao, FrancescoT.
CREATE OR REPLACE FUNCTION THELIB.IFS_UNLINK_UTF8 (
PATH_UTF8 VARCHAR(5000) CCSID 1208 )
RETURNS INTEGER
LANGUAGE SQL
SPECIFIC IFSUNLKUTF
NOT DETERMINISTIC
MODIFIES SQL DATA
RETURNS NULL ON NULL INPUT
NOT FENCED
SET OPTION BINDOPT = 'BNDSRVPGM(QSYS/QP0LLIB1)' ,
COMMIT = *NONE ,
DFTRDBCOL = QSYS2 ,
DYNUSRPRF = *USER ,
SRTSEQ = *HEX
MAIN : BEGIN
--CALL QSYS2.QCMDEXC('CRTSRCPF FILE(QTEMP/QCSRC) RCDLEN(160) MBR(*NONE)');
--CALL QSYS2.QCMDEXC('ADDPFM FILE(QTEMP/QCSRC) MBR(IFSUNLK8) SRCTYPE(C)');
--INSERT INTO QTEMP.QCSRC (SRCSEQ, SRCDTA) VALUES
-- ( 1, '{'),
-- ( 2, '#include <qlg.h>'),
-- ( 3, '#include <Qp0lstdi.h>'),
-- ( 4, '#include <errno.h>'),
-- ( 5, '#include <string.h>'),
-- ( 6, 'struct pns_s {'),
-- ( 7, ' Qlg_Path_Name_T hdr;'),
-- ( 8, ' char name[5000];'),
-- ( 9, '};'),
-- (10, 'struct pns_s pns;'),
-- (11, 'unsigned int len;'),
-- (12, 'len = IFS_UNLINK_UTF8.PATH_UTF8.LEN;'),
-- (13, 'if (len > sizeof(pns.name)) len = sizeof(pns.name);'),
-- (14, 'memset(&pns, 0, sizeof(pns));'),
-- (15, 'pns.hdr.CCSID = 1208;'),
-- (16, 'pns.hdr.Path_Type = 0;'),
-- (17, 'pns.hdr.Path_Length = len;'),
-- (18, 'pns.hdr.Path_Name_Delimiter[0] = 0x2F;'),
-- (19, 'memcpy(pns.name, IFS_UNLINK_UTF8.PATH_UTF8.DAT, len);'),
-- (20, 'MAIN.RC = QlgUnlink((Qlg_Path_Name_T *)&pns);'),
-- (21, 'if (MAIN.RC != 0) { MAIN.RC = errno; }'),
-- (22, '}');
DECLARE RC INT DEFAULT 0 ;
INCLUDE QTEMP / QCSRC ( IFSUNLK8 ) ;
RETURN RC ;
END ;
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org for any subscription related questions.