Exemplo n.º 1
0
static size_t write_callback( char *ptr, size_t size, size_t nmemb, void *userdata)
{
	int open_id;	
	Json::Value msgValue, respVal;
	Json::Reader reader;

	if(false == reader.parse(ptr, msgValue))
	{
		send_fail();
		goto done;
	}

	if (!msgValue["error"].isNull()) {
		send_fail();		
		goto done;
	}

	if (msgValue["id"].isNull()) {
		send_fail();
		goto done;
	}
	update_new_share((struct share_data *)userdata);
	send_success();
done:	
	return size * nmemb;
}
Exemplo n.º 2
0
static void
autofs_expire_one(am_node *mp, char *name, unsigned long token)
{
  autofs_fh_t *fh;
  am_node *ap;
  struct autofs_pending_umount *p;
  char *ap_path;

  fh = mp->am_autofs_fh;

  ap_path = str3cat(NULL, mp->am_path, "/", name);
  if (amuDebug(D_TRACE))
    plog(XLOG_DEBUG, "\tumount(%s)", ap_path);

  p = fh->pending_umounts;
  while (p && p->wait_queue_token != token)
    p = p->next;

  if (p) {
    /* already pending */
    dlog("Umounting of %s already pending", ap_path);
    amd_stats.d_drops++;
    goto out;
  }

  ap = find_ap(ap_path);
  if (ap == NULL) {
    /* not found??? not sure what to do here... */
    send_fail(fh->ioctlfd, token);
    goto out;
  }

  p = ALLOC(struct autofs_pending_umount);
  p->wait_queue_token = token;
  p->name = strdup(name);
  p->next = fh->pending_umounts;
  fh->pending_umounts = p;

  unmount_mp(ap);

out:
  XFREE(ap_path);
}
Exemplo n.º 3
0
void
autofs_mount_failed(am_node *mp)
{
  autofs_fh_t *fh = mp->am_parent->am_autofs_fh;
  struct autofs_pending_mount **pp, *p;

  pp = &fh->pending_mounts;
  while (*pp && !STREQ((*pp)->name, mp->am_name))
    pp = &(*pp)->next;

  /* sanity check */
  if (*pp == NULL)
    return;

  p = *pp;
  plog(XLOG_INFO, "autofs: mounting %s failed", mp->am_path);
  send_fail(fh->ioctlfd, p->wait_queue_token);

  XFREE(p->name);
  *pp = p->next;
  XFREE(p);
}
Exemplo n.º 4
0
static void
autofs_lookup_failed(am_node *mp, char *name)
{
  autofs_fh_t *fh = mp->am_autofs_fh;
  struct autofs_pending_mount **pp, *p;

  pp = &fh->pending_mounts;
  while (*pp && !STREQ((*pp)->name, name))
    pp = &(*pp)->next;

  /* sanity check */
  if (*pp == NULL)
    return;

  p = *pp;
  plog(XLOG_INFO, "autofs: lookup of %s failed", name);
  send_fail(fh->ioctlfd, p->wait_queue_token);

  XFREE(p->name);
  *pp = p->next;
  XFREE(p);
}
Exemplo n.º 5
0
int main(void)
{
	int len;
	char *lenstr,poststr[512];
	char *player_id, *server_id, *token;

	setenv("http_proxy", "127.0.0.1:8087", 1);
	setenv("https_proxy", "127.0.0.1:8087", 1);	

	init_db((char *)"127.0.0.1", 3306, (char *)"pay", (char *)"root", (char *)"123456");

	printf("Content-Type:text/html\n\n");
/*	
	lenstr=getenv("CONTENT_LENGTH");
	if(lenstr == NULL) {
		printf("<DIV STYLE=\"COLOR:RED\">Errorarameters should be entered!</DIV>\n");
		return (0);
	}
	len=atoi(lenstr) + 1;
	if (len >= 512)
		return (0);
	
	fgets(poststr,len,stdin);
	parse_post_data(poststr, len);

	len = 10;
	for (; len == 10;)
		sleep(2);
*/	
	lenstr = getenv("QUERY_STRING");
	if(lenstr == NULL) {
		printf("<DIV STYLE=\"COLOR:RED\">Errorarameters should be entered!</DIV>\n");
		return (0);
	}
	len = strlen(lenstr) + 1;
	parse_post_data(lenstr, len);	
	
	server_id = get_value((char *)"server_id");
	player_id = get_value((char *)"player_id");
	token = get_value((char *)"token");	
	if (!server_id || !player_id || !token)
		return (0);	

//	server_id = "15";
//	player_id = "15";
//	token = "AAACEdEose0cBAKedvUNeBVZAlpbsjUo4r2LHmR3K56gGFbJ4Gwp6PWVEp5wte4X4IdLK5YHziYabuXHCZCoXhzqmSZCKrsiZCLgOb1yjddnI2MyiZBmFK";

	g_data.server_id = server_id;
	g_data.player_id = player_id;
	g_data.times = 0;
	
	MYSQL_RES *res = NULL;
	MYSQL_ROW row;	
	char sql[256];

	sprintf(sql, "select last_share_time, share_times from share where server_id = \"%s\" and player_id = \"%s\"", server_id, player_id);
	res = query(sql, 1, NULL);
	if (!res) {
		send_facebook_share(token, share_msg[0], &g_data);
		goto done;
	}
	row = fetch_row(res);
	if (!row) {
		send_facebook_share(token, share_msg[0], &g_data);		
		goto done;
	}

	if (!check_can_share(row)) {
		send_fail();
		goto done;
	}
	g_data.times = atoi(row[1]);

	free_query(res);
	res = NULL;

	send_facebook_share(token, share_msg[g_data.times], &g_data);		

//	ret = atoi(row[0]);
	
	
done:
	if (res)
		free_query(res);
	fflush(stdout);
	close_db();		
	return 0;
}
Exemplo n.º 6
0
int main(void)
{
	int len;
	char *lenstr,poststr[512];
	char *player_id, *server_id, *pay_id;
	int n_pay_id;
	int n_pay_times;
	int can_share = 1;
	uint64_t effect = 0;
	MYSQL_RES *res = NULL;
	MYSQL_ROW row;	
	char sql[256];
/*
	len = 10;
	for (;;) {
		if (len != 10)
			break;
		sleep(2);
	}
*/
	
	init_db((char *)"127.0.0.1", 3306, (char *)"pay", (char *)"root", (char *)"123456");

	printf("Content-Type:text/html\n\n");
	lenstr=getenv("CONTENT_LENGTH");
	if(lenstr == NULL) {
		printf("<DIV STYLE=\"COLOR:RED\">Errorarameters should be entered!</DIV>\n");
		return (0);
	}
	len=atoi(lenstr) + 1;
	if (len >= 512)
		return (0);
	
	fgets(poststr,len,stdin);
	parse_post_data(poststr, len);
	server_id = get_value((char *)"server_id");
	player_id = get_value((char *)"player_id");
	pay_id = get_value((char *)"pay_id");	
	if (!server_id || !player_id || !pay_id)
		return (0);	


	sprintf(sql, "select share_times, pay_times from share where server_id = %s and player_id = %s", server_id, player_id);
	res = query(sql, 1, NULL);
	if (!res) {
		send_fail();
		goto done;
	}
	row = fetch_row(res);
	if (!row) {
		send_fail();
		goto done;
	}

	n_pay_id = atoi(pay_id);
	if (!check_can_get_share_pay(row, n_pay_id)) {
		send_fail();
		goto done;
	}

	n_pay_times = atoi(row[1]);
	n_pay_times |= (1 << n_pay_id);

	free_query(res);
	res = NULL;
	
	sprintf(sql, "update `share` set `pay_times` = %d where `server_id` = %s and `player_id` = %s",
		n_pay_times, server_id, player_id);
	
	query(sql, 1, &effect);

	if (effect != 1) {
		send_fail();
		goto done;
	}
	
	send_success(n_pay_id);
	send_charge_gold_req(atoi(player_id), get_gold[n_pay_id], 0, (char *)"share reward", (char *)"127.0.0.1", (char *)"3008");
	
done:
	if (res)
		free_query(res);
	fflush(stdout);
	close_db();		
	return 0;
}