@ -64,12 +64,12 @@
/ / raylib example info struct
typedef struct {
char category [ 16 ] ;
char name [ 64 ] ;
char name [ 128 ] ;
char stars ;
float verCreated ;
float verUpdated ;
char author [ 64 ] ;
char authorGitHub [ 32 ] ;
char authorGitHub [ 64 ] ;
} rlExampleInfo ;
/ / Example management operations
@ -82,6 +82,10 @@ typedef enum {
OP_VALIDATE = 5 , / / Validate examples , using [ examples_list . txt ] as main source by default
} rlExampleOperation ;
# define MAX_EXAMPLE_CATEGORIES 8
static const char * exCategories [ MAX_EXAMPLE_CATEGORIES ] = { " core " , " shapes " , " textures " , " text " , " models " , " shaders " , " audio " , " others " } ;
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/ / Module specific functions declaration
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -91,7 +95,9 @@ static int FileRename(const char *fileName, const char *fileRename);
static int FileRemove ( const char * fileName ) ;
/ / Load examples collection information
static rlExampleInfo * LoadExamplesData ( const char * fileName , int * exCount ) ;
/ / NOTE 1 : Load by category : " ALL " , " core " , " shapes " , " textures " , " text " , " models " , " shaders " , others "
/ / NOTE 2 : Sort examples list on request flag
static rlExampleInfo * LoadExamplesData ( const char * fileName , const char * category , bool sort , int * exCount ) ;
static void UnloadExamplesData ( rlExampleInfo * exInfo ) ;
/ / Get text lines ( by line - breaks ' \n ' )
@ -104,7 +110,7 @@ static int ParseExampleInfoLine(const char *line, rlExampleInfo *entry);
/ / Sort array of strings by name
/ / WARNING : items [ ] pointers are reorganized
static void SortStringsByName ( char * * items , int count ) ;
static void SortExampleByName ( rlExampleInfo * items , int count ) ;
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/ / Program main entry point
@ -117,8 +123,8 @@ int main(int argc, char *argv[])
char * exWebPath = " C:/GitHub/raylib.com/examples " ;
char * exTemplateFilePath = " C:/GitHub/raylib/examples/examples_template.c " ;
char * exTemplateScreenshot = " C:/GitHub/raylib/examples/examples_template.png " ;
char * exCollectionList = " C:/GitHub/raylib/examples/examples_list.txt " ;
char * exCollectionListPath = " C:/GitHub/raylib/examples/examples_list.txt " ;
char inFileName [ 1024 ] = { 0 } ; / / Example input filename ( to be added )
char exName [ 64 ] = { 0 } ; / / Example name , without extension : core_basic_window
@ -203,12 +209,29 @@ int main(int argc, char *argv[])
}
}
/ / Load examples collection information
/ / exInfo = LoadExamplesData ( exCollectionListPath , " core " , true , & exInfoCount ) ;
/ / for ( int i = 0 ; i < exInfoCount ; i + + ) printf ( " %i - %s [%i] \n " , i + 1 , exInfo [ i ] . name , exInfo [ i ] . stars ) ;
switch ( opCode )
{
case 1 : / / Create : New example from template
{
/ / Create : raylib / examples / < category > / < category > _example_name . c
FileCopy ( exTemplateFilePath , TextFormat ( " %s/%s/%s.c " , exBasePath , exCategory , exName ) ) ;
char * exText = LoadFileText ( exTemplateFilePath ) ;
char * exTextUpdated [ 6 ] = { 0 } ;
int exIndex = TextFindIndex ( exText , " /**************** " ) ;
exTextUpdated [ 0 ] = TextReplace ( exText + exIndex , " <module> " , exCategory ) ;
exTextUpdated [ 1 ] = TextReplace ( exTextUpdated [ 0 ] , " <name> " , exName + strlen ( exCategory ) + 1 ) ;
/ / TextReplace ( newExample , " <user_name> " , " Ray " ) ;
/ / TextReplace ( newExample , " @<user_github> " , " @raysan5 " ) ;
/ / TextReplace ( newExample , " <year_created> " , 2025 ) ;
/ / TextReplace ( newExample , " <year_updated> " , 2025 ) ;
SaveFileText ( TextFormat ( " %s/%s/%s.c " , exBasePath , exCategory , exName ) , exTextUpdated [ 1 ] ) ;
for ( int i = 0 ; i < 6 ; i + + ) { MemFree ( exTextUpdated [ i ] ) ; exTextUpdated [ i ] = NULL ; }
UnloadFileText ( exText ) ;
}
case 2 : / / Add : Example from command - line input filename
{
@ -220,45 +243,174 @@ int main(int argc, char *argv[])
/ / Copy : raylib / examples / < category > / resources / . . . / / WARNING : To be updated manually !
/ / Check if example is already listed
/ / If not , add to the main examples_list
/ / TODO : Update the required files to add new example in the required position ( ordered by category and name ) ,
/ / it could require some logic to make it possible . . .
/ / Add example to the main collection list , if not already there
/ / NOTE : Required format : shapes ; shapes_basic_shapes ; ⭐ ️ ☆ ☆ ☆ ; 1.0 ; 4.2 ; " Ray " ; @ raysan5
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
char * exColInfo = LoadFileText ( exCollectionListPath ) ;
if ( TextFindIndex ( exColInfo , exName ) = = - 1 ) / / Example not found
{
char * exColInfoUpdated = ( char * ) RL_CALLOC ( 2 * 1024 * 1024 , 1 ) ; / / Updated list copy , 2 MB
/ / Add example to the main list , by category
/ / by default add it last in the category list
/ / NOTE : When populating to other files , lists are sorted by name
int nextCatIndex = 0 ;
if ( strcmp ( exCategory , " core " ) = = 0 ) nextCatIndex = 1 ;
else if ( strcmp ( exCategory , " shapes " ) = = 0 ) nextCatIndex = 2 ;
else if ( strcmp ( exCategory , " textures " ) = = 0 ) nextCatIndex = 3 ;
else if ( strcmp ( exCategory , " text " ) = = 0 ) nextCatIndex = 4 ;
else if ( strcmp ( exCategory , " models " ) = = 0 ) nextCatIndex = 5 ;
else if ( strcmp ( exCategory , " shaders " ) = = 0 ) nextCatIndex = 6 ;
else if ( strcmp ( exCategory , " audio " ) = = 0 ) nextCatIndex = 7 ;
else if ( strcmp ( exCategory , " others " ) = = 0 ) nextCatIndex = - 1 ; / / Add to EOF
if ( nextCatIndex = = - 1 )
{
/ / Add example to the end of the list
int endIndex = ( int ) strlen ( exColInfo ) ;
memcpy ( exColInfoUpdated , exColInfo , endIndex ) ;
sprintf ( exColInfoUpdated + endIndex , TextFormat ( " \n %s/%s \n " , exCategory , exName ) ) ;
}
else
{
/ / Add example to the end of the category list
/ / TODO : Get required example info from example file header ( if provided )
/ / NOTE : If no example info is provided ( other than category / name ) , just using some default values
int catIndex = TextFindIndex ( exColInfo , exCategories [ nextCatIndex ] ) ;
memcpy ( exColInfoUpdated , exColInfo , catIndex ) ;
int textWritenSize = sprintf ( exColInfoUpdated + catIndex , TextFormat ( " %s;%s;⭐️☆☆☆;6.0;6.0; \" Ray \" ;@raysan5 \n " , exCategory , exName ) ) ;
memcpy ( exColInfoUpdated + catIndex + textWritenSize , exColInfo + catIndex , strlen ( exColInfo ) - catIndex ) ;
}
SaveFileText ( exCollectionListPath , exColInfoUpdated ) ;
RL_FREE ( exColInfoUpdated ) ;
}
UnloadFileText ( exColInfo ) ;
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/ / Edit : raylib / examples / Makefile - - > Add new example
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*
char * mkText = LoadFileText ( TextFormat ( " %s/Makefile " , exBasePath ) ) ;
char * mkTextUpdated = ( char * ) RL_CALLOC ( 2 * 1024 * 1024 , 1 ) ; / / Updated Makefile copy , 2 MB
int exListStartIndex = TextFindIndex ( mkText , " #EXAMPLES_LIST_START " ) ;
int exListEndIndex = TextFindIndex ( mkText , " #EXAMPLES_LIST_END " ) ;
char * mkTextUpdate = ( char * ) RL_CALLOC ( 2 * 1024 * 1024 , 1 ) ; / / 2 MB
memcpy ( mkTextUpdate , mkText , exListStartIndex ) ;
/ / TODO : Update required lines . . .
/ / SaveFileText ( TextFormat ( " %s/Makefile " , exBasePath ) , mkTextUpdate ) ;
int mkIndex = 0 ;
memcpy ( mkTextUpdated , mkText , exListStartIndex ) ;
mkIndex = sprintf ( mkTextUpdated + exListStartIndex , " #EXAMPLES_LIST_START \n " ) ;
for ( int i = 0 ; i < MAX_EXAMPLE_CATEGORIES ; i + + )
{
mkIndex + = sprintf ( mkTextUpdated + exListStartIndex + mkIndex , TextFormat ( " %s = \\ \n " , TextToUpper ( exCategories [ i ] ) ) ) ;
int exCount = 0 ;
rlExampleInfo * exCatList = LoadExamplesData ( exCollectionListPath , exCategories [ i ] , true , & exCount ) ;
for ( int x = 0 ; x < exCount - 1 ; x + + ) mkIndex + = sprintf ( mkTextUpdated + exListStartIndex + mkIndex , TextFormat ( " %s/%s \\ \n " , exCatList [ x ] . category , exCatList [ x ] . name ) ) ;
mkIndex + = sprintf ( mkTextUpdated + exListStartIndex + mkIndex , TextFormat ( " %s/%s \n \n " , exCatList [ exCount - 1 ] . category , exCatList [ exCount - 1 ] . name ) ) ;
UnloadExamplesData ( exCatList ) ;
}
/ / Add the remaining part of the original file
memcpy ( mkTextUpdated + exListStartIndex + mkIndex , mkText + exListEndIndex , strlen ( mkText ) - exListEndIndex ) ;
/ / Save updated file
SaveFileText ( TextFormat ( " %s/Makefile " , exBasePath ) , mkTextUpdated ) ;
UnloadFileText ( mkText ) ;
RL_FREE ( mkTextUpdate ) ;
RL_FREE ( mkTextUpdated ) ;
*/
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/ / Edit : raylib / examples / Makefile . Web - - > Add new example
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/ / TODO .
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/ / Edit : raylib / examples / README . md - - > Add new example
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/ / TODO : Use [ examples_list . txt ] to update / regen README . md
/ / Look for " | 01 | "
/ / Lines format : | 01 | [ core_basic_window ] ( core / core_basic_window . c ) | < img src = " core/core_basic_window.png " alt = " core_basic_window " width = " 80 " > | ⭐ ️ ☆ ☆ ☆ | 1.0 | 1.0 | [ Ray ] ( https : / / github . com / raysan5 ) |
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/ / Create : raylib / projects / VS2022 / examples / < category > _example_name . vcxproj
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileCopy ( TextFormat ( " %s/../projects/VS2022/examples/core_basic_window.vcxproj " , exBasePath ) ,
TextFormat ( " %s/../projects/VS2022/examples/%s.vcxproj " , exBasePath , exName ) ) ;
FileTextReplace ( , " core_basic_window " , exName ) ;
FileTextReplace ( , " .. \ .. \ examples \ core " , TextFormat ( " .. \ .. \ examples \ %s " , exCategory ) ) ;
FileTextReplace ( TextFormat ( " %s/../projects/VS2022/examples/%s.vcxproj " , exBasePath , exName ) ,
" core_basic_window " , exName ) ;
FileTextReplace ( TextFormat ( " %s/../projects/VS2022/examples/%s.vcxproj " , exBasePath , exName ) ,
" .. \\ .. \\ examples \\ core " , TextFormat ( " .. \\ .. \\ examples \\ %s " , exCategory ) ) ;
/ / Edit : raylib / projects / VS2022 / raylib . sln - - > Add new example project
system ( TextFormat ( " dotnet solution raylib.sln add %s/../projects/VS2022/examples/%s.vcxproj " , exBasePath , exName ) ) ;
system ( TextFormat ( " dotnet solution %s/../projects/VS2022/raylib.sln add %s/../projects/VS2022/examples/%s.vcxproj " , exBasePath , exBasePath , exName ) ) ;
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/ / Edit : raylib . com / common / examples . js - - > Add new example
/ / Entries format : exampleEntry ( ' ⭐ ️ ☆ ☆ ☆ ' , ' core ' , ' basic_window ' ) ,
/ / NOTE : Entries format : exampleEntry ( ' ⭐ ️ ☆ ☆ ☆ ' , ' core ' , ' basic_window ' ) ,
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
char * jsText = LoadFileText ( TextFormat ( " %s/../common/examples.js " , exWebPath ) ) ;
char * jsTextUpdated = ( char * ) RL_CALLOC ( 2 * 1024 * 1024 , 1 ) ; / / Updated examples . js copy , 2 MB
int exListStartIndex = TextFindIndex ( jsText , " //EXAMPLE_DATA_LIST_START " ) ;
int exListEndIndex = TextFindIndex ( jsText , " //EXAMPLE_DATA_LIST_END " ) ;
int mkIndex = 0 ;
memcpy ( jsTextUpdated , jsText , exListStartIndex ) ;
mkIndex = sprintf ( jsTextUpdated + exListStartIndex , " #EXAMPLES_LIST_START \n " ) ;
int jsIndex = 0 ;
memcpy ( jsTextUpdated , jsText , exListStartIndex ) ;
jsIndex = sprintf ( jsTextUpdated + exListStartIndex , " //EXAMPLE_DATA_LIST_START \n " ) ;
jsIndex + = sprintf ( jsTextUpdated + exListStartIndex + jsIndex , " var exampleData = [ \n " ) ;
/ / NOTE : We avoid " others " category
for ( int i = 0 , exCount = 0 ; i < MAX_EXAMPLE_CATEGORIES - 1 ; i + + )
{
rlExampleInfo * exCatList = LoadExamplesData ( exCollectionListPath , exCategories [ i ] , false , & exCount ) ;
for ( int x = 0 ; x < exCount ; x + + )
{
char stars [ 16 ] = { 0 } ;
for ( int s = 0 ; s < 4 ; s + + )
{
if ( s < exCatList [ x ] . stars ) strcpy ( stars + 3 * s , " ⭐️ " ) ;
else strcpy ( stars + 3 * s , " ☆ " ) ;
}
if ( ( i = = 6 ) & & ( x = = ( exCount - 1 ) ) )
{
/ / Last line to add , special case to consider
jsIndex + = sprintf ( jsTextUpdated + exListStartIndex + jsIndex ,
TextFormat ( " exampleEntry('%s', '%s', '%s')]; \n " , stars , exCatList [ x ] . category , exCatList [ x ] . name + strlen ( exCatList [ x ] . category ) + 1 ) ) ;
}
else
{
jsIndex + = sprintf ( jsTextUpdated + exListStartIndex + jsIndex ,
TextFormat ( " exampleEntry('%s', '%s', '%s'), \n " , stars , exCatList [ x ] . category , exCatList [ x ] . name + strlen ( exCatList [ x ] . category ) + 1 ) ) ;
}
}
UnloadExamplesData ( exCatList ) ;
}
/ / Add the remaining part of the original file
memcpy ( jsTextUpdated + exListStartIndex + jsIndex , jsText + exListEndIndex , strlen ( jsText ) - exListEndIndex ) ;
/ / Save updated file
SaveFileText ( TextFormat ( " %s/../common/examples.js " , exWebPath ) , jsTextUpdated ) ;
UnloadFileText ( jsText ) ;
RL_FREE ( jsTextUpdated ) ;
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/ / Recompile example ( on raylib side )
/ / NOTE : Tools requirements : emscripten , w64devkit
@ -266,7 +418,9 @@ int main(int argc, char *argv[])
/ / Compile to : raylib . com / examples / < category > / < category > _example_name . data
/ / Compile to : raylib . com / examples / < category > / < category > _example_name . wasm
/ / Compile to : raylib . com / examples / < category > / < category > _example_name . js
system ( TextFormat ( " %s/../build_example_web.bat %s \ %s " , exBasePath , exCategory , exName ) ) ;
/ / TODO : WARNING : This . BAT is not portable and it does not consider RESOURCES for Web properly ,
/ / Makefile . Web should be used . . . but it requires proper editing first !
system ( TextFormat ( " %s/build_example_web.bat %s/%s " , exBasePath , exCategory , exName ) ) ;
/ / Copy results to web side
FileCopy ( TextFormat ( " %s/%s/%s.html " , exBasePath , exCategory , exName ) ,
@ -303,7 +457,7 @@ int main(int argc, char *argv[])
/ / Recompile example ( on raylib side )
/ / NOTE : Tools requirements : emscripten , w64devkit
system ( TextFormat ( " %s/../build_example_web.bat %s< /span>\ %s " , exBasePath , exCategory , exName ) ) ;
system ( TextFormat ( " %s/../build_example_web.bat %s/%s " , exBasePath , exCategory , exName ) ) ;
/ / Copy results to web side
FileCopy ( TextFormat ( " %s/%s/%s.html " , exBasePath , exCategory , exName ) ,
@ -382,14 +536,15 @@ int main(int argc, char *argv[])
/ / Module specific functions definition
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/ / Load examples collection information
static rlExampleInfo * LoadExamplesData ( const char * fileName , int * exCount )
static rlExampleInfo * LoadExamplesData ( const char * fileName , ">const char * category , bool sort , int * exCount )
{
# define MAX_EXAMPLES_INFO 256
* exCount = 0 ;
rlExampleInfo * exInfo = ( rlExampleInfo * ) RL_CALLOC ( MAX_EXAMPLES_INFO , sizeof ( rlExampleInfo ) ) ;
int exCounter = 0 ;
* exCount = 0 ;
const char * text = LoadFileText ( fileName ) ;
char * text = LoadFileText ( fileName ) ;
if ( text ! = NULL )
{
@ -407,11 +562,33 @@ static rlExampleInfo *LoadExamplesData(const char *fileName, int *exCount)
( linePtrs [ i ] [ 0 ] = = ' a ' ) | | / / audio
( linePtrs [ i ] [ 0 ] = = ' o ' ) ) ) / / others
{
if ( ParseExampleInfoLine ( linePtrs [ i ] , & exInfo [ * exCount ] ) = = 0 ) * exCount + = 1 ;
rlExampleInfo info = { 0 } ;
int result = ParseExampleInfoLine ( linePtrs [ i ] , & info ) ;
if ( result = = 1 ) / / Success on parsing
{
if ( strcmp ( category , " ALL " ) = = 0 )
{
/ / Add all examples to the list
memcpy ( & exInfo [ exCounter ] , & info , sizeof ( rlExampleInfo ) ) ;
exCounter + + ;
}
else if ( strcmp ( info . category , category ) = = 0 )
{
/ / Get only specific category examples
memcpy ( & exInfo [ exCounter ] , & info , sizeof ( rlExampleInfo ) ) ;
exCounter + + ;
}
}
}
}
UnloadFileText ( text ) ;
}
/ / Sorting required
if ( sort ) SortExampleByName ( exInfo , exCounter ) ;
* exCount = exCounter ;
return exInfo ;
}
@ -482,7 +659,7 @@ static int FileRemove(const char *fileName)
/ / WARNING : It does not copy text data , just returns line pointers
static const char * * GetTextLines ( const char * text , int * count )
{
# define MAX_TEXT_LINE_PTRS 128
# define MAX_TEXT_LINE_PTRS 5 12
static const char * linePtrs [ MAX_TEXT_LINE_PTRS ] = { 0 } ;
for ( int i = 0 ; i < MAX_TEXT_LINE_PTRS ; i + + ) linePtrs [ i ] = NULL ; / / Init NULL pointers to substrings
@ -509,7 +686,7 @@ static const char **GetTextLines(const char *text, int *count)
}
/ / raylib example line info parser
/ / Parses following line format : core o">/ core_basic_window ; ⭐ ️ ☆ ☆ ☆ ; 1.0 ; 1.0 ; " Ray " o">/ @ raysan5
/ / Parses following line format : core p">; core_basic_window ; ⭐ ️ ☆ ☆ ☆ ; 1.0 ; 1.0 ; " Ray " p">; @ raysan5
static int ParseExampleInfoLine ( const char * line , rlExampleInfo * entry )
{
# define MAX_EXAMPLE_INFO_LINE_LEN 512
@ -522,8 +699,8 @@ static int ParseExampleInfoLine(const char *line, rlExampleInfo *entry)
char * * tokens = TextSplit ( line , ' ; ' , & tokenCount ) ;
/ / Get category and name
strn cpy ( entry - > category , tokens [ 0 ], sizeof ( entry - > category ) ) ;
strn cpy ( entry - > name , tokens [ 1 ], sizeof ( entry - > name ) ) ;
strcpy ( entry - > category , tokens [ 0 ] ) ;
strcpy ( entry - > name , tokens [ 1 ] ) ;
/ / Parsing stars
/ / NOTE : Counting the unicode char occurrences : ⭐ ️
@ -547,24 +724,24 @@ static int ParseExampleInfoLine(const char *line, rlExampleInfo *entry)
/ / Get author and github
char * quote1 = strchr ( tokens [ 5 ] , ' " ' ) ;
char * quote2 = quote1 ? strchr ( quote1 + 1 , ' " ' ) : NULL ;
if ( quote1 & & quote2 ) strn cpy ( entry - > author , quote1 + 1, sizeof ( entry - > author ) ) ;
strn cpy ( entry - > authorGitHub , tokens [ 6 ], sizeof ( entry - > authorGitHub ) ) ;
if ( quote1 & & quote2 ) strcpy ( entry - > author , quote1 + 1 ) ;
strcpy ( entry - > authorGitHub , tokens [ 6 ] ) ;
return 1 ;
}
/ / Text compare , required for qsort ( ) function
static int SortText Compare( const void * a , const void * b )
static int rlExampleInfo Compare( const void * a , const void * b )
{
const kt">char * str1 = * ( const char * * ) a ;
const kt">char * str2 = * ( const char * * ) b ;
const n">rlExampleInfo * ex1 = ( const rlExampleInfo * ) a ;
const n">rlExampleInfo * ex2 = ( const rlExampleInfo * ) b ;
return strcmp ( str1 , str2 ) ;
return strcmp ( ex1 - > name , ex2 - > name ) ;
}
/ / Sort array of strings by name
/ / WARNING : items [ ] pointers are reorganized
static void SortStringsByName ( char * * items , int count )
static void SortExampleByName ( rlExampleInfo * items , int count )
{
qsort ( items , count , sizeof ( kt">char * ) , SortText Compare ) ;
qsort ( items , count , sizeof ( n">rlExampleInfo ) , rlExampleInfo Compare ) ;
}