Browse Source

Add FreeHGBD, remove GetURLStr

master v1.1
Alec Murphy 4 years ago
parent
commit
5ce127c5c1
2 changed files with 24 additions and 49 deletions
  1. +24
    -24
      HGBD.HC
  2. +0
    -25
      hgbdd

+ 24
- 24
HGBD.HC View File

@ -4,7 +4,6 @@
#define HGC_SCREENSHOT 0x03
#define HGC_DIRH 0x04
#define HGC_GETURL 0x05
#define HGC_GETURLSTR 0x06
#define HGC_DELH 0x07
#define HGC_CDH 0x08
#define HGC_DIRCURH 0x09
@ -30,15 +29,19 @@ BlkDevAdd(HGBD_DEV,0,1,1);
HGBD = Let2Drv(HGBD_DEV->first_drv_let);
U0 HGExec(I64 cmd)
U0 FreeHGBD()
{
 while (HGBD_OP>0) { Sleep(1+(RandU16/8192)); };
HGBD_OP=0;
}
U0 HGExec(I64 cmd, Bool chain=FALSE)
{
while (HGBD_OP>0 && !chain) { Sleep(1+(RandU16/8192)); };
HGBD_OP=cmd;
OutU8(HGC_PORT,HGC_NOOP);
while (InU8(HGC_PORT)!=HGC_NOOP) { Sleep(0); };
OutU8(HGC_PORT,cmd);
while (InU8(HGC_PORT)!=cmd) { Sleep(0); };
HGBD_OP=0;
}
U0 ReadParamBuf() { DskCacheInvalidate(HGBD); BlkRead(HGBD,HGBD_PARAM_BUF,0,1); }
@ -67,6 +70,7 @@ I64 CdH(U8 *pathname)
ReadParamBuf;
result = Str2I64(HGBD_PARAM_BUF);
if (result==0) { Print("%s ", pathname); PrintErr("Path not found.\n"); };
FreeHGBD;
return result;
}
@ -79,7 +83,7 @@ I64 CopyG(U8 *filename)
HGExec(HGC_COPYG);
ReadParamBuf;
size = Str2I64(HGBD_PARAM_BUF);
if (size==-1) { return 0; };
if (size==-1) { FreeHGBD; return 0; };
Print("Copying %s to Guest\n",filename);
BlkRead(HGBD,HGFS_BUF,1,(size/BLK_SIZE)+1);
if (StrCmp(filename+StrLen(filename)-2,".Z")==0) {
@ -91,6 +95,7 @@ I64 CopyG(U8 *filename)
} else {
FileWrite(filename, HGFS_BUF, size);
};
FreeHGBD;
return 1;
}
@ -98,7 +103,7 @@ I64 CopyH(U8 *filename)
{
I64 size;
CDirEntry *de = FilesFind(filename);
if (de==NULL) { return 0; };
if (de==NULL) { FreeHGBD; return 0; };
Print("Copying %s to Host\n",de->full_name);
U8 *file = FileRead(de->full_name, &size);
ZeroParamBuf;
@ -109,6 +114,7 @@ I64 CopyH(U8 *filename)
HGExec(HGC_COPYH);
Free(file);
DirEntryDel(de);
FreeHGBD;
return 1;
}
@ -122,6 +128,7 @@ I64 DelH(U8 *filename)
ReadParamBuf;
result = Str2I64(HGBD_PARAM_BUF);
if (result==1) { Print("DelH %s\n", filename); };
FreeHGBD;
return result;
}
@ -136,6 +143,7 @@ I64 DirH() {
BlkRead(HGBD,HGFS_BUF,1,(size/BLK_SIZE)+1);
MemSetU8(ToI64(HGFS_BUF)+size, 0x0, 1);
Print(HGFS_BUF);
FreeHGBD;
return entries;
}
@ -155,10 +163,13 @@ I64 CopyFindH(U8 *files)
U8 *DirCurH()
{
U8 StrDCH[1024];
ZeroParamBuf;
HGExec(HGC_DIRCURH);
ReadParamBuf;
return HGBD_PARAM_BUF;
StrCpy(StrDCH,HGBD_PARAM_BUF);
FreeHGBD;
return StrDCH;
}
U0 ScrShot()
@ -166,7 +177,7 @@ U0 ScrShot()
I64 size;
BMPScrnCapture(SCREENSHOT_FILE);
CDirEntry *de = FilesFind(SCREENSHOT_FILE);
if (de==NULL) { return; };
if (de==NULL) { FreeHGBD; return; };
U8 *file = FileRead(de->full_name, &size);
ZeroParamBuf;
MemCpy(HGBD_PARAM_BUF,&size,8);
@ -177,6 +188,7 @@ U0 ScrShot()
OutU8(0x03F8, 0x99);
Free(file);
DirEntryDel(de);
FreeHGBD;
}
U0 GetURL(U8 *url)
@ -195,7 +207,7 @@ U0 GetURL(U8 *url)
HGExec(HGC_GETURL);
ReadParamBuf;
size = Str2I64(HGBD_PARAM_BUF);
if (size==-1) { PrintErr("Bad URL.\n"); return; };
if (size==-1) { PrintErr("Bad URL.\n"); FreeHGBD; return; };
BlkRead(HGBD,HGFS_BUF,1,(size/BLK_SIZE)+1);
if (StrCmp(localfile+StrLen(localfile)-2,".Z")==0) {
U8 uzlocalfile[28];
@ -206,21 +218,7 @@ U0 GetURL(U8 *url)
} else {
FileWrite(localfile, HGFS_BUF, size);
};
}
U8 *GetURLStr(U8 *url)
{
I64 size;
ZeroParamBuf;
StrCpy(HGBD_PARAM_BUF,url);
WriteParamBuf;
HGExec(HGC_GETURLSTR);
ReadParamBuf;
size = Str2I64(HGBD_PARAM_BUF);
if (size==-1) { PrintErr("Bad URL.\n"); return ""; };
BlkRead(HGBD,HGFS_BUF,1,(size/BLK_SIZE)+1);
MemSetU8(ToI64(HGFS_BUF)+size, 0x0, 1);
return HGFS_BUF;
FreeHGBD;
}
U0 HCopy()
@ -234,6 +232,7 @@ U0 HCopy()
BlkWrite(HGBD,clip,1,(size/BLK_SIZE)+1);
HGExec(HGC_HCOPY);
Free(clip);
FreeHGBD;
}
U0 HPaste()
@ -246,6 +245,7 @@ U0 HPaste()
BlkRead(HGBD,HGFS_BUF,1,(size/BLK_SIZE)+1);
MemSetU8(ToI64(HGFS_BUF)+size, 0x0, 1);
Print(HGFS_BUF);
FreeHGBD;
}
U0 HGBDInit()


+ 0
- 25
hgbdd View File

@ -30,8 +30,6 @@ def builtin(data):
HGCDirH()
if data == HGC_GETURL:
HGCGetURL()
if data == HGC_GETURLSTR:
HGCGetURLStr()
if data == HGC_HCOPY:
HGCHCopy()
if data == HGC_HPASTE:
@ -220,29 +218,6 @@ def HGCGetURL():
logger.error("error reading url " + url)
conn.send(chr(HGC_GETURL))
def HGCGetURLStr():
os.lseek(HGBD,0,os.SEEK_SET)
HGBD_PARAM_BUF = os.read(HGBD,BLK_SIZE)
url_comp = urlparse.urlparse(HGBD_PARAM_BUF[:HGBD_PARAM_BUF.find('\x00')])
url = url_comp.scheme + "://" + url_comp.netloc + urllib.quote(url_comp.path)
filedata = subprocess.Popen('wget -q -O - -U "" "' + url + '" 2>/dev/null', shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]
filedata = filedata.replace('$','$$')
filesize = len(filedata)
if filesize>0:
ZeroParamBuf()
os.lseek(HGBD,0,os.SEEK_SET)
os.write(HGBD,str(filesize))
os.lseek(HGBD,BLK_SIZE,os.SEEK_SET)
os.write(HGBD,filedata)
logger.info("CUrl " + url)
else:
filesize = -1
ZeroParamBuf()
os.lseek(HGBD,0,os.SEEK_SET)
os.write(HGBD,str(filesize))
logger.error("error reading url " + url)
conn.send(chr(HGC_GETURLSTR))
def HGCHCopy():
os.lseek(HGBD,0,os.SEEK_SET)
HGBD_PARAM_BUF = os.read(HGBD,BLK_SIZE)


Loading…
Cancel
Save