grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / filesys / CDVDFS / src / joliet.c
blob7f2e981ba39e1809744c364be3843946ff973d32
1 #include <proto/exec.h>
2 #include <exec/memory.h>
3 #include <stdlib.h>
4 #include <string.h>
6 #include "debug.h"
7 #include "iso9660.h"
8 #include "charset.h"
9 #include "joliet.h"
10 #include "globals.h"
11 #include "aros_stuff.h"
12 #include "clib_stuff.h"
15 * History:
17 * 06-Mar-09 error - Removed madness, fixed insanity. Cleanup started
20 extern struct Globals *global;
22 #define SysBase global->SysBase
24 t_bool Uses_Joliet_Protocol(CDROM *p_cdrom, t_ulong offset, t_ulong *p_svdoffset)
26 t_ulong svd_offset;
27 sup_vol_desc *svd;
29 for (svd_offset = 17;;svd_offset++)
31 if (!Read_Chunk(p_cdrom, svd_offset + offset))
32 return FALSE;
33 svd = (sup_vol_desc *)p_cdrom->buffer;
34 if (StrNCmp(svd->id, "CD001", 5) != 0)
35 return FALSE;
36 if (svd->type == 255)
37 return FALSE;
38 if ((svd->type == 2) && (svd->escape[0] == 0x25) && (svd->escape[1] == 0x2F) &&
39 ((svd->escape[2] == 0x40) || (svd->escape[2] == 0x43) || (svd->escape[2] == 0x45))) {
40 *p_svdoffset = svd_offset;
41 return TRUE;
46 int Get_Joliet_Name(struct CDVDBase *global, char *from, char *to, unsigned char len)
48 int l;
50 l = UTF16ToSystem(global, from, to, len);
52 if (l == -1)
54 int i;
56 l = 0;
57 for (i = 0; i < len; i+=2)
58 to[l++] = from[i] ? '_' : from[i+1];
61 return l;