# HG changeset patch # User Binki # Date 2009-07-15 13:28:47 # Node ID 82e46a3537bb2e67c927646a2dc153303f0280ff # Parent 9a584f11d1623950bf0677ff090042bfd04ce5e0 added blendjob_get(), moved func prototypes diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -37,17 +37,14 @@ #include -/* - internally defined funcs's prototypes -*/ -void status_report_generator(); -void blendjob_remove(struct blendjob **head, struct blendjob *bj); // Global Vars, try to cut down on these -int jobnum = 0; // The next job number to create in the queue +jobnum_t jobnum = 0; // The next job number to create in the queue int hcfjob; // Highest consecutively finished job int highest_jobnum; // The job number of the most recently created job, this is used when creating new jobs +typedef unsigned int jobnum_t; + /* ******************* Structs ************************ */ // Stores config info? editmycomment @@ -86,7 +83,7 @@ struct blendjob { char *name; char *submitter; char *email; - unsigned int jobnum; + jobnum_t jobnum; int priority; // 1 is lowest, 10 is highest, 0 means the job is done int percent_done; int completed_frames; // number of completed frames for stats/etc @@ -110,7 +107,13 @@ struct frameset { // Using this method to save memory, because if animation starts on a high frame number, it would waste a lot of RAM on empty structures +/* + internally defined funcs's prototypes +*/ +void status_report_generator(); +void blendjob_remove(struct blendjob **head, struct blendjob *bj); +struct blendjob *blendjob_get(struct blendjob *head, jobnum_t jobnum); /* ********************** Functions ************************* */ @@ -339,6 +342,27 @@ void blend_frame_watchdog(struct blendjo } /** + Finds a blendjob struct based on the jobnum + @arg jobnum job number to search for + @return NULL on job doesn't exist + */ +struct blendjob *blendjob_get(struct blendjob *head, jobnum_t jobnum) +{ + struct blendjob *blendjob_ptr; + + /* + The conditions of the for loop will leave blendjob_ptr at NULL if the end of the list is reached. It will leave it pointing to the correct job if it is found. + */ + for(blendjob_ptr = head; + blendjob_ptr + && blendjob_ptr->jobnum != jobnum; + blendjob_ptr = blendjob_ptr->next); + + return blendjob_ptr; +} + + +/** Removes a blendjob from the blendjob linkelist. @arg head a double pointer. the head pointer will have to be changed if blendjob == *head. Thus, make sure that the pointer points to the pointer to the head that all functions use. (I'm going to come back to this and misunderstand myself ;-))