Removed warnings, minor cleanup.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11008 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-01-24 18:53:34 +00:00
parent bd1ede2ae9
commit c586de1d62
+54 -57
View File
@@ -1,53 +1,29 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ /*
// * Copyright (c) 2001-2005, Haiku.
// Copyright (c) 2001-2004, Haiku *
// * This software is part of the Haiku distribution and is covered
// This software is part of the Haiku distribution and is covered * by the MIT license.
// by the Haiku license. *
// * Author: Daniel Reinhold ([email protected])
// */
// File: listarea.c
// Author: Daniel Reinhold ([email protected]) /** Lists area info for all currently running teams */
// Description: lists area info for all currently running teams
//
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#include <OS.h> #include <OS.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
void list_area_info(team_id id); static void list_areas_for_id(team_id team);
void list_area_info_a(const char *arg); static void list_areas_for_name(const char *teamName);
void show_memory_totals(void); static void show_memory_totals(void);
int static void
main(int argc, char **argv) show_memory_totals(void)
{
show_memory_totals();
if (argc == 1) {
int32 cookie = 0;
team_info info;
// list for all teams
while (get_next_team_info(&cookie, &info) >= B_OK)
list_area_info(info.team);
} else {
// list for each team_id on the command line
while (--argc)
list_area_info_a(*++argv);
}
return 0;
}
void
show_memory_totals()
{ {
int32 max = 0, used = 0; int32 max = 0, used = 0;
@@ -62,8 +38,8 @@ show_memory_totals()
} }
void static void
list_area_info(team_id id) list_areas_for_id(team_id id)
{ {
int32 cookie = 0; int32 cookie = 0;
team_info teamInfo; team_info teamInfo;
@@ -76,14 +52,14 @@ list_area_info(team_id id)
strcpy(teamInfo.args, "KERNEL SPACE"); strcpy(teamInfo.args, "KERNEL SPACE");
printf("\n%s (team %ld)\n", teamInfo.args, id); printf("\n%s (team %ld)\n", teamInfo.args, id);
printf(" ID name address size alloc. #-cow #-in #-out\n"); printf(" ID name address size alloc. #-cow #-in #-out\n");
printf("------------------------------------------------------------------------------------\n"); printf("------------------------------------------------------------------------------------\n");
while (get_next_area_info(id, &cookie, &areaInfo) == B_OK) { while (get_next_area_info(id, &cookie, &areaInfo) == B_OK) {
printf("%5ld %32s %08lx %8lx %8lx %5ld %5ld %5ld\n", printf("%5ld %32s %08lx %8lx %8lx %5ld %5ld %5ld\n",
areaInfo.area, areaInfo.area,
areaInfo.name, areaInfo.name,
(void *)areaInfo.address, (addr_t)areaInfo.address,
areaInfo.size, areaInfo.size,
areaInfo.ram_size, areaInfo.ram_size,
areaInfo.copy_count, areaInfo.copy_count,
@@ -93,23 +69,44 @@ list_area_info(team_id id)
} }
void static void
list_area_info_a(const char *arg) list_areas_for_name(const char *name)
{ {
int32 cookie = 0; int32 cookie = 0;
team_info info; team_info info;
team_id tid;
tid = atoi(arg);
// if atoi returns >0 it's likely it's a number, else take it as string
if (tid > 0) {
list_area_info(tid);
return;
}
while (get_next_team_info(&cookie, &info) >= B_OK) { while (get_next_team_info(&cookie, &info) >= B_OK) {
if (strstr(info.args, arg)) { if (strstr(info.args, name) != NULL)
list_area_info(info.team); list_areas_for_id(info.team);
}
} }
} }
int
main(int argc, char **argv)
{
show_memory_totals();
if (argc == 1) {
// list areas of all teams
int32 cookie = 0;
team_info info;
while (get_next_team_info(&cookie, &info) >= B_OK)
list_areas_for_id(info.team);
} else {
// list areas for each team ID/name on the command line
while (--argc) {
const char *arg = *++argv;
team_id team = atoi(arg);
// if atoi returns >0 it's likely it's a number, else take it as string
if (team > 0)
list_areas_for_id(team);
else
list_areas_for_name(arg);
}
}
return 0;
}