本文整理汇总了C++中NewHash函数的典型用法代码示例。如果您正苦于以下问题:C++ NewHash函数的具体用法?C++ NewHash怎么用?C++ NewHash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewHash函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Swig_feature_set
void
Swig_feature_set(Hash *features, String *name, SwigType *decl, String *featurename, DOH *value) {
Hash *n;
Hash *fhash;
/* Printf(stdout,"feature: %s %s %s %s\n", name, decl, featurename, value);*/
n = Getattr(features,name);
if (!n) {
n = NewHash();
Setattr(features,name,n);
}
if (!decl) {
fhash = Getattr(n,"*");
if (!fhash) {
fhash = NewHash();
Setattr(n,"*",fhash);
}
} else {
fhash = Getattr(n,decl);
if (!fhash) {
fhash = NewHash();
Setattr(n,Copy(decl),fhash);
}
}
if (value) {
Setattr(fhash,featurename,value);
} else {
Delattr(fhash,featurename);
}
}
示例2: DBInitEventQueue
void DBInitEventQueue(void)
{
pthread_mutex_init(&DBEventQueueMutex, NULL);
pthread_mutex_init(&DBEventExitQueueMutex, NULL);
DBQueueEvents = NewHash(1, Flathash);
DBInboundEventQueues[0] = NewHash(1, Flathash);
DBInboundEventQueues[1] = NewHash(1, Flathash);
DBInboundEventQueue = DBInboundEventQueues[0];
}
示例3: defined
DecodingResult OAEP_Base::Unpad(const byte *oaepBlock, size_t oaepBlockLen, byte *output, const NameValuePairs ¶meters) const
{
bool invalid = false;
#if defined(CRYPTOPP_CXX11)
std::unique_ptr<HashTransformation> pHash(NewHash());
#else
std::auto_ptr<HashTransformation> pHash(NewHash());
#endif
// convert from bit length to byte length
if (oaepBlockLen % 8 != 0)
{
invalid = (oaepBlock[0] != 0) || invalid;
oaepBlock++;
}
oaepBlockLen /= 8;
const size_t hLen = pHash->DigestSize();
const size_t seedLen = hLen, dbLen = oaepBlockLen-seedLen;
invalid = (oaepBlockLen < 2*hLen+1) || invalid;
SecByteBlock t(oaepBlock, oaepBlockLen);
byte *const maskedSeed = t;
byte *const maskedDB = t+seedLen;
#if defined(CRYPTOPP_CXX11)
std::unique_ptr<MaskGeneratingFunction> pMGF(NewMGF());
#else
std::auto_ptr<MaskGeneratingFunction> pMGF(NewMGF());
#endif
pMGF->GenerateAndMask(*pHash, maskedSeed, seedLen, maskedDB, dbLen);
pMGF->GenerateAndMask(*pHash, maskedDB, dbLen, maskedSeed, seedLen);
ConstByteArrayParameter encodingParameters;
parameters.GetValue(Name::EncodingParameters(), encodingParameters);
// DB = pHash' || 00 ... || 01 || M
byte *M = std::find(maskedDB+hLen, maskedDB+dbLen, 0x01);
invalid = (M == maskedDB+dbLen) || invalid;
invalid = (std::find_if(maskedDB+hLen, M, std::bind2nd(std::not_equal_to<byte>(), byte(0))) != M) || invalid;
invalid = !pHash->VerifyDigest(maskedDB, encodingParameters.begin(), encodingParameters.size()) || invalid;
if (invalid)
return DecodingResult();
M++;
memcpy(output, M, maskedDB+dbLen-M);
return DecodingResult(maskedDB+dbLen-M);
}
示例4: NewHash
void
ServerStartModule_CONTEXT
(void)
{
long *v;
HttpReqTypes = NewHash(1, NULL);
HttpHeaderHandler = NewHash(1, NULL);
v = malloc(sizeof(long));
*v = eGET;
Put(HttpReqTypes, HKEY("GET"), v, NULL);
v = malloc(sizeof(long));
*v = ePOST;
Put(HttpReqTypes, HKEY("POST"), v, NULL);
v = malloc(sizeof(long));
*v = eOPTIONS;
Put(HttpReqTypes, HKEY("OPTIONS"), v, NULL);
v = malloc(sizeof(long));
*v = ePROPFIND;
Put(HttpReqTypes, HKEY("PROPFIND"), v, NULL);
v = malloc(sizeof(long));
*v = ePUT;
Put(HttpReqTypes, HKEY("PUT"), v, NULL);
v = malloc(sizeof(long));
*v = eDELETE;
Put(HttpReqTypes, HKEY("DELETE"), v, NULL);
v = malloc(sizeof(long));
*v = eHEAD;
Put(HttpReqTypes, HKEY("HEAD"), v, NULL);
v = malloc(sizeof(long));
*v = eMOVE;
Put(HttpReqTypes, HKEY("MOVE"), v, NULL);
v = malloc(sizeof(long));
*v = eCOPY;
Put(HttpReqTypes, HKEY("COPY"), v, NULL);
v = malloc(sizeof(long));
*v = eREPORT;
Put(HttpReqTypes, HKEY("REPORT"), v, NULL);
}
示例5: SwigType_namestr
String *Swig_name_destroy(const_String_or_char_ptr nspace, const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
char *cname;
rclassname = SwigType_namestr(classname);
r = NewStringEmpty();
if (!naming_hash)
naming_hash = NewHash();
f = Getattr(naming_hash, "destroy");
if (!f) {
Append(r, "delete_%n%c");
} else {
Append(r, f);
}
cname = Char(rclassname);
if ((strncmp(cname, "struct ", 7) == 0) || ((strncmp(cname, "class ", 6) == 0)) || ((strncmp(cname, "union ", 6) == 0))) {
cname = strchr(cname, ' ') + 1;
}
replace_nspace(r, nspace);
Replace(r, "%c", cname, DOH_REPLACE_ANY);
Delete(rclassname);
return r;
}
示例6: SwigType_namestr
String *Swig_name_disown(const String_or_char *classname) {
String *r;
String *f;
String *rclassname;
char *cname;
rclassname = SwigType_namestr(classname);
r = NewString("");
if (!naming_hash) naming_hash = NewHash();
f = Getattr(naming_hash,"disown");
if (!f) {
Append(r,"disown_%c");
} else {
Append(r,f);
}
cname = Char(rclassname);
if ((strncmp(cname,"struct ", 7) == 0) ||
((strncmp(cname,"class ", 6) == 0)) ||
((strncmp(cname,"union ", 6) == 0))) {
cname = strchr(cname, ' ')+1;
}
Replace(r,"%c",cname, DOH_REPLACE_ANY);
Delete(rclassname);
return r;
}
示例7: DohSetmeta
int
DohSetmeta(DOH *ho, const DOH *name, const DOH *value) {
DohBase *h = (DohBase *) ho;
if (!DohCheck(ho)) return 0;
if (!h->meta) h->meta = NewHash();
return DohSetattr(h->meta, name, value);
}
示例8: NewHash
SwigType *SwigType_strip_qualifiers(SwigType *t) {
static Hash *memoize_stripped = 0;
SwigType *r;
List *l;
Iterator ei;
if (!memoize_stripped)
memoize_stripped = NewHash();
r = Getattr(memoize_stripped, t);
if (r)
return Copy(r);
l = SwigType_split(t);
r = NewStringEmpty();
for (ei = First(l); ei.item; ei = Next(ei)) {
if (SwigType_isqualifier(ei.item))
continue;
Append(r, ei.item);
}
Delete(l);
{
String *key, *value;
key = Copy(t);
value = Copy(r);
Setattr(memoize_stripped, key, value);
Delete(key);
Delete(value);
}
return r;
}
示例9: Swig_fragment_register
void
Swig_fragment_register(Node* fragment) {
if (Getattr(fragment,k_emitonly)) {
Swig_fragment_emit(fragment);
return;
} else {
String *name = Copy(Getattr(fragment,k_value));
String *type = Getattr(fragment,k_type);
if (type) {
SwigType *rtype = SwigType_typedef_resolve_all(type);
String *mangle = Swig_string_mangle(type);
Append(name,mangle);
Delete(mangle);
Delete(rtype);
if (debug) Printf(stdout,"register fragment %s %s\n",name,type);
}
if (!fragments) {
fragments = NewHash();
}
if (!Getattr(fragments,name)) {
String *section = Copy(Getattr(fragment,k_section));
String *ccode = Copy(Getattr(fragment,k_code));
Hash *kwargs = Getattr(fragment,k_kwargs);
Setmeta(ccode,k_section,section);
if (kwargs) {
Setmeta(ccode,k_kwargs,kwargs);
}
Setattr(fragments,name,ccode);
if (debug) Printf(stdout,"registering fragment %s %s\n",name,section);
Delete(section);
Delete(ccode);
}
Delete(name);
}
}
示例10: TestHash
void TestHash()
{
Thing key = Word(7);
Thing item = Word(11);
Thing X, Y;
CommentLine("Testing Hashtable");
Hash H = NewHash(NULL);
HashIns(H, key, item);
//BAD CODE: if (IntWord(HashGet(H, key)) != 11)
//{ printf("no match!\n"); }
//HashGet can return NULL!
X = HashGet(H, key);
assert(X);
assert(SameThing(X, item));
if (ThingCmp(X, item) != EQ) printf("error in retr hash");
Y = HashRm(H, key);
assert(SameThing(Y, item));
assert(SameThing(X, Y));
DelThing(X);
X = HashRm(H, key);
assert(X == NULL);
DelHash(H);
//asm("int3");
DelThing(Y); // this calls the dtor on item
DelThing(key);
printf("Basic insert/retrieve in hash table done.\n");
}
示例11: serv_puts
HashList *load_netconf(StrBuf *Target, WCTemplputParams *TP)
{
StrBuf *Buf;
HashList *Hash;
char nnn[64];
char buf[SIZ];
int nUsed;
NodeConf *Node;
serv_puts("CONF getsys|application/x-citadel-ignet-config");
serv_getln(buf, sizeof buf);
if (buf[0] == '1') {
Hash = NewHash(1, NULL);
Buf = NewStrBuf();
while (StrBuf_ServGetln(Buf), strcmp(ChrPtr(Buf), "000")) {
Node = NewNode(Buf);
if (Node != NULL) {
nUsed = GetCount(Hash);
nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed+1);
Put(Hash, nnn, nUsed, Node, DeleteNodeConf);
}
}
FreeStrBuf(&Buf);
return Hash;
}
return NULL;
}
示例12: assert
void OAEP_Base::Pad(RandomNumberGenerator &rng, const byte *input, size_t inputLength, byte *oaepBlock, size_t oaepBlockLen, const NameValuePairs ¶meters) const
{
assert (inputLength <= MaxUnpaddedLength(oaepBlockLen));
// convert from bit length to byte length
if (oaepBlockLen % 8 != 0)
{
oaepBlock[0] = 0;
oaepBlock++;
}
oaepBlockLen /= 8;
std::auto_ptr<HashTransformation> pHash(NewHash());
const size_t hLen = pHash->DigestSize();
const size_t seedLen = hLen, dbLen = oaepBlockLen-seedLen;
byte *const maskedSeed = oaepBlock;
byte *const maskedDB = oaepBlock+seedLen;
ConstByteArrayParameter encodingParameters;
parameters.GetValue(Name::EncodingParameters(), encodingParameters);
// DB = pHash || 00 ... || 01 || M
pHash->CalculateDigest(maskedDB, encodingParameters.begin(), encodingParameters.size());
memset(maskedDB+hLen, 0, dbLen-hLen-inputLength-1);
maskedDB[dbLen-inputLength-1] = 0x01;
memcpy(maskedDB+dbLen-inputLength, input, inputLength);
rng.GenerateBlock(maskedSeed, seedLen);
std::auto_ptr<MaskGeneratingFunction> pMGF(NewMGF());
pMGF->GenerateAndMask(*pHash, maskedDB, dbLen, maskedSeed, seedLen);
pMGF->GenerateAndMask(*pHash, maskedSeed, seedLen, maskedDB, dbLen);
}
示例13: NewHash
Parm *NewParm(SwigType *type, String_or_char *n) {
Parm *p = NewHash();
if (type) {
Setattr(p,"type", Copy(type));
}
Setattr(p,"name",n);
return p;
}
示例14: POP3C_GetListCommandState
eNextState POP3C_GetListCommandState(pop3aggr *RecvMsg)
{
AsyncIO *IO = &RecvMsg->IO;
POP3C_DBG_READ();
if (!POP3C_OK) return eTerminateConnection;
RecvMsg->MsgNumbers = NewHash(1, NULL);
RecvMsg->State++;
return eReadMore;
}
示例15: malloc
Wrapper *NewWrapper(void) {
Wrapper *w;
w = (Wrapper *) malloc(sizeof(Wrapper));
w->localh = NewHash();
w->locals = NewStringEmpty();
w->code = NewStringEmpty();
w->def = NewStringEmpty();
return w;
}