コード例 #1
0
ファイル: im_login.cpp プロジェクト: mailru/icqdesktop
    bool im_login_list::update(/*in, out*/ im_login_id& _login)
    {
        bool found = false;

        for (auto iter = logins_.begin(); iter != logins_.end(); ++iter)
        {
            if (iter->get_login() == _login.get_login())
            {
                found = true;

                _login = *iter;

                if (iter == logins_.begin())
                    return true;

                logins_.erase(iter);
                break;
            }
        }

        if (!found)
            _login.set_id(get_next_id());

        logins_.push_front(_login);

        save();
        return found;
    }
コード例 #2
0
ファイル: main.cpp プロジェクト: Ithamar/cosmoe
static void authorize( const char* pzLoginName )
{
dbprintf( "main.cpp: authorize '%s'\n", pzLoginName );
    for (;;)
    {
        std::string cName;
        std::string cPassword;

        if ( pzLoginName != NULL || get_login( &cName, &cPassword ) )
        {
            struct passwd* psPass;

dbprintf( "main.cpp: authorize '%s' / '%s'\n", cName.c_str(), cPassword.c_str() );
            if ( pzLoginName != NULL ) {
                psPass = getpwnam( pzLoginName );
            } else {
                psPass = getpwnam( cName.c_str() );
            }

            if ( psPass != NULL ) {
                const char* pzPassWd = crypt(  cPassword.c_str(), "$1$" );
        
                if ( pzLoginName == NULL && pzPassWd == NULL ) {
                    perror( "crypt()" );
                    pzLoginName = NULL;
                    continue;
                }

                if ( pzLoginName != NULL || strcmp( pzPassWd, psPass->pw_passwd ) == 0 ) {
                    setgid( psPass->pw_gid );
                    setuid( psPass->pw_uid );
                    setenv( "HOME", psPass->pw_dir, true );
                    chdir( psPass->pw_dir );
                    break;
                } else {
                    BAlert* pcAlert = new BAlert( "Login failed",  "Incorrect password", "Sorry" );
                    pcAlert->Go();
                }
            } else {
                BAlert* pcAlert = new BAlert( "Login failed",  "No such user", "Sorry" );
                pcAlert->Go();
            }
        }
        pzLoginName = NULL;
    }
    
}
コード例 #3
0
ファイル: login.c プロジェクト: rashadkm/grass_cmake
/*!  
  \brief Get login parameters for driver/database

  If driver/database is not found, output arguments are set to NULL.
  
  \param driver driver name
  \param database database name (can be NULL)
  \param[out] user name
  \param[out] password string
  \param[out] host name
  \param[out] port

  \return DB_OK on success
  \return DB_FAILED on failure
*/
int db_get_login2(const char *driver, const char *database, const char **user,
                  const char **password, const char **host, const char **port)
{
    return get_login(driver, database, user,
                     password, host, port);
}
コード例 #4
0
ファイル: login.c プロジェクト: rashadkm/grass_cmake
/*!  
  \brief Get login parameters for driver/database

  If driver/database is not found, output arguments are set to NULL.

  \deprecated Use db_set_login2() instead.
  
  \todo: GRASS 8: to be replaced by db_set_login2().

  \param driver driver name
  \param database database name (can be NULL)
  \param[out] user name
  \param[out] password string

  \return DB_OK on success
  \return DB_FAILED on failure
*/
int db_get_login(const char *driver, const char *database, const char **user,
		 const char **password)
{
    return get_login(driver, database, user,
                     password, NULL, NULL);
}
コード例 #5
0
ファイル: bsqlodbc.c プロジェクト: smalinin/FreeTDS
int
main(int argc, char *argv[])
{
	LOGINREC *login;
	SQLHENV hEnv = 0;
	SQLHDBC hDbc = 0;
	SQLRETURN erc;
	const char *sql;

	setlocale(LC_ALL, "");

	memset(&options, 0, sizeof(options));
	options.headers = stderr;
	login = get_login(argc, argv, &options); /* get command-line parameters and call dblogin() */
	assert(login != NULL);

	/* 
	 * Override stdin, stdout, and stderr, as required 
	 */
	if (options.input_filename) {
		if (freopen(options.input_filename, "r", stdin) == NULL) {
			fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.input_filename, strerror(errno));
			exit(1);
		}
	}

	if (options.output_filename) {
		if (freopen(options.output_filename, "w", stdout) == NULL) {
			fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.output_filename, strerror(errno));
			exit(1);
		}
	}
	
	if (options.error_filename) {
		if (freopen(options.error_filename, "w", stderr) == NULL) {
			fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.error_filename, strerror(errno));
			exit(1);
		}
	}

	if (options.fverbose) {
		options.verbose = stderr;
	} else {
		static const char null_device[] = "/dev/null";
		options.verbose = fopen(null_device, "w");
		if (options.verbose == NULL) {
			fprintf(stderr, "%s:%d unable to open %s for verbose operation: %s\n", 
					options.appname, __LINE__, null_device, strerror(errno));
			exit(1);
		}
	}

	fprintf(options.verbose, "%s:%d: Verbose operation enabled\n", options.appname, __LINE__);
	
	/* 
	 * Connect to the server 
	 */
	if ((erc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hEnv)) != SQL_SUCCESS) {
		odbc_herror(SQL_HANDLE_ENV, hEnv, erc, "SQLAllocHandle", "failed to allocate an environment");
		exit(EXIT_FAILURE);
	}
	assert(hEnv);

	if ((erc = SQLSetEnvAttr(hEnv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)options.odbc_version, SQL_IS_UINTEGER)) != SQL_SUCCESS){
		odbc_herror(SQL_HANDLE_DBC, hDbc, erc, "SQLSetEnvAttr", "failed to set SQL_OV_ODBC3");
		exit(EXIT_FAILURE);
	}

	if ((erc = SQLAllocHandle(SQL_HANDLE_DBC, hEnv, &hDbc)) != SQL_SUCCESS) {
		odbc_herror(SQL_HANDLE_DBC, hDbc, erc, "SQLAllocHandle", "failed to allocate a connection");
		exit(EXIT_FAILURE);
	}
	assert(hDbc);

	if ((erc = SQLConnect(hDbc, 	(SQLCHAR *) options.servername, SQL_NTS, 
					(SQLCHAR *) login->username, SQL_NTS, 
					(SQLCHAR *) login->password, SQL_NTS)) != SQL_SUCCESS) {
		odbc_herror(SQL_HANDLE_DBC, hDbc, erc, "SQLConnect", "failed");
		exit(EXIT_FAILURE);
	}

#if 0
	/* Switch to the specified database, if any */
	if (options.database)
		dbuse(dbproc, options.database);
#endif

	/* 
	 * Read the queries and write the results
	 */
	while ((sql = next_query()) != NULL ) {
		SQLHSTMT hStmt;

		if ((erc = SQLAllocHandle(SQL_HANDLE_STMT, hDbc, &hStmt)) != SQL_SUCCESS) {
			odbc_perror(hStmt, erc, "SQLAllocHandle", "failed to allocate a statement handle");
			exit(EXIT_FAILURE);
		}

		/* "Prepare" the query and send it to the server */
		if ((erc = SQLPrepare(hStmt, (SQLCHAR *) sql, SQL_NTS)) != SQL_SUCCESS) {
			odbc_perror(hStmt, erc, "SQLPrepare", "failed");
			exit(EXIT_FAILURE);
		}

		if((erc = SQLExecute(hStmt)) != SQL_SUCCESS) {
			switch(erc) {
			case SQL_NEED_DATA: 
				goto FreeStatement;
			case SQL_SUCCESS_WITH_INFO:
				if (0 != print_error_message(SQL_HANDLE_STMT, hStmt)) {
					fprintf(stderr, "SQLExecute: continuing...\n");
				}
				break;
			default:
				odbc_perror(hStmt, erc, "SQLExecute", "failed");
				exit(EXIT_FAILURE);
			}
		}

		/* Write the output */
		print_results(hStmt);
		
		FreeStatement:
		if ((erc = SQLFreeHandle(SQL_HANDLE_STMT, hStmt)) != SQL_SUCCESS){
			odbc_perror(hStmt, erc, "SQLFreeHandle", "failed");
			exit(EXIT_FAILURE);
		} 
	}

	SQLDisconnect(hDbc);
	SQLFreeHandle(SQL_HANDLE_DBC, hDbc);
	SQLFreeHandle(SQL_HANDLE_ENV, hEnv);

	return 0;
}
コード例 #6
0
ファイル: gerrit_curl.c プロジェクト: cherrydigital/cs-cgit
int gerrit_get_project_list(char *value, struct cgit_context *ctx, repo_config_fn repo_config) {
#ifdef MYDEBUG
  fprintf(stderr, "DEBUG gerrit_get_project_list start\n");
  fprintf(stderr,"DEBUG: REQUEST_URI:%s\n", getenv("REQUEST_URI"));
  fprintf(stderr, "DEBUG url:%s\n", ctx->cfg.gerrit_project_list_url);
#endif
  char * tmp_remote_user = getenv("REMOTE_USER");
  if( tmp_remote_user == NULL ) {
    tmp_remote_user = getenv("HTTP_X_FORWARDED_USER");
  }

  if( tmp_remote_user == NULL) {
    fprintf(stderr,"REMOET_USER or HTTP_X_FORWARDED_USER is NULL exit...\n");
    return -1;
  }
  char * remote_user = (char *)malloc( strlen(tmp_remote_user) + 1000);
  sprintf(remote_user,"REMOTE_USER: %s", tmp_remote_user );

#ifdef MYDEBUG
	fprintf(stderr,"DEBUG COOKIE:%s\n", getenv("HTTP_COOKIE")); 
#endif
	MemoryStruct chunk;
	chunk.memory = (char *)malloc(1);
	chunk.size = 0;
	
	/*	
	MemoryStruct chunk2;
	chunk2.memory = (char *)malloc(1);
	chunk2.size = 0;
	*/	

	bool exitflag = false;
	int ret = get_list(ctx, remote_user, &chunk);
	if( ret == 0) {
		const char * strjson = strstr((const char *)chunk.memory, "{");
		if( strjson == NULL) {
			fprintf(stderr,"error: failed to get json string\n");
		}
		gerrit_scan_projects(value, strjson, repo_config);
	}
	else if( ret == 1) {
		htmlf("%s\n", "Content-Type: text/html;charset=utf-8");
		htmlf("%s\n", "Content-Length: 0");
		//int ret2 = get_login(ctx, remote_user, &chunk2);
		int ret2 = get_login(ctx, remote_user, &chunk);
		if(ret2 == 0) {
#ifdef MYDEBUG
			fprintf(stderr, "DEBUG going to ctx->cfg.gerrit_cgit_url: %s\n", ctx->cfg.gerrit_cgit_url);
#endif
			htmlf("%s\n", "Referer: cgit-redirect");
			htmlf("%s%s\n", "Location: ",ctx->cfg.gerrit_cgit_url);
		}
		else {
#ifdef MYDEBUG
			fprintf(stderr, "DEBUG going to ctx->cfg.gerrit_index_url : %s\n", ctx->cfg.gerrit_index_url);
#endif
			htmlf("%s%s\n", "Location: ", ctx->cfg.gerrit_index_url);
		}
		htmlf("\n");
		exitflag  = true;
	}
	else if(ret == -1) {
	}

	//cleanup
	free(remote_user);
	free(chunk.memory);
	//free(chunk2.memory);


	if(exitflag) {
		exit(0);
	}
	return 0;
}
コード例 #7
0
ファイル: bsqldb.c プロジェクト: msabramo/freetds
/**
 * The purpose of this program is threefold:
 *
 * 1.  To provide a generalized SQL processor suitable for testing db-lib.
 * 2.  To offer a robust batch-oriented SQL processor suitable for use in a production environment.  
 * 3.  To serve as a model example of how to use db-lib functions.  
 *
 * These purposes may be somewhat at odds with one another.  For instance, the tutorial aspect calls for
 * explanatory comments that wouldn't appear in production code.  Nevertheless, I hope the  experienced
 * reader will forgive the verbosity and still find the program useful.  
 *
 * \todo The error/message handlers are not robust enough.  They should anticipate certain conditions 
 * and cause the application to retry the operation.  
 */
int
main(int argc, char *argv[])
{
	LOGINREC *login;
	DBPROCESS *dbproc;
	RETCODE erc;

	setlocale(LC_ALL, "");

	/* Initialize db-lib */
	erc = dbinit();	
	if (erc == FAIL) {
		fprintf(stderr, "%s:%d: dbinit() failed\n", options.appname, __LINE__);
		exit(1);
	}
	
	/* Install our error and message handlers */
	dberrhandle(err_handler);
	dbmsghandle(msg_handler);

	memset(&options, 0, sizeof(options));
	options.headers = stderr;
	login = get_login(argc, argv, &options); /* get command-line parameters and call dblogin() */
	assert(login != NULL);

	/* 
	 * Override stdin, stdout, and stderr, as required 
	 */
	if (options.input_filename) {
		if (freopen(options.input_filename, "r", stdin) == NULL) {
			fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.input_filename, strerror(errno));
			exit(1);
		}
	}

	if (options.output_filename) {
		if (freopen(options.output_filename, "w", stdout) == NULL) {
			fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.output_filename, strerror(errno));
			exit(1);
		}
	}
	
	if (options.error_filename) {
		if (freopen(options.error_filename, "w", stderr) == NULL) {
			fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.error_filename, strerror(errno));
			exit(1);
		}
	}

	if (options.fverbose) {
		options.verbose = stderr;
	} else {
		static const char null_device[] = NULL_DEVICE;
		options.verbose = fopen(null_device, "w");
		if (options.verbose == NULL) {
			fprintf(stderr, "%s:%d unable to open %s for verbose operation: %s\n", 
					options.appname, __LINE__, null_device, strerror(errno));
			exit(1);
		}
	}

	fprintf(options.verbose, "%s:%d: Verbose operation enabled\n", options.appname, __LINE__);
	
	/* 
	 * Connect to the server 
	 */
	if ((dbproc = dbopen(login, options.servername)) == NULL)
		return 1;
	
	/* Switch to the specified database, if any */
	if (options.database)
		dbuse(dbproc, options.database);

	/* 
	 * Read the queries and write the results
	 */
	while (next_query(dbproc) != -1 ) {
	
		/* Send the query to the server (we could use dbsqlexec(), instead) */
		erc = dbsqlsend(dbproc);
		if (erc == FAIL) {
			fprintf(stderr, "%s:%d: dbsqlsend() failed\n", options.appname, __LINE__);
			exit(1);
		}
		fprintf(options.verbose, "%s:%d: dbsqlsend(): OK\n", options.appname, __LINE__);
		
		/* Wait for it to execute */
		erc = dbsqlok(dbproc);
		if (erc == FAIL) {
			fprintf(stderr, "%s:%d: dbsqlok() failed\n", options.appname, __LINE__);
			exit(1);
		}
		fprintf(options.verbose, "%s:%d: dbsqlok(): OK\n", options.appname, __LINE__);

		/* Write the output */
		print_results(dbproc);
	}

	return 0;
}
コード例 #8
0
int request_server_entry()
{
  if (prot && main_net_cfg)
  {
    if (!net_server) return 0;

    if (game_sock) delete game_sock;
    dprintf("Joining game in progress, hang on....\n");

    game_sock=prot->create_listen_socket(main_net_cfg->port+2,net_socket::SOCKET_FAST);     // this is used for fast game packet transmission
    if (!game_sock) { if (comm_sock) delete comm_sock; comm_sock=NULL; prot=NULL; return 0; }
    game_sock->read_selectable();

    net_socket *sock=prot->connect_to_server(net_server,net_socket::SOCKET_SECURE);
    if (!sock)
    {
      fprintf(stderr,"unable to connect to server\n");
      return 0;
    }

    uint8_t ctype=CLIENT_ABUSE;
    uint16_t port=lstl(main_net_cfg->port+2),cnum;

    uint8_t reg;
    if (sock->write(&ctype,1)!=1 ||   // send server out game port
                sock->read(&reg,1)!=1)        // is remote engine registered?
    { delete sock; return 0; }

    if (reg==2)   // too many players
    {
      fprintf(stderr, "%s", symbol_str("max_players"));
      delete sock;
      return 0;
    }

    // make sure the server is registered or sync problems will occur
    if (!reg)
    {
      fprintf(stderr, "%s", symbol_str("server_not_reg"));
      delete sock;
      return 0;
    }

    const size_t unamesize = 256;
    char uname[unamesize];
    strncpy(uname, get_login(), unamesize);

    uint8_t len=strlen(uname)+1;
    short nkills;

    if (sock->write(&len,1)!=1 ||
                sock->write(uname,len)!=len ||
                sock->write(&port,2)!=2  ||            // send server out game port
                sock->read(&port,2)!=2   ||            // read server's game port
                sock->read(&nkills,2)!=2 ||
                sock->read(&cnum,2)!=2   || cnum==0    // read player number (cannot be 0 because 0 is server)
                )
    { delete sock; return 0; }

    nkills=lstl(nkills);
    port=lstl(port);
    cnum=lstl(cnum);

    main_net_cfg->kills=nkills;
    net_address *addr=net_server->copy();
    addr->set_port(port);

    delete game_face;
    game_face=new game_client(sock,addr);
    delete addr;

    local_client_number=cnum;
    return cnum;
  }
  return 0;
}
コード例 #9
0
ファイル: defncopy.c プロジェクト: ystk/debian-freetds
/**
 * The purpose of this program is to load or extract the text of a stored procedure.  
 * This first cut does extract only.  
 * TODO: support loading procedures onto the server.  
 */
int
main(int argc, char *argv[])
{
	LOGINREC *login;
	DBPROCESS *dbproc;
	PROCEDURE procedure;
	RETCODE erc;
	int i, nrows;

	/* Initialize db-lib */
	erc = dbinit();	
	if (erc == FAIL) {
		fprintf(stderr, "%s:%d: dbinit() failed\n", options.appname, __LINE__);
		exit(1);
	}
	

	memset(&options, 0, sizeof(options));
	login = get_login(argc, argv, &options); /* get command-line parameters and call dblogin() */
	assert(login != NULL);

	/* Install our error and message handlers */
	dberrhandle(err_handler);
	dbmsghandle(msg_handler);

	/* 
	 * Override stdin, stdout, and stderr, as required 
	 */
	if (options.input_filename) {
		if (freopen(options.input_filename, "r", stdin) == NULL) {
			fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.input_filename, strerror(errno));
			exit(1);
		}
	}

	if (options.output_filename) {
		if (freopen(options.output_filename, "w", stdout) == NULL) {
			fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.output_filename, strerror(errno));
			exit(1);
		}
	}
	
	/* 
	 * Connect to the server 
	 */
	dbproc = dbopen(login, options.servername);
	assert(dbproc != NULL);
	
	/* Switch to the specified database, if any */
	if (options.database)
		dbuse(dbproc, options.database);

	/* 
	 * Read the procedure names and move their texts.  
	 */
	for (i=options.optind; i < argc; i++) {
		static const char query[] = " select	c.text"
					 " from	syscomments  as c"
					 " join 	sysobjects as o"
					 " on 		o.id = c.id"
					 " where	o.name = '%s'"
					 " and 	o.uid = user_id('%s')"
					 " and		o.type not in ('U', 'S')" /* no user or system tables */
					 " order by 	c.colid"
					;
		static const char query_table[] = " execute sp_help '%s.%s' ";

		parse_argument(argv[i], &procedure);

		erc = dbfcmd(dbproc, query, procedure.name, procedure.owner); 
	
		/* Send the query to the server (we could use dbsqlexec(), instead) */
		erc = dbsqlsend(dbproc);
		if (erc == FAIL) {
			fprintf(stderr, "%s:%d: dbsqlsend() failed\n", options.appname, __LINE__);
			exit(1);
		}
		
		/* Wait for it to execute */
		erc = dbsqlok(dbproc);
		if (erc == FAIL) {
			fprintf(stderr, "%s:%d: dbsqlok() failed\n", options.appname, __LINE__);
			exit(1);
		}

		/* Write the output */
		nrows = print_results(dbproc);
		
		if (0 == nrows) {
			erc = dbfcmd(dbproc, query_table, procedure.owner, procedure.name);
			erc = dbsqlexec(dbproc);
			if (erc == FAIL) {
				fprintf(stderr, "%s:%d: dbsqlexec() failed\n", options.appname, __LINE__);
				exit(1);
			}
			nrows = print_ddl(dbproc, &procedure);
		}

		switch (nrows) {
		case -1:
			return 1;
		case 0:
			fprintf(stderr, "%s: error: %s.%s.%s.%s not found\n", options.appname, 
					options.servername, options.database, procedure.owner, procedure.name);
			return 2;
		default:
			break;
		}
	}

	return 0;
}
コード例 #10
0
ファイル: innet.c プロジェクト: spippolatore/abuse
int request_server_entry()
{
  if (prot && main_net_cfg)
  {
    if (!net_server) return 0;

    if (game_sock) delete game_sock;
    dprintf("Joining game in progress, hang on....\n");

    int game_port = main_net_cfg->game_port;
		
    game_sock=prot->create_listen_socket(game_port,net_socket::SOCKET_FAST);     // this is used for fast game packet transmission
    if (!game_sock) { if (comm_sock) delete comm_sock; comm_sock=NULL; prot=NULL; return 0; }
    game_sock->read_selectable();
    main_net_cfg->game_port = game_port;

    net_socket *sock=prot->connect_to_server(net_server,net_socket::SOCKET_SECURE);
    if (!sock)
    { 
      dprintf("unable to connect to server\n");
      return 0;
    }

    uchar ctype=CLIENT_ABUSE;
    ushort port=lstl(game_port),cnum;

    uchar reg;
    if (sock->write(&ctype,1)!=1 ||   // send server our game port
        sock->read(&reg,1)!=1)        // is remote engine registered?
    { delete sock; return 0; }

    if (reg==2)   // too many players
    {
      dprintf(symbol_str("max_players"));
      delete sock;
      return 0;
    }

    // maker sure the two games are both registered or unregistered or sync problems
    // will occur.

    if (reg && !registered)
    {
      dprintf(symbol_str("net_not_reg"));
      delete sock; 
      return 0;
    } 

    if (!reg && registered)
    {
      dprintf(symbol_str("server_not_reg"));
      delete sock;
      return 0;
    }

    char uname[256];
    if (get_login())
      strcpy(uname,get_login());
    else strcpy(uname,"unknown");
    uchar len=strlen(uname)+1;
    short nkills;

    if (sock->write(&len,1)!=1 ||
        sock->write(uname,len)!=len || 
        sock->write(&port,2)!=2  ||            // send server our game port
        sock->read(&port,2)!=2   ||            // read server's game port
        sock->read(&nkills,2)!=2 ||
        sock->read(&cnum,2)!=2   || cnum==0    // read player number (cannot be 0 because 0 is server)
        )
    { delete sock; return 0; }

    nkills=lstl(nkills);
    port=lstl(port);
    cnum=lstl(cnum);
    
    main_net_cfg->kills=nkills;
    net_address *addr=net_server->copy();
    addr->set_port(port);

    if (game_face)
      delete game_face;
    game_face=new game_client(sock,addr);
    delete addr;

    local_client_number=cnum;
    return cnum;
  } else return 0;
}
コード例 #11
0
ファイル: testuid.c プロジェクト: cookrn/openamq
int main (int argc, char *argv [])
{
    printf ("Login name = %s\n", get_login ());
    return (EXIT_SUCCESS);
}
コード例 #12
0
ファイル: osm-traces.c プロジェクト: evanbattaglia/viking
/*
 * Upload a file
 * returns a basic status:
 *   < 0  : curl error
 *   == 0 : OK
 *   > 0  : HTTP error
  */
static gint osm_traces_upload_file(const char *user,
				   const char *password,
				   const char *file,
				   const char *filename,
				   const char *description,
				   const char *tags,
				   const OsmTraceVis_t *vistype)
{
  CURL *curl;
  CURLcode res;
  char curl_error_buffer[CURL_ERROR_SIZE];
  struct curl_slist *headers = NULL;
  struct curl_httppost *post=NULL;
  struct curl_httppost *last=NULL;

  char *base_url = "http://www.openstreetmap.org/api/0.6/gpx/create";

  gchar *user_pass = get_login();

  gint result = 0; // Default to it worked!

  g_debug("%s: %s %s %s %s %s %s", __FUNCTION__,
  	  user, password, file, filename, description, tags);

  /* Init CURL */
  curl = curl_easy_init();

  /* Filling the form */
  curl_formadd(&post, &last,
               CURLFORM_COPYNAME, "description",
               CURLFORM_COPYCONTENTS, description, CURLFORM_END);
  curl_formadd(&post, &last,
               CURLFORM_COPYNAME, "tags",
               CURLFORM_COPYCONTENTS, tags, CURLFORM_END);
  curl_formadd(&post, &last,
               CURLFORM_COPYNAME, "visibility",
               CURLFORM_COPYCONTENTS, vistype->apistr, CURLFORM_END);
  curl_formadd(&post, &last,
               CURLFORM_COPYNAME, "file",
               CURLFORM_FILE, file,
               CURLFORM_FILENAME, filename,
	       CURLFORM_CONTENTTYPE, "text/xml", CURLFORM_END);

  /* Prepare request */
  /* As explained in http://wiki.openstreetmap.org/index.php/User:LA2 */
  /* Expect: header seems to produce incompatibilites between curl and httpd */
  headers = curl_slist_append(headers, "Expect: ");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);
  curl_easy_setopt(curl, CURLOPT_URL, base_url);
  curl_easy_setopt(curl, CURLOPT_USERPWD, user_pass);
  curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_error_buffer);
  if (vik_verbose)
    curl_easy_setopt ( curl, CURLOPT_VERBOSE, 1 );

  /* Execute request */
  res = curl_easy_perform(curl);
  if (res == CURLE_OK)
  {
    long code;
    res = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
    if (res == CURLE_OK)
    {
      g_debug("received valid curl response: %ld", code);
      if (code != 200) {
        g_warning(_("failed to upload data: HTTP response is %ld"), code);
	result = code;
      }
    }
    else {
      g_error(_("curl_easy_getinfo failed: %d"), res);
      result = -1;
    }
  }
  else {
    g_warning(_("curl request failed: %s"), curl_error_buffer);
    result = -2;
  }

  /* Memory */
  g_free(user_pass); user_pass = NULL;
  
  curl_formfree(post);
  curl_easy_cleanup(curl);
  return result;
}