Exemplo n.º 1
0
int CSubTitles::Init (const char* filename)
{
	CFile cf;
	int 	size, readCount;
	ubyte	*p;
	int 	bHaveBinary = 0;

m_nCaptions = 0;
if (!gameOpts->movies.bSubTitles)
	return 0;
if (!cf.Open (filename, gameFolders.szDataDir, "rb", 0)) { // first try text version
	char filename2 [FILENAME_LEN];	//no text version, try binary version
	CFile::ChangeFilenameExtension (filename2, filename, ".txb");
	if (!cf.Open (filename2, gameFolders.szDataDir, "rb", 0))
		return 0;
	bHaveBinary = 1;
	}

size = cf.Length ();
m_rawDataP = new ubyte [size+1];
readCount = (int) cf.Read (m_rawDataP, 1, size);
cf.Close ();
m_rawDataP [size] = 0;
if (readCount != size) {
	delete[] m_rawDataP;
	return 0;
	}
p = m_rawDataP;
while (p && (p < m_rawDataP + size)) {
	char* endp = strchr (reinterpret_cast<char*> (p), '\n'); 

	if (endp) {
		if (endp [-1] == '\r')
			endp [-1] = 0;		//handle 0d0a pair
		*endp = 0;			//string termintor
		}
	if (bHaveBinary)
		DecodeTextLine (reinterpret_cast<char*> (p));
	if (*p != ';') {
		m_captions [m_nCaptions].first_frame = atoi (reinterpret_cast<char*> (p));
		if (!(p = NextField (p))) 
			continue;
		m_captions [m_nCaptions].last_frame = atoi (reinterpret_cast<char*> (p));
		if (!(p = NextField (p)))
			continue;
		m_captions [m_nCaptions].msg = reinterpret_cast<char*> (p);
		Assert (m_nCaptions==0 || m_captions [m_nCaptions].first_frame >= m_captions [m_nCaptions-1].first_frame);
		Assert (m_captions [m_nCaptions].last_frame >= m_captions [m_nCaptions].first_frame);
		m_nCaptions++;
		}
	p = reinterpret_cast<ubyte*> (endp + 1);
	}
return 1;
}
Exemplo n.º 2
0
test_F ScalarProduct()
{
   while (NextField() > 0) {
      int size;
      for (size = 0; size < 1000; size += size / 10 + 1) {
         PTR a, b;
         FfSetNoc(size);
         a = FfAlloc(1);
         b = FfAlloc(1);
         TestScalarProduct1(a,b,size);
         SysFree(a);
         SysFree(b);
      }
   }
}
Exemplo n.º 3
0
int NNTPResponse::NextIntField()
{
	return sstoi(NextField());
/***
	string_slice field = NextField();

	// convert to int
	char fieldStr[256];
	if (field.length() > 255)
		field.resize(255);
	int len = field.length();
	memcpy(fieldStr, field.begin(), len);
	fieldStr[len] = 0;
	return atoi(fieldStr);
***/
}
Exemplo n.º 4
0
/**
 * Worker for ApplyProperty that handles a yes, no, maybe property value.
 *
 * @returns 0 (NO), 1 (YES), 2 (MAYBE).
 * @param   ppszNextField   The field cursor, input and output.
 */
static int YesNoMaybePropertyValue(char **ppszNextField)
{
    if (!**ppszNextField)
    {
        ParseError("Missing Y/N/M field\n");
        return 0;
    }
    char *psz = NextField(ppszNextField);
    if (!strcmp(psz, "N"))
        return 0;
    if (!strcmp(psz, "Y"))
        return 1;
    if (!strcmp(psz, "M"))
        return 2;
    ParseError("Unexpected Y/N/M value: '%s'\n",  psz);
    return 0;
}
Exemplo n.º 5
0
test_F GreasedMapRow()
{
   while (NextField() > 0) {
      int gr_level;
      int max_gr_level;
      int fpow;
      Matrix_t *m = RndMat(FfOrder,20,20);
      for (fpow = FfOrder, max_gr_level = 1;
           max_gr_level <= 16 && fpow < 66000;
           ++max_gr_level, fpow *= FfOrder) {
      }
      --max_gr_level;
      for (gr_level = 0; gr_level <= max_gr_level; ++gr_level) {
         TestGrMapRow1(m,gr_level);
      }
      MatFree(m);
   }
}
Exemplo n.º 6
0
/**
 * Reads a property file.
 *
 * There are several property files, this code can read all
 * of those but will only make use of the properties it recognizes.
 *
 * @returns 0 on success.
 * @returns !0 on failure.
 * @param   pszBasePath         The base path, can be NULL.
 * @param   pszFilename     The name of the file.
 */
static int ReadProperties(const char *pszBasePath, const char *pszFilename)
{
    /*
     * Open input.
     */
    FILE *pFile = OpenFile(pszBasePath, pszFilename);
    if (!pFile)
        return 1;

    /*
     * Parse the input and spit out the output.
     */
    char szLine[4096];
    while (GetLineFromFile(szLine, sizeof(szLine), pFile) != NULL)
    {
        if (IsCommentOrBlankLine(szLine))
            continue;
        char *pszCurField;
        char *pszRange    = FirstField(&pszCurField, StripLine(szLine));
        char *pszProperty = NextField(&pszCurField);
        if (!*pszProperty)
        {
            ParseError("no property field.\n");
            continue;
        }

        RTUNICP LastCP;
        RTUNICP StartCP = ToRange(pszRange, &LastCP);
        if (StartCP == ~(RTUNICP)0)
            continue;

        while (StartCP <= LastCP)
            ApplyProperty(StartCP++, pszProperty, pszCurField);
    }

    CloseFile(pFile);

    return 0;
}
Exemplo n.º 7
0
/* FindUser()
 * Open the indicated file and find the first line where the first
 * field matches the provided username.  Optionally return the
 * second field (password) and/or parse the remaining fields
 * (groups) into a non-NULL terminated, length-prefixed sequence
 * of strings (see below).
 *
 * The caller must supply a read buffer for use when processing
 * the file.
 *
 * Leading and trailing whitesapce is stripped from the password
 * and all group names.
 *
 * Returns:  0 for success,
 *          -1 if the user was not found
 *          -2 on error, *errorMessage will be set to a static C
 *             string describing the error.
 *
 * If groups are requested, the supplied group buffer must be at
 * least as large as the supplied read buffer.  The groups are
 * written into that buffer in the following format:
 *   <one byte length><group string><one byte length><group string>...
 * and *numGroups is set to indicate how many groups were written
 * to the group buffer.  Note that the group name strings are not
 * NULL terminated.
 */
int FindUser(const char *fileName,  /* File to read                */
             const char *userName,  /* Who we're looking for       */
             char *readBuffer,      /* Caller-supplied read buffer */
             int readBufferLength,
             char **passwordPtr,    /* Output: password            */
             char *groupBuffer,     /* Output: group list          */
             int *numGroups,        /* Output: number of groups    */
             char **errorMessage)   /* Static C string for errors  */
{
    int rc = -1;
    int foundUser = 0;              /* Found the user yet?          */

    int groupCount = 0;
    int length;
    char *linePtr;
    char *field;
    char *nextPtr;
    char *cptr;
    char *errMsg = NULL;            /* Temp local error message */
    FILE *fp = NULL;

    if (userName == NULL)
    {
        errMsg = "NULL user name supplied";
        rc = -2;
        goto exit;
    }

    if (readBuffer == NULL)
    {
        errMsg = "NULL read buffer supplied";
        rc = -2;
        goto exit;
    }

    if (passwordPtr != NULL)
    {
        *passwordPtr = NULL;
    }

    if (numGroups != NULL)
    {
        *numGroups = 0;
    }


    fp = fopen(fileName,"r");
    if (fp == NULL) {
        errMsg = "Cannot open specified file\n";
        rc = -2;
        goto exit;
    }


    while (foundUser == 0)
    {
        linePtr = GetNextLine(fp, readBuffer, readBufferLength);
        if (linePtr == (char*)-1)
        {
            /* Line length error */
            errMsg = "Encountered an invalid input line in file";
            rc = -2;
            goto exit;
        }
        if (linePtr == NULL)
        {
            /* We've probably reached the end of file, but make sure. */
            if (feof(fp))
            {
                /* End of file: User not found. */
                rc = -1;
            }
            else
            {
                /* Not end of file, must have encountered an error. */
                rc = -2;
                errMsg = "Unknown file error encountered";
            }
            goto exit;
        }

        field = NextField(linePtr, &nextPtr);
        if (field != NULL && strcasecmp(field, userName) == 0)
        {
            /* Found the correct user name.  Parse the line. */
            foundUser = 1;

            /* Second field is the password */
            field = NextField(nextPtr, &nextPtr);

            /* A blank password field is an error. */
            if (field == NULL)
            {
                errMsg = "No password for user";
                rc = -2;
                goto exit;
            }
            if (passwordPtr != NULL)
            {
                *passwordPtr = field;
            }

            /* If we were requested to return group information,
             * parse the rest of the line.
             */
            if (groupBuffer != NULL)
            {
                cptr = groupBuffer;

                field = NextField(nextPtr, &nextPtr);
                while (field != NULL)
                {
                    length = strlen(field);

                    if (length > 255)
                    {
                        /* Since the group list is formatted using
                         * one byte lengths, a length of more than 255
                         * bytes is an error.
                         */
                        errMsg = "group name too long";
                        rc = -2;
                        goto exit;
                    }

                    *((unsigned char*)cptr) = (unsigned char)length;
                    cptr++;

                    memcpy(cptr, field, length);
                    cptr += length;

                    groupCount++;

                    field = NextField(nextPtr, &nextPtr);
                }

                /* Write a NULL byte after the last group; a
                 * "zero length group" indicates the end of the
                 * group list in case the caller did not supply
                 * "numGroups".
                 */
                *cptr = '\0';

                if (numGroups != NULL)
                {
                    *numGroups = groupCount;
                }
            }

            rc = 0;     /* Found the user */
        }
    }

exit:
    if (fp != NULL)
    {
        fclose(fp);
    }

    if (errMsg != NULL)
    {
        char msg[256];
        snprintf(msg, 256,
                 "security plugin 'combined' encountered an error\n"
                 "User: %s\nFile: %s\nError: %s\n",
                 userName, fileName, errMsg);
        msg[255]='\0';            /* ensure NULL terminated */
        logFunc(DB2SEC_LOG_ERROR, msg, strlen(msg));

        if (errorMessage != NULL)
        {
            *errorMessage = errMsg;
        }
    }

    return(rc);
}
Exemplo n.º 8
0
/* DoesGroupExist
 * Searches the user definition file for the named group.  If
 * any user is a member of the group, DB2SEC_PLUGIN_OK is
 * returned, otherwise DB2SEC_PLUGIN_INVALIDUSERORGROUP is
 * returned.
 */
SQL_API_RC SQL_API_FN DoesGroupExist(const char *groupName,
                          db2int32 groupNameLength,
                          char **errorMessage,
                          db2int32 *errorMessageLength)
{
    int rc = DB2SEC_PLUGIN_OK;

    char localGroupName[DB2SEC_MAX_AUTHID_LENGTH + 1];
    char readBuffer[MAX_LINE_LENGTH];

    int foundGroup = 0;

    char *linePtr;
    char *field;
    char *nextPtr;
    FILE *fp = NULL;

    *errorMessage = NULL;
    *errorMessageLength = 0;

    if (groupName == NULL)
    {
        *errorMessage = "NULL group name supplied";
        rc = DB2SEC_PLUGIN_UNKNOWNERROR;
        goto exit;
    }

    /* NULL terminate the group name */
    if (groupNameLength > DB2SEC_MAX_AUTHID_LENGTH)
    {
        char msg[512];
        memcpy(localGroupName, groupName, DB2SEC_MAX_AUTHID_LENGTH);
        localGroupName[DB2SEC_MAX_AUTHID_LENGTH] = '\0';
        snprintf(msg, 512,
             "DoesGroupExist: group name too long ("FMT_S32" bytes): %s... (truncated)",
             groupNameLength, localGroupName);

        msg[511]='\0';            /* ensure NULL terminated */
        logFunc(DB2SEC_LOG_ERROR, msg, strlen(msg));

        *errorMessage = "DoesGroupExist: group name too long";
        rc = DB2SEC_PLUGIN_BADUSER;
        goto exit;
    }

    memcpy(localGroupName, groupName, groupNameLength);
    localGroupName[groupNameLength] = '\0';


    fp = fopen(getUserFileName(),"r");
    if (fp == NULL) {
        char msg[256];
        snprintf(msg, 256,
                  "DoesGroupExist: can't open file: %s",
                  getUserFileName());

        msg[255]='\0';            /* ensure NULL terminated */
        logFunc(DB2SEC_LOG_ERROR, msg, strlen(msg));

        *errorMessage = "Cannot open specified file\n";
        rc = DB2SEC_PLUGIN_UNKNOWNERROR;
        goto exit;
    }

    while (foundGroup == 0)
    {
        /* Read the next line from the user definition file */
        linePtr = GetNextLine(fp, readBuffer, sizeof(readBuffer));

        if (linePtr == (char*)-1)
        {
            /* Line length error */
            *errorMessage = "Encountered an invalid input line in file";
            rc = DB2SEC_PLUGIN_UNKNOWNERROR;
            goto exit;
        }

        if (linePtr == NULL)
        {
            /* We've probably reached the end of file, but make sure. */
            if (feof(fp))
            {
                /* End of file: Group not found. */
                rc = DB2SEC_PLUGIN_INVALIDUSERORGROUP;
            }
            else
            {
                /* Not end of file, must have encountered an error. */
                rc = DB2SEC_PLUGIN_UNKNOWNERROR;
                *errorMessage = "Unknown file error encountered";
            }
            goto exit;
        }


        field = NextField(linePtr, &nextPtr);   /* Skip user name */
        field = NextField(nextPtr, &nextPtr);   /* and password   */

        /* Examine all of the remaining fields */
        field = NextField(nextPtr, &nextPtr);
        while (field != NULL)
        {
            if (strcasecmp(field, localGroupName) == 0)
            {
                /* Found it! */
                foundGroup = 1;
                break;
            }

            field = NextField(nextPtr, &nextPtr);
        }
    }

    if (foundGroup == 1)
    {
        rc = DB2SEC_PLUGIN_OK;
    }

exit:
    if (fp != NULL)
    {
        fclose(fp);
    }

    if (*errorMessage != NULL)
    {
        *errorMessageLength = strlen(*errorMessage);
    }

    return(rc);
}
Exemplo n.º 9
0
/**
 * Read the UnicodeData.txt file.
 * @returns 0 on success.
 * @returns !0 on failure.
 * @param   pszBasePath         The base path, can be NULL.
 * @param   pszFilename         The name of the file.
 */
static int ReadUnicodeData(const char *pszBasePath, const char *pszFilename)
{
    /*
     * Open input.
     */
    FILE *pFile = OpenFile(pszBasePath, pszFilename);
    if (!pFile)
        return 1;

    /*
     * Parse the input and spit out the output.
     */
    char szLine[4096];
    RTUNICP i = 0;
    while (GetLineFromFile(szLine, sizeof(szLine), pFile) != NULL)
    {
        if (IsCommentOrBlankLine(szLine))
            continue;

        char *pszCurField;
        char *pszCodePoint = FirstField(&pszCurField, StripLine(szLine)); /* 0 */
        char *pszName = NextField(&pszCurField);                          /* 1 */
        char *pszGeneralCategory = NextField(&pszCurField);               /* 2 */
        char *pszCanonicalCombiningClass = NextField(&pszCurField);       /* 3 */
        char *pszBidiClass = NextField(&pszCurField);                     /* 4 */
        char *pszDecompositionType = NextField(&pszCurField);             /* 5 */
        char *pszDecompositionMapping = SplitDecompField(&pszDecompositionType);
        char *pszNumericType = NextField(&pszCurField);                   /* 6 */
        char *pszNumericValueD = NextField(&pszCurField);                 /* 7 */
        char *pszNumericValueN = NextField(&pszCurField);                 /* 8 */
        char *pszBidiMirrored = NextField(&pszCurField);                  /* 9 */
        char *pszUnicode1Name = NextField(&pszCurField);                  /* 10 */
        char *pszISOComment = NextField(&pszCurField);                    /* 11 */
        char *pszSimpleUpperCaseMapping = NextField(&pszCurField);        /* 12 */
        char *pszSimpleLowerCaseMapping = NextField(&pszCurField);        /* 13 */
        char *pszSimpleTitleCaseMapping = NextField(&pszCurField);        /* 14 */

        RTUNICP CodePoint = ToNum(pszCodePoint);
        if (CodePoint >= RT_ELEMENTS(g_aCPInfo))
        {
            ParseError("U+05X is out of range\n", CodePoint);
            continue;
        }

        /* catchup? */
        while (i < CodePoint)
            NullEntry(i++);
        if (i != CodePoint)
        {
            ParseError("i=%d CodePoint=%u\n", i, CodePoint);
            CloseFile(pFile);
            return 1;
        }

        /* this one */
        g_aCPInfo[i].CodePoint = i;
        g_aCPInfo[i].fNullEntry = 0;
        g_aCPInfo[i].pszName                    = DupStr(pszName);
        g_aCPInfo[i].SimpleUpperCaseMapping     = ToNumDefault(pszSimpleUpperCaseMapping, CodePoint);
        g_aCPInfo[i].SimpleLowerCaseMapping     = ToNumDefault(pszSimpleLowerCaseMapping, CodePoint);
        g_aCPInfo[i].SimpleTitleCaseMapping     = ToNumDefault(pszSimpleTitleCaseMapping, CodePoint);
        g_aCPInfo[i].CanonicalCombiningClass    = ToNum(pszCanonicalCombiningClass);
        g_aCPInfo[i].pszDecompositionType       = DupStr(pszDecompositionType);
        g_aCPInfo[i].paDecompositionMapping     = ToMapping(pszDecompositionMapping, &g_aCPInfo[i].cDecompositionMapping, 20);
        g_aCPInfo[i].pszGeneralCategory         = DupStr(pszGeneralCategory);
        g_aCPInfo[i].pszBidiClass               = DupStr(pszBidiClass);
        g_aCPInfo[i].pszNumericType             = DupStr(pszNumericType);
        g_aCPInfo[i].pszNumericValueD           = DupStr(pszNumericValueD);
        g_aCPInfo[i].pszNumericValueN           = DupStr(pszNumericValueN);
        g_aCPInfo[i].pszBidiMirrored            = DupStr(pszBidiMirrored);
        g_aCPInfo[i].pszUnicode1Name            = DupStr(pszUnicode1Name);
        g_aCPInfo[i].pszISOComment              = DupStr(pszISOComment);
        i++;
    }

    /* catchup? */
    while (i < RT_ELEMENTS(g_aCPInfo))
        NullEntry(i++);
    CloseFile(pFile);

    return 0;
}
Exemplo n.º 10
0
static size_t loaduser( void )
{
   FILE *stream;
   struct UserTable *userp;
   size_t subscript;
   char *token;

/*--------------------------------------------------------------------*/
/*     First, load in the active user as first user in the table      */
/*--------------------------------------------------------------------*/

   userp = inituser( E_mailbox );
   userp->realname = E_name;
   userp->homedir  = E_homedir;

/*--------------------------------------------------------------------*/
/*       Password file format:                                        */
/*          user id:password:::user/system name:homedir:shell         */
/*--------------------------------------------------------------------*/

   if ((stream = FOPEN(E_passwd, "r",TEXT_MODE)) == NULL)
   {
      if ( debuglevel > 2 )
         printerr( E_passwd );

      users = realloc(users, userElements *  sizeof(*users));

      checkref(users);
      return userElements;
   } /* if */

   PushDir( E_confdir );      /* Use standard reference point for     */
                              /* for directories                      */

/*--------------------------------------------------------------------*/
/*                 The password file is open; read it                 */
/*--------------------------------------------------------------------*/

   while (! feof(stream))
   {
      char buf[BUFSIZ];

      if (fgets(buf,BUFSIZ,stream) == NULL)   /* Try to read a line   */
         break;               /* Exit if end of file                  */

      if ((*buf == '#') || (*buf == '\0'))
         continue;            /* Line is a comment; loop again        */

      if ( buf[ strlen(buf) - 1 ] == '\n')
         buf[ strlen(buf) - 1 ] = '\0';

      token = NextField(buf);

      if (token    == NULL)   /* Any data?                            */
         continue;            /* No --> read another line             */

      userp = inituser(token);/* Initialize record for user           */

      if ( userp->uid == NULL )
      {
         panic();
      }

      if (userp->password != NULL)  /* Does the user already exist?   */
      {                       /* Yes --> Report and ignore            */

         printmsg(0,"loaduser: Duplicate entry for '%s' in '%s' ignored",
               token,E_passwd);
         continue;            /* System already in /etc/passwd,
                                 ignore it.                           */
      }

/*--------------------------------------------------------------------*/
/*       Password fields are funny; if the tokenize field function    */
/*       is returns NULL, we set the password to the comparable       */
/*       empty string ("").  But if the password is if asterisk       */
/*       (*), we leave the password NULL, and the user can never      */
/*       login remotely.                                              */
/*--------------------------------------------------------------------*/

      token = NextField(NULL);   /* Get the user password             */

      if ( token == NULL )       /* No password needed for login?     */
      {
         printmsg(2,"loaduser: WARNING: No password assigned for user %s",
                     userp->uid );
         userp->password = "";   /* Assign requested password        */
      }
      else if (!equal(token,"*")) /* User can login with passwd?      */
         userp->password = newstr(token); /* Yes --> Set password     */

      token = NextField(NULL);   /* Use  UNIX user number as tone     */
                                 /* to beep at                        */
      if (token != NULL)
         userp->beep = newstr( token );

      token = NextField(NULL);   /* UNIX group number                 */

      if (token != NULL)         /* Did they provide a group?         */
         userp->group = newstr(token); /* Yes --> Copy                */

      token = NextField(NULL);   /* Get the formal user name          */

      if (token != NULL)         /* Did they provide user name?       */
         userp->realname = newstr(token); /* Yes --> Copy             */

      token = NextField(NULL);   /* Get home directory (optional)     */

      if ( token != NULL)
      {
         userp->homedir = newstr(normalize( token ));
         if ( equal( userp->uid, E_mailbox ))
            E_homedir = userp->homedir;
      }

      token = NextField(NULL);   /* Get user shell (optional)         */

      if ( token != NULL )       /* Did we get it?                    */
         userp->sh = newstr(token); /* Yes --> Copy it in             */

   }  /* while */

   PopDir();

   fclose(stream);
   users = realloc(users, userElements *  sizeof(*users));
   checkref(users);

   qsort(users, userElements ,sizeof(users[0]) , usercmp);

   for (subscript = 0 ; subscript < userElements; subscript ++)
   {
      KWBoolean duplicate = KWFalse;

      if ( subscript && equali( users[subscript].uid,
                                users[subscript- 1 ].uid))
      {
         printmsg(0,"*error* The user id \"%s\" occurs more than once in %s!"
                    "  Delete extra entries!",
                     users[subscript-1].uid,
                     E_passwd );

         duplicate = KWTrue;
      }

      printmsg(duplicate ? 0: 8,
                 "loaduser: user[%d]\tlogin(%s)\tno(%s)\tgroup(%s)"
                 "\tname(%s)\thome(%s)\tshell(%s)",
         subscript,
         users[subscript].uid,
         users[subscript].beep == NULL ? "NONE" : users[subscript].beep,
         users[subscript].group,
         users[subscript].realname,
         users[subscript].homedir,
         users[subscript].sh);
   } /* for */

   return userElements;

} /* loaduser */
Exemplo n.º 11
0
int main(int argc, char **argv)
{
    register int i;
    char   *current;
    char   *next;
    char   *uid;
    char   *pw;
    int    rc;
    int    fd;
    struct stat    buff;
    char   *auid = 0;
    char   *apw = 0;
    char   *filenm = 0;
    char   *area = 0;
    RPC2_EncryptionKey	key;
    
 /* parse arguments    */
    for (i = 1; i < argc; i++) {
	if (argv[i][0] == '-') {
	    if (strcmp(argv[i], "-f") == 0) {
		filenm = argv[++i];
		continue;
	    }
	    break;
	}
	if (auid == 0) {
	    auid = argv[i];
	    continue;
	}
	if (apw == 0) {
	    apw = argv[i];
	    continue;
	}
	break;
    }

    if (!auid || !apw || !filenm) {
	printf("usage: newuser -f filename authuserid authpasswd\n");
	fflush(stdout);
	exit(-1);
    }
 /* Bind to auth server using auid and apw */

    U_InitRPC();
    memset(key, 0, sizeof(RPC2_EncryptionKey));
    strncpy(key, apw, sizeof(RPC2_EncryptionKey));
    rc = U_BindToServer(1, auid, key, &AuthID);
    if(rc != AUTH_SUCCESS) {
	printf("Bind to Auth Server failed %s\n",U_Error(rc));
	fflush(stdout);
	exit(-2);
    }

 /* open input file and read it into area malloc */
    if(stat(filenm, &buff)) {
	printf("Could not stat %s because %d\n",filenm, errno);
	fflush(stdout);
	exit(-3);
    }
    area = (char *)malloc(buff.st_size+1);
    fd = open(filenm, O_RDONLY, 0);
    if(fd <= 0) {
	printf("Could not open %s because %d\n",filenm, errno);
	fflush(stdout);
	exit(-4);
    }
    rc = read(fd, area, buff.st_size);
    if(rc != buff.st_size) {
	printf("Could nor read %s got %d bytes instead of %d, error = %d\n",
		filenm, rc, buff.st_size, errno);
	fflush(stdout);
	exit(-5);
    }
    close(fd);
    *(area+buff.st_size+1) = '\0';

 /* parse data in area and pass it to AddNewUser. The first field in each line is the
    uid, the second field in each line is the password. Fields are blank separated */

    for(current = area; current < area+buff.st_size; current = next) {
	next = NextRecord(current);	/* next line */
	uid = current;				/* use first field  */
	pw = NextField(uid);			/* use second field */
	MakeString(uid);			/* make uid a string */
	MakeString(pw);			/* make pw a string */
	AddNewUser(uid, pw);
    }

 /* clean up and Unbind the connection */
    if(area) free(area);
    RPC2_Unbind(AuthID);
    return(0);
}