1*9b0c212aSAxel Dörfler /* 2*9b0c212aSAxel Dörfler * Copyright (c) 2001-2005, Haiku. 3*9b0c212aSAxel Dörfler * 4*9b0c212aSAxel Dörfler * This software is part of the Haiku distribution and is covered 5*9b0c212aSAxel Dörfler * by the MIT license. 6*9b0c212aSAxel Dörfler * 7*9b0c212aSAxel Dörfler * Author: Daniel Reinhold (danielre@users.sf.net) 8*9b0c212aSAxel Dörfler */ 9*9b0c212aSAxel Dörfler 10*9b0c212aSAxel Dörfler /** Description: lists image info for all currently running teams */ 1117049c45SAxel Dörfler 1217049c45SAxel Dörfler 1317049c45SAxel Dörfler #include <OS.h> 1417049c45SAxel Dörfler #include <image.h> 1517049c45SAxel Dörfler 1617049c45SAxel Dörfler #include <stdio.h> 1717049c45SAxel Dörfler #include <stdlib.h> 1817049c45SAxel Dörfler #include <string.h> 1917049c45SAxel Dörfler #include <ctype.h> 2017049c45SAxel Dörfler 2117049c45SAxel Dörfler 2217049c45SAxel Dörfler static status_t 2317049c45SAxel Dörfler list_images_for_team_by_id(team_id id) 2417049c45SAxel Dörfler { 2517049c45SAxel Dörfler team_info teamInfo; 2617049c45SAxel Dörfler image_info imageInfo; 2717049c45SAxel Dörfler int32 cookie = 0; 2817049c45SAxel Dörfler status_t status; 2917049c45SAxel Dörfler 3017049c45SAxel Dörfler status = get_team_info(id, &teamInfo); 3117049c45SAxel Dörfler if (id != 1 && status < B_OK) 3217049c45SAxel Dörfler return status; 3317049c45SAxel Dörfler 3417049c45SAxel Dörfler if (id == 1) 3517049c45SAxel Dörfler printf("\nKERNEL TEAM:\n"); 3617049c45SAxel Dörfler else 3717049c45SAxel Dörfler printf("\nTEAM %4ld (%s):\n", id, teamInfo.args); 3817049c45SAxel Dörfler printf(" ID name text data seq# init#\n"); 3917049c45SAxel Dörfler printf("------------------------------------------------------------------------------------------------------------\n"); 4017049c45SAxel Dörfler 4117049c45SAxel Dörfler while ((status = get_next_image_info(id, &cookie, &imageInfo)) == B_OK) { 42*9b0c212aSAxel Dörfler printf("%5ld %64s %p %p %4ld %10lu\n", 4317049c45SAxel Dörfler imageInfo.id, 4417049c45SAxel Dörfler imageInfo.name, 45*9b0c212aSAxel Dörfler imageInfo.text, 46*9b0c212aSAxel Dörfler imageInfo.data, 4717049c45SAxel Dörfler imageInfo.sequence, 4817049c45SAxel Dörfler imageInfo.init_order); 4917049c45SAxel Dörfler } 5017049c45SAxel Dörfler if (status != B_ENTRY_NOT_FOUND && status != EINVAL) { 5117049c45SAxel Dörfler printf("get images failed: %s\n", strerror(status)); 5217049c45SAxel Dörfler return status; 5317049c45SAxel Dörfler } 5417049c45SAxel Dörfler return B_OK; 5517049c45SAxel Dörfler } 5617049c45SAxel Dörfler 5717049c45SAxel Dörfler 5817049c45SAxel Dörfler static void 5917049c45SAxel Dörfler list_images_for_team(const char *arg) 6017049c45SAxel Dörfler { 6117049c45SAxel Dörfler int32 cookie = 0; 6217049c45SAxel Dörfler team_info info; 6317049c45SAxel Dörfler 6417049c45SAxel Dörfler if (atoi(arg) > 0) { 6517049c45SAxel Dörfler if (list_images_for_team_by_id(atoi(arg)) == B_OK) 6617049c45SAxel Dörfler return; 6717049c45SAxel Dörfler } 6817049c45SAxel Dörfler 6917049c45SAxel Dörfler // search for the team by name 7017049c45SAxel Dörfler 7117049c45SAxel Dörfler while (get_next_team_info(&cookie, &info) >= B_OK) { 7217049c45SAxel Dörfler if (strstr(info.args, arg)) { 7317049c45SAxel Dörfler status_t status = list_images_for_team_by_id(info.team); 7417049c45SAxel Dörfler if (status != B_OK) 7517049c45SAxel Dörfler printf("\nCould not retrieve information about team %ld: %s\n", 7617049c45SAxel Dörfler info.team, strerror(status)); 7717049c45SAxel Dörfler } 7817049c45SAxel Dörfler } 7917049c45SAxel Dörfler } 8017049c45SAxel Dörfler 8117049c45SAxel Dörfler 8217049c45SAxel Dörfler int 8317049c45SAxel Dörfler main(int argc, char **argv) 8417049c45SAxel Dörfler { 8517049c45SAxel Dörfler if (argc == 1) { 8617049c45SAxel Dörfler int32 cookie = 0; 8717049c45SAxel Dörfler team_info info; 8817049c45SAxel Dörfler 8917049c45SAxel Dörfler // list for all teams 9017049c45SAxel Dörfler while (get_next_team_info(&cookie, &info) >= B_OK) { 9117049c45SAxel Dörfler status_t status = list_images_for_team_by_id(info.team); 9217049c45SAxel Dörfler if (status != B_OK) 9317049c45SAxel Dörfler printf("\nCould not retrieve information about team %ld: %s\n", 9417049c45SAxel Dörfler info.team, strerror(status)); 9517049c45SAxel Dörfler } 9617049c45SAxel Dörfler } else { 9717049c45SAxel Dörfler // list for each team_id on the command line 9817049c45SAxel Dörfler while (--argc) 9917049c45SAxel Dörfler list_images_for_team(*++argv); 10017049c45SAxel Dörfler } 10117049c45SAxel Dörfler return 0; 10217049c45SAxel Dörfler } 10317049c45SAxel Dörfler 104