linux - Deduce type of void in pure C -


well, have callback arisen when http response on http request. prototype of callback following (async programming, arised @ time):

// use ecore_con_url library efl framework eina_bool _pt_url_data_cb(void *data, int type, void *event_info) 

and callback can contains data in event_info in json format, or pure data. depends on in void* data. well, there 2 ways avoid of pure design:

  • use 2 callbacks. if expect pure data - register callback _pt_url_pure_cb, if expect data in json format register _pt_url_json_cb. lack of method have register/unregister callbacks @ runtime. , arised when http response data, doesn't matter in form are. think big problems solution.

for example:

// expect http response pure data ecore_event_handler_add(ecore_con_event_url_data, _pt_url_pure_cb, data); return;  // _pt_url_pure_cb wasn't yet called // expect http response in json format  ecore_event_handler_add(ecore_con_event_url_data, _pt_url_json_cb, data); ... // called pure data _pt_url_json_cb() 
  • the second approach somehow identify type of void* data , depending on parse event_info pure or json data. well, how possible approaches?

note: mean pure , json data? pure - binary file or other file should not parsed, download bytes , save them on file system. json should parsed , can contain http identifiers these pure data.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -