summaryrefslogtreecommitdiff
path: root/frontends/calculator/CEdev/examples/fileio_read_write/src
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2019-04-13 12:40:52 -0400
committerAndrew Opalach <andrew@akon.city> 2019-04-13 12:40:52 -0400
commit55bfff7cf6541caac172b43186cf14405185b14d (patch)
treec1ae99d2b39f8df8933d81ec2e61e81050bdb410 /frontends/calculator/CEdev/examples/fileio_read_write/src
parent761462861fc1228e65546c4e0f877d5212320082 (diff)
downloadcetris-55bfff7cf6541caac172b43186cf14405185b14d.tar.gz
cetris-55bfff7cf6541caac172b43186cf14405185b14d.tar.bz2
cetris-55bfff7cf6541caac172b43186cf14405185b14d.zip
fix curses on linux
Diffstat (limited to 'frontends/calculator/CEdev/examples/fileio_read_write/src')
-rw-r--r--frontends/calculator/CEdev/examples/fileio_read_write/src/main.c176
1 files changed, 88 insertions, 88 deletions
diff --git a/frontends/calculator/CEdev/examples/fileio_read_write/src/main.c b/frontends/calculator/CEdev/examples/fileio_read_write/src/main.c
index a776037..4747b99 100644
--- a/frontends/calculator/CEdev/examples/fileio_read_write/src/main.c
+++ b/frontends/calculator/CEdev/examples/fileio_read_write/src/main.c
@@ -1,88 +1,88 @@
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <tice.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <fileioc.h>
-
-/* Declare some variables */
-const char *appvarName = "AppVar";
-
-typedef struct {
- char name[15];
- uint8_t var1;
- uint8_t var2;
-} data_t;
-
-data_t data;
-
-#define VAR1_VALUE 10
-#define VAR2_VALUE 20
-
-/* Function prototypes */
-void printText(int8_t xpos, int8_t ypos, const char *text);
-
-/* Main Function */
-void main(void) {
- char nameBuffer[10];
- ti_var_t myAppVar;
- int x;
-
- /* Clear the homescreen */
- os_ClrHome();
-
- /* Declare some variable values */
- strcpy(data.name, "My Data");
- data.var1 = VAR1_VALUE;
- data.var2 = VAR2_VALUE;
-
- /* Close any files that may be open already */
- ti_CloseAll();
-
- /* Open a new variable; deleting it if it already exists */
- myAppVar = ti_Open(appvarName, "w");
-
- /* Make sure we opened okay */
- if (!myAppVar) goto err;
-
- /* Write the structure to the appvar */
- if (ti_Write(&data, sizeof(data_t), 1, myAppVar) != 1) goto err;
-
- /* Go back to the start of the file */
- if (ti_Rewind(myAppVar) == EOF) goto err;
-
- /* Let's read it just to make sure we wrote it correctly */
- if (ti_Read(&data, sizeof(data_t), 1, myAppVar) != 1) goto err;
-
- /* Make sure we read these variables correctly too */
- if (data.var1 != VAR1_VALUE && data.var2 != VAR2_VALUE) goto err;
-
- /* Ensure the name of the AppVar is correct */
- ti_GetName(nameBuffer, myAppVar);
-
- printText(0, 0, "Appvar: ");
- printText(8, 0, nameBuffer);
- printText(0, 1, "Read was successful");
- goto noerr;
-
-err:
- printText(0, 0, "An error occured");
-noerr:
-
- /* Pause */
- while (!os_GetCSC());
-
- /* Close all open files */
- ti_CloseAll();
-}
-
-/* Draw text on the homescreen at the given X/Y location */
-void printText(int8_t xpos, int8_t ypos, const char *text) {
- os_SetCursorPos(ypos, xpos);
- os_PutStrFull(text);
-}
-
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <tice.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <fileioc.h>
+
+/* Declare some variables */
+const char *appvarName = "AppVar";
+
+typedef struct {
+ char name[15];
+ uint8_t var1;
+ uint8_t var2;
+} data_t;
+
+data_t data;
+
+#define VAR1_VALUE 10
+#define VAR2_VALUE 20
+
+/* Function prototypes */
+void printText(int8_t xpos, int8_t ypos, const char *text);
+
+/* Main Function */
+void main(void) {
+ char nameBuffer[10];
+ ti_var_t myAppVar;
+ int x;
+
+ /* Clear the homescreen */
+ os_ClrHome();
+
+ /* Declare some variable values */
+ strcpy(data.name, "My Data");
+ data.var1 = VAR1_VALUE;
+ data.var2 = VAR2_VALUE;
+
+ /* Close any files that may be open already */
+ ti_CloseAll();
+
+ /* Open a new variable; deleting it if it already exists */
+ myAppVar = ti_Open(appvarName, "w");
+
+ /* Make sure we opened okay */
+ if (!myAppVar) goto err;
+
+ /* Write the structure to the appvar */
+ if (ti_Write(&data, sizeof(data_t), 1, myAppVar) != 1) goto err;
+
+ /* Go back to the start of the file */
+ if (ti_Rewind(myAppVar) == EOF) goto err;
+
+ /* Let's read it just to make sure we wrote it correctly */
+ if (ti_Read(&data, sizeof(data_t), 1, myAppVar) != 1) goto err;
+
+ /* Make sure we read these variables correctly too */
+ if (data.var1 != VAR1_VALUE && data.var2 != VAR2_VALUE) goto err;
+
+ /* Ensure the name of the AppVar is correct */
+ ti_GetName(nameBuffer, myAppVar);
+
+ printText(0, 0, "Appvar: ");
+ printText(8, 0, nameBuffer);
+ printText(0, 1, "Read was successful");
+ goto noerr;
+
+err:
+ printText(0, 0, "An error occured");
+noerr:
+
+ /* Pause */
+ while (!os_GetCSC());
+
+ /* Close all open files */
+ ti_CloseAll();
+}
+
+/* Draw text on the homescreen at the given X/Y location */
+void printText(int8_t xpos, int8_t ypos, const char *text) {
+ os_SetCursorPos(ypos, xpos);
+ os_PutStrFull(text);
+}
+