mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
A Small tool help upload codes
This commit is contained in:
parent
435776b825
commit
cd23deebe3
83
.SmallCode/GitHubURLHelper.cpp
Normal file
83
.SmallCode/GitHubURLHelper.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
#include <windows.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
char clipbuffer[1024];
|
||||
char uname[1024];
|
||||
char cmessage[1024];
|
||||
char fname[1024];
|
||||
int tid;
|
||||
void GetClipData()
|
||||
{
|
||||
OpenClipboard(NULL);
|
||||
HANDLE hClipboardData=GetClipboardData(CF_TEXT);
|
||||
char* pchData=(char*)GlobalLock(hClipboardData);
|
||||
strcpy(clipbuffer,pchData);
|
||||
GlobalUnlock(hClipboardData);
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
void SplitData()
|
||||
{
|
||||
char* p=strstr(clipbuffer,"://")+3;
|
||||
p=strstr(p,"/");
|
||||
char* q=strstr(p+1,"/");
|
||||
strncpy(uname,p+1,q-p-1);
|
||||
sprintf(cmessage,"From %s",clipbuffer);
|
||||
}
|
||||
|
||||
void GetFileNum()
|
||||
{
|
||||
printf("Please input Problem ID:\n");
|
||||
scanf("%d%*c",&tid);
|
||||
sprintf(fname,"%d_%s.cpp",tid,uname);
|
||||
}
|
||||
|
||||
void SetClip(const char* inc)
|
||||
{
|
||||
OpenClipboard(NULL);
|
||||
EmptyClipboard();
|
||||
HGLOBAL hClipboardData;
|
||||
hClipboardData=GlobalAlloc(GMEM_DDESHARE,strlen(inc)+1);
|
||||
char* pchData;
|
||||
pchData=(char*)GlobalLock(hClipboardData);
|
||||
strcpy(pchData,inc);
|
||||
GlobalUnlock(hClipboardData);
|
||||
SetClipboardData(CF_TEXT,hClipboardData);
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
void PrintFileName()
|
||||
{
|
||||
SetClip(fname);
|
||||
printf("File Name Set.\n");
|
||||
}
|
||||
void PrintCommentMessage()
|
||||
{
|
||||
SetClip(cmessage);
|
||||
printf("Comment Message Set.\n");
|
||||
}
|
||||
void ShowClip()
|
||||
{
|
||||
printf("Data In Clipboard...\n");
|
||||
printf("%s\n",clipbuffer);
|
||||
}
|
||||
void GPause()
|
||||
{
|
||||
getchar();
|
||||
}
|
||||
int main()
|
||||
{
|
||||
printf("Link Start!\n");
|
||||
GetClipData();
|
||||
ShowClip();
|
||||
SplitData();
|
||||
GetFileNum();
|
||||
PrintFileName();
|
||||
GPause();
|
||||
PrintCommentMessage();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user