Beispiel #1
0
void				key_delete(t_entry *user)
{
	int				i;

	i = user->cursor;
	while (user->current->cmd[i] != '\0')
	{
		user->current->cmd[i] = user->current->cmd[i + 1];
		i++;
	}
	user->current->clen--;
	put_cmd(user);
}
Beispiel #2
0
// step = 1 - no  control. step = 2 - if no label or func found, throw err
vararray* compile(vararray* lines, vararray* labels, vararray* funcs, int step) {
    vararray* binary = var_ctor(sizeof(char), 128);

    int i = 0, j = 0; // i - line number; j - word number
    int type = 0;
    line_t* cur_line = NULL;
    char word[MAX_WORD_LENGTH];

    DBGPRINT("Lines: %d\n", (int)(lines->nmax));
    for (i = 0; i < (lines->nmax); i++) {
        j = 0;

        cur_line = (line_t*)var_get(lines, i);

        DBGPRINT("Label: %s\n", cur_line->words[j]);
        DBGPRINT("Next word: %s\n", cur_line->words[j+1]);

        DBGPRINT("Keyword: \"%s\"\n", cur_line->words[j]);
        type = get_type(cur_line->words[j]);
        DBGPRINT("Type: %d\n", type);

        if (type == FUNC) {
            put_lf(cur_line->words[j+1], funcs, binary->nmax);
            continue;
        }

        if (type == LABEL) {
            strcpy(word, cur_line->words[j]);
            word[strlen(word)-1] = '\0';
            put_lf(word, labels, binary->nmax);
            DBGPRINT("Label: %s\n", cur_line->words[j]);
            j++;
            DBGPRINT("Next word: %s\n", cur_line->words[j]);
            type = get_type(cur_line->words[j]);
        }

        if (type == EMPTY)
            continue;

        put_cmd(binary, cur_line, j, labels, funcs, step);
    }
    if (step < 2) {
        var_dtor(binary);
        return NULL;
    }
    else
        return binary;
}
Beispiel #3
0
void				key_backspace(t_entry *user)
{
	int				i;

	if (user->cursor <= 0)
		return ;
	i = user->cursor - 1;
	while (user->current->cmd[i] != '\0')
	{
		user->current->cmd[i] = user->current->cmd[i + 1];
		i++;
	}
	user->current->clen--;
	user->cursor--;
	put_cmd(user);
}
Beispiel #4
0
int main(int argc, char **argv)
{
	struct sockaddr_in serveraddr;

	if(argc == 4)
	{
		if(!strcmp(argv[1], GET))
		{
			if(strlen(argv[2]) > 255)
			{
				printf("filename is too long\n");
			}
			else
			{
				serveraddr.sin_family = AF_INET;
				serveraddr.sin_port = htons(69);
				serveraddr.sin_addr.s_addr = inet_addr(argv[3]);
				get_cmd(argv[2], OCTET,serveraddr, strlen(argv[2]));
			}
		}
		else if(!strcmp(argv[1], PUT))
		{
			if(strlen(argv[2]) > 255)
			{
				printf("filename is too long\n");
			}
			else
			{
				serveraddr.sin_family = AF_INET;
				serveraddr.sin_port = htons(69);
				serveraddr.sin_addr.s_addr = inet_addr(argv[3]);
				put_cmd(argv[2], OCTET,serveraddr, strlen(argv[2]));
			}
		}
	}
	else
	{
		printf("arg error\n");
		return -1;
	}
	
	return 0;
}