3 * Control program for the CDVDFS handler.
5 * ----------------------------------------------------------------------
6 * This code is (C) Copyright 1993,1994 by Frank Munkert.
7 * (C) Copyright 2007 by Pavel Fedin.
9 * This software may be freely distributed and redistributed for
10 * non-commercial purposes, provided this notice is included.
16 #include <proto/dos.h>
17 #include <proto/exec.h>
18 #include <proto/utility.h>
20 #include <dos/dosextens.h>
21 #include <exec/memory.h>
24 extern struct Library
*DOSBase
;
27 #include "cdcontrol.h"
30 struct UtilityBase
*UtilityBase
= NULL
;
32 struct Library
*UtilityBase
= NULL
;
35 struct MsgPort
*g_device_proc
;
46 CloseLibrary ((APTR
)UtilityBase
);
49 void Send_Packet (int p_cmd
, void *p_1
, void *p_2
)
51 struct MsgPort
*replyport
= CreateMsgPort();
52 struct StandardPacket
*packet
= AllocMem (sizeof (struct StandardPacket
),
53 MEMF_CLEAR
| MEMF_PUBLIC
);
56 if (!packet
|| !replyport
) {
57 fprintf (stderr
, "ERROR: cannot send packet\n");
59 FreeMem (packet
, sizeof (struct StandardPacket
));
61 DeleteMsgPort(replyport
);
65 packet
->sp_Msg
.mn_Node
.ln_Name
= (char *) &(packet
->sp_Pkt
);
66 packet
->sp_Pkt
.dp_Link
= &(packet
->sp_Msg
);
68 packet
->sp_Pkt
.dp_Port
= replyport
;
69 packet
->sp_Pkt
.dp_Type
= ACTION_USER
;
70 packet
->sp_Pkt
.dp_Arg1
= p_cmd
;
71 packet
->sp_Pkt
.dp_Arg2
= (IPTR
) p_1
;
72 packet
->sp_Pkt
.dp_Arg3
= (IPTR
) p_2
;
74 PutMsg (g_device_proc
, (struct Message
*) packet
);
78 res1
= packet
->sp_Pkt
.dp_Res1
;
79 res2
= packet
->sp_Pkt
.dp_Res2
;
81 PrintFault (res2
, (UBYTE
*) "ERROR");
83 FreeMem (packet
, sizeof (struct StandardPacket
));
84 DeleteMsgPort (replyport
);
87 void Cmd_Lowercase (void *p_1
, void *p_2
)
89 Send_Packet (CDCMD_LOWERCASE
, p_1
, p_2
);
92 void Cmd_Mactoiso (void *p_1
, void *p_2
)
94 Send_Packet (CDCMD_MACTOISO
, p_1
, p_2
);
97 void Cmd_Convertspaces (void *p_1
, void *p_2
)
99 Send_Packet (CDCMD_CONVERTSPACES
, p_1
, p_2
);
102 void Cmd_Showversion (void *p_1
, void *p_2
)
104 Send_Packet (CDCMD_SHOWVERSION
, p_1
, p_2
);
107 void Cmd_Hfsfirst (void *p_1
, void *p_2
)
109 Send_Packet (CDCMD_HFSFIRST
, p_1
, p_2
);
112 void Cmd_Dataext (void *p_1
, void *p_2
)
114 Send_Packet (CDCMD_DATAEXT
, p_1
, p_2
);
117 void Cmd_Resourceext (void *p_1
, void *p_2
)
119 Send_Packet (CDCMD_RESOURCEEXT
, p_1
, p_2
);
122 void Cmd_Unicodetable (void *p_1
, void *p_2
)
124 if (!Stricmp(p_1
, "none"))
126 Send_Packet (CDCMD_UNICODETABLE
, p_1
, p_2
);
134 void (*func
)(void *, void *);
136 {"lowercase", "l", PAR_ON_OFF
, PAR_NONE
, Cmd_Lowercase
},
137 {"mactoiso", "mi", PAR_ON_OFF
, PAR_NONE
, Cmd_Mactoiso
},
138 {"convertspaces", "cs", PAR_ON_OFF
, PAR_NONE
, Cmd_Convertspaces
},
139 {"showversion", "sv", PAR_ON_OFF
, PAR_NONE
, Cmd_Showversion
},
140 {"hfsfirst", "hf", PAR_ON_OFF
, PAR_NONE
, Cmd_Hfsfirst
},
141 {"dataext", "de", PAR_ANY
, PAR_NONE
, Cmd_Dataext
},
142 {"resourceext", "re", PAR_ANY
, PAR_NONE
, Cmd_Resourceext
},
143 {"unicodetable", "ut", PAR_ANY
, PAR_NONE
, Cmd_Unicodetable
}
149 "Usage: cdcontrol device command\n"
150 " Commands & parameters Abbrev. Meaning\n"
151 " --------------------- ------- -------\n"
152 " lowercase [on/off] l Convert ISO filenames to lowercase\n"
153 " mactoiso [on/off] mi Convert Mac to Amiga characters\n"
154 " convertspaces [on/off] cs Convert HFS spaces into underscores\n"
155 " showversion [on/off] sv Show version number of ISO filenames\n"
156 " hfsfirst [on/off] hf Look for a HFS partition first\n"
157 " dataext <extension> de Set extension for HFS data forks\n"
158 " resourceext <extension> re Set extension for HFS resource forks\n"
159 " unicodetable <name> ut Load Joliet character conversion table\n"
160 " (\"none\" means default built-in Latin-1 table)\n"
162 " cdcontrol cd0: showversion on\n"
163 " cdcontrol cd0: sv on\n"
164 " cdcontrol cd0: ut L:FileSystem_Trans/windows-1251.txt\n"
165 " cdcontrol cd0: ut none\n"
171 int main (int argc
, char *argv
[])
181 if (!(UtilityBase
= (APTR
)OpenLibrary ("utility.library", 37))) {
182 fprintf (stderr
, "cannot open utility.library\n");
186 dvp
= GetDeviceProc(argv
[1], NULL
);
188 fprintf (stderr
, "ERROR: cannot find device \"%s\"\n", argv
[1]);
192 g_device_proc
= dvp
->dvp_DevNode
->dol_Task
;
194 g_device_proc
= dvp
->dvp_Port
;
198 if (!g_device_proc
) {
199 fprintf(stderr
, "ERROR: \"%s\" is not a CDVDFS device\n", argv
[1]);
203 for (i
=0; i
< (sizeof (g_par
) / sizeof (struct par
)); i
++) {
204 if (Stricmp ((UBYTE
*) argv
[2], (UBYTE
*) g_par
[i
].name
) == 0 ||
205 Stricmp ((UBYTE
*) argv
[2], (UBYTE
*) g_par
[i
].abbrev
) == 0) {
209 if (g_par
[i
].par1
== PAR_ON_OFF
) {
210 if (Stricmp ((UBYTE
*) argv
[3], (UBYTE
*) "on") == 0)
212 else if (Stricmp ((UBYTE
*) argv
[3], (UBYTE
*) "off") == 0)
215 fprintf (stderr
, "ERROR: \"on\" or \"off\" expected\n");
219 g_par
[i
].func (a
, b
);