This commit is contained in:
biosvos
2026-08-07 17:38:18 +09:00
commit 873193a243
9613 changed files with 2755992 additions and 0 deletions
@@ -0,0 +1,55 @@
# Makefile for sample file
CC = g++
CFLAGS = -g -Wall
SDK_INCLUDE = ./SDK/include
SDK_LIB = ./SDK/lib
PATH_INC = -I$(SDK_INCLUDE)
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
PATH_LIBS = -lc -lz -lexpat -lgssapi_krb5 -L$(SDK_LIB)
else
PATH_LIBS = -lc -lexpat -L$(SDK_LIB)
endif
APP= sample sample_csdk_static sample_csdk_dynamic sample_ssdk_static sample_ssdk_dynamic auth_token
all: $(APP)
sync
sample: sample.o
$(CC) $(CFLAGS) -o $@ $^ $(PATH_LIBS) $(SDK_LIB)/libshcsdk.a $(SDK_LIB)/libshssdk.a
sample.o: sample.cpp
$(CC) $(CFLAGS) -c $^ $(PATH_INC)
sample_csdk_static: sample_csdk.o
$(CC) $(CFLAGS) -o $@ $^ $(PATH_LIBS) $(SDK_LIB)/libshcsdk.a
sample_csdk_dynamic: sample_csdk.o
$(CC) $(CFLAGS) -o $@ $^ $(PATH_LIBS) -Wl,-rpath,'$(SDK_LIB)' -lshcsdk
sample_csdk.o: sample_csdk.cpp
$(CC) $(CFLAGS) -c $^ $(PATH_INC)
sample_ssdk_static: sample_ssdk.o
$(CC) $(CFLAGS) -o $@ $^ $(PATH_LIBS) $(SDK_LIB)/libshssdk.a
sample_ssdk_dynamic: sample_ssdk.o
$(CC) $(CFLAGS) -o $@ $^ $(PATH_LIBS) -Wl,-rpath,'$(SDK_LIB)' -lshssdk
sample_ssdk.o: sample_ssdk.cpp
$(CC) $(CFLAGS) -c $^ $(PATH_INC)
auth_token.o: auth_token.cpp
$(CC) $(CFLAGS) -c $^ $(PATH_INC)
auth_token: auth_token.o
$(CC) $(CFLAGS) -o $@ $^ $(PATH_LIBS) $(SDK_LIB)/libshssdk.a
clean:
rm -f *.o $(APP)
@@ -0,0 +1,29 @@
1. make SDK include
/smpale dir/SDK/include
2. make SDK lib
/smpale dir/SDK/lib
3. copy include, library files
tar.SDK/include/* => /smpale dir/SDK/include
tar.SDK/_shared/csdk/* => /smpale dir/SDK/lib
tar.SDK/_shared/ssdk/* => /smpale dir/SDK/lib
tar.SDK/_shared/sdk/* => /smpale dir/SDK/lib
tar.SDK/_static/csdk/* => /smpale dir/SDK/lib
tar.SDK/_static/ssdk/* => /smpale dir/SDK/lib
tar.SDK/_static/sdk/* => /smpale dir/SDK/lib
ex)
[sample_linux]# tar zxvf Solbox_SDK.tar.gz
[sample_linux]# tar zxvf Sample.tar.gz
[sample_linux]# cd sample_linux
[sample_linux]# mkdir -p SDK/include
[sample_linux]# mkdir -p SDK/lib
[sample_linux]# cp ../64/SOLBOX/include/* SDK/include
[sample_linux]# cp -P ../64/SOLBOX/_shared/csdk/* SDK/lib/
[sample_linux]# cp -P ../64/SOLBOX/_shared/ssdk/* SDK/lib/
[sample_linux]# cp -P ../64/SOLBOX/_shared/sdk/* SDK/lib/
[sample_linux]# cp -P ../64/SOLBOX/_static/csdk/* SDK/lib/
[sample_linux]# cp -P ../64/SOLBOX/_static/ssdk/* SDK/lib/
[sample_linux]# cp -P ../64/SOLBOX/_static/sdk/* SDK/lib/
@@ -0,0 +1,73 @@
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctime>
#include "SHSSDK.h"
// 사용방법 표시
void PrintUsage(const char* prg)
{
fprintf( stderr, "\n" );
fprintf( stderr, "Usage: %s [id] [passwd] [service] [auth key] [cert file] [expire time]\n", prg );
fprintf( stderr, "Inputs: \n" );
fprintf( stderr, " id : ID \n" );
fprintf( stderr, " passwd : Password\n" );
fprintf( stderr, " service : Service Name \n" );
fprintf( stderr, " auth key : Service authentication key \n" );
fprintf( stderr, " cert file : authentication file(full path) \n" );
fprintf( stderr, " expire time: auth token expiration time(sec) \n" );
fprintf( stderr, "\n" );
fprintf( stderr, " ex) %s test pass test1 authkey /user/service/cert/test123.cert 3600", prg );
fprintf( stderr, "\n" );
fprintf( stderr, "\n" );
fprintf( stderr, " %s is Solbox Cloud Storage auth token tool.\n", prg );
fprintf( stderr, "\n" );
fprintf( stderr, "[Note] This program doesn't check for the input argument.\n");
fprintf( stderr, "\n" );
return;
}
int main(int argc, char * argv[])
{
if( argc != 7 ) {
PrintUsage(argv[0]);
return 1;
}
///////////////////////// SSDK ////////////////////////////////////////////////////////////////////
// !!! 중요 !!!
// SSDK 가 End User에게 배포가되면 안됩니다.
// 그 이유는 보안상 취약점이 발생 하기때문입니다.
// 해당 소스는 샘플용일 뿐이며, SSDK는 인증서버를 마련하여 해당 서버에서
// 생성해 전달 될 수 있도록 제작되어야 합니다.
char *__auth_string = NULL;
time_t expire = time(0)+atoll(argv[6]);
/* SSDK : get auth string */
__auth_string = (char *)sh_get_auth_string(argv[1], argv[2], argv[3], argv[4], argv[5], expire);
if (!__auth_string) {
fprintf(stderr, "Cannot get the auth string.\n");
return 1;
}
tm * ptm = localtime(&expire);
char buffer[64] = {0};
strftime(buffer, 64, "%F %T", ptm);
fprintf(stdout, "\n");
fprintf(stdout, "* auth token : \n");
fprintf(stdout, "%s\n\n",__auth_string);
fprintf(stdout, "* expire date : \n");
fprintf(stdout, "%s \n",buffer);
fprintf(stdout, "\n");
if(__auth_string)
sh_mem_free(__auth_string);
///////////////////////// SSDK ////////////////////////////////////////////////////////////////////
return 0;
}
@@ -0,0 +1,194 @@
#define INDEV stdin
#define OUTDEV stdout
#define DEFAULT_BUF_SIZE 1024
#define RESERVED 5
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "SHSSDK.h"
#include "SHCSDK.h"
// 아래는 개통정보 전달시 전달된 내용입니다.
// 단, cert 파일은 샘플소스와 함께 전달됩니다.
#define ID "wjthinkbig"
#define PWD "wjthinkbig1@"
#define FILE_PATH "./wjthinkbig295.cert"
#define AUTHSTR "wjthinkbig"
#define SERVICE "wjthinkbig"
/* Callback Funtion */
int CallbackProc(void *param, long long int result)
{
// progress
printf("File Transfer : %lld\n", result);
// 1 : Stop
// 0 : Continue
return 1;
}
int main(void)
{
char service[DEFAULT_BUF_SIZE + RESERVED];
char path[DEFAULT_BUF_SIZE + RESERVED];
char service_host[DEFAULT_BUF_SIZE + RESERVED];
char auth_string[DEFAULT_BUF_SIZE + RESERVED];
char *auth_key, *auth_file;
char *__service_host = NULL;
char *__auth_string = NULL;
HSHSDK hsdk;
HSHFILELIST hsdf;
int i;
PSHFILE_STRUCT pshf;
strcpy(service, SERVICE);
if (service && !strcmp(service, SERVICE)) {
auth_key = AUTHSTR;
auth_file = FILE_PATH;
} else {
fprintf(OUTDEV, "There isn't the service ID\n");
return -1;
}
///////////////////////// SSDK ////////////////////////////////////////////////////////////////////
// !!! 중요 !!!
// SSDK 가 End User에게 배포가되면 안됩니다.
// 그 이유는 보안상 취약점이 발생 하기때문입니다.
// 해당 소스는 샘플용일 뿐이며, SSDK는 인증서버를 마련하여 해당 서버에서
// 생성해 전달 될 수 있도록 제작되어야 합니다.
/* SSDK : get service host */
__service_host = (char *)sh_get_service_host(ID, PWD, service);
if (!__service_host) {
fprintf(OUTDEV, "Cannot get the service host.\n");
goto ERR_EXIT;
}
/* SSDK : get auth string */
__auth_string = (char *)sh_get_auth_string(ID, PWD, service, auth_key, auth_file, time(0)+100000);
if (!__auth_string) {
fprintf(OUTDEV, "Cannot get the auth string.\n");
goto ERR_EXIT;
}
///////////////////////// SSDK ////////////////////////////////////////////////////////////////////
sprintf(service_host, "%s", __service_host);
sprintf(auth_string, "%s", __auth_string);
/* CSDK : init */
fprintf(stderr, "service_host!!! %s\n", service_host);
hsdk = sh_init(service_host, auth_string, CallbackProc, NULL);
if (hsdk == NULL) {
fprintf(OUTDEV, "Failed to initiate the SDK.\n");
goto ERR_EXIT;
}
path[0] = '\0';
/* TODO : listing base uri copy to path */
strcpy(path, "/");
/* CSDK : get list */
hsdf = sh_get_filelist(hsdk, path, 1);
if (hsdf == NULL) {
fprintf(OUTDEV, "Failed to retrieve the file list.\n");
goto ERR_EXIT;
}
for (i = 0; i< sh_get_filelist_count(hsdk, hsdf); i++) {
pshf = sh_get_file(hsdk, hsdf, i);
if (pshf->attr == SHFILEATTR_FOLDER) {
fprintf(OUTDEV, "Folder Name : %s\n", pshf->path);
} else {
fprintf(OUTDEV, "file Name : %s(%lld byte)\n",
pshf->path, pshf->size);
}
}
sh_free_filelist(hsdk, hsdf);
/* Upload Test */
if (!sh_upload(hsdk, "./test.txt", "/test.txt", SHWRITEPOLICY_OVERWRITE, -1, NULL))
{
printf("sh_upload ERROR 1: %d, %s\n", sh_get_error_number(hsdk), sh_get_error_message(hsdk));
goto ERR_EXIT;
} else {
printf("sh_upload SUCCESS\n");
}
/* Dowload Test */
if (!sh_download(hsdk, "/test.txt", "./test.txt", SHWRITEPOLICY_OVERWRITE, -1, NULL))
{
printf("sh_download ERROR : %d, %s\n", sh_get_error_number(hsdk), sh_get_error_message(hsdk));
goto ERR_EXIT;
} else {
printf("sh_download SUCCESS\n");
}
/* CSDK : get list */
hsdf = sh_get_filelist(hsdk, path, 1);
if (hsdf == NULL) {
fprintf(OUTDEV, "Failed to retrieve the file list.\n");
goto ERR_EXIT;
}
for (i = 0; i< sh_get_filelist_count(hsdk, hsdf); i++) {
pshf = sh_get_file(hsdk, hsdf, i);
if (pshf->attr == SHFILEATTR_FOLDER) {
fprintf(OUTDEV, "Folder Name : %s\n", pshf->path);
} else {
fprintf(OUTDEV, "file Name : %s(%lld byte)\n",
pshf->path, pshf->size);
}
}
sh_free_filelist(hsdk, hsdf);
/* File delete test */
if (sh_delete(hsdk, "/test.txt") == 0)
{
printf("sh_delete ERROR : %d, %s\n", sh_get_error_number(hsdk), sh_get_error_message(hsdk));
goto ERR_EXIT;
}
else
{
printf("sh_delete SUCCESS\n");
}
/* CSDK : get list */
hsdf = sh_get_filelist(hsdk, path, 1);
if (hsdf == NULL) {
fprintf(OUTDEV, "Failed to retrieve the file list.\n");
goto ERR_EXIT;
}
for (i = 0; i< sh_get_filelist_count(hsdk, hsdf); i++) {
pshf = sh_get_file(hsdk, hsdf, i);
if (pshf->attr == SHFILEATTR_FOLDER) {
fprintf(OUTDEV, "Folder Name : %s\n", pshf->path);
} else {
fprintf(OUTDEV, "file Name : %s(%lld byte)\n",
pshf->path, pshf->size);
}
}
sh_free_filelist(hsdk, hsdf);
sh_free(hsdk);
ERR_EXIT:
if(__service_host)
sh_mem_free(__service_host);
if(__auth_string)
sh_mem_free(__auth_string);
return 0;
}
@@ -0,0 +1,210 @@
#define INDEV stdin
#define OUTDEV stdout
#define DEFAULT_BUF_SIZE 1024
#define RESERVED 5
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "SHCSDK.h"
/* Callback Funtion */
int CallbackProc(void *param, long long int result)
{
// progress
printf("File Transfer : %lld\n", result);
// 1 : Stop
// 0 : Continue
return 1;
}
static int __totalsend = 0;
ssize_t Upload_Func(void *userval, char *buf, size_t len)
{
int nbyte =*((int *)userval);
// Check buffer (MUST BE)
if(buf == 0x00)
return 0;
// Check the capacity of transmission (MUST BE)
if(__totalsend >= nbyte)
return 0; //
int nsend = 0;
char data[11] = "1234567890";
// copy data
nsend = strlen(data);
if ( nsend > (int)len )
{
nsend = len;
}
if( nbyte - __totalsend < nsend )
{
nsend = nbyte - __totalsend;
}
strncpy(buf, data, nsend);
__totalsend += nsend;
printf("uploading : %d\n", __totalsend);
// Return capacity of transmission
return nsend;
}
int main(void)
{
// Service Information : Again provided
char *__service_host = "http://nctest.ktsh.co.kr/dav";
char *__auth_string = "bmN0ZXN0QG5jdGVzdDpJci0ocTJeCl8XQ+7BR5mjQu+lIZB/YryG0skrskPC+NmftbbpDiB4C+iTuEErTRQQ+I3oOv5yDDg=";
char path[DEFAULT_BUF_SIZE + RESERVED];
char service_host[DEFAULT_BUF_SIZE + RESERVED];
char auth_string[DEFAULT_BUF_SIZE + RESERVED];
HSHSDK hsdk = NULL;
int nBytes = 0;
sprintf(service_host, "%s", __service_host);
sprintf(auth_string, "%s", __auth_string);
/* CSDK : init */
fprintf(stderr, "service_host!!! %s\n", service_host);
hsdk = sh_init(service_host, auth_string, CallbackProc, NULL);
if (hsdk == NULL) {
fprintf(OUTDEV, "Failed to initiate the SDK.\n");
goto ERR_EXIT;
}
path[0] = '\0';
/* TODO : listing base uri copy to path */
strcpy(path, "/test");
/* CSDK : Creating a directory */
if (sh_make_directory(hsdk, path) == 0)
{
if (sh_get_error_number(hsdk) != SHCERRNO_ALREADYEXIST )
{
printf("sh_make_directory ERROR : %d, %s\n", sh_get_error_number(hsdk), sh_get_error_message(hsdk));
goto ERR_EXIT;
}
else
{
printf("sh_make_directory always EXIST\n");
}
}
else
{
printf("sh_make_directory SUCCESS\n");
}
/* CSDK : Upload Test */
/* sh_upload_buffer_r Test : Add at the end of the file */
nBytes = 1024;
for(int n = 0; n < 3; ++n)
{
__totalsend = 0;
if (!sh_upload_buffer_r(hsdk, "/test.txt", SHWRITEPOLICY_APPEND, Upload_Func, -1, nBytes, &nBytes))
{
printf("upload_buffer_r : %d, %s\n", sh_get_error_number(hsdk), sh_get_error_message(hsdk));
goto ERR_EXIT;
}
else
{
printf("upload_buffer_r SUCCESS\n");
}
}
/* sh_upload_buffer_r Test : Replace the middle part of the file */
__totalsend = 0;
if (!sh_upload_buffer_r(hsdk, "/test.txt", SHWRITEPOLICY_APPEND, Upload_Func, 10, nBytes, &nBytes))
{
printf("upload_buffer_r : %d, %s\n", sh_get_error_number(hsdk), sh_get_error_message(hsdk));
goto ERR_EXIT;
}
else
{
printf("upload_buffer_r SUCCESS\n");
}
/* CSDK : delete Test */
/* File delete test */
if (sh_delete(hsdk, "/test.txt") == 0)
{
printf("sh_delete ERROR : %d, %s\n", sh_get_error_number(hsdk), sh_get_error_message(hsdk));
goto ERR_EXIT;
}
else
{
printf("sh_delete SUCCESS\n");
}
/* Directory delete test */
if (sh_delete(hsdk, "/test") == 0)
{
printf("sh_delete ERROR : %d, %s\n", sh_get_error_number(hsdk), sh_get_error_message(hsdk));
goto ERR_EXIT;
}
else
{
printf("sh_delete SUCCESS\n");
}
// sh_open : Create the parent directory of the file
strcpy(path, "/SVC1_TEST/test_send.txt");
if(!sh_open(hsdk, path) )
{
printf("sh_open ERROR : %d, %s\n", sh_get_error_number(hsdk), sh_get_error_message(hsdk));
goto ERR_EXIT;
}
else
{
printf("sh_open SUCCESS.\n");
nBytes = 1024;
for(int u = 0; u < 3; ++u)
{
__totalsend = 0;
// sh_send_append : Add data to the end of the file.
if(!sh_send_append(hsdk, path, Upload_Func, nBytes, &nBytes))
{
printf("sh_send_append ERROR : %d, %s\n", sh_get_error_number(hsdk), sh_get_error_message(hsdk));
goto ERR_EXIT;
}
else
{
printf("sh_send_append SUCCESS.\n");
}
}
// sh_send_block : Changes in the contents of the specified location.
nBytes = 10;
__totalsend = 0;
if( !sh_send_block(hsdk,path, Upload_Func, 3, nBytes, &nBytes) )
{
printf("sh_send_block ERROR : %d, %s\n", sh_get_error_number(hsdk), sh_get_error_message(hsdk));
goto ERR_EXIT;
}
else
{
printf("sh_send_block SUCCESS.\n");
}
}
ERR_EXIT:
if(hsdk) sh_free(hsdk);
return 0;
}
@@ -0,0 +1,39 @@
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "SHSSDK.h"
// 아래는 개통정보 전달시 전달된 내용입니다.
#define ID "nctest"
#define PWD "nctest123"
#define SERVICE "nctest"
int main(void)
{
///////////////////////// SSDK ////////////////////////////////////////////////////////////////////
// !!! 중요 !!!
// SSDK 가 End User에게 배포가되면 안됩니다.
// 그 이유는 보안상 취약점이 발생 하기때문입니다.
// 해당 소스는 샘플용일 뿐이며, SSDK는 인증서버를 마련하여 해당 서버에서
// 생성해 전달 될 수 있도록 제작되어야 합니다.
/* SSDK : get service space (Bytes) */
long long t = 0, f = 0;
if (sh_get_service_info(ID, PWD, SERVICE, &t, &f))
{
printf("Service [%s] => Total space : %lld, Free space %lld\n", SERVICE, t, f);
}
else
{
char errmsg[254] = {0};
sh_get_error_msg(sh_get_lasterror(), errmsg);
printf("sh_get_service_info ERROR : %d, %s\n", sh_get_lasterror(), errmsg);
}
///////////////////////// SSDK ////////////////////////////////////////////////////////////////////
return 0;
}
@@ -0,0 +1,49 @@
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.
test file.