[Coco] More on F$prsnam system call

Bob Devries bdevries at gil.com.au
Wed Jan 4 22:01:16 EST 2006


Well, Gene, it seems I was reading something into the documentation about 
the system call [F$Prsnam] that wasn't there. Even though the docs seem to 
suggest that you can call the function multiple times with that same 
pathname pointer, that is actually not the case.
Nor does the function allow for leading slash '/' characters, although it 
does not include them in the count.
The function call is supposed to flag illegal characters such as * and +, 
and return -1, but does not, instead, treating them as a delimeter like the 
slash '/'.
It correctly identifies leading '.' and '_' and '+' and '*' as being 
illegal, and returns -1 for those.

I guess what I need to do is work out what the system call returns in all 
sorts of situations.

Here's the code I tested it with on the Coco (well, MESS anyway):

/* _prsnam() test */
main()
{
        char *filename = "/DD/CMDS/Basic09"; /* insert illegal characters 
*+._ here at your pleasure */
/*        char *filename = "/D*/.CMDS/Basic09"; */ /* just an example */
        char name[28];
        int i;
        i = _prsnam(filename); /* do the call */
        if (i != -1) {
                if (*filename = '/') filename++; /* gotta skip the leading 
slash manually */
                strncpy(name, filename, i); /* copy results */
                name[i] = '\0';
                printf("name = %s, filename = %s, i = %d\n", name, filename, 
i); /* display results */
                filename += i;
        } else {
                printf("_prsnam() returned %d\n", i); /* or display failure 
*/
        }
        i = _prsnam(filename); /* go do it again.... */
        if (i != -1) {
                if (*filename = '/') filename++;
                strncpy(name, filename, i);
                name[i] = '\0';
                printf("name = %s, filename = %s, i = %d\n", name, filename, 
i);
        } else {
                printf("_prsnam() returned %d\n", i);
        }
}

/* OS9 function _prsnam() for COCO OS-9 */
#include <os9.h>
int
_prsnam(string)
char *string;
{
        struct registers reg;
        reg.rg_x = string;
        if (_os9(F_PRSNAM,&reg) != 0) {
                return(-1);
        } else {
                return((int)reg.rg_b & 0x0ff);
        }
}
/* EOF parsnam.c */

--
Regards, Bob Devries, Dalby, Queensland, Australia

Isaiah 50:4 The sovereign Lord has given me
the capacity to be his spokesman,
so that I know how to help the weary.

website: http://www.home.gil.com.au/~bdevasl
my blog: http://bdevries.invigorated.org/ 




More information about the Coco mailing list