annotate lib/spawn_faction_init.c @ 14079:97fc9a21a8fb

maint: update almost all copyright ranges to include 2011 Run the new "make update-copyright" rule.
author Jim Meyering <meyering@redhat.com>
date Sat, 01 Jan 2011 20:17:23 +0100
parents c2cbabec01dd
children 8250f2777afc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14079
97fc9a21a8fb maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents: 12559
diff changeset
1 /* Copyright (C) 2000, 2009-2011 Free Software Foundation, Inc.
10506
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 This file is part of the GNU C Library.
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 #include <config.h>
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 /* Specification. */
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 #include <spawn.h>
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include <errno.h>
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include <stdlib.h>
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #include <string.h>
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #include "spawn_int.h"
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 /* Function used to increase the size of the allocated array. This
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 function is called from the `add'-functions. */
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 int
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 __posix_spawn_file_actions_realloc (posix_spawn_file_actions_t *file_actions)
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 {
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 int newalloc = file_actions->_allocated + 8;
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 void *newmem = realloc (file_actions->_actions,
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10506
diff changeset
36 newalloc * sizeof (struct __spawn_action));
10506
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 if (newmem == NULL)
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 /* Not enough memory. */
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 return ENOMEM;
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 file_actions->_actions = (struct __spawn_action *) newmem;
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 file_actions->_allocated = newalloc;
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 return 0;
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 }
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 /* Initialize data structure for file attribute for `spawn' call. */
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 int
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 posix_spawn_file_actions_init (posix_spawn_file_actions_t *file_actions)
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 {
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 /* Simply clear all the elements. */
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 memset (file_actions, '\0', sizeof (*file_actions));
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 return 0;
989d25db0548 New module 'posix_spawn_file_actions_init'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 }