-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added current version utility, int limits and math lib .h
- Loading branch information
Showing
21 changed files
with
206 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.27 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef _LIMITS_H | ||
#define _LIMITS_H 1 | ||
|
||
#define INT_MAX 2147483647 | ||
#define INT_MIN -2147483648 | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef _MATH_H | ||
#define _MATH_H 1 | ||
|
||
#include "stdint.h" | ||
|
||
uint32_t factorial(uint32_t n); | ||
uint32_t pow(uint32_t num, uint32_t n); | ||
double sqrt(double n); | ||
double sin(double n); | ||
double cos(double n); | ||
double tan(double n); | ||
double asin(double n); | ||
double acos(double n); | ||
double atan(double n); | ||
double exp(double n); | ||
double log(double n); | ||
double log10(double n); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef _MATH_SHELL_H | ||
#define _MATH_SHELL_H 1 | ||
|
||
#include "stdint.h" | ||
|
||
uint32_t parse_int(char *string); | ||
double parse_float(char *string); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef _VERSION_H | ||
#define _VERSION_H 1 | ||
|
||
#define V1 1 | ||
#define V2 0 | ||
#define V3 27 | ||
|
||
#endif |
Binary file not shown.
Binary file not shown.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "../include/math.h" | ||
|
||
uint32_t factorial(uint32_t n) | ||
{ | ||
if (n == 0) | ||
{ | ||
return 1; | ||
} | ||
else if (n == 1) | ||
{ | ||
return 1; | ||
} | ||
else | ||
{ | ||
return n * factorial(n - 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "../include/math_shell.h" | ||
#include "../include/string.h" | ||
|
||
#include "stdint.h" | ||
|
||
uint32_t parse_int(char *string) | ||
{ | ||
uint32_t i; | ||
char *parser; | ||
while (string[i] != '\0') | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
FILE *fp; | ||
char *line = NULL; | ||
size_t len = 0; | ||
ssize_t read; | ||
const char s[2] = "."; | ||
char *token; | ||
unsigned int version[3]; | ||
unsigned short int i = 0; | ||
int count = 0; | ||
|
||
fp = fopen("current_version.txt", "r"); | ||
if (fp == NULL) | ||
exit(EXIT_FAILURE); | ||
while ((read = getline(&line, &len, fp)) != -1) | ||
{ | ||
/* get the first token */ | ||
token = strtok(line, s); | ||
|
||
/* walk through other tokens */ | ||
while (token != NULL) | ||
{ | ||
version[i] = atoi(token); | ||
i++; | ||
token = strtok(NULL, s); | ||
} | ||
} | ||
fclose(fp); | ||
if (line) | ||
free(line); | ||
line = NULL; | ||
len = 0; | ||
|
||
fp = fopen("current_version.txt", "w"); | ||
if (fp == NULL) | ||
exit(EXIT_FAILURE); | ||
printf("%d\n", version[2]); | ||
version[2] = version[2] + 1; | ||
printf("%d\n", version[2]); | ||
fprintf(fp, "%u.%u.%u", version[0], version[1], version[2]); | ||
fclose(fp); | ||
|
||
i = 0; | ||
fp = fopen("include/version.h", "w"); | ||
if (fp == NULL) | ||
exit(EXIT_FAILURE); | ||
|
||
fprintf(fp, "#ifndef _VERSION_H\n"); | ||
fprintf(fp, "#define _VERSION_H 1\n\n"); | ||
for (i = 0; i < 3; i++) | ||
{ | ||
fprintf(fp, "#define V%d %u\n", i + 1, version[i]); | ||
} | ||
fprintf(fp, "\n#endif"); | ||
|
||
return 0; | ||
} |