forked from Imagelibrary/rtems
Whitespace removal.
This commit is contained in:
@@ -25,8 +25,8 @@
|
|||||||
* converted to an access type before being used further.
|
* converted to an access type before being used further.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE void *_Addresses_Add_offset (
|
STATIC INLINE void *_Addresses_Add_offset (
|
||||||
void *base,
|
void *base,
|
||||||
size_t offset
|
size_t offset
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#define NUMBER_ELEMENTS( _x ) (sizeof(_x) / sizeof _x[0])
|
#define NUMBER_ELEMENTS( _x ) (sizeof(_x) / sizeof _x[0])
|
||||||
|
|
||||||
void exit_application(
|
void exit_application(
|
||||||
int status
|
int status
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -54,14 +54,14 @@ int CheckSections( void );
|
|||||||
|
|
||||||
void GenerateLists( void );
|
void GenerateLists( void );
|
||||||
|
|
||||||
void GenerateAList(
|
void GenerateAList(
|
||||||
char *section,
|
char *section,
|
||||||
Chain_Control *the_list
|
Chain_Control *the_list
|
||||||
);
|
);
|
||||||
|
|
||||||
void LookForInternalInconsistencies( void );
|
void LookForInternalInconsistencies( void );
|
||||||
|
|
||||||
int Match_Argument(
|
int Match_Argument(
|
||||||
char **array,
|
char **array,
|
||||||
int entries,
|
int entries,
|
||||||
char *users
|
char *users
|
||||||
@@ -89,7 +89,7 @@ void PrintFile(
|
|||||||
char *out
|
char *out
|
||||||
);
|
);
|
||||||
|
|
||||||
void DumpList(
|
void DumpList(
|
||||||
Chain_Control *the_list
|
Chain_Control *the_list
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* main.c
|
* main.c
|
||||||
*
|
*
|
||||||
* This program takes a texinfo file without node and menu commands,
|
* This program takes a texinfo file without node and menu commands,
|
||||||
* build those commands and inserts them.
|
* build those commands and inserts them.
|
||||||
*
|
*
|
||||||
* It works by reading the input file into a linked list of lines
|
* It works by reading the input file into a linked list of lines
|
||||||
* and then performing sweeps on that list until all formatting is
|
* and then performing sweeps on that list until all formatting is
|
||||||
* complete. After the program is run, there is still a little
|
* complete. After the program is run, there is still a little
|
||||||
* clean up to be performed by hand. The following have to be fixed
|
* clean up to be performed by hand. The following have to be fixed
|
||||||
* by hand:
|
* by hand:
|
||||||
* + previous of the first node
|
* + previous of the first node
|
||||||
* + next of the last node
|
* + next of the last node
|
||||||
@@ -50,14 +50,14 @@ Chain_Control Lines;
|
|||||||
|
|
||||||
FILE *OutFile;
|
FILE *OutFile;
|
||||||
|
|
||||||
static void ProcessFile2(
|
static void ProcessFile2(
|
||||||
FILE *infile,
|
FILE *infile,
|
||||||
FILE *outfile );
|
FILE *outfile );
|
||||||
static void PrintFile2(
|
static void PrintFile2(
|
||||||
FILE *outfile );
|
FILE *outfile );
|
||||||
static void ReadFileIntoChain2(
|
static void ReadFileIntoChain2(
|
||||||
FILE *InFile );
|
FILE *InFile );
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
***** DATA TYPES AND CONSTANT TABLES *****
|
***** DATA TYPES AND CONSTANT TABLES *****
|
||||||
@@ -69,7 +69,7 @@ static void ReadFileIntoChain2(
|
|||||||
|
|
||||||
char *Usage_Strings[] = {
|
char *Usage_Strings[] = {
|
||||||
"\n",
|
"\n",
|
||||||
"usage: cmd [-cv] [-p prev] [-n next] [-u up] \n",
|
"usage: cmd [-cv] [-p prev] [-n next] [-u up] \n",
|
||||||
"\n",
|
"\n",
|
||||||
"EOF"
|
"EOF"
|
||||||
};
|
};
|
||||||
@@ -81,7 +81,7 @@ char *Usage_Strings[] = {
|
|||||||
|
|
||||||
#define PAGE_SEPARATOR "#PAGE"
|
#define PAGE_SEPARATOR "#PAGE"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Section Delimiter Keywords
|
* Section Delimiter Keywords
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ char *Usage_Strings[] = {
|
|||||||
/*
|
/*
|
||||||
* Level indicates where in the format the delimiter is allowed to occur.
|
* Level indicates where in the format the delimiter is allowed to occur.
|
||||||
* 1 indicates a major section divider (e.g. "ATTRIBUTE DESCRIPTIONS:").
|
* 1 indicates a major section divider (e.g. "ATTRIBUTE DESCRIPTIONS:").
|
||||||
* 2 indicates a subsection (e.g. "ATTRIBUTE:").
|
* 2 indicates a subsection (e.g. "ATTRIBUTE:").
|
||||||
* 3 indicates a heading (e.g. "DESCRIPTION:").
|
* 3 indicates a heading (e.g. "DESCRIPTION:").
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ char *Usage_Strings[] = {
|
|||||||
#define SUBSECTION 2
|
#define SUBSECTION 2
|
||||||
#define SUBSUBSECTION 3
|
#define SUBSUBSECTION 3
|
||||||
#define HEADING 4
|
#define HEADING 4
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
UNUSED, /* dummy 0 slot */
|
UNUSED, /* dummy 0 slot */
|
||||||
KEYWORD_CHAPTER,
|
KEYWORD_CHAPTER,
|
||||||
@@ -113,7 +113,7 @@ typedef enum {
|
|||||||
KEYWORD_LOWER,
|
KEYWORD_LOWER,
|
||||||
KEYWORD_OTHER,
|
KEYWORD_OTHER,
|
||||||
KEYWORD_END
|
KEYWORD_END
|
||||||
|
|
||||||
} Keyword_indices_t;
|
} Keyword_indices_t;
|
||||||
|
|
||||||
#define KEYWORD_FIRST KEYOWRD_CHAPTER
|
#define KEYWORD_FIRST KEYOWRD_CHAPTER
|
||||||
@@ -187,7 +187,7 @@ Keyword_info_t Keywords[] = {
|
|||||||
* exit_application
|
* exit_application
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void exit_application(
|
void exit_application(
|
||||||
int status
|
int status
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -195,7 +195,7 @@ void exit_application(
|
|||||||
/*
|
/*
|
||||||
fprintf( stderr, "*** Error encountered on line %d ***\n", CurrentLine );
|
fprintf( stderr, "*** Error encountered on line %d ***\n", CurrentLine );
|
||||||
*/
|
*/
|
||||||
fclose( OutFile );
|
fclose( OutFile );
|
||||||
exit( status );
|
exit( status );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,12 +223,12 @@ void PrintLine(
|
|||||||
#if 0
|
#if 0
|
||||||
fprintf( stderr, "%s\n", line->Contents );
|
fprintf( stderr, "%s\n", line->Contents );
|
||||||
#else
|
#else
|
||||||
/*
|
/*
|
||||||
* Include some debugging information
|
* Include some debugging information
|
||||||
*/
|
*/
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr,
|
stderr,
|
||||||
"<%d,%d,%d>:%s\n",
|
"<%d,%d,%d>:%s\n",
|
||||||
line->keyword,
|
line->keyword,
|
||||||
line->format,
|
line->format,
|
||||||
line->level,
|
line->level,
|
||||||
@@ -274,11 +274,11 @@ Line_Control *AllocateLine( void )
|
|||||||
new_line = (Line_Control *) _Chain_Get( &Line_Pool );
|
new_line = (Line_Control *) _Chain_Get( &Line_Pool );
|
||||||
assert( new_line );
|
assert( new_line );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is commented out because although it is helpful during debug,
|
* This is commented out because although it is helpful during debug,
|
||||||
* it consumes a significant percentage of the program's execution time.
|
* it consumes a significant percentage of the program's execution time.
|
||||||
|
|
||||||
memset( new_line->Contents, '\0', sizeof( new_line->Contents ) );
|
memset( new_line->Contents, '\0', sizeof( new_line->Contents ) );
|
||||||
*/
|
*/
|
||||||
new_line->number = -1;
|
new_line->number = -1;
|
||||||
@@ -314,14 +314,14 @@ Line_Control *DeleteLine(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
Line_Control *next;
|
Line_Control *next;
|
||||||
|
|
||||||
next = (Line_Control *)line->Node.next;
|
next = (Line_Control *)line->Node.next;
|
||||||
_Chain_Extract( &line->Node );
|
_Chain_Extract( &line->Node );
|
||||||
FreeLine( line );
|
FreeLine( line );
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PrintSurroundingLines
|
* PrintSurroundingLines
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -335,8 +335,8 @@ void PrintSurroundingLines(
|
|||||||
int real_backward;
|
int real_backward;
|
||||||
Line_Control *local;
|
Line_Control *local;
|
||||||
|
|
||||||
for ( local=line, real_backward=0, i=1 ;
|
for ( local=line, real_backward=0, i=1 ;
|
||||||
i<=backward ;
|
i<=backward ;
|
||||||
i++, real_backward++ ) {
|
i++, real_backward++ ) {
|
||||||
if ( &local->Node == Lines.first )
|
if ( &local->Node == Lines.first )
|
||||||
break;
|
break;
|
||||||
@@ -347,7 +347,7 @@ void PrintSurroundingLines(
|
|||||||
PrintLine( local );
|
PrintLine( local );
|
||||||
local = (Line_Control *) local->Node.next;
|
local = (Line_Control *) local->Node.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintLine( local );
|
PrintLine( local );
|
||||||
|
|
||||||
for ( i=1 ; i<=forward ; i++ ) {
|
for ( i=1 ; i<=forward ; i++ ) {
|
||||||
@@ -356,7 +356,7 @@ void PrintSurroundingLines(
|
|||||||
break;
|
break;
|
||||||
PrintLine( local );
|
PrintLine( local );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -388,7 +388,7 @@ void LineCopyFromRight(
|
|||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
for ( p=line->Contents ; *p != ' ' ; p++ )
|
for ( p=line->Contents ; *p != ' ' ; p++ )
|
||||||
;
|
;
|
||||||
p++; /* skip the ' ' */
|
p++; /* skip the ' ' */
|
||||||
for ( ; isspace( *p ) ; p++ )
|
for ( ; isspace( *p ) ; p++ )
|
||||||
@@ -418,7 +418,7 @@ void LineCopySectionName(
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ; *p ; )
|
for ( ; *p ; )
|
||||||
*d++ = *p++;
|
*d++ = *p++;
|
||||||
|
|
||||||
*d = '\0';
|
*d = '\0';
|
||||||
@@ -458,13 +458,13 @@ int main(
|
|||||||
NodeNameIncludesChapter = 0;
|
NodeNameIncludesChapter = 0;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
DocsPreviousNode = strdup(optarg);
|
DocsPreviousNode = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
DocsNextNode = strdup(optarg);
|
DocsNextNode = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
DocsUpNode = strdup(optarg);
|
DocsUpNode = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
@@ -478,14 +478,14 @@ int main(
|
|||||||
usage();
|
usage();
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Verbose )
|
if ( Verbose )
|
||||||
fprintf( stderr, "Arguments successfully parsed\n" );
|
fprintf( stderr, "Arguments successfully parsed\n" );
|
||||||
|
|
||||||
FillLinePool();
|
FillLinePool();
|
||||||
|
|
||||||
ProcessFile2( stdin, stdout );
|
ProcessFile2( stdin, stdout );
|
||||||
|
|
||||||
if ( Verbose )
|
if ( Verbose )
|
||||||
fprintf( stderr, "Exitting\n" );
|
fprintf( stderr, "Exitting\n" );
|
||||||
|
|
||||||
@@ -528,20 +528,20 @@ void ProcessFile2(
|
|||||||
|
|
||||||
FormatToTexinfo();
|
FormatToTexinfo();
|
||||||
|
|
||||||
if ( Verbose )
|
if ( Verbose )
|
||||||
fprintf( stderr, "-------->FILE FORMATTED TO TEXINFO\n" );
|
fprintf( stderr, "-------->FILE FORMATTED TO TEXINFO\n" );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print the file
|
* Print the file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PrintFile2( outfile );
|
PrintFile2( outfile );
|
||||||
|
|
||||||
if ( Verbose )
|
if ( Verbose )
|
||||||
fprintf( stderr, "-------->FILE PRINTED\n" );
|
fprintf( stderr, "-------->FILE PRINTED\n" );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clean Up
|
* Clean Up
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ReleaseFile();
|
ReleaseFile();
|
||||||
@@ -566,7 +566,7 @@ void usage( void )
|
|||||||
* ReadFileIntoChain
|
* ReadFileIntoChain
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ReadFileIntoChain2(
|
void ReadFileIntoChain2(
|
||||||
FILE *InFile
|
FILE *InFile
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -589,21 +589,21 @@ void ReadFileIntoChain2(
|
|||||||
|
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
line = fgets( Buffer, BUFFER_SIZE, InFile );
|
line = fgets( Buffer, BUFFER_SIZE, InFile );
|
||||||
if ( !line )
|
if ( !line )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
Buffer[ strlen( Buffer ) - 1 ] = '\0';
|
Buffer[ strlen( Buffer ) - 1 ] = '\0';
|
||||||
|
|
||||||
new_line = AllocateLine();
|
new_line = AllocateLine();
|
||||||
|
|
||||||
strcpy( new_line->Contents, Buffer );
|
strcpy( new_line->Contents, Buffer );
|
||||||
|
|
||||||
new_line->number = ++line_count;
|
new_line->number = ++line_count;
|
||||||
|
|
||||||
_Chain_Append( &Lines, &new_line->Node );
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose( InFile );
|
_Chain_Append( &Lines, &new_line->Node );
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose( InFile );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -616,19 +616,19 @@ void StripBlanks( void )
|
|||||||
Keyword_indices_t index;
|
Keyword_indices_t index;
|
||||||
int indentation;
|
int indentation;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
for ( line = (Line_Control *) Lines.first ;
|
for ( line = (Line_Control *) Lines.first ;
|
||||||
!_Chain_Is_last( &line->Node ) ;
|
!_Chain_Is_last( &line->Node ) ;
|
||||||
line = (Line_Control *) line->Node.next
|
line = (Line_Control *) line->Node.next
|
||||||
) {
|
) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Strip white space from the end of each line
|
* Strip white space from the end of each line
|
||||||
*/
|
*/
|
||||||
|
|
||||||
length = strlen( line->Contents );
|
length = strlen( line->Contents );
|
||||||
|
|
||||||
while ( isspace( line->Contents[ --length ] ) )
|
while ( isspace( line->Contents[ --length ] ) )
|
||||||
line->Contents[ length ] = '\0';
|
line->Contents[ length ] = '\0';
|
||||||
|
|
||||||
if ( strstr( line->Contents, "@chapter" ) )
|
if ( strstr( line->Contents, "@chapter" ) )
|
||||||
@@ -651,7 +651,7 @@ void StripBlanks( void )
|
|||||||
line->keyword = KEYWORD_LOWER;
|
line->keyword = KEYWORD_LOWER;
|
||||||
else
|
else
|
||||||
line->keyword = KEYWORD_OTHER;
|
line->keyword = KEYWORD_OTHER;
|
||||||
|
|
||||||
}
|
}
|
||||||
line = AllocateLine();
|
line = AllocateLine();
|
||||||
line->keyword = KEYWORD_END;
|
line->keyword = KEYWORD_END;
|
||||||
@@ -679,7 +679,7 @@ boolean strIsAllSpace(
|
|||||||
* BuildTexinfoNodes
|
* BuildTexinfoNodes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void BuildTexinfoNodes( void )
|
void BuildTexinfoNodes( void )
|
||||||
{
|
{
|
||||||
char Buffer[ BUFFER_SIZE ];
|
char Buffer[ BUFFER_SIZE ];
|
||||||
Line_Control *line;
|
Line_Control *line;
|
||||||
@@ -717,7 +717,7 @@ void BuildTexinfoNodes( void )
|
|||||||
line->keyword == KEYWORD_APPENDIX ||
|
line->keyword == KEYWORD_APPENDIX ||
|
||||||
line->keyword == KEYWORD_PREFACE ||
|
line->keyword == KEYWORD_PREFACE ||
|
||||||
line->keyword == KEYWORD_CHAPHEADING ) {
|
line->keyword == KEYWORD_CHAPHEADING ) {
|
||||||
|
|
||||||
strcpy( ChapterName, NodeName );
|
strcpy( ChapterName, NodeName );
|
||||||
|
|
||||||
} else if ( NodeNameIncludesChapter ) {
|
} else if ( NodeNameIncludesChapter ) {
|
||||||
@@ -828,8 +828,8 @@ continue_menu_loop:
|
|||||||
|
|
||||||
if ( (up_node->level == -1) )
|
if ( (up_node->level == -1) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( up_node->level == (line->level - 1) ) {
|
if ( up_node->level == (line->level - 1) ) {
|
||||||
LineCopySectionName( up_node, Buffer );
|
LineCopySectionName( up_node, Buffer );
|
||||||
if (NodeNameIncludesChapter) {
|
if (NodeNameIncludesChapter) {
|
||||||
if (!strcmp(ChapterName, Buffer))
|
if (!strcmp(ChapterName, Buffer))
|
||||||
@@ -899,7 +899,7 @@ void FormatToTexinfo( void )
|
|||||||
fprintf( stderr, "-------->INSERTING TEXINFO MENUS\n" );
|
fprintf( stderr, "-------->INSERTING TEXINFO MENUS\n" );
|
||||||
|
|
||||||
for ( line = (Line_Control *) Lines.first ;
|
for ( line = (Line_Control *) Lines.first ;
|
||||||
!_Chain_Is_last( &line->Node ) ;
|
!_Chain_Is_last( &line->Node ) ;
|
||||||
line = (Line_Control *) line->Node.next ) {
|
line = (Line_Control *) line->Node.next ) {
|
||||||
|
|
||||||
switch (line->keyword) {
|
switch (line->keyword) {
|
||||||
@@ -959,7 +959,7 @@ void PrintFile2(
|
|||||||
assert( OutFile );
|
assert( OutFile );
|
||||||
|
|
||||||
for ( line = (Line_Control *) Lines.first ;
|
for ( line = (Line_Control *) Lines.first ;
|
||||||
!_Chain_Is_last( &line->Node ) ;
|
!_Chain_Is_last( &line->Node ) ;
|
||||||
line = (Line_Control *) line->Node.next ) {
|
line = (Line_Control *) line->Node.next ) {
|
||||||
fprintf( OutFile, "%s\n", line->Contents );
|
fprintf( OutFile, "%s\n", line->Contents );
|
||||||
/*
|
/*
|
||||||
@@ -978,7 +978,7 @@ void PrintFile2(
|
|||||||
* DumpList
|
* DumpList
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void DumpList(
|
void DumpList(
|
||||||
Chain_Control *the_list
|
Chain_Control *the_list
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -987,7 +987,7 @@ void DumpList(
|
|||||||
fprintf( stderr, "---> Dumping list (%p)\n", the_list );
|
fprintf( stderr, "---> Dumping list (%p)\n", the_list );
|
||||||
|
|
||||||
for ( line = (Line_Control *) the_list->first ;
|
for ( line = (Line_Control *) the_list->first ;
|
||||||
!_Chain_Is_last( &line->Node ) ;
|
!_Chain_Is_last( &line->Node ) ;
|
||||||
line = (Line_Control *) line->Node.next ) {
|
line = (Line_Control *) line->Node.next ) {
|
||||||
/* if (line->level != -1) */
|
/* if (line->level != -1) */
|
||||||
PrintLine( line );
|
PrintLine( line );
|
||||||
@@ -1005,7 +1005,7 @@ void ReleaseFile()
|
|||||||
Line_Control *next;
|
Line_Control *next;
|
||||||
|
|
||||||
for ( line = (Line_Control *) Lines.first ;
|
for ( line = (Line_Control *) Lines.first ;
|
||||||
!_Chain_Is_last( &line->Node ) ;
|
!_Chain_Is_last( &line->Node ) ;
|
||||||
) {
|
) {
|
||||||
next = (Line_Control *) line->Node.next;
|
next = (Line_Control *) line->Node.next;
|
||||||
line = next;
|
line = next;
|
||||||
@@ -1038,7 +1038,7 @@ void strtoInitialCaps(
|
|||||||
|
|
||||||
for ( ; *source && !isspace( *source ) ; source++ )
|
for ( ; *source && !isspace( *source ) ; source++ )
|
||||||
*destination++ = tolower( *source );
|
*destination++ = tolower( *source );
|
||||||
|
|
||||||
if ( !*source )
|
if ( !*source )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* _Chain_Initialize
|
* _Chain_Initialize
|
||||||
*
|
*
|
||||||
* This kernel routine initializes a doubly linked chain.
|
* This kernel routine initializes a doubly linked chain.
|
||||||
*
|
*
|
||||||
* Input parameters:
|
* Input parameters:
|
||||||
* the_chain - pointer to chain header
|
* the_chain - pointer to chain header
|
||||||
@@ -27,14 +27,14 @@
|
|||||||
* Output parameters: NONE
|
* Output parameters: NONE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void _Chain_Initialize(
|
void _Chain_Initialize(
|
||||||
Chain_Control *the_chain,
|
Chain_Control *the_chain,
|
||||||
void *starting_address,
|
void *starting_address,
|
||||||
size_t number_nodes,
|
size_t number_nodes,
|
||||||
size_t node_size
|
size_t node_size
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
size_t count;
|
size_t count;
|
||||||
Chain_Node *current;
|
Chain_Node *current;
|
||||||
Chain_Node *next;
|
Chain_Node *next;
|
||||||
|
|
||||||
@@ -62,11 +62,11 @@ void _Chain_Initialize(
|
|||||||
*
|
*
|
||||||
* Input parameters:
|
* Input parameters:
|
||||||
* the_chain - pointer to chain header
|
* the_chain - pointer to chain header
|
||||||
*
|
*
|
||||||
* Output parameters:
|
* Output parameters:
|
||||||
* return_node - pointer to node in chain allocated
|
* return_node - pointer to node in chain allocated
|
||||||
* CHAIN_END - if no nodes available
|
* CHAIN_END - if no nodes available
|
||||||
*
|
*
|
||||||
* INTERRUPT LATENCY:
|
* INTERRUPT LATENCY:
|
||||||
* only case
|
* only case
|
||||||
*/
|
*/
|
||||||
@@ -78,7 +78,7 @@ Chain_Node *_Chain_Get(
|
|||||||
Chain_Node *return_node;
|
Chain_Node *return_node;
|
||||||
|
|
||||||
return_node = NULL;
|
return_node = NULL;
|
||||||
if ( !_Chain_Is_empty( the_chain ) )
|
if ( !_Chain_Is_empty( the_chain ) )
|
||||||
return_node = _Chain_Get_first_unprotected( the_chain );
|
return_node = _Chain_Get_first_unprotected( the_chain );
|
||||||
return return_node;
|
return return_node;
|
||||||
}
|
}
|
||||||
@@ -92,14 +92,14 @@ Chain_Node *_Chain_Get(
|
|||||||
* Input parameters:
|
* Input parameters:
|
||||||
* the_chain - pointer to chain header
|
* the_chain - pointer to chain header
|
||||||
* node - address of node to put at rear of chain
|
* node - address of node to put at rear of chain
|
||||||
*
|
*
|
||||||
* Output parameters: NONE
|
* Output parameters: NONE
|
||||||
*
|
*
|
||||||
* INTERRUPT LATENCY:
|
* INTERRUPT LATENCY:
|
||||||
* only case
|
* only case
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void _Chain_Append(
|
void _Chain_Append(
|
||||||
Chain_Control *the_chain,
|
Chain_Control *the_chain,
|
||||||
Chain_Node *node
|
Chain_Node *node
|
||||||
)
|
)
|
||||||
@@ -115,17 +115,17 @@ void _Chain_Append(
|
|||||||
*
|
*
|
||||||
* Input parameters:
|
* Input parameters:
|
||||||
* node - pointer to node in chain to be deleted
|
* node - pointer to node in chain to be deleted
|
||||||
*
|
*
|
||||||
* Output parameters: NONE
|
* Output parameters: NONE
|
||||||
*
|
*
|
||||||
* INTERRUPT LATENCY:
|
* INTERRUPT LATENCY:
|
||||||
* only case
|
* only case
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void _Chain_Extract(
|
void _Chain_Extract(
|
||||||
Chain_Node *node
|
Chain_Node *node
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_Chain_Extract_unprotected( node );
|
_Chain_Extract_unprotected( node );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,14 +139,14 @@ void _Chain_Extract(
|
|||||||
* Input parameters:
|
* Input parameters:
|
||||||
* after_node - pointer to node in chain to be inserted after
|
* after_node - pointer to node in chain to be inserted after
|
||||||
* node - pointer to node to be inserted
|
* node - pointer to node to be inserted
|
||||||
*
|
*
|
||||||
* Output parameters: NONE
|
* Output parameters: NONE
|
||||||
*
|
*
|
||||||
* INTERRUPT LATENCY:
|
* INTERRUPT LATENCY:
|
||||||
* only case
|
* only case
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void _Chain_Insert(
|
void _Chain_Insert(
|
||||||
Chain_Node *after_node,
|
Chain_Node *after_node,
|
||||||
Chain_Node *node
|
Chain_Node *node
|
||||||
)
|
)
|
||||||
@@ -156,17 +156,17 @@ void _Chain_Insert(
|
|||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
*
|
*
|
||||||
* _Chain_Insert_chain
|
* _Chain_Insert_chain
|
||||||
*
|
*
|
||||||
* This routine inserts a chain after the specified node in another
|
* This routine inserts a chain after the specified node in another
|
||||||
* chain. It is assumed that the insert after node is not on the
|
* chain. It is assumed that the insert after node is not on the
|
||||||
* second chain.
|
* second chain.
|
||||||
*
|
*
|
||||||
* Input parameters:
|
* Input parameters:
|
||||||
* insert_after - insert the chain after this node
|
* insert_after - insert the chain after this node
|
||||||
* to_insert - the chain to insert
|
* to_insert - the chain to insert
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void _Chain_Insert_chain(
|
void _Chain_Insert_chain(
|
||||||
Chain_Node *insert_after,
|
Chain_Node *insert_after,
|
||||||
Chain_Control *to_insert
|
Chain_Control *to_insert
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* chain.h
|
/* chain.h
|
||||||
*
|
*
|
||||||
* This include file contains all the constants and structures associated
|
* This include file contains all the constants and structures associated
|
||||||
* with the Doubly Linked Chain Handler.
|
* with the Doubly Linked Chain Handler.
|
||||||
*
|
*
|
||||||
@@ -43,11 +43,11 @@ struct Chain_Node_struct {
|
|||||||
*
|
*
|
||||||
* NOTE: This implementation does not require special checks for
|
* NOTE: This implementation does not require special checks for
|
||||||
* manipulating the first and last elements on the chain.
|
* manipulating the first and last elements on the chain.
|
||||||
* To accomplish this the chain control structure is
|
* To accomplish this the chain control structure is
|
||||||
* treated as two overlapping chain nodes. The permanent
|
* treated as two overlapping chain nodes. The permanent
|
||||||
* head of the chain overlays a node structure on the
|
* head of the chain overlays a node structure on the
|
||||||
* first and permanent_null fields. The permanent tail
|
* first and permanent_null fields. The permanent tail
|
||||||
* of the chain overlays a node structure on the
|
* of the chain overlays a node structure on the
|
||||||
* permanent_null and last elements of the structure.
|
* permanent_null and last elements of the structure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ typedef struct {
|
|||||||
Chain_Node *last;
|
Chain_Node *last;
|
||||||
} Chain_Control;
|
} Chain_Control;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Initialize
|
* _Chain_Initialize
|
||||||
*
|
*
|
||||||
* This routine initializes the_chain structure to manage the
|
* This routine initializes the_chain structure to manage the
|
||||||
@@ -65,14 +65,14 @@ typedef struct {
|
|||||||
* starting_address. Each node is of node_size bytes.
|
* starting_address. Each node is of node_size bytes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void _Chain_Initialize(
|
void _Chain_Initialize(
|
||||||
Chain_Control *the_chain,
|
Chain_Control *the_chain,
|
||||||
void *starting_address,
|
void *starting_address,
|
||||||
size_t number_nodes,
|
size_t number_nodes,
|
||||||
size_t node_size
|
size_t node_size
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Initialize_empty
|
* _Chain_Initialize_empty
|
||||||
*
|
*
|
||||||
* This routine initializes the specified chain to contain zero nodes.
|
* This routine initializes the specified chain to contain zero nodes.
|
||||||
@@ -82,7 +82,7 @@ STATIC INLINE void _Chain_Initialize_empty(
|
|||||||
Chain_Control *the_chain
|
Chain_Control *the_chain
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Extract_unprotected
|
* _Chain_Extract_unprotected
|
||||||
*
|
*
|
||||||
* This routine extracts the_node from the chain on which it resides.
|
* This routine extracts the_node from the chain on which it resides.
|
||||||
@@ -94,7 +94,7 @@ STATIC INLINE void _Chain_Extract_unprotected(
|
|||||||
Chain_Node *the_node
|
Chain_Node *the_node
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Extract
|
* _Chain_Extract
|
||||||
*
|
*
|
||||||
* This routine extracts the_node from the chain on which it resides.
|
* This routine extracts the_node from the chain on which it resides.
|
||||||
@@ -102,11 +102,11 @@ STATIC INLINE void _Chain_Extract_unprotected(
|
|||||||
* extract operation.
|
* extract operation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void _Chain_Extract(
|
void _Chain_Extract(
|
||||||
Chain_Node *the_node
|
Chain_Node *the_node
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Get_unprotected
|
* _Chain_Get_unprotected
|
||||||
*
|
*
|
||||||
* This function removes the first node from the_chain and returns
|
* This function removes the first node from the_chain and returns
|
||||||
@@ -115,11 +115,11 @@ void _Chain_Extract(
|
|||||||
* get operation.
|
* get operation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE Chain_Node *_Chain_Get_unprotected(
|
STATIC INLINE Chain_Node *_Chain_Get_unprotected(
|
||||||
Chain_Control *the_chain
|
Chain_Control *the_chain
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Get
|
* _Chain_Get
|
||||||
*
|
*
|
||||||
* This function removes the first node from the_chain and returns
|
* This function removes the first node from the_chain and returns
|
||||||
@@ -128,11 +128,11 @@ STATIC INLINE Chain_Node *_Chain_Get_unprotected(
|
|||||||
* get operation.
|
* get operation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Chain_Node *_Chain_Get(
|
Chain_Node *_Chain_Get(
|
||||||
Chain_Control *the_chain
|
Chain_Control *the_chain
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Get_first_unprotected
|
* _Chain_Get_first_unprotected
|
||||||
*
|
*
|
||||||
* This function removes the first node from the_chain and returns
|
* This function removes the first node from the_chain and returns
|
||||||
@@ -140,11 +140,11 @@ Chain_Node *_Chain_Get(
|
|||||||
* the atomicity of the get operation.
|
* the atomicity of the get operation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE Chain_Node *_Chain_Get_first_unprotected(
|
STATIC INLINE Chain_Node *_Chain_Get_first_unprotected(
|
||||||
Chain_Control *the_chain
|
Chain_Control *the_chain
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Insert_unprotected
|
* _Chain_Insert_unprotected
|
||||||
*
|
*
|
||||||
* This routine inserts the_node on a chain immediately following
|
* This routine inserts the_node on a chain immediately following
|
||||||
@@ -157,7 +157,7 @@ STATIC INLINE void _Chain_Insert_unprotected(
|
|||||||
Chain_Node *the_node
|
Chain_Node *the_node
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Insert
|
* _Chain_Insert
|
||||||
*
|
*
|
||||||
* This routine inserts the_node on a chain immediately following
|
* This routine inserts the_node on a chain immediately following
|
||||||
@@ -165,12 +165,12 @@ STATIC INLINE void _Chain_Insert_unprotected(
|
|||||||
* of the extract operation.
|
* of the extract operation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void _Chain_Insert(
|
void _Chain_Insert(
|
||||||
Chain_Node *after_node,
|
Chain_Node *after_node,
|
||||||
Chain_Node *the_node
|
Chain_Node *the_node
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Append_unprotected
|
* _Chain_Append_unprotected
|
||||||
*
|
*
|
||||||
* This routine appends the_node onto the end of the_chain.
|
* This routine appends the_node onto the end of the_chain.
|
||||||
@@ -183,7 +183,7 @@ STATIC INLINE void _Chain_Append_unprotected(
|
|||||||
Chain_Node *the_node
|
Chain_Node *the_node
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Append
|
* _Chain_Append
|
||||||
*
|
*
|
||||||
* This routine appends the_node onto the end of the_chain.
|
* This routine appends the_node onto the end of the_chain.
|
||||||
@@ -191,12 +191,12 @@ STATIC INLINE void _Chain_Append_unprotected(
|
|||||||
* append operation.
|
* append operation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void _Chain_Append(
|
void _Chain_Append(
|
||||||
Chain_Control *the_chain,
|
Chain_Control *the_chain,
|
||||||
Chain_Node *the_node
|
Chain_Node *the_node
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Prepend_unprotected
|
* _Chain_Prepend_unprotected
|
||||||
*
|
*
|
||||||
* This routine prepends the_node onto the front of the_chain.
|
* This routine prepends the_node onto the front of the_chain.
|
||||||
@@ -209,7 +209,7 @@ STATIC INLINE void _Chain_Prepend_unprotected(
|
|||||||
Chain_Node *the_node
|
Chain_Node *the_node
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Prepend
|
* _Chain_Prepend
|
||||||
*
|
*
|
||||||
* This routine prepends the_node onto the front of the_chain.
|
* This routine prepends the_node onto the front of the_chain.
|
||||||
@@ -235,7 +235,7 @@ void _Chain_Insert_chain(
|
|||||||
Chain_Control *to_insert
|
Chain_Control *to_insert
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Head
|
* _Chain_Head
|
||||||
*
|
*
|
||||||
* This function returns a pointer to the first node on the chain.
|
* This function returns a pointer to the first node on the chain.
|
||||||
@@ -245,7 +245,7 @@ STATIC INLINE Chain_Node *_Chain_Head(
|
|||||||
Chain_Control *the_chain
|
Chain_Control *the_chain
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Tail
|
* _Chain_Tail
|
||||||
*
|
*
|
||||||
* This function returns a pointer to the last node on the chain.
|
* This function returns a pointer to the last node on the chain.
|
||||||
@@ -255,7 +255,7 @@ STATIC INLINE Chain_Node *_Chain_Tail(
|
|||||||
Chain_Control *the_chain
|
Chain_Control *the_chain
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Is_head
|
* _Chain_Is_head
|
||||||
*
|
*
|
||||||
* This function returns TRUE if the_node is the head of the_chain and
|
* This function returns TRUE if the_node is the head of the_chain and
|
||||||
@@ -267,7 +267,7 @@ STATIC INLINE boolean _Chain_Is_head(
|
|||||||
Chain_Node *the_node
|
Chain_Node *the_node
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Is_tail
|
* _Chain_Is_tail
|
||||||
*
|
*
|
||||||
* This function returns TRUE if the_node is the tail of the_chain and
|
* This function returns TRUE if the_node is the tail of the_chain and
|
||||||
@@ -279,7 +279,7 @@ STATIC INLINE boolean _Chain_Is_tail(
|
|||||||
Chain_Node *the_node
|
Chain_Node *the_node
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Is_first
|
* _Chain_Is_first
|
||||||
*
|
*
|
||||||
* This function returns TRUE if the_node is the first node on a chain and
|
* This function returns TRUE if the_node is the first node on a chain and
|
||||||
@@ -290,7 +290,7 @@ STATIC INLINE boolean _Chain_Is_first(
|
|||||||
Chain_Node *the_node
|
Chain_Node *the_node
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Is_last
|
* _Chain_Is_last
|
||||||
*
|
*
|
||||||
* This function returns TRUE if the_node is the last node on a chain and
|
* This function returns TRUE if the_node is the last node on a chain and
|
||||||
@@ -301,7 +301,7 @@ STATIC INLINE boolean _Chain_Is_last(
|
|||||||
Chain_Node *the_node
|
Chain_Node *the_node
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Is_empty
|
* _Chain_Is_empty
|
||||||
*
|
*
|
||||||
* This function returns TRUE if there a no nodes on the_chain and
|
* This function returns TRUE if there a no nodes on the_chain and
|
||||||
@@ -312,7 +312,7 @@ STATIC INLINE boolean _Chain_Is_empty(
|
|||||||
Chain_Control *the_chain
|
Chain_Control *the_chain
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Has_only_one_node
|
* _Chain_Has_only_one_node
|
||||||
*
|
*
|
||||||
* This function returns TRUE if there is only one node on the_chain and
|
* This function returns TRUE if there is only one node on the_chain and
|
||||||
@@ -323,7 +323,7 @@ STATIC INLINE boolean _Chain_Has_only_one_node(
|
|||||||
Chain_Control *the_chain
|
Chain_Control *the_chain
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Is_null
|
* _Chain_Is_null
|
||||||
*
|
*
|
||||||
* This function returns TRUE if the_chain is NULL and FALSE otherwise.
|
* This function returns TRUE if the_chain is NULL and FALSE otherwise.
|
||||||
@@ -333,7 +333,7 @@ STATIC INLINE boolean _Chain_Is_null(
|
|||||||
Chain_Control *the_chain
|
Chain_Control *the_chain
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _Chain_Is_null_node
|
* _Chain_Is_null_node
|
||||||
*
|
*
|
||||||
* This function returns TRUE if the_node is NULL and FALSE otherwise.
|
* This function returns TRUE if the_node is NULL and FALSE otherwise.
|
||||||
|
|||||||
Reference in New Issue
Block a user