60 lines
1.1 KiB
C
60 lines
1.1 KiB
C
#ifndef JOB_H
|
|
#define JOB_H
|
|
#include <stddef.h>
|
|
#include <stdlib.h>
|
|
|
|
/* A job */
|
|
struct Job {
|
|
int jobId;
|
|
int pid;
|
|
int writeFd[2];
|
|
int readFd[2];
|
|
char *command;
|
|
char *status;
|
|
};
|
|
|
|
/* List of jobs including the length */
|
|
struct Jobs {
|
|
struct Job **jobs;
|
|
int length;
|
|
};
|
|
|
|
// TODO: remove this as global
|
|
struct Jobs programJobs;
|
|
|
|
/* get_job_from_pid()
|
|
* ------------------
|
|
* Gets a job given by the pid of the job
|
|
*
|
|
* pid: the process id of the job
|
|
*
|
|
* Returns: the job if the pid exists, otherwise NULL
|
|
*/
|
|
struct Job *get_job_from_pid(int pid);
|
|
|
|
/* get_job_from_id()
|
|
* ------------------
|
|
* Gets a job given by the job id
|
|
*
|
|
* id: the id of the job
|
|
*
|
|
* Returns: the job if the job id exists, otherwise NULL
|
|
*/
|
|
struct Job *get_job_from_id(int id);
|
|
|
|
/* add_job()
|
|
* Adds the given job to the list of current jobs
|
|
*
|
|
* job: the pointer to the job to add
|
|
*
|
|
* Returns: the job id of the given job
|
|
*/
|
|
int add_job(struct Job *job);
|
|
|
|
/* deinit_jobs()
|
|
* -------------
|
|
* Deinitialises all jobs and frees memory
|
|
*/
|
|
void deinit_jobs(void);
|
|
#endif
|