From ea4a3f0c5835f2731a1049dce68c43238d2ec20a Mon Sep 17 00:00:00 2001 From: Jakub Jermar Date: Mon, 3 Apr 2017 22:59:19 +0200 Subject: [PATCH] Add missing copyright notices, cstyle --- uspace/lib/c/generic/vfs/inbox.c | 85 ++++++++++++++++++++++++++++++---------- uspace/lib/c/include/vfs/inbox.h | 40 +++++++++++++++++++ 2 files changed, 104 insertions(+), 21 deletions(-) diff --git a/uspace/lib/c/generic/vfs/inbox.c b/uspace/lib/c/generic/vfs/inbox.c index e759ebb7f..55429c91b 100644 --- a/uspace/lib/c/generic/vfs/inbox.c +++ b/uspace/lib/c/generic/vfs/inbox.c @@ -1,3 +1,39 @@ +/* + * Copyright (c) 2013 Jiri Zarevucky + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * - The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** @addtogroup libc + * @{ + */ + +/** + * @file + * @brief + */ #include #include @@ -9,12 +45,15 @@ #include "../private/io.h" #include -/* This is an attempt at generalization of the "standard files" concept to arbitrary names. - * When loading a task, the parent can put arbitrary files to an "inbox" through IPC calls, - * every file in an inbox has a name assigned (e.g. "stdin", "stdout", "stderr", "data", "logfile", - * etc.). The client then retrieves those files from inbox by name. "stdin", "stdout" and "stderr" - * are handled automatically by libc to initialize standard streams and legacy file - * descriptors 0, 1, 2. Other names are subject to conventions and application-specific rules. +/* + * This is an attempt at generalization of the "standard files" concept to + * arbitrary names. When loading a task, the parent can put arbitrary files to + * an "inbox" through IPC calls, every file in an inbox has a name assigned + * (e.g. "stdin", "stdout", "stderr", "data", "logfile", etc.). The client then + * retrieves those files from inbox by name. "stdin", "stdout" and "stderr" are + * handled automatically by libc to initialize standard streams and + * legacy file descriptors 0, 1, 2. Other names are subject to conventions and + * application-specific rules. */ typedef struct { @@ -26,10 +65,11 @@ typedef struct { static LIST_INITIALIZE(inb_list); /* Inserts a named file into the inbox. - * If a file with the same name is already present, it overwrites it and returns the original - * value. Otherwise, it returns -1. - * If the argument 'file' is -1, nothing is inserted and the file with specified name is - * removed and returned if present. + * + * If a file with the same name is already present, it overwrites it and returns + * the original value. Otherwise, it returns -1. If the argument 'file' is -1, + * nothing is inserted and the file with specified name is removed and returned + * if present. * * @param name Name of the inbox entry. * @param file File to insert or -1. @@ -61,9 +101,8 @@ int inbox_set(const char *name, int file) } out: - if (file == -1) { + if (file == -1) return -1; - } inbox_entry *entry = calloc(sizeof(inbox_entry), 1); entry->name = str_dup(name); @@ -97,24 +136,24 @@ int inbox_get(const char *name) return ENOENT; } -/* Writes names of entries that are currently set into and array provided by the user. +/* Writes names of entries that are currently set into an array provided by the + * user. * * @param names Array in which names are stored. * @param capacity Capacity of the array. - * @return Number of entries written. If capacity == 0, return the total number of entries. + * @return Number of entries written. If capacity == 0, return the total number + * of entries. */ int inbox_list(const char **names, int capacity) { - if (capacity == 0) { + if (capacity == 0) return list_count(&inb_list); - } int used = 0; list_foreach(inb_list, link, inbox_entry, e) { - if (used == capacity) { + if (used == capacity) return used; - } names[used] = e->name; used++; } @@ -122,11 +161,15 @@ int inbox_list(const char **names, int capacity) return used; } -void __inbox_init(struct pcb_inbox_entry *entries, int count) { +void __inbox_init(struct pcb_inbox_entry *entries, int count) +{ for (int i = 0; i < count; i++) { int original = inbox_set(entries[i].name, entries[i].file); - if (original >= 0) { + if (original >= 0) vfs_put(original); - } } } + +/** + * @} + */ diff --git a/uspace/lib/c/include/vfs/inbox.h b/uspace/lib/c/include/vfs/inbox.h index 01a8d2447..d2f39e541 100644 --- a/uspace/lib/c/include/vfs/inbox.h +++ b/uspace/lib/c/include/vfs/inbox.h @@ -1,3 +1,39 @@ +/* + * Copyright (c) 2013 Jiri Zarevucky + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * - The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** @addtogroup libc + * @{ + */ + +/** + * @file + * @brief + */ #ifndef LIBC_VFS_INBOX_H_ #define LIBC_VFS_INBOX_H_ @@ -12,3 +48,7 @@ extern int inbox_get(const char *name); extern int inbox_list(const char **names, int capacity); #endif + +/** + * @} + */ -- 2.11.4.GIT