add pic_state structure

This commit is contained in:
Yuichi Nishiwaki 2013-10-10 16:15:41 +09:00
parent 9d33e0e079
commit 25c9fef1d0
3 changed files with 36 additions and 0 deletions

10
include/picrin.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef PICRIN_H__
#define PICRIN_H__
typedef struct {
} pic_state;
pic_state *pic_open();
void pic_close(pic_state *pic);
#endif

View File

@ -1,13 +1,18 @@
#include <stdio.h> #include <stdio.h>
#include "picrin.h"
#define LINE_MAX_LENGTH 256 #define LINE_MAX_LENGTH 256
int int
main() main()
{ {
pic_state *pic;
char line[LINE_MAX_LENGTH], last_char; char line[LINE_MAX_LENGTH], last_char;
int char_index; int char_index;
pic = pic_open();
while (1) { while (1) {
printf("> "); printf("> ");
@ -36,5 +41,7 @@ main()
goto exit; goto exit;
exit: exit:
pic_close(pic);
return 0; return 0;
} }

19
src/state.c Normal file
View File

@ -0,0 +1,19 @@
#include <stdlib.h>
#include "picrin.h"
pic_state *
pic_open()
{
pic_state *pic;
pic = (pic_state *)calloc(sizeof(pic_state));
return pic;
}
void
pic_close(pic_state *pic)
{
free(pic);
}