コード例 #1
0
ファイル: functions.c プロジェクト: timofonic/dopus5allamigas
void LIBFUNC L_BtoCStr(
	REG(a0, BSTR bstr),
	REG(a1, char *cstr),
	REG(d0, int len))
{
	int length = len;
	int size;
	#ifdef __AROS__
	char *string = AROS_BSTR_ADDR(bstr);
	#else
	char *string = (char *)(bstr<<2);
	#endif

	length--;
	#ifdef __AROS__
	size = AROS_BSTR_strlen(bstr);
	#else
	size = *((UBYTE *)string);
	string++;
	#endif
	if (size < len)
		length = size;
	for(size=0; size<length; size++)
		*(cstr++) = *(string++);
	*cstr = 0;
}
コード例 #2
0
void mount(struct HDTBPartition *table, struct PartitionHandle *ph, STRPTR name, struct DosEnvec *de)
{
    struct ExpansionBase *ExpansionBase;
    struct DeviceNode *dn;
    struct DosEnvec *nde;
    IPTR *params;
    ULONG i;

    D(bug("[HDToolBox] mount('%s')\n", name));

#error "TODO: pass DOS device name in params[0] and set handler name manually"
#warning "TODO: get filesystem"
    if ((de->de_DosType & 0xFFFFFF00) == BBNAME_DOS)
    {
        ExpansionBase = (struct ExpansionBase *)OpenLibrary("expansion.library",41);
        if (ExpansionBase)
        {
            params = (IPTR *)AllocVec(sizeof(struct DosEnvec)+sizeof(IPTR)*4, MEMF_PUBLIC | MEMF_CLEAR);
            if (params)
            {
                nde = (struct DosEnvec *)&params[4];
                CopyMem(de, nde, sizeof(struct DosEnvec));
                params[0] = (IPTR)"afs.handler";
                params[1] = (IPTR)table->hd->devname;
                params[2] = (IPTR)table->hd->unit;
                params[3] = 0;
                i = getOffset(ph->root);
                nde->de_LowCyl += i;
                nde->de_HighCyl += i;
                dn = MakeDosNode(params);
                if (dn)
                {
                    dn->dn_Name = MKBADDR(AllocVec(AROS_BSTR_MEMSIZE4LEN(strlen(name)), MEMF_PUBLIC));
                    dn->dn_Ext.dn_AROS.dn_DevName = AROS_BSTR_ADDR(dn->dn_Name);

                    i = 0;
                    do
                    {
                        AROS_BSTR_putchar(dn->dn_Name, i, name[i]);
                    } while (name[i++]);
                    AROS_BSTR_setstrlen(dn->dn_Name, i-1);
                    AddDosNode(nde->de_BootPri, ADNF_STARTPROC, dn);
                }
                else
                    FreeVec(params);
            }
            CloseLibrary((struct Library *)ExpansionBase);
        }
    }
    else
        kprintf("ignored %s: unknown FS (0x%lx)\n", name, de->de_DosType);
}
コード例 #3
0
ファイル: files_list.cpp プロジェクト: eriser/protrekkr-1
void CopyStringBSTRToC(BSTR in,
                       STRPTR out,
                       uint32_t max)
{
    uint32_t i;
    
    max = AROS_BSTR_strlen(in);
    
    for(i = 0; i < max; i++)
    {
        out[i] = *(AROS_BSTR_ADDR(in) + i);
    }
    out[i] = 0;
}
コード例 #4
0
static int GM_UNIQUENAME(Init)(LIBBASETYPEPTR conbase)
{
    static const char *devnames[2] = { "CON", "RAW" };
    struct DeviceNode *dn;
    int     	      i;


    /* Really bad hack, but con_handler is in ROM, intuition.library is
       open, if intuition.library is open, then Input.Device must be
       open, too, ... and I don't like to OpenDevice just for Peek-
       Qualifier */

#warning InputDevice open hack. Hope this is not a problem since it is only used for PeekQualifier
    Forbid();
    conbase->inputbase = (struct Device *)FindName(&SysBase->DeviceList, "input.device");
    Permit();

    /* Install CON: and RAW: handlers into device list
     *
     * KLUDGE: con-handler should create only one device node, depending on
     * the startup packet it gets. The mountlists for CON:/RAW: should be into dos.library bootstrap
     * routines.
     */
    for(i = 0; i < 2; i++)
    {
	if((dn = AllocMem(sizeof (struct DeviceNode) + 4 + AROS_BSTR_MEMSIZE4LEN(3),
                          MEMF_CLEAR|MEMF_PUBLIC)))
	{
	    BSTR s = (BSTR)MKBADDR(((IPTR)dn + sizeof(struct DeviceNode) + 3) & ~3);
	    WORD   a;
	    
	    for(a = 0; a < 3; a++)
	    {
		AROS_BSTR_putchar(s, a, devnames[i][a]);
	    }
	    AROS_BSTR_setstrlen(s, 3);

	    dn->dn_Type		= DLT_DEVICE;

	    /* 
	       i equals 1 when dn_DevName is "RAW", and 0 otherwise. This
	       tells con_task that it has to start in RAW mode
	     */   
	    dn->dn_Ext.dn_AROS.dn_Unit		= (struct Unit *)i;

	    dn->dn_Ext.dn_AROS.dn_Device	= &conbase->device;
	    dn->dn_Handler	= NULL;
	    dn->dn_Startup	= NULL;
	    dn->dn_Name		= s;
	    dn->dn_Ext.dn_AROS.dn_DevName	= AROS_BSTR_ADDR(dn->dn_Name);

	    if (AddDosEntry((struct DosList *)dn))
	    {
		if (i == 0)
		    continue;

		return TRUE;
	    }

	    FreeMem(dn, sizeof (struct DeviceNode));
	}
    }

    return FALSE;
}
コード例 #5
0
/* 
 Output: 0 - no mount (no partition change)
         1 - mount that device
         2 - reboot not really neccessary
             (FS not so important things changed like de_Mask)
         3 - reboot neccessary
             (FS important things changed like de_LowCyl)
*/
WORD checkMount(struct HDTBPartition *table, STRPTR name, struct DosEnvec *de)
{
    WORD retval = 1;
    struct DosList *dl;
    struct DeviceNode *entry;
    ULONG i;

    D(bug("[HDToolBox] checkMount('%s')\n", name));

    dl = LockDosList(LDF_READ | LDF_DEVICES);
    if (dl)
    {
        entry = (struct DeviceNode *)FindDosEntry(dl, name, LDF_DEVICES);
        if (entry)
        {
            struct FileSysStartupMsg *fssm;
            struct DosEnvec *d_de;
            STRPTR devname;

            fssm = (struct FileSysStartupMsg *)BADDR(entry->dn_Startup);
            devname = AROS_BSTR_ADDR(fssm->fssm_Device);
            if (
                    (fssm->fssm_Unit != table->hd->unit) ||
                    (strcmp(devname, table->hd->devname))
                )
            {
                retval = 3; /* better do a reboot */
            }
            else
            {	
                d_de = (struct DosEnvec *)BADDR(fssm->fssm_Environ);
                i = getOffset(table->ph);
                if (
                        (d_de->de_SizeBlock != de->de_SizeBlock) ||
                        (d_de->de_Reserved  != de->de_Reserved) ||
                        (d_de->de_PreAlloc  != de->de_PreAlloc) ||
                        (d_de->de_LowCyl    != (de->de_LowCyl+i)) ||
                        (d_de->de_HighCyl   != (de->de_HighCyl+i)) ||
                        (d_de->de_DosType   != de->de_DosType) ||
                        (
                            (
                                /* at least one has de_BootBocks */
                                (d_de->de_TableSize>=DE_BOOTBLOCKS) ||
                                (de->de_TableSize>=DE_BOOTBLOCKS)
                            ) &&
                            (
                                /* if one has no de_BootBlock assume de_BootBlock change */
                                (d_de->de_TableSize<DE_BOOTBLOCKS) ||
                                (de->de_TableSize<DE_BOOTBLOCKS)
                            )
                        ) ||
                        (
                            /* both have de_BootBlocks */
                            (d_de->de_TableSize>=DE_BOOTBLOCKS) &&
                            (de->de_TableSize>=DE_BOOTBLOCKS) &&
                            (d_de->de_BootBlocks != de->de_BootBlocks)
                        )
                    )
                {
                    retval = 3;
                }
                else if
                    (
                        (d_de->de_NumBuffers  != de->de_NumBuffers) ||
                        (d_de->de_BufMemType  != de->de_BufMemType) ||
                        (d_de->de_MaxTransfer != de->de_MaxTransfer) ||
                        (d_de->de_Mask        != de->de_Mask) ||
                        (d_de->de_BootPri     != de->de_BootPri)
                    )
                {
                    retval = 2;
                }
                else
                    retval = 0;
            }
        }
        UnLockDosList(LDF_READ | LDF_DEVICES);
    }
    return retval;
}
コード例 #6
0
ファイル: rawdofmt.c プロジェクト: michalsc/AROS
APTR InternalRawDoFmt(CONST_STRPTR FormatString, APTR DataStream, VOID_FUNC PutChProc,
		      APTR inPutChData, va_list VaListStream)
{
#if defined(mc68000)
    /* Frequently, AmigaOS users of RawDoFmt() rely upon the AmigaOS
     * behaviour that A3 *in this routine* is the pointer to PutChData,
     * *and* that it can be modified in PutChProc.
     */
    register volatile UBYTE  *PutChData asm("%a3");
#else
    UBYTE *PutChData = inPutChData;
#endif

    /* As long as there is something to format left */
    while (*FormatString)
    {
	/* Check for '%' sign */
	if (*FormatString == '%')
	{
	    /*
		left	 - left align flag
		fill	 - pad character
		minus	 - 1: number is negative
		minwidth - minimum width
		maxwidth - maximum width
		size	 - one of 'h', 'l', 'i'.
		width	 - width of printable string
		buf	 - pointer to printable string
	    */
	    int left  = 0;
	    int fill  = ' ';
	    int minus = 0;
	    int size  = 'h';
	    ULONG minwidth = 0;
	    ULONG maxwidth = ~0;
	    ULONG width    = 0;
	    UBYTE *buf;

            /* Number of decimal places required to convert a unsigned long to
               ascii. The formula is: ceil(number_of_bits*log10(2)).
	       Since I can't do this here I use .302 instead of log10(2) and
	       +1 instead of ceil() which most often leads to exactly the
	       same result (and never becomes smaller).

	       Note that when the buffer is large enough for decimal it's
	       large enough for hexadecimal as well.  */

	    #define CBUFSIZE (sizeof(IPTR)*8*302/1000+1)
	    /* The buffer for converting long to ascii.  */
	    UBYTE cbuf[CBUFSIZE];
	    ULONG i;

	    /* Skip over '%' character */
	    FormatString++;

	    /* '-' modifier? (left align) */
	    if (*FormatString == '-')
		left = *FormatString++;

	    /* '0' modifer? (pad with zeros) */
	    if (*FormatString == '0')
		fill = *FormatString++;

	    /* Get minimal width */
	    while (*FormatString >= '0' && *FormatString <= '9')
	    {
	        minwidth = minwidth * 10 + (*FormatString++ - '0');
	    }

	    /* Dot following width modifier? */
	    if(*FormatString == '.')
	    {
		FormatString++;
		/* Get maximum width */

		if(*FormatString >= '0' && *FormatString <= '9')
		{
		    maxwidth = 0;
		    do
			maxwidth = maxwidth *10 + (*FormatString++ - '0');
		    while (*FormatString >= '0' && *FormatString <= '9');
		}
	    }

	    /* size modifiers */
	    switch (*FormatString)
	    {
	    case 'l':
	    case 'i':
	    	size = *FormatString++;
		break;
	    }

	    /* Switch over possible format characters. Sets minus, width and buf. */
	    switch(*FormatString)
	    {
		/* BCPL string */
		case 'b':
                {
                    BSTR s = fetch_arg(BSTR);
                    
                    if (s)
                    {
		    	buf = AROS_BSTR_ADDR(s);
		    	width = AROS_BSTR_strlen(s);
		    }
		    else
		    {
		    	buf = "";
		    	width = 0;
		    }

		    break;
                }

		/* C string */
		case 's':
  		    buf = fetch_arg(UBYTE *);

                    if (!buf)
                        buf = "";
		    width = strlen(buf);

		    break;
		{
		    IPTR number = 0; int base;
		    static const char digits[] = "0123456789ABCDEF";

		    case 'p':
		    case 'P':
			fill = '0';
			minwidth = sizeof(APTR)*2;
			size = 'i';
		    case 'x':
		    case 'X':
		        base   = 16;
			number = fetch_number(size, 1);

                        goto do_number;

		    case 'd':
		    case 'D':
		        base   = 10;
  		        number = fetch_number(size, -1);
			minus  = (SIPTR)number < 0;

			if (minus) number = -number;

			goto do_number;

		    case 'u':
		    case 'U':
		        base = 10;
  		        number = fetch_number(size, 1);

		    do_number:

		        buf = &cbuf[CBUFSIZE];
			do
			{
  		            *--buf = digits[number % base];
			    number /= base;
		            width++;
			} while (number);

		    break;
		}


		/* single character */
		case 'c':
		    /* Some space for the result */
		    buf   = cbuf;
		    width = 1;

		    *buf = fetch_number(size, 1);

		    break;

		/* '%' before '\0'? */
		case '\0':
		    /*
			This is nonsense - but do something useful:
			Instead of reading over the '\0' reuse the '\0'.
		    */
		    FormatString--;
		    /* Get compiler happy */
		    buf = NULL;
		    break;

		/* Convert '%unknown' to 'unknown'. This includes '%%' to '%'. */
		default:
		    buf   = (UBYTE *)FormatString;
		    width = 1;
		    break;
	    }

	    if (width > maxwidth) width = maxwidth;

	    /* Skip the format character */
	    FormatString++;

	    /*
		Now everything I need is known:
		buf	 - contains the string to be printed
		width	 - the size of the string
		minus	 - is 1 if there is a '-' to print
		fill	 - is the pad character
		left	 - is 1 if the string should be left aligned
		minwidth - is the minimal width of the field
		(maxwidth is already part of width)

		So just print it.
	    */

	    /* Print '-' (if there is one and the pad character is no space) */
	    if (minus && fill != ' ')
	        PutCh('-');

	    /* Pad left if not left aligned */
	    if (!left)
		for (i = width + minus; i < minwidth; i++)
		    PutCh(fill);

	    /* Print '-' (if there is one and the pad character is a space) */
	    if(minus && fill == ' ')
                PutCh('-');

	    /* Print body upto width */
	    for(i=0; i<width; i++) {
	        PutCh(*buf);
		buf++;
	    }

	    /* Pad right if left aligned */
	    if(left)
		for(i = width + minus; i<minwidth; i++)
		    PutCh(fill);
	}
	else
	{