forked from iPodLinux/podzilla0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
about.c
120 lines (106 loc) · 3.17 KB
/
about.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* Copyright (C) 2004, 2005 Courtney Cavin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "pz.h"
#include "ipod.h"
#define BUFSIZR 2048
#define NUM_GENS 13
static char *buf = NULL;
extern void new_stringview_window(char *buf, char *title);
static void populate_credits() {
int i, len = 0;
char *cnames[] = {"Bernard Leach", "Matthew J. Sahagian",
"Courtney Cavin", "matz-josh", "Matthis Rouch",
"ansi", "Jens Taprogge", "Fredrik Bergholtz",
"Jeffrey Nelson", "Scott Lawrence",
"Cameron Nishiyama", "Prashant V", "Alastair Stuart",
"David Carne", "Nik Rolls", "Filippo Forlani",
"Martin Kaltenbrunner", "Adam Johnston",
"Matthew Westcott", "Nils Schneider", "Damien Marchal",
"Joshua Oreman", "Brett Ryland",
0};
for (i = 0; cnames[i] != 0; i++)
len += strlen(cnames[i]) + 9;
buf = malloc(sizeof(char) * (len + 47));
strcpy(buf, "Brought to you by:\n\n");
for (i = 0; cnames[i] != 0; i++) {
strcat(buf, " ");
strcat(buf, cnames[i]);
strcat(buf, "\n");
}
strcat(buf, "\nhttp://www.ipodlinux.org\n");
}
static void populate_about() {
int i;
char kern[BUFSIZR], fstype[BUFSIZR];
char *gens[NUM_GENS] = {"", "1st Generation", "2nd Generation",
"3rd Generation", "Mini", "4th Generation", "Photo",
"2nd Gen Mini", "", "", "", "5th Generation", "Nano" };
#ifdef IPOD
char fslist[BUFSIZR], fsmount[11];
#endif
FILE *ptr;
#if defined(__linux__) || defined(IPOD)
if((ptr = popen("uname -rv", "r")) != NULL) {
#else
if((ptr = popen("uname -r", "r")) != NULL) {
#endif
while(fgets(kern, BUFSIZR, ptr)!=NULL);
pclose(ptr);
}
#ifdef IPOD
if((ptr = fopen("/proc/mounts", "r")) != NULL) {
while(fgets(fslist, BUFSIZR, ptr)!=NULL) {
sscanf(fslist, "%s%*s%s", fsmount, fstype);
if(strcmp(fsmount, "/dev/root")==0)
break;
}
if(strncmp(fstype, "hfs", 3)==0)
sprintf(fstype, "Mac iPod.");
else
sprintf(fstype, "Win iPod.");
fclose(ptr);
}
#else
sprintf(fstype, "Not an iPod.");
#endif
i = hw_version;
if (i > NUM_GENS || i < 0)
i = 0;
buf = malloc(sizeof(char) * (32 + strlen(PZ_VER) + strlen(kern) +
strlen(fstype) + strlen(gens[i])));
sprintf(buf, "%s\n\n%s\n%s %s\n Rev. 0x%05lX", PZ_VER, kern,
fstype, gens[i], ipod_get_hw_version());
}
void about_podzilla()
{
populate_about();
new_stringview_window(buf, "About");
free(buf);
buf = NULL;
}
void show_credits()
{
populate_credits();
new_stringview_window(buf, "Credits");
free(buf);
buf = NULL;
}