source: rtems/cpukit/libfs/src/imfs/imfs_gtkn.c @ cf0539b1

4.104.114.84.95
Last change on this file since cf0539b1 was cf0539b1, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:54:17

2003-09-04 Joel Sherrill <joel@…>

  • src/dosfs/dosfs.h, src/dosfs/fat.h, src/dosfs/fat_fat_operations.h, src/dosfs/fat_file.h, src/dosfs/msdos.h, src/dosfs/msdos_create.c, src/dosfs/msdos_dir.c, src/dosfs/msdos_eval.c, src/dosfs/msdos_file.c, src/dosfs/msdos_free.c, src/dosfs/msdos_fsunmount.c, src/dosfs/msdos_handlers_dir.c, src/dosfs/msdos_handlers_file.c, src/dosfs/msdos_init.c, src/dosfs/msdos_initsupp.c, src/dosfs/msdos_misc.c, src/dosfs/msdos_mknod.c, src/dosfs/msdos_node_type.c, src/imfs/deviceio.c, src/imfs/imfs.h, src/imfs/imfs_chown.c, src/imfs/imfs_config.c, src/imfs/imfs_creat.c, src/imfs/imfs_debug.c, src/imfs/imfs_directory.c, src/imfs/imfs_eval.c, src/imfs/imfs_fchmod.c, src/imfs/imfs_fcntl.c, src/imfs/imfs_fdatasync.c, src/imfs/imfs_free.c, src/imfs/imfs_fsunmount.c, src/imfs/imfs_getchild.c, src/imfs/imfs_gtkn.c, src/imfs/imfs_handlers_device.c, src/imfs/imfs_handlers_directory.c, src/imfs/imfs_handlers_link.c, src/imfs/imfs_handlers_memfile.c, src/imfs/imfs_init.c, src/imfs/imfs_initsupp.c, src/imfs/imfs_link.c, src/imfs/imfs_mknod.c, src/imfs/imfs_mount.c, src/imfs/imfs_ntype.c, src/imfs/imfs_readlink.c, src/imfs/imfs_rmnod.c, src/imfs/imfs_stat.c, src/imfs/imfs_symlink.c, src/imfs/imfs_unixstub.c, src/imfs/imfs_unlink.c, src/imfs/imfs_unmount.c, src/imfs/imfs_utime.c, src/imfs/ioman.c, src/imfs/linearfile.c, src/imfs/memfile.c, src/imfs/miniimfs_init.c: URL for license changed.
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  IMFS_get_token
3 *
4 *  Routine to get a token (name or separator) from the path
5 *  the length of the token is returned in token_len.
6 *
7 *  COPYRIGHT (c) 1989-1999.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.com/license/LICENSE.
13 *
14 *  $Id$
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <stdlib.h>
22#include <string.h>
23
24#include "imfs.h"
25#include <rtems/libio_.h>
26
27IMFS_token_types IMFS_get_token(
28  const char       *path,
29  char             *token,
30  int              *token_len
31)
32{
33  register int i = 0;
34  IMFS_token_types  type = IMFS_NAME;
35  register char c;
36
37  /*
38   *  Copy a name into token.  (Remember NULL is a token.)
39   */
40  c = path[i];
41  while ( (!IMFS_is_separator(c)) && (i <= IMFS_NAME_MAX) ) {
42
43     token[i] = c;
44
45     if ( i == IMFS_NAME_MAX )
46       return IMFS_INVALID_TOKEN;
47
48     if ( !IMFS_is_valid_name_char(c) )
49       type = IMFS_INVALID_TOKEN;   
50
51     c = path [++i];
52  }
53
54  /*
55   *  Copy a seperator into token.
56   */
57
58  if ( i == 0 ) {
59    token[i] = c;
60
61    if ( token[i] != '\0' ) {
62      i++;
63      type = IMFS_CURRENT_DIR;
64    } else {
65      type = IMFS_NO_MORE_PATH;
66    }
67  } else if (token[ i-1 ] != '\0') {
68    token[i] = '\0';
69  }
70
71  /*
72   *  Set token_len to the number of characters copied.
73   */
74
75  *token_len = i;
76
77  /*
78   *  If we copied something that was not a seperator see if
79   *  it was a special name.
80   */
81
82  if ( type == IMFS_NAME ) {
83    if ( strcmp( token, "..") == 0 )
84      type = IMFS_UP_DIR;
85    else if ( strcmp( token, "." ) == 0 )
86      type = IMFS_CURRENT_DIR;
87  }
88
89  return type;
90}
Note: See TracBrowser for help on using the repository browser.