ptools namespace (move to putil namespace someday)
This commit is contained in:
parent
1b5e4392d4
commit
50e49d308c
|
|
@ -772,17 +772,17 @@ static psock_t *get_connected_socket() {
|
|||
time(&rawtime);
|
||||
|
||||
char *macAddr;
|
||||
macAddr = getMACaddr();
|
||||
macAddr = ptools_get_mac_addr();
|
||||
|
||||
eventParams params = {1, // Number of parameters we are passing below.
|
||||
{PAPI_STR(EPARAM_MAC, macAddr)}};
|
||||
create_backend_event(apiserver, INST_EVENT_CATEG, INST_EVENT_FLOGIN,
|
||||
ptools_create_backend_event(apiserver, INST_EVENT_CATEG, INST_EVENT_FLOGIN,
|
||||
INST_EVENT_CATEG, psync_my_auth, P_OS_ID, rawtime,
|
||||
¶ms, (char **)res);
|
||||
} else {
|
||||
debug(D_NOTICE, "Not a first login. Run sync event.");
|
||||
|
||||
send_psyncs_event(apiserver, psync_my_auth);
|
||||
ptools_send_psyncs_event(apiserver, psync_my_auth);
|
||||
}
|
||||
|
||||
if (isbusiness) {
|
||||
|
|
|
|||
|
|
@ -2804,7 +2804,7 @@ int psync_is_folder_syncable(char *localPath, char **errMsg) {
|
|||
|
||||
// Check if folder is not a child of an igrnored folder
|
||||
ignorePaths = psync_setting_get_string(_PS(ignorepaths));
|
||||
parse_os_path((char *)ignorePaths, &folders, (char *)DELIM_SEMICOLON, 0);
|
||||
ptools_parse_os_path((char *)ignorePaths, &folders, (char *)DELIM_SEMICOLON, 0);
|
||||
|
||||
for (i = 0; i < folders.cnt; i++) {
|
||||
debug(D_NOTICE, "Check ignored folder: [%s]=[%s]", folders.folders[i],
|
||||
|
|
@ -2850,7 +2850,7 @@ psync_folderid_t create_bup_mach_folder(char **msgErr) {
|
|||
eventParams optionalParams = {0};
|
||||
|
||||
debug(D_NOTICE, "Call backend [backup/createdevice].");
|
||||
res = backend_call(apiserver, "backup/createdevice", FOLDER_META,
|
||||
res = ptools_backend_call(apiserver, "backup/createdevice", FOLDER_META,
|
||||
&requiredParams, &optionalParams, &retData, msgErr);
|
||||
|
||||
if (res == 0) {
|
||||
|
|
@ -2907,7 +2907,7 @@ int psync_create_backup(char *path, char **errMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
parse_os_path(path, &folders, (char *)DELIM_DIR, 1);
|
||||
ptools_parse_os_path(path, &folders, (char *)DELIM_DIR, 1);
|
||||
|
||||
if (folders.cnt > 1) {
|
||||
oParCnt = 1;
|
||||
|
|
@ -2927,7 +2927,7 @@ int psync_create_backup(char *path, char **errMsg) {
|
|||
|
||||
debug(D_NOTICE, "Call backend [backup/createbackup].");
|
||||
|
||||
res = backend_call(apiserver, "backup/createbackup", FOLDER_META, &reqPar,
|
||||
res = ptools_backend_call(apiserver, "backup/createbackup", FOLDER_META, &reqPar,
|
||||
&optPar, &retData, errMsg);
|
||||
|
||||
if (res == 0) {
|
||||
|
|
@ -2995,7 +2995,7 @@ int psync_delete_backup(psync_syncid_t syncId, char **errMsg) {
|
|||
|
||||
debug(D_NOTICE, "Call backend [backup/stopbackup].");
|
||||
|
||||
res = backend_call(apiserver, "backup/stopbackup", NO_PAYLOAD, &reqPar,
|
||||
res = ptools_backend_call(apiserver, "backup/stopbackup", NO_PAYLOAD, &reqPar,
|
||||
&optPar, &retData, errMsg);
|
||||
|
||||
if (res == 0) {
|
||||
|
|
@ -3029,7 +3029,7 @@ void psync_stop_device(psync_folderid_t folderId, char **errMsg) {
|
|||
|
||||
debug(D_NOTICE, "Call backend [backup/stopdevice].");
|
||||
|
||||
res = backend_call(apiserver, "backup/stopdevice", NO_PAYLOAD, &reqPar,
|
||||
res = ptools_backend_call(apiserver, "backup/stopdevice", NO_PAYLOAD, &reqPar,
|
||||
&optPar, &retData, errMsg);
|
||||
|
||||
if (res != 0) {
|
||||
|
|
@ -3046,7 +3046,7 @@ char *get_backup_root_name() {
|
|||
"s.value = f.id AND s.id = 'BackupRootFoId'");
|
||||
}
|
||||
|
||||
char *get_pc_name() { return get_machine_name(); }
|
||||
char *get_pc_name() { return ptools_get_machine_name(); }
|
||||
|
||||
void psync_async_delete_sync(void *ptr) {
|
||||
psync_syncid_t syncId = (psync_syncid_t)(uintptr_t)ptr;
|
||||
|
|
@ -3223,12 +3223,12 @@ userinfo_t *psync_get_userinfo() {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int psync_create_backend_event(const char *category, const char *action,
|
||||
int psync_ptools_create_backend_event(const char *category, const char *action,
|
||||
const char *label, eventParams params,
|
||||
char *err) {
|
||||
time_t rawtime;
|
||||
time(&rawtime);
|
||||
return create_backend_event(apiserver, category, action, label, psync_my_auth,
|
||||
return ptools_create_backend_event(apiserver, category, action, label, psync_my_auth,
|
||||
P_OS_ID, rawtime, ¶ms, &err);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1750,7 +1750,7 @@ userinfo_t *psync_get_userinfo();
|
|||
* label - string representing label of the event
|
||||
* eventParams - list of binparams(optional)
|
||||
*/
|
||||
int psync_create_backend_event(const char *category, const char *action,
|
||||
int psync_ptools_create_backend_event(const char *category, const char *action,
|
||||
const char *label, eventParams params,
|
||||
char *err);
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
char *getMACaddr() {
|
||||
char *ptools_get_mac_addr() {
|
||||
char buffer[128];
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
|
|
@ -81,7 +81,7 @@ char *getMACaddr() {
|
|||
}
|
||||
}
|
||||
|
||||
int create_backend_event(const char *binapi, const char *category,
|
||||
int ptools_create_backend_event(const char *binapi, const char *category,
|
||||
const char *action, const char *label,
|
||||
const char *auth, int os, time_t etime,
|
||||
eventParams *params, char **err) {
|
||||
|
|
@ -208,7 +208,7 @@ int create_backend_event(const char *binapi, const char *category,
|
|||
return result;
|
||||
}
|
||||
|
||||
int backend_call(const char *binapi, const char *wsPath,
|
||||
int ptools_backend_call(const char *binapi, const char *wsPath,
|
||||
const char *payloadName, eventParams *requiredParams,
|
||||
eventParams *optionalParams, binresult **resData, char **err) {
|
||||
int reqParCnt = requiredParams->paramCnt;
|
||||
|
|
@ -339,7 +339,7 @@ int backend_call(const char *binapi, const char *wsPath,
|
|||
return result;
|
||||
}
|
||||
|
||||
char *get_machine_name() {
|
||||
char *ptools_get_machine_name() {
|
||||
int nameSize = 1024;
|
||||
char pcName[1024];
|
||||
|
||||
|
|
@ -354,7 +354,7 @@ char *get_machine_name() {
|
|||
return psync_strdup(pcName);
|
||||
}
|
||||
|
||||
void parse_os_path(char *path, folderPath *folders, char *delim, int mode) {
|
||||
void ptools_parse_os_path(char *path, folderPath *folders, char *delim, int mode) {
|
||||
char fName[255];
|
||||
char *buff;
|
||||
int i = 0, j = 0, k = 0;
|
||||
|
|
@ -401,7 +401,7 @@ void parse_os_path(char *path, folderPath *folders, char *delim, int mode) {
|
|||
folders->cnt = j;
|
||||
}
|
||||
|
||||
void send_psyncs_event(const char *binapi, const char *auth) {
|
||||
void ptools_send_psyncs_event(const char *binapi, const char *auth) {
|
||||
psync_folderid_t syncEventFlag = 0;
|
||||
time_t rawtime;
|
||||
char *errMsg;
|
||||
|
|
@ -431,7 +431,7 @@ void send_psyncs_event(const char *binapi, const char *auth) {
|
|||
eventParams params = {1, // Number of parameters passed below
|
||||
{PAPI_NUM(PSYNC_SYNCS_COUNT, syncCnt)}};
|
||||
|
||||
intRes = create_backend_event(binapi,
|
||||
intRes = ptools_create_backend_event(binapi,
|
||||
PSYNC_EVENT_CATEG, // "SYNCS_EVENTS"
|
||||
PSYNC_EVENT_ACTION, // "SYNCS_LOG_COUNT"
|
||||
PSYNC_EVENT_LABEL, // "SYNCS_COUNT"
|
||||
|
|
@ -449,7 +449,7 @@ void send_psyncs_event(const char *binapi, const char *auth) {
|
|||
psync_free(errMsg);
|
||||
}
|
||||
|
||||
int set_be_file_dates(uint64_t fileid, time_t ctime, time_t mtime) {
|
||||
int ptools_set_backend_file_dates(uint64_t fileid, time_t ctime, time_t mtime) {
|
||||
int callRes;
|
||||
char msgErr[1024];
|
||||
binresult *retData;
|
||||
|
|
@ -468,7 +468,7 @@ int set_be_file_dates(uint64_t fileid, time_t ctime, time_t mtime) {
|
|||
PAPI_NUM("newtm", ctime), PAPI_BOOL("isctime", 1)}};
|
||||
|
||||
callRes =
|
||||
backend_call(apiserver, "setfilemtime", FOLDER_META, &requiredParams1,
|
||||
ptools_backend_call(apiserver, "setfilemtime", FOLDER_META, &requiredParams1,
|
||||
&optionalParams, &retData, (char **)msgErr);
|
||||
|
||||
debug(D_NOTICE, "cTime res: [%d]", callRes);
|
||||
|
|
@ -480,7 +480,7 @@ int set_be_file_dates(uint64_t fileid, time_t ctime, time_t mtime) {
|
|||
PAPI_NUM("newtm", mtime), PAPI_BOOL("isctime", 0)}};
|
||||
|
||||
callRes =
|
||||
backend_call(apiserver, "setfilemtime", FOLDER_META, &requiredParams,
|
||||
ptools_backend_call(apiserver, "setfilemtime", FOLDER_META, &requiredParams,
|
||||
&optionalParams, &retData, (char **)msgErr);
|
||||
|
||||
debug(D_NOTICE, "mTime res: [%d]", callRes);
|
||||
|
|
@ -488,7 +488,7 @@ int set_be_file_dates(uint64_t fileid, time_t ctime, time_t mtime) {
|
|||
return callRes;
|
||||
}
|
||||
|
||||
psync_syncid_t get_sync_id_from_fid(psync_folderid_t fid) {
|
||||
psync_syncid_t ptools_syncid_from_fid(psync_folderid_t fid) {
|
||||
psync_sql_res *res;
|
||||
psync_variant_row row;
|
||||
psync_syncid_t syncId = -1;
|
||||
|
|
@ -506,7 +506,7 @@ psync_syncid_t get_sync_id_from_fid(psync_folderid_t fid) {
|
|||
return syncId;
|
||||
}
|
||||
|
||||
char *get_sync_folder_by_syncid(uint64_t syncId) {
|
||||
char *ptools_sfldr_by_syncid(uint64_t syncId) {
|
||||
psync_sql_res *res;
|
||||
psync_variant_row row;
|
||||
const char *syncName;
|
||||
|
|
@ -530,7 +530,7 @@ char *get_sync_folder_by_syncid(uint64_t syncId) {
|
|||
return retName;
|
||||
}
|
||||
|
||||
char *get_folder_name_from_path(char *path) {
|
||||
char *ptools_fldr_name_by_path(char *path) {
|
||||
char *folder;
|
||||
|
||||
folder = "";
|
||||
|
|
|
|||
|
|
@ -79,27 +79,27 @@ typedef struct _folderPath {
|
|||
char *folders[50];
|
||||
} folderPath;
|
||||
|
||||
int create_backend_event(const char *binapi, const char *category,
|
||||
int ptools_create_backend_event(const char *binapi, const char *category,
|
||||
const char *action, const char *label,
|
||||
const char *auth, int os, time_t etime,
|
||||
eventParams *params, char **err);
|
||||
|
||||
int backend_call(const char *binapi, const char *wsPath,
|
||||
int ptools_backend_call(const char *binapi, const char *wsPath,
|
||||
const char *payloadName, eventParams *requiredParams,
|
||||
eventParams *optionalParams, binresult **resData, char **err);
|
||||
|
||||
char *getMACaddr();
|
||||
char *ptools_get_mac_addr();
|
||||
|
||||
char *get_machine_name();
|
||||
char *ptools_get_machine_name();
|
||||
|
||||
void parse_os_path(char *path, folderPath *folders, char *delim, int mode);
|
||||
void ptools_parse_os_path(char *path, folderPath *folders, char *delim, int mode);
|
||||
|
||||
void send_psyncs_event(const char *binapi, const char *auth);
|
||||
void ptools_send_psyncs_event(const char *binapi, const char *auth);
|
||||
|
||||
int set_be_file_dates(uint64_t fileid, time_t ctime, time_t mtime);
|
||||
int ptools_set_backend_file_dates(uint64_t fileid, time_t ctime, time_t mtime);
|
||||
|
||||
uint32_t get_sync_id_from_fid(uint64_t fid);
|
||||
uint32_t ptools_syncid_from_fid(uint64_t fid);
|
||||
|
||||
char *get_sync_folder_by_syncid(uint64_t syncId);
|
||||
char *ptools_sfldr_by_syncid(uint64_t syncId);
|
||||
|
||||
char *get_folder_name_from_path(char *path);
|
||||
char *ptools_fldr_name_by_path(char *path);
|
||||
|
|
|
|||
|
|
@ -357,9 +357,9 @@ int handle_api_errors(sync_err_struct *err_struct) {
|
|||
case BEAPI_ERR_MV_TOO_MANY_IN_SHA:
|
||||
debug(D_NOTICE, "Critical sync error. Stopping the sync.");
|
||||
|
||||
syncId = get_sync_id_from_fid(err_struct->folderid);
|
||||
syncFolder = get_sync_folder_by_syncid(syncId);
|
||||
folder = get_folder_name_from_path(syncFolder);
|
||||
syncId = ptools_syncid_from_fid(err_struct->folderid);
|
||||
syncFolder = ptools_sfldr_by_syncid(syncId);
|
||||
folder = ptools_fldr_name_by_path(syncFolder);
|
||||
|
||||
debug(D_NOTICE, "Got sync path: [%s] Sync folder: [%s]", syncFolder,
|
||||
folder);
|
||||
|
|
@ -577,7 +577,7 @@ static int check_file_if_exists(const unsigned char *hashhex, uint64_t fsize,
|
|||
(unsigned long)folderid, name);
|
||||
set_local_file_remote_id(localfileid, fileid, hash);
|
||||
|
||||
set_be_file_dates(fileid, pfile_stat_ctime(st), pfile_stat_mtime(st));
|
||||
ptools_set_backend_file_dates(fileid, pfile_stat_ctime(st), pfile_stat_mtime(st));
|
||||
|
||||
return 1;
|
||||
} else
|
||||
|
|
|
|||
Loading…
Reference in New Issue