Command line args /K/M

5 posts / 0 new
Last post
mritter0
mritter0's picture
Offline
Last seen: 6 months 22 hours ago
Joined: 2014-04-21 21:15
Command line args /K/M
Does anyone have a modern, up to date, example on how to read command line args with a /K/M switch? As in: argTemplate="PATH/K/M,ICONIFY/S"; I guess the use of the PATH is optional. My code works just fine for PATH/K, but throw in the /M and all the text is garbled. I imagine there is a sub-array for the /M items??? And how is arg 0 the name of the program?
jabirulo
jabirulo's picture
Offline
Last seen: 3 days 3 hours ago
Joined: 2013-05-30 00:53
Yes, you're right seems it
Yes, you're right seems it returns an array. SDK's ReadArgs autodoc: /M - Multiple strings. This means the argument will take any number of strings, returning them as an array of strings. Any arguments not considered to be part of another option will be added to this option. Only one /M should be specified in a template. Example: for a template "Dir/M,All/S" the command-line "foo bar all qwe" will set the boolean "all", and return an array consisting of "foo", "bar", and "qwe" The entry in the array will be a pointer to an array of string pointers, the last of which will be NULL. There is an interaction between /M parameters and /A parameters. If there are unfilled /A parameters after parsing, it will grab strings from the end of a previous /M parameter list to fill the /A's. This is used for things like Copy ("From/A/M,To/A"). xadmaster lib has and example using 'FROM/A/M', maybe ot helps you somehow (see GetNames() function at bottom of source code and/or search for 'from' variable part of 'struct Args').
  1. ;/* to compile: execute xadUnFileM.c
  2. gcc xadUnFileM.c -Wall -N -oxadUnFileM -gstabs
  3. quit
  4. * Add -D_DEBUG_ to have some more little info.
  5. */
  6. #define NAME "xadUnFileM"
  7. #define DISTRIBUTION "(Freeware) "
  8. #define REVISION "26"
  9. #define DATE "16.07.2013"
  10.  
  11. /* Programmheader
  12.  
  13.  Name: xadUnFile
  14.  Author: SDI
  15.  Distribution: Freeware
  16.  Description: dearchives file archives
  17.  
  18.  1.0 13.09.1998: first version
  19.  1.1 18.11.1998: added FILE parameter and directory creation
  20.  1.2 03.02.1999: added corrupt message
  21.  1.3 07.02.1999: added missing "group crunched" handling
  22.  1.4 16.03.1999: errors no longer abort decrunching
  23.  1.5 21.06.1999: added support for multiple input files and renaming
  24.  1.6 04.07.1999: bug fix
  25.  1.7 18.07.1999: added SHOWPROT, reduced status prints, added QUIT, splitted in xadUnFile and xadUnFileM
  26.  1.8 19.08.1999: also strips "/" at name start for NOABS
  27.  1.9 15.09.1999: forgot to set date/comment/bits for directories
  28.  1.10 28.09.1999: added NAMESIZE keyword
  29.  1.11 01.11.1999: added SFS keyword
  30.  1.12 07.12.1999: added NOKILLPART keyword
  31.  1.13 17.12.1999: added VERBOSE mode
  32.  1.14 14.01.2000: added DARC, ENTRY, DIMG
  33.  1.15 12.02.2000: added auto DIMG and pattern support
  34.  1.16 05.03.2000: bug fixes
  35.  1.17 19.03.2000: support for XADFIF_NOUNCRUNCHSIZE
  36.  1.18 28.05.2000: added final report
  37.  1.19 04.06.2000: added multi-filesystem support
  38.  1.20 27.07.2000: fixed multi-filesystem support for empty fs parts
  39.  1.21 28.01.2001: returns RETURN_ERROR if errors occured
  40.  1.22 25.02.2001: GetInfo supports progress hook now
  41.  1.23 12.08.2001: shows unix devices info
  42.  1.24 17.11.2001: added indisk-support
  43.  1.25 10.03.2002: now aborts for disk I/O errors
  44.  1.26 16.07.2013: updated to OS4; splitted/removed MULTIFLE support
  45. */
  46.  
  47. #ifdef _DEBUG_
  48. #define D(x) x;
  49. #else
  50. #define D(x)
  51. #endif
  52.  
  53. #include <proto/xadmaster.h>
  54. #include <proto/exec.h>
  55. #include <proto/dos.h>
  56. #include <proto/utility.h>
  57. //#include "string.h"
  58. #include "SDI_version.h"
  59. #include <SDI_compiler.h>
  60.  
  61. struct XadMasterIFace *IXadMaster = NULL;
  62. struct Library *XadMasterBase = NULL;
  63. struct UtilityIFace *IUtility = NULL;
  64. struct Library *UtilityBase = NULL;
  65.  
  66. #define MINPRINTSIZE 51200 // 50KB
  67. #define NAMEBUFSIZE 1024
  68. #define PATBUFSIZE (NAMEBUFSIZE*2+10)
  69.  
  70. struct RDArgs *rda;
  71. CONST_STRPTR PARAM =
  72. "FROM/A/M,DEST=DESTDIR/K,PASSWORD/K,FILE/K,NAMESIZE/K/N,FFS=OFS/S,SFS/S,\
  73. INFO=LIST/S,Q=QUIET/S,AM=ASKMAKEDIR/S,OW=OVERWRITE/S,SP=SHOWPROT/S,VERBOSE/S,\
  74. DARC=DISKARCHIVE/S,ENTRY/K/N,DIMG=DISKIMAGE/S,NA=NOABS/S,NC=NOCOMMENT/S,\
  75. ND=NODATE/S,NE=NOEXTERN/S,NKP=NOKILLPART/S,NP=NOPROT/S,NT=NOTREE/S";
  76.  
  77. #define OPTIONS1 \
  78.   "FROM The input archive file(s)\n" \
  79.   "DESTDIR The destination directory, not needed with INFO\n" \
  80.   "PASSWORD A password for encrypted archives\n" \
  81.   "FILE Filename (with patterns) to be extracted\n"
  82. #define OPTIONS2 \
  83.   "NAMESIZE Names with more characters result in rename request\n" \
  84.   "FFS=OFS Sets NAMESIZE to 30\n" \
  85.   "SFS Sets NAMESIZE to 100\n" \
  86.   "INFO Shows archive information without extracting\n" \
  87.   "QUIET Turns of progress report and user interaction\n" \
  88.   "ASKMAKEDIR You get asked before a directory is created\n" \
  89.   "OVERWRITE Files are overwritten without asking\n" \
  90.   "SHOWPROT Show protection information with LIST\n" \
  91.   "VERBOSE Print some more information with INFO\n" \
  92.   "DARC input file is an disk archive\n" \
  93.   "ENTRY entry number for DARC, if not the first one\n" \
  94.   "DIMG input file is an disk image (ADF file)\n" \
  95.   "NOABS Do not extract absolute path name parts\n" \
  96.   "NOCOMMENT No filenote comments are extracted or displayed\n" \
  97.   "NODATE Creation date information gets not extracted\n" \
  98.   "NOEXTERN Turns off usage of external clients\n" \
  99.   "NOKILLPART Do not delete partial or corrupt output files.\n" \
  100.   "NOPROT Protection information gets not extracted\n" \
  101.   "NOTREE Files are extracted without subdirectories\n"
  102.  
  103. struct xHookArgs{
  104. STRPTR name;
  105. ULONG extractmode;
  106. ULONG flags;
  107. ULONG finish;
  108. ULONG lastprint;
  109. };
  110.  
  111. STATIC struct Args{
  112. STRPTR *from;
  113. STRPTR destdir;
  114. STRPTR password;
  115. STRPTR file;
  116. LONG *namesize;
  117. ULONG ffs;
  118. ULONG sfs;
  119. ULONG info;
  120. ULONG quiet;
  121. ULONG askmakedir;
  122. ULONG overwrite;
  123. ULONG showprot;
  124. ULONG verbose;
  125. ULONG diskarchive;
  126. LONG *entry;
  127. ULONG diskimage;
  128. ULONG noabs;
  129. ULONG nocomment;
  130. ULONG nodate;
  131. ULONG noextern;
  132. ULONG nokillpart;
  133. ULONG noprot;
  134. ULONG notree;
  135. } args;
  136.  
  137. STATIC ULONG prfunc(struct Hook *, UNUSED APTR, struct xadProgressInfo *);
  138. void ShowProt(ULONG);
  139. LONG CheckNameSize(STRPTR, ULONG);
  140. void CalcPercent(ULONG, ULONG, ULONG *, ULONG *);
  141. STRPTR *GetNames(STRPTR *);
  142.  
  143.  
  144. int main(void)
  145. {
  146. int ret = RETURN_FAIL, numerr = 0;
  147.  
  148. if( (DOSBase = IExec->OpenLibrary("dos.library", 51)) &&
  149. (UtilityBase = IExec->OpenLibrary("utility.library", 51)) &&
  150. (IUtility = (struct UtilityIFace *)IExec->GetInterface(UtilityBase, "main", 1, NULL))
  151. )
  152. {
  153. LONG err = 0;
  154.  
  155. if( (XadMasterBase = IExec->OpenLibrary(XADNAME, 13)) &&
  156. (IXadMaster = (struct XadMasterIFace *)IExec->GetInterface(XadMasterBase, "main", 1, NULL))
  157. )
  158. {
  159. // memset(&args, 0, sizeof(struct Args) ); // fill args with 0's (initialize)
  160. IUtility->ClearMem(&args, sizeof(struct Args) );
  161. if( (rda = (struct RDArgs *)IDOS->AllocDosObject(DOS_RDARGS, TAG_END)) )
  162. {
  163. rda->RDA_ExtHelp = OPTIONS1 OPTIONS2;
  164. if(IDOS->ReadArgs(PARAM, (LONG *)&args, rda) )
  165. {
  166. LONG namesize = 0;
  167. struct Hook *prhook;
  168. char filename[NAMEBUFSIZE];
  169. struct xHookArgs xh;
  170. STRPTR *argstring;
  171. D(STRPTR *r2;)
  172.  
  173. xh.name = filename;
  174. xh.flags = xh.finish = xh.lastprint = xh.extractmode = 0;
  175. prhook = (struct Hook *)IExec->AllocSysObjectTags(ASOT_HOOK, ASOHOOK_Entry,prfunc,
  176. ASOHOOK_Data,&xh, TAG_DONE);
  177. // Note! The hook may change the filename!!!
  178. // memset(&prhook, 0, sizeof(struct Hook) ); // fill prhook with 0's (initialize)
  179. // prhook.h_Entry = (ULONG (*)())progrhook;
  180. // prhook.h_Data = &xh;
  181.  
  182. if(args.namesize && *args.namesize > 0) namesize = *args.namesize;
  183. else
  184. if(args.ffs) namesize = 30;
  185. else
  186. if(args.sfs) namesize = 100;
  187.  
  188. if( !(args.from = argstring = GetNames(args.from)) ); // correct the argument list
  189. else
  190. if( !(*argstring) ) IDOS->SetIoErr(ERROR_REQUIRED_ARG_MISSING);
  191. else // comes together with following if!
  192.  
  193. if(args.destdir || args.info)
  194. {
  195. D( IDOS->Printf("[%ld]\n",__LINE__); )
  196. ULONG numfile = 0, numdir = 0;
  197. struct xadDeviceInfo *dvi = NULL;
  198. struct xadArchiveInfo *ai;
  199. struct TagItem ti[5];
  200. struct TagItem ti2[5];
  201. LONG loop = 2;
  202.  
  203. ti[1].ti_Tag = XAD_NOEXTERN;
  204. ti[1].ti_Data = args.noextern;
  205. ti[2].ti_Tag = args.password ? XAD_PASSWORD : TAG_IGNORE;
  206. ti[2].ti_Data = (ULONG)args.password;
  207. ti[3].ti_Tag = args.entry ? XAD_ENTRYNUMBER : TAG_IGNORE;
  208. ti[3].ti_Data = args.entry ? *args.entry : 1;
  209. ti[4].ti_Tag = TAG_DONE;
  210.  
  211. ti2[1].ti_Tag = XAD_NOEMPTYERROR;
  212. ti2[1].ti_Data = TRUE;
  213. ti2[2].ti_Tag = args.quiet ? TAG_IGNORE : XAD_PROGRESSHOOK;
  214. ti2[2].ti_Data = (ULONG)prhook;
  215. ti2[3].ti_Tag = TAG_DONE;
  216. ti2[4].ti_Tag = TAG_DONE; // needed later for loop
  217.  
  218. if( (ai = (struct xadArchiveInfo *)IXadMaster->xadAllocObjectA(XADOBJ_ARCHIVEINFO, 0)) )
  219. {
  220. if( *(args.from) ) //+1) )
  221. {
  222. struct xadSplitFile *sf = 0, *sf2, *sf0 = 0;
  223. D( for(r2 = args.from; *r2; ++r2) IDOS->Printf("%s\n",*r2); )
  224. while(*args.from && !err)
  225. {
  226. if( (sf2 = IXadMaster->xadAllocObjectA(XADOBJ_SPLITFILE, 0)) )
  227. {
  228. D( IDOS->Printf("[%ld]sf=0x%lx sf2=0x%lx sf0=0x%lx\n",__LINE__,sf,sf2,sf0) )
  229. if(sf)
  230. {
  231. sf->xsf_Next = sf2;
  232. sf = sf2;
  233. }
  234. else sf0 = sf = sf2;
  235.  
  236. D( IDOS->Printf("[%ld]sf=0x%lx sf2=0x%lx sf0=0x%lx\n",__LINE__,sf,sf2,sf0) )
  237. sf->xsf_Type = XAD_INFILENAME;
  238. sf->xsf_Data = (ULONG)*(args.from++);
  239. }
  240. else err = XADERR_NOMEMORY;
  241.  
  242. D( IDOS->Printf("[%ld]sf'%s' sf2'%s' sf0'%s'\n",__LINE__,sf->xsf_Data,sf2->xsf_Data,sf0->xsf_Data) )
  243. } // END while
  244.  
  245. if(!err)
  246. {
  247. if(args.diskarchive)
  248. {
  249. D( IDOS->Printf("[%ld]\n",__LINE__); )
  250. ti[0].ti_Tag = XAD_INSPLITTED;
  251. ti[0].ti_Data = (ULONG)sf0;
  252.  
  253. ti2[0].ti_Tag = XAD_INDISKARCHIVE;
  254. ti2[0].ti_Data = (ULONG)ti;
  255. if( (err = IXadMaster->xadGetDiskInfoA(ai, ti2)) )
  256. {
  257. ti2[0].ti_Tag = XAD_INSPLITTED;
  258. ti2[0].ti_Data = (ULONG)sf0;
  259. if( !IXadMaster->xadGetDiskInfoA(ai, ti2) ) err = 0;
  260. }
  261. }
  262. else
  263. if(args.diskimage)
  264. {
  265. D( IDOS->Printf("[%ld]\n",__LINE__); )
  266. ti2[0].ti_Tag = XAD_INSPLITTED;
  267. ti2[0].ti_Data = (ULONG)sf0;
  268. err = IXadMaster->xadGetDiskInfoA(ai, ti2);
  269. }
  270. else
  271. {
  272. err = IXadMaster->xadGetInfo(ai, XAD_INSPLITTED, sf0,
  273. XAD_NOEXTERN, args.noextern,
  274. args.password ? XAD_PASSWORD : TAG_IGNORE, args.password,
  275. args.quiet ? TAG_IGNORE : XAD_PROGRESSHOOK, prhook,
  276. TAG_DONE);
  277. D( IDOS->Printf("[%ld]err=%ld\n",__LINE__,err); )
  278. --loop;
  279. }
  280. } // END if(err)
  281.  
  282. while(sf0)
  283. {
  284. sf2 = sf0;
  285. sf0 = sf0->xsf_Next;
  286. D( IDOS->Printf("[%ld]sf=0x%lx sf2=0x%lx sf0=0x%lx\n",__LINE__,sf,sf2,sf0) )
  287. D( IDOS->Printf("sf'%s' sf2'%s' sf0=0x%lx\n",sf->xsf_Data,sf2->xsf_Data,sf0) )
  288. IXadMaster->xadFreeObjectA(sf2, 0);
  289. }
  290. } // if( *(args.from+1) )
  291. else
  292. if(args.diskarchive)
  293. {
  294. D( IDOS->Printf("[%ld]\n",__LINE__); )
  295. ti[0].ti_Tag = XAD_INFILENAME;
  296. ti[0].ti_Data = (ULONG)*args.from;
  297.  
  298. ti2[0].ti_Tag = XAD_INDISKARCHIVE;
  299. ti2[0].ti_Data = (ULONG)ti;
  300. if( (err = IXadMaster->xadGetDiskInfoA(ai, ti2)) )
  301. {
  302. ti2[0].ti_Tag = XAD_INFILENAME;
  303. ti2[0].ti_Data = (ULONG)*args.from;
  304. if( !IXadMaster->xadGetDiskInfoA(ai, ti2) ) err = 0;
  305.  
  306. }
  307. } // if(args.diskarchive)
  308. else
  309. if(args.diskimage)
  310. {
  311. D( IDOS->Printf("[%ld]\n",__LINE__); )
  312. if(*args.from[IUtility->Strlen(*args.from)-1] == ':')
  313. {
  314. if((dvi = (struct xadDeviceInfo *)IXadMaster->xadAllocObjectA(XADOBJ_DEVICEINFO, 0)) )
  315. {
  316. *args.from[IUtility->Strlen(*args.from)-1] = 0; // strip ':'
  317. dvi->xdi_DOSName = *args.from;
  318. ti2[0].ti_Tag = XAD_INDEVICE;
  319. ti2[0].ti_Data = (ULONG)dvi;
  320. err = IXadMaster->xadGetDiskInfoA(ai, ti2);
  321. /* *args.from[strlen(*args.from)] = ':'; */
  322. }
  323. else err = XADERR_NOMEMORY;
  324.  
  325. } // if(*args.from[strlen(*..
  326. else
  327. {
  328. ti2[0].ti_Tag = XAD_INFILENAME;
  329. ti2[0].ti_Data = (ULONG)*args.from;
  330. err = IXadMaster->xadGetDiskInfoA(ai, ti2);
  331. }
  332. } // if(args.diskimage)
  333. else
  334. {
  335. D( IDOS->Printf("[%ld]\n",__LINE__); )
  336. err = IXadMaster->xadGetInfo(ai, XAD_INFILENAME, *args.from,
  337. XAD_NOEXTERN, args.noextern,
  338. args.password ? XAD_PASSWORD : TAG_IGNORE, args.password,
  339. args.quiet ? TAG_IGNORE : XAD_PROGRESSHOOK, prhook,
  340. TAG_DONE);
  341. --loop;
  342. }
  343.  
  344. while(!err && loop)
  345. {
  346. if(ai->xai_Flags & XADAIF_FILECORRUPT) IDOS->Printf("!!! The archive file has some corrupt data. !!!\n");
  347.  
  348. if(args.info)
  349. {
  350. struct xadFileInfo *xfi;
  351. ULONG grsize = 0;
  352.  
  353. if(ai->xai_Client) IDOS->Printf("ClientName: %s\n", ai->xai_Client->xc_ArchiverName);
  354.  
  355. IDOS->Printf("Size CrndSize Ratio Date Time %s%sName\n",
  356. args.verbose ? "Info " : "",args.showprot ? "Protection " : "");
  357. xfi = ai->xai_FileInfo;
  358. while(xfi && !(IExec->SetSignal(0L,0L) & SIGBREAKF_CTRL_C) )
  359. {
  360. if( !(xfi->xfi_Flags & XADFIF_GROUPED) ) grsize = 0;
  361.  
  362. if(xfi->xfi_Flags & XADFIF_DIRECTORY)
  363. {
  364. IDOS->Printf(" <dir> <dir> %02ld.%02ld.%04ld %02ld:%02ld:%02ld ",
  365. xfi->xfi_Date.xd_Day, xfi->xfi_Date.xd_Month,
  366. xfi->xfi_Date.xd_Year, xfi->xfi_Date.xd_Hour,
  367. xfi->xfi_Date.xd_Minute, xfi->xfi_Date.xd_Second);
  368. if(args.verbose) IDOS->Printf("%-15s", xfi->xfi_EntryInfo);
  369.  
  370. if(args.showprot) ShowProt(xfi->xfi_Protection);
  371.  
  372. IDOS->Printf("%s\n", args.notree ? IDOS->FilePart(xfi->xfi_FileName) : xfi->xfi_FileName);
  373. }
  374. else
  375. if(xfi->xfi_Flags & XADFIF_GROUPED)
  376. {
  377. IDOS->Printf("%9lu merged n/a %02ld.%02ld.%04ld %02ld:%02ld:%02ld ",
  378. xfi->xfi_Size, xfi->xfi_Date.xd_Day, xfi->xfi_Date.xd_Month,
  379. xfi->xfi_Date.xd_Year, xfi->xfi_Date.xd_Hour,
  380. xfi->xfi_Date.xd_Minute, xfi->xfi_Date.xd_Second);
  381. if(args.verbose) IDOS->Printf("%-15s", xfi->xfi_EntryInfo);
  382.  
  383. if(args.showprot) ShowProt(xfi->xfi_Protection);
  384.  
  385. IDOS->Printf("%s\n", args.notree ? IDOS->FilePart(xfi->xfi_FileName) : xfi->xfi_FileName);
  386. grsize += xfi->xfi_Size;
  387. if(xfi->xfi_Flags & XADFIF_ENDOFGROUP)
  388. {
  389. ULONG i, j;
  390.  
  391. CalcPercent(xfi->xfi_GroupCrSize, grsize, &i, &j);
  392. IDOS->Printf("%9lu %9lu %2ld.%1ld%%\n", grsize, xfi->xfi_GroupCrSize, i, j);
  393. grsize = 0;
  394. }
  395. } // if(xfi->xfi_Flags &..
  396. else
  397. if(xfi->xfi_Flags & XADFIF_NOUNCRUNCHSIZE)
  398. {
  399. IDOS->Printf(" <nosize> %9lu %02ld.%02ld.%04ld %02ld:%02ld:%02ld ",
  400. xfi->xfi_CrunchSize, xfi->xfi_Date.xd_Day, xfi->xfi_Date.xd_Month,
  401. xfi->xfi_Date.xd_Year, xfi->xfi_Date.xd_Hour,
  402. xfi->xfi_Date.xd_Minute, xfi->xfi_Date.xd_Second);
  403. if(args.verbose) IDOS->Printf("%-15s", xfi->xfi_EntryInfo);
  404.  
  405. if(args.showprot) ShowProt(xfi->xfi_Protection);
  406.  
  407. IDOS->Printf("%s\n", args.notree ? IDOS->FilePart(xfi->xfi_FileName) : xfi->xfi_FileName);
  408. }
  409. else
  410. {
  411. ULONG i, j;
  412.  
  413. CalcPercent(xfi->xfi_CrunchSize, xfi->xfi_Size, &i, &j);
  414. IDOS->Printf("%9lu %9lu %2ld.%1ld%% %02ld.%02ld.%04ld %02ld:%02ld:%02ld ",
  415. xfi->xfi_Size, xfi->xfi_CrunchSize, i, j,
  416. xfi->xfi_Date.xd_Day, xfi->xfi_Date.xd_Month,
  417. xfi->xfi_Date.xd_Year, xfi->xfi_Date.xd_Hour,
  418. xfi->xfi_Date.xd_Minute, xfi->xfi_Date.xd_Second);
  419. if(args.verbose) IDOS->Printf("%-15s", xfi->xfi_EntryInfo);
  420.  
  421. if(args.showprot) ShowProt(xfi->xfi_Protection);
  422.  
  423. IDOS->Printf("%s\n", args.notree ? IDOS->FilePart(xfi->xfi_FileName) : xfi->xfi_FileName);
  424. }
  425.  
  426. if(xfi->xfi_Flags & XADFIF_LINK) IDOS->Printf("link: %s\n", xfi->xfi_LinkName);
  427.  
  428. if(!args.nocomment)
  429. {
  430. if(xfi->xfi_Comment) IDOS->Printf(": %s\n", xfi->xfi_Comment);
  431. /* get DSI error on 'xfi->xfi_Special->..'!
  432.   if(xfi->xfi_Special && xfi->xfi_Special->xfis_Type == XADSPECIALTYPE_UNIXDEVICE)
  433.   IDOS->Printf(": Unix %s device (%3ld | %3ld)\n", xfi->xfi_FileType == XADFILETYPE_UNIXBLOCKDEVICE ? "block" : "character",
  434.   xfi->xfi_Special->xfis_Data.xfis_UnixDevice.xfis_MajorVersion,
  435.   xfi->xfi_Special->xfis_Data.xfis_UnixDevice.xfis_MinorVersion);
  436. */
  437. if(xfi->xfi_FileType == XADFILETYPE_UNIXFIFO) IDOS->Printf(": Unix named pipe\n");
  438. }
  439. #ifdef _DEBUG_
  440. if(xfi->xfi_Flags)
  441. {
  442. IDOS->Printf("Flags: ");
  443. if(xfi->xfi_Flags & XADFIF_CRYPTED) IDOS->Printf("XADFIF_CRYPTED ");
  444.  
  445. if(xfi->xfi_Flags & XADFIF_DIRECTORY) IDOS->Printf("XADFIF_DIRECTORY ");
  446.  
  447. if(xfi->xfi_Flags & XADFIF_LINK) IDOS->Printf("XADFIF_LINK ");
  448.  
  449. if(xfi->xfi_Flags & XADFIF_INFOTEXT) IDOS->Printf("XADFIF_INFOTEXT ");
  450.  
  451. if(xfi->xfi_Flags & XADFIF_GROUPED) IDOS->Printf("XADFIF_GROUPED ");
  452.  
  453. if(xfi->xfi_Flags & XADFIF_ENDOFGROUP) IDOS->Printf("XADFIF_ENDOFGROUP ");
  454.  
  455. if(xfi->xfi_Flags & XADFIF_NODATE) IDOS->Printf("XADFIF_NODATE ");
  456.  
  457. IDOS->Printf("\n");
  458. }
  459. #endif
  460. if(xfi->xfi_Flags & XADFIF_CRYPTED) IDOS->Printf("The entry is encrypted.\n");
  461.  
  462. if(xfi->xfi_Flags & XADFIF_PARTIALFILE) IDOS->Printf("The entry is no complete file.\n");
  463.  
  464. xfi = xfi->xfi_Next;
  465. } // END while(xfi &&..
  466. ret = 0;
  467. } // if(args.info)
  468. else
  469. {
  470. struct xadFileInfo *fi;
  471. char parsebuf[PATBUFSIZE];
  472.  
  473. ret = 0;
  474. fi = ai->xai_FileInfo;
  475. if(!args.file || IDOS->ParsePatternNoCase(args.file, parsebuf, PATBUFSIZE) >= 0)
  476. {
  477. while(fi && !(IExec->SetSignal(0L,0L) & SIGBREAKF_CTRL_C) && !xh.finish)
  478. {
  479. if(!args.file || IDOS->MatchPatternNoCase(parsebuf, args.notree ?
  480. IDOS->FilePart(fi->xfi_FileName) : fi->xfi_FileName) )
  481. {
  482. IExec->CopyMem(args.destdir, filename, IUtility->Strlen(args.destdir)+1);
  483. if( IUtility->Stricmp(args.destdir, "NIL:") )
  484. {
  485. if(args.notree)
  486. IDOS->AddPart(filename, IDOS->FilePart(fi->xfi_FileName), NAMEBUFSIZE);
  487. else
  488. if(!args.noabs) IDOS->AddPart(filename, fi->xfi_FileName, NAMEBUFSIZE);
  489. else
  490. {
  491. STRPTR fname = filename, f;
  492.  
  493. if(*args.destdir)
  494. {
  495. fname += IUtility->Strlen(args.destdir)-1;
  496. if(*fname != ':' && *fname != '/') *(++fname) = '/';
  497.  
  498. ++fname;
  499. }
  500. for(f = fi->xfi_FileName; *f == '/' || *f == ':'; ++f);
  501.  
  502. for(; *f; ++f) *(fname++) = *f == ':' ? '/' : *f;
  503.  
  504. *fname = 0;
  505. }
  506. }
  507. if(fi->xfi_Flags & XADFIF_LINK)
  508. {
  509. if(!args.quiet) IDOS->Printf("Skipped Link\n");
  510. }
  511. else
  512. if(fi->xfi_Flags & XADFIF_DIRECTORY)
  513. {
  514. if(!args.notree)
  515. {
  516. BPTR a;
  517. LONG err = 0, i = 0;
  518. char r;
  519.  
  520. ++numdir;
  521. while(filename[i] && !err)
  522. {
  523. for(;filename[i] && filename[i] != '/'; ++i);
  524.  
  525. r = filename[i];
  526. filename[i] = 0;
  527. if( (a = IDOS->Lock(filename, SHARED_LOCK)) ) IDOS->UnLock(a);
  528. else
  529. if( (a = IDOS->CreateDir(filename)) ) IDOS->UnLock(a);
  530. else err = 1;
  531.  
  532. filename[i++] = r;
  533. }
  534.  
  535. if(!args.quiet)
  536. {
  537. if(err)
  538. {
  539. IDOS->Printf("failed to create directory '%s'\n", fi->xfi_FileName);
  540. ++numerr;
  541. }
  542. else IDOS->Printf("Created directory : %s\n", filename);
  543.  
  544. }
  545.  
  546. if(!err)
  547. {
  548. struct DateStamp d;
  549.  
  550. if(!args.nodate && !(fi->xfi_Flags & XADFIF_NODATE)
  551. && !IXadMaster->xadConvertDates(XAD_DATEXADDATE,&fi->xfi_Date,
  552. XAD_GETDATEDATESTAMP,&d, TAG_DONE) )
  553. IDOS->SetDate(filename, &d);
  554.  
  555. if(!args.noprot) IDOS->SetProtection(filename, fi->xfi_Protection);
  556.  
  557. if(fi->xfi_Comment && !args.nocomment) IDOS->SetComment(filename, fi->xfi_Comment);
  558. /* SetOwner ??? */
  559. }
  560.  
  561. } // END if(!args.notree)
  562. } // if(fi->xfi_Flags &..
  563. else
  564. {
  565. struct DateStamp d;
  566.  
  567. if(namesize) xh.finish = CheckNameSize(IDOS->FilePart(filename), namesize);
  568.  
  569. if(!xh.finish)
  570. {
  571. LONG e;
  572.  
  573. ++numfile;
  574. xh.extractmode = 1;
  575. if(args.diskimage || args.diskarchive)
  576. e = IXadMaster->xadDiskFileUnArc(ai, XAD_OUTFILENAME, filename,
  577. XAD_ENTRYNUMBER, fi->xfi_EntryNumber,
  578. XAD_MAKEDIRECTORY, !args.askmakedir,
  579. XAD_OVERWRITE, args.overwrite,
  580. XAD_NOKILLPARTIAL, args.nokillpart,
  581. args.quiet ? TAG_IGNORE : XAD_PROGRESSHOOK, prhook,
  582. TAG_DONE);
  583. else
  584. e = IXadMaster->xadFileUnArc(ai, XAD_OUTFILENAME, filename,
  585. XAD_ENTRYNUMBER, fi->xfi_EntryNumber,
  586. XAD_MAKEDIRECTORY, !args.askmakedir,
  587. XAD_OVERWRITE, args.overwrite,
  588. XAD_NOKILLPARTIAL, args.nokillpart,
  589. args.quiet ? TAG_IGNORE : XAD_PROGRESSHOOK, prhook,
  590. TAG_DONE);
  591.  
  592. xh.extractmode = 0;
  593. if(!e)
  594. {
  595. if(!args.nodate && !(fi->xfi_Flags & XADFIF_NODATE)
  596. && !IXadMaster->xadConvertDates(XAD_DATEXADDATE,&fi->xfi_Date,
  597. XAD_GETDATEDATESTAMP,&d, TAG_DONE) )
  598. IDOS->SetDate(filename, &d);
  599.  
  600. if(!args.noprot) IDOS->SetProtection(filename, fi->xfi_Protection);
  601.  
  602. if(fi->xfi_Comment && !args.nocomment) IDOS->SetComment(filename, fi->xfi_Comment);
  603. /* SetOwner ??? */
  604. }
  605. else ++numerr;
  606. // IO-errors, abort
  607. if(e == XADERR_INPUT || e == XADERR_OUTPUT) xh.finish = 1;
  608. } // END if(!xh.finish)
  609. } // END if(fi->xfi_Flags &..
  610. }
  611. fi = fi->xfi_Next;
  612. }
  613. }
  614. }
  615. ti2[3].ti_Tag = XAD_STARTCLIENT;
  616. ti2[3].ti_Data = (ULONG)ai->xai_Client->xc_Next;
  617. IXadMaster->xadFreeInfo(ai);
  618. if(--loop)
  619. {
  620. loop = 0;
  621. if(ti2[3].ti_Data)
  622. {
  623. IXadMaster->xadFreeObjectA(ai, 0); // realloc ai structure
  624. if( (ai = (struct xadArchiveInfo *)IXadMaster->xadAllocObjectA(XADOBJ_ARCHIVEINFO, 0)) )
  625. {
  626. if( !IXadMaster->xadGetDiskInfoA(ai, ti2) ) loop = 2;
  627. }
  628. }
  629. }
  630. if(!args.info && !loop && !(IExec->SetSignal(0L,0L) & SIGBREAKF_CTRL_C) )
  631. {
  632. IDOS->Printf("Processed");
  633. if(numfile) IDOS->Printf(" %ld file%s%s", numfile, numfile == 1 ? "" : "s", numdir ? " and" : "");
  634. if(numdir) IDOS->Printf(" %ld director%s", numdir, numdir == 1 ? "y" : "ies");
  635. if(!numfile && !numdir) IDOS->Printf(" nothing");
  636. if(numerr) IDOS->Printf(", %ld error%s", numerr, numerr == 1 ? "" : "s");
  637.  
  638. IDOS->Printf(".\n");
  639. }
  640. } // xadGetInfo while loop
  641.  
  642. if(ai) IXadMaster->xadFreeObjectA(ai, 0);
  643. if(dvi) IXadMaster->xadFreeObjectA(dvi, 0);
  644. } // xadAllocObject
  645. }
  646. else IDOS->SetIoErr(ERROR_REQUIRED_ARG_MISSING);
  647.  
  648. if(argstring) IExec->FreeVec(argstring);
  649. IExec->FreeSysObject(ASOT_HOOK, prhook);
  650. IDOS->FreeArgs(rda);
  651. } // ReadArgs()
  652. IDOS->FreeDosObject(DOS_RDARGS, rda);
  653. } // AllocDosObject()
  654. if(IExec->SetSignal(0L,0L) & SIGBREAKF_CTRL_C) IDOS->SetIoErr(ERROR_BREAK);
  655.  
  656. if(!args.quiet)
  657. {
  658. if(err) IDOS->Printf("An error occured: %s\n", IXadMaster->xadGetErrorText(err) );
  659. else
  660. if(ret) IDOS->PrintFault(IDOS->IoErr(), 0);
  661. }
  662.  
  663. if(IXadMaster) IExec->DropInterface( (struct Interface *)IXadMaster );
  664. if(XadMasterBase) IExec->CloseLibrary(XadMasterBase);
  665. } // OpenLibrary xadmaster
  666. else IDOS->Printf("Failed to open 'xadmaster.library' V13\n");
  667.  
  668. if(IUtility) IExec->DropInterface( (struct Interface *)IUtility );
  669. if(UtilityBase) IExec->CloseLibrary(UtilityBase);
  670. if(DOSBase) IExec->CloseLibrary(DOSBase);
  671. } // OpenLibrary DOS/utility_lib
  672. if(!ret && numerr) ret = RETURN_ERROR;
  673.  
  674. return ret;
  675. }
  676.  
  677.  
  678. //ASM (ULONG) progrhook(REG(a0, struct Hook *), REG(a1, struct xadProgressInfo *) );
  679. STATIC ULONG prfunc(struct Hook *hook, UNUSED APTR obj, struct xadProgressInfo *pi)
  680. {
  681. ULONG ret = 0;
  682. // D( static ULONG cnthook=0; )
  683. STRPTR name = ((struct xHookArgs *)(hook->h_Data))->name;
  684.  
  685. // D( IDOS->Printf("[Hook #%ld]\n",cnthook++) )
  686. switch(pi->xpi_Mode)
  687. {
  688. case XADPMODE_ASK:
  689. ret |= ((struct xHookArgs *)(hook->h_Data))->flags;
  690. if( (pi->xpi_Status & XADPIF_OVERWRITE) && !(ret & XADPIF_OVERWRITE) )
  691. {
  692. int32 r;
  693.  
  694. IDOS->Printf("File '%s' already exists, overwrite? (Y|A|S|\033[1mN\033[0m|Q|R): ",pi->xpi_FileName);
  695. IDOS->FFlush( IDOS->Output() );
  696. IDOS->SetMode(IDOS->Input(), TRUE); // single char input mode
  697. r = IDOS->FGetC( IDOS->Input() );
  698. IDOS->SetMode(IDOS->Input(), FALSE); // line buffered input mode
  699. switch(r)
  700. {
  701. case 'a': case 'A': ((struct xHookArgs *)(hook->h_Data))->flags |= XADPIF_OVERWRITE;
  702. case 'y': case 'Y': ret |= XADPIF_OVERWRITE; break;
  703. case 's': case 'S': ret |= XADPIF_SKIP; break;
  704. case 'q': case 'Q': ((struct xHookArgs *)(hook->h_Data))->finish = 1; break;
  705. case 'r': case 'R':
  706. IDOS->Printf("\r\033[KEnter new (full) name for '%s':", pi->xpi_FileName);
  707. IDOS->FFlush( IDOS->Output() );
  708. IDOS->FGets(IDOS->Input(), name, NAMEBUFSIZE);//-1); // 1 byte less to correct bug before V39
  709. r = IUtility->Strlen(name);
  710. if(name[r-1] == '\n') name[--r] = 0; // skip return character
  711.  
  712. IDOS->Printf("\033[1F\033[K"); // go up one line and clear it
  713. if( (pi->xpi_NewName = IXadMaster->xadAllocVec(++r, MEMF_SHARED)) )
  714. {
  715. while(r--) pi->xpi_NewName[r] = name[r];
  716.  
  717. ret |= XADPIF_RENAME;
  718. }
  719. else IDOS->Printf("No memory to store new name\n");
  720. } //switch(r)
  721. } // end if( (pi->xpi_Status &..
  722. if( (pi->xpi_Status & XADPIF_ISDIRECTORY) )
  723. {
  724. int32 r;
  725.  
  726. IDOS->Printf("File '%s' exists as directory, rename? (R|S|\033[1mN\033[0m|Q): ",pi->xpi_FileName);
  727. IDOS->FFlush( IDOS->Output() );
  728. IDOS->SetMode(IDOS->Input(), TRUE);
  729. r = IDOS->FGetC( IDOS->Input() );
  730. IDOS->SetMode(IDOS->Input(), FALSE);
  731. switch(r)
  732. {
  733. case 's': case 'S': ret |= XADPIF_SKIP; break;
  734. case 'q': case 'Q': ((struct xHookArgs *)(hook->h_Data))->finish = 1; break;
  735. case 'r': case 'R':
  736. IDOS->Printf("\r\033[KEnter new (full) name for '%s':", pi->xpi_FileName);
  737. IDOS->FFlush( IDOS->Output() );
  738. IDOS->FGets(IDOS->Input(), name, NAMEBUFSIZE);//-1); // 1 byte less to correct bug before V39
  739. r = IUtility->Strlen(name);
  740. if(name[r-1] == '\n') name[--r] = 0; // skip return character
  741.  
  742. IDOS->Printf("\033[1F\033[K"); // go up one line and clear it
  743. if( (pi->xpi_NewName = IXadMaster->xadAllocVec(++r, MEMF_SHARED)) )
  744. {
  745. while(r--) pi->xpi_NewName[r] = name[r];
  746.  
  747. ret |= XADPIF_RENAME;
  748. }
  749. else IDOS->Printf("No memory to store new name\n");
  750. } // end switch(r)
  751. } //end if( (pi->xpi_Status
  752. if( (pi->xpi_Status & XADPIF_MAKEDIRECTORY) && !(ret & XADPIF_MAKEDIRECTORY) )
  753. {
  754. IDOS->Printf("Directory of file '%s' does not exist, create? (Y|A|S|\033[1mN\033[0m|Q): ",name);
  755. IDOS->FFlush( IDOS->Output() );
  756. IDOS->SetMode(IDOS->Input(), TRUE);
  757. switch( IDOS->FGetC( IDOS->Input() ) )
  758. {
  759. case 'a': case 'A': ((struct xHookArgs *)(hook->h_Data))->flags |= XADPIF_MAKEDIRECTORY;
  760. case 'y': case 'Y': ret |= XADPIF_MAKEDIRECTORY; break;
  761. case 's': case 'S': ret |= XADPIF_SKIP; break;
  762. case 'q': case 'Q': ((struct xHookArgs *)(hook->h_Data))->finish = 1;
  763. }
  764. IDOS->SetMode(IDOS->Input(), FALSE);
  765. }
  766. break;
  767.  
  768. case XADPMODE_PROGRESS:
  769. if(pi->xpi_CurrentSize - ((struct xHookArgs *)(hook->h_Data))->lastprint >= MINPRINTSIZE)
  770. {
  771. if(pi->xpi_FileInfo->xfi_Flags & XADFIF_NOUNCRUNCHSIZE)
  772. IDOS->Printf("\r\033[KWrote %9lu bytes: %s", pi->xpi_CurrentSize, name);
  773. else IDOS->Printf("\r\033[KWrote %lu of %lu bytes: %s",
  774. pi->xpi_CurrentSize, pi->xpi_FileInfo->xfi_Size, name);
  775. IDOS->FFlush( IDOS->Output() );
  776. ((struct xHookArgs *)(hook->h_Data))->lastprint = pi->xpi_CurrentSize;
  777. }
  778. break;
  779.  
  780. case XADPMODE_END:
  781. IDOS->Printf("\r\033[KWrote %9lu bytes: %s\n", pi->xpi_CurrentSize, name);
  782. break;
  783.  
  784. case XADPMODE_ERROR:
  785. if( ((struct xHookArgs *)(hook->h_Data))->extractmode )
  786. IDOS->Printf("\r\033[K%s: %s\n", name, IXadMaster->xadGetErrorText(pi->xpi_Error) );
  787. break;
  788.  
  789. case XADPMODE_GETINFOEND:
  790. break;
  791. } // switch(pi->xpi_Mode)
  792.  
  793. if( !(IExec->SetSignal(0L,0L) & SIGBREAKF_CTRL_C) ) ret |= XADPIF_OK; // clear ok flag
  794.  
  795. // D( IDOS->Printf("[End of Hook]\n") )
  796. return ret;
  797. }
  798.  
  799.  
  800. void ShowProt(ULONG i)
  801. {
  802. LONG j;
  803. char buf[16], *b = "rwedrwedhsparwed";
  804.  
  805. for(j = 0; j <= 11; ++j) buf[j] = (i & (1<<(15-j))) ? b[j] : '-';
  806.  
  807. for(; j <= 15; ++j) buf[j] = (i & (1<<(15-j))) ? '-' : b[j];
  808.  
  809. IDOS->Printf("%.16s ", buf);
  810. }
  811.  
  812.  
  813. LONG CheckNameSize(STRPTR name, ULONG size)
  814. {
  815. LONG ret = 0;
  816. int32 r;
  817.  
  818. if( (r = IUtility->Strlen(name)) > size )
  819. {
  820. char buf[NAMEBUFSIZE];
  821.  
  822. IDOS->Printf("\r\033[KFilename '%s' exceeds name limit of %ld by %ld, rename? (Y|\033[1mN\033[0m|Q): ", name, size, r-size);
  823.  
  824. IDOS->FFlush( IDOS->Output() );
  825. IDOS->SetMode(IDOS->Input(), TRUE);
  826. r = IDOS->FGetC( IDOS->Input() );
  827. IDOS->SetMode(IDOS->Input(), FALSE);
  828. switch(r)
  829. {
  830. case 'q': case 'Q': ret = 1; break;
  831. case 'y': case 'Y':
  832. IDOS->Printf("\r\033[KEnter new name for '%s':", name);
  833. IDOS->FFlush( IDOS->Output() );
  834. IDOS->FGets(IDOS->Input(), buf, NAMEBUFSIZE);//-1); // 1 byte less to correct bug before V39
  835. r = IUtility->Strlen(buf);
  836. if(buf[r-1] == '\n') buf[--r] = 0; // skip return character
  837.  
  838. IDOS->Printf("\033[1F\033[K"); // go up one line and clear it
  839. if( !(ret = CheckNameSize(buf, size)) )
  840. {
  841. for(r = 0; buf[r]; ++r) *(name++) = buf[r];
  842.  
  843. *name = 0;
  844. }
  845. break;
  846.  
  847. }
  848. }
  849. return ret;
  850. }
  851.  
  852.  
  853. void CalcPercent(ULONG cr, ULONG ucr, ULONG *p1, ULONG *p2)
  854. {
  855. ULONG i = 0, j = 0;
  856.  
  857. if(cr < ucr)
  858. {
  859. if( cr > (0xFFFFFFFF/1000) ) i = 1000 - cr / (ucr / 1000);
  860. else i = 1000 - (1000 * cr) / ucr;
  861.  
  862. j = i % 10;
  863. i /= 10;
  864. }
  865. *p1 = i;
  866. *p2 = j;
  867. }
  868.  
  869.  
  870. STRPTR *GetNames(STRPTR *names)
  871. {
  872. struct AnchorPath *APath;
  873. STRPTR *result = 0, s, f, *r;
  874. ULONG *filelist, *fl = 0, *a, *b, retval = 0, namesize = 0;
  875. LONG i;
  876. //struct ExamineData *data;
  877.  
  878. // if( (APath = (struct AnchorPath *) IExec->AllocMem(sizeof(struct AnchorPath)+512, MEMF_PUBLIC|MEMF_CLEAR)) )
  879. if( (APath = IDOS->AllocDosObjectTags(DOS_ANCHORPATH,
  880. ADO_Strlen, 1024L,
  881. ADO_Mask, SIGBREAKF_CTRL_C,
  882. TAG_END)) )
  883. {
  884. // APath->ap_BreakBits = SIGBREAKF_CTRL_C;
  885. // APath->ap_Strlen = 512;
  886. while(*names && !retval)
  887. {
  888. filelist = 0;
  889. for(retval = IDOS->MatchFirst(*names, APath); !retval; retval = IDOS->MatchNext(APath) )
  890. {
  891. if(APath->ap_Info.fib_DirEntryType < 0)
  892. {
  893. i = IUtility->Strlen(APath->ap_Buffer)+1;
  894. // if( !(a = (ULONG *)IExec->AllocVec(i+4, MEMF_ANY)) ) break;
  895. if( !(a = IExec->AllocVecTags(i+4, AVT_Type,MEMF_SHARED, TAG_DONE)) ) break;
  896.  
  897. IExec->CopyMem(APath->ap_Buffer, a+1, i);
  898. namesize += i;
  899. if(!filelist)
  900. {
  901. filelist = a;
  902. *a = 0;
  903. }
  904. else
  905. if(IUtility->Stricmp( (STRPTR)(filelist+1), APath->ap_Buffer ) >= 0)
  906. {
  907. *a = (ULONG) filelist;
  908. filelist = a;
  909. }
  910. else
  911. {
  912. for(b = filelist; *b && (i = IUtility->Stricmp( (STRPTR)(*b+4),//SDI_stricmp((STRPTR) (*b+4),
  913. APath->ap_Buffer)) < 0; b = (ULONG *)*b);
  914. *a = *b; *b = (ULONG)a;
  915. }
  916. }
  917. } // END for(retval..
  918. if(fl)
  919. {
  920. for(b = fl; *b; b = (ULONG *)*b);
  921.  
  922. *b = (ULONG)filelist;
  923. }
  924. else fl = filelist;
  925.  
  926. IDOS->MatchEnd(APath);
  927. if(retval == ERROR_NO_MORE_ENTRIES) retval = 0;
  928.  
  929. ++names;
  930. } // END while
  931.  
  932. if(!retval)
  933. {
  934. i = 0;
  935. for(b = fl; b; b = (ULONG *)*b) ++i;
  936.  
  937. // if( (result = (STRPTR *)IExec->AllocVec((i+1)*sizeof(STRPTR)+namesize, MEMF_ANY)) )
  938. if( (result = (STRPTR *)IExec->AllocVecTags( (i+1)*sizeof(STRPTR)+namesize, AVT_Type, MEMF_SHARED, TAG_DONE)) )
  939. {
  940. s = ( (STRPTR)result)+((i+1)*sizeof(STRPTR) );
  941. i = 0;
  942. for(b = fl; b; b = (ULONG *)*b)
  943. {
  944. result[i++] = s;
  945. for(f = (STRPTR)(b+1); *f; ++f) *(s++) = *f;
  946.  
  947. *(s++) = 0;
  948. }
  949. result[i] = 0;
  950. }
  951. }
  952.  
  953. while(fl)
  954. {
  955. a = (ULONG *)*fl;
  956. IExec->FreeVec(fl);
  957. fl = a;
  958. }
  959. IDOS->FreeDosObject(DOS_ANCHORPATH, APath);
  960. // IExec->FreeMem(APath, sizeof(struct AnchorPath)+512);
  961. } // END if( (APath = (struct..
  962. if(!retval)
  963. {
  964. IDOS->Printf("Loading files in following order: ");
  965. for(r = result; *r; ++r) IDOS->Printf("%s%s", *r, r[1] ? ", " : "\n");
  966.  
  967. }
  968. return result;
  969. }
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
mritter0
mritter0's picture
Offline
Last seen: 6 months 22 hours ago
Joined: 2014-04-21 21:15
None of the examples I found
None of the examples I found had everything I needed. I took bits and pieces from 3 places and merged into my code. Thanks
thomas
thomas's picture
Offline
Last seen: 3 weeks 4 days ago
Joined: 2011-05-16 14:23
http://www.amigans.net/module
http://www.amigans.net/modules/xforum/viewtopic.php?post_id=63398#forumpost63398
hypex
hypex's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2011-09-09 16:20
The "/K" specifies it as a
The "/K" specifies it as a keyword. So in your case "PATH=Here:" will specifically tell it. But "Here" will work just as well if the template is clear enough for the parser. It is optional unless you see "/A" meaning it its required. Now if you attach "/M" on the end for multiple then you should make it the last argument on the template. Otherwise it gets confusing. So the "ICONIFY/S" should be up front. As to the arg 0, being the name of the program, I'm only aware of that happening when you use the argv[] from the main() function. Which doesn't relate to ReadArgs().
Log in or register to post comments