@@ -68,6 +68,8 @@ static void print_script_sig_info(int type, char **patterns);
6868static void print_param_info (int type, char **patterns);
6969static void print_funct_info (char **patterns);
7070static void print_thread_info (char **patterns);
71+ static void print_struct_info (char **patterns);
72+ static void print_struct_names (char **patterns);
7173static void print_comp_names (char **patterns);
7274static void print_pin_names (char **patterns);
7375static void print_sig_names (char **patterns);
@@ -1022,6 +1024,7 @@ int do_show_cmd(char *type, char **patterns)
10221024 print_param_aliases (NULL );
10231025 print_funct_info (NULL );
10241026 print_thread_info (NULL );
1027+ print_struct_info (NULL );
10251028 } else if (strcmp (type, " all" ) == 0 ) {
10261029 /* print everything, using the pattern */
10271030 print_comp_info (patterns);
@@ -1032,6 +1035,7 @@ int do_show_cmd(char *type, char **patterns)
10321035 print_param_aliases (patterns);
10331036 print_funct_info (patterns);
10341037 print_thread_info (patterns);
1038+ print_struct_info (patterns);
10351039 } else if (strcmp (type, " comp" ) == 0 ) {
10361040 print_comp_info (patterns);
10371041 } else if (strcmp (type, " pin" ) == 0 ) {
@@ -1055,6 +1059,8 @@ int do_show_cmd(char *type, char **patterns)
10551059 print_funct_info (patterns);
10561060 } else if (strcmp (type, " thread" ) == 0 ) {
10571061 print_thread_info (patterns);
1062+ } else if (strcmp (type, " struct" ) == 0 ) {
1063+ print_struct_info (patterns);
10581064 } else if (strcmp (type, " alias" ) == 0 ) {
10591065 print_pin_aliases (patterns);
10601066 print_param_aliases (patterns);
@@ -1093,6 +1099,8 @@ int do_list_cmd(char *type, char **patterns)
10931099 print_funct_names (patterns);
10941100 } else if (strcmp (type, " thread" ) == 0 ) {
10951101 print_thread_names (patterns);
1102+ } else if (strcmp (type, " struct" ) == 0 ) {
1103+ print_struct_names (patterns);
10961104 } else {
10971105 halcmd_error (" Unknown 'list' type '%s'\n " , type);
10981106 return -1 ;
@@ -2067,6 +2075,54 @@ static void print_thread_info(char **patterns)
20672075 halcmd_output (" \n " );
20682076}
20692077
2078+ static void print_struct_info (char **patterns)
2079+ {
2080+ SHMFIELD (hal_struct_entry_t ) next;
2081+ hal_struct_entry_t *entry;
2082+ hal_comp_t *comp;
2083+
2084+ if (scriptmode == 0 ) {
2085+ halcmd_output (" Structs:\n " );
2086+ halcmd_output (" Owner Refs Name\n " );
2087+ }
2088+ rtapi_mutex_get (&(hal_data->mutex ));
2089+ next = hal_data->struct_list_ptr ;
2090+ while (next != 0 ) {
2091+ entry = SHMPTR (next);
2092+ if ( match (patterns, entry->name ) ) {
2093+ comp = SHMPTR (entry->owner_ptr );
2094+ if (scriptmode == 0 ) {
2095+ halcmd_output (" %5d %4d %s\n " ,
2096+ comp->comp_id , entry->attach_count , entry->name );
2097+ } else {
2098+ halcmd_output (" %s %d %s\n " ,
2099+ comp->name , entry->attach_count , entry->name );
2100+ }
2101+ }
2102+ next = entry->next_ptr ;
2103+ }
2104+ rtapi_mutex_give (&(hal_data->mutex ));
2105+ halcmd_output (" \n " );
2106+ }
2107+
2108+ static void print_struct_names (char **patterns)
2109+ {
2110+ SHMFIELD (hal_struct_entry_t ) next;
2111+ hal_struct_entry_t *entry;
2112+
2113+ rtapi_mutex_get (&(hal_data->mutex ));
2114+ next = hal_data->struct_list_ptr ;
2115+ while (next != 0 ) {
2116+ entry = SHMPTR (next);
2117+ if ( match (patterns, entry->name ) ) {
2118+ halcmd_output (" %s " , entry->name );
2119+ }
2120+ next = entry->next_ptr ;
2121+ }
2122+ rtapi_mutex_give (&(hal_data->mutex ));
2123+ halcmd_output (" \n " );
2124+ }
2125+
20702126static void print_comp_names (char **patterns)
20712127{
20722128 SHMFIELD (hal_comp_t ) next;
0 commit comments