Forráskód Böngészése

scheme: Code cleanup

Serj Kalichev 3 éve
szülő
commit
adddeb09ab
1 módosított fájl, 0 hozzáadás és 160 törlés
  1. 0 160
      klish/kscheme/kscheme.c

+ 0 - 160
klish/kscheme/kscheme.c

@@ -331,9 +331,6 @@ bool_t kscheme_prepare(kscheme_t *scheme, kcontext_t *context, faux_error_t *err
 		// Iterate COMMANDs
 		commands_iter = kview_commands_iter(view);
 		while ((command = kview_commands_each(&commands_iter))) {
-//			kview_commands_node_t *commands_iter = NULL;
-//			kcommand_t *command = NULL;
-
 			printf("COMMAND: %s\n", kcommand_name(command));
 			// ACTIONs
 			if (!kscheme_prepare_action_list(scheme,
@@ -346,163 +343,6 @@ bool_t kscheme_prepare(kscheme_t *scheme, kcontext_t *context, faux_error_t *err
 		}
 	}
 
-#if 0
-	clish_command_t *cmd;
-	clish_view_t *view;
-	clish_nspace_t *nspace;
-	lub_list_t *view_tree, *nspace_tree;
-	lub_list_node_t *nspace_iter, *view_iter;
-	lub_bintree_t *cmd_tree;
-	lub_bintree_iterator_t cmd_iter;
-	clish_hook_access_fn_t *access_fn = NULL;
-	clish_paramv_t *paramv;
-	int i = 0;
-
-	/* Iterate the VIEWs */
-	view_tree = this->view_tree;
-	view_iter = lub_list_iterator_init(view_tree);
-	while(view_iter) {
-		lub_list_node_t *old_view_iter;
-		view = (clish_view_t *)lub_list_node__get_data(view_iter);
-		old_view_iter = view_iter;
-		view_iter = lub_list_node__get_next(view_iter);
-		/* Check access rights for the VIEW */
-		if (access_fn && clish_view__get_access(view) &&
-			access_fn(this, clish_view__get_access(view))) {
-#ifdef DEBUG
-			fprintf(stderr, "Warning: Access denied. Remove VIEW \"%s\"\n",
-				clish_view__get_name(view));
-#endif
-			lub_list_del(view_tree, old_view_iter);
-			lub_list_node_free(old_view_iter);
-			clish_view_delete(view);
-			continue;
-		}
-
-		/* Iterate the NAMESPACEs */
-		nspace_tree = clish_view__get_nspaces(view);
-		nspace_iter = lub_list__get_head(nspace_tree);
-		while(nspace_iter) {
-			clish_view_t *ref_view;
-			lub_list_node_t *old_nspace_iter;
-			nspace = (clish_nspace_t *)lub_list_node__get_data(nspace_iter);
-			old_nspace_iter = nspace_iter;
-			nspace_iter = lub_list_node__get_next(nspace_iter);
-			/* Resolve NAMESPACEs and remove unresolved ones */
-			ref_view = clish_shell_find_view(this, clish_nspace__get_view_name(nspace));
-			if (!ref_view) {
-#ifdef DEBUG
-				fprintf(stderr, "Warning: Remove unresolved NAMESPACE \"%s\" from \"%s\" VIEW\n",
-					clish_nspace__get_view_name(nspace), clish_view__get_name(view));
-#endif
-				lub_list_del(nspace_tree, old_nspace_iter);
-				lub_list_node_free(old_nspace_iter);
-				clish_nspace_delete(nspace);
-				continue;
-			}
-			clish_nspace__set_view(nspace, ref_view);
-			clish_nspace__set_view_name(nspace, NULL); /* Free some memory */
-			/* Check access rights for the NAMESPACE */
-			if (access_fn && (
-				/* Check NAMESPASE owned access */
-				(clish_nspace__get_access(nspace) && access_fn(this, clish_nspace__get_access(nspace)))
-				||
-				/* Check referenced VIEW's access */
-				(clish_view__get_access(ref_view) && access_fn(this, clish_view__get_access(ref_view)))
-				)) {
-#ifdef DEBUG
-				fprintf(stderr, "Warning: Access denied. Remove NAMESPACE \"%s\" from \"%s\" VIEW\n",
-					clish_nspace__get_view_name(nspace), clish_view__get_name(view));
-#endif
-				lub_list_del(nspace_tree, old_nspace_iter);
-				lub_list_node_free(old_nspace_iter);
-				clish_nspace_delete(nspace);
-				continue;
-			}
-		}
-
-		/* Iterate the COMMANDs */
-		cmd_tree = clish_view__get_tree(view);
-		cmd = lub_bintree_findfirst(cmd_tree);
-		for (lub_bintree_iterator_init(&cmd_iter, cmd_tree, cmd);
-			cmd; cmd = lub_bintree_iterator_next(&cmd_iter)) {
-			int cmd_is_alias = clish_command__get_alias(cmd)?1:0;
-			clish_param_t *args = NULL;
-
-			/* Check access rights for the COMMAND */
-			if (access_fn && clish_command__get_access(cmd) &&
-				access_fn(this, clish_command__get_access(cmd))) {
-#ifdef DEBUG
-				fprintf(stderr, "Warning: Access denied. Remove COMMAND \"%s\" from VIEW \"%s\"\n",
-					clish_command__get_name(cmd), clish_view__get_name(view));
-#endif
-				lub_bintree_remove(cmd_tree, cmd);
-				clish_command_delete(cmd);
-				continue;
-			}
-
-			/* Resolve command aliases */
-			if (cmd_is_alias) {
-				clish_view_t *aview;
-				clish_command_t *cmdref;
-				const char *alias_view = clish_command__get_alias_view(cmd);
-				if (!alias_view)
-					aview = clish_command__get_pview(cmd);
-				else
-					aview = clish_shell_find_view(this, alias_view);
-				if (!aview /* Removed or broken VIEW */
-					||
-					/* Removed or broken referenced COMMAND */
-					!(cmdref = clish_view_find_command(aview, clish_command__get_alias(cmd), BOOL_FALSE))
-					) {
-#ifdef DEBUG
-					fprintf(stderr, "Warning: Remove unresolved link \"%s\" from \"%s\" VIEW\n",
-						clish_command__get_name(cmd), clish_view__get_name(view));
-#endif
-					lub_bintree_remove(cmd_tree, cmd);
-					clish_command_delete(cmd);
-					continue;
-					/*fprintf(stderr, CLISH_XML_ERROR_STR"Broken VIEW for alias \"%s\"\n",
-						clish_command__get_name(cmd));
-					return -1; */
-					/*fprintf(stderr, CLISH_XML_ERROR_STR"Broken alias \"%s\"\n",
-						clish_command__get_name(cmd));
-					return -1; */
-				}
-				if (!clish_command_alias_to_link(cmd, cmdref)) {
-					fprintf(stderr, CLISH_XML_ERROR_STR"Something wrong with alias \"%s\"\n",
-						clish_command__get_name(cmd));
-					return -1;
-				}
-				/* Check access rights for newly constructed COMMAND.
-				   Now the link has access filed from referenced command.
-				 */
-				if (access_fn && clish_command__get_access(cmd) &&
-					access_fn(this, clish_command__get_access(cmd))) {
-#ifdef DEBUG
-					fprintf(stderr, "Warning: Access denied. Remove COMMAND \"%s\" from VIEW \"%s\"\n",
-						clish_command__get_name(cmd), clish_view__get_name(view));
-#endif
-					lub_bintree_remove(cmd_tree, cmd);
-					clish_command_delete(cmd);
-					continue;
-				}
-			}
-			if (cmd_is_alias) /* Don't duplicate paramv processing for aliases */
-				continue;
-			/* Iterate PARAMeters */
-			paramv = clish_command__get_paramv(cmd);
-			if (iterate_paramv(this, paramv, access_fn) < 0)
-				return -1;
-			/* Resolve PTYPE for args */
-			if ((args = clish_command__get_args(cmd))) {
-				if (!resolve_ptype(this, args))
-					return -1;
-			}
-		}
-	}
-#endif
-
 	return BOOL_TRUE;
 }