From 864e244635768ed24f2bcdb0a3a50681c18e3603 Mon Sep 17 00:00:00 2001 From: emarti Date: Wed, 24 Apr 2024 20:46:28 +0300 Subject: [PATCH] Add files via upload --- Install.e | 237 ++++++++++++++++++ amiget.e | 637 +++++++++++++++++++++++++++++++++++++++++++++++++ amiget.info | Bin 0 -> 5484 bytes amisearch.c | 389 ++++++++++++++++++++++++++++++ amisearch.info | Bin 0 -> 5493 bytes copy2c.e | 23 ++ copy2c.m | Bin 0 -> 290 bytes install.info | Bin 0 -> 1760 bytes 8 files changed, 1286 insertions(+) create mode 100644 Install.e create mode 100644 amiget.e create mode 100644 amiget.info create mode 100644 amisearch.c create mode 100644 amisearch.info create mode 100644 copy2c.e create mode 100644 copy2c.m create mode 100644 install.info diff --git a/Install.e b/Install.e new file mode 100644 index 0000000..ec03fa1 --- /dev/null +++ b/Install.e @@ -0,0 +1,237 @@ +OPT OSVERSION=37 +OPT PREPROCESS + +MODULE 'window','classes/window', + 'gadgets/layout','layout', + 'libraries/gadtools','gadtools', + 'icon', + 'button','gadgets/button', + 'space', + 'label','images/label', + 'bitmap','images/bitmap', + 'images/bevel', + 'amigalib/boopsi', + 'intuition/intuition', + 'intuition/imageclass', + 'intuition/screens', + 'intuition/gadgetclass', + '*copy2c', + 'reaction/reaction_macros', + 'reaction/reaction_lib' + +#define VERSION 'Amiget Installer v1.0 (29.03.2024)' + +->InstallWindow gadgets +ENUM LAYOUT_5, SPACE_6, LAYOUT_8, SPACE_9, BITMAP_11, BITMAP_12, BITMAP_13, + SPACE_14, LAYOUT_22, SPACE_26, LABEL_23, SPACE_24, LABEL_25, + SPACE_27, LAYOUT_33, BUTTON_34, LAYOUT_35, LABEL_21 + +DEF gScreen=0,gVisInfo=0,gDrawInfo=0,gAppPort=0 + +DEF mainGadgets[19]:ARRAY OF LONG + +PROC setup() + IF (windowbase:=OpenLibrary('window.class',0))=NIL THEN Throw("LIB","win") + IF (layoutbase:=OpenLibrary('gadgets/layout.gadget',0))=NIL THEN Throw("LIB","layo") + IF (gadtoolsbase:=OpenLibrary('gadtools.library',0))=NIL THEN Throw("LIB","gadt") + IF (iconbase:=OpenLibrary('icon.library',0))=NIL THEN Throw("LIB","icon") + IF (buttonbase:=OpenLibrary('gadgets/button.gadget',0))=NIL THEN Throw("LIB","btn") + IF (spacebase:=OpenLibrary('gadgets/space.gadget',0))=NIL THEN Throw("LIB","spce") + IF (labelbase:=OpenLibrary('images/label.image',0))=NIL THEN Throw("LIB","labl") + IF (bitmapbase:=OpenLibrary('images/bitmap.image',0))=NIL THEN Throw("LIB","bmap") + IF (gScreen:=LockPubScreen(NIL))=NIL THEN Raise("pub") + IF (gVisInfo:=GetVisualInfoA(gScreen, [TAG_END]))=NIL THEN Raise("visi") + IF (gDrawInfo:=GetScreenDrawInfo(gScreen))=NIL THEN Raise("dinf") + IF (gAppPort:=CreateMsgPort())=NIL THEN Raise("port") +ENDPROC + +PROC cleanup() + IF gVisInfo THEN FreeVisualInfo(gVisInfo) + IF gDrawInfo THEN FreeScreenDrawInfo(gScreen,gDrawInfo) + IF gAppPort THEN DeleteMsgPort(gAppPort) + IF gScreen THEN UnlockPubScreen(NIL,gScreen) + + IF gadtoolsbase THEN CloseLibrary(gadtoolsbase) + IF iconbase THEN CloseLibrary(iconbase) + IF windowbase THEN CloseLibrary(windowbase) + IF layoutbase THEN CloseLibrary(layoutbase) + IF buttonbase THEN CloseLibrary(buttonbase) + IF spacebase THEN CloseLibrary(spacebase) + IF labelbase THEN CloseLibrary(labelbase) + IF bitmapbase THEN CloseLibrary(bitmapbase) +ENDPROC + +PROC runWindow(windowObject:PTR TO LONG) HANDLE + DEF running=TRUE + DEF win:PTR TO window,wsig,code,msg,sig,result + + IF (win:=RA_OpenWindow(windowObject)) + GetAttr( WINDOW_SIGMASK, windowObject, {wsig} ) + + + WHILE running + sig:=Wait(wsig) + IF (sig AND (wsig)) + WHILE ((result:=RA_HandleInput(windowObject,{code}+2)) <> WMHI_LASTMSG) + msg:=(result AND WMHI_CLASSMASK) + SELECT msg + CASE WMHI_CLOSEWINDOW + running:=FALSE + CASE WMHI_GADGETUP + copyToC() + SetGadgetAttrsA(mainGadgets[BUTTON_34], win, NIL,[GA_TEXT, 'Installation successful!', BUTTON_TEXTPEN, 2, BUTTON_BACKGROUNDPEN, 0, GA_READONLY, TRUE, BUTTON_BEVELSTYLE, BVS_NONE, TAG_DONE]) + ENDSELECT + ENDWHILE + ENDIF + ENDWHILE + ENDIF +EXCEPT DO + RA_CloseWindow(windowObject) +ENDPROC + +PROC installwindow() HANDLE + DEF windowObject + + windowObject:=WindowObject, + WA_TITLE, 'Amiget Installer', + WA_SCREENTITLE, 'Amiget Installer', + WA_LEFT, 5, + WA_TOP, 20, + WA_WIDTH, 320, + WA_HEIGHT, 240, + WA_MINWIDTH, 150, + WA_MINHEIGHT, 80, + WA_MAXWIDTH, 8192, + WA_MAXHEIGHT, 8192, + WINDOW_LOCKWIDTH, TRUE, + WINDOW_LOCKHEIGHT, TRUE, + WINDOW_APPPORT, gAppPort, + WA_CLOSEGADGET, TRUE, + WA_DEPTHGADGET, TRUE, + WA_DRAGBAR, TRUE, + WA_ACTIVATE, TRUE, + WINDOW_POSITION, WPOS_CENTERWINDOW, + WINDOW_ICONTITLE, 'Amiget Installer', + WA_SMARTREFRESH, TRUE, + WA_IDCMP, IDCMP_GADGETDOWN OR IDCMP_GADGETUP OR IDCMP_CLOSEWINDOW, + WINDOW_PARENTGROUP, VLayoutObject, + LAYOUT_SPACEOUTER, TRUE, + LAYOUT_DEFERLAYOUT, TRUE, + LAYOUT_ADDCHILD, mainGadgets[LAYOUT_5]:=LayoutObject, + GA_ID, LAYOUT_5, + LAYOUT_ORIENTATION, LAYOUT_ORIENT_VERT, + LAYOUT_LABELPLACE, BVJ_IN_CENTER, + LAYOUT_ADDCHILD, mainGadgets[SPACE_6]:=SpaceObject, + GA_ID, SPACE_6, + SpaceEnd, + LAYOUT_ADDCHILD, mainGadgets[LAYOUT_8]:=LayoutObject, + GA_ID, LAYOUT_8, + LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ, + LAYOUT_ADDCHILD, mainGadgets[SPACE_9]:=SpaceObject, + GA_ID, SPACE_9, + SpaceEnd, + LAYOUT_ADDIMAGE, mainGadgets[BITMAP_11]:=BitMapObject, + GA_ID, BITMAP_11, + IA_LEFT, 0, + IA_TOP, 0, + IA_WIDTH, 0, + IA_HEIGHT, 0, + BITMAP_SCREEN, gScreen, + BITMAP_SOURCEFILE, 'amiget.info', + BitMapEnd, + LAYOUT_ADDIMAGE, mainGadgets[BITMAP_12]:=BitMapObject, + GA_ID, BITMAP_12, + IA_LEFT, 0, + IA_TOP, 0, + IA_WIDTH, 0, + IA_HEIGHT, 0, + BITMAP_SCREEN, gScreen, + BITMAP_SOURCEFILE, 'Install.info', + BitMapEnd, + LAYOUT_ADDIMAGE, mainGadgets[BITMAP_13]:=BitMapObject, + GA_ID, BITMAP_13, + IA_LEFT, 0, + IA_TOP, 0, + IA_WIDTH, 0, + IA_HEIGHT, 0, + BITMAP_SCREEN, gScreen, + BITMAP_SOURCEFILE, 'System:C.info', + BitMapEnd, + LAYOUT_ADDCHILD, mainGadgets[SPACE_14]:=SpaceObject, + GA_ID, SPACE_14, + SpaceEnd, + LayoutEnd, + LAYOUT_ADDCHILD, mainGadgets[LAYOUT_22]:=LayoutObject, + GA_ID, LAYOUT_22, + LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ, + LAYOUT_HORIZALIGNMENT, LALIGN_RIGHT, + LAYOUT_ADDCHILD, mainGadgets[SPACE_26]:=SpaceObject, + GA_ID, SPACE_26, + SpaceEnd, + LAYOUT_ADDIMAGE, mainGadgets[LABEL_23]:=LabelObject, + GA_ID, LABEL_23, + LABEL_DRAWINFO, gDrawInfo, + LABEL_TEXT, 'Amiget', + LABEL_JUSTIFICATION, LJ_RIGHT, + LabelEnd, + LAYOUT_ADDCHILD, mainGadgets[SPACE_24]:=SpaceObject, + GA_ID, SPACE_24, + SpaceEnd, + LAYOUT_ADDIMAGE, mainGadgets[LABEL_25]:=LabelObject, + GA_ID, LABEL_25, + LABEL_DRAWINFO, gDrawInfo, + LABEL_TEXT, ' SYS:C', + LabelEnd, + LAYOUT_ADDCHILD, mainGadgets[SPACE_27]:=SpaceObject, + GA_ID, SPACE_27, + SpaceEnd, + LayoutEnd, + LAYOUT_ADDCHILD, mainGadgets[LAYOUT_33]:=LayoutObject, + GA_ID, LAYOUT_33, + LAYOUT_ORIENTATION, LAYOUT_ORIENT_VERT, + LAYOUT_LEFTSPACING, 16, + LAYOUT_RIGHTSPACING, 16, + LAYOUT_TOPSPACING, 8, + LAYOUT_BOTTOMSPACING, 8, + LAYOUT_ADDCHILD, mainGadgets[BUTTON_34]:=ButtonObject, + GA_ID, BUTTON_34, + GA_TEXT, 'Install', + GA_RELVERIFY, TRUE, + GA_TABCYCLE, TRUE, + BUTTON_TEXTPEN, 1, + BUTTON_BACKGROUNDPEN, 3, + BUTTON_FILLTEXTPEN, 1, + BUTTON_FILLPEN, 3, + ButtonEnd, + LayoutEnd, + LAYOUT_ADDCHILD, mainGadgets[LAYOUT_35]:=LayoutObject, + GA_ID, LAYOUT_35, + LAYOUT_ORIENTATION, LAYOUT_ORIENT_VERT, + LAYOUT_HORIZALIGNMENT, LALIGN_RIGHT, + LAYOUT_TOPSPACING, 8, + LAYOUT_ADDIMAGE, mainGadgets[LABEL_21]:=LabelObject, + GA_ID, LABEL_21, + LABEL_DRAWINFO, gDrawInfo, + LABEL_TEXT, 'Amiget V1.0 (29.03.2024)', + LABEL_JUSTIFICATION, LJ_CENTER, + LabelEnd, + LayoutEnd, + LayoutEnd, + LayoutEnd, + WindowEnd + mainGadgets[18]:=0 + + runWindow(windowObject) + +EXCEPT DO + IF windowObject THEN DisposeObject(windowObject); +ENDPROC + +PROC main() HANDLE + setup() + installwindow() +EXCEPT DO + cleanup() +ENDPROC + +CHAR '$VER: ',VERSION,0 diff --git a/amiget.e b/amiget.e new file mode 100644 index 0000000..b438d33 --- /dev/null +++ b/amiget.e @@ -0,0 +1,637 @@ +->-------------------------------------------<- +-> Amiget v1.0 (29/03/2024) +-> Coded by emarti, Murat Ozdemir +->-------------------------------------------<- + +OPT OSVERSION=37 +OPT PREPROCESS +OPT LARGE + +#define VERSION 'Amiget v1.0 (29.03.2024)' + +MODULE 'ftpaminet', + 'dos/dos', + 'dos', + 'playtone', + 'arguments', + 'fileexist', + 'makedir' + + +#define SEARCHFILENAME 'RAM:T/search.dat' +#define PROCESSING 'RAM:T/processing.dat' +#define CONFIGFILE 'SYS:Prefs/Env-Archive/amiget.cfg' +#define BUFFER $400 + +DEF amiftp:PTR TO transfer, + paramCount, + paramIndex, + paramStr[$200]:STRING, + aminetPath[$100]:STRING, + aminetFilename[$100]:STRING, + aminetFileReadme[$100]:STRING, + destinationDrawer[$100]:STRING, + searchwords[$100]:STRING, + choice[6]:STRING, + fp, + line[BUFFER/2]:STRING, + s: LONG, + cfg, + cfgDownloadDrawer[$200]:STRING, + cfgLine[$200]:STRING, + cfgTemp[$200]:STRING, + recordsperpage=25, + sort[2]:STRING, + ord[2]:STRING + +->-------------------------------------------<- +PROC main() + + amiftp:= NEW amiftp + amiftp.isreadme:=0 + amiftp.yes:=0 + amiftp.extract:=0 + amiftp.effect:=0 + + IF (cfg:=Open(CONFIGFILE, MODE_OLDFILE))=NIL + -> No config file found + StrCopy(cfgDownloadDrawer, 'RAM:') + ELSE + WHILE (Fgets(cfg, cfgLine, BUFFER/2)<>NIL) + IF cfgLine[0]<>"#" + IF InStr(cfgLine, 'RECORDS_PER_PAGE')<>-1 + MidStr(cfgTemp, cfgLine, 17) + recordsperpage := Val(cfgTemp) + + ELSEIF InStr(cfgLine, 'DOWNLOAD_DRAWER')<>-1 + MidStr(cfgTemp, cfgLine, 16) + StrCopy(cfgDownloadDrawer, cfgTemp) + cfgDownloadDrawer[StrLen(cfgDownloadDrawer)-1]:=$0 + IF NOT fileExist(cfgDownloadDrawer) + mkdir(cfgDownloadDrawer) + ENDIF + amiftp.localpath:= cfgDownloadDrawer + + ELSEIF InStr(cfgLine, 'AUTO_YES=Yes')<>-1 + amiftp.yes:=1 + + ELSEIF InStr(cfgLine, 'SOUND_EFFECT=Yes')<>-1 + amiftp.effect:=1 + ENDIF + ENDIF + + ENDWHILE + Close(cfg) + ENDIF + + initplay() + + StrCopy(paramStr, arg) + paramCount:=getargs(0, paramStr) -> total argument count + + SELECT paramCount + CASE -1 + help() + CASE 3 + paramCount:=getargs(2, aminetFilename) + paramCount:=getargs(3, aminetPath) + StrCopy(destinationDrawer, cfgDownloadDrawer, ALL) + CASE 4 + paramCount:=getargs(2, aminetFilename) + paramCount:=getargs(3, aminetPath) + paramCount:=getargs(4, destinationDrawer) + IF destinationDrawer[StrLen(destinationDrawer)-1]="/" THEN destinationDrawer[StrLen(destinationDrawer)-1]:=$0 + IF NOT fileExist(destinationDrawer) + mkdir(destinationDrawer) + ENDIF + DEFAULT + + ENDSELECT + + IF aminetPath[StrLen(aminetPath)-1]<>"/" THEN StrAdd(aminetPath, '/', ALL) ELSE aminetPath[StrLen(aminetPath)-1]:=$0 + + paramCount:=getargs(1, paramStr) + IF (paramStr[0]<>"-") -> always use/begins '-' char. + help() + ENDIF + + paramIndex:=1 + + SELECT paramStr[paramIndex] + + CASE "h" -> help + help() + CASE "v" -> version + version() + CleanUp(0) + CASE "c" -> creates default config file + createConfigFile() + CASE "s" -> search + -> amisearch is exists? + IF NOT ((fileExist('PROGDIR:amisearch'))OR(fileExist('SYS:C/amisearch'))) + WriteF('\e[1;31;40m\aamisearch\a not found.\e[0;31;40m Try reinstalling \aAmiget\a to fix the problem\n') + JUMP end2 + ENDIF + MidStr(searchwords, arg, 3, ALL) + StrCopy(searchwords, TrimStr(searchwords)) + IF StrLen(searchwords)<2 + WriteF('Insufficient length for search\n') + JUMP end2 + ENDIF + + -> sort and order + StrCopy(sort, 'n') + StrCopy(ord, 'a') + + REPEAT + -> sort by name + IF (paramStr[paramIndex]="n") THEN StrCopy(sort, 'n') + -> sort by path + IF (paramStr[paramIndex]="p") THEN StrCopy(sort, 'p') + -> sort by date + IF (paramStr[paramIndex]="d") THEN StrCopy(sort, 'd') + -> sort by size + IF (paramStr[paramIndex]="s") THEN StrCopy(sort, 's') + -> ascending order + IF (paramStr[paramIndex]="a") THEN StrCopy(ord, 'a') + -> descending order + IF (paramStr[paramIndex]="z") THEN StrCopy(ord, 'z') + paramIndex++ + UNTIL paramIndex > StrLen(paramStr) + + StringF(searchwords, 'amisearch \s\s \s', sort, ord, searchwords); + prerunamisearch: + DeleteFile(SEARCHFILENAME) + + sound(amiftp) + s:=SystemTagList(searchwords, NIL) + + IF s<1 THEN JUMP end + table: + IF (opendocument(SEARCHFILENAME, s)>0) + + sound(amiftp) + WriteF(' \e[1;31;40mPackage Name:\e[0;31;40m \s\n\n', aminetFilename) + whattodo: + WriteF(' \e[0;30;41m [D]ownload \e[0;31;40m') + IF ((InStr(aminetFilename, '.lha')>-1) OR (InStr(aminetFilename, '.zip')>-1) OR (InStr(aminetFilename, '.gz')>-1) ) THEN + WriteF(' \e[0;30;41m Download & [E]xtract \e[0;31;40m') + IF InStr(aminetFilename, '.adf') > -1 THEN + WriteF(' \e[0;30;41m Download & [M]ount \e[0;31;40m') + + WriteF(' \e[0;30;41m [R]eadme \e[0;31;40m \e[0;30;41m Return [L]ist \e[0;31;40m \e[0;30;41m [Q]uit \e[0;31;40m \e[1;31;40mEnter your choice ==>\e[0;31;40m ') + + ReadStr(stdout, choice) + StrCopy(choice, TrimStr(choice)) + LowerStr(choice) + + + IF (choice[0]="d") + StrCopy(destinationDrawer, cfgDownloadDrawer, ALL) + downloadpackage() + JUMP end2 + ELSEIF (choice[0]="e") OR (choice[0]="m") + StrCopy(destinationDrawer, cfgDownloadDrawer, ALL) + amiftp.extract:=1 + downloadpackage() + JUMP end2 + ELSEIF (choice[0]="r") + readpackage() + ELSEIF (choice[0]="l") + JUMP table + ELSEIF (choice[0]="q") + JUMP end + ELSE + WriteF('\c\c\b',8,8) + JUMP whattodo + ENDIF + + + ENDIF + end: + -> to delete message that includes 'amisearch failure return code -4' + fillChar($8, 1) + WriteF('\b') + fillChar($20, 128) + WriteF('\b') + end2: + + + CASE "r" -> readme + + REPEAT + -> sound effect + IF (paramStr[paramIndex]="e") THEN amiftp.effect:=1 + paramIndex++ + UNTIL paramIndex > StrLen(paramStr) + readpackage() + + CASE "d" -> download + REPEAT + -> yes + IF (paramStr[paramIndex]="y") THEN amiftp.yes:=1 + -> extract + IF (paramStr[paramIndex]="x") THEN amiftp.extract:=1 + -> mount adf + IF (paramStr[paramIndex]="m") THEN amiftp.extract:=1 + -> sound effect + IF (paramStr[paramIndex]="e") THEN amiftp.effect:=1 + paramIndex++ + UNTIL paramIndex > StrLen(paramStr) + downloadpackage() + CASE "S" -> reprocess the last search for packages + s:=0 + + IF (fp:= Open(SEARCHFILENAME, MODE_OLDFILE)) <> NIL + WHILE (Fgets(fp, line, BUFFER/2)<>NIL) + s++ + ENDWHILE + Close(fp) + + WriteF('\n\e[1;31;40m Last search results\n Found \d package(s)\e[0;31;40m\n\n',s) + JUMP table + ELSE + WriteF('\e[1;31;40mNo found\e[0;31;40m the last search for packages\n') + ENDIF + CASE "D" -> Downloads the processed package + + IF activePackage()=TRUE + downloadpackage() + ELSE + WriteF('No processed package\n') + ENDIF + CASE "L" -> Latest packages, last 30 days + StrCopy(searchwords, 'amisearch **recent**') + JUMP prerunamisearch + CASE "R" -> Displays readme file of the processed package + IF activePackage() + readpackage() + ELSE + WriteF('No processed package\n') + ENDIF + DEFAULT + help() + ENDSELECT + + -> Bye + freeplay() + + END amiftp + + IF (amiftp) + Dispose(amiftp) + amiftp:=NIL + ENDIF + + +ENDPROC + +->-------------------------------------------<- +PROC activePackage() + IF (cfg:=Open(PROCESSING, MODE_OLDFILE))<>NIL + + Fgets(cfg, aminetPath, BUFFER/2) + aminetPath[StrLen(aminetPath)-1]:=0 + Fgets(cfg, aminetFilename, BUFFER/2) + aminetFilename[StrLen(aminetFilename)-1]:=0 + StrCopy(destinationDrawer, cfgDownloadDrawer, ALL) + Close(cfg) + ELSE + RETURN FALSE + ENDIF +ENDPROC TRUE + +->-------------------------------------------<- +PROC readpackage() + amiftp.yes:=1 + amiftp.isreadme:=1 + + amiftp.remotepath := aminetPath + amiftp.filename:= aminetFilename + + processingSave() + amiftp.localpath:= 'RAM:T/' + StrCopy(aminetFileReadme, getfilenamewithoutext(aminetFilename)) + StrAdd(aminetFileReadme, '.readme') + amiftp.filename:= aminetFileReadme + + + freeplay() + download(amiftp) + initplay() + + StringF(aminetFileReadme, 'RAM:T/\s', aminetFileReadme) + opendocument(aminetFileReadme, 0) +ENDPROC + +->-------------------------------------------<- +PROC downloadpackage() + amiftp.remotepath := aminetPath + amiftp.filename:= aminetFilename + amiftp.localpath:= destinationDrawer + processingSave() + freeplay() + download(amiftp) + initplay() +ENDPROC + +->-------------------------------------------<- +PROC help() + version() + sound(amiftp) + WriteF( 'usage: amiget \n\nThe following options are available:\n'+ + '\t-s[] \n\t\tSearches for packages\n'+ + '\t\t\tSort:\n'+ + '\t\t\tn\tName (default)\n'+ + '\t\t\tp\tPath\n'+ + '\t\t\td\tDate\n'+ + '\t\t\ts\tSize\n\n'+ + '\t\t\tOrder:\n'+ + '\t\t\ta\tAscending (default)\n'+ + '\t\t\tz\tDescending\n\n' + + ) + WriteF( '\t-S\n\t\tReprocesses last search for packages\n'+ + '\t-D\n\t\tDownloads the processed package\n'+ + '\t\t\ta) After displays readme of package\n'+ + '\t\t\tb) To download the same package again\n'+ + '\t\t\tc) To resume to download the same package\n'+ + '\t-R\n\t\tDisplays readme of the processed package\n'+ + '\t-L\n\t\tLatest packages, last 30 days\n\n' + ) + + WriteF( '\t-r[] \n'+ + '\t\tDisplays readme of package\n\n'+ + '\t-d[] []\n'+ + '\t\tDownloads a package from aminet\n\n\t\tThe default destination drawer is "RAM:" or\n'+ + '\t\tcreates if not exist when entered\n\n\t\tsuboptions:\n' + ) + + WriteF( '\t\ty\t Automatic yes to prompts\n'+ + '\t\tx\t Extracts all files from package (for lha, tar.gz and zip only)\n'+ + '\t\tm\t Mounts ADF image (for OS3.2.X only)\n'+ + '\t\te\t Informs with sound effect\n\n'+ + '\t-h\tDisplays this help\n'+ + '\t-v\tDisplays version\n'+ + '\t-c\tCreates config file to set some variables\n\n' + ) + + WriteF( 'examples:\n'+ + '\tamiget -dxey DAControlGUI.lha disk/misc\n'+ + '\tamiget -de Concrete.lha demo/aga RAM:Demos\n'+ + '\tamiget -s demo party\n'+ + '\tamiget -sdz commodore\n'+ + '\tamiget -re GoAway.lha demo/tp92\n'+ + '\tamiget -R\n\n'+ + 'More help, email bug reports, questions, discussions to \e[3;31;40m\e[0;31;40m\n'+ + 'and/or open issue at \e[3;31;40mhttps://github.com/emartisoft/amiget\e[0;31;40m\n\n' + ) + + CleanUp(0) +ENDPROC + +->-------------------------------------------<- +PROC version() + DEF ver[150]:STRING, lenVer, n + StrCopy(ver, '\n\e[1;31;40m ') + StrAdd(ver, VERSION) + StrAdd(ver, '\n\e[1;33;40m Copyright © 2024 by emarti, Murat Ozdemir\n\e[0;31;40m All rights reserved, MIT License\n\n') + lenVer:=StrLen(ver) + + sound(amiftp) + FOR n:=0 TO lenVer + WriteF('\c',ver[n]) + IF ver[n]=" " THEN Delay(3) + ENDFOR + Delay(15) +ENDPROC + +->-------------------------------------------<- +PROC processingSave() + DEF pstr[$200]:STRING + StringF(pstr, '\s\n\s\n',amiftp.remotepath, amiftp.filename) + + IF (cfg:=Open(PROCESSING, MODE_NEWFILE))<>NIL + Write(cfg, pstr, $200) + Close(cfg) + ENDIF +ENDPROC + +->-------------------------------------------<- +PROC createConfigFile() + sound(amiftp) + IF NOT fileExist(CONFIGFILE) + IF (cfg:=Open(CONFIGFILE, MODE_NEWFILE))<>NIL + Write(cfg, {configstr}, 700) + Close(cfg) + WriteF('Config file created \e[1;31;40m[\s]\e[0;31;40m\n', CONFIGFILE) + ELSE + WriteF('Unable to create config file\n') + ENDIF + ELSE + WriteF('Config file already exists\n') + ENDIF + IF fileExist('SYS:Rexxc/RX') + Execute('rx "ADDRESS workbench WINDOW \aSYS:Prefs/Env-Archive\a OPEN"', NIL, NIL) + ENDIF +ENDPROC + +configstr: +CHAR '# ------------------------------------------------------------------',$0a, + '# Amiget Config File',$0a, + '# ------------------------------------------------------------------',$0a,$0a, + '# The maximum number of search results per page, 25 is default',$0a, + 'RECORDS_PER_PAGE=25',$0a,$0a, + '# The destination drawer to download package file, "RAM:" is default',$0a, + '# DOWNLOAD_DRAWER=DEMO:Game/Downloads',$0a, + 'DOWNLOAD_DRAWER=RAM:Packages',$0a,$0a, + '# Automatic yes to prompts after search to download package,',$0a,'# [Yes/No] "No" is default',$0a, + '# AUTO_YES=Yes',$0a, + 'AUTO_YES=No',$0a,$0a, + '# Inform with sound effect, [Yes/No] "No" is default',$0a, + '# WARNING: If SOUND_EFFECT value is "Yes", the system',$0a, + '# may crash while listening to music',$0a, + '# SOUND_EFFECT=Yes',$0a, + 'SOUND_EFFECT=No',$0a,$0a,$00 + +->-------------------------------------------<- +PROC opendocument(filepath:PTR TO CHAR, packageCount=0) +DEF done=TRUE, + readmefile, + readmefilename[$100]:STRING, + startline=0, + endline, + currentline, + pageCount, currentPage, + gopage, + selection = 0 + + endline := recordsperpage + readmefile := packageCount = 0 + + IF NOT readmefile + -> search.dat + StrCopy(filepath, SEARCHFILENAME) + ELSE + -> readmefile + -> totalline for readme file => packageCount + + packageCount:=0 + IF(fp:= Open(filepath, MODE_OLDFILE)) <> NIL + WHILE (Fgets(fp, line, BUFFER/2)<>NIL) + packageCount++ + ENDWHILE + Close(fp) + ENDIF + + + MidStr(readmefilename, aminetFileReadme, 6) + StrCopy(readmefilename, getfilenamewithoutext(readmefilename)) + + + ENDIF + + pageCount := packageCount / recordsperpage + IF Mod(packageCount,recordsperpage)>0 THEN pageCount++ + + IF(fp:= Open(filepath, MODE_OLDFILE)) <> NIL + + + fillChar($8, 16) + WriteF('\b') + fillChar($20, 200) + WriteF('\b') + + WHILE (done) + + currentline:=0 + + Seek(fp, 0, OFFSET_BEGINNING) + + + IF NOT readmefile + WriteF('\e[1;31;40m ID Name Path Size Date Description\e[0;31;40m\n'); + WriteF('\e[1;31;40m------ ------------------------------ ------------ ------ ---------- -----------\e[0;31;40m\n'); + ELSE + IF startline=0 THEN WriteF('\e[1;31;40m\s Readme File\e[0m\n', readmefilename) + + ENDIF + + + WHILE (Fgets(fp, line, BUFFER/2)<>NIL) + IF (currentline >= startline) AND (currentline < endline) THEN WriteF('\s', line) + currentline++ + ENDWHILE + + sound(amiftp) + currentPage:=(startline / recordsperpage)+1 + + WriteF('\n') + input: + + WriteF('\e[1;31;40m Page[\d/\d]\e[0m \e[0;30;41m [P]rev \e[0m \e[0;30;41m [N]ext \e[0m \e[0;30;41m [G]o to Page \e[0m \e[0;30;41m [Q]uit \e[0m ', currentPage, pageCount); + IF NOT readmefile THEN WriteF('\e[0;30;41m Type ID to select \e[0m'); + WriteF('\e[1;31;40m Enter your choice ==> \e[0m '); + + + ReadStr(stdout, choice) + StrCopy(choice, TrimStr(choice)) + LowerStr(choice) + + IF choice[0]=NIL + //WriteF('\b') + fillChar($8, 16) + WriteF('\b') + JUMP input + ENDIF + + IF (choice[0]="n") + IF (currentPage packageCount) THEN endline:=packageCount + ELSE + fillChar($8, 16) + WriteF('\b') + JUMP input + ENDIF + + ELSEIF (choice[0]="p") + startline -= recordsperpage + endline := startline + recordsperpage + IF (startline < 0) + startline:=0 + endline:=recordsperpage + + fillChar($8, 16) + WriteF('\b') + JUMP input + ENDIF + ELSEIF (choice[0]="g") + IF pageCount<>1 + WriteF('\n\e[1;31;40m Enter page number (1-\d) ==>\e[0m ', pageCount) + ReadStr(stdout, choice) + gopage:=Val(choice) + + IF ((gopage>0) AND (gopage<=pageCount)) + gopage-- + startline := recordsperpage * gopage + endline := startline + recordsperpage + + ENDIF + ELSE + fillChar($8, 16) + WriteF('\b') + JUMP input + ENDIF + + + ELSEIF (choice[0]="q") + selection:=-1 + done:=FALSE + + ELSE + selection:=Val(choice) + IF((selection>0) AND (selection<=packageCount)) AND (NOT readmefile) + -> after searching, defines aminetPath and aminetFilename from fp + Seek(fp, 0, OFFSET_BEGINNING) + currentline:=1 + WHILE (Fgets(fp, line, BUFFER/2)<>NIL) + IF (currentline = selection) + ->WriteF('\s\n', line) + MidStr(aminetFilename, line, 7, 30); StrCopy(aminetFilename, TrimStr(aminetFilename)) + MidStr(aminetPath, line, 38, 12); StrCopy(aminetPath, TrimStr(aminetPath)) + ->WriteF('*\s*\s*\n', aminetPath, aminetFilename) + ENDIF + currentline++ + ENDWHILE + done:=FALSE + ELSE + fillChar($8, 16) + WriteF('\b') + JUMP input + ENDIF + ENDIF + + WriteF('\b\c\b', $8) + fillChar($20, 200) + WriteF('\b\e[1;31;40m Page[\d/\d]\e[0m\n\n', currentPage, pageCount) + + + ENDWHILE + + Close(fp) + ENDIF + +ENDPROC selection + +->-------------------------------------------<- +PROC fillChar(c, length) + DEF i + FOR i:=0 TO length + WriteF('\c', c) + ENDFOR +ENDPROC + +->-------------------------------------------<- +CHAR '$VER: ',VERSION,0 diff --git a/amiget.info b/amiget.info new file mode 100644 index 0000000000000000000000000000000000000000..99a09c5851901a84ab2e920d7529fa917590876a GIT binary patch literal 5484 zcmchbZ)_aJ8OGn)J)a!|{)^!_gZF}jWa9jBNfC!hxs7t6i7J{D*#?zJw^pkvwGcTF zA6(bIT@xfr&4s-lwd1!N=yNxfF8keHA&0Vj@qx6|jH zyYpRwND-u+508KQ&g|^oGw(Y)$%#4=#4SN5X+3QqKdwd9`PF}^I)CdU+#z11ef*cm z!G*4Fw-l($<9f_fMdG%nWU1?l)JsA-;uR7TPUWXW(lNS7*v=1<%#rORV$PbR zLle#|c!lnv2GbOKoULTipmx1*sM>kSPvGt#QT2W;0p9xXmn3`+X+&EqY;YgCh?2ig zOq19Z!t2q$yK|i+Izu-kN&GdI+eS2f*Bp549lWbpu;)w?A0;t^SQtD|L&9_Q1rp2s z2d`zO0N#1&>F+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isearch.c @@ -0,0 +1,389 @@ +;/* +sc amisearch.c link lib lib:httpget.lib lib:funcs.lib lib:sc.lib lib:amiga.lib INCLUDEDIR=NETINCLUDE: to amisearch +delete #?.o #?.lnk +quit +*/ +/* + Amisearch v1.0 (29.03.2024) + Coded by emarti, Murat Ozdemir +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define SEARCHHTML "RAM:T/search.html" +#define SEARCHFILE "RAM:T/search.dat" +#define SEARCHURL "m68k.aminet.net/search?arch[]=m68k-amigaos&arch[]=generic&query=" +#define RECENT "m68k.aminet.net/search?o_date=newer&date=%s&arch[]=m68k-amigaos&arch[]=generic&sort=date&ord=DESC" + +#define MATCHING "matching" +#define LIGHT "lightrow" +#define DARK "darkrow" + +#define BUFFER 0x0400 +UBYTE *vers = "\0$VER: amisearch 1.0 (29.03.2024) emarti, Murat Ozdemir\r\n\0"; + +BPTR file, htmlfile; +char **arrline; +char filename[50], htmlfilename[50]; +int i, sayfa, si; +char url[BUFFER/4]; +char urlWithStart[BUFFER/4]; +UBYTE htmlline[BUFFER]; +UBYTE c; +int packageCount; +char temp[BUFFER/2]; +char desc[BUFFER/2]; +int packageNo=1; + +void removeRecurringChars(char* str); +void removeTags(char *str); +void trimle(char *line, BOOL endofline); +int getPackageCount(char *str); +int searchPageDownloadCount(int packageCount); +int posInString(char *str, char c); +int countInString(char *str, char c); +void INThandler(int sig); // CTRL-C +void htmllineToData(void); +char* leftTrim(char *str); + +int main(int argc, char* argv[]) { + + char sure; + time_t t; + struct tm *dt; + char strdate[0xff]; + char opt[3]; + + + signal(SIGINT, INThandler); + + if(argc<2){ printf("This program is part of amiget\n"); return -9;} + + if(strcmp(argv[1], "**recent**")==0) + { + time(&t); + dt=localtime(&t); + sprintf(strdate, "%6d", (1900+dt->tm_year)*10000+(dt->tm_mon)*100+dt->tm_mday); // last 30 days + sprintf(url, RECENT, strdate); + } + else + { + // searching from aminet and download html pages + strcpy(url, SEARCHURL); + for(i=2;idata + htmlfile = Open(htmlfilename, MODE_OLDFILE); + if (htmlfile == NULL) { + printf("HTML file not found\n"); + return -2; + } + + file = Open(filename, MODE_NEWFILE); + if(file==NULL) {Close(htmlfile); return -3;} + + while(FGets(htmlfile, htmlline, BUFFER) != NULL) + { + + if(strstr(htmlline, MATCHING) != NULL) { + trimle(htmlline, TRUE); + packageCount = getPackageCount(htmlline); + break; + } + } + + printf("\033[1;31;40mFound\033[0m %d package%s\n\n", packageCount, (packageCount>1)?"s":""); + if (packageCount == 0) {Close(htmlfile); Close(file); return -4;} + + if (packageCount>300) // packageCount>300 => download? + { + printf("There are many search results (>300). \033[1;31;40mContinue the process?\033[0m [Y/n]"); + sure = getchar(); + + if (sure == 'n' || sure == 'N') + { + Close(htmlfile); Close(file); return -100; + } + } + + arrline=(char**)malloc(BUFFER/2); + + htmllineToData(); + + Close(htmlfile); + + + + sayfa=searchPageDownloadCount(packageCount); + if (sayfa>2) printf("Please wait while processing...\n\n"); + + for(si=1;si') { + tag = 0; + *p++ = '|'; + } + str++; + } + + *p = '\0'; +} + +void trimle(char *line, BOOL endofline) +{ + int lastChars = 14; + if (!endofline) lastChars=1; + removeTags(line); + removeRecurringChars(line); + line[strlen(line)-lastChars]='\0'; +} + +// 'Found XXX matching package' +int getPackageCount(char *str) +{ + char *token; + token = strtok(str, " "); + token = strtok(NULL, " "); + return atoi(token); +} + +int searchPageDownloadCount(int packageCount) +{ + int kalan, result; + result = packageCount / 50; + kalan = packageCount % 50; + if(kalan>0) result++; + return result; +} + +int posInString(char *str, char c) +{ + int p=0; + for(;p (posInString(htmlline,'>')) ) + { + while(htmlline[i]!='|') + { + htmlline[i]=' '; + i--; + } + } + + trimle(htmlline, TRUE); + c='|'; + strncat(htmlline, &c, 1); + + if (countInString(htmlline, '|')!=8) + { + i=strlen(htmlline)-2; + strcat(htmlline, "*|"); + while (htmlline[i]!='|') + { + htmlline[i+2]=htmlline[i]; + i--; + } + htmlline[i+1]=' '; + htmlline[i+2]='|'; + } + + } + + par=countInString(htmlline, '|'); + arrline = getArray(htmlline, "|", par); + + strcpy(desc, ""); + np=0; + while(np<=par-8) + { + strcat(desc, arrline[7+np]); + np++; + } + + sprintf(temp, "%6d %30s %12s %6s %10s %s\n",packageNo, arrline[0],arrline[2],arrline[4],arrline[5],leftTrim(desc)); + FPuts(file, temp); + packageNo++; + + } + } +} diff --git a/amisearch.info b/amisearch.info new file mode 100644 index 0000000000000000000000000000000000000000..3bbe739ff8fadb64587d1e49505fe3ce65342474 GIT binary patch literal 5493 zcmeH}U1%It6vyw(B>Mp-yDN$bESXfqMr@k+P;4QTl#*(dwpc6_d~n4;^u=uZq7TLH zCeVN{y79BbSAUETPg)K=pS$L4YIiGmu+ zT8v66a`n`ys{iH%yV{=bW3~NqC%J`MyfzAZs}h|`ym)`~;$B0pV8=QqEP4nlhea&yv;W z$5=ba9b8dBy5l^dH$?h7$yR)&gy^>GcBK9UgwKyCwtpf{FQD`7#(wrJOK3WRVrefK zu1xeSm_^S5qGti|-38IJfaqC3d}BaJf$lWNZdt;8>{-Hl*|UW6V@-zHpo*pafU@MA zu(q8`@jbD3Mzw*2ZJ+N8ajeIMZU|p>M9%_C^eiBH77$V`)l0O@bDTX(R)g_|`xsD* z<}lf5`#EHLDPG%q!tEb#sdP_XW!8M(PtHuELs85W`xNsQ* z*q~-+R7a@Eleq&8ed1&8s2ppuWR<~vYMeVyd_t#|N;N(i zXV2oh#!BkDPNJ|@B6=3gqGtiovw*0@p!4gj!ac`h30F00)<*w}jt$mc<67T1Abke^ zof_X0>{$QCiKB0dL&uIE5kmXs@WEq84;?tzg9%rAyXX>ahmRb14XJxx_%ubSQ+h>P z^r`NtWMndVF_S!HC1)~bS`0@s$uXIHFZXy#CdaJgTe(N*AN|p^l8aW{yP~Jped)jS zv}L6%zB;#g{M$qe7`lB9yw4ocHjLSoBORIiBh?zZm}_urZ}AO)6(2k9MGC73ZZrL#U;Vby{Hi0tW7?^S&Kr5^Gk9;&MBNQ+fN8| z$zLbfwrV2wY&P6H%)P*IC*D890~4|5ilzc~TV zUN?6oX7mLww@=LKDObm$+5Us4!)P?yQ{E25#++)^%`xlG8DV~rGQ-asK= literal 0 HcmV?d00001 diff --git a/copy2c.e b/copy2c.e new file mode 100644 index 0000000..c8364fe --- /dev/null +++ b/copy2c.e @@ -0,0 +1,23 @@ +/* +Coded by emarti, Murat Ozdemir (March 29, 2024) +*/ + +OPT OSVERSION=37 +OPT MODULE + +MODULE 'dos', 'dos/dos' + +EXPORT PROC copyToC() + + copyfile('amiget') + copyfile('amiget.info') + copyfile('amisearch') + copyfile('amisearch.info') + +ENDPROC + +PROC copyfile(file) + DEF cmd[100]:STRING + StringF(cmd, 'Copy \s to SYS:C >NIL:', file) + Execute(cmd, NIL, NIL) +ENDPROC diff --git a/copy2c.m b/copy2c.m new file mode 100644 index 0000000000000000000000000000000000000000..b474acffc8a574f3776d8b1fda1275cea24eda0e GIT binary patch literal 290 zcmZ?u^><-lWnf?^U{Gaf5Ck&7fEUJKU=;?%^V|4=N%Y$g?@>e}zy?{r$1;}Ej!C2AlQWT9IeA|q}ARd}}7dv{m=!SFu zjQ@Mfj_5NCBN44I+S=8tvR&rnK20mD*{A_}0>CB1KEsoRQ1i4AJ!3d$IG?>TJ+G8A zTUAO`<^p8ZFt|E{{;JN2s_3cnj$u|aTpR9lOFN*?@K_Pvo#6h>71O9 z+Z02ok%5t6Eje~Qlg>S35XT!kJCVuZ(f%9Qz5?1{ zSrNDc$-B`w)-uFC)BP`WdxNfS(!wF#Kcf2qc^pu#D3@eXQf}n}rycf+mB2Yqxt${; zO}QA)0bd6wJ5%^S4QQ=S+pEReH(G#Yr(UdW(QUPylg{Z4Xj>kGMSYg8XL1tkmkSe8 zow^6G)7>q1QURtEj==OENcW@@XI`t&|Bx&lR;5?x`0AIPDlCCEzcD*Q?rAtIY`U&Rw z2dvP{B*k@tuSxNvC~V2NV%%n_Nt-cl