Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
rexbu committed Mar 31, 2018
1 parent a387213 commit 809b7ea
Show file tree
Hide file tree
Showing 38 changed files with 108 additions and 90 deletions.
Binary file added basic/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion basic/HMAC_SHA1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//******************************************************************************
#include <iostream>
#include <memory>
#include "HMAC_SHA1.h"
#include "hmac_sha1.h"


void CHMAC_SHA1::HMAC_SHA1(BYTE *text, int text_len, BYTE *key, int key_len, BYTE *digest)
Expand Down
2 changes: 1 addition & 1 deletion basic/HMAC_SHA1.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifndef __HMAC_SHA1_H__
#define __HMAC_SHA1_H__

#include "SHA1.h"
#include "sha1.h"

typedef unsigned char BYTE ;

Expand Down
2 changes: 1 addition & 1 deletion basic/JSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

#include "JSON.h"
#include "McZip.h"
#include "Zip.h"
#include <float.h>

using namespace mc;
Expand Down
2 changes: 1 addition & 1 deletion basic/SHA1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/

#include "SHA1.h"
#include "sha1.h"

#ifdef SHA1_UTILITY_FUNCTIONS
#define SHA1_MAX_FILE_BUFFER 8000
Expand Down
2 changes: 1 addition & 1 deletion basic/Thread.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Thread.h"
#include "thread.h"
#ifdef __ANDROID__
#include <jni.h>
#endif
Expand Down
20 changes: 10 additions & 10 deletions basic/ThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* history:
*/

#include "ThreadPool.h"
#include "threadpool.h"

#pragma --mark "工作者线程"
ThreadWork::ThreadWork(pthread_mutex_t* lock, pthread_cond_t* ready, std::queue<thread_task_t>* queue){
Expand Down Expand Up @@ -53,24 +53,24 @@ void ThreadWork::loop(){
}

#pragma --mark "线程池"
ThreadPool* ThreadPool::m_instance = NULL;
threadpool* threadpool::m_instance = NULL;

ThreadPool* ThreadPool::shareInstance(){
threadpool* threadpool::shareInstance(){
if (m_instance==NULL) {
m_instance = new ThreadPool();
m_instance = new threadpool();
}

return m_instance;
}

void ThreadPool::destroyInstance(){
void threadpool::destroyInstance(){
if (m_instance!=NULL) {
delete m_instance;
m_instance = NULL;
}
}

ThreadPool::ThreadPool(int thread_num){
threadpool::threadpool(int thread_num){
m_threads.resize(thread_num);
pthread_mutex_init(&m_lock, NULL);
pthread_cond_init(&m_ready, NULL);
Expand All @@ -81,19 +81,19 @@ ThreadPool::ThreadPool(int thread_num){
}
}

ThreadPool::~ThreadPool(){
threadpool::~threadpool(){
destroy();
}

void ThreadPool::add(void* (*run)(void*),void* arg){
void threadpool::add(void* (*run)(void*),void* arg){
pthread_mutex_lock(&m_lock);
thread_task_t task = {run , arg};
m_queue.push(task);
pthread_cond_signal(&m_ready);
pthread_mutex_unlock(&m_lock);
}

void ThreadPool::destroy(){
void threadpool::destroy(){
if (m_threads.size()==0) {
return;
}
Expand Down Expand Up @@ -121,5 +121,5 @@ void ThreadPool::destroy(){
}

void async_run(void* (*run)(void*), void* arg){
ThreadPool::shareInstance()->add(run, arg);
threadpool::shareInstance()->add(run, arg);
}
12 changes: 6 additions & 6 deletions basic/ThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <queue>
#include <vector>
#include "bs.h"
#include "Thread.h"
#include "thread.h"

using namespace std;
typedef struct thread_task_t{
Expand All @@ -36,19 +36,19 @@ class ThreadWork:public LoopThread{
pthread_cond_t m_queue_ready;
};

class ThreadPool{
class threadpool{
public:
static ThreadPool* shareInstance();
static threadpool* shareInstance();
static void destroyInstance();

ThreadPool(int thread_num = 20);
~ThreadPool();
threadpool(int thread_num = 2);
~threadpool();

void add(void* (*run)(void*),void* arg);
void destroy();

protected:
static ThreadPool* m_instance;
static threadpool* m_instance;

std::vector<ThreadWork*> m_threads;
std::queue<thread_task_t> m_queue;
Expand Down
4 changes: 2 additions & 2 deletions basic/android/McDevice.cpp → basic/android/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include <iostream>
#include <string>
#include "bs.h"
#include "../McDevice.h"
#include "../McFile.h"
#include "device.h"
#include "file.h"

using namespace std;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <jni.h>
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#include "../McFile.h"
#include "file.h"

extern JavaVM* g_jvm;

Expand Down
22 changes: 11 additions & 11 deletions basic/McBasic.h → basic/basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
#ifndef __basic_h
#define __basic_h

#include "JSON.h"
#include "McDevice.h"
#include "McFile.h"
#include "McHttp.h"
#include "McZip.h"
#include "Thread.h"
#include "McReference.h"
#include "SharedPreferences.h"
#include "McTask.h"
#include "ThreadPool.h"
#include "McTimer.h"
#include "json.h"
#include "device.h"
#include "file.h"
#include "http.h"
#include "zip.h"
#include "thread.h"
#include "reference.h"
#include "shared_preferences.h"
#include "task.h"
#include "threadpool.h"
#include "timer.h"

// 内存管理好烦啊
// 异步删除内存,用于回调中删除自己
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions basic/McFile.cpp → basic/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include <iostream>
#include <string>
#include "McFile.h"
#include "McDevice.h"
#include "file.h"
#include "device.h"

using namespace mc;

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions basic/McHmacAuth.cpp → basic/hmac_auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Copyright © 2017年 Rex. All rights reserved.
//

#include "McHmacAuth.h"
#include "hmac_auth.h"
#include <string.h>
#include "HMAC_SHA1.h"
#include "hmac_sha1.h"

#define MAX_MESSAGE_LENGTH 4096

Expand Down
File renamed without changes.
24 changes: 12 additions & 12 deletions basic/McHttp.cpp → basic/http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
*/

#include "bs.h"
#include "McDevice.h"
#include "McHttp.h"
#include "McFile.h"
#include "McTask.h"
#include "ThreadPool.h"
#include "SharedPreferences.h"
#include "McFile.h"
#include "McZip.h"
#include "device.h"
#include "http.h"
#include "file.h"
#include "task.h"
#include "threadpool.h"
#include "shared_preferences.h"
#include "file.h"
#include "Zip.h"
#include <iterator>
#include "JSON.h"

Expand Down Expand Up @@ -98,7 +98,7 @@ bool HttpSession::http_show_log = false;

HttpSession::HttpSession(void *threadpool) {
if (threadpool == NULL) {
m_thread_pool = ThreadPool::shareInstance();
m_thread_pool = threadpool::shareInstance();
} else {
m_thread_pool = threadpool;
}
Expand Down Expand Up @@ -148,7 +148,7 @@ void HttpSession::http(const char *url, const char *method, const char *body, ui
void **para = (void **) malloc(sizeof(void *) * 2);
para[0] = h;
para[1] = this;
((ThreadPool *) m_thread_pool)->add(thread_http, para);
((threadpool *) m_thread_pool)->add(thread_http, para);
}

void HttpSession::download(const char *url, const char *path, HttpFileCallback *callback) {
Expand Down Expand Up @@ -261,7 +261,7 @@ void HttpSession::saveCookie(const char *cookie) {
int64_t crysize = crypt.encryptByCompress((byte *) str, (uint32_t) strlen(str));

char path[1024];
SharedPreferences::path("__CurrentCookie", path, sizeof(path));
shared_preferences::path("__CurrentCookie", path, sizeof(path));
FileManager::write(path, crypt.bytes(), (size_t) crysize);
}

Expand All @@ -271,7 +271,7 @@ void HttpSession::setCookie(const char *cookie) {

void HttpSession::clearCookie() {
char path[1024];
SharedPreferences::path("__CurrentCookie", path, sizeof(path));
shared_preferences::path("__CurrentCookie", path, sizeof(path));
FileManager::remove(path);
map<string, string>::iterator cookie = m_headers.find("Cookie");
m_headers.erase(cookie);
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions basic/ios/McDevice.mm → basic/ios/device.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#import <Foundation/Foundation.h>
#include <sys/utsname.h>
#import <CommonCrypto/CommonDigest.h>
#include "McDevice.h"
#include "device.h"
#import "SecureUDID.h"
#include <sys/sysctl.h>
#include <net/if_dl.h>
#include "McDevice.h"
#include "device.h"
#include "SFHFKeychainUtils.h"
#include <string.h>

Expand Down
2 changes: 1 addition & 1 deletion basic/ios/McFile.mm → basic/ios/file.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>
#include <stdio.h>
#include <string.h>
#include "McFile.h"
#include "file.h"
using namespace mc;

//const char* FileManager::m_root_path = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] UTF8String];
Expand Down
4 changes: 2 additions & 2 deletions basic/McReference.cpp → basic/reference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* history:
*/

#include "McReference.h"
#include "reference.h"

using namespace mc;

Expand All @@ -33,7 +33,7 @@ ReferenceCache::~ReferenceCache(){
m_cache.clear();
}

Reference* ReferenceCache::get(){
reference* ReferenceCache::get(){
for (int i=0; i<m_cache.size(); i++) {
if (m_cache[i]->idle()) {
return m_cache[i];
Expand Down
10 changes: 5 additions & 5 deletions basic/McReference.h → basic/reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#include <vector>

namespace mc {
class Reference{
class reference{
public:
Reference(){
reference(){
m_referencecount = 0;
m_is_reference = true;
}
Expand Down Expand Up @@ -68,16 +68,16 @@ namespace mc {

~ReferenceCache();

virtual Reference* get();
virtual reference* get();

// 必须是new出来的对象
inline void add(Reference* r){
inline void add(reference* r){
m_cache.push_back(r);
}

protected:
static ReferenceCache* m_instance;
std::vector<Reference*> m_cache;
std::vector<reference*> m_cache;
};
}

Expand Down
12 changes: 6 additions & 6 deletions basic/SharedPreferences.cpp → basic/shared_preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* history:
*/

#include "SharedPreferences.h"
#include "McZip.h"
#include "shared_preferences.h"
#include "Zip.h"

using namespace mc;

static char g_root_path[1024];
const char* SharedPreferences::m_root_path = NULL;
const char* shared_preferences::m_root_path = NULL;

SharedPreferences::SharedPreferences(const char* name){
shared_preferences::shared_preferences(const char* name){
if (name != NULL) {
path(name, m_path, sizeof(m_path));
if(open(m_path)){
Expand All @@ -26,15 +26,15 @@ SharedPreferences::SharedPreferences(const char* name){
}
}

bool SharedPreferences::commit(){
bool shared_preferences::commit(){
const char* b = toString();
Crypt crypt;
int64_t size = crypt.encryptByCompress((byte*)b, (uint32_t)strlen(b));
FileManager::write(m_path, crypt.bytes(), (uint32_t)size);
return true;
}

const char* SharedPreferences::path(const char* name, char* path, uint32_t size){
const char* shared_preferences::path(const char* name, char* path, uint32_t size){
if (m_root_path == NULL) {
snprintf(g_root_path, sizeof(g_root_path), "%s/__shared_prefs", FileManager::rootPath());
// 如果不存在则创建文件夹
Expand Down
Loading

0 comments on commit 809b7ea

Please sign in to comment.