OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [libgui/] [src/] [tclwinpath.c] - Blame information for rev 578

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/* tclwinpath.c -- Tcl routines to convert paths under cygwin32.
2
   Copyright (C) 1997 Cygnus Solutions.
3
   Written by Ian Lance Taylor <ian@cygnus.com>.
4
 
5
   This file contains Tcl interface routines to do path translation
6
   when using cygwin32.  */
7
 
8
#ifdef __CYGWIN32__
9
 
10
#include <windows.h>
11
 
12
#include <tcl.h>
13
 
14
#include "guitcl.h"
15
#include "subcommand.h"
16
 
17
/* The path conversion routines are not declared anywhere that I know
18
   of.  */
19
 
20
extern void cygwin32_conv_to_win32_path (const char *, char *);
21
extern void cygwin32_conv_to_full_win32_path (const char *, char *);
22
extern void cygwin32_conv_to_posix_path (const char *, char *);
23
extern void cygwin32_conv_to_full_posix_path (const char *, char *);
24
extern int cygwin32_posix_path_list_p (const char *);
25
extern int cygwin32_win32_to_posix_path_list_buf_size (const char *);
26
extern int cygwin32_posix_to_win32_path_list_buf_size (const char *);
27
extern void cygwin32_win32_to_posix_path_list (char *, char *);
28
extern void cygwin32_posix_to_win32_path_list (char *, char *);
29
extern void cygwin32_split_path (const char *, char *, char *);
30
 
31
/* This file declares a Tcl command with subcommands.
32
 
33
   Each of the following subcommands returns a string based on the
34
   PATH argument.  If PATH is already in the desired form, these
35
   commands just return it unchanged.
36
 
37
   ide_cygwin_path to_win32 PATH
38
       Return PATH converted to a win32 pathname.
39
 
40
   ide_cygwin_path to_full_win32 PATH
41
       Return PATH converted to an absolute win32 pathname.
42
 
43
   ide_cygwin_path to_posix PATH
44
       Return PATH converted to a POSIX pathname.
45
 
46
   ide_cygwin_path to_full_posix PATH
47
       Return PATH converted to an absolute POSIX pathname.
48
 
49
   The following subcommand returns a boolean value.
50
 
51
   ide_cygwin_path posix_path_list_p PATHLIST
52
       Return whether PATHLIST is a POSIX style path list.
53
 
54
   The following subcommands return strings.
55
 
56
   ide_cygwin_path posix_to_win32_path_list PATHLIST
57
       Return PATHLIST converted from POSIX style to win32 style.
58
 
59
   ide_cygwin_path win32_to_posix_path_list PATHLIST
60
       Return PATHLIST converted from win32 style to POSIX style.
61
 
62
   */
63
 
64
/* Handle ide_cygwin_path to_win32.  */
65
 
66
static int
67
path_to_win32 (ClientData cd, Tcl_Interp *interp, int argc, char **argv)
68
{
69
  char buf[MAX_PATH];
70
 
71
  cygwin32_conv_to_win32_path (argv[2], buf);
72
  Tcl_SetResult (interp, buf, TCL_VOLATILE);
73
  return TCL_OK;
74
}
75
 
76
/* Handle ide_cygwin_path to_full_win32.  */
77
 
78
static int
79
path_to_full_win32 (ClientData cd, Tcl_Interp *interp, int argc, char **argv)
80
{
81
  char buf[MAX_PATH];
82
 
83
  cygwin32_conv_to_full_win32_path (argv[2], buf);
84
  Tcl_SetResult (interp, buf, TCL_VOLATILE);
85
  return TCL_OK;
86
}
87
 
88
/* Handle ide_cygwin_path to_posix.  */
89
 
90
static int
91
path_to_posix (ClientData cd, Tcl_Interp *interp, int argc, char **argv)
92
{
93
  char buf[MAX_PATH];
94
 
95
  cygwin32_conv_to_posix_path (argv[2], buf);
96
  Tcl_SetResult (interp, buf, TCL_VOLATILE);
97
  return TCL_OK;
98
}
99
 
100
/* Handle ide_cygwin_path to_full_posix.  */
101
 
102
static int
103
path_to_full_posix (ClientData cd, Tcl_Interp *interp, int argc, char **argv)
104
{
105
  char buf[MAX_PATH];
106
 
107
  cygwin32_conv_to_full_posix_path (argv[2], buf);
108
  Tcl_SetResult (interp, buf, TCL_VOLATILE);
109
  return TCL_OK;
110
}
111
 
112
/* Handle ide_cygwin_path posix_path_list_p.  */
113
 
114
static int
115
path_posix_path_list_p (ClientData cd, Tcl_Interp *interp, int argc,
116
                        char **argv)
117
{
118
  int ret;
119
 
120
  ret = cygwin32_posix_path_list_p (argv[2]);
121
  Tcl_ResetResult (interp);
122
  Tcl_SetBooleanObj (Tcl_GetObjResult (interp), ret);
123
  return TCL_OK;
124
}
125
 
126
/* Handle ide_cygwin_path posix_to_win32_path_list.  */
127
 
128
static int
129
path_posix_to_win32_path_list (ClientData cd, Tcl_Interp *interp, int argc,
130
                               char **argv)
131
{
132
  int size;
133
  char *buf;
134
 
135
  size = cygwin32_posix_to_win32_path_list_buf_size (argv[2]);
136
  buf = Tcl_Alloc (size);
137
  cygwin32_posix_to_win32_path_list (argv[2], buf);
138
  Tcl_SetResult (interp, buf, TCL_DYNAMIC);
139
  return TCL_OK;
140
}
141
 
142
/* Handle ide_cygwin_path win32_to_posix_path_list.  */
143
 
144
static int
145
path_win32_to_posix_path_list (ClientData cd, Tcl_Interp *interp, int argc,
146
                               char **argv)
147
{
148
  int size;
149
  char *buf;
150
 
151
  size = cygwin32_win32_to_posix_path_list_buf_size (argv[2]);
152
  buf = Tcl_Alloc (size);
153
  cygwin32_win32_to_posix_path_list (argv[2], buf);
154
  Tcl_SetResult (interp, buf, TCL_DYNAMIC);
155
  return TCL_OK;
156
}
157
 
158
/* The subcommand table.  */
159
 
160
static const struct ide_subcommand_table path_commands[] =
161
{
162
  { "to_win32",         path_to_win32,          3, 3 },
163
  { "to_full_win32",    path_to_full_win32,     3, 3 },
164
  { "to_posix",         path_to_posix,          3, 3 },
165
  { "to_full_posix",    path_to_full_posix,     3, 3 },
166
  { "posix_path_list_p", path_posix_path_list_p, 3, 3 },
167
  { "posix_to_win32_path_list", path_posix_to_win32_path_list, 3, 3 },
168
  { "win32_to_posix_path_list", path_win32_to_posix_path_list, 3, 3 },
169
  { NULL, NULL, 0, 0}
170
};
171
 
172
/* Create the ide_cygwin_path command.  */
173
 
174
int
175
ide_create_cygwin_path_command (Tcl_Interp *interp)
176
{
177
  return ide_create_command_with_subcommands (interp, "ide_cygwin_path",
178
                                              path_commands, NULL, NULL);
179
}
180
 
181
#endif /* __CYGWIN32__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.