c - error: incompatible types when assigning to type ‘char *’ from type ‘digestInfo’ -
this become apparent newly @ c programming. (i know other languages, php well, wanted have go @ c).
i've managed hack code working way want - , i'm extending little more - , can't figure out how it.
some background. i'm working object:
typedef struct { dsuint16_t stversion; ... (omitted clarity) dsuint16_t objinfolength; char *objinfo; ... (omitted clarity) }objattr; to me, *objinfo area can utilize store data, object (struct?), have created typedef:
typedef struct { unsigned int stversion ; /* construction version */ const evp_md *digest_id ; /* digest name */ unsigned char digest_value ; /* digest calculated value (variable length) */ // ... /* in future may want store else */ } digestinfo ; i have struct in .h file, can referenced in 2 of .c files.
now in .c file, storing info (which ends in application database), have code:
... objattr objattr; digestinfo digesto; ... memset(&digesto,0x00,sizeof(digesto)); digesto.stversion = 1; digesto.digest_id = evp_get_digestbyname(digest); ... evp_digestfinal_ex(&mdctx, md_value, &md_len); digesto.digest_value = *md_value; objattr.objinfo = *digesto; objattr.objinfolength = sizeof(digesto); when compile, error:
error: invalid type argument of ‘unary *’ (have ‘digestinfo’) i know because trying store digestinfo object char value - how should that?
i have tried combinations of
objattr.objinfo = digesto; objattr.objinfo = &digesto; but still error of sorts (although lastly 1 compile warning).
am on right track here? (basically i'm calculating md5 of info coming in via stdin (which beingness stored in application), , want store hash calcs in "objinfo" area of objattr.
i want include algorithm used (md5, sha1, etc), resulting hash, when retrieve data, can re-run digest create sure still same hash.
if i'm way of track this, mind pointing me in right direction?
am right utilize memset first, 0 out memory?
should worried each of these vars (digest_id,digest_value) have variable length?
appreciate help.
the field objinfo char pointer (char*), must assign pointer it, gotten & on "object". objattr.objinfo = &digesto; closest attempt, &digest0 pointer digestinfo, want alter
typedef struct { dsuint16_t stversion; ... (omitted clarity) dsuint16_t objinfolength; char *objinfo; ... (omitted clarity) }objattr; to
typedef struct { dsuint16_t stversion; ... (omitted clarity) dsuint16_t objinfolength; digestinfo *objinfo; ... (omitted clarity) }objattr; c
No comments:
Post a Comment