예제 #1
0
static int server_subconnect(void) 
{
	struct afp_connection_request * conn_req;

#define BUFFER_SIZE 2048
	conn_req = malloc(sizeof(struct afp_connection_request));

        memset(conn_req, 0,sizeof(struct afp_connection_request));

        conn_req->url=url;
	conn_req->url.requested_version=31;
	if (strlen(url.uamname)>0) {
		if ((conn_req->uam_mask = find_uam_by_name(url.uamname))==0) {
			printf("I don't know about UAM %s\n",url.uamname);
			return -1;
		}
		
	} else {
        	conn_req->uam_mask=default_uams_mask();
	}
	if ((server=afp_server_full_connect(NULL, conn_req))==NULL) {
		goto error;
	}

	printf("Connected to server %s using UAM \"%s\"\n",
		server->server_name_printable, uam_bitmap_to_string(server->using_uam));

	free(conn_req);

	return 0;
error:
	free(conn_req);
	printf("Could not connect\n");
	return -1;
}
예제 #2
0
static int server_subconnect(void) 
{
	struct afp_connection_request * conn_req;
	int error;

	conn_req = malloc(sizeof(struct afp_connection_request));

	if ((afp_default_connection_request(conn_req,&url))==-1) {
			printf("I don't know about UAM %s\n",url.uamname);
			return -1;
	}

	if ((server=afp_server_full_connect(NULL, conn_req,&error))==NULL) {
		goto error;
	}

	printf("Connected to server %s using UAM \"%s\"\n",
		server->basic.server_name_printable, 
		uam_bitmap_to_string(server->using_uam));

	free(conn_req);

	return 0;
error:
	free(conn_req);
	printf("Could not connect\n");
	return -1;
}
예제 #3
0
static int server_subconnect(struct afp_url url)
{
  struct afp_connection_request *conn_req;
  struct afp_server * server = NULL;

  conn_req = malloc( sizeof(struct afp_connection_request) );
  server = malloc( sizeof(struct afp_server) );
 
  memset(conn_req, 0, sizeof(struct afp_connection_request));

  conn_req->url=url;
  conn_req->url.requested_version=31;

  writeError(ERR_DEBUG_MODULE, "[%s] AFP connection - username: %s password: %s server: %s", MODULE_NAME, url.username, url.password, url.servername); 

  if (strlen(url.uamname) > 0) 
  {
    if ((conn_req->uam_mask = find_uam_by_name(url.uamname)) == 0) {
      writeError(ERR_ERROR, "[%s] Unknown UAM: %s", MODULE_NAME, url.uamname); 
      FREE(conn_req);
      FREE(server);
      return FAILURE;
    }
  } 
  else 
  {
    conn_req->uam_mask=default_uams_mask();
  }

  writeError(ERR_DEBUG_MODULE, "[%s] Initiating connection attempt.", MODULE_NAME);
  if ((server = afp_server_full_connect(NULL, conn_req)) == NULL) 
  {
    FREE(conn_req);
    FREE(server);
    return FAILURE;
  }

  writeError(ERR_DEBUG_MODULE, "[%s] Connected to server: %s via UAM: %s", MODULE_NAME, server->server_name_printable, uam_bitmap_to_string(server->using_uam));

  FREE(conn_req);
  FREE(server);

  return SUCCESS;
}