add pic_state structure
This commit is contained in:
		
							parent
							
								
									9d33e0e079
								
							
						
					
					
						commit
						25c9fef1d0
					
				| 
						 | 
					@ -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
 | 
				
			||||||
| 
						 | 
					@ -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;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue