Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
(ARM).Porting TCP-IP programmer's guide.Ver 1.6.pdf
Скачиваний:
43
Добавлен:
23.08.2013
Размер:
2.64 Mб
Скачать

Miscellaneous Library Functions

9.2in_utils.c

This file contains an assortment of general utility functions. They are described in this section. The functions are:

con_page() on page 9-7

hexdump() on page 9-8

nextarg() on page 9-9

ns_printf() on page 9-10

panic() on page 9-11

print_eth() on page 9-12

print_ipad() on page 9-13

print_uptime() on page 9-13

std_in() on page 9-14

std_out() on page 9-15

sysuptime() on page 9-15

uslash() on page 9-16.

9-6

Copyright © 1998-2001 ARM Limited. All rights reserved.

ARM DUI 0144B

Miscellaneous Library Functions

9.2.1con_page()

This function implements a simple more facility.

Syntax

int con_page(void *vio, int lines)

where:

vio

Points to a generic I/O structure (see ns_printf() on page 9-10).

lines Is a counter containing the number of lines printed so far.

Return value

Returns one of the following:

0If more output should be produced.

1If the user indicates that no more output is wanted.

Usage

The con_page() function implements a simple more facility that waits for a key press from the user if more than a screen of information has been displayed. Normally, 0 is returned. The value 1 is returned if the Escape key is pressed as a response to the press any key for more prompt, indicating that the user does not wish to see more output.

ARM DUI 0144B

Copyright © 1998-2001 ARM Limited. All rights reserved.

9-7

Miscellaneous Library Functions

9.2.2hexdump()

This function is used to display an area of memory, usually for debugging purposes.

Syntax

void hexdump(void *pio, void * buffer, unsigned len)

where:

 

pio

Points to a generic I/O structure (see ns_printf() on page 9-10).

buffer

Points to the memory area to be displayed.

len

Is the number of bytes to be displayed.

Return value

None.

Usage

The hexdump() function displays len bytes of data, starting from the address buffer, using the dprintf() routine.

9-8

Copyright © 1998-2001 ARM Limited. All rights reserved.

ARM DUI 0144B

Miscellaneous Library Functions

9.2.3nextarg()

This function is used to parse a string into separate arguments.

Syntax

char *nextarg(char *argp)

where:

argp

Points to the string of arguments to be processed.

Return value

Returns a pointer to the next argument in argp, or to the terminating null character if there are no more arguments.

Usage

This function returns a pointer to the next argument in the string passed. Arguments are considered to be printable ASCII sequences of characters delimited by spaces. If there are no more arguments present within the string passed, this function returns a pointer to the null character that terminates the string. For example, calling nextarg() with the string one two three returns a pointer to the letter t of the word two. Calling nextarg() with that pointer returns a pointer to the letter t of the word three, and calling nextarg() once more returns a pointer to the terminating null character of the string.

ARM DUI 0144B

Copyright © 1998-2001 ARM Limited. All rights reserved.

9-9