view regexParser/sequentialSearch.cc @ 295:0c663f46954d

todo
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 02 Feb 2016 11:24:29 +0900
parents ef95a7f1bc03
children 63213964502a
line wrap: on
line source

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>

#include "fileread.h"

void state1(Buffer buff);

void stateSkip(Buffer buff) {
    buff.matchBegin = buff.buffptr;
    state1(buff);
}

void stateMatch(Buffer buff) {
    fwrite(buff.matchBegin,buff.buffptr-buff.matchBegin-1,1,stdout);
    puts("");
    buff.buffptr--;
    stateSkip(buff);
}

#include "state.cc"
int main(int argc, char **argv) {
    char *filename;
    for (int i = 1; i < argc; i++) {
        if (strcmp(argv[i],"-file") == 0) {
            filename = argv[i+1]; i++;
        }
    }

    int fd = 0;
    st_mmap_t st_mmap = createSt_mmap(filename,fd);
    Buffer buff = createBuffer(st_mmap);
    stateSkip(buff);
    close(fd);
    return 0;
}