4
#include "logo_types.h"
6
/* Loads a logo from disk */
7
struct logo_info *load_logo_from_disk(char *filename) {
9
struct logo_info *new_logo;
10
int logo_start=0,ascii_logo_start=0;
11
int ascii_size=0,size=0;
15
new_logo=calloc(1,sizeof(struct logo_info));
18
printf("Error allocating memory!\n");
22
fff=fopen(filename,"r");
24
printf("Error loading logo: %s\n",filename);
29
new_logo->ascii_logo=NULL;
32
fgets(temp_st,BUFSIZ,fff);
34
if (!strncmp(temp_st,"END_LOGO",8)) logo_start=0;
35
if (!strncmp(temp_st,"END_ASCII_LOGO",14)) ascii_logo_start=0;
38
size+=strlen(temp_st);
40
if (new_logo->logo==NULL) {
41
new_logo->logo=strdup(temp_st);
44
new_logo->logo=realloc(new_logo->logo,size+1);
45
strncat( new_logo->logo,temp_st,strlen(temp_st));
51
if (ascii_logo_start) {
52
ascii_size+=strlen(temp_st);
54
if (new_logo->ascii_logo==NULL) {
55
new_logo->ascii_logo=strdup(temp_st);
58
new_logo->ascii_logo=realloc(new_logo->ascii_logo,ascii_size+1);
59
strncat( new_logo->ascii_logo,temp_st,strlen(temp_st));
61
new_logo->ascii_ysize++;
64
if (!strncmp(temp_st,"BEGIN_ASCII_LOGO",16)) ascii_logo_start=1;
65
if (!strncmp(temp_st,"BEGIN_LOGO",10)) logo_start=1;
67
if ( (!ascii_logo_start) && (!logo_start) ) {
68
if (!strncmp(temp_st,"SYSINFO_POSITION",16)) {
69
if (!strncmp(temp_st+17,"bottom",6)) {
70
new_logo->sysinfo_position=SYSINFO_BOTTOM;
72
if (!strncmp(temp_st+17,"right",5)) {
73
new_logo->sysinfo_position=SYSINFO_RIGHT;
76
if (!strncmp(temp_st,"DESCRIPTION_STRING",18)) {
77
new_logo->description=strdup(temp_st+19);
78
new_logo->description[strlen(new_logo->description)-1]=0;
80
if (!strncmp(temp_st,"NAME",4)) {
81
new_logo->name=strdup(temp_st+5);
82
new_logo->name[strlen(new_logo->name)-1]=0;
87
new_logo->next_logo=NULL;