Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo committed Mar 26, 2014
1 parent f73e8e6 commit a19e65d
Show file tree
Hide file tree
Showing 19 changed files with 12,914 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -3,7 +3,7 @@ TARGET = MegaFuse
###############


SRC = src/megafusecallbacks.cpp src/fuse.c src/fuseFileCache.cpp src/megafuse.cpp src/megaposix.cpp src/Config.cpp src/megabdb.cpp src/megaclient.cpp src/megacrypto.cpp src/megacli.cpp src/fuseImpl.cpp
SRC = src/megacli.cpp src/megafusecallbacks.cpp src/fuse.c src/fuseFileCache.cpp src/megafuse.cpp src/megaposix.cpp src/Config.cpp sdk/megabdb.cpp src/megaclient.cpp sdk/megacrypto.cpp src/fuseImpl.cpp

OUT = $(TARGET)
OBJ = $(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SRC)))
Expand Down
18 changes: 18 additions & 0 deletions sdk/Makefile
@@ -0,0 +1,18 @@
CXX=g++
CFLAGS=-g -Wall -isystem /usr/include/cryptopp
LIB=-lcryptopp -lfreeimage -lreadline -ltermcap -lcurl -ldb_cxx
LDFLAGS=
SOURCES=megaposix.cpp megacli.cpp megaclient.cpp megacrypto.cpp megabdb.cpp
OBJECTS=$(SOURCES:.cpp=.o)
PROGS=megaclient

all: $(PROGS)

megaclient: $(OBJECTS)
$(CXX) $(CFLAGS) $(LDFLAGS) $^ -o $@ $(LIB)

.cpp.o:
$(CXX) -c $(CFLAGS) $< -o $@

clean:
rm -f $(OBJECTS) $(PROGS) $(PROGS:=.o)
18 changes: 18 additions & 0 deletions sdk/Makefile.win32
@@ -0,0 +1,18 @@
CXX=g++
CFLAGS=-g -Wall -isystem ../cryptopp -isystem ../FreeImage/Dist -isystem ../db -isystem ..
LIB=-lwinhttp -lws2_32 -L../cryptopp -lcryptopp -L../FreeImage/Dist -lfreeimage -L../readline -lreadline -L../termcap -ltermcap -L../db -ldb_cxx
LDFLAGS=
SOURCES=megawin32.cpp megacli.cpp megacrypto.cpp megaclient.cpp megabdb.cpp
OBJECTS=$(SOURCES:.cpp=.o)
PROGS=megaclient

all: $(PROGS)

megaclient: $(OBJECTS)
$(CXX) $(CFLAGS) $(LDFLAGS) $^ -o $@ $(LIB)

.cpp.o:
$(CXX) -c $(CFLAGS) $< -o $@

clean:
rm -f $(OBJECTS) $(PROGS) $(PROGS:=.o)
41 changes: 41 additions & 0 deletions sdk/mega.h
@@ -0,0 +1,41 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
#include <assert.h>
#include <memory.h>

#ifndef _WIN32
#include <unistd.h>
#include <arpa/inet.h>

#ifndef __MACH__
#include <endian.h>
#endif
#endif

#ifdef _WIN32
#define atoll _atoi64
#define snprintf _snprintf
#define mkdir _mkdir
#include <windows.h>
#define _CRT_SECURE_NO_WARNINGS
#endif

typedef int64_t m_off_t;

#ifndef htobe64
#define htobe64(x) (((uint64_t) htonl((uint32_t) ((x) >> 32))) | (((uint64_t) htonl((uint32_t) x)) << 32))
#endif

#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <iterator>
#include <queue>
#include <list>

using namespace std;
3 changes: 0 additions & 3 deletions src/megabdb.cpp → sdk/megabdb.cpp
Expand Up @@ -42,9 +42,6 @@ DbTable* BdbAccess::open(string* name)

dbdir.append(*name);
MegaClient::escapefilename(&dbdir);
string dbpath = string(getenv("HOME")) + "/.megaclient/";
mkdir(dbpath.c_str(),0700);
dbdir = dbpath + dbdir;
mkdir(dbdir.c_str(),0700);

env = new DbEnv(0);
Expand Down
57 changes: 57 additions & 0 deletions sdk/megabdb.h
@@ -0,0 +1,57 @@
/*
MEGA SDK 2013-10-03 - sample application, Berkeley DB access
(c) 2013 by Mega Limited, Wellsford, New Zealand
Applications using the MEGA API must present a valid application key
and comply with the the rules set forth in the Terms of Service.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/

#ifndef MEGABDB_H
#define MEGABDB_H 1

class BdbAccess : public DbAccess
{
DbEnv* env;

public:
DbTable* open(string*);

BdbAccess();
~BdbAccess();
};

class BdbTable : public DbTable
{
Db* db;
DbTxn* dbtxn;
DbEnv* dbenv;
Dbc* dbcursor;

public:
void rewind();
int next(uint32_t*, string*);
int get(uint32_t, string*);
int put(uint32_t, char*, unsigned);
int del(uint32_t);
void truncate();
void begin();
void commit();
void abort();

uint32_t nextid;

BdbTable(DbEnv*);
~BdbTable();
};

#endif

0 comments on commit a19e65d

Please sign in to comment.