/* This file is part of GNU Pies. Copyright (C) 2008-2013 Sergey Poznyakoff GNU Pies is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GNU Pies is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Pies. If not, see . */ enum prog_type { TYPE_COMPONENT, TYPE_REDIRECTOR, TYPE_COMMAND }; enum prog_status { status_enabled, /* Component enabled. prog->pid!=0 shows if it is actually running */ status_disabled, /* Component is disabled. */ status_listener, /* Component is an inetd listener */ status_sleeping, /* Component is sleeping. An attempt to start it will be made at prog->v.p.timestamp + SLEEPTIME */ status_stopping, /* Component is being stopped */ status_finished, /* A "once" component has finished */ }; struct conn_class { const char *tag; union pies_sockaddr_storage sa_storage; size_t sa_len; size_t count; }; struct prog { struct prog *next, *prev; enum prog_type type; pid_t pid; /* PID */ char *tag; /* Entry tag (for diagnostics purposes) */ char **prereq; int facility; union { struct { struct component *comp; size_t idx; /* Numeric identifier */ int socket; struct prog *redir[2]; /* Pointers to redirectors */ time_t timestamp; /* Time of last startup */ size_t failcount; /* Number of failed starts since timestamp */ enum prog_status status; /* Current component status */ char *runlevels; /* If status == status_listener: */ size_t num_instances; /* Number of running instances */ /* If comp->type == pies_comp_inetd && status == status_enabled */ struct prog *listener; union pies_sockaddr_storage sa_storage; size_t sa_len; struct conn_class *cclass; } p; struct { struct prog *master; } r; struct { char *command; } c; } v; }; void progman_foreach (int (*filter) (struct prog *, void *data), void *data);