/*
 */

#include "sm/generic.h"
SM_RCSID("@(#)$Id: qsch.c,v 1.1 2006/12/11 01:12:42 ca Exp $")
#include "sm/error.h"
#include "sm/assert.h"
#include "sm/io.h"
#include "sm/qmgr.h"
#include "sm/qmgr-int.h"

/*
**  QSC_CTX_FIND -- Find QMGR - SMTPC context based on id
**
**	Parameters:
**		qmgr_ctx -- QMGR context
**		sc_id -- SMTPC id
**		pqsc_ctx -- QMGR - SMTPC context (output)
**
**	Returns:
**		usual sm_error code
*/

sm_ret_T
qsc_ctx_find(qmgr_ctx_P qmgr_ctx, uint sc_id, qsc_ctx_P *pqsc_ctx)
{
	uint i;
	qsc_ctx_P qsc_ctx;

	SM_IS_QMGR_CTX(qmgr_ctx);
	SM_REQUIRE(pqsc_ctx != NULL);
	for (i = 0; i < QM_N_SC_GLI(qmgr_ctx); i++) {
		qsc_ctx = qmgr_li_sc(qmgr_ctx, i);
		if (qsc_ctx != NULL && sc_id == qsc_ctx->qsc_id) {
			*pqsc_ctx = qsc_ctx;
			return SM_SUCCESS;
		}
	}
	return sm_error_perm(SM_EM_Q, SM_E_NOTFOUND);
}


syntax highlighted by Code2HTML, v. 0.9.1