amiga-news ENGLISH VERSION
.
Links| Forum| Kommentare| News melden
.
Chat| Umfragen| Newsticker| Archiv
.

amiga-news.de Forum > Programmierung > SAS/C (a)stcsma [ - Suche - Neue Beiträge - Registrieren - Login - ]

-1- [ - Beitrag schreiben - ]

07.04.2006, 18:03 Uhr

Flipflop
Posts: 187
Nutzer
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

[ - Antworten - Zitieren - Direktlink - ]

11.04.2006, 16:36 Uhr

softwarefailure
Posts: 38
Nutzer
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()}


[ - Antworten - Zitieren - Direktlink - ]

12.04.2006, 08:59 Uhr

gni
Posts: 1106
Nutzer
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;
}


[ - Antworten - Zitieren - Direktlink - ]


-1- [ - Beitrag schreiben - ]


amiga-news.de Forum > Programmierung > SAS/C (a)stcsma [ - Suche - Neue Beiträge - Registrieren - Login - ]


.
Impressum | Datenschutzerklärung | Netiquette | Werbung | Kontakt
Copyright © 1998-2024 by amiga-news.de - alle Rechte vorbehalten.
.