static char *pin_generator(const char *text, int state) { static int len; static int next; static int aliased; char *name; if(!state) { next = hal_data->pin_list_ptr; len = strlen(text); aliased = 0; } while(next) { hal_pin_t *pin = SHMPTR(next); switch (aliased) { case 0: // alias (if any) has not been output if (pin->oldname != 0) { // there's an alias, so use that and do not update the pin pointer hal_oldname_t *oldname = SHMPTR(pin->oldname); name = oldname->name; aliased = 1; } else { // no alias, so use the name and update the pin pointer name = pin->name; next = pin->next_ptr; } break; case 1: // there is an alias, and it has been processed already name = pin->name; next = pin->next_ptr; aliased = 0; break; default: // shouldn't be able to get here, so assume we're done rl_attempted_completion_over = 1; return NULL; break; } if ( !writer_match( pin->dir, match_writers ) ) continue; if ( !direction_match( pin->dir, match_direction ) ) continue; if ( match_type != HAL_TYPE_UNSPECIFIED && match_type != pin->type ) continue; if ( strncmp(text, name, len) == 0 ) return strdup(name); } rl_attempted_completion_over = 1; return NULL; }
static int yield_pinstrname(hal_object_ptr o, foreach_args_t *args) { if ( !writer_match( o.pin->dir, match_writers ) ) return 0; if ( !direction_match( o.pin->dir, match_direction ) ) return 0; if ( match_type != HAL_TYPE_UNSPECIFIED && match_type != o.pin->type ) return 0; size_t len = strlen(args->user_ptr1); if ((len == 0) || !strncmp(hh_get_name(o.hdr), // prefix match args->user_ptr1, len)) { args->result = strdup(hh_get_name(o.hdr)); return 1; } return 0; }