diff --git a/mozilla/security/nss/cmd/pk11util/pk11table.c b/mozilla/security/nss/cmd/pk11util/pk11table.c index a77ab2c3296..f6686a89088 100644 --- a/mozilla/security/nss/cmd/pk11util/pk11table.c +++ b/mozilla/security/nss/cmd/pk11util/pk11table.c @@ -39,7 +39,9 @@ const char *_constTypeString[] = { "Attribute", "Mechanism", "Result", - "Trust" + "Trust", + "AvailableSizes", + "CurrentSize" }; const char **constTypeString = &_constTypeString[0]; @@ -246,10 +248,10 @@ const Constant _consts[] = { mkEntry2(CKA_NETSCAPE_DB, Attribute, None), mkEntry2(CKA_NETSCAPE_TRUST, Attribute, Trust), - mkEntry(CKM_RSA_PKCS_KEY_PAIR_GEN, Mechanism), mkEntry(CKM_RSA_PKCS, Mechanism), mkEntry(CKM_RSA_9796, Mechanism), mkEntry(CKM_RSA_X_509, Mechanism), + mkEntry(CKM_RSA_PKCS_KEY_PAIR_GEN, Mechanism), mkEntry(CKM_MD2_RSA_PKCS, Mechanism), mkEntry(CKM_MD5_RSA_PKCS, Mechanism), mkEntry(CKM_SHA1_RSA_PKCS, Mechanism), @@ -550,6 +552,9 @@ const Constant _consts[] = { mkEntry(CKT_NETSCAPE_TRUST_UNKNOWN, Trust), mkEntry(CKT_NETSCAPE_VALID, Trust), mkEntry(CKT_NETSCAPE_VALID_DELEGATOR, Trust), + + mkEntry(CK_EFFECTIVELY_INFINITE, AvailableSizes), + mkEntry(CK_UNAVAILABLE_INFORMATION, CurrentSize), }; const Constant *consts = &_consts[0]; @@ -557,257 +562,690 @@ const int constCount = sizeof(_consts)/sizeof(_consts[0]); const Commands _commands[] = { {"C_Initialize", F_C_Initialize, +"C_Initialize pInitArgs\n\n" +"C_Initialize initializes the PKCS #11 library.\n" +" pInitArgs if this is not NULL_PTR it gets\n" +" cast to \n" +" and dereferenced\n", {ArgInitializeArgs, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_Finalize", F_C_Finalize, +"C_Finalize pReserved \n\n" +"C_Finalize indicates that an application is done with the PKCS #11 library.\n" +" pReserved reserved. Should be NULL_PTR\n", {ArgInitializeArgs, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_GetInfo", F_C_GetInfo, +"C_GetInfo pInfo\n\n" +"C_GetInfo returns general information about PKCS #11.\n" +" pInfo location that receives information\n", {ArgInfo|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_GetFunctionList", F_C_GetFunctionList, +"C_GetFunctionList ppFunctionList \n\n" +"C_GetFunctionList returns the function list.\n" +" ppFunctionList receives pointer to\n" +" function list\n", {ArgFunctionList|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_GetSlotList", F_C_GetSlotList, +"C_GetSlotList tokenPresent pSlotList pulCount \n\n" +"C_GetSlotList obtains a list of slots in the system.\n" +" tokenPresent only slots with tokens?\n" +" pSlotList receives array of slot IDs\n" +" pulCount receives number of slots\n", {ArgULong, ArgULong|ArgArray|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_GetSlotInfo", F_C_GetSlotInfo, +"C_GetSlotInfo slotID pInfo\n\n" +"C_GetSlotInfo obtains information about a particular slot in the system.\n" +" slotID the ID of the slot\n" +" pInfo receives the slot information\n", {ArgULong, ArgSlotInfo|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_GetTokenInfo", F_C_GetTokenInfo, +"C_GetTokenInfo slotID pInfo\n\n" +"C_GetTokenInfo obtains information about a particular token in the system.\n" +" slotID ID of the token's slot\n" +" pInfo receives the token information\n", {ArgULong, ArgTokenInfo|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_GetMechanismList", F_C_GetMechanismList, +"C_GetMechanismList slotID pMechanismList pulCount\n\n" +"C_GetMechanismList obtains a list of mechanism types supported by a token.\n" +" slotID ID of token's slot\n" +" pMechanismList gets mech. array\n" +" pulCount gets # of mechs.\n", {ArgULong, ArgULong|ArgArray|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_GetMechanismInfo", F_C_GetMechanismInfo, +"C_GetMechanismInfo slotID type pInfo\n\n" +"C_GetMechanismInfo obtains information about a particular mechanism possibly supported by a token.\n" +" slotID ID of the token's slot\n" +" type type of mechanism\n" +" pInfo receives mechanism info\n", {ArgULong, ArgULong, ArgMechanismInfo|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_InitToken", F_C_InitToken, +"C_InitToken slotID pPin ulPinLen pLabel\n\n" +"C_InitToken initializes a token.\n" +" slotID ID of the token's slot\n" +" pPin the SO's initial PIN\n" +" ulPinLen length in bytes of the PIN\n" +" pLabel 32-byte token label (blank padded)\n", {ArgULong, ArgUTF8, ArgULong, ArgUTF8, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_InitPIN", F_C_InitPIN, +"C_InitPIN hSession pPin ulPinLen\n\n" +"C_InitPIN initializes the normal user's PIN.\n" +" hSession the session's handle\n" +" pPin the normal user's PIN\n" +" ulPinLen length in bytes of the PIN\n", {ArgULong, ArgUTF8, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_SetPIN", F_C_SetPIN, +"C_SetPIN hSession pOldPin ulOldLen pNewPin ulNewLen\n\n" +"C_SetPIN modifies the PIN of the user who is logged in.\n" +" hSession the session's handle\n" +" pOldPin the old PIN\n" +" ulOldLen length of the old PIN\n" +" pNewPin the new PIN\n" +" ulNewLen length of the new PIN\n", {ArgULong, ArgUTF8, ArgULong, ArgUTF8, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_OpenSession", F_C_OpenSession, +"C_OpenSession slotID flags phSession\n\n" +"C_OpenSession opens a session between an application and a token.\n" +" slotID the slot's ID\n" +" flags from \n" +" phSession gets session handle\n", {ArgULong, ArgULong, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_CloseSession", F_C_CloseSession, +"C_CloseSession hSession\n\n" +"C_CloseSession closes a session between an application and a token.\n" +" hSession the session's handle\n", {ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_CloseAllSessions", F_C_CloseAllSessions, +"C_CloseAllSessions slotID\n\n" +"C_CloseAllSessions closes all sessions with a token.\n" +" slotID the token's slot\n", {ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_GetSessionInfo", F_C_GetSessionInfo, +"C_GetSessionInfo hSession pInfo\n\n" +"C_GetSessionInfo obtains information about the session.\n" +" hSession the session's handle\n" +" pInfo receives session info\n", {ArgULong, ArgSessionInfo|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_GetOperationState", F_C_GetOperationState, +"C_GetOperationState hSession pOpState pulOpStateLen\n\n" +"C_GetOperationState obtains the state of the cryptographic operation in a session.\n" +" hSession session's handle\n" +" pOpState gets state\n" +" pulOpStateLen gets state length\n", {ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_SetOperationState", F_C_SetOperationState, +"C_SetOperationState hSession pOpState ulOpStateLen hEncKey hAuthKey\n\n" +"C_SetOperationState restores the state of the cryptographic operation in a session.\n" +" hSession session's handle\n" +" pOpState holds state\n" +" ulOpStateLen holds state length\n" +" hEncKey en/decryption key\n" +" hAuthnKey sign/verify key\n", {ArgULong, ArgChar|ArgOut, ArgULong, ArgULong, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_Login", F_C_Login, +"C_Login hSession userType pPin ulPinLen\n\n" +"C_Login logs a user into a token.\n" +" hSession the session's handle\n" +" userType the user type\n" +" pPin the user's PIN\n" +" ulPinLen the length of the PIN\n", {ArgULong, ArgULong, ArgVar, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_Logout", F_C_Logout, +"C_Logout hSession\n\n" +"C_Logout logs a user out from a token.\n" +" hSession the session's handle\n", {ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_CreateObject", F_C_CreateObject, +"C_CreateObject hSession pTemplate ulCount phObject\n\n" +"C_CreateObject creates a new object.\n" +" hSession the session's handle\n" +" pTemplate the object's template\n" +" ulCount attributes in template\n" +" phObject gets new object's handle.\n", {ArgULong, ArgAttribute|ArgArray, ArgULong, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_CopyObject", F_C_CopyObject, +"C_CopyObject hSession hObject pTemplate ulCount phNewObject\n\n" +"C_CopyObject copies an object creating a new object for the copy.\n" +" hSession the session's handle\n" +" hObject the object's handle\n" +" pTemplate template for new object\n" +" ulCount attributes in template\n" +" phNewObject receives handle of copy\n", {ArgULong, ArgULong, ArgAttribute|ArgArray, ArgULong, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_DestroyObject", F_C_DestroyObject, +"C_DestroyObject hSession hObject\n\n" +"C_DestroyObject destroys an object.\n" +" hSession the session's handle\n" +" hObject the object's handle\n", {ArgULong, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_GetObjectSize", F_C_GetObjectSize, +"C_GetObjectSize hSession hObject pulSize\n\n" +"C_GetObjectSize gets the size of an object in bytes.\n" +" hSession the session's handle\n" +" hObject the object's handle\n" +" pulSize receives size of object\n", {ArgULong, ArgULong, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_GetAttributeValue", F_C_GetAttributeValue, +"C_GetAttributeValue hSession hObject pTemplate ulCount\n\n" +"C_GetAttributeValue obtains the value of one or more object attributes.\n" +" hSession the session's handle\n" +" hObject the object's handle\n" +" pTemplate specifies attrs; gets vals\n" +" ulCount attributes in template\n", {ArgULong, ArgULong, ArgAttribute|ArgArray, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_SetAttributeValue", F_C_SetAttributeValue, +"C_SetAttributeValue hSession hObject pTemplate ulCount\n\n" +"C_SetAttributeValue modifies the value of one or more object attributes\n" +" hSession the session's handle\n" +" hObject the object's handle\n" +" pTemplate specifies attrs and values\n" +" ulCount attributes in template\n", {ArgULong, ArgULong, ArgAttribute|ArgArray, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_FindObjectsInit", F_C_FindObjectsInit, +"C_FindObjectsInit hSession pTemplate ulCount\n\n" +"C_FindObjectsInit initializes a search for token and session objects that match a template.\n" +" hSession the session's handle\n" +" pTemplate attribute values to match\n" +" ulCount attrs in search template\n", {ArgULong, ArgAttribute|ArgArray, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_FindObjectsFinal", F_C_FindObjectsFinal, +"C_FindObjectsFinal hSession\n\n" +"C_FindObjectsFinal finishes a search for token and session objects.\n" +" hSession the session's handle\n", {ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_FindObjects", F_C_FindObjects, +"C_FindObjects hSession phObject ulMaxObjectCount pulObjectCount\n\n" +"C_FindObjects continues a search for token and session objects that match a template obtaining additional object handles.\n" +" hSession session's handle\n" +" phObject gets obj. handles\n" +" ulMaxObjectCount max handles to get\n" +" pulObjectCount actual # returned\n", {ArgULong, ArgULong|ArgOut, ArgULong, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_EncryptInit", F_C_EncryptInit, +"C_EncryptInit hSession pMechanism hKey\n\n" +"C_EncryptInit initializes an encryption operation.\n" +" hSession the session's handle\n" +" pMechanism the encryption mechanism\n" +" hKey handle of encryption key\n", {ArgULong, ArgMechanism, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_EncryptUpdate", F_C_EncryptUpdate, +"C_EncryptUpdate hSession pPart ulPartLen pEncryptedPart pulEncryptedPartLen\n\n" +"C_EncryptUpdate continues a multiple-part encryption operation.\n" +" hSession session's handle\n" +" pPart the plaintext data\n" +" ulPartLen plaintext data len\n" +" pEncryptedPart gets ciphertext\n" +" pulEncryptedPartLen gets c-text size\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_EncryptFinal", F_C_EncryptFinal, +"C_EncryptFinal hSession pLastEncryptedPart pulLastEncryptedPartLen\n\n" +"C_EncryptFinal finishes a multiple-part encryption operation.\n" +" hSession session handle\n" +" pLastEncryptedPart last c-text\n" +" pulLastEncryptedPartLen gets last size\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_Encrypt", F_C_Encrypt, +"C_Encrypt hSession pData ulDataLen pEncryptedData pulEncryptedDataLen\n\n" +"C_Encrypt encrypts single-part data.\n" +" hSession session's handle\n" +" pData the plaintext data\n" +" ulDataLen bytes of plaintext\n" +" pEncryptedData gets ciphertext\n" +" pulEncryptedDataLen gets c-text size\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_DecryptInit", F_C_DecryptInit, +"C_DecryptInit hSession pMechanism hKey\n\n" +"C_DecryptInit initializes a decryption operation.\n" +" hSession the session's handle\n" +" pMechanism the decryption mechanism\n" +" hKey handle of decryption key\n", {ArgULong, ArgMechanism, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_DecryptUpdate", F_C_DecryptUpdate, +"C_DecryptUpdate hSession pEncryptedPart ulEncryptedPartLen pPart pulPartLen\n\n" +"C_DecryptUpdate continues a multiple-part decryption operation.\n" +" hSession session's handle\n" +" pEncryptedPart encrypted data\n" +" ulEncryptedPartLen input length\n" +" pPart gets plaintext\n" +" pulPartLen p-text size\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_DecryptFinal", F_C_DecryptFinal, +"C_DecryptFinal hSession pLastPart pulLastPartLen\n\n" +"C_DecryptFinal finishes a multiple-part decryption operation.\n" +" hSession the session's handle\n" +" pLastPart gets plaintext\n" +" pulLastPartLen p-text size\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_Decrypt", F_C_Decrypt, +"C_Decrypt hSession pEncryptedData ulEncryptedDataLen pData pulDataLen\n\n" +"C_Decrypt decrypts encrypted data in a single part.\n" +" hSession session's handle\n" +" pEncryptedData ciphertext\n" +" ulEncryptedDataLen ciphertext length\n" +" pData gets plaintext\n" +" pulDataLen gets p-text size\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_DigestInit", F_C_DigestInit, +"C_DigestInit hSession pMechanism\n\n" +"C_DigestInit initializes a message-digesting operation.\n" +" hSession the session's handle\n" +" pMechanism the digesting mechanism\n", {ArgULong, ArgMechanism, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_DigestUpdate", F_C_DigestUpdate, +"C_DigestUpdate hSession pPart ulPartLen\n\n" +"C_DigestUpdate continues a multiple-part message-digesting operation.\n" +" hSession the session's handle\n" +" pPart data to be digested\n" +" ulPartLen bytes of data to be digested\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_DigestKey", F_C_DigestKey, +"C_DigestKey hSession hKey\n\n" +"C_DigestKey continues a multi-part message-digesting operation by digesting the value of a secret key as part of the data already digested.\n" +" hSession the session's handle\n" +" hKey secret key to digest\n", {ArgULong, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_DigestFinal", F_C_DigestFinal, +"C_DigestFinal hSession pDigest pulDigestLen\n\n" +"C_DigestFinal finishes a multiple-part message-digesting operation.\n" +" hSession the session's handle\n" +" pDigest gets the message digest\n" +" pulDigestLen gets byte count of digest\n", {ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_Digest", F_C_Digest, +"C_Digest hSession pData ulDataLen pDigest pulDigestLen\n\n" +"C_Digest digests data in a single part.\n" +" hSession the session's handle\n" +" pData data to be digested\n" +" ulDataLen bytes of data to digest\n" +" pDigest gets the message digest\n" +" pulDigestLen gets digest length\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_SignInit", F_C_SignInit, +"C_SignInit hSession pMechanism hKey \n\n" +"C_SignInit initializes a signature (private key encryption operation where the signature is (will be) an appendix to the data and plaintext cannot be recovered from the signature.\n" +" hSession the session's handle\n" +" pMechanism the signature mechanism\n" +" hKey handle of signature key\n", {ArgULong, ArgMechanism, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_SignUpdate", F_C_SignUpdate, +"C_SignUpdate hSession pPart ulPartLen\n\n" +"C_SignUpdate continues a multiple-part signature operation where the signature is (will be) an appendix to the data and plaintext cannot be recovered from the signature.\n" +" hSession the session's handle\n" +" pPart the data to sign\n" +" ulPartLen count of bytes to sign\n", {ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_SignFinal", F_C_SignFinal, +"C_SignFinal hSession pSignature pulSignatureLen\n\n" +"C_SignFinal finishes a multiple-part signature operation returning the signature.\n" +" hSession the session's handle\n" +" pSignature gets the signature\n" +" pulSignatureLen gets signature length\n", {ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_SignRecoverInit", F_C_SignRecoverInit, +"C_SignRecoverInit hSession pMechanism hKey\n\n" +"C_SignRecoverInit initializes a signature operation where the data can be recovered from the signature.\n" +" hSession the session's handle\n" +" pMechanism the signature mechanism\n" +" hKey handle of the signature key\n", {ArgULong, ArgMechanism, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_SignRecover", F_C_SignRecover, +"C_SignRecover hSession pData ulDataLen pSignature pulSignatureLen\n\n" +"C_SignRecover signs data in a single operation where the data can be recovered from the signature.\n" +" hSession the session's handle\n" +" pData the data to sign\n" +" ulDataLen count of bytes to sign\n" +" pSignature gets the signature\n" +" pulSignatureLen gets signature length\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_Sign", F_C_Sign, +"C_Sign hSession pData ulDataLen pSignature pulSignatureLen\n\n" +"C_Sign signs (encrypts with private key) data in a single part where the signature is (will be) an appendix to the data and plaintext cannot be recovered from the signature.\n" +" hSession the session's handle\n" +" pData the data to sign\n" +" ulDataLen count of bytes to sign\n" +" pSignature gets the signature\n" +" pulSignatureLen gets signature length\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_VerifyInit", F_C_VerifyInit, +"C_VerifyInit hSession pMechanism hKey\n\n" +"C_VerifyInit initializes a verification operation where the signature is an appendix to the data and plaintext cannot cannot be recovered from the signature (e.g. DSA).\n" +" hSession the session's handle\n" +" pMechanism the verification mechanism\n" +" hKey verification key \n", {ArgULong, ArgMechanism, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_VerifyUpdate", F_C_VerifyUpdate, +"C_VerifyUpdate hSession pPart ulPartLen\n\n" +"C_VerifyUpdate continues a multiple-part verification operation where the signature is an appendix to the data and plaintext cannot be recovered from the signature.\n" +" hSession the session's handle\n" +" pPart signed data\n" +" ulPartLen length of signed data\n", {ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_VerifyFinal", F_C_VerifyFinal, +"C_VerifyFinal hSession pSignature ulSignatureLen\n\n" +"C_VerifyFinal finishes a multiple-part verification operation checking the signature.\n" +" hSession the session's handle\n" +" pSignature signature to verify\n" +" ulSignatureLen signature length\n", {ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_VerifyRecoverInit", F_C_VerifyRecoverInit, +"C_VerifyRecoverInit hSession pMechanism hKey\n\n" +"C_VerifyRecoverInit initializes a signature verification operation where the data is recovered from the signature.\n" +" hSession the session's handle\n" +" pMechanism the verification mechanism\n" +" hKey verification key\n", {ArgULong, ArgMechanism, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_VerifyRecover", F_C_VerifyRecover, +"C_VerifyRecover hSession pSignature ulSignatureLen pData pulDataLen\n\n" +"C_VerifyRecover verifies a signature in a single-part operation where the data is recovered from the signature.\n" +" hSession the session's handle\n" +" pSignature signature to verify\n" +" ulSignatureLen signature length\n" +" pData gets signed data\n" +" pulDataLen gets signed data len\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_Verify", F_C_Verify, +"C_Verify hSession pData ulDataLen pSignature ulSignatureLen\n\n" +"C_Verify verifies a signature in a single-part operation where the signature is an appendix to the data and plaintext cannot be recovered from the signature.\n" +" hSession the session's handle\n" +" pData signed data\n" +" ulDataLen length of signed data\n" +" pSignature signature\n" +" ulSignatureLen signature length*/\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_DigestEncryptUpdate", F_C_DigestEncryptUpdate, +"C_DigestEncryptUpdate hSession pPart ulPartLen pEncryptedPart pulEncryptedPartLen\n\n" +"C_DigestEncryptUpdate continues a multiple-part digesting and encryption operation.\n" +" hSession session's handle\n" +" pPart the plaintext data\n" +" ulPartLen plaintext length\n" +" pEncryptedPart gets ciphertext\n" +" pulEncryptedPartLen gets c-text length\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_DecryptDigestUpdate", F_C_DecryptDigestUpdate, +"C_DecryptDigestUpdate hSession pEncryptedPart ulEncryptedPartLen pPart pulPartLen\n\n" +"C_DecryptDigestUpdate continues a multiple-part decryption and digesting operation.\n" +" hSession session's handle\n" +" pEncryptedPart ciphertext\n" +" ulEncryptedPartLen ciphertext length\n" +" pPart gets plaintext\n" +" pulPartLen gets plaintext len\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_SignEncryptUpdate", F_C_SignEncryptUpdate, +"C_SignEncryptUpdate hSession pPart ulPartLen pEncryptedPart pulEncryptedPartLen\n\n" +"C_SignEncryptUpdate continues a multiple-part signing and encryption operation.\n" +" hSession session's handle\n" +" pPart the plaintext data\n" +" ulPartLen plaintext length\n" +" pEncryptedPart gets ciphertext\n" +" pulEncryptedPartLen gets c-text length\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_DecryptVerifyUpdate", F_C_DecryptVerifyUpdate, +"C_DecryptVerifyUpdate hSession pEncryptedPart ulEncryptedPartLen pPart pulPartLen\n\n" +"C_DecryptVerifyUpdate continues a multiple-part decryption and verify operation.\n" +" hSession session's handle\n" +" pEncryptedPart ciphertext\n" +" ulEncryptedPartLen ciphertext length\n" +" pPart gets plaintext\n" +" pulPartLen gets p-text length\n", {ArgULong, ArgChar, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_GenerateKeyPair", F_C_GenerateKeyPair, +"C_GenerateKeyPair hSession pMechanism pPublicKeyTemplate ulPublicKeyAttributeCount pPrivateKeyTemplate ulPrivateKeyAttributeCount phPublicKey phPrivateKey \n\n" +"C_GenerateKeyPair generates a public-key/private-key pair creating new key objects.\n" +" hSession sessionhandle\n" +" pMechanism key-genmech.\n" +" pPublicKeyTemplate templatefor pub. key\n" +" ulPublicKeyAttributeCount # pub. attrs.\n" +" pPrivateKeyTemplate templatefor priv. key\n" +" ulPrivateKeyAttributeCount # priv. attrs.\n" +" phPublicKey gets pub. keyhandle\n" +" phPrivateKey getspriv. keyhandle\n", {ArgULong, ArgMechanism, ArgAttribute|ArgArray, ArgULong, ArgAttribute|ArgArray, ArgULong, ArgULong|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone }}, {"C_GenerateKey", F_C_GenerateKey, +"C_GenerateKey hSession pMechanism pTemplate ulCount phKey \n\n" +"C_GenerateKey generates a secret key creating a new key object.\n" +" hSession the session's handle\n" +" pMechanism key generation mech.\n" +" pTemplate template for new key\n" +" ulCount # of attrs in template\n" +" phKey gets handle of new key\n", {ArgULong, ArgMechanism, ArgAttribute|ArgArray, ArgULong, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_WrapKey", F_C_WrapKey, +"C_WrapKey hSession pMechanism hWrappingKey hKey pWrappedKey pulWrappedKeyLen\n\n" +"C_WrapKey wraps (i.e. encrypts) a key.\n" +" hSession the session's handle\n" +" pMechanism the wrapping mechanism\n" +" hWrappingKey wrapping key\n" +" hKey key to be wrapped\n" +" pWrappedKey gets wrapped key\n" +" pulWrappedKeyLen gets wrapped key size\n", {ArgULong, ArgMechanism, ArgULong, ArgULong, ArgULong, ArgChar|ArgOut, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone }}, {"C_UnwrapKey", F_C_UnwrapKey, +"C_UnwrapKey hSession pMechanism hUnwrappingKey pWrappedKey ulWrappedKeyLen pTemplate ulAttributeCount phKey\n\n" +"C_UnwrapKey unwraps (decrypts) a wrapped key creating a new key object.\n" +" hSession session's handle\n" +" pMechanism unwrapping mech.\n" +" hUnwrappingKey unwrapping key\n" +" pWrappedKey the wrapped key\n" +" ulWrappedKeyLen wrapped key len\n" +" pTemplate new key template\n" +" ulAttributeCount template length\n" +" phKey gets new handle\n", {ArgULong, ArgMechanism, ArgULong, ArgChar, ArgULong, ArgAttribute|ArgArray, ArgULong, ArgULong|ArgOut, ArgNone, ArgNone }}, {"C_DeriveKey", F_C_DeriveKey, +"C_DeriveKey hSession pMechanism hBaseKey pTemplate ulAttributeCount phKey\n\n" +"C_DeriveKey derives a key from a base key creating a new key object.\n" +" hSession session's handle\n" +" pMechanism key deriv. mech.\n" +" hBaseKey base key\n" +" pTemplate new key template\n" +" ulAttributeCount template length\n" +" phKey gets new handle\n", {ArgULong, ArgMechanism, ArgULong, ArgAttribute|ArgArray, ArgULong, ArgULong|ArgOut, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_SeedRandom", F_C_SeedRandom, +"C_SeedRandom hSession pSeed ulSeedLen\n\n" +"C_SeedRandom mixes additional seed material into the token's random number generator.\n" +" hSession the session's handle\n" +" pSeed the seed material\n" +" ulSeedLen length of seed material\n", {ArgULong, ArgChar, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_GenerateRandom", F_C_GenerateRandom, +"C_GenerateRandom hSession RandomData ulRandomLen\n\n" +"C_GenerateRandom generates random data.\n" +" hSession the session's handle\n" +" RandomData receives the random data\n" +" ulRandomLen # of bytes to generate\n", {ArgULong, ArgChar, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_GetFunctionStatus", F_C_GetFunctionStatus, +"C_GetFunctionStatus hSession\n\n" +"C_GetFunctionStatus is a legacy function; it obtains an updated status of a function running in parallel with an application.\n" +" hSession the session's handle\n", {ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_CancelFunction", F_C_CancelFunction, +"C_CancelFunction hSession\n\n" +"C_CancelFunction is a legacy function; it cancels a function running in parallel.\n" +" hSession the session's handle\n", {ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"C_WaitForSlotEvent", F_C_WaitForSlotEvent, +"C_WaitForSlotEvent flags pSlot pRserved \n\n" +"C_WaitForSlotEvent waits for a slot event (token insertion removal etc.) to occur.\n" +" flags blocking/nonblocking flag\n" +" pSlot location that receives the slot ID\n" +" pRserved reserved. Should be NULL_PTR\n", {ArgULong, ArgULong|ArgArray, ArgVar, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"NewArray", F_NewArray, +"NewArray varName varType array size\n\n" +"Creates a new array variable.\n" +" varName variable name of the new array\n" +" varType data type of the new array\n" +" size number of elements in the array\n", {ArgVar|ArgNew, ArgVar, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"NewTemplate", F_NewTemplate, +"NewTemplate varName attributeList\n\n" +"Create a new empty template and populate the attribute list\n" +" varName variable name of the new template\n" +" attributeList comma separated list of CKA_ATTRIBUTE types\n", {ArgVar|ArgNew, ArgVar, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"NewMechanism", F_NewMechanism, +"NewMechanism varName mechanismType\n\n" +"Create a new CK_MECHANISM object with type NULL paramters and specified type\n" +" varName variable name of the new mechansim\n" +" mechanismType CKM_ mechanism type value to set int the type field\n", {ArgMechanism|ArgOut, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"BuildTemplate", F_BuildTemplate, +"BuildTemplate template\n\n" +"Allocates space for the value in a template which has the sizes filled in, but no values allocated yet.\n" +" template variable name of the template\n", {ArgAttribute, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"SetTemplate", F_SetTemplate, +"SetTemplate template index value\n\n" +"Sets a particular element of a template to a CK_ULONG\n" +" template variable name of the template\n" +" index index into the template to the element to change\n" +" value 32 bit value to set in the template\n", {ArgAttribute, ArgULong, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, + {"SetString", F_SetStringVar, +"SetString varName string\n\n" +"Sets a particular variable to a string value\n" +" variable variable name of new string\n" +" string String to set the variable to\n", + {ArgVar|ArgNew, ArgVar, ArgNone, ArgNone, ArgNone, + ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"Set", F_SetVar, +"Set varName value\n\n" +"Sets a particular variable to CK_ULONG\n" +" variable name of the new variable\n" +" value 32 bit value to set variable to\n", {ArgVar|ArgNew, ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"Print", F_Print, +"Print varName\n\n" +"prints a variable\n" +" variable name of the variable to print\n", {ArgVar, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"Delete", F_Delete, +"Delete varName\n\n" +"delete a variable\n" +" variable name of the variable to delete\n", {ArgVar|ArgNew, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"Load", F_Load, +"load libraryName\n\n" +"load a pkcs #11 module\n" +" libraryName Name of a shared library\n", {ArgVar, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"Save", F_SaveVar, +"Save filename variable\n\n" +"Saves the binary value of 'variable' in file 'filename'\n" +" fileName target file to save the variable in\n" +" variable variable to save\n", {ArgVar|ArgNew, ArgVar, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"Restore", F_RestoreVar, +"Restore filename variable\n\n" +"Restors a variable from a file\n" +" fileName target file to restore the variable from\n" +" variable variable to restore\n", {ArgVar|ArgNew, ArgVar, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"List", F_List, +"List all the variables\n", {ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"Unload", F_Unload, +"Unload the currrently loaded PKCS #11 library\n", {ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"Run", F_Run, +"Run filename\n\n" +"reads filename as script of commands to execute\n", {ArgVar|ArgNew, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"System", F_System, + "Fix Me... ", {ArgULong, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, + {"Help", F_Help, +"Help [command]\n\n" +"print general help, or help for a specific command\n", + {ArgVar|ArgOpt, ArgNone, ArgNone, ArgNone, ArgNone, + ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, {"Quit", F_Quit, +"Exit from this program", {ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone, ArgNone }}, }; diff --git a/mozilla/security/nss/cmd/pk11util/pk11util.c b/mozilla/security/nss/cmd/pk11util/pk11util.c index e7709820245..2bfcee4dce8 100644 --- a/mozilla/security/nss/cmd/pk11util/pk11util.c +++ b/mozilla/security/nss/cmd/pk11util/pk11util.c @@ -39,6 +39,7 @@ #undef __STDC__ #include "fcntl.h" #include "io.h" +#include #else #include #include @@ -66,9 +67,59 @@ CK_ULONG systemFlags; #define FLAG_VerifyFile 0x00000002 int ArgSize(ArgType type); -char *constLookup(char *bp, CK_ULONG *value, ConstType *type); +const char *constLookup(const char *bp, CK_ULONG *value, ConstType *type); + +int +isNum(char c) +{ + return (c >= '0' && c <= '9'); +} + +int +isConst(const char *c) +{ + CK_ULONG value; + ConstType type; + + constLookup(c, &value, &type); + return type != ConstNone; +} + +/* + * see if the variable is really a 'size' function. This + * function may modify var if it is a size function. + */ +char * +isSize(char *var, int *isArray) +{ + char *ptr = NULL; + char *end; + int array = 0; + + if (PL_strncasecmp(var,"sizeof(",/*)*/ 7) == 0) { + ptr = var + 7; + } else if (PL_strncasecmp(var,"size(",/*)*/ 5) == 0) { + ptr = var + 5; + } else if (PL_strncasecmp(var,"sizeofarray(",/*)*/ 12) == 0) { + ptr = var + 12; + array = 1; + } else if (PL_strncasecmp(var,"sizea(",/*)*/ 6) == 0) { + ptr = var + 6; + array = 1; + } else { + return NULL; + } + end = strchr(ptr,/*(*/ ')') ; + if (end == NULL) { + return NULL; + } + if (isArray) *isArray = array; + *end = 0; + return ptr; +} -void printConst(CK_ULONG value, ConstType type, int newLine) +void +printConst(CK_ULONG value, ConstType type, int newLine) { int i; @@ -83,14 +134,19 @@ void printConst(CK_ULONG value, ConstType type, int newLine) } } if (i == constCount) { - printf("Unknown %s (%lu:0x%lx)",constTypeString[type],value,value); + if ((type == ConstAvailableSizes) || (type == ConstCurrentSize)) { + printf("%lu",value); + } else { + printf("Unknown %s (%lu:0x%lx)",constTypeString[type],value,value); + } } if (newLine) { printf("\n"); } } -ConstType getConstFromAttribute(CK_ATTRIBUTE_TYPE type) +ConstType +getConstFromAttribute(CK_ATTRIBUTE_TYPE type) { int i; @@ -102,7 +158,8 @@ ConstType getConstFromAttribute(CK_ATTRIBUTE_TYPE type) return ConstNone; } -void printChars(char *name, CK_ULONG size) +void +printChars(const char *name, CK_ULONG size) { CK_ULONG i; for (i=0; i < size; i++) { @@ -115,7 +172,7 @@ void printChars(char *name, CK_ULONG size) } #define DUMP_LEN 16 -void printDump(unsigned char *buf, int size) +void printDump(const unsigned char *buf, int size) { int i,j; @@ -146,7 +203,26 @@ void printDump(unsigned char *buf, int size) /* * free an argument structure */ -void argFree(Value *arg) +void +argFreeData(Value *arg) +{ + if (arg->data && ((arg->type & ArgStatic) == 0)) { + if ((arg->type & ArgMask) == ArgAttribute) { + int i; + CK_ATTRIBUTE *template = (CK_ATTRIBUTE *)arg->data; + + for (i=0; i < arg->arraySize; i++) { + free(template[i].pValue); + } + } + free(arg->data); + } + arg->type &= ~ArgStatic; + arg->data = NULL; +} + +void +argFree(Value *arg) { if (arg == NULL) return; @@ -155,17 +231,7 @@ void argFree(Value *arg) if (arg->type & ArgFile) { free(arg->filename); } - if (arg->data) { - if ((arg->type & ArgMask) == ArgAttribute) { - int i; - CK_ATTRIBUTE *template = (CK_ATTRIBUTE *)arg->data; - - for (i=0; i < arg->arraySize; i++) { - free(template[i].pValue); - } - } - free(arg->data); - } + argFreeData(arg); free (arg); } } @@ -173,7 +239,8 @@ void argFree(Value *arg) /* * free and argument list */ -void parseFree(Value **ap) +void +parseFree(Value **ap) { int i; for (i=0 ; i < MAX_ARGS; i++) { @@ -184,7 +251,8 @@ void parseFree(Value **ap) /* * getEnd: how for to the end of this argmument list? */ -int getEnd(char *bp) +int +getEnd(const char *bp) { int count = 0; @@ -200,7 +268,8 @@ int getEnd(char *bp) /* * strip: return the first none white space character */ -char *strip(char *bp) +const char * +strip(const char *bp) { while (*bp && (*bp == ' ' || *bp == '\t' || *bp == '\n')) bp++; return bp; @@ -209,9 +278,10 @@ char *strip(char *bp) /* * read in the next argument into dp ... don't overflow */ -char *readChars(char *bp, char *dp, int max ) +const char * +readChars(const char *bp, char *dp, int max ) { - int count = 0; + int count = 1; while (*bp) { if (*bp == ' ' || *bp == '\t' || *bp == '\n' ) { *dp = 0; @@ -225,62 +295,36 @@ char *readChars(char *bp, char *dp, int max ) return (bp); } -/* - * look up a variable from the variable chain - */ -static Variable *varHead = NULL; -Value * varLookup(char *bp, char *vname, int max) { - Variable *current; - bp = readChars(bp, vname, max); +Value * varLookup(const char *bp, char *vname, int max, int *error); - for (current = varHead; current; current = current->next) { - if (PL_strcasecmp(current->vname, vname) == 0) { - return current->value; - } - } - return NULL; -} - -static CK_RV list(void) +CK_ULONG +getValue(const char *v, int *error) { - Variable *current; + Value * varVal = NULL; + CK_ULONG retVal = 0; + ConstType type; + char tvar[512]; - if (varHead) { - printf(" %10s\t%16s\t%8s\tSize\tElements\n","Name","Type","Const"); - } else { - printf(" no variables set\n"); - } + *error = 0; - for (current = varHead; current; current = current->next) { - printf(" %10s\t%16s\t%8s\t%d\t%d\n", current->vname, - valueString[current->value->type&ArgMask], - constTypeString[current->value->constType], - current->value->size, current->value->arraySize); - } - return CKR_OK; -} + varVal = varLookup( v, tvar, sizeof(tvar), error); -CK_RV printFlags(char *s, CK_ULONG flags, ConstType type) -{ - CK_ULONG i; - int needComma = 0; - - printf("%s",s); - for (i=1; i ; i=i << 1) { - if (flags & i) { - printf("%s",needComma?",":""); - printConst(i, type, 0); - needComma=1; + if (varVal) { + if ((varVal->type & ArgMask) == ArgULong) { + retVal = *(CK_ULONG *)varVal->data; + } else { + fprintf(stderr,"%s: is not a ulong\n", v); + *error = 1; } + argFree(varVal); + return retVal; } - if (!needComma) { - printf("Empty"); - } - printf("\n"); - return CKR_OK; + constLookup(v, &retVal, &type); + return retVal; } -Value *NewValue(ArgType type, CK_ULONG arraySize) +Value * +NewValue(ArgType type, CK_ULONG arraySize) { Value *value; @@ -302,25 +346,237 @@ Value *NewValue(ArgType type, CK_ULONG arraySize) return value; } +#define INVALID_INDEX 0xffffffff + +CK_ULONG +handleArray(char *vname, int *error) +{ + char *bracket; + CK_ULONG index = INVALID_INDEX; + + if ((bracket = strchr(vname,'[')) != 0) { + char *tmpv = bracket+1; + *bracket = 0; + bracket = strchr(tmpv,']'); + + if (bracket == 0) { + fprintf(stderr,"%s: missing closing brace\n", vname); + return INVALID_INDEX; + } + *bracket = 0; + + index = getValue(tmpv, error); + if (*error == 1) { + return INVALID_INDEX; + } else if (index == INVALID_INDEX) { + fprintf(stderr, "%s: 0x%x is an invalid index\n",vname,index); + *error = 1; + } + } + return index; +} + +void * +makeArrayTarget(const char *vname, const Value *value, CK_ULONG index) +{ + char * target; + CK_ULONG elementSize; + + if (index > (CK_ULONG)value->arraySize) { + fprintf(stderr, "%s[%d]: index larger than array size (%d)\n", + vname, index, value->arraySize); + return NULL; + } + + target = (char *)value->data; + elementSize = value->size/value->arraySize; + target += index * elementSize; + return target; +} + +/* + * look up a variable from the variable chain + */ +static Variable *varHead = NULL; +Value * +varLookup(const char *bp, char *vname, int max, int *error) +{ + Variable *current; + CK_ULONG index = INVALID_INDEX; + int isArray = 0; + char *ptr; + *error = 0; + + if (bp != NULL) { + readChars(bp, vname, max); + } + + /* don't make numbers into variables */ + if (isNum(vname[0])) { + return NULL; + } + /* nor consts */ + if (isConst(vname)) { + return NULL; + } + /* handle sizeof() */ + if ((ptr = isSize(vname, &isArray)) != NULL) { + CK_ULONG size; + Value *targetValue = NULL; + Value *sourceValue = varLookup(NULL, ptr, 0, error); + if (!sourceValue) { + if (*error == 0) { + /* just didn't find it */ + *error = 1; + fprintf(stderr,"Couldn't find variable %s to take size of\n", + ptr); + return NULL; + } + } + size = isArray ? sourceValue->arraySize : sourceValue->size; + targetValue = NewValue(ArgULong,1); + memcpy(targetValue->data, &size, sizeof(size)); + + return targetValue; + } + + /* modifies vname */ + index = handleArray(vname, error); + if (*error == 1) { + return NULL; + } + + for (current = varHead; current; current = current->next) { + if (PL_strcasecmp(current->vname, vname) == 0) { + char *target; + if (index == INVALID_INDEX) { + (current->value->reference)++; + return current->value; + } + target = makeArrayTarget(vname, current->value, index); + if (target) { + Value *element = NewValue(current->value->type, 1); + if (!element) { + fprintf(stderr, "MEMORY ERROR!\n"); + *error = 1; + } + argFreeData(element); + element->data = target; + element->type |= ArgStatic; + return element; + } + *error = 1; + return NULL; + } + } + return NULL; +} + +static CK_RV +list(void) +{ + Variable *current; + + if (varHead) { + printf(" %10s\t%16s\t%8s\tSize\tElements\n","Name","Type","Const"); + } else { + printf(" no variables set\n"); + } + + for (current = varHead; current; current = current->next) { + printf(" %10s\t%16s\t%8s\t%d\t%d\n", current->vname, + valueString[current->value->type&ArgMask], + constTypeString[current->value->constType], + current->value->size, current->value->arraySize); + } + return CKR_OK; +} + +CK_RV +printFlags(const char *s, CK_ULONG flags, ConstType type) +{ + CK_ULONG i; + int needComma = 0; + + printf("%s",s); + for (i=1; i ; i=i << 1) { + if (flags & i) { + printf("%s",needComma?",":""); + printConst(i, type, 0); + needComma=1; + } + } + if (!needComma) { + printf("Empty"); + } + printf("\n"); + return CKR_OK; +} + /* * add a new variable to the chain */ -char *AddVariable(char *bp, Value **ptr) +const char * +AddVariable(const char *bp, Value **ptr) { char vname[512]; Variable *current; + int index = INVALID_INDEX; int size; + int error = 0; bp = readChars(bp,vname,sizeof(vname)); + /* don't make numbers into variables */ + if (isNum(vname[0])) { + return bp; + } + /* or consts */ + if (isConst(vname)) { + return bp; + } + /* or NULLs */ + if (vname[0] == 0) { + return bp; + } + /* or sizeof */ + if (isSize(vname, NULL)) { + return bp; + } + /* arrays values should be written back to the original */ + index = handleArray(vname, &error); + if (error == 1) { + return bp; + } + + for (current = varHead; current; current = current->next) { if (PL_strcasecmp(current->vname,vname) == 0) { - argFree(*ptr); + char *target; + /* found a complete object, return the found one */ + if (index == INVALID_INDEX) { + argFree(*ptr); *ptr = current->value; return bp; + } + /* found an array, update the array element */ + target = makeArrayTarget(vname, current->value, index); + if (target) { + memcpy(target, (*ptr)->data, (*ptr)->size); + argFreeData(*ptr); + (*ptr)->data = target; + (*ptr)->type |= ArgStatic; + } + return bp; } } + /* we are looking for an array and didn't find one */ + if (index != INVALID_INDEX) { + return bp; + } + + current = (Variable *)malloc(sizeof(Variable)); size = strlen(vname); current->vname = (char *)malloc(size+1); @@ -333,7 +589,8 @@ char *AddVariable(char *bp, Value **ptr) return bp; } -ArgType FindTypeByName(char *typeName) +ArgType +FindTypeByName(const char *typeName) { int i; @@ -350,7 +607,8 @@ ArgType FindTypeByName(char *typeName) return ArgNone; } -CK_RV ArrayVariable(char *bp, char *typeName, CK_ULONG count) +CK_RV +ArrayVariable(const char *bp, const char *typeName, CK_ULONG count) { ArgType type; Value *value; /* new Value */ @@ -367,7 +625,8 @@ CK_RV ArrayVariable(char *bp, char *typeName, CK_ULONG count) #define MAX_TEMPLATE 25 -CK_RV ArrayTemplate(char *bp, char *attributes) +CK_RV +ArrayTemplate(const char *bp, char *attributes) { char aname[512]; CK_ULONG attributeTypes[MAX_TEMPLATE]; @@ -389,7 +648,7 @@ CK_RV ArrayTemplate(char *bp, char *attributes) (void)constLookup(cur, &attributeTypes[count], &type); if ((type != ConstAttribute) && (type != ConstNone)) { - printf("Unknown Attribute %s\n", cur); + fprintf(stderr, "Unknown Attribute %s\n", cur); return CKR_FUNCTION_FAILED; } } @@ -404,7 +663,8 @@ CK_RV ArrayTemplate(char *bp, char *attributes) return CKR_OK; } -CK_RV BuildTemplate(Value *vp) +CK_RV +BuildTemplate(Value *vp) { CK_ATTRIBUTE *template = (CK_ATTRIBUTE *)vp->data; int i; @@ -418,14 +678,15 @@ CK_RV BuildTemplate(Value *vp) return CKR_OK; } -CK_RV SetTemplate(Value *vp, CK_ULONG index, CK_ULONG value) +CK_RV +SetTemplate(Value *vp, CK_ULONG index, CK_ULONG value) { CK_ATTRIBUTE *template = (CK_ATTRIBUTE *)vp->data; int isbool = 0; CK_ULONG len; ConstType attrType; - if (index >= vp->arraySize) { + if (index >= (CK_ULONG) vp->arraySize) { fprintf(stderr,"index (%lu) greater than array (%d)\n", index, vp->arraySize); return CKR_ARGUMENTS_BAD; @@ -435,7 +696,7 @@ CK_RV SetTemplate(Value *vp, CK_ULONG index, CK_ULONG value) if (attrType == ConstNone) { fprintf(stderr,"can't set index (%lu) because ", index); printConst(template[index].type,ConstAttribute, 0); - printf(" is not a CK_BBOOL or CK_ULONG\n"); + fprintf(stderr, " is not a CK_BBOOL or CK_ULONG\n"); return CKR_ARGUMENTS_BAD; } isbool = (attrType == ConstBool); @@ -454,7 +715,8 @@ CK_RV SetTemplate(Value *vp, CK_ULONG index, CK_ULONG value) } -CK_RV NewMechanism(char *bp, CK_ULONG mechType) +CK_RV +NewMechanism(const char *bp, CK_ULONG mechType) { Value *value; /* new Value */ CK_MECHANISM *mechanism; @@ -471,7 +733,8 @@ CK_RV NewMechanism(char *bp, CK_ULONG mechType) /* * add a new variable to the chain */ -CK_RV DeleteVariable(char *bp) +CK_RV +DeleteVariable(const char *bp) { char vname[512]; Variable **current; @@ -490,7 +753,8 @@ CK_RV DeleteVariable(char *bp) /* * convert an octal value to integer */ -CK_ULONG otoi(char *o) +CK_ULONG +otoi(const char *o) { CK_ULONG value = 0; @@ -507,7 +771,8 @@ CK_ULONG otoi(char *o) /* * convert a hex value to integer */ -CK_ULONG htoi(char *x) +CK_ULONG +htoi(const char *x) { CK_ULONG value = 0; @@ -529,7 +794,8 @@ CK_ULONG htoi(char *x) /* * look up or decode a constant value */ -char *constLookup(char *bp, CK_ULONG *value, ConstType *type) +const char * +constLookup(const char *bp, CK_ULONG *value, ConstType *type) { char vname[512]; int i; @@ -556,7 +822,8 @@ char *constLookup(char *bp, CK_ULONG *value, ConstType *type) return bp; } -int ArgSize(ArgType type) +int +ArgSize(ArgType type) { int size=0; type &= ArgMask; @@ -610,7 +877,7 @@ int ArgSize(ArgType type) } CK_RV -restore(char *filename,Value *ptr) +restore(const char *filename,Value *ptr) { int fd,size; @@ -637,7 +904,7 @@ restore(char *filename,Value *ptr) } CK_RV -save(char *filename,Value *ptr) +save(const char *filename,Value *ptr) { int fd,size; @@ -660,7 +927,8 @@ save(char *filename,Value *ptr) return CKR_OK; } -CK_RV printArg(Value *ptr,int arg_number) +CK_RV +printArg(Value *ptr,int arg_number) { ArgType type = ptr->type & ArgMask; CK_INFO *info; @@ -715,8 +983,7 @@ CK_RV printArg(Value *ptr,int arg_number) } break; case ArgVar: - printf(" Variable.....error\n"); - ckrv = CKR_ARGUMENTS_BAD; + printf(" %s\n",(char *)ptr->data); break; case ArgUTF8: printf(" %s\n",(char *)ptr->data); @@ -751,7 +1018,8 @@ CK_RV printArg(Value *ptr,int arg_number) break; case ArgTokenInfo: tokenInfo = (CK_TOKEN_INFO *)ptr->data; - printf(" Label: %s\n",tokenInfo->label); + printf(" Label: "); + printChars(tokenInfo->label,sizeof(tokenInfo->label)); printf(" Manufacturer ID: "); printChars(tokenInfo->manufacturerID,sizeof(tokenInfo->manufacturerID)); printf(" Model: "); @@ -759,24 +1027,30 @@ CK_RV printArg(Value *ptr,int arg_number) printf(" Serial Number: "); printChars(tokenInfo->serialNumber,sizeof(tokenInfo->serialNumber)); printFlags(" Flags: ", tokenInfo->flags, ConstTokenFlags); - printf(" Max Session Count: %lu\n",tokenInfo->ulMaxSessionCount); - printf(" Session Count: %lu\n",tokenInfo->ulSessionCount); - printf(" RW Session Count: %lu\n",tokenInfo->ulMaxRwSessionCount); - printf(" Max Pin Length : %lu\n",tokenInfo->ulMaxPinLen); - printf(" Min Pin Length : %lu\n",tokenInfo->ulMinPinLen); - printf(" Total Public Memory: %lu\n", - tokenInfo->ulTotalPublicMemory); - printf(" Free Public Memory: %lu\n", - tokenInfo->ulFreePublicMemory); - printf(" Total Private Memory: %lu\n", - tokenInfo->ulTotalPrivateMemory); - printf(" Free Private Memory: %lu\n", - tokenInfo->ulFreePrivateMemory); + printf(" Max Session Count: "); + printConst(tokenInfo->ulMaxSessionCount, ConstAvailableSizes, 1); + printf(" Session Count: "); + printConst(tokenInfo->ulSessionCount, ConstCurrentSize, 1); + printf(" RW Session Count: "); + printConst(tokenInfo->ulMaxRwSessionCount, ConstAvailableSizes, 1); + printf(" Max Pin Length : "); + printConst(tokenInfo->ulMaxPinLen, ConstCurrentSize, 1); + printf(" Min Pin Length : "); + printConst(tokenInfo->ulMinPinLen, ConstCurrentSize, 1); + printf(" Total Public Memory: "); + printConst(tokenInfo->ulTotalPublicMemory, ConstAvailableSizes, 1); + printf(" Free Public Memory: "); + printConst(tokenInfo->ulFreePublicMemory, ConstCurrentSize, 1); + printf(" Total Private Memory: "); + printConst(tokenInfo->ulTotalPrivateMemory, ConstAvailableSizes, 1); + printf(" Free Private Memory: "); + printConst(tokenInfo->ulFreePrivateMemory, ConstCurrentSize, 1); printf(" Hardware Version: %d.%02d\n", VERSION(tokenInfo->hardwareVersion)); printf(" Firmware Version: %d.%02d\n", VERSION(tokenInfo->firmwareVersion)); - printf(" UTC Time: %s\n",tokenInfo->utcTime); + printf(" UTC Time: "); + printChars(tokenInfo->utcTime,sizeof(tokenInfo->utcTime)); break; case ArgSessionInfo: sessionInfo = (CK_SESSION_INFO *)ptr->data; @@ -849,7 +1123,7 @@ CK_RV printArg(Value *ptr,int arg_number) * with full expressions. */ Value ** -parseArgs(int index, char * bp) +parseArgs(int index, const char * bp) { const Commands *cp = &commands[index]; int size = strlen(cp->fname); @@ -878,18 +1152,23 @@ parseArgs(int index, char * bp) */ for (i=0 ;i < MAX_ARGS; i++) { ArgType type = cp->args[i] & ArgMask; + int error; /* strip blanks */ bp = strip(bp); /* if we hit ArgNone, we've nabbed all the arguments we need */ if (type == ArgNone) { - break; + break; } /* if we run out of space in the line, we weren't given enough * arguments... */ if (*bp == '\0') { + /* we're into optional arguments, ok to quit now */ + if (cp->args[i] & ArgOpt) { + break; + } fprintf(stderr,"%s: only %d args found,\n",cp->fname,i); parseFree(argList); return NULL; @@ -899,8 +1178,9 @@ parseArgs(int index, char * bp) * look up the argument in our variable list first... only * exception is the new argument type for set... */ + error = 0; if ((cp->args[i] != (ArgVar|ArgNew)) && - (possible = varLookup(bp,vname,sizeof(vname)))) { + (possible = varLookup(bp,vname,sizeof(vname),&error))) { /* ints are only compatible with other ints... all other types * are interchangeable... */ if (type != ArgVar) { /* ArgVar's match anyone */ @@ -908,6 +1188,7 @@ parseArgs(int index, char * bp) ((possible->type & ArgMask) == ArgULong)) { fprintf(stderr,"%s: Arg %d incompatible type with <%s>\n", cp->fname,i+1,vname); + argFree(possible); parseFree(argList); return NULL; } @@ -918,6 +1199,7 @@ parseArgs(int index, char * bp) fprintf(stderr, "%s: Arg %d %s is too small (%d bytes needs to be %d bytes)\n", cp->fname,i+1,vname,possible->size,ArgSize(type)); + argFree(possible); parseFree(argList); return NULL; } @@ -925,7 +1207,6 @@ parseArgs(int index, char * bp) /* everything looks kosher here, use it */ argList[i] = possible; - possible->reference++; bp = readChars(bp,vname,sizeof(vname)); if (cp->args[i] & ArgOut) { @@ -934,6 +1215,11 @@ parseArgs(int index, char * bp) continue; } + if (error == 1) { + parseFree(argList); + return NULL; + } + /* create space for our argument */ argList[i] = NewValue(type, 1); @@ -945,7 +1231,7 @@ parseArgs(int index, char * bp) parseFree(argList); return NULL; } - free(argList[i]->data); + argFreeData(argList[i]); argList[i]->data = NULL; argList[i]->size = 0; bp += 4; @@ -955,17 +1241,17 @@ parseArgs(int index, char * bp) /* if we're an output variable, we need to add it */ if (cp->args[i] & ArgOut) { - if (PL_strncasecmp(bp,"file(",5) == 0) { + if (PL_strncasecmp(bp,"file(",5) == 0 /* ) */ ) { char filename[512]; bp = readChars(bp+5,filename,sizeof(filename)); - size = strlen(filename); - if ((size > 0) && (filename[size-1] == ')')) { + size = PL_strlen(filename); + if ((size > 0) && (/* ( */filename[size-1] == ')')) { filename[size-1] = 0; } filename[size] = 0; argList[i]->filename = (char *)malloc(size+1); - strcpy(argList[i]->filename,filename); + PL_strcpy(argList[i]->filename,filename); argList[i]->type |= ArgOut|ArgFile; break; @@ -975,12 +1261,14 @@ parseArgs(int index, char * bp) continue; } - if (PL_strncasecmp(bp, "file(", 5) == 0) { + if (PL_strncasecmp(bp, "file(", 5) == 0 /* ) */ ) { char filename[512]; bp = readChars(bp+5,filename,sizeof(filename)); - size = strlen(filename); - if ((size > 0) && (filename[size-1] == ')')) filename[size-1] = 0; + size = PL_strlen(filename); + if ((size > 0) && ( /* ( */ filename[size-1] == ')')) { + filename[size-1] = 0; + } if (restore(filename,argList[i]) != CKR_OK) { parseFree(argList); @@ -989,32 +1277,6 @@ parseArgs(int index, char * bp) continue; } - if (PL_strncasecmp(bp, "size(", 5) == 0) { - CK_ULONG *ulong = (CK_ULONG *)argList[i]->data; - char tmpname[512]; - - bp = readChars(bp+5,tmpname,sizeof(tmpname)); - size = strlen(tmpname); - if ((size > 0) && (tmpname[size-1] == ')')) tmpname[size-1] = 0; - - if (argList[i]->size == sizeof(CK_ULONG) || ulong == NULL) { - fprintf(stderr, - "%s: size used for non-int argument,\n",cp->fname); - parseFree(argList); - return NULL; - } - *ulong = 0; - varLookup(tmpname, vname,sizeof(vname)); - if (!possible) { - fprintf(stderr, - "%s: %s was not found\n",cp->fname, vname); - parseFree(argList); - return NULL; - } - *ulong = possible->arraySize; - continue; - } - switch (type) { case ArgULong: bp = constLookup(bp, &value, &constType); @@ -1022,8 +1284,8 @@ parseArgs(int index, char * bp) argList[i]->constType = constType; break; case ArgVar: - free(argList[i]->data); - size = getEnd(bp); + argFreeData(argList[i]); + size = getEnd(bp)+1; argList[i]->data = (void *)malloc(size); argList[i]->size = size; /* fall through */ @@ -1048,28 +1310,27 @@ parseArgs(int index, char * bp) } /* lookup the command in the array */ -int lookup(char *buf) +int +lookup(const char *buf) { int size,i; int buflen; - buflen = strlen(buf); + buflen = PL_strlen(buf); for ( i = 0; i < commandCount; i++) { - size = strlen(commands[i].fname); + size = PL_strlen(commands[i].fname); - if (size > buflen) { - continue; + if (size <= buflen) { + if (PL_strncasecmp(buf,commands[i].fname,size) == 0) { + return i; + } } - if (PL_strncasecmp(buf,commands[i].fname,size) == 0) { - return i; - } - if (size-2 > buflen) { - continue; - } - if (commands[i].fname[0] == 'C' && commands[i].fname[1] == '_' && + if (size-2 <= buflen) { + if (commands[i].fname[0] == 'C' && commands[i].fname[1] == '_' && (PL_strncasecmp(buf,&commands[i].fname[2],size-2) == 0)) { - return i; + return i; + } } } fprintf(stderr,"Can't find command %s\n",buf); @@ -1103,7 +1364,9 @@ putOutput(Value **ptr) } } -CK_RV unloadModule(Module *module) { +CK_RV +unloadModule(Module *module) +{ if (module->library) { PR_UnloadLibrary(module->library); @@ -1115,7 +1378,9 @@ CK_RV unloadModule(Module *module) { return CKR_OK; } -CK_RV loadModule(Module *module, char *library) { +CK_RV +loadModule(Module *module, char *library) +{ PRLibrary *newLibrary; CK_C_GetFunctionList getFunctionList; CK_FUNCTION_LIST *functionList; @@ -1148,15 +1413,53 @@ CK_RV loadModule(Module *module, char *library) { return CKR_OK; } +static void +printHelp(int index, int full) +{ + int j; + printf(" %s", commands[index].fname); + for (j=0; j < MAX_ARGS; j++) { + ArgType type = commands[index].args[j] & ArgMask; + if (type == ArgNone) { + break; + } + printf(" %s", valueString[type]); + } + printf("\n"); + printf(" %s\n",commands[index].helpString); +} + +/* add Topical help here ! */ +static CK_RV +printTopicHelp(char *topic) +{ + return CKR_DATA_INVALID; +} + +static CK_RV +printGeneralHelp(void) +{ + int i; + printf(" To get help on commands, select from the list below:"); + for ( i = 0; i < commandCount; i++) { + if (i % 5 == 0) printf("\n"); + printf("%s,", commands[i].fname); + } + printf("\n"); + /* print help topics */ + return CKR_OK; +} + CK_RV run(char *); /* * Actually dispatch the function... Bad things happen * if these don't match the commands array. */ -CK_RV do_func(int index, Value **a) +CK_RV +do_func(int index, Value **a) { - int value; + int value, helpIndex; static Module module = { NULL, NULL} ; CK_FUNCTION_LIST *func = module.functionList; @@ -1175,7 +1478,7 @@ CK_RV do_func(int index, Value **a) return func->C_GetFunctionList((CK_FUNCTION_LIST **)a[0]->data); case F_C_GetSlotList: if (!func) return CKR_CRYPTOKI_NOT_INITIALIZED; - return func->C_GetSlotList(*(CK_ULONG *)a[0]->data, + return func->C_GetSlotList((CK_BBOOL)*(CK_ULONG *)a[0]->data, (CK_SLOT_ID *)a[1]->data, (CK_LONG *)a[2]->data); case F_C_GetSlotInfo: @@ -1540,6 +1843,7 @@ CK_RV do_func(int index, Value **a) (void *)a[2]->data); /* set a variable */ case F_SetVar: + case F_SetStringVar: (void) DeleteVariable(a[0]->data); (void) AddVariable(a[0]->data,&a[1]); return CKR_OK; @@ -1583,6 +1887,16 @@ CK_RV do_func(int index, Value **a) systemFlags |= value; } return CKR_OK; + case F_Help: + if (a[0]) { + helpIndex = lookup(a[0]->data); + if (helpIndex < 0) { + return printTopicHelp(a[0]->data); + } + printHelp(helpIndex, 1); + return CKR_OK; + } + return printGeneralHelp(); case F_Quit: return 0x80000000; default: @@ -1595,7 +1909,8 @@ CK_RV do_func(int index, Value **a) } -CK_RV process(FILE *inFile,int user) +CK_RV +process(FILE *inFile,int user) { char buf[2048]; Value **arglist; @@ -1606,7 +1921,7 @@ CK_RV process(FILE *inFile,int user) while (fgets(buf,2048,inFile) != NULL) { int index; - char *bp; + const char *bp; if (!user) printf("* %s",buf); bp = strip(buf); diff --git a/mozilla/security/nss/cmd/pk11util/pk11util.h b/mozilla/security/nss/cmd/pk11util/pk11util.h index 7fbc010aec2..cdb4970c966 100644 --- a/mozilla/security/nss/cmd/pk11util/pk11util.h +++ b/mozilla/security/nss/cmd/pk11util/pk11util.h @@ -14,6 +14,7 @@ typedef enum { #undef CK_NEED_ARG_LISt #undef CK_PKCS11_FUNCTION_INFO F_SetVar, + F_SetStringVar, F_NewArray, F_NewTemplate, F_NewMechanism, @@ -28,6 +29,7 @@ typedef enum { F_Load, F_Unload, F_System, + F_Help, F_Quit, } FunctionType; @@ -55,6 +57,8 @@ typedef enum { ArgArray = 0x200, ArgNew = 0x400, ArgFile = 0x800, + ArgStatic = 0x1000, + ArgOpt = 0x2000, } ArgType; typedef enum _constType @@ -76,7 +80,9 @@ typedef enum _constType ConstAttribute, ConstMechanism, ConstResult, - ConstTrust + ConstTrust, + ConstAvailableSizes, + ConstCurrentSize } ConstType; typedef struct _constant { @@ -120,6 +126,7 @@ struct _variable { typedef struct _commands { char *fname; FunctionType fType; + char *helpString; ArgType args[MAX_ARGS]; } Commands;