lfn
serial
ticket/834-toolchain-update
topic/msim-upgrade
topic/simplify-dev-export
|
Last change
on this file since 598e3a7 was 598e3a7, checked in by Matthieu Riolo <matthieu.riolo@…>, 7 years ago |
|
adding cmd unalias
|
-
Property mode
set to
100644
|
|
File size:
1.3 KB
|
| Line | |
|---|
| 1 | /* Automatically generated by mknewcmd on Fre Nov 30 05:45:31 CET 2018
|
|---|
| 2 | * This is machine generated output. The author of mknewcmd claims no
|
|---|
| 3 | * copyright over the contents of this file. Where legally permitted, the
|
|---|
| 4 | * contents herein are donated to the public domain.
|
|---|
| 5 | *
|
|---|
| 6 | * You should apply any license and copyright that you wish to this file,
|
|---|
| 7 | * replacing this header in its entirety. */
|
|---|
| 8 |
|
|---|
| 9 | #include <stdio.h>
|
|---|
| 10 | #include <stdlib.h>
|
|---|
| 11 | #include <adt/odict.h>
|
|---|
| 12 |
|
|---|
| 13 | #include "config.h"
|
|---|
| 14 | #include "util.h"
|
|---|
| 15 | #include "errors.h"
|
|---|
| 16 | #include "entry.h"
|
|---|
| 17 | #include "unalias.h"
|
|---|
| 18 | #include "cmds.h"
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 | static const char *cmdname = "unalias";
|
|---|
| 23 |
|
|---|
| 24 | /* Dispays help for unalias in various levels */
|
|---|
| 25 | void help_cmd_unalias(unsigned int level)
|
|---|
| 26 | {
|
|---|
| 27 | printf("This is the %s help for '%s'.\n",
|
|---|
| 28 | level ? EXT_HELP : SHORT_HELP, cmdname);
|
|---|
| 29 | return;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | /* Main entry point for unalias, accepts an array of arguments */
|
|---|
| 33 | int cmd_unalias(char **argv)
|
|---|
| 34 | {
|
|---|
| 35 |
|
|---|
| 36 | size_t i;
|
|---|
| 37 |
|
|---|
| 38 | for(i = 1; argv[i] != NULL; i++) {
|
|---|
| 39 | odlink_t *alias_link = odict_find_eq(&alias_dict, (void*)argv[i], NULL);
|
|---|
| 40 |
|
|---|
| 41 | if(alias_link == NULL) {
|
|---|
| 42 | printf("%s: No alias '%s' found\n", cmdname, argv[i]);
|
|---|
| 43 | return CMD_FAILURE;
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | alias_t *data = odict_get_instance(alias_link, alias_t, odict);
|
|---|
| 47 | odict_remove(alias_link);
|
|---|
| 48 |
|
|---|
| 49 | free(data->name);
|
|---|
| 50 | free(data->value);
|
|---|
| 51 | free(data);
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 | return CMD_SUCCESS;
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.