Fixed found Valgrind issues.
[rpn.git] / src / psp / psp.c
blobf8b219fe765df37f8542868ceddf78e11a3c4a1d
1 /*******************************************************************************
2 * Reverse Polish Notation calculator. *
3 * Copyright (c) 2007-2008, Samuel Fredrickson <kinghajj@gmail.com> *
4 * All rights reserved. *
5 * *
6 * Redistribution and use in source and binary forms, with or without *
7 * modification, are permitted provided that the following conditions are met: *
8 * * Redistributions of source code must retain the above copyright *
9 * notice, this list of conditions and the following disclaimer. *
10 * * Redistributions in binary form must reproduce the above copyright *
11 * notice, this list of conditions and the following disclaimer in the *
12 * documentation and/or other materials provided with the distribution. *
13 * *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS *
15 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
17 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY *
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER *
21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY *
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
24 * DAMAGE. *
25 ******************************************************************************/
27 /* psp.c - the PSP front-end.
30 #include "rpn.h"
32 // Tell the PSP about the program.
33 PSP_MODULE_INFO("PSPRPN", 0, 1, 1);
35 int main()
37 RPNCalculator *calculator;
38 RPNValue peek = 0;
39 char *input;
41 // Setup the PSP screen, callbacks, etc.
42 RPNPSP_Setup();
44 // Start Program.
45 kprintf("PSPRPN v. %i.%i.%i.%i\n",
46 __RPN_MAJOR__,
47 __RPN_MINOR__,
48 __RPN_REVIS__,
49 __RPN_BUILD__);
51 #ifdef __GNUC__
52 kprintf("GCC %i.%i.%i on %s at %s\n",
53 __GNUC__,
54 __GNUC_MINOR__,
55 __GNUC_PATCHLEVEL__,
56 __DATE__, __TIME__);
57 #endif
59 calculator = RPN_newCalculator();
61 // Input loop.
62 while(calculator->status == RPN_STATUS_CONTINUE)
64 kprintf("[%g]> ", peek);
65 input = RPNPSP_GetString();
66 if(input)
67 peek = RPN_eval(input, calculator);
70 sceKernelExitGame();
72 return 0;