The Pedigree Project
0.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
user
applications
display-mode
display-mode/main.c
1
/*
2
* Copyright (c) 2008-2014, Pedigree Developers
3
*
4
* Please see the CONTRIB file in the root of the source tree for a full
5
* list of contributors.
6
*
7
* Permission to use, copy, modify, and distribute this software for any
8
* purpose with or without fee is hereby granted, provided that the above
9
* copyright notice and this permission notice appear in all copies.
10
*
11
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
*/
19
20
#include <stdio.h>
21
#include <stdlib.h>
22
#include <string.h>
23
24
void
usage()
25
{
26
printf(
"display-mode: List and select the Pedigree display modes.\n"
);
27
printf(
"usage:\tdisplay-mode list\n"
);
28
printf(
"\tdisplay-mode select <width>x<height>x<depth>\n"
);
29
}
30
31
int
main(
int
argc,
char
**argv)
32
{
33
if
(argc == 1)
34
{
35
usage();
36
exit(1);
37
}
38
/*
39
char buf[256];
40
int result;
41
unsigned int width, height, depth;
42
43
if(argc == 2 && !strcmp(argv[1], "list"))
44
{
45
result = pedigree_config_query("select * from 'display_modes'");
46
if (result == -1)
47
fprintf(stderr, "Unable to get the modes.\n");
48
49
if (pedigree_config_was_successful(result) != 0)
50
{
51
pedigree_config_get_error_message(result, buf, 256);
52
fprintf(stderr, "Error: %s\n", buf);
53
return 1;
54
}
55
56
if (pedigree_config_numrows(result) == 0)
57
printf("No modes\n");
58
else
59
while (pedigree_config_nextrow(result) == 0)
60
printf("Display[%d]: Mode %dx%dx%d\n",
61
pedigree_config_getnum_s(result, "display_id"),
62
pedigree_config_getnum_s(result, "width"),
63
pedigree_config_getnum_s(result, "height"),
64
pedigree_config_getnum_s(result, "depth"));
65
66
pedigree_config_freeresult(result);
67
68
}
69
else if(argc == 3 && !strcmp(argv[1], "select"))
70
{
71
if(sscanf(argv[2], "%dx%dx%d", &width, &height, &depth) == 3)
72
{
73
sprintf(buf, "select * from 'display_modes' where width = %d and
74
height = %d and depth = %d and display_id = 0", width, height, depth);
75
result = pedigree_config_query(buf);
76
memset(buf, 0, 256);
77
if (result == -1)
78
fprintf(stderr, "Unable to get the mode.\n");
79
80
if (pedigree_config_was_successful(result) != 0)
81
{
82
pedigree_config_get_error_message(result, buf, 256);
83
fprintf(stderr, "Error: %s\n", buf);
84
return 1;
85
}
86
87
if (pedigree_config_numrows(result) == 0 ||
88
pedigree_config_nextrow(result) != 0)
89
{
90
pedigree_config_freeresult(result);
91
printf("No such mode\n");
92
}
93
else
94
{
95
memset(buf, 0, 256);
96
sprintf(buf, "update displays set mode_id = %d where id =
97
0", pedigree_config_getnum_s(result, "mode_id"));
98
pedigree_config_freeresult(result);
99
printf("Setting mode %dx%dx%d...\n", width, height, depth);
100
result = pedigree_config_query(buf);
101
memset(buf, 0, 256);
102
if (result == -1)
103
fprintf(stderr, "Unable to set the mode.\n");
104
105
if (pedigree_config_was_successful(result) != 0)
106
{
107
pedigree_config_get_error_message(result, buf, 256);
108
fprintf(stderr, "Error: %s\n", buf);
109
return 1;
110
}
111
pedigree_config_freeresult(result);
112
}
113
}
114
else
115
{
116
usage();
117
exit(1);
118
}
119
}
120
else
121
{
122
usage();
123
exit(1);
124
}
125
126
exit(0);*/
127
}
Generated on Fri Jan 24 2020 06:46:14 for The Pedigree Project by
1.8.11