"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "load_logo.c" between
linux_logo-5.11.tar.gz and linux_logo-6.0.tar.gz

About: Linux_Logo - an ANSI Color Penguin Logo that can be run at bootup. Also shows some system info.

load_logo.c  (linux_logo-5.11):load_logo.c  (linux_logo-6.0)
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "logo_types.h" #include "logo_types.h"
/* Loads a logo from disk */ /* Loads a logo from disk */
struct logo_info *load_logo_from_disk(char *filename) { struct logo_info *load_logo_from_disk(char *filename) {
struct logo_info *new_logo; struct logo_info *new_logo;
int logo_start=0,ascii_logo_start=0; int logo_start=0,ascii_logo_start=0;
int ascii_size=0,size=0; int ascii_size=0,size=0;
char temp_st[BUFSIZ]; char temp_st[BUFSIZ];
FILE *fff; FILE *fff;
char *result;
new_logo=calloc(1,sizeof(struct logo_info));
new_logo=calloc(1,sizeof(struct logo_info));
if (new_logo==NULL) {
printf("Error allocating memory!\n"); if (new_logo==NULL) {
return NULL; printf("Error allocating memory!\n");
} return NULL;
}
fff=fopen(filename,"r");
if (fff==NULL) { fff=fopen(filename,"r");
printf("Error loading logo: %s\n",filename); if (fff==NULL) {
return NULL; printf("Error loading logo: %s\n",filename);
} return NULL;
}
new_logo->logo=NULL;
new_logo->ascii_logo=NULL; new_logo->logo=NULL;
new_logo->ascii_logo=NULL;
while (!feof(fff)) {
fgets(temp_st,BUFSIZ,fff); while (!feof(fff)) {
result=fgets(temp_st,BUFSIZ,fff);
if (!strncmp(temp_st,"END_LOGO",8)) logo_start=0; if (result==NULL) {
if (!strncmp(temp_st,"END_ASCII_LOGO",14)) ascii_logo_start=0; break;
}
if (logo_start) {
size+=strlen(temp_st); if (!strncmp(temp_st,"END_LOGO",8)) logo_start=0;
if (!strncmp(temp_st,"END_ASCII_LOGO",14)) ascii_logo_start=0;
if (new_logo->logo==NULL) {
new_logo->logo=strdup(temp_st); if (logo_start) {
} size+=strlen(temp_st);
else {
new_logo->logo=realloc(new_logo->logo,size+1); if (new_logo->logo==NULL) {
strncat( new_logo->logo,temp_st,strlen(temp_st)); new_logo->logo=strdup(temp_st);
} }
else {
new_logo->ysize++; new_logo->logo=realloc(new_logo->logo,size+1);
} if (new_logo->logo==NULL) {
printf("realloc of size %d failed!\n",siz
if (ascii_logo_start) { e+1);
ascii_size+=strlen(temp_st); return NULL;
}
if (new_logo->ascii_logo==NULL) { memcpy(new_logo->logo+strlen(new_logo->logo),
new_logo->ascii_logo=strdup(temp_st); temp_st,strlen(temp_st)+1);
} }
else { new_logo->ysize++;
new_logo->ascii_logo=realloc(new_logo->ascii_logo,ascii_size+1); }
strncat( new_logo->ascii_logo,temp_st,strlen(temp_st));
} if (ascii_logo_start) {
new_logo->ascii_ysize++; ascii_size+=strlen(temp_st);
}
if (new_logo->ascii_logo==NULL) {
if (!strncmp(temp_st,"BEGIN_ASCII_LOGO",16)) ascii_logo_start=1; new_logo->ascii_logo=strdup(temp_st);
if (!strncmp(temp_st,"BEGIN_LOGO",10)) logo_start=1; }
else {
if ( (!ascii_logo_start) && (!logo_start) ) { new_logo->ascii_logo=realloc(
if (!strncmp(temp_st,"SYSINFO_POSITION",16)) { new_logo->ascii_logo,ascii_size+1);
if (!strncmp(temp_st+17,"bottom",6)) { memcpy( new_logo->ascii_logo
new_logo->sysinfo_position=SYSINFO_BOTTOM; +strlen(new_logo->ascii_logo),
} temp_st,strlen(temp_st)+1);
if (!strncmp(temp_st+17,"right",5)) { }
new_logo->sysinfo_position=SYSINFO_RIGHT; new_logo->ascii_ysize++;
} }
}
if (!strncmp(temp_st,"DESCRIPTION_STRING",18)) { if (!strncmp(temp_st,"BEGIN_ASCII_LOGO",16)) {
new_logo->description=strdup(temp_st+19); ascii_logo_start=1;
new_logo->description[strlen(new_logo->description)-1]=0; }
} if (!strncmp(temp_st,"BEGIN_LOGO",10)) {
if (!strncmp(temp_st,"NAME",4)) { logo_start=1;
new_logo->name=strdup(temp_st+5); }
new_logo->name[strlen(new_logo->name)-1]=0;
} if ( (!ascii_logo_start) && (!logo_start) ) {
} if (!strncmp(temp_st,"SYSINFO_POSITION",16)) {
} if (!strncmp(temp_st+17,"bottom",6)) {
new_logo->sysinfo_position=
SYSINFO_BOTTOM;
}
if (!strncmp(temp_st+17,"right",5)) {
new_logo->sysinfo_position=
SYSINFO_RIGHT;
}
}
if (!strncmp(temp_st,"DESCRIPTION_STRING",18)) {
new_logo->description=strdup(temp_st+19);
new_logo->description[strlen(
new_logo->description)-1]=0;
}
if (!strncmp(temp_st,"NAME",4)) {
new_logo->name=strdup(temp_st+5);
new_logo->name[strlen(new_logo->name)-1]=0;
}
}
}
new_logo->next_logo=NULL; new_logo->next_logo=NULL;
fclose(fff); fclose(fff);
return new_logo; return new_logo;
} }
 End of changes. 4 change blocks. 
80 lines changed or deleted 99 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)