int         bytesRead, fileLen=0; char        buffer[BUFF_SIZE], *asn1Buf;
SECStatus   rv;
GetBitsFromFile(char *filePath, SECItem *fileBits){    PRFileDesc *fileDesc;    int         bytesRead, fileLen=0;    char        buffer[BUFF_SIZE], *asn1Buf;    fileDesc = PR_Open(filePath, PR_RDONLY, 0644);    while (1) {        bytesRead = PR_Read(fileDesc, buffer, BUFF_SIZE);	if (bytesRead <= 0) break;	fileLen += bytesRead;    }    if (bytesRead < 0) {        printf ("Error while getting the length of file %s.\n", filePath);	goto loser;    }    PR_Close(fileDesc);        fileDesc = PR_Open(filePath, PR_RDONLY, 0644);    asn1Buf = PORT_ZNewArray(char, fileLen);    if (asn1Buf == NULL) {        printf ("Out of memory in function GetBitsFromFile\n");        goto loser;    }    bytesRead = PR_Read(fileDesc, asn1Buf, fileLen);    if (bytesRead != fileLen) {        printf ("Error while reading the contents of %s\n", filePath);	goto loser;    }    fileBits->data = (unsigned char*)asn1Buf;    fileBits->len  = fileLen;    return; loser:    if (asn1Buf) {        PORT_Free(asn1Buf);    }    fileBits->data = NULL;    fileBits->len  = 0;} 