annotate toys/posix/mkfifo.c @ 694:786841fdb1e0

Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style. The actual code should be the same afterward, this is just cosmetic refactoring.
author Rob Landley <rob@landley.net>
date Tue, 13 Nov 2012 17:14:08 -0600
parents 7e846e281e38
children 4ca4134dad17
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
1 /* mkfifo.c - Create FIFOs (named pipes)
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
2 *
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
3 * Copyright 2012 Georgi Chorbadzhiyski <georgi@unixsol.org>
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
4 *
656
6df4ccc0acbe Regularize command headers, update links to standards documents.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
5 * See http://opengroup.org/onlinepubs/9699919799/utilities/mkfifo.html
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
6 *
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
7 * TODO: Add -m
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
8
551
2548e6e590b2 Add string to mode_t parser
Daniel Walter <d.walter@0x90.at>
parents: 531
diff changeset
9 USE_MKFIFO(NEWTOY(mkfifo, "<1m:", TOYFLAG_BIN))
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
10
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
11 config MKFIFO
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
12 bool "mkfifo"
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
13 default y
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
14 help
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
15 usage: mkfifo [fifo_name...]
531
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
16
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
17 Create FIFOs (named pipes).
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
18 */
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
19
674
7e846e281e38 New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
20 #define FOR_mkfifo
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
21 #include "toys.h"
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
22
674
7e846e281e38 New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
23 GLOBALS(
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
24 char *m_string;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
25 mode_t mode;
531
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
26 )
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
27
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
28 void mkfifo_main(void)
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
29 {
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
30 char **s;
531
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
31
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
32 TT.mode = 0666;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
33 if (toys.optflags & FLAG_m) {
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
34 TT.mode = string_to_mode(TT.m_string, 0);
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
35 }
531
6fedb88874a4 Cleanups: use perror_msg() and make mode a global.
Rob Landley <rob@landley.net>
parents: 530
diff changeset
36
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
37 for (s = toys.optargs; *s; s++) {
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
38 if (mknod(*s, S_IFIFO | TT.mode, 0) < 0) {
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
39 perror_msg("cannot create fifo '%s'", *s);
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
40 toys.exitval = 1;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
41 }
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
42 }
530
6afff0596646 Add mkfifo.
Georgi Chorbadzhiyski <gf@unixsol.org>
parents:
diff changeset
43 }