4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
41 static struct RequesterBase makelink_req
={
44 0,0,0,0,NULL
,NULL
,NULL
,NULL
,
46 0,0,NULL
,IDCMP_MOUSEBUTTONS
|IDCMP_GADGETUP
,NULL
};
49 makelink_type_gadget
[]={
50 {RO_Type
,OBJECT_GADGET
},
51 {RO_GadgetType
,GADGET_CYCLE
},
52 {RO_GadgetID
,MAKELINK_TYPE
},
62 makelink_name_gadget
[]={
63 {RO_Type
,OBJECT_GADGET
},
64 {RO_GadgetType
,GADGET_STRING
},
65 {RO_GadgetID
,MAKELINK_NAME
},
75 {RO_StringUndo
,(IPTR
)str_undobuffer
},
78 makelink_destname_gadget
[]={
79 {RO_Type
,OBJECT_GADGET
},
80 {RO_GadgetType
,GADGET_STRING
},
81 {RO_GadgetID
,MAKELINK_DESTNAME
},
92 {RO_StringUndo
,(IPTR
)str_undobuffer
},
95 makelink_glass_gadget
[]={
96 {RO_Type
,OBJECT_GADGET
},
97 {RO_GadgetType
,GADGET_TINYGLASS
},
98 {RO_GadgetID
,MAKELINK_DESTSELECT
},
107 {RO_HighRecess
,TRUE
},
110 makelink_okay_gadget
[]={
111 {RO_Type
,OBJECT_GADGET
},
112 {RO_GadgetType
,GADGET_BOOLEAN
},
113 {RO_GadgetID
,MAKELINK_OKAY
},
119 {RO_TextNum
,STR_OKAY
},
120 {RO_TextPos
,TEXTPOS_CENTER
},
121 {RO_HighRecess
,TRUE
},
124 makelink_cancel_gadget
[]={
125 {RO_Type
,OBJECT_GADGET
},
126 {RO_GadgetType
,GADGET_BOOLEAN
},
127 {RO_GadgetID
,MAKELINK_CANCEL
},
135 {RO_TextNum
,STR_CANCEL
},
136 {RO_TextPos
,TEXTPOS_CENTER
},
137 {RO_HighRecess
,TRUE
},
140 makelink_type_text
[]={
141 {RO_Type
,OBJECT_BORDER
},
142 {RO_BorderType
,BORDER_NONE
},
147 {RO_TextNum
,STR_MAKELINK_TYPE
},
148 {RO_TextPos
,TEXTPOS_CENTER
},
151 makelink_name_text
[]={
152 {RO_Type
,OBJECT_BORDER
},
153 {RO_BorderType
,BORDER_NONE
},
159 {RO_TextNum
,STR_MAKELINK_NAME
},
160 {RO_TextPos
,TEXTPOS_CENTER
},
163 makelink_dest_text
[]={
164 {RO_Type
,OBJECT_BORDER
},
165 {RO_BorderType
,BORDER_NONE
},
171 {RO_TextNum
,STR_MAKELINK_DESTINATION
},
172 {RO_TextPos
,TEXTPOS_CENTER
},
175 *makelink_gadgets
[]={
176 makelink_name_gadget
,
177 makelink_type_gadget
,
178 makelink_destname_gadget
,
179 makelink_glass_gadget
,
180 makelink_okay_gadget
,
181 makelink_cancel_gadget
,
184 int getmakelinkdata(char *namebuf
, char *destbuf
, int *type
)
187 UWORD gadgetid
,__unused code
;
188 struct Window
*swindow
;
189 struct Gadget
*name_gad
,*makelink_type_gad
, *makelink_destname_gad
;
190 char *makelink_type_array
[3] = {globstring
[STR_MAKELINK_TYPE_SOFT
], globstring
[STR_MAKELINK_TYPE_HARD
], NULL
};
191 char makelink_namebuf
[108], makelink_destbuf
[256];
195 strcpy(makelink_namebuf
,namebuf
);
196 strcpy(makelink_destbuf
,destbuf
);
197 makelink_type
= type
? 1: 0;
199 fix_requester(&makelink_req
,globstring
[STR_ENTER_MAKELINK_PARAMS
]);
201 set_reqobject(makelink_name_gadget
,RO_StringBuf
,(IPTR
)makelink_namebuf
);
202 set_reqobject(makelink_destname_gadget
,RO_StringBuf
,(IPTR
)makelink_destbuf
);
204 if (!(swindow
=OpenRequester(&makelink_req
)) ||
205 !(name_gad
=addreqgadgets(&makelink_req
,makelink_gadgets
,0,NULL
)) ||
206 !(AddRequesterObject(&makelink_req
,makelink_type_text
)) ||
207 !(AddRequesterObject(&makelink_req
,makelink_name_text
)) ||
208 !(AddRequesterObject(&makelink_req
,makelink_dest_text
))) {
209 CloseRequester(&makelink_req
);
212 RefreshRequesterObject(&makelink_req
,NULL
);
214 makelink_type_gad
=name_gad
->NextGadget
;
215 makelink_destname_gad
=makelink_type_gad
->NextGadget
;
216 DoCycleGadget(makelink_type_gad
,swindow
,makelink_type_array
,makelink_type
);
218 ActivateStrGad(name_gad
,swindow
);
221 Wait(1<<swindow
->UserPort
->mp_SigBit
);
222 while ((IMsg
=(struct IntuiMessage
*)GetMsg(swindow
->UserPort
))) {
228 gadgetid
=((struct Gadget
*) IMsg
->IAddress
)->GadgetID
;
231 ReplyMsg((struct Message
*) IMsg
);
234 case IDCMP_MOUSEBUTTONS
:
235 ActivateStrGad(name_gad
,swindow
);
241 case SELECT_SELECTBASE:
242 strcpy(buffer[select_base],sel_patternbuf);
243 if (++select_base>3) select_base=0;
244 DoCycleGadget(gadlist,swindow,select_base_array,select_base);
245 strcpy(sel_patternbuf,buffer[select_base]);
246 RefreshStrGad(gadlist->NextGadget,swindow);
247 ActivateStrGad(gadlist->NextGadget,swindow);
250 if (code==0) // RETURN
252 else if (code!=0xFFFF) // ESC
256 if (++makelink_type
>1) makelink_type
=0;
257 DoCycleGadget(makelink_type_gad
,swindow
,makelink_type_array
,makelink_type
);
258 ActivateStrGad(name_gad
,swindow
);
260 case MAKELINK_DESTSELECT
:
262 struct DOpusFileReq filereq
;
263 char dirbuf
[256],filebuf
[FILEBUF_SIZE
],*ptr
;
265 filereq
.dirbuf
=dirbuf
;
266 filereq
.filebuf
=filebuf
;
267 filereq
.window
=swindow
;
272 filereq
.title
=globstring
[STR_FILE_REQUEST
];
273 filereq
.filearraykey
=NULL
;
275 LStrCpy(dirbuf
,makelink_destbuf
);
276 if ((ptr
=BaseName(dirbuf
))>dirbuf
) {
277 LStrCpy(filebuf
,ptr
);
280 else if (CheckExist(dirbuf
,NULL
)<1) {
282 LStrCpy(filebuf
,makelink_destbuf
);
285 if (FileRequest(&filereq
)) {
286 LStrCpy(makelink_destbuf
,dirbuf
);
287 TackOn(makelink_destbuf
,filebuf
,256);
289 RefreshStrGad(makelink_destname_gad
,swindow
);
290 ActivateStrGad(makelink_destname_gad
,swindow
);
295 strcpy(namebuf
,str_pathbuffer
[data_active_window
]);
296 TackOn(namebuf
,makelink_namebuf
,256);
297 strcpy(destbuf
,makelink_destbuf
);
299 case MAKELINK_CANCEL
:
300 CloseRequester(&makelink_req
);
309 int makelink(int rexx
)
311 char name
[256], path
[256];
314 name
[0]=path
[0]=mode
=0;
318 strcpy(name
,rexx_args
[0]);
319 strcpy(path
,rexx_args
[1]);
320 if (atoi(rexx_args
[2])) mode
= 1;
322 else if (!(getmakelinkdata(name
,path
,&mode
))) return 0;
324 if (name
[0] && path
[0])
330 if ((lock
= Lock(path
,ACCESS_READ
)))
332 if (MakeLink(name
,(SIPTR
)lock
,FALSE
))
334 dostatustext(str_okaystring
);
343 if (MakeLink(name
,(SIPTR
)path
,TRUE
))
345 dostatustext(str_okaystring
);
352 doerror(ERROR_REQUIRED_ARG_MISSING
);