示例#1
0
文件: frame.c 项目: collects/me
/*
 * frameChangeDepth  - Change the depth of the screen.
 * Resize the screen, re-writing the screen
 */
int
frameChangeDepth(int f, int n)
{
    /* if no argument is given then prompt for the new depth */
    if (f == false)
    {
        meUByte buff[meSBUF_SIZE_MAX] ;

        if (meGetString((meUByte *)"New depth", 0, 0, buff, meSBUF_SIZE_MAX) <= 0)
            return false ;
        n = meAtoi(buff) ;
    }
    else
        /* n is a delta, add this to the current width to get the new width */
        n = frameCur->depth + 1 + n ;
    if ((n < 4) || (n > 400))           /* Argument in range ?? */
        return mlwrite(MWABORT,(meUByte *)"[Screen depth %d out of range]", n);
    if (n == (frameCur->depth+1))
        return true;                    /* Already the right size */

    if(meFrameChangeDepth(frameCur,n) <= 0)
        return false ;

#ifdef _WINDOW
    meFrameSetWindowSize(frameCur) ;    /* Change the size of the window */
#endif
    return true ;
}
示例#2
0
/*
 * findRegistry
 * Find a key in the registry by indexing
 */
int
findRegistry (int f, int n)
{
    meUByte rootbuf [meBUF_SIZE_MAX];
    meUByte valbuf [12];
    int index;
    meRegNode *rnp ;

    /* Get the arguments */
    if((meGetString((meUByte *)"Registry Path", 0, 0, rootbuf, meBUF_SIZE_MAX) == meABORT) ||
       (meGetString((meUByte *)"Index", 0, 0, valbuf, 12) == meABORT))
        return meABORT;
    index = meAtoi (valbuf);

    /* Assigns the new value */
    if((rnp = regFind (&root, rootbuf)) == NULL)
        return mlwrite(MWCLEXEC|MWABORT,(meUByte *)"[Cannot find node %s]",rootbuf);
    /* Find the node that is indexed */
    f = index ;
    rnp = rnp->child;
    while((--index >= 0) && rnp)
        rnp = rnp->next;
    if(rnp == NULL)
    {
        resultStr [0] ='\0';
        return mlwrite (MWCLEXEC|MWABORT,(meUByte *)"Cannot find node at index %d", f);
    }
    meStrncpy(resultStr, rnp->name, meBUF_SIZE_MAX-1);
    resultStr[meBUF_SIZE_MAX-1] = '\0';
    return meTRUE;
}
示例#3
0
/*
 * Parse the file and import into the registry.
 */
static void
parseFile(meRegNode *rnp, meLine *hlp)
{
    meLine  *lp;                          /* Current line pointer */
    meRegNode *cnp;                         /* Current node pointer */
    meRegNode *lnp;                         /* Last node pointer */
    meUByte *lsp;                         /* Current line string pointer */
    meUByte  buf [meTOKENBUF_SIZE_MAX];              /* Local parse buffer */
    int level = 0;                      /* Nesting depth */
    int needValue = 0;                  /* Need a value flag */

    cnp = rnp;                          /* Current node pointer */
    lnp = NULL;                         /* No last node pointer */
    lp = meLineGetNext(hlp) ;                   /* Initial line pointer */
    lsp = lp->text ;                  /* Initial line string pointer */
    lineNo = 1;                         /* Initial line number */
    
    /* Read in the file until all processed. */
    while (lp != hlp)
    {
        lsp = token(lsp,buf) ;
        switch (buf[0])
        {
        case '\0':
            /* end of line, move to next */
        case ';':
            /* comment to the end of line, move to next */
            lp = meLineGetNext(lp) ;                   /* Initial line pointer */
            lsp = lp->text ;                 /* Initial line string pointer */
            lineNo++ ;                         /* Initial line number */
            break ;
            
        case '"':
            if (needValue)
            {
                /* Link the value to the name */
                meStrrep(&lnp->value,buf+1) ;
                needValue = 0;
            }
            else
            {
                /* Allocate a new node and link to the tree */
                if ((lnp = rnodeFind (cnp,buf+1)) == NULL)
                {
                    if ((lnp = rnodeNew (buf+1)) != NULL)
                        rnodeLink (cnp, lnp);
                }
            }
            break;
        
        case '{':
            if ((lnp == NULL) || needValue)
            {
                mlwrite(MWWAIT,(meUByte *)"[Registry error: unexpected '{' %s:%d]",
                        rnp->value, lineNo);
                return ;
            }
            level++;
            cnp = lnp;
            lnp = NULL;
            break;
        case '}':
            if(needValue || (level <= 0))
            {
                mlwrite(MWWAIT,(meUByte *)"[Registry error: mismatched '}' %s:%d]",
                        rnp->value, lineNo);
                return ;
            }
            cnp = cnp->parent;        /* Back up a level */
            lnp = NULL;
            level--;
            break;
        case '=':
            if(needValue || (lnp == NULL))
            {
                mlwrite(MWWAIT,(meUByte *)"[Registry error: expected <name>=<value> %s:%d]",
                        rnp->value, lineNo);
                return ;
            }
            needValue = 1;
            break;
        default:
            if(!isDigit(buf[0]) || needValue || (lnp == NULL))
            {
                mlwrite(MWWAIT,(meUByte *)"[Registry error: unexpected token \"%s\":%d]",
                        buf,lineNo);
                return ;
            }
            lnp->mode |= meAtoi(buf) ;
        }
    }

    /* End of file. Check for unmatched braces. */
    if (level > 0)
        mlwrite(MWWAIT,(meUByte *)"[Registry error: mismatched '}' at EOF. %d levels open %s:%d]",
                level, rnp->value, lineNo);
}