amiga-news DEUTSCHE VERSION
.
Links| Forums| Comments| Report news
.
Chat| Polls| Newsticker| Archive
.

amiga-news.de Forum > Programmierung > SAS/C (a)stcsma [ - Search - New posts - Register - Login - ]

-1- [ - Post reply - ]

2006-04-07, 18:03 h

Flipflop
Posts: 187
User
Hi!

Hab hier einen alten SAS/C Source, der sich bis auf zwei
Routinen nicht compilieren lässt, und mir fehlt gerade
die Doku dazu... :-(

stcsma und astcsma

beides wohl für PatternMatching gedacht?!

Wenn vielleicht gleich jemand nen Ersatz-Code auf Basis
der dos.library anzubieten hat?!

DANKE!

Flipflop

[ - Answer - Quote - Direct link - ]

2006-04-11, 16:36 h

softwarefailure
Posts: 38
User
Nicht verzagen, SAS/C Manual fragen...

Nr. 1:

code:
astcsma-AmigaDOS string pattern match (anchored)

Synopsis

	#include <string.h>

	length = astcsma(s,p);

	int length;	  /* length of matching string */
	const char *s;	  /* string being scanned */
	const char *p;	  /* pattern string */

Description

	The function astcsma performs a simple anchored AmigaDOS style
	pattern match.	That is, you can specify the wildcards #? in the
	pattern string.  The pattern must match at the beginning of the
	specified string.

	This function is not available if the @{" _STRICT_ANSI " Link _STRICT_ANSI} flag has been
	defined.

Portability

	@{" AmigaDOS " Link "Glossary - AmigaDOS"}

Returns

	This function returns the length of the matching string or 0 if
	there was no match.

Example


	/* Show all files matching the pattern "#?.c" */

	#include <stdio.h>
	#include <stdlib.h>
	#include <string.h>
	#include <sys/types.h>
	#include <sys/dir.h>

	void main(void)
	{
	    DIR *dfd;
	    struct direct *dptr;

	    dfd=opendir("");  /* opens the current directory */
	    if (dfd != NULL)
	    {
		while ((dptr=readdir(dfd))!=NULL)
		{
		    if (astcsma(dptr->d_name,"#?.c")!=0)
		    {
			printf("%sn",dptr->d_name);
		    }
		}
		closedir(dfd);
	    }
	}

See Also

	@{" stcpm " Link stcpm()}, @{" stcpma " Link stcpma()}, @{" stcsma " Link stcsma()}



Nr. 2:
code:
stcsma-UNIX string pattern match (anchored)

Synopsis

	#include <string.h>

	length = stcsma (s,p);

	int length;	   /* length of matching string */
	const char *s;	   /* string being scanned */
	const char *p;	   /* pattern string */

Description

	The function stcsma performs an anchored pattern match of the type
	used by the UNIX shell.  The only meta-characters recognized are
	the asterisk (*) and the question mark (?).  The asterisk matches
	an arbitrary number of characters, and the question mark matches
	exactly one character. The pattern must match at the beginning of
	the supplied string.

	This function is not available if the @{" _STRICT_ANSI " Link _STRICT_ANSI} flag has been
	defined.

Portability

	@{" AmigaDOS " Link "Glossary - AmigaDOS"}

Returns

	This function returns the length of the matching string or 0 if
	there was no match.

See Also

	@{" astcsma " Link astcsma()}, @{" stcpm " Link stcpm()}, @{" stcpma " Link stcpma()}


[ - Answer - Quote - Direct link - ]

2006-04-12, 08:59 h

gni
Posts: 1106
User
Zitat:
Flipflop:
Wenn vielleicht gleich jemand nen Ersatz-Code auf Basis
der dos.library anzubieten hat?!

Das CVS Repository von YAM auf sourceforge hatte eine astcma() Funktion für Nicht-SAS/C. Schau Dir den Code an und schreib was eigenes.
code:
#include <stdlib.h>
#include <string.h>
#include <proto/dos.h>

/* Not completely equivalent to the SAS/C version, as the returned value
   is not the same. But YAM only uses the return value as a boolean. */
int astcsma(const char *s, const char *p)
{
   int ret,len=strlen(p)*2+2;
   char *buf=malloc(len);

   if (!buf)
     return 0;
   if (ParsePatternNoCase(p, buf, len) < 0)
     ret=0;
   else
     ret=MatchPatternNoCase(buf, (STRPTR)s);
   free(buf);
   return ret;
}


[ - Answer - Quote - Direct link - ]


-1- [ - Post reply - ]


amiga-news.de Forum > Programmierung > SAS/C (a)stcsma [ - Search - New posts - Register - Login - ]


.
Masthead | Privacy policy | Netiquette | Advertising | Contact
Copyright © 1998-2024 by amiga-news.de - all rights reserved.
.