2 * Copyright (c) 2001-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Daniel Reinhold, danielre@users.sf.net
7 * John Scipione, jscipione@gmail.com
10 /*! Lists image info for all currently running teams. */
24 list_images_for_team_by_id(team_id id
)
32 status_t result
= get_team_info(id
, &teamInfo
);
33 if (id
!= 1 && result
< B_OK
)
36 i
= asprintf(&header
, " ID %*s %*s Seq# Init# Name",
37 sizeof(uintptr_t) * 2, "Text", sizeof(uintptr_t) * 2, "Data");
41 i
= asprintf(&format
, "%%5" B_PRId32
" 0x%%0%" B_PRIu32 PRIxPTR
42 " 0x%%0%" B_PRIu32 PRIxPTR
" %%4" B_PRId32
" %%10" B_PRIu32
" %%s\n",
43 sizeof(uintptr_t) * 2, sizeof(uintptr_t) * 2);
50 printf("\nKERNEL TEAM:\n");
52 printf("\nTEAM %4" B_PRId32
" (%s):\n", id
, teamInfo
.args
);
55 for (i
= 0; i
< 80; i
++)
59 while ((result
= get_next_image_info(id
, &cookie
, &imageInfo
)) == B_OK
) {
60 printf(format
, imageInfo
.id
, imageInfo
.text
, imageInfo
.data
,
61 imageInfo
.sequence
, imageInfo
.init_order
, imageInfo
.name
);
67 if (result
!= B_ENTRY_NOT_FOUND
&& result
!= EINVAL
) {
68 printf("get images failed: %s\n", strerror(result
));
77 list_images_for_team(const char* arg
)
83 if (atoi(arg
) > 0 && list_images_for_team_by_id(atoi(arg
)) == B_OK
)
86 /* search for the team by name */
88 while (get_next_team_info(&cookie
, &info
) >= B_OK
) {
89 if (strstr(info
.args
, arg
)) {
90 result
= list_images_for_team_by_id(info
.team
);
92 printf("\nCould not retrieve information about team %"
93 B_PRId32
": %s\n", info
.team
, strerror(result
));
101 main(int argc
, char** argv
)
108 /* list for all teams */
109 while (get_next_team_info(&cookie
, &info
) >= B_OK
) {
110 result
= list_images_for_team_by_id(info
.team
);
111 if (result
!= B_OK
) {
112 printf("\nCould not retrieve information about team %"
113 B_PRId32
": %s\n", info
.team
, strerror(result
));
117 /* list for each team_id on the command line */
118 while (--argc
> 0 && ++argv
!= NULL
)
119 list_images_for_team(*argv
);