PAM Programming Manual
Link-Level Programming Examples
PAM Programming Manual—142482
B-17
Finding a Free Buffer
Finding a Free Buffer
The application must provide a function that allows it to find a free buffer to contain the 
aggregate SDU.
#pragma page “FUNCTION: Find Free Buffer”
/* ----------------------------------------------------------------
 FUNCTION: Find Free Buffer
---------------------------------------------------------------- */
int Find_Free_Buffer ( buffer_lst_ndx )
 long *buffer_lst_ndx;
{
 *buffer_lst_ndx = 0;
 while ( *buffer_lst_ndx < ( NoWait_Depth ) )
 {
 if (!(buffer_lst [ *buffer_lst_ndx ].in_use_flag))
 return True;
 *buffer_lst_ndx = ( *buffer_lst_ndx + 1 );
 };
 return (False);
}
Building an Aggregate SDU
The application must provide a function for building the aggregate SDU.
#pragma page “FUNCTION: Build Aggr SDU”
/* ----------------------------------------------------------------
 FUNCTION: Build Aggr SDU
---------------------------------------------------------------- */
int Build_Aggr_SDU ( Aggr_SDU_buf )
 char *Aggr_SDU_buf;
{
 int SDU_ndx;
 int frmt_error;
 int data_offset_b;
 int count;
 frmt_error = ZL2S_FRMT_AGGR_SDU_HDR_ 
 ( (char *)Aggr_SDU_buf, Max_Req_Size );
 if ( frmt_error != zl2s_err_frmt_ok )
 {
 fprintf(stdout,”Aggr SDU Hdr Error:%d\n”, frmt_error);
 exit(Abend_exit);
 }
/* -------------- In case there are 0 SDUs to build ------------ */
 data_offset_b = sizeof (struct zl2s_ddl_aggr_sdu_hdr_def);
 for (SDU_ndx = 1; SDU_ndx <= SDU_Cnt; SDU_ndx++)
 {
 frmt_error = ZL2S_FRMT_SDU_HDR_ ( (char *)Aggr_SDU_buf,
 Port_Type,
 Command_Code,
 P_F_Flag,










