int encode_DIS_JobObit( int sock, /* I */ struct batch_request *preq) /* I */ { int rc; struct svrattrl *psvrl; psvrl = (struct svrattrl *)GET_NEXT(preq->rq_ind.rq_jobobit.rq_attr); if ((rc = diswst(sock, preq->rq_ind.rq_jobobit.rq_jid) != 0) || (rc = diswsi(sock, preq->rq_ind.rq_jobobit.rq_status) != 0) || (rc = encode_DIS_svrattrl(sock, psvrl) != 0)) { /* FAILURE */ return(rc); } return(0); } /* END encode_DIS_JobObit() */
int encode_DIS_reply( struct tcp_chan *chan, struct batch_reply *reply) { int ct; int i; struct brp_select *psel; struct brp_status *pstat; svrattrl *psvrl; int rc; /* first encode "header" consisting of protocol type and version */ if ((rc = diswui(chan, PBS_BATCH_PROT_TYPE)) || (rc = diswui(chan, PBS_BATCH_PROT_VER))) return rc; /* next encode code, auxcode and choice (union type identifier) */ if ((rc = diswsi(chan, reply->brp_code)) || (rc = diswsi(chan, reply->brp_auxcode)) || (rc = diswui(chan, reply->brp_choice))) return rc; switch (reply->brp_choice) { case BATCH_REPLY_CHOICE_NULL: break; /* no more to do */ case BATCH_REPLY_CHOICE_Queue: case BATCH_REPLY_CHOICE_RdytoCom: case BATCH_REPLY_CHOICE_Commit: if ((rc = diswst(chan, reply->brp_un.brp_jid))) return (rc); break; case BATCH_REPLY_CHOICE_Select: /* have to send count of number of strings first */ ct = 0; psel = reply->brp_un.brp_select; while (psel) { ++ct; psel = psel->brp_next; } if ((rc = diswui(chan, ct))) return rc; psel = reply->brp_un.brp_select; while (psel) { /* now encode each string */ if ((rc = diswst(chan, psel->brp_jobid))) return rc; psel = psel->brp_next; } break; case BATCH_REPLY_CHOICE_Status: /* encode "server version" of status structure. * * Server always uses svrattrl form. * Commands decode into their form. * * First need to encode number of status objects and then * the object itself. */ ct = 0; pstat = (struct brp_status *)GET_NEXT(reply->brp_un.brp_status); while (pstat) { ++ct; pstat = (struct brp_status *)GET_NEXT(pstat->brp_stlink); } if ((rc = diswui(chan, ct))) return rc; pstat = (struct brp_status *)GET_NEXT(reply->brp_un.brp_status); while (pstat) { if ((rc = diswui(chan, pstat->brp_objtype)) || (rc = diswst(chan, pstat->brp_objname))) return rc; psvrl = (svrattrl *)GET_NEXT(pstat->brp_attr); if ((rc = encode_DIS_svrattrl(chan, psvrl))) return rc; pstat = (struct brp_status *)GET_NEXT(pstat->brp_stlink); } break; case BATCH_REPLY_CHOICE_Text: /* text reply */ if ((rc = diswcs(chan, reply->brp_un.brp_txt.brp_str, reply->brp_un.brp_txt.brp_txtlen))) return rc; break; case BATCH_REPLY_CHOICE_Locate: /* Locate Job Reply */ if ((rc = diswst(chan, reply->brp_un.brp_locate))) return rc; break; case BATCH_REPLY_CHOICE_RescQuery: /* Query Resources Reply */ ct = reply->brp_un.brp_rescq.brq_number; if ((rc = diswui(chan, ct))) return rc; for (i = 0; (i < ct) && (rc == 0); ++i) { rc = diswui(chan, *(reply->brp_un.brp_rescq.brq_avail + i)); } if (rc) return rc; for (i = 0; (i < ct) && (rc == 0); ++i) { rc = diswui(chan, *(reply->brp_un.brp_rescq.brq_alloc + i)); } if (rc) return rc; for (i = 0; (i < ct) && (rc == 0); ++i) { rc = diswui(chan, *(reply->brp_un.brp_rescq.brq_resvd + i)); } if (rc) return rc; for (i = 0; (i < ct) && (rc == 0); ++i) { rc = diswui(chan, *(reply->brp_un.brp_rescq.brq_down + i)); } if (rc) return rc; break; default: return -1; } return 0; }