BPX1GPE (getpwent) example

The following code accesses the user database starting with the next available entry and continuing until end of fileon the database. It returns a structure identifying information about each user entry in the database. For the callable service, see getpwent (BPX1GPE, BPX4GPE) — Sequentially access the user database. For the data structure, see BPXYGIDN — Map data returned for getpwnam and getpwuid. AMODE 64 callers use BPX4GPE (getpwent) example.
                                              
GPELOOP  DS    0H                                                       
         CALL  BPX1GPE,              Access the user database          +
               (RETVAL,              Return value: 0 or ->BPXYGIDN     +
               RETCODE,              Return code                       +
               RSNCODE),             Reason code                       +
               VL,MF=(E,PLIST)       ---------------------------------- 
         ICM   R8,B'1111',RETVAL                                        
         BZ    CHKGPERR              Error or end of file               
         USING GIDN,R8                                                  
*        access the user structure                                      
         DROP  R8                                                       
         B     GPELOOP               Check next user entry              
CHKGPERR DS    0H                                                       
         ICM   R8,B'1111',RETCODE                                       
         BZ    GPEEOF                End of file                        
*        handle error as needed                                         
GPEEOF   DS    0H