Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset ea4a3f0 in mainline


Ignore:
Timestamp:
2017-04-03T20:59:19Z (5 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
a6fc88a
Parents:
2c40637
Message:

Add missing copyright notices, cstyle

Location:
uspace/lib/c
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/vfs/inbox.c

    r2c40637 rea4a3f0  
     1/*
     2 * Copyright (c) 2013 Jiri Zarevucky
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28
     29/** @addtogroup libc
     30 * @{
     31 */
     32
     33/**
     34 * @file
     35 * @brief
     36 */
    137
    238#include <vfs/inbox.h>
     
    1046#include <errno.h>
    1147
    12 /* This is an attempt at generalization of the "standard files" concept to arbitrary names.
    13  * When loading a task, the parent can put arbitrary files to an "inbox" through IPC calls,
    14  * every file in an inbox has a name assigned (e.g. "stdin", "stdout", "stderr", "data", "logfile",
    15  * etc.). The client then retrieves those files from inbox by name. "stdin", "stdout" and "stderr"
    16  * are handled automatically by libc to initialize standard <stdio.h> streams and legacy file
    17  * descriptors 0, 1, 2. Other names are subject to conventions and application-specific rules.
     48/*
     49 * This is an attempt at generalization of the "standard files" concept to
     50 * arbitrary names.  When loading a task, the parent can put arbitrary files to
     51 * an "inbox" through IPC calls, every file in an inbox has a name assigned
     52 * (e.g. "stdin", "stdout", "stderr", "data", "logfile", etc.). The client then
     53 * retrieves those files from inbox by name. "stdin", "stdout" and "stderr" are
     54 * handled automatically by libc to initialize standard <stdio.h> streams and
     55 * legacy file descriptors 0, 1, 2. Other names are subject to conventions and
     56 * application-specific rules.
    1857 */
    1958
     
    2766
    2867/* Inserts a named file into the inbox.
    29  * If a file with the same name is already present, it overwrites it and returns the original
    30  * value. Otherwise, it returns -1.
    31  * If the argument 'file' is -1, nothing is inserted and the file with specified name is
    32  * removed and returned if present.
     68 *
     69 * If a file with the same name is already present, it overwrites it and returns
     70 * the original value. Otherwise, it returns -1.  If the argument 'file' is -1,
     71 * nothing is inserted and the file with specified name is removed and returned
     72 * if present.
    3373 *
    3474 * @param name Name of the inbox entry.
     
    62102
    63103out:
    64         if (file == -1) {
     104        if (file == -1)
    65105                return -1;
    66         }
    67106
    68107        inbox_entry *entry = calloc(sizeof(inbox_entry), 1);
     
    98137}
    99138
    100 /* Writes names of entries that are currently set into and array provided by the user.
     139/* Writes names of entries that are currently set into an array provided by the
     140 * user.
    101141 *
    102142 * @param names Array in which names are stored.
    103143 * @param capacity Capacity of the array.
    104  * @return Number of entries written. If capacity == 0, return the total number of entries.
     144 * @return Number of entries written. If capacity == 0, return the total number
     145 *         of entries.
    105146 */
    106147int inbox_list(const char **names, int capacity)
    107148{
    108         if (capacity == 0) {
     149        if (capacity == 0)
    109150                return list_count(&inb_list);
    110         }
    111151
    112152        int used = 0;
    113153
    114154        list_foreach(inb_list, link, inbox_entry, e) {
    115                 if (used == capacity) {
     155                if (used == capacity)
    116156                        return used;
    117                 }
    118157                names[used] = e->name;
    119158                used++;
     
    123162}
    124163
    125 void __inbox_init(struct pcb_inbox_entry *entries, int count) {
     164void __inbox_init(struct pcb_inbox_entry *entries, int count)
     165{
    126166        for (int i = 0; i < count; i++) {
    127167                int original = inbox_set(entries[i].name, entries[i].file);
    128                 if (original >= 0) {
     168                if (original >= 0)
    129169                        vfs_put(original);
    130                 }
    131170        }
    132171}
     172
     173/**
     174 * @}
     175 */
  • uspace/lib/c/include/vfs/inbox.h

    r2c40637 rea4a3f0  
     1/*
     2 * Copyright (c) 2013 Jiri Zarevucky
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28
     29/** @addtogroup libc
     30 * @{
     31 */
     32
     33/**
     34 * @file
     35 * @brief
     36 */
    137
    238#ifndef LIBC_VFS_INBOX_H_
     
    1349
    1450#endif
     51
     52/**
     53 * @}
     54 */
Note: See TracChangeset for help on using the changeset viewer.