Changeset 13538 for trunk/Ohana/src/opihi/cmd.basic/list.c
- Timestamp:
- May 30, 2007, 12:10:43 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.basic/list.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.basic/list.c
r11386 r13538 55 55 56 56 return (TRUE); 57 } 58 59 // remove the single named entry from the list (finds entry with given name, reduces list length by one) 60 // return an error if -add is given with no other args 61 if ((argc > 2) && (!strcmp (argv[2], "-del"))) { 62 if (argc != 4) { 63 gprint (GP_ERR, "USAGE: list (root) -del (word)\n"); 64 return (FALSE); 65 } 66 67 int j; 68 char *value, *next_value; 69 char line2[1024]; 70 71 sprintf (line, "%s:n", argv[1]); 72 N = get_int_variable (line, &found); 73 for (i = 0; i < N; i++) { 74 sprintf (line, "%s:%d", argv[1], i); 75 value = get_variable (line); 76 if (value == NULL) continue; 77 if (!strcmp (value, argv[3])) { 78 free (value); 79 for (j = i + 1; j < N; j++) { 80 sprintf (line2, "%s:%d", argv[1], j); 81 next_value = get_variable (line2); 82 set_str_variable (line, next_value); 83 strcpy (line, line2); 84 } 85 DeleteNamedScalar (line); 86 sprintf (line2, "%s:n", argv[1]); 87 set_int_variable (line2, N - 1); 88 return (TRUE); 89 } 90 free (value); 91 } 92 gprint (GP_ERR, "value %s not found in list\n", argv[3]); 93 return (FALSE); 57 94 } 58 95
Note:
See TracChangeset
for help on using the changeset viewer.
