Back to index

lightning-sunbird  0.9+nobinonly
Functions
interp.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "VerReg.h"
#include "NSReg.h"

Go to the source code of this file.

Functions

char * errstr (REGERR err)
int DumpTree (void)
int error (char *func, int err)
static char * GetNextWord (char *cmd, char *buf)
static int vr_ParseVersion (char *verstr, VERSION *result)
void vCreate (char *cmd)
void vFind (char *cmd)
void vHelp (char *cmd)
void vInstall (char *cmd)
void interp (void)

Function Documentation

int DumpTree ( void  )

Here is the caller graph for this function:

int error ( char *  func,
int  err 
)

Definition at line 51 of file interp.c.

{
       if (err == REGERR_OK)
       {
       printf("\t%s -- OK\n", func);
       }
       else
       {
              printf("\t%s -- %s\n", func, errstr(err));
       }

       return err;

}      /* error */

Here is the call graph for this function:

char* errstr ( REGERR  err)

Definition at line 56 of file regtest.c.

{

       switch( err )
       {
       case REGERR_OK:
              return "REGERR_OK";
       case REGERR_FAIL:
              return "REGERR_FAIL";
       case REGERR_NOMORE:
              return "REGERR_MORE";
       case REGERR_NOFIND:
              return "REGERR_NOFIND";
       case REGERR_BADREAD:
              return "REGERR_BADREAD";
       case REGERR_BADLOCN:
              return "REGERR_BADLOCN";
       case REGERR_PARAM:
              return "REGERR_PARAM";
       case REGERR_BADMAGIC:
              return "REGERR_BADMAGIC";
    case REGERR_BADCHECK:
        return "REGERR_BADCHECK";
    case REGERR_NOFILE:
        return "REGERR_NOFILE";
    case REGERR_MEMORY:
        return "REGERR_MEMORY";
    case REGERR_BUFTOOSMALL:
        return "REGERR_BUFTOOSMALL";
    case REGERR_NAMETOOLONG:
        return "REGERR_NAMETOOLONG";
    case REGERR_REGVERSION:
        return "REGERR_REGVERSION";
    case REGERR_DELETED:
        return "REGERR_DELETED";
    case REGERR_BADTYPE:
        return "REGERR_BADTYPE";
    case REGERR_NOPATH:
        return "REGERR_NOPATH";
    case REGERR_BADNAME:
        return "REGERR_BADNAME";
    case REGERR_READONLY:
        return "REGERR_READONLY";
    case REGERR_BADUTF8:
        return "REGERR_BADUTF8";
       default:
              return "<Unknown>";
       }

}      // errstr

Here is the caller graph for this function:

static char* GetNextWord ( char *  cmd,
char *  buf 
) [static]

Definition at line 66 of file interp.c.

{
       /* copies until ',' or eos, then skips spaces */
       if (!cmd || !buf)
              return 0;
       while (*cmd && *cmd != ',')
              *buf++ = *cmd++;
       *buf = '\0';
       if (*cmd == ',')
       {
              cmd++;
              while(*cmd && *cmd == ' ')
                     cmd++;
       }
       return cmd;

}      /* GetNextWord */

Here is the caller graph for this function:

void interp ( void  )

Definition at line 207 of file interp.c.

{

       char line[256];
       char *p;

       while(1)
       {
              putchar('>');
              putchar(' ');
              fflush(stdin); fflush(stdout); fflush(stderr);
              gets(line);

              /* p points to next word after verb on command line */
              p = line;
              while (*p && *p!=' ')
                     p++;
              if (!*p)
                     p = 0;
              else
              {
                     while(*p && *p==' ')
                            p++;
              }

              switch(toupper(line[0]))
              {
              case 'N':
                     vCreate(p);
                     break;
        case 'A':
            error("VR_SetRegDirectory", VR_SetRegDirectory(p));
            break;
        case 'C':
            error("VR_Close", VR_Close());
            break;

              case 'I':
                     vInstall(p);
                     break;
              case 'R':
              error("VR_Remove", VR_Remove(p));
                     break;
        case 'X':
              error("VR_InRegistry", VR_InRegistry(p));
            break;
        case 'T':
              error("VR_ValidateComponent", VR_ValidateComponent(p));
            break;

#if  LATER
        case 'E':
            vEnum(p);
            break;

        case 'V':
            vVersion(p);
            break;
        case 'P':
            vPath(p);
            break;
        case 'F':
            vGetRefCount(p);
            break;
        case 'D':
            vGetDir(p);
            break;
        
        case 'S':
            puts("--Unsupported--");
#endif

              case 'H':
              default:
                     vHelp(line);
                     break;
              case 'Q':
                     return;
              }      /* switch */
       }      /* while */

       assert(0);
       return;       /* shouldn't get here */

}      /* interp */

Here is the call graph for this function:

Here is the caller graph for this function:

void vCreate ( char *  cmd)

Definition at line 118 of file interp.c.

{

       /* Syntax: Create [new,] 5.0b1 */
       char buf[512];
    
       int flag = 0;
       cmd = GetNextWord(cmd, buf);
    
       error("VR_CreateRegistry", VR_CreateRegistry("Communicator", buf, cmd));

}      /* vCreate */

Here is the call graph for this function:

Here is the caller graph for this function:

void vFind ( char *  cmd)

Definition at line 133 of file interp.c.

{

       VERSION ver;
       char path[MAXREGPATHLEN];

       if (error("VR_GetVersion", VR_GetVersion(cmd, &ver)) == REGERR_OK)
       {
              if (error("VR_GetPath", VR_GetPath(cmd, sizeof(path), path)) == REGERR_OK)
              {
                     printf("%s found: ver=%d.%d.%d.%d, check=0x%04x, path=%s\n", 
                            cmd, ver.major, ver.minor, ver.release, ver.build, ver.check,
                            path);
                     return;
              }
       }

       printf("%s not found.\n", cmd);
       return;

}      /* vFind */

Here is the call graph for this function:

void vHelp ( char *  cmd)

Definition at line 156 of file interp.c.

{

       puts("Enter a command:");
    puts("\tN)ew <dir> [, <ver>] - create a new registry");
    puts("\tA)pp <dir>       - set application directory");
    puts("\tC)lose           - close the registry");
    puts("");
       puts("\tI)nstall <name>, <version>, <path> - install a new component");
       puts("\tR)emove <name>   - deletes a component from the Registry");
    puts("\tX)ists <name>    - checks for existence in registry");
    puts("\tT)est <name>     - validates physical existence");
    puts("\tE)num <name>     - dumps named subtree");
    puts("");
    puts("\tV)ersion <name>  - gets component version");
    puts("\tP)ath <name>     - gets component path");
    puts("\treF)count <name> - gets component refcount");
    puts("\tD)ir <name>      - gets component directory");
    puts("\tSR)efcount <name>- sets component refcount");
    puts("\tSD)ir <name>     - sets component directory");
    puts("");
       puts("\tQ)uit            - end the program");

}      /* vHelp */

Here is the call graph for this function:

Here is the caller graph for this function:

void vInstall ( char *  cmd)

Definition at line 182 of file interp.c.

{

       char name[MAXREGPATHLEN+1];
       char path[MAXREGPATHLEN+1];
    char ver[MAXREGPATHLEN+1];

    char *pPath, *pVer;

       cmd = GetNextWord(cmd, name);
    cmd = GetNextWord(cmd, ver);
    cmd = GetNextWord(cmd, path);

    pVer  = ( ver[0]  != '*' ) ? ver  : NULL;
    pPath = ( path[0] != '*' ) ? path : NULL;

       error("VR_Install", VR_Install(name, pPath, pVer, FALSE));

}      /* vInstall */

Here is the call graph for this function:

Here is the caller graph for this function:

static int vr_ParseVersion ( char *  verstr,
VERSION result 
) [static]

Definition at line 84 of file interp.c.

{

       result->major = result->minor = result->release = result->build = 0;
       result->major = atoi(verstr);
       while (*verstr && *verstr != '.')
              verstr++;
       if (*verstr)
       {
              verstr++;
              result->minor = atoi(verstr);
              while (*verstr && *verstr != '.')
                     verstr++;
              if (*verstr)
              {
                     verstr++;
                     result->release = atoi(verstr);
                     while (*verstr && *verstr != '.')
                            verstr++;
                     if (*verstr)
                     {
                            verstr++;
                            result->build = atoi(verstr);
                            while (*verstr && *verstr != '.')
                                   verstr++;
                     }
              }
       }

       return REGERR_OK;

}      /* ParseVersion */