2014-09-15 20:22:02 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2013 Bryan Christ <bryan.christ@mediafire.com>
|
2014-09-17 11:20:23 +02:00
|
|
|
* 2014 Johannes Schauer <j.schauer@email.de>
|
2014-09-15 20:22:02 +02:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License version 2, as published by
|
|
|
|
|
* the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc., 51
|
|
|
|
|
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2014-09-15 20:00:05 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
|
2014-09-18 09:11:00 +02:00
|
|
|
#include "../apicalls.h"
|
|
|
|
|
#include "../mfconn.h"
|
|
|
|
|
#include "../../utils/http.h"
|
|
|
|
|
#include "../../utils/strings.h"
|
2014-09-15 20:00:05 +02:00
|
|
|
|
|
|
|
|
int
|
2014-09-19 23:13:29 +02:00
|
|
|
mfconn_api_folder_create(mfconn *conn,char *parent,char *name)
|
2014-09-15 20:00:05 +02:00
|
|
|
{
|
|
|
|
|
char *api_call;
|
|
|
|
|
int retval;
|
|
|
|
|
|
2014-09-19 23:13:29 +02:00
|
|
|
if(conn == NULL) return -1;
|
2014-09-15 20:00:05 +02:00
|
|
|
|
|
|
|
|
if(name == NULL) return -1;
|
|
|
|
|
if(strlen(name) < 1) return -1;
|
|
|
|
|
|
|
|
|
|
// key must either be 11 chars or "myfiles"
|
|
|
|
|
if(parent != NULL)
|
|
|
|
|
{
|
|
|
|
|
if(strlen(parent) != 13)
|
|
|
|
|
{
|
|
|
|
|
// if it is myfiles, set paret to NULL
|
|
|
|
|
if(strcmp(parent,"myfiles") == 0) parent = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(parent != NULL)
|
|
|
|
|
{
|
2014-09-19 23:13:29 +02:00
|
|
|
api_call = mfconn_create_signed_get(conn,0,"folder/create.php",
|
2014-09-15 20:00:05 +02:00
|
|
|
"?parent_key=%s"
|
|
|
|
|
"&foldername=%s"
|
|
|
|
|
"&response_format=json",
|
2014-09-18 09:11:00 +02:00
|
|
|
parent,name);
|
2014-09-15 20:00:05 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-09-19 23:13:29 +02:00
|
|
|
api_call = mfconn_create_signed_get(conn,0,"folder/create.php",
|
2014-09-18 09:11:00 +02:00
|
|
|
"?foldername=%s&response_format=json", name);
|
2014-09-15 20:00:05 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-19 23:13:29 +02:00
|
|
|
mfhttp *http = http_create();
|
|
|
|
|
retval = http_get_buf(http, api_call, NULL, NULL);
|
|
|
|
|
http_destroy(http);
|
2014-09-15 20:00:05 +02:00
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|