diff --git a/src/bin/listimage.c b/src/bin/listimage.c index 3a4928c007..42486eef1f 100644 --- a/src/bin/listimage.c +++ b/src/bin/listimage.c @@ -1,22 +1,21 @@ /* - * Copyright (c) 2001-2005, Haiku. + * Copyright (c) 2001-2005 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. * - * This software is part of the Haiku distribution and is covered - * by the MIT license. - * - * Author: Daniel Reinhold (danielre@users.sf.net) + * Authors: + * Daniel Reinhold, danielre@users.sf.net */ -/** Description: lists image info for all currently running teams */ +/*! Lists image info for all currently running teams. */ -#include +#include #include - #include #include #include -#include + +#include static status_t @@ -25,20 +24,23 @@ list_images_for_team_by_id(team_id id) team_info teamInfo; image_info imageInfo; int32 cookie = 0; - status_t status; + status_t result; - status = get_team_info(id, &teamInfo); - if (id != 1 && status < B_OK) - return status; + result = get_team_info(id, &teamInfo); + if (id != 1 && result < B_OK) + return result; if (id == 1) printf("\nKERNEL TEAM:\n"); else printf("\nTEAM %4ld (%s):\n", id, teamInfo.args); - printf(" ID name text data seq# init#\n"); - printf("------------------------------------------------------------------------------------------------------------\n"); - while ((status = get_next_image_info(id, &cookie, &imageInfo)) == B_OK) { + puts(" ID name" + " text data seq# init#"); + puts("---------------------------------------------------------------------" + "---------------------------------------"); + + while ((result = get_next_image_info(id, &cookie, &imageInfo)) == B_OK) { printf("%5ld %64s %p %p %4ld %10lu\n", imageInfo.id, imageInfo.name, @@ -47,40 +49,41 @@ list_images_for_team_by_id(team_id id) imageInfo.sequence, imageInfo.init_order); } - if (status != B_ENTRY_NOT_FOUND && status != EINVAL) { - printf("get images failed: %s\n", strerror(status)); - return status; + + if (result != B_ENTRY_NOT_FOUND && result != EINVAL) { + printf("get images failed: %s\n", strerror(result)); + return result; } + return B_OK; } static void -list_images_for_team(const char *arg) +list_images_for_team(const char* arg) { int32 cookie = 0; team_info info; - if (atoi(arg) > 0) { - if (list_images_for_team_by_id(atoi(arg)) == B_OK) - return; - } + if (atoi(arg) > 0 && list_images_for_team_by_id(atoi(arg)) == B_OK) + return; // search for the team by name while (get_next_team_info(&cookie, &info) >= B_OK) { if (strstr(info.args, arg)) { - status_t status = list_images_for_team_by_id(info.team); - if (status != B_OK) + status_t result = list_images_for_team_by_id(info.team); + if (result != B_OK) { printf("\nCould not retrieve information about team %ld: %s\n", - info.team, strerror(status)); + info.team, strerror(result)); + } } } } int -main(int argc, char **argv) +main(int argc, char** argv) { if (argc == 1) { int32 cookie = 0; @@ -88,16 +91,17 @@ main(int argc, char **argv) // list for all teams while (get_next_team_info(&cookie, &info) >= B_OK) { - status_t status = list_images_for_team_by_id(info.team); - if (status != B_OK) + status_t result = list_images_for_team_by_id(info.team); + if (result != B_OK) { printf("\nCould not retrieve information about team %ld: %s\n", - info.team, strerror(status)); + info.team, strerror(result)); + } } } else { // list for each team_id on the command line while (--argc) list_images_for_team(*++argv); } + return 0; } -