>>> "Danny" == Danny Epstein <[EMAIL PROTECTED]> writes:
[...]
Danny> I can't find anything in the code that limits the length
Danny> and I really doubt there's any documented limit (but I
Danny> haven't checked). I'd try to stick to a reasonable
Danny> limit, if possible, in case one is ever imposed later.
[...]
>>> "Jim" == Jim Schram <[EMAIL PROTECTED]> writes:
[...]
Jim> There doesn't appear to be a hard-coded limit on the length of a database name
as far as the name-search routines are concerned;
[...]
Ok, thanks to both of you for your answer. The reason I
asked this was not that I want to choose a library name with
a sane length, but because I'm writing a function the lookup
the library name from a given SysLib database. The caller
of that routines needs to allocate enough place for the library
name, or if there is no limit as it appears to be the case, I
have to take an aditionnal argument to limit the length of the
looked-up name.
I'm including this function below, I think it might interests
some other people too. I would especially welcome comments on
the `FIXME:' question :) Or maybe you know some clever way to
get the same result?
/*------------------------------------------------------------------.
| Open a database (known to be a SysLib) and run its initialization |
| function to get the library name. Unless an error occured, copy |
| that name to the area pointed by the `name' argument, up to |
| `nameMaxLen' chars. |
`------------------------------------------------------------------*/
static Err
GetSysLibName (UInt16 card, LocalID id, Char *name, UInt16 nameMaxLen)
{
/* Open the library for reading. */
DmOpenRef ref = DmOpenDatabase (card, id, dmModeReadOnly);
if (ref) {
/* Get's its code resource. */
MemHandle codeHdl = DmGet1Resource (sysResTLibrary, 0);
if (codeHdl) {
MemPtr codePtr = MemHandleLock (codeHdl);
/* Call the initialization function, with a dummy SysLib table
entry. FIXME: Does the RefNum argument really matters? */
SysLibTblEntryType entry;
entry.dispatchTblP = 0;
((SysLibEntryProcPtr) codePtr) (1234, &entry); /* Error code ignored. */
/* Now we should have the dispatch table handy. */
if (entry.dispatchTblP) {
/* The dispatch table is a list of signed offsets relative to the
dispatch table itself. The library name is pointed by the
first entry in that table. */
const Int16 *offsets = (const Int16 *) entry.dispatchTblP;
const Char *libname = ((const Char *) entry.dispatchTblP +
offsets[sysLibTrapName - sysLibTrapBase]);
/* Save the result. */
StrNCopy (name, libname, nameMaxLen);
}
MemHandleUnlock (codeHdl); /* Error code ignored. */
DmReleaseResource (codeHdl); /* Error code ignored. */
}
DmCloseDatabase (ref);
}
return DmGetLastErr ();
}
--
Alexandre Duret-Lutz
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/