/* Parse argv */
optind = 1; /* Initialize optind to clear prev. index */
- while (1) {
- c = getopt_long(argc, argv, "", long_opts, &opt_idx);
- if (-1 == c) {
- usage();
- break; /* Parse is end */
- }
- switch (c) {
- case OPTVAL_PRE_INSTALL:
- pre_app_install();
- break;
- case OPTVAL_POST_INSTALL:
- post_app_install();
- break;
- case OPTVAL_PRE_UNINSTALL:
- pre_app_uninstall();
- break;
- case OPTVAL_POST_UNINSTALL:
- post_app_uninstall();
- break;
- case OPTVAL_PRE_UPGRADE:
- pre_app_upgrade();
- break;
- case OPTVAL_POST_UPGRADE:
- post_app_upgrade();
- break;
- case OPTVAL_MOVE_TO_EXTERNAL:
- app_move_to_external();
- break;
- case OPTVAL_MOVE_TO_INTERNAL:
- app_move_to_internal();
- break;
- case OPTVAL_ENABLE_APP:
- app_enable();
- break;
- case OPTVAL_DISABLE_APP:
- app_disable();
- break;
- case OPTVAL_ENABLE_FULL:
- fullpkg_enable();
- break;
- case OPTVAL_DISABLE_FULL:
- fullpkg_disable();
- break;
- case OPTVAL_MIGRATE_ALL:
- migrate_all();
- break;
- case OPTVAL_USAGE:
- default:
- usage();
- break;
- }
-
+ c = getopt_long(argc, argv, "", long_opts, &opt_idx);
+ if (-1 == c) {
+ usage();
+ app2ext_deinit(handle);
+ return 0; /* Parse is end */
+ }
+ switch (c) {
+ case OPTVAL_PRE_INSTALL:
+ pre_app_install();
+ break;
+ case OPTVAL_POST_INSTALL:
+ post_app_install();
+ break;
+ case OPTVAL_PRE_UNINSTALL:
+ pre_app_uninstall();
+ break;
+ case OPTVAL_POST_UNINSTALL:
+ post_app_uninstall();
+ break;
+ case OPTVAL_PRE_UPGRADE:
+ pre_app_upgrade();
+ break;
+ case OPTVAL_POST_UPGRADE:
+ post_app_upgrade();
+ break;
+ case OPTVAL_MOVE_TO_EXTERNAL:
+ app_move_to_external();
+ break;
+ case OPTVAL_MOVE_TO_INTERNAL:
+ app_move_to_internal();
+ break;
+ case OPTVAL_ENABLE_APP:
+ app_enable();
+ break;
+ case OPTVAL_DISABLE_APP:
+ app_disable();
+ break;
+ case OPTVAL_ENABLE_FULL:
+ fullpkg_enable();
+ break;
+ case OPTVAL_DISABLE_FULL:
+ fullpkg_disable();
+ break;
+ case OPTVAL_MIGRATE_ALL:
+ migrate_all();
+ break;
+ case OPTVAL_USAGE:
+ default:
+ usage();
break;
}