Exemplo n.º 1
0
void getpost(char *pre, char *mid)
{
    if (!strlen(pre) || !strlen(mid)) return;
    char *p = strchr(mid, pre[0]), tmp1[26] = "\0", tmp2[26] = "\0";
    getpost(strncpy(tmp1, pre, strlen(mid) - strlen(p) + 1) + 1, strncpy(tmp2, mid, strlen(mid) - strlen(p)));
    getpost(pre + strlen(mid) - strlen(p), ++p);
    fprintf(fout, "%c", pre[0]);
}
Exemplo n.º 2
0
int main()
{
    fin = fopen("heritage.in", "r");
    fout = fopen("heritage.out", "w");

    fscanf(fin, "%s %s", mid, pre);

    getpost(pre, mid);
    fprintf(fout, "\n");

    fclose(fin); fclose(fout);
    return 0;
}
Exemplo n.º 3
0
subuser *checkrecv(char *pSock, ape_socket *client, acetables *g_ape, char *ip_client)
{

	unsigned int op;
	unsigned int isget = 0;
	
	subuser *user = NULL;
	int local = (strcmp(ip_client, CONFIG_VAL(Server, ip_local, g_ape->srv)) == 0);
	
	clientget *cget = xmalloc(sizeof(*cget));


	if (strlen(pSock) < 3 || (local && getqueryip(pSock, cget->ip_get) == 0)) {  // get query IP (from htaccess)
		free(cget);
		shutdown(client->fd, 2);
		return NULL;		
	}
	if (!local) {
		strncpy(cget->ip_get, ip_client, 16); // get real IP (from socket)
	}
	
	cget->client = client;
	
	gethost(pSock, cget->host);
	
	if (strncasecmp(pSock, "GET", 3) == 0) {
		if (!fixpacket(pSock, 0) || (cget->get = getfirstparam(pSock, (local ? '&' : '?'))) == NULL) {
			free(cget);
			
			shutdown(client->fd, 2);
			return NULL;			
		} else {
			isget = 1;
		}
	} else if (strncasecmp(pSock, "POST", 4) == 0) {
		if ((cget->get = getpost(pSock)) == NULL) {
			free(cget);
			
			shutdown(client->fd, 2);
			return NULL;			
		}
	} else {
		free(cget);

		shutdown(client->fd, 2);
		return NULL;		
	}
	
	fixpacket(cget->get, 1);

	if (isget) {
		urldecode(cget->get);
	}
	
	op = checkcmd(cget, gettransport(pSock), &user, g_ape);

	switch (op) {
		case CONNECT_SHUTDOWN:
			shutdown(client->fd, 2);			
			break;
		case CONNECT_KEEPALIVE:
			break;
	}

	free(cget);
	
	return user;

}