tizen 2.3.1 release
[framework/appfw/pkgmgr-info.git] / src / pkgmgrinfo_basic.c
1 /*
2  * pkgmgrinfo-basic
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee <airjany@samsung.com>, Junsuk Oh <junsuk77.oh@samsung.com>,
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #include <stdlib.h>
23 #include <string.h>
24
25 #include "pkgmgrinfo_basic.h"
26 #include "pkgmgrinfo_private.h"
27 #include <openssl/md5.h>
28
29 #define HASH_LEN  MD5_DIGEST_LENGTH * 2
30
31
32 static void __ps_free_category(category_x *category)
33 {
34         if (category == NULL)
35                 return;
36         FREE_AND_NULL(category->name);
37         FREE_AND_NULL(category);
38 }
39
40 static void __ps_free_privilege(privilege_x *privilege)
41 {
42         if (privilege == NULL)
43                 return;
44         FREE_AND_NULL(privilege->text);
45         FREE_AND_NULL(privilege);
46 }
47
48 static void __ps_free_privileges(privileges_x *privileges)
49 {
50         if (privileges == NULL)
51                 return;
52         /*Free Privilege*/
53         if (privileges->privilege) {
54                 privilege_x *privilege = privileges->privilege;
55                 privilege_x *tmp = NULL;
56                 while(privilege != NULL) {
57                         tmp = privilege->next;
58                         __ps_free_privilege(privilege);
59                         privilege = tmp;
60                 }
61         }
62         FREE_AND_NULL(privileges);
63 }
64
65 static void __ps_free_metadata(metadata_x *metadata)
66 {
67         if (metadata == NULL)
68                 return;
69         FREE_AND_NULL(metadata->key);
70         FREE_AND_NULL(metadata->value);
71         FREE_AND_NULL(metadata);
72 }
73
74 static void __ps_free_permission(permission_x *permission)
75 {
76         if (permission == NULL)
77                 return;
78         FREE_AND_NULL(permission->type);
79         FREE_AND_NULL(permission->value);
80         FREE_AND_NULL(permission);
81 }
82
83 static void __ps_free_icon(icon_x *icon)
84 {
85         if (icon == NULL)
86                 return;
87         FREE_AND_NULL(icon->text);
88         FREE_AND_NULL(icon->lang);
89         FREE_AND_NULL(icon->name);
90         FREE_AND_NULL(icon->section);
91         FREE_AND_NULL(icon->size);
92         FREE_AND_NULL(icon->resolution);
93         FREE_AND_NULL(icon);
94 }
95
96 static void __ps_free_image(image_x *image)
97 {
98         if (image == NULL)
99                 return;
100         FREE_AND_NULL(image->text);
101         FREE_AND_NULL(image->lang);
102         FREE_AND_NULL(image->name);
103         FREE_AND_NULL(image->section);
104         FREE_AND_NULL(image);
105 }
106
107 static void __ps_free_operation(operation_x *operation)
108 {
109         if (operation == NULL)
110                 return;
111         FREE_AND_NULL(operation->text);
112         FREE_AND_NULL(operation);
113 }
114
115 static void __ps_free_uri(uri_x *uri)
116 {
117         if (uri == NULL)
118                 return;
119         FREE_AND_NULL(uri->text);
120         FREE_AND_NULL(uri);
121 }
122
123 static void __ps_free_mime(mime_x *mime)
124 {
125         if (mime == NULL)
126                 return;
127         FREE_AND_NULL(mime->text);
128         FREE_AND_NULL(mime);
129 }
130
131 static void __ps_free_subapp(subapp_x *subapp)
132 {
133         if (subapp == NULL)
134                 return;
135         FREE_AND_NULL(subapp->text);
136         FREE_AND_NULL(subapp);
137 }
138
139 static void __ps_free_condition(condition_x *condition)
140 {
141         if (condition == NULL)
142                 return;
143         FREE_AND_NULL(condition->text);
144         FREE_AND_NULL(condition->name);
145         FREE_AND_NULL(condition);
146 }
147
148 static void __ps_free_notification(notification_x *notification)
149 {
150         if (notification == NULL)
151                 return;
152         FREE_AND_NULL(notification->text);
153         FREE_AND_NULL(notification->name);
154         FREE_AND_NULL(notification);
155 }
156
157 static void __ps_free_compatibility(compatibility_x *compatibility)
158 {
159         if (compatibility == NULL)
160                 return;
161         FREE_AND_NULL(compatibility->text);
162         FREE_AND_NULL(compatibility->name);
163         FREE_AND_NULL(compatibility);
164 }
165
166 static void __ps_free_allowed(allowed_x *allowed)
167 {
168         if (allowed == NULL)
169                 return;
170         FREE_AND_NULL(allowed->name);
171         FREE_AND_NULL(allowed->text);
172         FREE_AND_NULL(allowed);
173 }
174
175 static void __ps_free_request(request_x *request)
176 {
177         if (request == NULL)
178                 return;
179         FREE_AND_NULL(request->text);
180         FREE_AND_NULL(request);
181 }
182
183 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
184 {
185         if (datacontrol == NULL)
186                 return;
187         FREE_AND_NULL(datacontrol->providerid);
188         FREE_AND_NULL(datacontrol->access);
189         FREE_AND_NULL(datacontrol->type);
190         FREE_AND_NULL(datacontrol);
191 }
192
193 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
194 {
195         if (launchconditions == NULL)
196                 return;
197         FREE_AND_NULL(launchconditions->text);
198         /*Free Condition*/
199         if (launchconditions->condition) {
200                 condition_x *condition = launchconditions->condition;
201                 condition_x *tmp = NULL;
202                 while(condition != NULL) {
203                         tmp = condition->next;
204                         __ps_free_condition(condition);
205                         condition = tmp;
206                 }
207         }
208         FREE_AND_NULL(launchconditions);
209 }
210
211 static void __ps_free_appsvc(appsvc_x *appsvc)
212 {
213         if (appsvc == NULL)
214                 return;
215         FREE_AND_NULL(appsvc->text);
216         /*Free Operation*/
217         if (appsvc->operation) {
218                 operation_x *operation = appsvc->operation;
219                 operation_x *tmp = NULL;
220                 while(operation != NULL) {
221                         tmp = operation->next;
222                         __ps_free_operation(operation);
223                         operation = tmp;
224                 }
225         }
226         /*Free Uri*/
227         if (appsvc->uri) {
228                 uri_x *uri = appsvc->uri;
229                 uri_x *tmp = NULL;
230                 while(uri != NULL) {
231                         tmp = uri->next;
232                         __ps_free_uri(uri);
233                         uri = tmp;
234                 }
235         }
236         /*Free Mime*/
237         if (appsvc->mime) {
238                 mime_x *mime = appsvc->mime;
239                 mime_x *tmp = NULL;
240                 while(mime != NULL) {
241                         tmp = mime->next;
242                         __ps_free_mime(mime);
243                         mime = tmp;
244                 }
245         }
246         /*Free subapp*/
247         if (appsvc->subapp) {
248                 subapp_x *subapp = appsvc->subapp;
249                 subapp_x *tmp = NULL;
250                 while(subapp != NULL) {
251                         tmp = subapp->next;
252                         __ps_free_subapp(subapp);
253                         subapp = tmp;
254                 }
255         }
256         FREE_AND_NULL(appsvc);
257 }
258
259 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
260 {
261         return;
262 }
263
264 static void __ps_free_define(define_x *define)
265 {
266         if (define == NULL)
267                 return;
268         FREE_AND_NULL(define->path);
269         /*Free Request*/
270         if (define->request) {
271                 request_x *request = define->request;
272                 request_x *tmp = NULL;
273                 while(request != NULL) {
274                         tmp = request->next;
275                         __ps_free_request(request);
276                         request = tmp;
277                 }
278         }
279         /*Free Allowed*/
280         if (define->allowed) {
281                 allowed_x *allowed = define->allowed;
282                 allowed_x *tmp = NULL;
283                 while(allowed != NULL) {
284                         tmp = allowed->next;
285                         __ps_free_allowed(allowed);
286                         allowed = tmp;
287                 }
288         }
289         FREE_AND_NULL(define);
290 }
291
292 static void __ps_free_datashare(datashare_x *datashare)
293 {
294         if (datashare == NULL)
295                 return;
296         /*Free Define*/
297         if (datashare->define) {
298                 define_x *define =  datashare->define;
299                 define_x *tmp = NULL;
300                 while(define != NULL) {
301                         tmp = define->next;
302                         __ps_free_define(define);
303                         define = tmp;
304                 }
305         }
306         /*Free Request*/
307         if (datashare->request) {
308                 request_x *request = datashare->request;
309                 request_x *tmp = NULL;
310                 while(request != NULL) {
311                         tmp = request->next;
312                         __ps_free_request(request);
313                         request = tmp;
314                 }
315         }
316         FREE_AND_NULL(datashare);
317 }
318
319 static void __ps_free_label(label_x *label)
320 {
321         if (label == NULL)
322                 return;
323         FREE_AND_NULL(label->name);
324         FREE_AND_NULL(label->text);
325         FREE_AND_NULL(label->lang);
326         FREE_AND_NULL(label);
327 }
328
329 static void __ps_free_author(author_x *author)
330 {
331         if (author == NULL)
332                 return;
333         FREE_AND_NULL(author->email);
334         FREE_AND_NULL(author->text);
335         FREE_AND_NULL(author->href);
336         FREE_AND_NULL(author->lang);
337         FREE_AND_NULL(author);
338 }
339
340 static void __ps_free_description(description_x *description)
341 {
342         if (description == NULL)
343                 return;
344         FREE_AND_NULL(description->name);
345         FREE_AND_NULL(description->text);
346         FREE_AND_NULL(description->lang);
347         FREE_AND_NULL(description);
348 }
349
350 static void __ps_free_license(license_x *license)
351 {
352         if (license == NULL)
353                 return;
354         FREE_AND_NULL(license->text);
355         FREE_AND_NULL(license->lang);
356         FREE_AND_NULL(license);
357 }
358
359 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
360 {
361         if (uiapplication == NULL)
362                 return;
363         FREE_AND_NULL(uiapplication->exec);
364         FREE_AND_NULL(uiapplication->ambient_support);
365         FREE_AND_NULL(uiapplication->appid);
366         FREE_AND_NULL(uiapplication->nodisplay);
367         FREE_AND_NULL(uiapplication->multiple);
368         FREE_AND_NULL(uiapplication->type);
369         FREE_AND_NULL(uiapplication->categories);
370         FREE_AND_NULL(uiapplication->extraid);
371         FREE_AND_NULL(uiapplication->taskmanage);
372         FREE_AND_NULL(uiapplication->enabled);
373         FREE_AND_NULL(uiapplication->hwacceleration);
374         FREE_AND_NULL(uiapplication->screenreader);
375         FREE_AND_NULL(uiapplication->mainapp);
376         FREE_AND_NULL(uiapplication->recentimage);
377         FREE_AND_NULL(uiapplication->package);
378         FREE_AND_NULL(uiapplication->launchcondition);
379         FREE_AND_NULL(uiapplication->multi_instance);
380         FREE_AND_NULL(uiapplication->multi_instance_mainid);
381         FREE_AND_NULL(uiapplication->multi_window);
382         FREE_AND_NULL(uiapplication->support_disable);
383         FREE_AND_NULL(uiapplication->ui_gadget);
384         FREE_AND_NULL(uiapplication->removable);
385         FREE_AND_NULL(uiapplication->support_mode);
386         FREE_AND_NULL(uiapplication->support_feature);
387         FREE_AND_NULL(uiapplication->satui_label);
388         FREE_AND_NULL(uiapplication->package_type);
389         FREE_AND_NULL(uiapplication->package_system);
390         FREE_AND_NULL(uiapplication->package_installed_time);
391
392         /*Free Label*/
393         if (uiapplication->label) {
394                 label_x *label = uiapplication->label;
395                 label_x *tmp = NULL;
396                 while(label != NULL) {
397                         tmp = label->next;
398                         __ps_free_label(label);
399                         label = tmp;
400                 }
401         }
402         /*Free Icon*/
403         if (uiapplication->icon) {
404                 icon_x *icon = uiapplication->icon;
405                 icon_x *tmp = NULL;
406                 while(icon != NULL) {
407                         tmp = icon->next;
408                         __ps_free_icon(icon);
409                         icon = tmp;
410                 }
411         }
412         /*Free image*/
413         if (uiapplication->image) {
414                 image_x *image = uiapplication->image;
415                 image_x *tmp = NULL;
416                 while(image != NULL) {
417                         tmp = image->next;
418                         __ps_free_image(image);
419                         image = tmp;
420                 }
421         }
422         /*Free LaunchConditions*/
423         if (uiapplication->launchconditions) {
424                 launchconditions_x *launchconditions = uiapplication->launchconditions;
425                 launchconditions_x *tmp = NULL;
426                 while(launchconditions != NULL) {
427                         tmp = launchconditions->next;
428                         __ps_free_launchconditions(launchconditions);
429                         launchconditions = tmp;
430                 }
431         }
432         /*Free Notification*/
433         if (uiapplication->notification) {
434                 notification_x *notification = uiapplication->notification;
435                 notification_x *tmp = NULL;
436                 while(notification != NULL) {
437                         tmp = notification->next;
438                         __ps_free_notification(notification);
439                         notification = tmp;
440                 }
441         }
442         /*Free DataShare*/
443         if (uiapplication->datashare) {
444                 datashare_x *datashare = uiapplication->datashare;
445                 datashare_x *tmp = NULL;
446                 while(datashare != NULL) {
447                         tmp = datashare->next;
448                         __ps_free_datashare(datashare);
449                         datashare = tmp;
450                 }
451         }
452         /*Free AppSvc*/
453         if (uiapplication->appsvc) {
454                 appsvc_x *appsvc = uiapplication->appsvc;
455                 appsvc_x *tmp = NULL;
456                 while(appsvc != NULL) {
457                         tmp = appsvc->next;
458                         __ps_free_appsvc(appsvc);
459                         appsvc = tmp;
460                 }
461         }
462         /*Free Category*/
463         if (uiapplication->category) {
464                 category_x *category = uiapplication->category;
465                 category_x *tmp = NULL;
466                 while(category != NULL) {
467                         tmp = category->next;
468                         __ps_free_category(category);
469                         category = tmp;
470                 }
471         }
472         /*Free Metadata*/
473         if (uiapplication->metadata) {
474                 metadata_x *metadata = uiapplication->metadata;
475                 metadata_x *tmp = NULL;
476                 while(metadata != NULL) {
477                         tmp = metadata->next;
478                         __ps_free_metadata(metadata);
479                         metadata = tmp;
480                 }
481         }
482         /*Free permission*/
483         if (uiapplication->permission) {
484                 permission_x *permission = uiapplication->permission;
485                 permission_x *tmp = NULL;
486                 while(permission != NULL) {
487                         tmp = permission->next;
488                         __ps_free_permission(permission);
489                         permission = tmp;
490                 }
491         }
492
493         /*Free datacontrol*/
494         if (uiapplication->datacontrol) {
495                 datacontrol_x *datacontrol = uiapplication->datacontrol;
496                 datacontrol_x *tmp = NULL;
497                 while(datacontrol != NULL) {
498                         tmp = datacontrol->next;
499                         __ps_free_datacontrol(datacontrol);
500                         datacontrol = tmp;
501                 }
502         }
503
504         /* _PRODUCT_LAUNCHING_ENHANCED_ START */
505         FREE_AND_NULL(uiapplication->indicatordisplay);
506         FREE_AND_NULL(uiapplication->portraitimg);
507         FREE_AND_NULL(uiapplication->landscapeimg);
508         FREE_AND_NULL(uiapplication->effectimage_type);
509         /* _PRODUCT_LAUNCHING_ENHANCED_ END */
510         FREE_AND_NULL(uiapplication->guestmode_visibility);
511         FREE_AND_NULL(uiapplication->app_component);
512         FREE_AND_NULL(uiapplication->permission_type);
513         FREE_AND_NULL(uiapplication->component_type);
514         FREE_AND_NULL(uiapplication->preload);
515         FREE_AND_NULL(uiapplication->submode);
516         FREE_AND_NULL(uiapplication->submode_mainid);
517         FREE_AND_NULL(uiapplication->installed_storage);
518         FREE_AND_NULL(uiapplication->process_pool);
519         FREE_AND_NULL(uiapplication->autorestart);
520         FREE_AND_NULL(uiapplication->onboot);
521
522         FREE_AND_NULL(uiapplication);
523 }
524
525 static void __ps_free_font(font_x *font)
526 {
527         if (font == NULL)
528                 return;
529         FREE_AND_NULL(font->name);
530         FREE_AND_NULL(font->text);
531         FREE_AND_NULL(font);
532 }
533
534 static void __ps_free_theme(theme_x *theme)
535 {
536         if (theme == NULL)
537                 return;
538         FREE_AND_NULL(theme->name);
539         FREE_AND_NULL(theme->text);
540         FREE_AND_NULL(theme);
541 }
542
543 static void __ps_free_daemon(daemon_x *daemon)
544 {
545         if (daemon == NULL)
546                 return;
547         FREE_AND_NULL(daemon->name);
548         FREE_AND_NULL(daemon->text);
549         FREE_AND_NULL(daemon);
550 }
551
552 static void __ps_free_ime(ime_x *ime)
553 {
554         if (ime == NULL)
555                 return;
556         FREE_AND_NULL(ime->name);
557         FREE_AND_NULL(ime->text);
558         FREE_AND_NULL(ime);
559 }
560
561 API void _pkgmgrinfo_basic_free_manifest_x(manifest_x *mfx)
562 {
563         if (mfx == NULL)
564                 return;
565         FREE_AND_NULL(mfx->ns);
566         FREE_AND_NULL(mfx->package);
567         FREE_AND_NULL(mfx->version);
568         FREE_AND_NULL(mfx->installlocation);
569         FREE_AND_NULL(mfx->preload);
570         FREE_AND_NULL(mfx->readonly);
571         FREE_AND_NULL(mfx->removable);
572         FREE_AND_NULL(mfx->update);
573         FREE_AND_NULL(mfx->system);
574         FREE_AND_NULL(mfx->hash);
575         FREE_AND_NULL(mfx->type);
576         FREE_AND_NULL(mfx->package_size);
577         FREE_AND_NULL(mfx->package_total_size);
578         FREE_AND_NULL(mfx->package_data_size);
579         FREE_AND_NULL(mfx->installed_time);
580         FREE_AND_NULL(mfx->installed_storage);
581         FREE_AND_NULL(mfx->storeclient_id);
582         FREE_AND_NULL(mfx->mainapp_id);
583         FREE_AND_NULL(mfx->package_url);
584         FREE_AND_NULL(mfx->root_path);
585         FREE_AND_NULL(mfx->csc_path);
586         FREE_AND_NULL(mfx->appsetting);
587         FREE_AND_NULL(mfx->nodisplay_setting);
588         FREE_AND_NULL(mfx->support_disable);
589         FREE_AND_NULL(mfx->mother_package);
590         FREE_AND_NULL(mfx->support_mode);
591         FREE_AND_NULL(mfx->groupid);
592         FREE_AND_NULL(mfx->support_reset);
593         FREE_AND_NULL(mfx->use_reset);
594
595         /*Free Icon*/
596         if (mfx->icon) {
597                 icon_x *icon = mfx->icon;
598                 icon_x *tmp = NULL;
599                 while(icon != NULL) {
600                         tmp = icon->next;
601                         __ps_free_icon(icon);
602                         icon = tmp;
603                 }
604         }
605         /*Free Label*/
606         if (mfx->label) {
607                 label_x *label = mfx->label;
608                 label_x *tmp = NULL;
609                 while(label != NULL) {
610                         tmp = label->next;
611                         __ps_free_label(label);
612                         label = tmp;
613                 }
614         }
615         /*Free Author*/
616         if (mfx->author) {
617                 author_x *author = mfx->author;
618                 author_x *tmp = NULL;
619                 while(author != NULL) {
620                         tmp = author->next;
621                         __ps_free_author(author);
622                         author = tmp;
623                 }
624         }
625         /*Free Description*/
626         if (mfx->description) {
627                 description_x *description = mfx->description;
628                 description_x *tmp = NULL;
629                 while(description != NULL) {
630                         tmp = description->next;
631                         __ps_free_description(description);
632                         description = tmp;
633                 }
634         }
635         /*Free License*/
636         if (mfx->license) {
637                 license_x *license = mfx->license;
638                 license_x *tmp = NULL;
639                 while(license != NULL) {
640                         tmp = license->next;
641                         __ps_free_license(license);
642                         license = tmp;
643                 }
644         }
645         /*Free Privileges*/
646         if (mfx->privileges) {
647                 privileges_x *privileges = mfx->privileges;
648                 privileges_x *tmp = NULL;
649                 while(privileges != NULL) {
650                         tmp = privileges->next;
651                         __ps_free_privileges(privileges);
652                         privileges = tmp;
653                 }
654         }
655         /*Free UiApplication*/
656         if (mfx->uiapplication) {
657                 uiapplication_x *uiapplication = mfx->uiapplication;
658                 uiapplication_x *tmp = NULL;
659                 while(uiapplication != NULL) {
660                         tmp = uiapplication->next;
661                         __ps_free_uiapplication(uiapplication);
662                         uiapplication = tmp;
663                 }
664         }
665         /*Free Daemon*/
666         if (mfx->daemon) {
667                 daemon_x *daemon = mfx->daemon;
668                 daemon_x *tmp = NULL;
669                 while(daemon != NULL) {
670                         tmp = daemon->next;
671                         __ps_free_daemon(daemon);
672                         daemon = tmp;
673                 }
674         }
675         /*Free Theme*/
676         if (mfx->theme) {
677                 theme_x *theme = mfx->theme;
678                 theme_x *tmp = NULL;
679                 while(theme != NULL) {
680                         tmp = theme->next;
681                         __ps_free_theme(theme);
682                         theme = tmp;
683                 }
684         }
685         /*Free Font*/
686         if (mfx->font) {
687                 font_x *font = mfx->font;
688                 font_x *tmp = NULL;
689                 while(font != NULL) {
690                         tmp = font->next;
691                         __ps_free_font(font);
692                         font = tmp;
693                 }
694         }
695         /*Free Ime*/
696         if (mfx->ime) {
697                 ime_x *ime = mfx->ime;
698                 ime_x *tmp = NULL;
699                 while(ime != NULL) {
700                         tmp = ime->next;
701                         __ps_free_ime(ime);
702                         ime = tmp;
703                 }
704         }
705         /*Free Compatibility*/
706         if (mfx->compatibility) {
707                 compatibility_x *compatibility = mfx->compatibility;
708                 compatibility_x *tmp = NULL;
709                 while(compatibility != NULL) {
710                         tmp = compatibility->next;
711                         __ps_free_compatibility(compatibility);
712                         compatibility = tmp;
713                 }
714         }
715         /*Free DeviceProfile*/
716         if (mfx->deviceprofile) {
717                 deviceprofile_x *deviceprofile = mfx->deviceprofile;
718                 deviceprofile_x *tmp = NULL;
719                 while(deviceprofile != NULL) {
720                         tmp = deviceprofile->next;
721                         __ps_free_deviceprofile(deviceprofile);
722                         deviceprofile = tmp;
723                 }
724         }
725         FREE_AND_NULL(mfx);
726         return;
727 }
728
729 API char*  pkgmgrinfo_basic_generate_hash_for_file( const char *file)
730 {
731
732         unsigned char c[MD5_DIGEST_LENGTH] = {0};
733         char *hash = NULL;
734         char temp[3]={0};
735         int index = 0;
736         MD5_CTX mdContext;
737         int bytes;
738         unsigned char data[1024];
739
740         FILE *inFile = fopen (file, "rb");
741
742         if (inFile == NULL) {
743                 _LOGD("@Error while opening the file: %s",strerror(errno));
744                 return NULL;
745         }
746
747         MD5_Init (&mdContext);
748
749         while ((bytes = fread (data, 1, 1024, inFile)) != 0)
750                 MD5_Update (&mdContext, data, bytes);
751
752         MD5_Final (c,&mdContext);
753
754         hash = (char*)malloc(HASH_LEN + 1);
755         if(hash == NULL){
756                 _LOGE("Malloc failed!!");
757                 goto catch;
758         }
759         memset(hash,'\0',HASH_LEN + 1);
760
761         for(index = 0; index < MD5_DIGEST_LENGTH; index++) {
762                 sprintf(temp,"%02x",c[index]);
763                 strncat(hash,temp,strlen(temp));
764
765         }
766
767 catch:
768         if(inFile)
769                 fclose (inFile);
770
771         return hash;
772 }