Compare commits
5 commits
mane
...
misc-fixes
| Author | SHA1 | Date | |
|---|---|---|---|
| 33c86ceca2 | |||
| df8a1fcc25 | |||
| 94f6cd0004 | |||
|
|
8df708921d | ||
|
|
c68e5fb6a7 |
35 changed files with 172 additions and 135 deletions
|
|
@ -127,7 +127,7 @@ char *latin1_subst[128] = {
|
||||||
* NAME: charset->unicode()
|
* NAME: charset->unicode()
|
||||||
* DESCRIPTION: return a Unicode string for MacOS Standard Roman
|
* DESCRIPTION: return a Unicode string for MacOS Standard Roman
|
||||||
*/
|
*/
|
||||||
UCS2 *cs_unicode(char *mstr, int *lenptr)
|
UCS2 *cs_unicode(const char *mstr, int *lenptr)
|
||||||
{
|
{
|
||||||
int len, i;
|
int len, i;
|
||||||
UCS2 *unicode, *ptr;
|
UCS2 *unicode, *ptr;
|
||||||
|
|
@ -151,7 +151,7 @@ UCS2 *cs_unicode(char *mstr, int *lenptr)
|
||||||
* NAME: charset->latin1()
|
* NAME: charset->latin1()
|
||||||
* DESCRIPTION: return a Latin-1 (ISO 8859-1) string for MacOS Standard Roman
|
* DESCRIPTION: return a Latin-1 (ISO 8859-1) string for MacOS Standard Roman
|
||||||
*/
|
*/
|
||||||
char *cs_latin1(char *mstr, int *lenptr)
|
char *cs_latin1(const char *mstr, int *lenptr)
|
||||||
{
|
{
|
||||||
int ilen, olen, i;
|
int ilen, olen, i;
|
||||||
char *latin1, *ptr;
|
char *latin1, *ptr;
|
||||||
|
|
@ -229,7 +229,7 @@ void mktable(void)
|
||||||
* NAME: charset->macroman()
|
* NAME: charset->macroman()
|
||||||
* DESCRIPTION: return a MacOS Standard Roman string for Latin-1 (ISO 8859-1)
|
* DESCRIPTION: return a MacOS Standard Roman string for Latin-1 (ISO 8859-1)
|
||||||
*/
|
*/
|
||||||
char *cs_macroman(char *lstr, int *lenptr)
|
char *cs_macroman(const char *lstr, int *lenptr)
|
||||||
{
|
{
|
||||||
int ilen, olen, i;
|
int ilen, olen, i;
|
||||||
char *macroman, *ptr;
|
char *macroman, *ptr;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
typedef unsigned short UCS2;
|
typedef unsigned short UCS2;
|
||||||
|
|
||||||
UCS2 *cs_unicode(char *, int *);
|
UCS2 *cs_unicode(const char *, int *);
|
||||||
|
|
||||||
char *cs_latin1(char *, int *);
|
char *cs_latin1(const char *, int *);
|
||||||
char *cs_macroman(char *, int *);
|
char *cs_macroman(const char *, int *);
|
||||||
|
|
|
||||||
2
glob.c
2
glob.c
|
|
@ -336,7 +336,7 @@ int doglob(hfsvol *vol, dlist *list, const char *dir, const char *rem)
|
||||||
* NAME: hfs->glob()
|
* NAME: hfs->glob()
|
||||||
* DESCRIPTION: perform glob pattern matching
|
* DESCRIPTION: perform glob pattern matching
|
||||||
*/
|
*/
|
||||||
char **hfs_glob(hfsvol *vol, int argc, char *argv[], int *nelts)
|
char **hfs_glob(hfsvol *vol, int argc, const char *argv[], int *nelts)
|
||||||
{
|
{
|
||||||
dlist list;
|
dlist list;
|
||||||
int i;
|
int i;
|
||||||
|
|
|
||||||
2
glob.h
2
glob.h
|
|
@ -19,4 +19,4 @@
|
||||||
* $Id: glob.h,v 1.6 1998/04/11 08:26:55 rob Exp $
|
* $Id: glob.h,v 1.6 1998/04/11 08:26:55 rob Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char **hfs_glob(hfsvol *, int, char *[], int *);
|
char **hfs_glob(hfsvol *, int, const char *[], int *);
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ int usage(void)
|
||||||
* NAME: hattrib->main()
|
* NAME: hattrib->main()
|
||||||
* DESCRIPTION: implement hattrib command
|
* DESCRIPTION: implement hattrib command
|
||||||
*/
|
*/
|
||||||
int hattrib_main(int argc, char *argv[])
|
int hattrib_main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
const char *type = 0, *crea = 0;
|
const char *type = 0, *crea = 0;
|
||||||
int invis = 0, lock = 0, bless = 0;
|
int invis = 0, lock = 0, bless = 0;
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,4 @@
|
||||||
* $Id: hattrib.h,v 1.6 1998/04/11 08:26:56 rob Exp $
|
* $Id: hattrib.h,v 1.6 1998/04/11 08:26:56 rob Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int hattrib_main(int, char *[]);
|
int hattrib_main(int, const char *[]);
|
||||||
|
|
|
||||||
2
hcd.c
2
hcd.c
|
|
@ -36,7 +36,7 @@
|
||||||
* NAME: hcd->main()
|
* NAME: hcd->main()
|
||||||
* DESCRIPTION: implement hcd command
|
* DESCRIPTION: implement hcd command
|
||||||
*/
|
*/
|
||||||
int hcd_main(int argc, char *argv[])
|
int hcd_main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
mountent *ment;
|
mountent *ment;
|
||||||
hfsvol *vol;
|
hfsvol *vol;
|
||||||
|
|
|
||||||
2
hcd.h
2
hcd.h
|
|
@ -19,4 +19,4 @@
|
||||||
* $Id: hcd.h,v 1.7 1998/04/11 08:26:56 rob Exp $
|
* $Id: hcd.h,v 1.7 1998/04/11 08:26:56 rob Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int hcd_main(int, char *[]);
|
int hcd_main(int, const char *[]);
|
||||||
|
|
|
||||||
8
hcopy.c
8
hcopy.c
|
|
@ -252,7 +252,7 @@ int usage(void)
|
||||||
* NAME: hcopy->main()
|
* NAME: hcopy->main()
|
||||||
* DESCRIPTION: implement hcopy command
|
* DESCRIPTION: implement hcopy command
|
||||||
*/
|
*/
|
||||||
int hcopy_main(int argc, char *argv[])
|
int hcopy_main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
int nargs, mode = 'a', result = 0;
|
int nargs, mode = 'a', result = 0;
|
||||||
const char *target;
|
const char *target;
|
||||||
|
|
@ -265,7 +265,7 @@ int hcopy_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
opt = getopt(argc, argv, "mbtra");
|
opt = getopt(argc, (char**)argv, "mbtra");
|
||||||
if (opt == EOF)
|
if (opt == EOF)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -294,7 +294,7 @@ int hcopy_main(int argc, char *argv[])
|
||||||
|
|
||||||
copy = do_copyin;
|
copy = do_copyin;
|
||||||
fargc = nargs - 1;
|
fargc = nargs - 1;
|
||||||
fargv = &argv[optind];
|
fargv = (char**)&argv[optind];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -311,7 +311,7 @@ int hcopy_main(int argc, char *argv[])
|
||||||
|
|
||||||
hfsutil_unmount(vol, &result);
|
hfsutil_unmount(vol, &result);
|
||||||
|
|
||||||
if (fargv && fargv != &argv[optind])
|
if (fargv && fargv != (char**)&argv[optind])
|
||||||
free(fargv);
|
free(fargv);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
2
hcopy.h
2
hcopy.h
|
|
@ -19,4 +19,4 @@
|
||||||
* $Id: hcopy.h,v 1.6 1998/04/11 08:26:56 rob Exp $
|
* $Id: hcopy.h,v 1.6 1998/04/11 08:26:56 rob Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int hcopy_main(int, char *[]);
|
int hcopy_main(int, const char *[]);
|
||||||
|
|
|
||||||
2
hdel.c
2
hdel.c
|
|
@ -35,7 +35,7 @@
|
||||||
* NAME: hdel->main()
|
* NAME: hdel->main()
|
||||||
* DESCRIPTION: implement hdel command
|
* DESCRIPTION: implement hdel command
|
||||||
*/
|
*/
|
||||||
int hdel_main(int argc, char *argv[])
|
int hdel_main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
hfsvol *vol;
|
hfsvol *vol;
|
||||||
int fargc;
|
int fargc;
|
||||||
|
|
|
||||||
2
hdel.h
2
hdel.h
|
|
@ -19,4 +19,4 @@
|
||||||
* $Id: hdel.h,v 1.6 1998/04/11 08:26:57 rob Exp $
|
* $Id: hdel.h,v 1.6 1998/04/11 08:26:57 rob Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int hdel_main(int, char *[]);
|
int hdel_main(int, const char *[]);
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ hfsvol *do_format(const char *path, int partno, int mode, const char *vname)
|
||||||
* NAME: hformat->main()
|
* NAME: hformat->main()
|
||||||
* DESCRIPTION: implement hformat command
|
* DESCRIPTION: implement hformat command
|
||||||
*/
|
*/
|
||||||
int hformat_main(int argc, char *argv[])
|
int hformat_main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
const char *vname;
|
const char *vname;
|
||||||
char *path = 0;
|
char *path = 0;
|
||||||
|
|
@ -89,7 +89,7 @@ int hformat_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
opt = getopt(argc, argv, "fl:");
|
opt = getopt(argc, (char**)argv, "fl:");
|
||||||
if (opt == EOF)
|
if (opt == EOF)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,4 @@
|
||||||
* $Id: hformat.h,v 1.7 1998/04/11 08:26:57 rob Exp $
|
* $Id: hformat.h,v 1.7 1998/04/11 08:26:57 rob Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int hformat_main(int, char *[]);
|
int hformat_main(int, const char *[]);
|
||||||
|
|
|
||||||
|
|
@ -64,14 +64,14 @@ const char *argv0, *bargv0;
|
||||||
* NAME: main()
|
* NAME: main()
|
||||||
* DESCRIPTION: program entry dispatch
|
* DESCRIPTION: program entry dispatch
|
||||||
*/
|
*/
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
int i, len;
|
int i, len;
|
||||||
const char *dot;
|
const char *dot;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
int (*func)(int, char *[]);
|
int (*func)(int, const char *[]);
|
||||||
} list[] = {
|
} list[] = {
|
||||||
{ "hattrib", hattrib_main },
|
{ "hattrib", hattrib_main },
|
||||||
{ "hcd", hcd_main },
|
{ "hcd", hcd_main },
|
||||||
|
|
@ -254,7 +254,7 @@ void hfsutil_pinfo(hfsvolent *ent)
|
||||||
* NAME: hfsutil->glob()
|
* NAME: hfsutil->glob()
|
||||||
* DESCRIPTION: perform filename globbing
|
* DESCRIPTION: perform filename globbing
|
||||||
*/
|
*/
|
||||||
char **hfsutil_glob(hfsvol *vol, int argc, char *argv[],
|
char **hfsutil_glob(hfsvol *vol, int argc, const char *argv[],
|
||||||
int *nelts, int *result)
|
int *nelts, int *result)
|
||||||
{
|
{
|
||||||
char **fargv;
|
char **fargv;
|
||||||
|
|
@ -276,7 +276,7 @@ char **hfsutil_glob(hfsvol *vol, int argc, char *argv[],
|
||||||
char *hfsutil_getcwd(hfsvol *vol)
|
char *hfsutil_getcwd(hfsvol *vol)
|
||||||
{
|
{
|
||||||
char *path, name[HFS_MAX_FLEN + 1 + 1];
|
char *path, name[HFS_MAX_FLEN + 1 + 1];
|
||||||
long cwd;
|
unsigned long cwd;
|
||||||
int pathlen;
|
int pathlen;
|
||||||
|
|
||||||
path = malloc(1);
|
path = malloc(1);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ hfsvol *hfsutil_remount(mountent *, int);
|
||||||
void hfsutil_unmount(hfsvol *, int *);
|
void hfsutil_unmount(hfsvol *, int *);
|
||||||
|
|
||||||
void hfsutil_pinfo(hfsvolent *);
|
void hfsutil_pinfo(hfsvolent *);
|
||||||
char **hfsutil_glob(hfsvol *, int, char *[], int *, int *);
|
char **hfsutil_glob(hfsvol *, int, const char *[], int *, int *);
|
||||||
char *hfsutil_getcwd(hfsvol *);
|
char *hfsutil_getcwd(hfsvol *);
|
||||||
|
|
||||||
int hfsutil_samepath(const char *, const char *);
|
int hfsutil_samepath(const char *, const char *);
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ int Tcl_AppInit(Tcl_Interp *interp)
|
||||||
|
|
||||||
if (Tcl_Eval(interp, xhfs) == TCL_ERROR)
|
if (Tcl_Eval(interp, xhfs) == TCL_ERROR)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error: %s\n", interp->result);
|
fprintf(stderr, "Error: %s\n", Tcl_GetStringResult(interp));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
4
hls.c
4
hls.c
|
|
@ -828,7 +828,7 @@ int queuepath(hfsvol *vol, char *path, darray *dirs, darray *files, int flags)
|
||||||
* NAME: hls->main()
|
* NAME: hls->main()
|
||||||
* DESCRIPTION: implement hls command
|
* DESCRIPTION: implement hls command
|
||||||
*/
|
*/
|
||||||
int hls_main(int argc, char *argv[])
|
int hls_main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
hfsvol *vol;
|
hfsvol *vol;
|
||||||
int fargc, i;
|
int fargc, i;
|
||||||
|
|
@ -871,7 +871,7 @@ int hls_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
opt = getopt(argc, argv, "1abcdfilmqrstxw:CFNQRSU");
|
opt = getopt(argc, (char**)argv, "1abcdfilmqrstxw:CFNQRSU");
|
||||||
if (opt == EOF)
|
if (opt == EOF)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
2
hls.h
2
hls.h
|
|
@ -19,4 +19,4 @@
|
||||||
* $Id: hls.h,v 1.6 1998/04/11 08:26:58 rob Exp $
|
* $Id: hls.h,v 1.6 1998/04/11 08:26:58 rob Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int hls_main(int, char *[]);
|
int hls_main(int, const char *[]);
|
||||||
|
|
|
||||||
2
hmkdir.c
2
hmkdir.c
|
|
@ -35,7 +35,7 @@
|
||||||
* NAME: hmkdir->main()
|
* NAME: hmkdir->main()
|
||||||
* DESCRIPTION: implement hmkdir command
|
* DESCRIPTION: implement hmkdir command
|
||||||
*/
|
*/
|
||||||
int hmkdir_main(int argc, char *argv[])
|
int hmkdir_main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
hfsvol *vol;
|
hfsvol *vol;
|
||||||
char **fargv;
|
char **fargv;
|
||||||
|
|
|
||||||
2
hmkdir.h
2
hmkdir.h
|
|
@ -19,4 +19,4 @@
|
||||||
* $Id: hmkdir.h,v 1.6 1998/04/11 08:26:58 rob Exp $
|
* $Id: hmkdir.h,v 1.6 1998/04/11 08:26:58 rob Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int hmkdir_main(int, char *[]);
|
int hmkdir_main(int, const char *[]);
|
||||||
|
|
|
||||||
2
hmount.c
2
hmount.c
|
|
@ -36,7 +36,7 @@
|
||||||
* NAME: hmount->main()
|
* NAME: hmount->main()
|
||||||
* DESCRIPTION: implement hmount command
|
* DESCRIPTION: implement hmount command
|
||||||
*/
|
*/
|
||||||
int hmount_main(int argc, char *argv[])
|
int hmount_main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
char *path = 0;
|
char *path = 0;
|
||||||
hfsvol *vol;
|
hfsvol *vol;
|
||||||
|
|
|
||||||
2
hmount.h
2
hmount.h
|
|
@ -19,4 +19,4 @@
|
||||||
* $Id: hmount.h,v 1.7 1998/04/11 08:26:59 rob Exp $
|
* $Id: hmount.h,v 1.7 1998/04/11 08:26:59 rob Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int hmount_main(int, char *[]);
|
int hmount_main(int, const char *[]);
|
||||||
|
|
|
||||||
2
hpwd.c
2
hpwd.c
|
|
@ -35,7 +35,7 @@
|
||||||
* NAME: hpwd->main()
|
* NAME: hpwd->main()
|
||||||
* DESCRIPTION: implement hpwd command
|
* DESCRIPTION: implement hpwd command
|
||||||
*/
|
*/
|
||||||
int hpwd_main(int argc, char *argv[])
|
int hpwd_main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
mountent *ent;
|
mountent *ent;
|
||||||
|
|
||||||
|
|
|
||||||
2
hpwd.h
2
hpwd.h
|
|
@ -19,4 +19,4 @@
|
||||||
* $Id: hpwd.h,v 1.7 1998/04/11 08:26:59 rob Exp $
|
* $Id: hpwd.h,v 1.7 1998/04/11 08:26:59 rob Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int hpwd_main(int, char *[]);
|
int hpwd_main(int, const char *[]);
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ int do_rename(hfsvol *vol, int argc, char *argv[], const char *dest)
|
||||||
* NAME: hrename->main()
|
* NAME: hrename->main()
|
||||||
* DESCRIPTION: implement hrename command
|
* DESCRIPTION: implement hrename command
|
||||||
*/
|
*/
|
||||||
int hrename_main(int argc, char *argv[])
|
int hrename_main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
mountent *ment;
|
mountent *ment;
|
||||||
hfsvol *vol;
|
hfsvol *vol;
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,4 @@
|
||||||
* $Id: hrename.h,v 1.6 1998/04/11 08:26:59 rob Exp $
|
* $Id: hrename.h,v 1.6 1998/04/11 08:26:59 rob Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int hrename_main(int, char *[]);
|
int hrename_main(int, const char *[]);
|
||||||
|
|
|
||||||
2
hrmdir.c
2
hrmdir.c
|
|
@ -35,7 +35,7 @@
|
||||||
* NAME: hrmdir->main()
|
* NAME: hrmdir->main()
|
||||||
* DESCRIPTION: implement hrmdir command
|
* DESCRIPTION: implement hrmdir command
|
||||||
*/
|
*/
|
||||||
int hrmdir_main(int argc, char *argv[])
|
int hrmdir_main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
hfsvol *vol;
|
hfsvol *vol;
|
||||||
char **fargv;
|
char **fargv;
|
||||||
|
|
|
||||||
2
hrmdir.h
2
hrmdir.h
|
|
@ -19,4 +19,4 @@
|
||||||
* $Id: hrmdir.h,v 1.6 1998/04/11 08:26:59 rob Exp $
|
* $Id: hrmdir.h,v 1.6 1998/04/11 08:26:59 rob Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int hrmdir_main(int, char *[]);
|
int hrmdir_main(int, const char *[]);
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
* NAME: humount->main()
|
* NAME: humount->main()
|
||||||
* DESCRIPTION: implement humount command
|
* DESCRIPTION: implement humount command
|
||||||
*/
|
*/
|
||||||
int humount_main(int argc, char *argv[])
|
int humount_main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
int vnum;
|
int vnum;
|
||||||
mountent *ent;
|
mountent *ent;
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,4 @@
|
||||||
* $Id: humount.h,v 1.6 1998/04/11 08:26:59 rob Exp $
|
* $Id: humount.h,v 1.6 1998/04/11 08:26:59 rob Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int humount_main(int, char *[]);
|
int humount_main(int, const char *[]);
|
||||||
|
|
|
||||||
2
hvol.c
2
hvol.c
|
|
@ -64,7 +64,7 @@ int showvol(mountent *ment)
|
||||||
* NAME: hvol->main()
|
* NAME: hvol->main()
|
||||||
* DESCRIPTION: implement hvol command
|
* DESCRIPTION: implement hvol command
|
||||||
*/
|
*/
|
||||||
int hvol_main(int argc, char *argv[])
|
int hvol_main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
int vnum;
|
int vnum;
|
||||||
mountent *ment;
|
mountent *ment;
|
||||||
|
|
|
||||||
2
hvol.h
2
hvol.h
|
|
@ -19,4 +19,4 @@
|
||||||
* $Id: hvol.h,v 1.7 1998/04/11 08:27:00 rob Exp $
|
* $Id: hvol.h,v 1.7 1998/04/11 08:27:00 rob Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int hvol_main(int, char *[]);
|
int hvol_main(int, const char *[]);
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ int os_open(void **priv, const char *path, int mode)
|
||||||
(errno == EACCES || errno == EAGAIN))
|
(errno == EACCES || errno == EAGAIN))
|
||||||
ERROR(EAGAIN, "unable to obtain lock for medium");
|
ERROR(EAGAIN, "unable to obtain lock for medium");
|
||||||
|
|
||||||
*priv = (void *) fd;
|
*priv = (void *)(intptr_t) fd;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
@ -105,7 +105,7 @@ fail:
|
||||||
*/
|
*/
|
||||||
int os_close(void **priv)
|
int os_close(void **priv)
|
||||||
{
|
{
|
||||||
int fd = (int) *priv;
|
int fd = (int)(intptr_t) *priv;
|
||||||
|
|
||||||
*priv = (void *) -1;
|
*priv = (void *) -1;
|
||||||
|
|
||||||
|
|
@ -124,7 +124,7 @@ fail:
|
||||||
*/
|
*/
|
||||||
int os_same(void **priv, const char *path)
|
int os_same(void **priv, const char *path)
|
||||||
{
|
{
|
||||||
int fd = (int) *priv;
|
int fd = (int)(intptr_t) *priv;
|
||||||
struct stat fdev, dev;
|
struct stat fdev, dev;
|
||||||
|
|
||||||
if (fstat(fd, &fdev) == -1 ||
|
if (fstat(fd, &fdev) == -1 ||
|
||||||
|
|
@ -144,7 +144,7 @@ fail:
|
||||||
*/
|
*/
|
||||||
unsigned long os_seek(void **priv, unsigned long offset)
|
unsigned long os_seek(void **priv, unsigned long offset)
|
||||||
{
|
{
|
||||||
int fd = (int) *priv;
|
int fd = (int)(intptr_t) *priv;
|
||||||
off_t result;
|
off_t result;
|
||||||
|
|
||||||
/* offset == -1 special; seek to last block of device */
|
/* offset == -1 special; seek to last block of device */
|
||||||
|
|
@ -169,7 +169,7 @@ fail:
|
||||||
*/
|
*/
|
||||||
unsigned long os_read(void **priv, void *buf, unsigned long len)
|
unsigned long os_read(void **priv, void *buf, unsigned long len)
|
||||||
{
|
{
|
||||||
int fd = (int) *priv;
|
int fd = (int)(intptr_t) *priv;
|
||||||
ssize_t result;
|
ssize_t result;
|
||||||
|
|
||||||
result = read(fd, buf, len << HFS_BLOCKSZ_BITS);
|
result = read(fd, buf, len << HFS_BLOCKSZ_BITS);
|
||||||
|
|
@ -189,7 +189,7 @@ fail:
|
||||||
*/
|
*/
|
||||||
unsigned long os_write(void **priv, const void *buf, unsigned long len)
|
unsigned long os_write(void **priv, const void *buf, unsigned long len)
|
||||||
{
|
{
|
||||||
int fd = (int) *priv;
|
int fd = (int)(intptr_t) *priv;
|
||||||
ssize_t result;
|
ssize_t result;
|
||||||
|
|
||||||
result = write(fd, buf, len << HFS_BLOCKSZ_BITS);
|
result = write(fd, buf, len << HFS_BLOCKSZ_BITS);
|
||||||
|
|
|
||||||
205
tclhfs.c
205
tclhfs.c
|
|
@ -76,6 +76,39 @@ typedef struct {
|
||||||
Tcl_HashTable volumes; /* set containing mounted volumes (no values) */
|
Tcl_HashTable volumes; /* set containing mounted volumes (no values) */
|
||||||
Tcl_HashTable files; /* mapping of frefs -> vrefs */
|
Tcl_HashTable files; /* mapping of frefs -> vrefs */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME: resultf()
|
||||||
|
* DESCRIPTION: Fill the interpreter result using a printf-style format specifier
|
||||||
|
* NOTES: Requires a C99-conforming snprintf implemnetation
|
||||||
|
*/
|
||||||
|
#if __GNUC__
|
||||||
|
static
|
||||||
|
void resultf(Tcl_Interp *interp, const char *fmt, ...)
|
||||||
|
__attribute__((format(printf, 2, 3)));
|
||||||
|
#endif
|
||||||
|
static
|
||||||
|
void resultf(Tcl_Interp *interp, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
char smallbuf[60];
|
||||||
|
int required;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
required = vsnprintf(smallbuf, sizeof(smallbuf), fmt, ap) + 1; // returned size does not include trailing NUL
|
||||||
|
va_end(ap);
|
||||||
|
if (required < sizeof(smallbuf)) {
|
||||||
|
Tcl_SetResult(interp, smallbuf, TCL_VOLATILE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *buf = Tcl_Alloc(required);
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vsnprintf(buf, required, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
Tcl_SetResult(interp, buf, TCL_DYNAMIC);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NAME: error()
|
* NAME: error()
|
||||||
* DESCRIPTION: return a Tcl error for an HFS error
|
* DESCRIPTION: return a Tcl error for an HFS error
|
||||||
|
|
@ -119,7 +152,7 @@ char *direntstr(hfsdirent *ent)
|
||||||
mddate[CHARLEN(long) + 1],
|
mddate[CHARLEN(long) + 1],
|
||||||
bkdate[CHARLEN(long) + 1];
|
bkdate[CHARLEN(long) + 1];
|
||||||
register int argc;
|
register int argc;
|
||||||
char *argv[24];
|
const char *argv[24];
|
||||||
int locked, invis;
|
int locked, invis;
|
||||||
|
|
||||||
argc = 0;
|
argc = 0;
|
||||||
|
|
@ -238,7 +271,7 @@ int getdir(Tcl_Interp *interp, volref *vref, const char *path)
|
||||||
str = direntstr(&ent);
|
str = direntstr(&ent);
|
||||||
if (str == 0)
|
if (str == 0)
|
||||||
{
|
{
|
||||||
interp->result = "out of memory";
|
Tcl_SetResult(interp, "out of memory", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -275,7 +308,7 @@ void file_del(ClientData clientData)
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int file_cmd(ClientData clientData, Tcl_Interp *interp,
|
int file_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
int argc, char *argv[])
|
int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
fileref *fref = clientData;
|
fileref *fref = clientData;
|
||||||
hfsfile *file = fref->file;
|
hfsfile *file = fref->file;
|
||||||
|
|
@ -283,7 +316,7 @@ int file_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
switch (argc)
|
switch (argc)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
interp->result = "missing command";
|
Tcl_SetResult(interp, "missing command", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|
@ -301,7 +334,7 @@ int file_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
if (offset == -1)
|
if (offset == -1)
|
||||||
return error(interp, 0);
|
return error(interp, 0);
|
||||||
|
|
||||||
sprintf(interp->result, "%lu", offset);
|
resultf(interp, "%lu", offset);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "stat") == 0)
|
else if (strcmp(argv[1], "stat") == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -314,7 +347,7 @@ int file_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
str = direntstr(&ent);
|
str = direntstr(&ent);
|
||||||
if (str == 0)
|
if (str == 0)
|
||||||
{
|
{
|
||||||
interp->result = "out of memory";
|
Tcl_SetResult(interp, "out of memory", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -322,7 +355,7 @@ int file_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "getfork") == 0)
|
else if (strcmp(argv[1], "getfork") == 0)
|
||||||
{
|
{
|
||||||
interp->result = (hfs_getfork(file) == 0) ? "data" : "rsrc";
|
Tcl_SetResult(interp, (hfs_getfork(file) == 0) ? "data" : "rsrc", TCL_STATIC);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -345,7 +378,7 @@ int file_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
fork = 1;
|
fork = 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
interp->result = "bad arg to setfork: must be data or rsrc";
|
Tcl_SetResult(interp, "bad arg to setfork: must be data or rsrc", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -362,7 +395,7 @@ int file_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
if (offset == -1)
|
if (offset == -1)
|
||||||
return error(interp, 0);
|
return error(interp, 0);
|
||||||
|
|
||||||
sprintf(interp->result, "%lu", offset);
|
resultf(interp, "%lu", offset);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "read") == 0)
|
else if (strcmp(argv[1], "read") == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -374,7 +407,7 @@ int file_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
|
|
||||||
if (bytes < 0)
|
if (bytes < 0)
|
||||||
{
|
{
|
||||||
interp->result = "size must be >= 0";
|
Tcl_SetResult(interp, "size must be >= 0", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -399,7 +432,7 @@ int file_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
if (bytes == -1)
|
if (bytes == -1)
|
||||||
return error(interp, 0);
|
return error(interp, 0);
|
||||||
|
|
||||||
sprintf(interp->result, "%lu", bytes);
|
resultf(interp, "%lu", bytes);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -428,7 +461,7 @@ int file_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
whence = HFS_SEEK_END;
|
whence = HFS_SEEK_END;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
interp->result = "bad arg 3: must be start, current, or end";
|
Tcl_SetResult(interp, "bad arg 3: must be start, current, or end", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -436,7 +469,7 @@ int file_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
if (offset == -1)
|
if (offset == -1)
|
||||||
return error(interp, 0);
|
return error(interp, 0);
|
||||||
|
|
||||||
sprintf(interp->result, "%lu", offset);
|
resultf(interp, "%lu", offset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -486,6 +519,7 @@ int fork_native(Tcl_Interp *interp, hfsfile *ifile, hfsfile *ofile)
|
||||||
/*
|
/*
|
||||||
* NAME: file->ref()
|
* NAME: file->ref()
|
||||||
* DESCRIPTION: called to initialize a new file reference
|
* DESCRIPTION: called to initialize a new file reference
|
||||||
|
* NOTE: Sets interpreter result to the new command name
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
void file_ref(Tcl_Interp *interp, volref *vref, fileref *fref, hfsfile *file)
|
void file_ref(Tcl_Interp *interp, volref *vref, fileref *fref, hfsfile *file)
|
||||||
|
|
@ -495,17 +529,18 @@ void file_ref(Tcl_Interp *interp, volref *vref, fileref *fref, hfsfile *file)
|
||||||
Tcl_HashEntry *entry;
|
Tcl_HashEntry *entry;
|
||||||
int new;
|
int new;
|
||||||
|
|
||||||
|
char buf[sizeof("hfsfile") + sizeof(int) * 3];
|
||||||
do
|
do
|
||||||
sprintf(interp->result, "hfsfile%d", id++);
|
snprintf(buf, sizeof(buf), "hfsfile%d", id++);
|
||||||
while (Tcl_GetCommandInfo(interp, interp->result, &info));
|
while (Tcl_GetCommandInfo(interp, buf, &info));
|
||||||
|
|
||||||
fref->file = file;
|
fref->file = file;
|
||||||
fref->interp = interp;
|
fref->interp = interp;
|
||||||
fref->cmd = Tcl_CreateCommand(interp, interp->result,
|
fref->cmd = Tcl_CreateCommand(interp, buf, file_cmd, fref, file_del);
|
||||||
file_cmd, fref, file_del);
|
|
||||||
|
|
||||||
entry = Tcl_CreateHashEntry(&files, (char *) fref, &new);
|
entry = Tcl_CreateHashEntry(&files, (char *) fref, &new);
|
||||||
Tcl_SetHashValue(entry, vref);
|
Tcl_SetHashValue(entry, vref);
|
||||||
|
Tcl_SetResult(interp, buf, TCL_VOLATILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -541,7 +576,7 @@ int do_copynative(Tcl_Interp *interp, hfsfile *ifile, hfsfile *ofile)
|
||||||
* DESCRIPTION: copy an HFS file to another HFS volume
|
* DESCRIPTION: copy an HFS file to another HFS volume
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int copynative(Tcl_Interp *interp, volref *srcvref, char *argv[])
|
int copynative(Tcl_Interp *interp, volref *srcvref, const char *argv[])
|
||||||
{
|
{
|
||||||
volref *dstvref;
|
volref *dstvref;
|
||||||
Tcl_CmdInfo info;
|
Tcl_CmdInfo info;
|
||||||
|
|
@ -612,7 +647,7 @@ int copynative(Tcl_Interp *interp, volref *srcvref, char *argv[])
|
||||||
if (srcvref->vol == dstvref->vol &&
|
if (srcvref->vol == dstvref->vol &&
|
||||||
ent.cnid == cnid)
|
ent.cnid == cnid)
|
||||||
{
|
{
|
||||||
interp->result = "source and destination files are the same";
|
Tcl_SetResult(interp, "source and destination files are the same", TCL_STATIC);
|
||||||
hfs_close(ifile);
|
hfs_close(ifile);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
@ -649,7 +684,7 @@ int copynative(Tcl_Interp *interp, volref *srcvref, char *argv[])
|
||||||
* DESCRIPTION: copy a UNIX file into an HFS volume
|
* DESCRIPTION: copy a UNIX file into an HFS volume
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int copyin(Tcl_Interp *interp, hfsvol *vol, char *argv[])
|
int copyin(Tcl_Interp *interp, hfsvol *vol, const char *argv[])
|
||||||
{
|
{
|
||||||
cpifunc copyfile;
|
cpifunc copyfile;
|
||||||
|
|
||||||
|
|
@ -666,7 +701,7 @@ int copyin(Tcl_Interp *interp, hfsvol *vol, char *argv[])
|
||||||
copyfile = cpi_raw;
|
copyfile = cpi_raw;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
interp->result = "bad mode: must be macb, binh, text, or raw";
|
Tcl_SetResult(interp, "bad mode: must be macb, binh, text, or raw", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -684,7 +719,7 @@ int copyin(Tcl_Interp *interp, hfsvol *vol, char *argv[])
|
||||||
* DESCRIPTION: copy an HFS file out to a UNIX file
|
* DESCRIPTION: copy an HFS file out to a UNIX file
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int copyout(Tcl_Interp *interp, hfsvol *vol, char *argv[])
|
int copyout(Tcl_Interp *interp, hfsvol *vol, const char *argv[])
|
||||||
{
|
{
|
||||||
cpofunc copyfile;
|
cpofunc copyfile;
|
||||||
|
|
||||||
|
|
@ -701,7 +736,7 @@ int copyout(Tcl_Interp *interp, hfsvol *vol, char *argv[])
|
||||||
copyfile = cpo_raw;
|
copyfile = cpo_raw;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
interp->result = "bad mode: must be macb, binh, text, or raw";
|
Tcl_SetResult(interp, "bad mode: must be macb, binh, text, or raw", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -807,7 +842,7 @@ void vol_del(ClientData clientData)
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
int argc, char *argv[])
|
int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
volref *vref = clientData;
|
volref *vref = clientData;
|
||||||
hfsvol *vol = vref->vol;
|
hfsvol *vol = vref->vol;
|
||||||
|
|
@ -815,7 +850,7 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
switch (argc)
|
switch (argc)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
interp->result = "missing command";
|
Tcl_SetResult(interp, "missing command", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|
@ -831,21 +866,21 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
hfsvolent ent;
|
hfsvolent ent;
|
||||||
|
|
||||||
hfs_vstat(vol, &ent);
|
hfs_vstat(vol, &ent);
|
||||||
sprintf(interp->result, "%lu %lu", ent.totbytes, ent.freebytes);
|
resultf(interp, "%lu %lu", ent.totbytes, ent.freebytes);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "crdate") == 0)
|
else if (strcmp(argv[1], "crdate") == 0)
|
||||||
{
|
{
|
||||||
hfsvolent ent;
|
hfsvolent ent;
|
||||||
|
|
||||||
hfs_vstat(vol, &ent);
|
hfs_vstat(vol, &ent);
|
||||||
sprintf(interp->result, "%ld", (long) ent.crdate);
|
resultf(interp, "%ld", (long) ent.crdate);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "mddate") == 0)
|
else if (strcmp(argv[1], "mddate") == 0)
|
||||||
{
|
{
|
||||||
hfsvolent ent;
|
hfsvolent ent;
|
||||||
|
|
||||||
hfs_vstat(vol, &ent);
|
hfs_vstat(vol, &ent);
|
||||||
sprintf(interp->result, "%ld", (long) ent.mddate);
|
resultf(interp, "%ld", (long) ent.mddate);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "islocked") == 0)
|
else if (strcmp(argv[1], "islocked") == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -853,9 +888,9 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
|
|
||||||
hfs_vstat(vol, &ent);
|
hfs_vstat(vol, &ent);
|
||||||
if (ent.flags & HFS_ISLOCKED)
|
if (ent.flags & HFS_ISLOCKED)
|
||||||
interp->result = "1";
|
Tcl_SetResult(interp, "1", TCL_STATIC);
|
||||||
else
|
else
|
||||||
interp->result = "0";
|
Tcl_SetResult(interp, "0", TCL_STATIC);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "umount") == 0)
|
else if (strcmp(argv[1], "umount") == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -864,13 +899,13 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
return error(interp, 0);
|
return error(interp, 0);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "cwd") == 0)
|
else if (strcmp(argv[1], "cwd") == 0)
|
||||||
sprintf(interp->result, "%lu", vref->cwd);
|
resultf(interp, "%lu", vref->cwd);
|
||||||
else if (strcmp(argv[1], "path") == 0)
|
else if (strcmp(argv[1], "path") == 0)
|
||||||
{
|
{
|
||||||
char name[HFS_MAX_FLEN + 1];
|
char name[HFS_MAX_FLEN + 1];
|
||||||
long id;
|
unsigned long id;
|
||||||
int listc, i;
|
int listc, i;
|
||||||
char **listv;
|
const char **listv;
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
id = vref->cwd;
|
id = vref->cwd;
|
||||||
|
|
@ -884,12 +919,12 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
|
|
||||||
/* reverse the resulting list */
|
/* reverse the resulting list */
|
||||||
|
|
||||||
if (Tcl_SplitList(interp, interp->result, &listc, &listv) != TCL_OK)
|
if (Tcl_SplitList(interp, Tcl_GetStringResult(interp), &listc, &listv) != TCL_OK)
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
|
|
||||||
for (i = 0; i < listc / 2; ++i)
|
for (i = 0; i < listc / 2; ++i)
|
||||||
{
|
{
|
||||||
char *tmp;
|
const char *tmp;
|
||||||
|
|
||||||
tmp = listv[i];
|
tmp = listv[i];
|
||||||
listv[i] = listv[listc - 1 - i];
|
listv[i] = listv[listc - 1 - i];
|
||||||
|
|
@ -897,7 +932,7 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
}
|
}
|
||||||
|
|
||||||
result = Tcl_Merge(listc, listv);
|
result = Tcl_Merge(listc, listv);
|
||||||
Tcl_Free(listv);
|
Tcl_Free((char*)listv);
|
||||||
|
|
||||||
Tcl_SetResult(interp, result, TCL_DYNAMIC);
|
Tcl_SetResult(interp, result, TCL_DYNAMIC);
|
||||||
}
|
}
|
||||||
|
|
@ -912,7 +947,7 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
return error(interp, 0);
|
return error(interp, 0);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "sepchar") == 0)
|
else if (strcmp(argv[1], "sepchar") == 0)
|
||||||
interp->result = ":";
|
Tcl_SetResult(interp, ":", TCL_STATIC);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Tcl_AppendResult(interp, "bad command \"", argv[1],
|
Tcl_AppendResult(interp, "bad command \"", argv[1],
|
||||||
|
|
@ -933,7 +968,7 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "dirinfo") == 0)
|
else if (strcmp(argv[1], "dirinfo") == 0)
|
||||||
{
|
{
|
||||||
long id;
|
unsigned long id;
|
||||||
char name[HFS_MAX_FLEN + 1], idstr[CHARLEN(unsigned long) + 1];
|
char name[HFS_MAX_FLEN + 1], idstr[CHARLEN(unsigned long) + 1];
|
||||||
|
|
||||||
if (Tcl_ExprLong(interp, argv[2], &id) != TCL_OK)
|
if (Tcl_ExprLong(interp, argv[2], &id) != TCL_OK)
|
||||||
|
|
@ -959,7 +994,7 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
fref = ALLOC(fileref, 1);
|
fref = ALLOC(fileref, 1);
|
||||||
if (fref == 0)
|
if (fref == 0)
|
||||||
{
|
{
|
||||||
interp->result = "out of memory";
|
Tcl_SetResult(interp, "out of memory", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -984,7 +1019,7 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
str = direntstr(&ent);
|
str = direntstr(&ent);
|
||||||
if (str == 0)
|
if (str == 0)
|
||||||
{
|
{
|
||||||
interp->result = "out of memory";
|
Tcl_SetResult(interp, "out of memory", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1024,7 +1059,8 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
else if (strcmp(argv[1], "glob") == 0)
|
else if (strcmp(argv[1], "glob") == 0)
|
||||||
{
|
{
|
||||||
int listc, fargc;
|
int listc, fargc;
|
||||||
char **listv, **fargv, *result;
|
const char **listv;
|
||||||
|
char **fargv, *result;
|
||||||
|
|
||||||
if (hfs_setcwd(vol, vref->cwd) == -1)
|
if (hfs_setcwd(vol, vref->cwd) == -1)
|
||||||
return error(interp, 0);
|
return error(interp, 0);
|
||||||
|
|
@ -1033,16 +1069,16 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
|
|
||||||
fargv = hfs_glob(vol, listc, listv, &fargc);
|
fargv = hfs_glob(vol, listc, listv, &fargc);
|
||||||
free(listv);
|
Tcl_Free((void*)listv);
|
||||||
|
|
||||||
if (fargv == 0)
|
if (fargv == 0)
|
||||||
{
|
{
|
||||||
interp->result = "globbing error";
|
Tcl_SetResult(interp, "globbing error", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = Tcl_Merge(fargc, fargv);
|
result = Tcl_Merge(fargc, (const char**)fargv);
|
||||||
Tcl_Free(fargv);
|
free(fargv);
|
||||||
|
|
||||||
Tcl_SetResult(interp, result, TCL_DYNAMIC);
|
Tcl_SetResult(interp, result, TCL_DYNAMIC);
|
||||||
}
|
}
|
||||||
|
|
@ -1093,14 +1129,14 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
if (strlen(argv[3]) != 4 ||
|
if (strlen(argv[3]) != 4 ||
|
||||||
strlen(argv[4]) != 4)
|
strlen(argv[4]) != 4)
|
||||||
{
|
{
|
||||||
interp->result = "type and creator must be 4 character strings";
|
Tcl_SetResult(interp, "type and creator must be 4 character strings", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
fref = ALLOC(fileref, 1);
|
fref = ALLOC(fileref, 1);
|
||||||
if (fref == 0)
|
if (fref == 0)
|
||||||
{
|
{
|
||||||
interp->result = "out of memory";
|
Tcl_SetResult(interp, "out of memory", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1152,13 +1188,13 @@ int vol_cmd(ClientData clientData, Tcl_Interp *interp,
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
int argc, char *argv[])
|
int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
static int id = 0;
|
static int id = 0;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
interp->result = "wrong # args";
|
Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1173,7 +1209,7 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
|
|
||||||
if (argc < 3 || argc > 4)
|
if (argc < 3 || argc > 4)
|
||||||
{
|
{
|
||||||
interp->result = "wrong # args";
|
Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1192,7 +1228,7 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
|
|
||||||
if (nparts > 1)
|
if (nparts > 1)
|
||||||
{
|
{
|
||||||
sprintf(interp->result, "must specify partition number "
|
resultf(interp, "must specify partition number "
|
||||||
"(%d available)", nparts);
|
"(%d available)", nparts);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
@ -1205,7 +1241,7 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
vref = ALLOC(volref, 1);
|
vref = ALLOC(volref, 1);
|
||||||
if (vref == 0)
|
if (vref == 0)
|
||||||
{
|
{
|
||||||
interp->result = "out of memory";
|
Tcl_SetResult(interp, "out of memory", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1225,12 +1261,13 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
|
|
||||||
entry = Tcl_CreateHashEntry(&volumes, (char *) vref, &new);
|
entry = Tcl_CreateHashEntry(&volumes, (char *) vref, &new);
|
||||||
|
|
||||||
|
char buf[sizeof("hfsvol") + sizeof(int) * 3];
|
||||||
do
|
do
|
||||||
sprintf(interp->result, "hfsvol%d", id++);
|
snprintf(buf, sizeof(buf), "hfsvol%d", id++);
|
||||||
while (Tcl_GetCommandInfo(interp, interp->result, &info));
|
while (Tcl_GetCommandInfo(interp, buf, &info));
|
||||||
|
|
||||||
Tcl_CreateCommand(interp, interp->result,
|
Tcl_CreateCommand(interp, buf, vol_cmd, vref, vol_del);
|
||||||
vol_cmd, vref, vol_del);
|
Tcl_SetResult(interp, buf, TCL_VOLATILE);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "zero") == 0)
|
else if (strcmp(argv[1], "zero") == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -1239,7 +1276,7 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
|
|
||||||
if (argc != 4)
|
if (argc != 4)
|
||||||
{
|
{
|
||||||
interp->result = "wrong # args";
|
Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1249,7 +1286,7 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
if (do_zero(argv[2], nparts, &len) == -1)
|
if (do_zero(argv[2], nparts, &len) == -1)
|
||||||
return error(interp, 0);
|
return error(interp, 0);
|
||||||
|
|
||||||
sprintf(interp->result, "%lu", len);
|
resultf(interp, "%lu", len);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "mkpart") == 0)
|
else if (strcmp(argv[1], "mkpart") == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -1257,7 +1294,7 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
|
|
||||||
if (argc != 4)
|
if (argc != 4)
|
||||||
{
|
{
|
||||||
interp->result = "wrong # args";
|
Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1273,7 +1310,7 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
|
|
||||||
if (argc != 3)
|
if (argc != 3)
|
||||||
{
|
{
|
||||||
interp->result = "wrong # args";
|
Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1281,7 +1318,7 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
nparts = hfs_nparts(argv[2]);
|
nparts = hfs_nparts(argv[2]);
|
||||||
suid_disable();
|
suid_disable();
|
||||||
|
|
||||||
sprintf(interp->result, "%d", nparts);
|
resultf(interp, "%d", nparts);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "format") == 0)
|
else if (strcmp(argv[1], "format") == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -1289,7 +1326,7 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
|
|
||||||
if (argc < 5 || argc > 6)
|
if (argc < 5 || argc > 6)
|
||||||
{
|
{
|
||||||
interp->result = "wrong # args";
|
Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1299,7 +1336,7 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
if (argc == 6)
|
if (argc == 6)
|
||||||
{
|
{
|
||||||
int listc, i;
|
int listc, i;
|
||||||
char **listv;
|
const char **listv;
|
||||||
unsigned long *badblocks;
|
unsigned long *badblocks;
|
||||||
|
|
||||||
if (Tcl_SplitList(interp, argv[5], &listc, &listv) != TCL_OK)
|
if (Tcl_SplitList(interp, argv[5], &listc, &listv) != TCL_OK)
|
||||||
|
|
@ -1308,9 +1345,9 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
badblocks = ALLOCX(unsigned long, listc);
|
badblocks = ALLOCX(unsigned long, listc);
|
||||||
if (listc && badblocks == 0)
|
if (listc && badblocks == 0)
|
||||||
{
|
{
|
||||||
Tcl_Free(listv);
|
Tcl_Free((void*)listv);
|
||||||
|
|
||||||
interp->result = "out of memory";
|
Tcl_SetResult(interp, "out of memory", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1319,13 +1356,13 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
if (Tcl_ExprLong(interp, listv[i],
|
if (Tcl_ExprLong(interp, listv[i],
|
||||||
(long *) &badblocks[i]) != TCL_OK)
|
(long *) &badblocks[i]) != TCL_OK)
|
||||||
{
|
{
|
||||||
Tcl_Free(listv);
|
Tcl_Free((void*)listv);
|
||||||
FREE(badblocks);
|
FREE(badblocks);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Tcl_Free(listv);
|
Tcl_Free((void*)listv);
|
||||||
|
|
||||||
if (do_format(argv[2], partno, 0, argv[4], listc, badblocks) == -1)
|
if (do_format(argv[2], partno, 0, argv[4], listc, badblocks) == -1)
|
||||||
{
|
{
|
||||||
|
|
@ -1351,7 +1388,7 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
|
|
||||||
if (argc != 5)
|
if (argc != 5)
|
||||||
{
|
{
|
||||||
interp->result = "wrong # args";
|
Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1360,8 +1397,8 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
(strcmp(argv[3], "latin1") != 0 &&
|
(strcmp(argv[3], "latin1") != 0 &&
|
||||||
strcmp(argv[3], "macroman") != 0))
|
strcmp(argv[3], "macroman") != 0))
|
||||||
{
|
{
|
||||||
interp->result = "bad arg to chartrans: "
|
Tcl_SetResult(interp, "bad arg to chartrans: "
|
||||||
"charsets must be one of latin1, macroman";
|
"charsets must be one of latin1, macroman", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1373,13 +1410,13 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
result = cs_latin1(argv[4], 0);
|
result = cs_latin1(argv[4], 0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Tcl_SetResult(interp, argv[4], TCL_VOLATILE);
|
Tcl_SetObjResult(interp, Tcl_NewStringObj(argv[4], -1));
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
interp->result = "out of memory";
|
Tcl_SetResult(interp, "out of memory", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1393,41 +1430,41 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
{
|
{
|
||||||
interp->result = "wrong # args";
|
Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
interp->result = (char *) hfsutils_version;
|
Tcl_SetResult(interp, (char *)hfsutils_version, TCL_STATIC);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "copyright") == 0)
|
else if (strcmp(argv[1], "copyright") == 0)
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
{
|
{
|
||||||
interp->result = "wrong # args";
|
Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
interp->result = (char *) hfsutils_copyright;
|
Tcl_SetResult(interp, (char *)hfsutils_copyright, TCL_STATIC);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "author") == 0)
|
else if (strcmp(argv[1], "author") == 0)
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
{
|
{
|
||||||
interp->result = "wrong # args";
|
Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
interp->result = (char *) hfsutils_author;
|
Tcl_SetResult(interp, (char *)hfsutils_author, TCL_STATIC);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "license") == 0)
|
else if (strcmp(argv[1], "license") == 0)
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
{
|
{
|
||||||
interp->result = "wrong # args";
|
Tcl_SetResult(interp, "wrong # args", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
interp->result = (char *) hfsutils_license;
|
Tcl_SetResult(interp, (char *)hfsutils_license, TCL_STATIC);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1448,13 +1485,13 @@ int cmd_hfs(ClientData clientData, Tcl_Interp *interp,
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int cmd_exit(ClientData clientData, Tcl_Interp *interp,
|
int cmd_exit(ClientData clientData, Tcl_Interp *interp,
|
||||||
int argc, char *argv[])
|
int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
{
|
{
|
||||||
interp->result = "wrong # args: should be \"exit ?returnCode?\"";
|
Tcl_SetResult(interp, "wrong # args: should be \"exit ?returnCode?\"", TCL_STATIC);
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1477,8 +1514,8 @@ int Hfs_Init(Tcl_Interp *interp)
|
||||||
Tcl_InitHashTable(&volumes, TCL_ONE_WORD_KEYS);
|
Tcl_InitHashTable(&volumes, TCL_ONE_WORD_KEYS);
|
||||||
Tcl_InitHashTable(&files, TCL_ONE_WORD_KEYS);
|
Tcl_InitHashTable(&files, TCL_ONE_WORD_KEYS);
|
||||||
|
|
||||||
Tcl_CreateCommand(interp, "hfs", cmd_hfs, 0, 0);
|
Tcl_CreateCommand(interp, "hfs", cmd_hfs, NULL, NULL);
|
||||||
Tcl_CreateCommand(interp, "exit", cmd_exit, 0, 0);
|
Tcl_CreateCommand(interp, "exit", cmd_exit, NULL, NULL);
|
||||||
|
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue