2016-06-05 03:19:36 +02:00
|
|
|
#include "process.h"
|
|
|
|
|
|
|
|
struct process * srv_process_copy (const struct process *p)
|
|
|
|
{
|
|
|
|
if (p == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
struct process * copy = malloc (sizeof(struct process));
|
|
|
|
memcpy (copy, p, sizeof (struct process));
|
|
|
|
|
|
|
|
return copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
int srv_process_eq (const struct process *p1, const struct process *p2)
|
|
|
|
{
|
|
|
|
return (p1->pid == p2->pid && p1->version == p2->version
|
|
|
|
&& p1->index == p2->index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void srv_process_gen (struct process *p
|
|
|
|
, pid_t pid, unsigned int index, unsigned int version)
|
|
|
|
{
|
|
|
|
p->pid = pid;
|
|
|
|
p->version = version;
|
|
|
|
p->index = index;
|
|
|
|
|
2016-06-10 20:02:58 +02:00
|
|
|
memset (p->path_in, 0, PATH_MAX);
|
|
|
|
memset (p->path_out, 0, PATH_MAX);
|
2016-09-10 16:48:46 +02:00
|
|
|
|
2016-09-11 14:37:41 +02:00
|
|
|
snprintf(p->path_in , PATH_MAX, "%s%d-%d-%d-in" , TMPDIR, pid, index, version);
|
|
|
|
snprintf(p->path_out, PATH_MAX, "%s%d-%d-%d-out", TMPDIR, pid, index, version);
|
2016-10-27 16:26:16 +02:00
|
|
|
snprintf(p->path_proc, PATH_MAX, "%s%d-%d-%d", TMPDIR, pid, index, version);
|
2016-09-10 16:59:53 +02:00
|
|
|
|
2016-06-05 03:19:36 +02:00
|
|
|
}
|
|
|
|
|
2016-06-07 13:49:23 +02:00
|
|
|
void srv_process_print (struct process *p)
|
2016-06-05 03:19:36 +02:00
|
|
|
{
|
2016-06-07 17:44:18 +02:00
|
|
|
if (p != NULL)
|
2016-09-09 12:06:25 +02:00
|
|
|
printf ("process %d : index %d, version %d\n"
|
|
|
|
, p->pid, p->index, p->version);
|
2016-06-05 03:19:36 +02:00
|
|
|
}
|