소스 검색

Coding style: reindent to Linux KNF

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Joachim Nilsson 6 년 전
부모
커밋
ab5aa6c968
5개의 변경된 파일1092개의 추가작업 그리고 1217개의 파일을 삭제
  1. 157
    177
      src/helpers.c
  2. 25
    28
      src/helpers.h
  3. 834
    933
      src/light.c
  4. 64
    65
      src/light.h
  5. 12
    14
      src/main.c

+ 157
- 177
src/helpers.c 파일 보기

@@ -6,229 +6,209 @@
6 6
 #include <sys/types.h>
7 7
 #include <dirent.h>
8 8
 
9
-LIGHT_BOOL light_readUInt(char const * filename, unsigned int *i)
9
+bool light_readUInt(char const *filename, unsigned int *i)
10 10
 {
11
-  FILE* fileHandle;
12
-  unsigned int iCopy;
13
-
14
-  fileHandle = fopen(filename, "r");
15
-
16
-  if(!fileHandle)
17
-  {
18
-    LIGHT_PERMERR("reading");
19
-    return FALSE;
20
-  }
21
-
22
-  if(fscanf(fileHandle, "%u", &iCopy) != 1)
23
-  {
24
-    LIGHT_ERR_FMT("Couldn't parse a positive integer number from '%s'", filename);
25
-    fclose(fileHandle);
26
-    return FALSE;
27
-  }
28
-  
29
-  *i = iCopy;
30
-
31
-  fclose(fileHandle);
32
-  return TRUE;
33
-}
11
+	FILE *fileHandle;
12
+	unsigned int iCopy;
34 13
 
35
-LIGHT_BOOL light_writeUInt(char const * filename, unsigned int i)
36
-{
37
-  FILE* fileHandle;
14
+	fileHandle = fopen(filename, "r");
38 15
 
39
-  fileHandle = fopen(filename, "w");
16
+	if (!fileHandle) {
17
+		LIGHT_PERMERR("reading");
18
+		return false;
19
+	}
40 20
 
41
-  if(!fileHandle)
42
-  {
43
-    LIGHT_PERMERR("writing");
44
-    return FALSE;
45
-  }
21
+	if (fscanf(fileHandle, "%u", &iCopy) != 1) {
22
+		LIGHT_ERR_FMT("Couldn't parse a positive integer number from '%s'", filename);
23
+		fclose(fileHandle);
24
+		return false;
25
+	}
46 26
 
47
-  if(fprintf(fileHandle, "%u", i) < 0)
48
-  {
49
-    LIGHT_ERR("fprintf failed");
50
-    fclose(fileHandle);
51
-    return FALSE;
52
-  }
27
+	*i = iCopy;
53 28
 
54
-  fclose(fileHandle);
55
-  return TRUE;
29
+	fclose(fileHandle);
30
+	return true;
56 31
 }
57 32
 
58
-
59
-LIGHT_BOOL light_readULong(char const * filename, unsigned long *i)
33
+bool light_writeUInt(char const *filename, unsigned int i)
60 34
 {
61
-  FILE* fileHandle;
62
-  unsigned long iCopy;;
63
-
64
-  fileHandle = fopen(filename, "r");
65
-
66
-  if(!fileHandle)
67
-  {
68
-    LIGHT_PERMERR("reading");
69
-    return FALSE;
70
-  }
71
-
72
-  if(fscanf(fileHandle, "%lu", &iCopy) != 1)
73
-  {
74
-    LIGHT_ERR_FMT("Couldn't parse a positive integer number from '%s'", filename);
75
-    fclose(fileHandle);
76
-    return FALSE;
77
-  }
78
-  
79
-  *i = iCopy;
80
-
81
-  fclose(fileHandle);
82
-  return TRUE;
35
+	FILE *fileHandle;
36
+
37
+	fileHandle = fopen(filename, "w");
38
+
39
+	if (!fileHandle) {
40
+		LIGHT_PERMERR("writing");
41
+		return false;
42
+	}
43
+
44
+	if (fprintf(fileHandle, "%u", i) < 0) {
45
+		LIGHT_ERR("fprintf failed");
46
+		fclose(fileHandle);
47
+		return false;
48
+	}
49
+
50
+	fclose(fileHandle);
51
+	return true;
83 52
 }
84 53
 
85
-LIGHT_BOOL light_writeULong(char const * filename, unsigned long i)
54
+bool light_readULong(char const *filename, unsigned long *i)
86 55
 {
87
-  FILE* fileHandle;
56
+	FILE *fileHandle;
57
+	unsigned long iCopy;;
88 58
 
89
-  fileHandle = fopen(filename, "w");
59
+	fileHandle = fopen(filename, "r");
90 60
 
91
-  if(!fileHandle)
92
-  {
93
-    LIGHT_PERMERR("writing");
94
-    return FALSE;
95
-  }
61
+	if (!fileHandle) {
62
+		LIGHT_PERMERR("reading");
63
+		return false;
64
+	}
96 65
 
97
-  if(fprintf(fileHandle, "%lu", i) < 0)
98
-  {
99
-    LIGHT_ERR("fprintf failed");
100
-    fclose(fileHandle);
101
-    return FALSE;
102
-  }
66
+	if (fscanf(fileHandle, "%lu", &iCopy) != 1) {
67
+		LIGHT_ERR_FMT("Couldn't parse a positive integer number from '%s'", filename);
68
+		fclose(fileHandle);
69
+		return false;
70
+	}
103 71
 
104
-  fclose(fileHandle);
105
-  return TRUE;
72
+	*i = iCopy;
73
+
74
+	fclose(fileHandle);
75
+	return true;
106 76
 }
107 77
 
78
+bool light_writeULong(char const *filename, unsigned long i)
79
+{
80
+	FILE *fileHandle;
81
+
82
+	fileHandle = fopen(filename, "w");
108 83
 
84
+	if (!fileHandle) {
85
+		LIGHT_PERMERR("writing");
86
+		return false;
87
+	}
88
+
89
+	if (fprintf(fileHandle, "%lu", i) < 0) {
90
+		LIGHT_ERR("fprintf failed");
91
+		fclose(fileHandle);
92
+		return false;
93
+	}
94
+
95
+	fclose(fileHandle);
96
+	return true;
97
+}
109 98
 
110
-LIGHT_BOOL light_readString(char const * filename, char *buffer, long* size)
99
+bool light_readString(char const *filename, char *buffer, long *size)
111 100
 {
112
-  FILE *fileHandle;
113
-  long fileSize;
114
-  long readSize;
115
-
116
-  /* Make sure buffer pointer is null */
117
-  if(buffer != NULL)
118
-  {
119
-    LIGHT_ERR("buffer passed to function isn't NULL");
120
-    return FALSE;
121
-  }
122
-
123
-  /* Open file */
124
-  fileHandle = fopen(filename, "r");
125
-
126
-  if(!fileHandle)
127
-  {
128
-    LIGHT_PERMERR("reading");
129
-    return FALSE;
130
-  }
131
-
132
-  /* Get the file size */
133
-  fseek(fileHandle, 0L, SEEK_END);
134
-  fileSize = ftell(fileHandle);
135
-  rewind(fileHandle);
136
-
137
-  /* Allocate the string and null-terminate it */
138
-  buffer = malloc(sizeof(char)*(fileSize+1));
139
-  memset(buffer, '\0', fileSize);
140
-
141
-  if(buffer == NULL)
142
-  {
143
-    LIGHT_MEMERR();
144
-    fclose(fileHandle);
145
-    return FALSE;
146
-  }
147
-
148
-  /* Read the file */
149
-  readSize = fread(buffer, sizeof(char), fileSize, fileHandle);
150
-
151
-  if(readSize != fileSize)
152
-  {
153
-    LIGHT_ERR("read error");
154
-    free(buffer);
155
-    fclose(fileHandle);
156
-    return FALSE;
157
-  }
158
-  
159
-  /* Set the size */
160
-  if(size != NULL)
161
-  {
162
-    *size = readSize;
163
-  }
164
-
165
-  /* All well, close handle and return TRUE */
166
-  fclose(fileHandle);
167
-  return TRUE;
101
+	FILE *fileHandle;
102
+	long fileSize;
103
+	long readSize;
104
+
105
+	/* Make sure buffer pointer is null */
106
+	if (buffer != NULL) {
107
+		LIGHT_ERR("buffer passed to function isn't NULL");
108
+		return false;
109
+	}
110
+
111
+	/* Open file */
112
+	fileHandle = fopen(filename, "r");
113
+
114
+	if (!fileHandle) {
115
+		LIGHT_PERMERR("reading");
116
+		return false;
117
+	}
118
+
119
+	/* Get the file size */
120
+	fseek(fileHandle, 0L, SEEK_END);
121
+	fileSize = ftell(fileHandle);
122
+	rewind(fileHandle);
123
+
124
+	/* Allocate the string and null-terminate it */
125
+	buffer = malloc(sizeof(char) * (fileSize + 1));
126
+	memset(buffer, '\0', fileSize);
127
+
128
+	if (buffer == NULL) {
129
+		LIGHT_MEMERR();
130
+		fclose(fileHandle);
131
+		return false;
132
+	}
133
+
134
+	/* Read the file */
135
+	readSize = fread(buffer, sizeof(char), fileSize, fileHandle);
136
+
137
+	if (readSize != fileSize) {
138
+		LIGHT_ERR("read error");
139
+		free(buffer);
140
+		fclose(fileHandle);
141
+		return false;
142
+	}
143
+
144
+	/* Set the size */
145
+	if (size != NULL) {
146
+		*size = readSize;
147
+	}
148
+
149
+	/* All well, close handle and return true */
150
+	fclose(fileHandle);
151
+	return true;
168 152
 }
169 153
 
170
-LIGHT_BOOL light_isDir(char const * path)
154
+bool light_isDir(char const *path)
171 155
 {
172
-  DIR *dirHandle = opendir(path);
156
+	DIR *dirHandle = opendir(path);
173 157
 
174
-  if(!dirHandle)
175
-  {
176
-    return FALSE;
177
-  }
158
+	if (!dirHandle) {
159
+		return false;
160
+	}
178 161
 
179
-  closedir(dirHandle);
180
-  return TRUE;
162
+	closedir(dirHandle);
163
+	return true;
181 164
 }
182 165
 
183
-LIGHT_BOOL light_isWritable(char const * filename)
166
+bool light_isWritable(char const *filename)
184 167
 {
185
-  FILE* fileHandle = fopen(filename, "r+");
168
+	FILE *fileHandle = fopen(filename, "r+");
186 169
 
187
-  if(!fileHandle)
188
-  {
189
-    LIGHT_PERMWARN("writing");
190
-    return FALSE;
191
-  }
170
+	if (!fileHandle) {
171
+		LIGHT_PERMWARN("writing");
172
+		return false;
173
+	}
192 174
 
193
-  fclose(fileHandle);
194
-  return TRUE;
175
+	fclose(fileHandle);
176
+	return true;
195 177
 }
196 178
 
197
-LIGHT_BOOL light_isReadable(char const * filename)
179
+bool light_isReadable(char const *filename)
198 180
 {
199
-  FILE* fileHandle = fopen(filename, "r");
181
+	FILE *fileHandle = fopen(filename, "r");
200 182
 
201
-  if(!fileHandle)
202
-  {
203
-    LIGHT_PERMWARN("reading");
204
-    return FALSE;
205
-  }
183
+	if (!fileHandle) {
184
+		LIGHT_PERMWARN("reading");
185
+		return false;
186
+	}
206 187
 
207
-  fclose(fileHandle);
208
-  return TRUE;
188
+	fclose(fileHandle);
189
+	return true;
209 190
 }
210 191
 
211 192
 unsigned long light_logInfClamp(unsigned long x)
212 193
 {
213
-  LIGHT_NOTE_FMT("specified value is inferior to %lu (raw), so adjusting it to this mininum value", x);
214
-  return x;
194
+	LIGHT_NOTE_FMT("specified value is inferior to %lu (raw), so adjusting it to this mininum value", x);
195
+	return x;
215 196
 }
216 197
 
217 198
 unsigned long light_logSupClamp(unsigned long x)
218 199
 {
219
-  LIGHT_NOTE_FMT("specified value is superior to %lu (raw), so adjusting it to this maximum value", x);
220
-  return x;
200
+	LIGHT_NOTE_FMT("specified value is superior to %lu (raw), so adjusting it to this maximum value", x);
201
+	return x;
221 202
 }
222 203
 
223 204
 double light_clampPercent(double p)
224 205
 {
225
-  if(p < 0.0)
226
-  {
227
-    LIGHT_WARN_FMT("specified value %g%% is not valid, adjusting it to 0%%", p);
228
-    return 0.0;
229
-  }else if(p > 100.0){
230
-    LIGHT_WARN_FMT("specified value %g%% is not valid, adjusting it to 100%%", p);
231
-    return 100.0;
232
-  }
233
-  return p;
206
+	if (p < 0.0) {
207
+		LIGHT_WARN_FMT("specified value %g%% is not valid, adjusting it to 0%%", p);
208
+		return 0.0;
209
+	} else if (p > 100.0) {
210
+		LIGHT_WARN_FMT("specified value %g%% is not valid, adjusting it to 100%%", p);
211
+		return 100.0;
212
+	}
213
+	return p;
234 214
 }

+ 25
- 28
src/helpers.h 파일 보기

@@ -1,6 +1,8 @@
1 1
 #ifndef LIGHT_HELPERS_H
2 2
 #define LIGHT_HELPERS_H
3 3
 
4
+#include <stdbool.h>
5
+
4 6
 /* Clamps x(value) between y(min) and z(max) in a nested ternary operation. 
5 7
  * if(x < y)
6 8
  * {
@@ -20,14 +22,15 @@
20 22
  * 0 - No output
21 23
  * 1 - Errors
22 24
  * 2 - Errors, warnings 
23
- * 3 - Errors, warnings, notices */
24
-typedef enum LIGHT_LOG_LEVEL {
25
-  LIGHT_ERROR_LEVEL = 1,
26
-  LIGHT_WARN_LEVEL,
27
-  LIGHT_NOTE_LEVEL
28
-} LIGHT_LOG_LEVEL;
29
-
30
-LIGHT_LOG_LEVEL light_verbosity;
25
+ * 3 - Errors, warnings, notices
26
+ */
27
+typedef enum {
28
+	LIGHT_ERROR_LEVEL = 1,
29
+	LIGHT_WARN_LEVEL,
30
+	LIGHT_NOTE_LEVEL
31
+} light_loglevel_t;
32
+
33
+light_loglevel_t light_verbosity;
31 34
 char light_log_buffer[LIGHT_LOG_FMT_BUF_SIZE];
32 35
 
33 36
 #define LIGHT_LOG(lvl,f,t,x)if(light_verbosity >= lvl){fprintf(f,t": \"%s\", in \"%s\" on line %u.\n", x, __FILE__, __LINE__);}
@@ -54,35 +57,29 @@ char light_log_buffer[LIGHT_LOG_FMT_BUF_SIZE];
54 57
 
55 58
 #define LIGHT_PERMWARN(x) LIGHT_PERMLOG(x,LIGHT_WARN)
56 59
 
57
-/* Typedef for boolean values */
58
-typedef enum LIGHT_BOOL {
59
-  FALSE = 0,
60
-  TRUE
61
-} LIGHT_BOOL;
62
-
63
-/* Reads an unsigned integer from a file into `i` if able, otherwise returns FALSE and leaves `i` untouched */
64
-LIGHT_BOOL light_readUInt(char const *filename, unsigned int *v);
60
+/* Reads an unsigned integer from a file into `i` if able, otherwise returns false and leaves `i` untouched */
61
+bool light_readUInt(char const *filename, unsigned int *v);
65 62
 
66
-/* Writes an unsigned integer `i` into file `filename` if able, otherwise returns FALSE */
67
-LIGHT_BOOL light_writeUInt(char const *filename, unsigned int v);
63
+/* Writes an unsigned integer `i` into file `filename` if able, otherwise returns false */
64
+bool light_writeUInt(char const *filename, unsigned int v);
68 65
 
69
-LIGHT_BOOL light_writeULong(char const *filename, unsigned long v);
70
-LIGHT_BOOL light_readULong(char const *filename, unsigned long *v);
66
+bool light_writeULong(char const *filename, unsigned long v);
67
+bool light_readULong(char const *filename, unsigned long *v);
71 68
 
72
-/* Reads a file into null-terminated `buffer` if able, otherwise returns FALSE
69
+/* Reads a file into null-terminated `buffer` if able, otherwise returns false
73 70
  * If `size` isn't NULL, it will be set to the read size.
74 71
  *
75 72
  * WARNING: `buffer` HAS to be freed by the user, also make sure it is NULL before passed */
76
-LIGHT_BOOL light_readString(char const * filename, char * buffer, long * size);
73
+bool light_readString(char const *filename, char *buffer, long *size);
77 74
 
78
-/* Returns TRUE if `path` is a valid directory, FALSE otherwise */
79
-LIGHT_BOOL light_isDir(char const * path);
75
+/* Returns true if `path` is a valid directory, false otherwise */
76
+bool light_isDir(char const *path);
80 77
 
81
-/* Returns TRUE if file is writable, FALSE otherwise */
82
-LIGHT_BOOL light_isWritable(char const * filename);
78
+/* Returns true if file is writable, false otherwise */
79
+bool light_isWritable(char const *filename);
83 80
 
84
-/* Returns TRUE if file is readable, FALSE otherwise */
85
-LIGHT_BOOL light_isReadable(char const * filename);
81
+/* Returns true if file is readable, false otherwise */
82
+bool light_isReadable(char const *filename);
86 83
 
87 84
 /* Clamps the `percent` value between 0% and 100% */
88 85
 double light_clampPercent(double percent);

+ 834
- 933
src/light.c
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 64
- 65
src/light.h 파일 보기

@@ -4,6 +4,7 @@
4 4
 #include "config.h"
5 5
 #include "helpers.h"
6 6
 
7
+#include <stdbool.h>
7 8
 #include <sys/types.h>
8 9
 #include <dirent.h>
9 10
 #include <linux/limits.h>
@@ -14,9 +15,9 @@
14 15
 #define ASSERT_SET(t,v)							\
15 16
 	if (v) {							\
16 17
 		fprintf(stderr, t" arguments cannot be used in conjunction.\n"); \
17
-		return FALSE;						\
18
+		return false;						\
18 19
 	}								\
19
-	v = TRUE;
20
+	v = true;
20 21
 
21 22
 #define ASSERT_OPSET() ASSERT_SET("Operation", opSet)
22 23
 #define ASSERT_TARGETSET() ASSERT_SET("Target", targetSet)
@@ -24,58 +25,57 @@
24 25
 #define ASSERT_CTRLSET() ASSERT_SET("Controller", ctrlSet)
25 26
 #define ASSERT_VALSET() ASSERT_SET("Value", valSet)
26 27
 
27
-typedef enum LIGHT_FIELD {
28
-  LIGHT_BRIGHTNESS = 0,
29
-  LIGHT_MAX_BRIGHTNESS,
30
-  LIGHT_MIN_CAP,
31
-  LIGHT_SAVERESTORE
32
-} LIGHT_FIELD;
33
-
34
-typedef enum LIGHT_TARGET {
35
-  LIGHT_BACKLIGHT = 0,
36
-  LIGHT_KEYBOARD
37
-} LIGHT_TARGET;
38
-
39
-typedef enum LIGHT_CTRL_MODE {
40
-  LIGHT_AUTO = 0,
41
-  LIGHT_SPECIFY
42
-} LIGHT_CTRL_MODE;
43
-
44
-typedef enum LIGHT_OP_MODE {
45
-  LIGHT_GET = 0,
46
-  LIGHT_SET,
47
-  LIGHT_ADD,
48
-  LIGHT_SUB,
49
-  LIGHT_PRINT_HELP,   /* Prints help and exits  */
50
-  LIGHT_PRINT_VERSION, /* Prints version info and exits */
51
-  LIGHT_LIST_CTRL,
52
-  LIGHT_RESTORE,
53
-  LIGHT_SAVE
54
-
55
-} LIGHT_OP_MODE;
56
-
57
-typedef enum LIGHT_VAL_MODE {
58
-  LIGHT_RAW = 0,
59
-  LIGHT_PERCENT
60
-} LIGHT_VAL_MODE;
28
+typedef enum {
29
+	LIGHT_BRIGHTNESS = 0,
30
+	LIGHT_MAX_BRIGHTNESS,
31
+	LIGHT_MIN_CAP,
32
+	LIGHT_SAVERESTORE
33
+} light_field_t;
34
+
35
+typedef enum {
36
+	LIGHT_BACKLIGHT = 0,
37
+	LIGHT_KEYBOARD
38
+} light_target_t;
39
+
40
+typedef enum {
41
+	LIGHT_AUTO = 0,
42
+	LIGHT_SPECIFY
43
+} light_ctrl_mode_t;
44
+
45
+typedef enum {
46
+	LIGHT_GET = 0,
47
+	LIGHT_SET,
48
+	LIGHT_ADD,
49
+	LIGHT_SUB,
50
+	LIGHT_PRINT_HELP,	/* Prints help and exits  */
51
+	LIGHT_PRINT_VERSION,	/* Prints version info and exits */
52
+	LIGHT_LIST_CTRL,
53
+	LIGHT_RESTORE,
54
+	LIGHT_SAVE
55
+} light_cmd_t;
56
+
57
+typedef enum {
58
+	LIGHT_RAW = 0,
59
+	LIGHT_PERCENT
60
+} light_val_mode_t;
61 61
 
62 62
 typedef struct light_runtimeArguments_s {
63
-  /* Which controller to use */
64
-  LIGHT_CTRL_MODE controllerMode;
65
-  char            specifiedController[NAME_MAX + 1];
63
+	/* Which controller to use */
64
+	light_ctrl_mode_t controllerMode;
65
+	char specifiedController[NAME_MAX + 1];
66 66
 
67
-  /* What to do with the controller */
68
-  LIGHT_OP_MODE   operationMode;
69
-  LIGHT_VAL_MODE  valueMode;
70
-  unsigned long   specifiedValueRaw; /* The specified value in raw mode */
71
-  double          specifiedValuePercent; /* The specified value in percent */
67
+	/* What to do with the controller */
68
+	light_cmd_t operationMode;
69
+	light_val_mode_t valueMode;
70
+	unsigned long specifiedValueRaw;	/* The specified value in raw mode */
71
+	double specifiedValuePercent;	/* The specified value in percent */
72 72
 
73
-  LIGHT_TARGET   target;
74
-  LIGHT_FIELD    field;
73
+	light_target_t target;
74
+	light_field_t field;
75 75
 
76
-  /* Cache data */
77
-  LIGHT_BOOL      hasCachedMaxBrightness;
78
-  unsigned long   cachedMaxBrightness;
76
+	/* Cache data */
77
+	bool hasCachedMaxBrightness;
78
+	unsigned long cachedMaxBrightness;
79 79
 
80 80
 } light_runtimeArguments, *light_runtimeArguments_p;
81 81
 
@@ -85,9 +85,8 @@ light_runtimeArguments light_Configuration;
85 85
 /* Sets default values for the configuration */
86 86
 void light_defaultConfig();
87 87
 
88
-
89 88
 /* Parses the program arguments and sets the configuration accordingly (unsanitized) */
90
-LIGHT_BOOL light_parseArguments(int argc, char** argv);
89
+bool light_parseArguments(int argc, char **argv);
91 90
 
92 91
 /* Prints a header if verbosity level > 0 */
93 92
 void light_printVersion(void);
@@ -98,10 +97,10 @@ void light_printHelp(void);
98 97
 /* -- SECTION: Main code -- */
99 98
 
100 99
 /* Initializes the application */
101
-LIGHT_BOOL light_initialize(int argc, char** argv);
100
+bool light_initialize(int argc, char **argv);
102 101
 
103 102
 /* Does the work */
104
-LIGHT_BOOL light_execute(void);
103
+bool light_execute(void);
105 104
 
106 105
 /* Frees up resources */
107 106
 void light_free();
@@ -110,29 +109,29 @@ void light_free();
110 109
 
111 110
 /* WARNING: `buffer` HAS to be freed by the user if not null once returned!
112 111
  * Size is always NAME_MAX + 1 */
113
-LIGHT_BOOL light_genPath(char const *controller, LIGHT_TARGET target, LIGHT_FIELD type, char **buffer);
112
+bool light_genPath(char const *controller, light_target_t target, light_field_t type, char **buffer);
114 113
 
115
-LIGHT_BOOL light_validControllerName(char const *controller);
114
+bool light_validControllerName(char const *controller);
116 115
 
117
-LIGHT_BOOL light_getBrightness(char const *controller, unsigned long *v);
116
+bool light_getBrightness(char const *controller, unsigned long *v);
118 117
 
119
-LIGHT_BOOL light_getMaxBrightness(char const *controller, unsigned long *v);
118
+bool light_getMaxBrightness(char const *controller, unsigned long *v);
120 119
 
121
-LIGHT_BOOL light_setBrightness(char const *controller, unsigned long v);
120
+bool light_setBrightness(char const *controller, unsigned long v);
122 121
 
123
-LIGHT_BOOL light_controllerAccessible(char const *controller);
122
+bool light_controllerAccessible(char const *controller);
124 123
 
125 124
 /* WARNING: `controller` HAS to be at most NAME_MAX, otherwise fails */
126
-LIGHT_BOOL light_getBestController(char *controller);
125
+bool light_getBestController(char *controller);
127 126
 
128
-LIGHT_BOOL light_getMinCap(char const *controller, LIGHT_BOOL *hasMinCap, unsigned long *minCap);
127
+bool light_getMinCap(char const *controller, bool * hasMinCap, unsigned long *minCap);
129 128
 
130
-LIGHT_BOOL light_setMinCap(char const *controller, unsigned long v);
129
+bool light_setMinCap(char const *controller, unsigned long v);
131 130
 
132
-LIGHT_BOOL light_listControllers();
131
+bool light_listControllers();
133 132
 
134
-LIGHT_BOOL light_saveBrightness(char const *controller, unsigned long v);
133
+bool light_saveBrightness(char const *controller, unsigned long v);
135 134
 
136
-LIGHT_BOOL light_restoreBrightness(char const *controller);
135
+bool light_restoreBrightness(char const *controller);
137 136
 
138 137
 #endif /* LIGHT_H_ */

+ 12
- 14
src/main.c 파일 보기

@@ -6,21 +6,19 @@
6 6
 #define LIGHT_RETURNVAL_EXECFAIL  1
7 7
 #define LIGHT_RETURNVAL_SUCCESS   0
8 8
 
9
-int main(int argc, char** argv)
9
+int main(int argc, char **argv)
10 10
 {
11
-  if(!light_initialize(argc, argv))
12
-  {
13
-    LIGHT_ERR("Initialization failed");
14
-    return LIGHT_RETURNVAL_INITFAIL;
15
-  }
11
+	if (!light_initialize(argc, argv)) {
12
+		LIGHT_ERR("Initialization failed");
13
+		return LIGHT_RETURNVAL_INITFAIL;
14
+	}
16 15
 
17
-  if(!light_execute())
18
-  {
19
-    LIGHT_ERR("Execution failed");
20
-    light_free();
21
-    return LIGHT_RETURNVAL_EXECFAIL;
22
-  }
16
+	if (!light_execute()) {
17
+		LIGHT_ERR("Execution failed");
18
+		light_free();
19
+		return LIGHT_RETURNVAL_EXECFAIL;
20
+	}
23 21
 
24
-  light_free();
25
-  return LIGHT_RETURNVAL_SUCCESS;
22
+	light_free();
23
+	return LIGHT_RETURNVAL_SUCCESS;
26 24
 }