From 1b3b98135eefe7cf03a379be1d5ebf13369dcfa5 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 24 Mar 2018 22:31:05 +0100 Subject: Add license headers and comments to source Signed-off-by: David Oberhollenzer --- lib/include/service.h | 47 ++++++++++++++++++++++++++++++++++++++++------- lib/include/telinit.h | 20 +++++++++++++++++++- lib/include/util.h | 22 ++++++++++++++++++++++ lib/src/del_srv_list.c | 17 +++++++++++++++++ lib/src/delsrv.c | 17 +++++++++++++++++ lib/src/enum_by_name.c | 17 +++++++++++++++++ lib/src/opensock.c | 17 +++++++++++++++++ lib/src/rdline.c | 17 +++++++++++++++++ lib/src/rdsrv.c | 17 +++++++++++++++++ lib/src/splitkv.c | 17 +++++++++++++++++ lib/src/srv_tsort.c | 17 +++++++++++++++++ lib/src/srvscan.c | 17 +++++++++++++++++ lib/src/strexpand.c | 17 +++++++++++++++++ 13 files changed, 251 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/include/service.h b/lib/include/service.h index eb92d85..6808bdd 100644 --- a/lib/include/service.h +++ b/lib/include/service.h @@ -1,19 +1,45 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * Copyright (C) 2018 - David Oberhollenzer + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ #ifndef SERVICE_H #define SERVICE_H #include enum { + /* + Start the service in the background and continue with + other services. The service will eventually terminate. + */ SVC_ONCE = 0, - SVC_WAIT, + SVC_WAIT, /* run service and wait until it finishes */ + + /* + Similar to SVC_ONCE, but restart the service when + it terminates. + */ SVC_RESPAWN, }; enum { - TGT_BOOT = 0, - TGT_SHUTDOWN, - TGT_REBOOT, - TGT_CAD, + TGT_BOOT = 0, /* run service when the system boots */ + TGT_SHUTDOWN, /* run service when at system shut down */ + TGT_REBOOT, /* run service when during system reboot */ + TGT_CAD, /* run service when CTRL+ALT+DEL is pressed */ TGT_MAX }; @@ -27,9 +53,9 @@ typedef struct service_t { size_t num_exec; /* number of command lines */ char *ctty; /* controlling tty or log file */ - char **before; + char **before; /* services that must be executed later */ size_t num_before; - char **after; + char **after; /* services that must be executed first */ size_t num_after; pid_t pid; @@ -49,6 +75,13 @@ service_t *rdsrv(int dirfd, const char *filename); void delsrv(service_t *srv); +/* + Rebuild a service list by scanning a directory and parsing all + service descriptions. + + Returns 0 on success, -1 on failure. The function takes care of + printing error messages on failure. +*/ int srvscan(const char *directory, service_list_t *list); void del_srv_list(service_list_t *list); diff --git a/lib/include/telinit.h b/lib/include/telinit.h index 72ad871..3a3dd8c 100644 --- a/lib/include/telinit.h +++ b/lib/include/telinit.h @@ -1,3 +1,20 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * Copyright (C) 2018 - David Oberhollenzer + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ #ifndef TELINIT_H #define TELINIT_H @@ -11,9 +28,10 @@ enum { }; typedef struct { - int type; + int type; /* TI_* message type identifier */ } ti_msg_t; +/* Try to connect to the init socket. */ int opensock(void); #endif /* TELINIT_H */ diff --git a/lib/include/util.h b/lib/include/util.h index bed2ba7..ed5dac2 100644 --- a/lib/include/util.h +++ b/lib/include/util.h @@ -1,3 +1,20 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * Copyright (C) 2018 - David Oberhollenzer + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ #ifndef UTIL_H #define UTIL_H @@ -52,6 +69,11 @@ int splitkv(char *line, char **key, char **value); */ const enum_map_t *enum_by_name(const enum_map_t *map, const char *name); +/* + Create a copy of the input string inp, but replace all occourances + of % with argv[number] if the number is within the bounds + specified by argc. +*/ char *strexpand(const char *inp, size_t argc, const char *const *argv); #endif /* UTIL_H */ diff --git a/lib/src/del_srv_list.c b/lib/src/del_srv_list.c index 916fcb2..d54c40b 100644 --- a/lib/src/del_srv_list.c +++ b/lib/src/del_srv_list.c @@ -1,3 +1,20 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * Copyright (C) 2018 - David Oberhollenzer + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ #include #include "service.h" diff --git a/lib/src/delsrv.c b/lib/src/delsrv.c index b660558..87b65bc 100644 --- a/lib/src/delsrv.c +++ b/lib/src/delsrv.c @@ -1,3 +1,20 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * Copyright (C) 2018 - David Oberhollenzer + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ #include #include "service.h" diff --git a/lib/src/enum_by_name.c b/lib/src/enum_by_name.c index 1948eb9..95f306f 100644 --- a/lib/src/enum_by_name.c +++ b/lib/src/enum_by_name.c @@ -1,3 +1,20 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * Copyright (C) 2018 - David Oberhollenzer + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ #include #include "util.h" diff --git a/lib/src/opensock.c b/lib/src/opensock.c index 06101ef..0c2bf56 100644 --- a/lib/src/opensock.c +++ b/lib/src/opensock.c @@ -1,3 +1,20 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * Copyright (C) 2018 - David Oberhollenzer + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ #include #include #include diff --git a/lib/src/rdline.c b/lib/src/rdline.c index 591c713..1b91008 100644 --- a/lib/src/rdline.c +++ b/lib/src/rdline.c @@ -1,3 +1,20 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * Copyright (C) 2018 - David Oberhollenzer + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ #include #include #include diff --git a/lib/src/rdsrv.c b/lib/src/rdsrv.c index 52eb19c..ec60ce1 100644 --- a/lib/src/rdsrv.c +++ b/lib/src/rdsrv.c @@ -1,3 +1,20 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * Copyright (C) 2018 - David Oberhollenzer + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ #include #include #include diff --git a/lib/src/splitkv.c b/lib/src/splitkv.c index 6c6fe94..b1ef8d3 100644 --- a/lib/src/splitkv.c +++ b/lib/src/splitkv.c @@ -1,3 +1,20 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * Copyright (C) 2018 - David Oberhollenzer + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ #include #include "util.h" diff --git a/lib/src/srv_tsort.c b/lib/src/srv_tsort.c index e2549b1..d375c4f 100644 --- a/lib/src/srv_tsort.c +++ b/lib/src/srv_tsort.c @@ -1,3 +1,20 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * Copyright (C) 2018 - David Oberhollenzer + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ #include #include #include diff --git a/lib/src/srvscan.c b/lib/src/srvscan.c index 71ad4f9..69d0b91 100644 --- a/lib/src/srvscan.c +++ b/lib/src/srvscan.c @@ -1,3 +1,20 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * Copyright (C) 2018 - David Oberhollenzer + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ #include #include #include diff --git a/lib/src/strexpand.c b/lib/src/strexpand.c index 7e552eb..58b69a0 100644 --- a/lib/src/strexpand.c +++ b/lib/src/strexpand.c @@ -1,3 +1,20 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * Copyright (C) 2018 - David Oberhollenzer + * + * This program 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 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ #include #include #include -- cgit v1.2.3