~ubuntu-branches/ubuntu/utopic/linuxlogo/utopic-proposed

« back to all changes in this revision

Viewing changes to linux_logo.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-07-14 12:40:04 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090714124004-oacwhjx94isy0zaz
Tags: 5.06-1
* Merging upstream version 5.06:
  - Fixes problem with logo naming (Closes: #510813).
* Readding default logo in linux_logo.conf.
* Removing dash.patch, not required anymore.
* Updating logo list in linux_logo.conf.
* Renaming directory for local debian additions to more common name.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*-------------------------------------------------------------------------*\
2
 
  LINUX LOGO 5.04 - Creates Nifty Logo With System Info - 12 December 2008
 
2
  LINUX LOGO 5.06 - Creates Nifty Logo With System Info - 1 July 2009
3
3
 
4
4
    by Vince Weaver (vince@deater.net, http://www.deater.net/weave )
5
5
 
10
10
\*-------------------------------------------------------------------------*/
11
11
 
12
12
 
13
 
#define VERSION "5.04"
 
13
#define VERSION "5.06"
14
14
 
15
15
#include <stdio.h>
16
16
#include <stdlib.h>   /* calloc() */
609
609
 
610
610
 
611
611
    /* global variables, a bit of a hack, should find a better way */
612
 
int logo_num=0,logo_override=0,random_logo=0,want_list_logos=0;
613
 
char random_type='e',random_type2='e',*logo_name=NULL,*logo_disk=NULL;
 
612
int logo_num=0,random_logo=0,want_list_logos=0;
 
613
char random_banner='e',random_ascii='e',*logo_name=NULL,*logo_disk=NULL;
614
614
 
615
615
 
616
616
    /* Find a logo by name */
652
652
}
653
653
 
654
654
   /* find a random logo */
655
 
static struct logo_info *get_random_logo(int random_type, int random_type2,
 
655
static struct logo_info *get_random_logo(int random_banner, 
 
656
                                         int random_ascii,
656
657
                       struct linux_logo_info_type *settings) {
657
658
 
658
659
    struct timeval time_time;
673
674
    i=0;
674
675
    while (i<2) {
675
676
       logo_found=1;
676
 
       if (random_type=='b') { /* Want banner mode */
 
677
       if (random_banner=='b') { /* Want banner mode */
677
678
          if (!custom_logo->sysinfo_position) logo_found=0;
678
679
          else settings->banner_mode=1;
679
680
       }
680
 
       if (random_type=='c') { /* Want classic mode */
 
681
       if (random_banner=='c') { /* Want classic mode */
681
682
          if (custom_logo->sysinfo_position) logo_found=0;
682
683
          else settings->banner_mode=0;
683
684
       }
684
 
       if (random_type=='e') { /* Want either */
 
685
       if (random_banner=='e') { /* Want either */
685
686
          /* we should be OK */
686
687
       }
687
688
 
688
 
       if (random_type2=='e') { /* Any logo at all */
 
689
       if (random_ascii=='e') { /* Any logo at all */
689
690
          settings->plain_ascii=rand()%2;
690
691
          if (custom_logo->ascii_logo==NULL) {
691
692
             settings->plain_ascii=!settings->plain_ascii;
692
693
          }
693
694
       }
694
 
       if (random_type2=='a') { /* Want Ascii */
 
695
       if (random_ascii=='a') { /* Want Ascii */
695
696
          if (custom_logo->ascii_logo==NULL) logo_found=0;
696
697
          else settings->plain_ascii=1;
697
698
       }
698
699
 
699
 
       if (random_type2=='n') { /* Want non-ascii */
 
700
       if (random_ascii=='n') { /* Want non-ascii */
700
701
          if (custom_logo->logo==NULL) logo_found=0;
701
702
          else settings->plain_ascii=0;
702
703
          break;
780
781
                    break;
781
782
          case 'D': argument=get_arg(&index,argc,argv);
782
783
                    logo_disk=strdup(argument);
 
784
                    logo_name=NULL;
783
785
                    break;
784
786
          case 'e': argument=get_arg(&index,argc,argv);
785
787
                    set_cpuinfo_file(argument);
830
832
          case 'l': settings->display_logo_only=1;
831
833
                    break;  
832
834
          case 'L': argument=get_arg(&index,argc,argv);
833
 
                       /* Reset values in case we get this after reading the file */
834
 
                    logo_num = 1; logo_override = 0; random_logo = 0;
 
835
                       /* Reset values in case we get this after reading */
 
836
                       /* the file */
 
837
                    logo_num = 1; random_logo = 0;
835
838
                    logo_num=strtol(argument,&endptr,10);
836
839
                    if ( endptr == argument ) {
837
840
                          /* we leak temp_st, need to fix */
841
844
                       }
842
845
                       else if (!strncmp(temp_st,"random",6)) {
843
846
                          random_logo=1;
844
 
                          random_type=temp_st[7];
845
 
                          random_type2=temp_st[8];
 
847
                          if (strlen(temp_st)>7) {
 
848
                             random_banner=temp_st[7];
 
849
                          }
 
850
                          if (strlen(temp_st)>8) {
 
851
                             random_ascii=temp_st[8];
 
852
                          }
846
853
                       }
847
854
                       else {
848
855
                          logo_name=strdup(temp_st);
849
856
                       }
850
857
                    }
851
 
                    else { /* It's a number */
852
 
                       logo_override=1;
 
858
                    else { /* It's a number.  Override any name */
 
859
                       logo_name=NULL;
853
860
                    }
854
861
                    break;  
855
862
 
1039
1046
    if (want_list_logos) list_logos();
1040
1047
 
1041
1048
       /* If user requested random logo, get one */
1042
 
    if (random_logo) custom_logo=get_random_logo(random_type,random_type2,&settings);
1043
 
 
 
1049
    if (random_logo) {
 
1050
       custom_logo=get_random_logo(random_banner,
 
1051
                                   random_ascii,
 
1052
                                   &settings);
 
1053
    }
1044
1054
       /* If user requested logo by number, get it */
1045
 
    if (logo_num!=0) custom_logo=get_logo_by_number(logo_num);
1046
 
 
 
1055
    else if (logo_num!=0) {
 
1056
       custom_logo=get_logo_by_number(logo_num);
 
1057
    }
1047
1058
       /* If user requested logo by name, get it */
1048
 
    if (logo_name!=NULL) custom_logo=get_logo_by_name(logo_name);
1049
 
 
 
1059
    else if (logo_name!=NULL) {
 
1060
       custom_logo=get_logo_by_name(logo_name);
 
1061
    }
1050
1062
       /* If user wants a logo from disk, get it */
1051
 
    if (logo_disk!=NULL) custom_logo=load_logo_from_disk(logo_disk);
1052
 
 
 
1063
    else if (logo_disk!=NULL) {
 
1064
       custom_logo=load_logo_from_disk(logo_disk);
 
1065
    }
1053
1066
       /* We have to keep these consistent or funny things happen */
1054
1067
    if (custom_logo!=NULL) settings.banner_mode=custom_logo->sysinfo_position;
1055
1068