source: rtems/cpukit/posix/src/psxnametoid.c @ b98d399f

4.115
Last change on this file since b98d399f was b98d399f, checked in by Sebastian Huber <sebastian.huber@…>, on 12/13/11 at 12:56:53

2011-12-13 Sebastian Huber <sebastian.huber@…>

  • posix/src/mqueuenametoid.c, posix/src/semaphorenametoid.c: Removed files.
  • posix/src/psxnametoid.c: New file.
  • posix/Makefile.am: Reflect changes above.
  • posix/include/rtems/posix/config.h: Fixed integer types.
  • posix/include/rtems/posix/posixapi.h: Declare _POSIX_Name_to_id().
  • posix/include/rtems/posix/mqueue.h, posix/inline/rtems/posix/mqueue.inl: Changed parameter of _POSIX_Message_queue_Create_support(). _POSIX_Message_queue_Name_to_id() is now inline.
  • posix/include/rtems/posix/semaphore.h, posix/inline/rtems/posix/semaphore.inl: Changed parameter of _POSIX_Semaphore_Create_support(). _POSIX_Semaphore_Name_to_id() is now inline.
  • posix/src/mqueuecreatesupp.c, posix/src/semaphorecreatesupp.c: Use _Workspace_String_duplicate().
  • posix/src/mqueuesendsupp.c, posix/src/mqueueopen.c, posix/src/mqueueunlink.c, posix/src/seminit.c, posix/src/semopen.c, posix/src/semunlink.c: Update due to API changes.
  • Property mode set to 100644
File size: 1.1 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13  #include "config.h"
14#endif
15
16#include <rtems/posix/posixapi.h>
17
18#include <string.h>
19#include <limits.h>
20#include <errno.h>
21
22/* pure ANSI mode does not have this prototype */
23size_t strnlen(const char *, size_t);
24
25int _POSIX_Name_to_id(
26  Objects_Information *information,
27  const char          *name,
28  Objects_Id          *id,
29  size_t              *len
30)
31{
32  int eno = EINVAL;
33  size_t n = 0;
34
35  if ( name != NULL && name [0] != '\0' ) {
36    n = strnlen( name, NAME_MAX );
37
38    if ( n < NAME_MAX ) {
39      Objects_Name_or_id_lookup_errors status = _Objects_Name_to_id_string(
40        information,
41        name,
42        id
43      );
44
45      if ( status == OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL ) {
46        eno = 0;
47      } else {
48        eno = ENOENT;
49      }
50    } else {
51      eno = ENAMETOOLONG;
52    }
53  }
54
55  *len = n;
56
57  return eno;
58}
Note: See TracBrowser for help on using the repository browser.