CryptoSys PKI Pro Manual

SMIME_Query

Query an S/MIME entity.

VBA/VB6 Syntax

Public Declare Function SMIME_Query Lib "diCrPKI.dll" (ByVal strOutput As String, ByVal nOutChars As Long, ByVal strFileIn As String, ByVal strQuery As String, ByVal nOptions As Long) As Long

nRet = SMIME_Query(strFileOut, strFileOut, strQuery, nOptions)

C/C++ Syntax

long __stdcall SMIME_Query(char *szOutput, long nOutChars, const char *szFileIn, const char *szQuery, long nOptions);

Parameters

szOutput
[out] string of sufficient length to receive the output.
nOutChars
[in] specifying the maximum number of characters to be received.
szFileIn
[in] string specifying the filename of the input file.
szQuery
[in] specifying the query (see Remarks below).
nOptions
[in] option flags: not used in this release. Specify zero.

Returns (VBA/C)

If successful, the return value is a positive number indicating the number of characters (bytes) in the output string, or number of characters required if nOutChars was set to zero. If the item queried cannot be found, the return value is zero. If there is an error (e.g. invalid input), it returns a negative error code.

VBA Wrapper Syntax

Public Function smimeQuery (szFileIn As String, szQuery As String, Optional nOptions As Long = 0) As String

.NET Equivalent

Smime.Query Method

C++ (STL) Equivalent

static std::string dipki::Smime::Query (const std::string &inputFile, const std::string &query)

Python Equivalent

static Smime.query(filename, query)

Remarks

Valid queries are (case-insensitive):

Query StringReturns
content-typeValue of Content-Type, e.g. "application/pkcs7-mime"
smime-typeValue of smime-type parameter of Content-Type, e.g. "enveloped-data"
encodingValue of Content-Transfer-Encoding, e.g. "base64"
nameValue of name parameter of Content-Type, e.g. "smime.p7m"
filenameValue of filename parameter of Content-Disposition, e.g. "smime.p7m"

If no value is found corresponding to the query then the zero-length empty string "" is output.

For the "raw" VBA/C function, the user must allocate an output string buffer szOutput of the required length. Specify a zero nOutChars or an empty string for szOutput to find the required length. ANSI C users must add one to this value when allocating memory.

Example (VBA core function)

Dim strQuery As String
Dim strOutput As String
Dim nRet As Long
Dim strFileIn As String

strFileIn = "cmsalice2bob-smime-env.txt"
Debug.Print "FILE: " & strFileIn

' Make a buffer large enough to receive output
strOutput = String(512, " ")

strQuery = "content-type"
nRet = SMIME_Query(strOutput, Len(strOutput), strFileIn, strQuery, 0)
If nRet <= 0 Then Exit Sub  ' catch error
Debug.Print strQuery & "=" & Left(strOutput, nRet)

strQuery = "smime-type"
nRet = SMIME_Query(strOutput, Len(strOutput), strFileIn, strQuery, 0)
If nRet <= 0 Then Exit Sub  ' catch error
Debug.Print strQuery & "=" & Left(strOutput, nRet)

strQuery = "encoding"
nRet = SMIME_Query(strOutput, Len(strOutput), strFileIn, strQuery, 0)
If nRet <= 0 Then Exit Sub  ' catch error
Debug.Print strQuery & "=" & Left(strOutput, nRet)

strQuery = "filename"
nRet = SMIME_Query(strOutput, Len(strOutput), strFileIn, strQuery, 0)
If nRet <= 0 Then Exit Sub  ' catch error
Debug.Print strQuery & "=" & Left(strOutput, nRet)
FILE: cmsalice2bob-smime-env.txt
content-type=application/pkcs7-mime
smime-type=enveloped-data
encoding=base64
filename=smime.p7m

Example (VBA wrapper function)

Dim strFileIn As String
Dim strQuery As String

strFileIn = "cmsalice2bob-smime-env.txt"
Debug.Print "FILE: " & strFileIn
strQuery = "content-type"
Debug.Print strQuery & "=" & smimeQuery(strFileIn, strQuery, 0)
strQuery = "smime-type"
Debug.Print strQuery & "=" & smimeQuery(strFileIn, strQuery, 0)
strQuery = "encoding"
Debug.Print strQuery & "=" & smimeQuery(strFileIn, strQuery, 0)
strQuery = "filename"
Debug.Print strQuery & "=" & smimeQuery(strFileIn, strQuery, 0)

See Also

SMIME_Extract

[Contents] [Index]

[PREV: SMIME_Extract...]   [Contents]   [Index]   
   [NEXT: SMIME_Wrap...]

Copyright © 2004-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-09-23T07:52:09Z.