本文整理汇总了C++中CLEAR_LINK函数的典型用法代码示例。如果您正苦于以下问题:C++ CLEAR_LINK函数的具体用法?C++ CLEAR_LINK怎么用?C++ CLEAR_LINK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CLEAR_LINK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
job *job_alloc(void)
{
job *pj;
pj = (job *)calloc(1, sizeof(job));
if (pj == NULL)
{
log_err(errno, "job_alloc", (char *)"no memory");
return(NULL);
}
pj->ji_qs.qs_version = PBS_QS_VERSION;
CLEAR_LINK(pj->ji_alljobs);
CLEAR_LINK(pj->ji_jobque);
CLEAR_HEAD(pj->ji_tasks);
pj->ji_taskid = TM_NULL_TASK + 1;
pj->ji_obit = TM_NULL_EVENT;
pj->ji_nodekill = TM_ERROR_NODE;
pj->ji_momhandle = -1; /* mark mom connection invalid */
/* set the working attributes to "unspecified" */
job_init_wattr(pj);
return(pj);
} /* END job_alloc() */
示例2: log_err
struct batch_request *alloc_br(
int type)
{
struct batch_request *req = NULL;
req = (struct batch_request *)malloc(sizeof(struct batch_request));
if (req == NULL)
{
log_err(errno, "alloc_br", msg_err_malloc);
return(NULL);
}
memset((void *)req, (int)0, sizeof(struct batch_request));
req->rq_type = type;
CLEAR_LINK(req->rq_link);
req->rq_conn = -1; /* indicate not connected */
req->rq_orgconn = -1; /* indicate not connected */
req->rq_time = time_now;
req->rq_reply.brp_choice = BATCH_REPLY_CHOICE_NULL;
req->rq_noreply = FALSE; /* indicate reply is needed */
append_link(&svr_requests, &req->rq_link, req);
return(req);
}
示例3: return
struct batch_request *alloc_br(int type)
{
struct batch_request *req = NULL;
if (alloc_br_success == false)
return(NULL);
req = (struct batch_request *)calloc(1, sizeof(struct batch_request));
if (req == NULL)
{
return(NULL);
}
req->rq_type = type;
req->rq_conn = -1; /* indicate not connected */
req->rq_orgconn = -1; /* indicate not connected */
req->rq_time = 9877665;
req->rq_reply.brp_choice = BATCH_REPLY_CHOICE_NULL;
req->rq_noreply = FALSE; /* indicate reply is needed */
CLEAR_LINK(req->rq_link);
return(req);
}
示例4: status_sched
/**
* @brief
* status_sched - Build the status reply for single scheduler
*
* @param[in] psched - ptr to sched receiving status query
* @param[in] preq - ptr to the decoded request
* @param[out] pstathd - head of list to append status to
*
* @return int
* @retval 0 : success
* @retval !0 : PBSE error code
*/
static int
status_sched(pbs_sched *psched, struct batch_request *preq, pbs_list_head *pstathd)
{
int rc = 0;
struct brp_status *pstat;
svrattrl *pal;
pstat = (struct brp_status *)malloc(sizeof(struct brp_status));
if (pstat == NULL)
return (PBSE_SYSTEM);
pstat->brp_objtype = MGR_OBJ_SCHED;
(void)strncpy(pstat->brp_objname, psched->sc_name, (PBS_MAXSVRJOBID > PBS_MAXDEST ?
PBS_MAXSVRJOBID : PBS_MAXDEST) -1);
pstat->brp_objname[(PBS_MAXSVRJOBID > PBS_MAXDEST ? PBS_MAXSVRJOBID : PBS_MAXDEST) - 1] = '\0';
CLEAR_LINK(pstat->brp_stlink);
CLEAR_HEAD(pstat->brp_attr);
append_link(pstathd, &pstat->brp_stlink, pstat);
bad = 0;
pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_status.rq_attr);
if (status_attrib(pal, sched_attr_def, psched->sch_attr, SCHED_ATR_LAST,
preq->rq_perm, &pstat->brp_attr, &bad))
reply_badattr(PBSE_NOATTR, bad, pal, preq);
return (rc);
}
示例5: strlen
svrattrl *fill_svrattr_info(
const char *aname, /* I */ /* attribute name */
const char *avalue, /* I */ /* attribute value */
const char *rname, /* i */ /* resource name */
char *log_buf, /* O */ /* error buffer */
size_t buf_len) /* I */ /* len of error buffer */
{
size_t vsize = 0;
svrattrl *pal = NULL;
if (avalue)
vsize = strlen(avalue) + 1;
if ((pal = attrlist_create(aname, rname, vsize)))
{
if (avalue)
strcpy(pal->al_value, avalue);
CLEAR_LINK(pal->al_link);
}
else
snprintf(log_buf, buf_len, "Error: could not allocate memory for svrattrl in %s", __func__);
return pal;
}
示例6: status_job
int status_job(
job *pjob, /* ptr to job to status */
struct batch_request *preq,
svrattrl *pal, /* specific attributes to status */
tlist_head *pstathd, /* RETURN: head of list to append status to */
int *bad) /* RETURN: index of first bad pbs_attribute */
{
struct brp_status *pstat;
int IsOwner = 0;
long query_others = 0;
/* see if the client is authorized to status this job */
if (svr_authorize_jobreq(preq, pjob) == 0)
IsOwner = 1;
get_svr_attr_l(SRV_ATR_query_others, &query_others);
if (!query_others)
{
if (IsOwner == 0)
{
return(PBSE_PERM);
}
}
/* allocate reply structure and fill in header portion */
if ((pstat = calloc(1, sizeof(struct brp_status))) == NULL)
{
return(PBSE_SYSTEM);
}
CLEAR_LINK(pstat->brp_stlink);
pstat->brp_objtype = MGR_OBJ_JOB;
strcpy(pstat->brp_objname, pjob->ji_qs.ji_jobid);
CLEAR_HEAD(pstat->brp_attr);
append_link(pstathd, &pstat->brp_stlink, pstat);
/* add attributes to the status reply */
*bad = 0;
if (status_attrib(
pal,
job_attr_def,
pjob->ji_wattr,
JOB_ATR_LAST,
preq->rq_perm,
&pstat->brp_attr,
bad,
IsOwner))
{
return(PBSE_NOATTR);
}
return (0);
} /* END status_job() */
示例7: que_alloc
pbs_queue *
que_alloc(char *name)
{
int i;
pbs_queue *pq;
pq = (pbs_queue *)malloc(sizeof(pbs_queue));
if (pq == (pbs_queue *)0) {
log_err(errno, "que_alloc", "no memory");
return ((pbs_queue *)0);
}
(void)memset((char *)pq, (int)0, (size_t)sizeof(pbs_queue));
pq->qu_qs.qu_type = QTYPE_Unset;
CLEAR_HEAD(pq->qu_jobs);
CLEAR_LINK(pq->qu_link);
strncpy(pq->qu_qs.qu_name, name, PBS_MAXQUEUENAME);
append_link(&svr_queues, &pq->qu_link, pq);
server.sv_qs.sv_numque++;
/* set the working attributes to "unspecified" */
for (i=0; i<(int)QA_ATR_LAST; i++) {
clear_attr(&pq->qu_attr[i], &que_attr_def[i]);
}
return (pq);
}
示例8: sched_alloc
/**
* @brief
* sched_alloc - allocate space for a pbs_sched structure and
* initialize attributes to "unset" and pbs_sched object is added
* to svr_allscheds list
*
* @param[in] sched_name - scheduler name
*
* @return pbs_sched *
* @retval null - space not available.
*/
pbs_sched *
sched_alloc(char *sched_name)
{
int i;
pbs_sched *psched;
psched = calloc(1, sizeof(pbs_sched));
if (psched == NULL) {
log_err(errno, __func__, "Unable to allocate memory (malloc error)");
return NULL;
}
CLEAR_LINK(psched->sc_link);
strncpy(psched->sc_name, sched_name, PBS_MAXSCHEDNAME);
psched->sc_name[PBS_MAXSCHEDNAME] = '\0';
psched->svr_do_schedule = SCH_SCHEDULE_NULL;
psched->svr_do_sched_high = SCH_SCHEDULE_NULL;
psched->scheduler_sock = -1;
psched->scheduler_sock2 = -1;
append_link(&svr_allscheds, &psched->sc_link, psched);
/* set the working attributes to "unspecified" */
for (i = 0; i < (int) SCHED_ATR_LAST; i++) {
clear_attr(&psched->sch_attr[i], &sched_attr_def[i]);
}
return (psched);
}
示例9: add_dest
void add_dest(
job *jobp)
{
badplace *bp;
char *baddest = jobp->ji_qs.ji_destin;
bp = (badplace *)calloc(1, sizeof(badplace));
if (bp == NULL)
{
log_err(errno, __func__, msg_err_malloc);
return;
}
CLEAR_LINK(bp->bp_link);
strcpy(bp->bp_dest, baddest);
append_link(&jobp->ji_rejectdest, &bp->bp_link, bp);
return;
} /* END add_dest() */
示例10: encode_unkn
int
encode_unkn(attribute *attr, pbs_list_head *phead, char *atname, char *rsname, int mode, svrattrl **rtnl)
{
svrattrl *plist;
svrattrl *pnew;
svrattrl *xprior = NULL;
int first = 1;
if (!attr)
return (-2);
plist = (svrattrl *)GET_NEXT(attr->at_val.at_list);
if (plist == NULL)
return (0);
while (plist != NULL) {
pnew = (svrattrl *)malloc(plist->al_tsize);
if (pnew == NULL)
return (-1);
CLEAR_LINK(pnew->al_link);
pnew->al_sister = NULL;
pnew->al_tsize = plist->al_tsize;
pnew->al_nameln = plist->al_nameln;
pnew->al_rescln = plist->al_rescln;
pnew->al_valln = plist->al_valln;
pnew->al_flags = plist->al_flags;
pnew->al_refct = 1;
pnew->al_name = (char *)pnew + sizeof(svrattrl);
(void)memcpy(pnew->al_name, plist->al_name, plist->al_nameln);
if (plist->al_rescln) {
pnew->al_resc = pnew->al_name + pnew->al_nameln;
(void)memcpy(pnew->al_resc, plist->al_resc,
plist->al_rescln);
} else {
pnew->al_resc = NULL;
}
if (plist->al_valln) {
pnew->al_value = pnew->al_name + pnew->al_nameln +
pnew->al_rescln;
(void)memcpy(pnew->al_value, plist->al_value,
pnew->al_valln);
}
if (phead)
append_link(phead, &pnew->al_link, pnew);
if (first) {
if (rtnl)
*rtnl = pnew;
first = 0;
} else {
if (xprior)
xprior->al_sister = pnew;
}
xprior = pnew;
plist = (svrattrl *)GET_NEXT(plist->al_link);
}
return (1);
}
示例11: sizeof
job *job_alloc(void)
{
job *pj;
pj = (job *)calloc(1, sizeof(job));
if (pj == NULL)
{
log_err(errno, "job_alloc", "no memory");
return(NULL);
}
pj->ji_qs.qs_version = PBS_QS_VERSION;
CLEAR_LINK(pj->ji_alljobs);
CLEAR_LINK(pj->ji_jobque);
CLEAR_HEAD(pj->ji_tasks);
pj->ji_taskid = TM_NULL_TASK + 1;
pj->ji_numnodes = 0;
pj->ji_numvnod = 0;
pj->ji_hosts = NULL;
pj->ji_vnods = NULL;
pj->ji_resources = NULL;
pj->ji_obit = TM_NULL_EVENT;
pj->ji_preq = NULL;
pj->ji_nodekill = TM_ERROR_NODE;
pj->ji_flags = 0;
pj->ji_globid = NULL;
pj->ji_stdout = 0;
pj->ji_stderr = 0;
pj->ji_qs.ji_un.ji_momt.ji_exitstat = 0;
pj->ji_job_is_being_rerun = 0;
pj->ji_momhandle = -1; /* mark mom connection invalid */
/* set the working attributes to "unspecified" */
job_init_wattr(pj);
return(pj);
} /* END job_alloc() */
示例12: void
/**
*
* @brief
* Creates a task of type 'type', 'event_id', and when task is dispatched,
* execute func with argument 'parm'. The task is added to
* 'task_list_immed' if 'type' is WORK_Immed; otherwise, task is added
* 'task_list_event'.
*
* @param[in] type - of task
* @param[in] event_id - event id of the task
* @param[in] func - function that will be executed in behalf of the task
* @param[in] parm - parameter to 'func'
*
* @return struct work_task *
* @retval <a work task entry> - for success
* @retval NULL - for any error
*
*/
struct work_task *set_task(enum work_type type, long event_id, void (*func)(struct work_task *) , void *parm)
{
struct work_task *pnew;
struct work_task *pold;
pnew = (struct work_task *)malloc(sizeof(struct work_task));
if (pnew == (struct work_task *)0)
return ((struct work_task *)0);
CLEAR_LINK(pnew->wt_linkall);
CLEAR_LINK(pnew->wt_linkobj);
CLEAR_LINK(pnew->wt_linkobj2);
pnew->wt_event = event_id;
pnew->wt_event2 = NULL;
pnew->wt_type = type;
pnew->wt_func = func;
pnew->wt_parm1 = parm;
pnew->wt_parm2 = NULL;
pnew->wt_parm3 = NULL;
pnew->wt_aux = 0;
pnew->wt_aux2 = 0;
if (type == WORK_Immed)
append_link(&task_list_immed, &pnew->wt_linkall, pnew);
else if (type == WORK_Timed) {
pold = (struct work_task *)GET_NEXT(task_list_timed);
while (pold) {
if (pold->wt_event > pnew->wt_event)
break;
pold = (struct work_task *)GET_NEXT(pold->wt_linkall);
}
if (pold)
insert_link(&pold->wt_linkall, &pnew->wt_linkall, pnew,
LINK_INSET_BEFORE);
else
append_link(&task_list_timed, &pnew->wt_linkall, pnew);
} else
append_link(&task_list_event, &pnew->wt_linkall, pnew);
return (pnew);
}
示例13: copy_attribute_list
int copy_attribute_list(
batch_request *preq,
batch_request *preq_tmp)
{
svrattrl *pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_manager.rq_attr);
tlist_head *phead = &preq_tmp->rq_ind.rq_manager.rq_attr;
svrattrl *newpal = NULL;
while (pal != NULL)
{
newpal = (svrattrl *)calloc(1, pal->al_tsize + 1);
if (!newpal)
{
free_br(preq_tmp);
return(PBSE_SYSTEM);
}
CLEAR_LINK(newpal->al_link);
newpal->al_atopl.next = 0;
newpal->al_tsize = pal->al_tsize + 1;
newpal->al_nameln = pal->al_nameln;
newpal->al_flags = pal->al_flags;
newpal->al_atopl.name = (char *)newpal + sizeof(svrattrl);
strcpy((char *)newpal->al_atopl.name, pal->al_atopl.name);
newpal->al_nameln = pal->al_nameln;
newpal->al_atopl.resource = newpal->al_atopl.name + newpal->al_nameln;
if (pal->al_atopl.resource != NULL)
strcpy((char *)newpal->al_atopl.resource, pal->al_atopl.resource);
newpal->al_rescln = pal->al_rescln;
newpal->al_atopl.value = newpal->al_atopl.name + newpal->al_nameln + newpal->al_rescln;
strcpy((char *)newpal->al_atopl.value, pal->al_atopl.value);
newpal->al_valln = pal->al_valln;
newpal->al_atopl.op = pal->al_atopl.op;
pal = (struct svrattrl *)GET_NEXT(pal->al_link);
}
if ((phead != NULL) &&
(newpal != NULL))
append_link(phead, &newpal->al_link, newpal);
return(PBSE_NONE);
} /* END copy_attribute_list() */
示例14: req_stat_svr
void
req_stat_svr(struct batch_request *preq)
{
svrattrl *pal;
struct batch_reply *preply;
struct brp_status *pstat;
/* update count and state counts from sv_numjobs and sv_jobstates */
server.sv_attr[(int)SRV_ATR_TotalJobs].at_val.at_long = server.sv_qs.sv_numjobs;
server.sv_attr[(int)SRV_ATR_TotalJobs].at_flags |= ATR_VFLAG_SET|ATR_VFLAG_MODCACHE;
update_state_ct(&server.sv_attr[(int)SRV_ATR_JobsByState],
server.sv_jobstates,
server.sv_jobstbuf);
update_license_ct(&server.sv_attr[(int)SRV_ATR_license_count],
server.sv_license_ct_buf);
/* allocate a reply structure and a status sub-structure */
preply = &preq->rq_reply;
preply->brp_choice = BATCH_REPLY_CHOICE_Status;
CLEAR_HEAD(preply->brp_un.brp_status);
pstat = (struct brp_status *)malloc(sizeof(struct brp_status));
if (pstat == NULL) {
reply_free(preply);
req_reject(PBSE_SYSTEM, 0, preq);
return;
}
CLEAR_LINK(pstat->brp_stlink);
(void)strcpy(pstat->brp_objname, server_name);
pstat->brp_objtype = MGR_OBJ_SERVER;
CLEAR_HEAD(pstat->brp_attr);
append_link(&preply->brp_un.brp_status, &pstat->brp_stlink, pstat);
/* add attributes to the status reply */
bad = 0;
pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_status.rq_attr);
if (status_attrib(pal, svr_attr_def, server.sv_attr, SRV_ATR_LAST,
preq->rq_perm, &pstat->brp_attr, &bad))
reply_badattr(PBSE_NOATTR, bad, pal, preq);
else
(void)reply_send(preq);
}
示例15: status_que
static int
status_que(pbs_queue *pque, struct batch_request *preq, pbs_list_head *pstathd)
{
struct brp_status *pstat;
svrattrl *pal;
if ((preq->rq_perm & ATR_DFLAG_RDACC) == 0)
return (PBSE_PERM);
/* ok going to do status, update count and state counts from qu_qs */
if (!svr_chk_history_conf()) {
pque->qu_attr[(int)QA_ATR_TotalJobs].at_val.at_long = pque->qu_numjobs;
} else {
pque->qu_attr[(int)QA_ATR_TotalJobs].at_val.at_long = pque->qu_numjobs -
(pque->qu_njstate[JOB_STATE_MOVED] + pque->qu_njstate[JOB_STATE_FINISHED]);
}
pque->qu_attr[(int)QA_ATR_TotalJobs].at_flags |= ATR_VFLAG_SET|ATR_VFLAG_MODCACHE;
update_state_ct(&pque->qu_attr[(int)QA_ATR_JobsByState],
pque->qu_njstate,
pque->qu_jobstbuf);
/* allocate status sub-structure and fill in header portion */
pstat = (struct brp_status *)malloc(sizeof(struct brp_status));
if (pstat == NULL)
return (PBSE_SYSTEM);
pstat->brp_objtype = MGR_OBJ_QUEUE;
(void)strcpy(pstat->brp_objname, pque->qu_qs.qu_name);
CLEAR_LINK(pstat->brp_stlink);
CLEAR_HEAD(pstat->brp_attr);
append_link(pstathd, &pstat->brp_stlink, pstat);
/* add attributes to the status reply */
bad = 0;
pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_status.rq_attr);
if (status_attrib(pal, que_attr_def, pque->qu_attr, QA_ATR_LAST,
preq->rq_perm, &pstat->brp_attr, &bad))
return (PBSE_NOATTR);
return (0);
}