Skip to content

Commit

Permalink
Use stdbool.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosbrando committed Dec 10, 2011
1 parent 3534181 commit 995473d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Binary file removed spark
Binary file not shown.
14 changes: 7 additions & 7 deletions spark.c
Expand Up @@ -2,8 +2,9 @@
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <stdbool.h>

int received_bash_pipe(void);
bool received_bash_pipe(void);
int *split_string(char *string);
char *remove_unwanted_characters(char *string);
char *join_arguments(char *arguments[], int count);
Expand Down Expand Up @@ -43,23 +44,22 @@ int main(int argc, char *argv[]) {
for (i = 0; i < count; ++i) {
current_value = (numerical_values[i] * 7) / max;
if (current_value < 0) current_value = 0;
/* printf("%d", numerical_values[i]); */
printf("%s", ticks[current_value]);
}

return 0;
}

/* Check if values were received via bash pipe */
int received_bash_pipe(void) {
bool received_bash_pipe(void) {
long size;

/* obtain file size: */
fseek(stdin, 0, SEEK_END);
size = ftell(stdin);
rewind(stdin);

return size != 0 ? 1 : 0;
return size != 0 ? true : false;
}

/* Join all parameters into a single string to enable
Expand All @@ -68,10 +68,10 @@ char *join_arguments(char *arguments[], int count) {
char *buffer;
register int i;

buffer = malloc(1);
buffer = (char *)malloc(sizeof(char));

for (i = 0; i < count; ++i) {
buffer = realloc(buffer, strlen(buffer) + strlen(arguments[i]) + 1);
buffer = (char *)realloc(buffer, (strlen(buffer) + strlen(arguments[i]) + 1) * sizeof(char));
strcat(buffer, arguments[i]);
strcat(buffer, " "); /* adds a space after the value */
}
Expand Down Expand Up @@ -110,7 +110,7 @@ char *remove_unwanted_characters(char *string) {
register int i;

size = strlen(string);
buffer = malloc(size);
buffer = (char *)malloc(size * sizeof(char));

for (i = 0; i < size; ++i)
buffer[i] = string[i] == '\n' || string[i] == ',' ? ' ' : string[i];
Expand Down

0 comments on commit 995473d

Please sign in to comment.