RemoteDrawingEngine: Reduce RP_READ_BITMAP result timeout.
[haiku.git] / src / bin / listport.c
blob5c8b87edd5c346a4fc15d72ad9d1f32fe6c4a8ea
1 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
2 //
3 // Copyright (c) 2001-2003, OpenBeOS
4 //
5 // This software is part of the OpenBeOS distribution and is covered
6 // by the MIT License.
7 //
8 //
9 // File: listport.c
10 // Author: Daniel Reinhold (danielre@users.sf.net)
11 // Description: lists all open ports in the system, organized by team
13 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <OS.h>
20 void list_team_ports (team_id id);
21 void show_port_totals (void);
25 int
26 main(int argc, char **argv)
28 show_port_totals();
30 if (argc == 1) {
31 int32 cookie = 0;
32 team_info info;
34 // list for all teams
35 while (get_next_team_info(&cookie, &info) >= B_OK)
36 list_team_ports(info.team);
38 else
39 // list for each team_id on the command line
40 while (--argc)
41 list_team_ports(atoi(*++argv));
43 return 0;
47 void
48 show_port_totals()
50 int32 max = 0, used = 0, left;
51 system_info sys;
53 if (get_system_info(&sys) == B_OK) {
54 max = sys.max_ports;
55 used = sys.used_ports;
58 left = max - used;
60 printf("port: total: %5ld, used: %5ld, left: %5ld\n", max, used, left);
64 void
65 list_team_ports(team_id id)
67 int32 cookie = 0;
68 port_info this_port;
69 team_info this_team;
71 if (get_team_info(id, &this_team) == B_BAD_TEAM_ID) {
72 printf("\nteam %ld unknown\n", id);
73 return;
76 printf("\nTEAM %4ld (%s):\n", id, this_team.args);
77 printf(" ID name capacity queued\n");
78 printf("----------------------------------------------------\n");
80 while (get_next_port_info(id, &cookie, &this_port) == B_OK) {
81 printf("%5ld %28s %8ld %6ld\n",
82 this_port.port,
83 this_port.name,
84 this_port.capacity,
85 this_port.queue_count);