Exemple #1
0
void unix_console_connection::process_input(int len) {
	int st = 0;

	while (st < len) {
		int i;

		for (i = st; i < len; i++) {
			if (buffer[i] == '\n' || buffer[i] == ';' || buffer[i] == '?') {
				break;
			}
		}

		if (buffer[i] == '?') {
			//std::string in((const char *)buffer + st, i - st);
			std::string in((const char *)buffer + st, (i + 1) - st);

			dump_partial(in.c_str());
		} else if ((i - st) > 0) {
			if (buffer[i] == '\n')
				i--;
			std::string in((const char *)buffer + st, i - st);
			process_line(in.c_str());
		}

		st = i + 1;
	}

	if (autoclose) {
		if (bufbuffer.empty())
			console->release_connection(this);
		else
			doom();
	}
}
Exemple #2
0
void console_connection::release() {
	doom();
}
Exemple #3
0
int main()
    {
        int x;
        FILE *f_in=fopen("input.dat","r");
        if (f_in == NULL)
        {
            perror("cannot open the file!");
        }

        FILE *f_out=fopen("output.dat","a");
        char option[15];

        while (fscanf(f_in,"%s",option)>0)
        {

            if (strcmp(option,"AF")==0)
            {
                fscanf(f_in,"%d",&x);
                addFirst(x);
            }

            if (strcmp(option,"AL")==0)
            {
                fscanf(f_in,"%d",&x);
                addLast(x);
            }

            if (strcmp(option,"DF")==0)
            {
                deleteFirst();
            }

            if (strcmp(option,"DL")==0)
            {
                deleteLast();
            }

            if (strcmp(option,"DOOM_THE_LIST")==0)
            {
                doom();
            }

            if (strcmp(option,"DE")==0)
            {
                fscanf(f_in,"%d",&x);
                delete_X(x);
            }

            if (strcmp(option,"PRINT_ALL")==0)
            {
                printall();
            }

            if (strcmp(option,"PRINT_F")==0)
            {
                fscanf(f_in,"%d",&x);
                print_first_X(x);
            }

           if (strcmp(option,"PRINT_L")==0)
            {
                fscanf(f_in,"%d",&x);
                print_last_X(x,f_out);
            }


        }

        fclose(f_in);
        fclose(f_out);


        return 0;
    }