Beispiel #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;
}
Beispiel #2
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;
}
Beispiel #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;

  //fprintf(stderr, "AFP connection - username: %s password: %s server: %s\n", url.username, url.password, url.servername); 

  if (strlen(url.uamname) > 0) {
    if ((conn_req->uam_mask = find_uam_by_name(url.uamname)) == 0) {
      fprintf(stderr, "[ERROR] Unknown UAM: %s", url.uamname);
      FREE(conn_req);
      FREE(server);
      return -1;
    }
  } else {
    conn_req->uam_mask = default_uams_mask();
  }

  //fprintf(stderr,  "Initiating connection attempt.\n");
  if ((server = afp_server_full_connect(NULL, conn_req)) == NULL) {
    FREE(conn_req);
//    FREE(server);
    return -1;
  }
  //fprintf(stderr,  "Connected to server: %s via UAM: %s\n", server->server_name_printable, uam_bitmap_to_string(server->using_uam));

  FREE(conn_req);
  FREE(server);

  return 0;
}