⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bmenu2.c

📁 RTEMS (Real-Time Executive for Multiprocessor Systems) is a free open source real-time operating sys
💻 C
📖 第 1 页 / 共 2 页
字号:
     fprintf( stderr, "-------->BLANKS BEFORE KEYWORDS STRIPPED\n" );   FormatToTexinfo();   if ( Verbose )      fprintf( stderr, "-------->FILE FORMATTED TO TEXINFO\n" );   /*    *  Print the file     */   PrintFile2( outfile );   if ( Verbose )      fprintf( stderr, "-------->FILE PRINTED\n" );   /*    *  Clean Up     */   ReleaseFile();   if ( Verbose )     fprintf( stderr, "-------->FILE RELEASED\n" );}/* *  usage */void usage( void ){  int index;  for ( index=0 ; strcmp( Usage_Strings[ index ], "EOF" ) ; index++ )    fprintf( stderr, Usage_Strings[ index ] );}/* *  ReadFileIntoChain */void ReadFileIntoChain2(   FILE *InFile){   int   line_count;   int   max_length;   char *line;   char  Buffer[ BUFFER_SIZE ];   Line_Control *new_line;   if ( !InFile ) {     fprintf( stderr, "Unable to open (%s)\n", "stdin" );     exit( 1 );   }   assert( InFile );   max_length = 0;   line_count = 0;   _Chain_Initialize_empty( &Lines );   for ( ;; ) {      line = fgets( Buffer, BUFFER_SIZE, InFile );      if ( !line )         break;      Buffer[ strlen( Buffer ) - 1 ] = '\0';      new_line = AllocateLine();       strcpy( new_line->Contents, Buffer );      new_line->number = ++line_count;       _Chain_Append( &Lines, &new_line->Node );   }    fclose( InFile ); }/* *  StripBlanks */void StripBlanks( void ){  Line_Control      *line;  Keyword_indices_t  index;  int                indentation;  int                length;   for ( line = (Line_Control *) Lines.first ;        !_Chain_Is_last( &line->Node ) ;        line = (Line_Control *) line->Node.next        ) {    /*     *  Strip white space from the end of each line      */    length = strlen( line->Contents );    while ( isspace( line->Contents[ --length ] ) )       line->Contents[ length ] = '\0';    if ( strstr( line->Contents, "@chapter" ) )      line->keyword = KEYWORD_CHAPTER;    else if ( strstr( line->Contents, "@appendix" ) )      line->keyword = KEYWORD_APPENDIX;    else if ( strstr( line->Contents, "@preface" ) )      line->keyword = KEYWORD_PREFACE;    else if ( strstr( line->Contents, "@chapheading" ) )      line->keyword = KEYWORD_CHAPHEADING;    else if ( strstr( line->Contents, "@section" ) )      line->keyword = KEYWORD_SECTION;    else if ( strstr( line->Contents, "@subsection" ) )      line->keyword = KEYWORD_SUBSECTION;    else if ( strstr( line->Contents, "@subsubsection" ) )      line->keyword = KEYWORD_SUBSUBSECTION;    else if ( strstr( line->Contents, "@raise" ) )      line->keyword = KEYWORD_RAISE;    else if ( strstr( line->Contents, "@lower" ) )      line->keyword = KEYWORD_LOWER;    else      line->keyword = KEYWORD_OTHER;      }  line = AllocateLine();  line->keyword = KEYWORD_END;  _Chain_Append( &Lines, &line->Node );}/* *  strIsAllSpace */boolean strIsAllSpace(  char *s){  char *p;  for ( p = s ; *p ; p++ )    if ( !isspace( *p ) )      return FALSE;  return TRUE;}/* *  BuildTexinfoNodes */void BuildTexinfoNodes( void ) {  char               Buffer[ BUFFER_SIZE ];  Line_Control      *line;  Line_Control      *next_node;  Line_Control      *up_node;  Line_Control      *new_line;  Line_Control      *menu_insert_point;  Line_Control      *node_line;  int                next_found;  int                menu_items;  Keyword_indices_t  index;  char               ChapterName[ BUFFER_SIZE ];  char               NodeName[ BUFFER_SIZE ];  char               UpNodeName[ BUFFER_SIZE ];  char               NextNodeName[ BUFFER_SIZE ];  char               PreviousNodeName[ BUFFER_SIZE ];  /*   *  Set Initial Previous Node Name   */  strcpy( PreviousNodeName, DocsPreviousNode );  for ( line = (Line_Control *) Lines.first ;        !_Chain_Is_last( &line->Node ) ;        line = (Line_Control *) line->Node.next        ) {    if ( line->level == -1 )      continue;    LineCopyFromRight( line, NodeName );    if ( line->keyword == KEYWORD_CHAPTER ||         line->keyword == KEYWORD_APPENDIX ||         line->keyword == KEYWORD_PREFACE ||         line->keyword == KEYWORD_CHAPHEADING ) {          strcpy( ChapterName, NodeName );    } else if ( NodeNameIncludesChapter ) {      sprintf( Buffer, "%s %s", ChapterName, NodeName );      strcpy( NodeName, Buffer );    }    /*     *  Set Default Next Node Name     */    next_found = FALSE;    strcpy( NextNodeName, DocsNextNode );    /*     *  Go ahead and put it on the chain in the right order (ahead of     *  the menu) and we can fill it in later (after the menu is built).     */    new_line = AllocateLine();    strcpy( new_line->Contents, "" ); /*"@ifinfo" ); */    _Chain_Insert( line->Node.previous, &new_line->Node );    node_line = AllocateLine();    _Chain_Insert( line->Node.previous, &node_line->Node );    new_line = AllocateLine();    strcpy( new_line->Contents, "" ); /* "@end ifinfo" ); */    _Chain_Insert( line->Node.previous, &new_line->Node );    next_node = (Line_Control *) line->Node.next;    menu_insert_point = next_node;    menu_items = 0;    for ( ; ; ) {      if ( next_node->keyword == KEYWORD_END )        break;      if ( next_node->level == -1 )        goto continue_menu_loop;      LineCopySectionName( next_node, Buffer );      if ( !next_found ) {        next_found = TRUE;        if (NodeNameIncludesChapter)          sprintf( NextNodeName, "%s %s", ChapterName, Buffer );        else          sprintf( NextNodeName, "%s", Buffer );      }      if ( next_node->level <= line->level )        break;      if ( next_node->level != (line->level + 1) )        goto continue_menu_loop;      if ( menu_items == 0 ) {        new_line = AllocateLine();        strcpy( new_line->Contents, "@ifinfo" );        _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node );        new_line = AllocateLine();        strcpy( new_line->Contents, "@menu" );        _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node );      }      menu_items++;      new_line = AllocateLine();      if (NodeNameIncludesChapter)        sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer );      else        sprintf( new_line->Contents, "* %s::", Buffer );      _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node );continue_menu_loop:      next_node = (Line_Control *) next_node->Node.next;    }    /*     *  If menu items were generated, then insert the end of menu stuff.     */    if ( menu_items ) {      new_line = AllocateLine();      strcpy( new_line->Contents, "@end menu" );      _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node );      new_line = AllocateLine();      strcpy( new_line->Contents, "@end ifinfo" );      _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node );    }    /*     *  Find the UpNodeName     *//* DumpList( &Lines ); */    if ( line->level == 0 ) {      strcpy( UpNodeName, DocsUpNode );    } else {      for ( up_node = line;            up_node && !_Chain_Is_first((Chain_Node *)up_node) ;            up_node = (Line_Control *) up_node->Node.previous            ) {        if ( (up_node->level == -1) )          continue;                  if ( up_node->level == (line->level - 1) ) {           LineCopySectionName( up_node, Buffer );          if (NodeNameIncludesChapter) {            if (!strcmp(ChapterName, Buffer))              sprintf( UpNodeName, "%s", Buffer );            else              sprintf( UpNodeName, "%s %s", ChapterName, Buffer );          } else            sprintf( UpNodeName, "%s", Buffer );          break;        }      }    }    /*     *  Update the node information     */#if 0    fprintf(      stderr,      "@node %s, %s, %s, %s\n",      NodeName,      NextNodeName,      PreviousNodeName,      UpNodeName    );#endif    /* node_line was previously inserted */    if (!NodeNameIncludesChapter) {      sprintf(        node_line->Contents,        "@node %s, %s, %s, %s",        NodeName,        NextNodeName,        PreviousNodeName,        UpNodeName      );    } else {      sprintf(        node_line->Contents,        "@node %s, %s, %s, %s",        NodeName,        NextNodeName,        PreviousNodeName,        UpNodeName      );    }    strcpy( PreviousNodeName, NodeName );    /* PrintLine( line ); */  }}/* *  FormatToTexinfo */void FormatToTexinfo( void ){  Line_Control *line;  int           baselevel = 0;  int           currentlevel;  if ( Verbose )    fprintf( stderr, "-------->INSERTING TEXINFO MENUS\n" );  for ( line = (Line_Control *) Lines.first ;        !_Chain_Is_last( &line->Node ) ;         line = (Line_Control *) line->Node.next ) {    switch (line->keyword) {      case UNUSED:      case KEYWORD_OTHER:      case KEYWORD_END:        line->level = -1;        break;      case KEYWORD_CHAPTER:      case KEYWORD_APPENDIX:      case KEYWORD_PREFACE:      case KEYWORD_CHAPHEADING:        currentlevel = 0;        line->level = baselevel + currentlevel;        break;      case KEYWORD_SECTION:        currentlevel = 1;        line->level = baselevel + currentlevel;        break;      case KEYWORD_SUBSECTION:        currentlevel = 2;        line->level = baselevel + currentlevel;        break;      case KEYWORD_SUBSUBSECTION:        currentlevel = 3;        line->level = baselevel + currentlevel;        break;      case KEYWORD_RAISE:        assert( baselevel );        baselevel--;        line->level = -1;        break;      case KEYWORD_LOWER:        baselevel++;        line->level = -1;        break;    }  }  BuildTexinfoNodes();}/* *  PrintFile */void PrintFile2(  FILE	*OutFile){  Line_Control *line;  if ( !OutFile ) {    fprintf( stderr, "Unable to open (%s) for output\n", "stdout" );    exit_application( 1 );  }  assert( OutFile );  for ( line = (Line_Control *) Lines.first ;        !_Chain_Is_last( &line->Node ) ;         line = (Line_Control *) line->Node.next ) {    fprintf( OutFile, "%s\n", line->Contents );/*    fprintf(      OutFile,      "(%d,%d)%s\n",      line->keyword,      line->format,      line->Contents    );*/  }}/* *  DumpList */void DumpList(   Chain_Control  *the_list){  Line_Control  *line;  fprintf( stderr, "---> Dumping list (%p)\n", the_list );  for ( line = (Line_Control *) the_list->first ;      !_Chain_Is_last( &line->Node ) ;       line = (Line_Control *) line->Node.next ) {    /* if (line->level != -1) */      PrintLine( line );      /* fprintf( stderr, "%s\n", line->Contents ); */  }}/* * ReleaseFile */void ReleaseFile(){   Line_Control *line;   Line_Control *next;   for ( line = (Line_Control *) Lines.first ;         !_Chain_Is_last( &line->Node ) ;        ) {     next = (Line_Control *) line->Node.next;     line = next;   }}/* *  strtoInitialCaps */void strtoInitialCaps(  char *dest,  char *src){  char *source = src;  char *destination = dest;  source = src;  destination = (dest) ? dest : src;  while ( *source ) {    while ( isspace( *source ) )      *destination++ = *source++;    if ( !*source )      break;    *destination++ = toupper( *source++ );    for ( ; *source && !isspace( *source ) ; source++ )      *destination++ = tolower( *source );         if ( !*source )      break;  }  *destination = '\0';}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -