-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathabout.c
124 lines (110 loc) · 3.25 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
120
121
122
123
/*
* 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>
#define PZMOD
#include "pz.h"
#include "ipod.h"
#define BUFSIZR 2048
#define NUM_GENS 8
static char *buf = NULL;
extern TWindow *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",
"Rebecca Bettencourt", "Joshua Oreman", 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"};
#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 = (int)(hw_version/10000);
if (i > NUM_GENS || i < 0)
i = 0;
buf = malloc(sizeof(char) * (18 + strlen(PZ_VER) + strlen(kern) +
strlen(fstype) + strlen(gens[i])));
sprintf(buf, "%s\n\n%s\n%s %s\n Rev. %ld", PZ_VER, kern,
fstype, gens[i], hw_version);
}
TWindow *about_podzilla (ttk_menu_item *item)
{
if (buf) {
free (buf);
buf = NULL;
}
populate_about();
return new_stringview_window(buf, "About");
}
TWindow *show_credits (ttk_menu_item *item)
{
if (buf) {
free (buf);
buf = NULL;
}
populate_credits();
return new_stringview_window(buf, "Credits");
}