+static void*as3_buffer=0;
+static int as3_buffer_pos=0;
+static int as3_buffer_len=0;
+void as3_file_input(FILE*fi)
+{
+ as3_in = fi;
+ as3_buffer = 0;
+}
+void as3_buffer_input(void*buffer, int len)
+{
+ as3_buffer = buffer;
+ as3_buffer_len = len;
+ as3_buffer_pos = 0;
+ as3_in = 0;
+}
+
+#define YY_INPUT(buf,result,max_size) { \
+ if(!as3_buffer) { \
+ errno=0; \
+ while((result = fread(buf, 1, max_size, as3_in))==0 && ferror(as3_in)) \
+ { if(errno != EINTR) {YY_FATAL_ERROR("input in flex scanner failed"); break;} \
+ errno=0; clearerr(as3_in); \
+ } \
+ } else { \
+ int to_read = max_size; \
+ if(to_read + as3_buffer_pos > as3_buffer_len) \
+ to_read = as3_buffer_len - as3_buffer_pos; \
+ memcpy(buf, as3_buffer+as3_buffer_pos, to_read); \
+ as3_buffer_pos += to_read; \
+ result=to_read; \
+ } \
+}
+