示例#1
0
文件: tr2u.c 项目: jerrylzy/CS35L
int finddup(const char* str)
{
    for ( ; *str != 0; str++)
        if (strsearch((str+1), *str))
            return 1;
    return 0;
}
示例#2
0
char *
xml_findend( char *buffer, char *tag )
{
	newstr endtag;
	char *p;

	newstr_init( &endtag );
	newstr_strcpy( &endtag, "</" );
	if ( xml_pns ) {
		newstr_strcat( &endtag, xml_pns );
		newstr_addchar( &endtag, ':' );
	}
	newstr_strcat( &endtag, tag );
	newstr_addchar( &endtag, '>' );

	p = strsearch( buffer, endtag.data );

	if ( p && *p ) {
		if ( *p ) p++;  /* skip <random_tag></end> combo */
		while ( *p && *(p-1)!='>' ) p++;
	}

	newstr_free( &endtag );
	return p;
}
示例#3
0
int main(){
	char *str = "hello dhgiwegeq";
	char *str2 = "hello moto";
	struct result res = strsearch(str, 'l');
	struct result *lista = malloc(640);

	printf("%d\n", sizeof(2));
	int i;
	
}
示例#4
0
char *
xml_findstart( char *buffer, char *tag )
{
	newstr starttag;
	char *p;

	newstr_init( &starttag );
	newstr_addchar( &starttag, '<' );
	newstr_strcat( &starttag, tag );
	newstr_addchar( &starttag, ' ' );
	p = strsearch( buffer, starttag.data );

	if ( !p ) {
		starttag.data[ starttag.len-1 ] = '>';
		p = strsearch( buffer, starttag.data );
	}

	newstr_free( &starttag );
	return p;
}
示例#5
0
static void
output_fileattach( FILE *fp, fields *info, int format_opts )
{
    newstr data;
    int i;
    newstr_init( &data );
    for ( i=0; i<info->nfields; ++i ) {
        if ( strcasecmp( info->tag[i].data, "FILEATTACH" ) ) continue;
        newstr_strcpy( &data, ":" );
        newstr_newstrcat( &data, &(info->data[i]) );
        if ( strsearch( info->data[i].data, ".pdf" ) )
            newstr_strcat( &data, ":PDF" );
        else if ( strsearch( info->data[i].data, ".html" ) )
            newstr_strcat( &data, ":HTML" );
        else newstr_strcat( &data, ":TYPE" );
        output_element( fp, "file", data.data, format_opts );
        fields_setused( info, i );
        newstr_empty( &data );
    }
    newstr_free( &data );
}
示例#6
0
static void
bibtexin_cleanref( fields *bibin, param *p )
{
	newstr *t, *d;
	int i;
	for ( i=0; i<bibin->nfields; ++i ) {
		t = &( bibin->tag[i] );
		d = &( bibin->data[i] );
		bibtex_cleandata( d, bibin, p );
		if ( !strsearch( t->data, "AUTHORS" ) ) {
			newstr_findreplace( d, "\n", " " );
			newstr_findreplace( d, "\r", " " );
		}
		else if ( !strsearch( t->data, "ABSTRACT" ) ||
		     !strsearch( t->data, "SUMMARY" ) || 
		     !strsearch( t->data, "NOTE" ) ) {
			newstr_findreplace( d, "\n", "" );
			newstr_findreplace( d, "\r", "" );
		}
	}
}
示例#7
0
int main()
{
	char *here;
	char *find_strings[] = {"abb",  "you", "not", "it", "dad", "yoo", "hoo",
		"oo", "oh", "xx", "xx", "x", "x", "field", "new", "row",
		"regime", "boom", "that", "impact", "and", "zoom", "texture",
		"magnet", "doom", "loom", "freq", "current", "phase",
		"images", 
		"appears", "phase", "conductor", "wavez", 
		"normal", "free", "termed",
		"provide", "for", "and", "struct", "about", "have",
		"proper",
		"involve",
		"describedly",
		"thats",
		"spaces",
		"circumstance",
		"the",
		"member",
		"such",
		"guide",
		"regard",
		"officers",
		"implement",
		"principalities",			      
		NULL};
	char *search_strings[] = {"cabbie", "your", "It isn't here",
		"But it is here", "hodad", "yoohoo", "yoohoo",
		"yoohoo", "yoohoo", "yoohoo", "xx", "x", ".", 
		"In recent years, the field of photonic ",
		"crystals has found new",
		"applications in the RF and microwave",
		"regime. A new type of metallic",
		"electromagnetic crystal has been", 
		"developed that is having a",
		"significant impact on the field of", 
		"antennas. It consists of a",
		"conductive surface, covered with a",
		"special texture which alters its",
		"electromagnetic properties. Made of solid",
		"metal, the structure",
		"conducts DC currents, but over a",
		"particular frequency range it does",
		"not conduct AC currents. It does not",
		"reverse the phase of reflected",
		"waves, and the effective image currents",

		"appear in-phase, rather than",
		"out-of-phase as they are on normal",
		"conductors. Furthermore, surface",
		"waves do not propagate, and instead",
		"radiate efficiently into free",
		"space. This new material, termed a",
		"high-impedance surface, provides",
		"a useful new ground plane for novel",
		"low-profile antennas and other",
		"electromagnetic structures.",
		"The recent protests about the Michigamua",
		"student organization have raised an",
		"important question as to the proper nature",
		"and scope of University involvement",
		"with student organizations. Accordingly",
		"the panel described in my Statement of",
		"February 25, 2000 that is considering the",
		"question of privileged space also will",
		"consider under what circumstances and in", 
		"what ways the University, its",
		"administrators and faculty members should",
		"be associated with such organizations",
		"and it will recommend guiding principles",
		"in this regard. The University's",
		"Executive Officers and I will then decide",
		"whether and how to implement such",
		"principles."			       
	};
	int i;

	for (i = 0; find_strings[i]; i++)
	{
		init_search(find_strings[i]);
		here = strsearch(search_strings[i]);
		printf("\"%s\" is%s in \"%s\"", find_strings[i],
				here ? "" : " not", search_strings[i]);
		if (here)
			printf(" [\"%s\"]", here);
		putchar('\n');
	}

	return 0;
}
示例#8
0
文件: adresse.c 项目: narv1/sen_ue4
int main(int argc, char *argv[])
{
    int stderr = 0;
    int opt;
    char vorn1[N], vorn2[N], nachn[N], stra[N], plz[N], ort[N], land[N], gesamt[100];
    extern char *optarg;
    extern int optind, optopt;

    while ((opt = getopt(argc, argv, "egh")) != -1) {
        switch (opt) {

        // Aufruf der Hilfe mit '-h'
        case 'h':
            printf("Dieses Programm hilft Adressen eines Kundestockes X zuverwalten, die Eingabe ist wieder mit getopt gestaltet\n\nBeschreibung:\n\nAchtung in diesen Programm dürfen keine Umlaute (ä,Ä,ö,Ö,ü,Ü) oder ein ß verwendet werden. \n\t-e\t\tEingabe der Adresse erfolgt nacheinander.\n\t\t\tReihenfolge: Vorname1, Vorname2, Nachname, Strasze, Postleitzahl, Ort, Land.\n\t-g\t\tEingabe der Adresse erfolgt in einem Satz es ist zu beachten:\n\t\t\t1) Das die Wörter entweder mit einem \",\" zu trennen sind.\n\t\t\t2) Das \"unbedingt\" die Reihenfolge einzuhalten ist.\n\n\t-h\t\tBei Programm aufruf mit \"-h\" wird die Hilfe des Programms ausgegeben.\n");
            return 0;

        // Wenn ein Falsches Argument aufgerufen wurde
        case'?':
            if (isprint (optopt)) {
                printf ("Unknown option `-%c'.\nPlease Type %s, -h for more information.\n", optopt, argv[0]);
            }
            stderr++;
            break;

        // Aufruf des Programm mit dem Argument '-e'
        case 'e':

            // Ausgabe zur Aufforderung der jeweiligen Eingabe + Eingabe des jeweiligen Elements
            printf("Bitte geben sie den Vornamen ein:\n(Falls vorhanden mit Leerezeichen oder \",\" den 2.Vornamen dahinter):\n");
            fgets(vorn1, N, stdin);
            printf("Bitte geben sie ihren Nachnamen ein:\n");
            fgets(nachn, N, stdin);
            printf("Bitte geben sie ihre Strasze ein:\n(Beispiel: Musterstrasze 1)\n");
            fgets(stra, N, stdin);
            printf("Bitte geben sie ihre Postleitzahl ein:\n");
            fgets(plz, N, stdin);
            printf("Bitte geben sie ihren Wohnort ein:\n");
            fgets(ort, N, stdin);
            printf("Bitte geben sie ihr Land ein:\n");
            fgets(land, N, stdin);

            int i, j, k = 0,  l = 0, m = 0;

            // Zur überprüfung der kommenden if-abfrage auf mehrere Vornamen
            k = strlength(vorn1, N);      // Überpfüfung der Länge des Vornamens
            char lookup[] = " ,";         // vergleichs String der Eingabe
            l = strcspn(vorn1,lookup);    // Vergleich des Vornamens mit lookup string
            // zählt den string bis zum element von lookup
            // Zerlegung der beiden Vornamen in jeweils einen seperaten
            for(i = 0; i < k; i++) {
                if(l == i) {
                    vorn1[i] = '\0';          // Falls lookup erfolgreich, beendigung des 1 Strings mit dem Nullbyte
                    i++;
                    m = 0;                    // Markierung für spätere Ausagabe
                    for( ; i < k; i++) {
                        vorn2[j] = vorn1[i];    // Sortierung des zweiten Vornamen in den zweiten String
                        j++;
                        if(k - 1 == i) {        // Abfrage zur abschließung des zweiten Strings mit dem Nullbyte
                            vorn2[j - 1] = '\0';
                            m = 1;
                        }
                    }
                }
            }
            if(m == 0) {
                i = strlength(vorn1, N);                                 // 1 Markierung
                vorn1[i - 1] = '\0';                                     // richtiges abschließen des Nullbytes auf Vornamen
            }
            //Abfrage + Ausgabe + Verlgiech (1Vor- und 2Vornamen)
            if (m == 1) {                                              // Abfragen der Markierung
                i = strlength(vorn1, N);
                k = strlength(vorn2, N);
                if(k <= i) {                                             // Sicherstellung auf Formatierung für strsearch
                    printf("\nVorname1:\t%d\t%s", i, vorn1);
                    printf("\nVorname2:\t%d\t%s\n", k, vorn2);
                    j = strsearch(vorn2, N, vorn1);                        // überprüfung auf Ähnlichkeiten
                }
                if(k > i) {                                              // Gegepart
                    printf("\nVorname1:\t%d\t%s", i, vorn1);
                    printf("\nVorname2:\t%d\t%s\n", k, vorn2);
                    j = strsearch(vorn1, N, vorn2);                        // überprüfung auf Ähnlichkeiten
                }
                if(j == -1) {                                            // Ausgabe auf Ähnlichkeit
                    printf("Die Woerter sind sich nicht aehnlich.\n");
                    m = 0;
                } else {
                    printf("Die Woerter sind sich aehnlich.\n");
                    m = 0;
                }
            }
            //Abfrage + Ausgabe + Verlgiech (Vor- und Nachnamen)
            if(m == 0) {                                               // 2 Markierung
                i = 0;
                i = strlength(vorn1, N);
                vorn1[i] = '\0';                                         // richtiges abschließen des Nullbytes auf Vornamen
                k = strlength(nachn, N);
                nachn[k - 1] = '\0';                                     // richtiges abschließen des Nullbytes auf Nachnamen
                j = 0;
                if(k <= i) {                                             // Sicherstellung auf Formatierung für strsearch
                    printf("\nVorname1:\t%d\t%s", i, vorn1);
                    printf("\nNachname:\t%d\t%s\n", k - 1, nachn);
                    j = strsearch(nachn, N, vorn1);                        // überprüfung auf Ähnlichkeiten
                }
                if(k > i) {                                              // Gegenpart
                    printf("\nVorname1:\t%d\t%s", i, vorn1);
                    printf("\nNachname:\t%d\t%s\n", k - 1, nachn);
                    j = strsearch(vorn1, N, nachn);                        // überprüfung auf Ähnlichkeiten
                }
                if(j == -1) {                                            // Ausgabe auf Ähnlichkeit
                    printf("Die Wörter sind sich nicht aehnlich.\n");
                } else {
                    printf("Die Wörter sind sich aehnlich.\n");
                }
            }
            //Ausgabe
            i = strlength(stra, N);
            stra[i - 1] = '\0';
            printf("\nStraße:\t\t%d\t%s", i - 1, stra);

            i = strlength(plz, N);
            plz[i - 1] = '\0';
            printf("\nPLZ:\t\t%d\t%s", i - 1, plz);

            i = strlength(ort, N);
            ort[i - 1] = '\0';
            printf("\nOrt:\t\t%d\t%s", i - 1, ort);

            i = strlength(land, N);
            land[i - 1] = '\0';
            printf("\nLand:\t\t%d\t%s\n", i - 1, land);
            return 0;

        /******************************/
        /* Aufruf des Programms mit   */
        /* "-g" speicherung in einen  */
        /*           String           */
        /******************************/
        case 'g':
            // Aufruf der Ausgabe + Aufforderung zu Eingabe
            printf("Bitte geben sie die gesamte Adresse ein:\n/Formatierung: Vorname1,Vorname2,Nachname,Strasze,Postleitzahl,Ort,Land\n");
            fgets(gesamt, 100, stdin);

            int i2, j2, k2 = 0, l2, m2 = 0, n2, o2, marker = 0, m3 = 0;
            char beistr[1] = ",";
            char zahlen[10] = "0123456789";
            j2 = strlength(gesamt, 100);             // Zähler für for-schleifen

            for(i2 = 0; i2 < j2; i2++) {
                if(gesamt[i2] == beistr[0]) {          // Zähler der Beistriche. Vorgabe der Formatierung
                    marker++;
                }
                if(marker == 3) {                      // Markierung. Überprüfung auf Eingabe mit 2.Vornamen
                    for(l2 = 0; l2 <= 10; l2++) {
                        if(gesamt[i2] == zahlen[l2]) {
                            m2++;
                        }
                    }
                }
                if(marker == 4) {                      // Markierung. Überprüfung auf Eingabe mit 2.Vornamen
                    for(l2 = 0; l2 <= 10; l2++) {
                        if(gesamt[i2] == zahlen[l2]) {
                            m3++;
                        }
                    }
                }
            }

            if((marker == 5 || marker == 6) && (m2 == 4 || m3 == 4)) {    // Erster Kontrolle auf Richtigkeit der Eingabe

                // Umsortierung auf einzelne Strings
                for(i2 = 0; i2 < j2; i2++) {
                    if(gesamt[i2] == beistr[0])break;
                    vorn1[i2] = gesamt[i2];
                    vorn1[i2 + 1] = '\0';
                }
                // Umsortierung auf einzelne Strings + Zweite Kontrolle auf Eingabe auf 2.Vornamen
                if(marker == 6 && m3 ==4) {
                    i2++;
                    for( ; i2 < j2; i2++) {
                        if(gesamt[i2] == beistr[0])break;
                        if(gesamt[i2] != beistr[0]) {
                            vorn2[k2] = gesamt[i2];
                            vorn2[k2 + 1] = '\0';
                            k2++;
                        }
                    }
                }
                // Umsortierung auf einzelne Strings
                k2 = 0;
                i2++;
                for( ; i2 < j2; i2++) {
                    if(gesamt[i2] == beistr[0])break;
                    if(gesamt[i2] != beistr[0]) {
                        nachn[k2] = gesamt[i2];
                        nachn[k2 + 1] = '\0';
                        k2++;
                    }
                }
                // Umsortierung auf einzelne Strings
                i2++;
                k2 = 0;
                for( ; i2 < j2; i2++) {
                    if(gesamt[i2] == beistr[0])break;
                    if(gesamt[i2] != beistr[0]) {
                        stra[k2] = gesamt[i2];
                        stra[k2 + 1] = '\0';
                        k2++;
                    }
                }
                // Umsortierung auf einzelne Strings
                i2++;
                k2 = 0;
                for( ; i2 < j2; i2++) {
                    if(gesamt[i2] == beistr[0])break;
                    if(gesamt[i2] != beistr[0]) {
                        plz[k2] = gesamt[i2];
                        plz[k2 + 1] = '\0';
                        k2++;
                    }
                }
                // Umsortierung auf einzelne Strings
                i2++;
                k2 = 0;
                for( ; i2 < j2; i2++) {
                    if(gesamt[i2] == beistr[0])break;
                    if(gesamt[i2] != beistr[0]) {
                        ort[k2] = gesamt[i2];
                        ort[k2 + 1] = '\0';
                        k2++;
                    }
                }
                // Umsortierung auf einzelne Strings
                i2++;
                k2 = 0;
                for( ; i2 < j2; i2++) {
                    if(gesamt[i2] == beistr[0])break;
                    if(gesamt[i2] != '\n') {
                        land[k2] = gesamt[i2];
                        land[k2 + 1] = '\0';
                        k2++;
                    }
                    // Bei erreichen des Nullbytes verlassen der Schleife
                    if(gesamt[i2] == '\0')break;
                }
            } else {
                // Bei Falsch Eingabe. Ausgabe
                printf("Die Postleitzahl ist auf das österreichische System gestellt 4 Zahlen oder sie haben sich nicht an die Formatierung der Eingabe gehalten.\nStarten sie das Programm neu und versuchen sie es erneut!\n");
                return 1;
            }
            //Ermittlung der Längen der einzelnen Wörter
            i2 = strlength(vorn1, N);
            j2 = strlength(nachn, N);
            k2 = strlength(stra, N);
            l2 = strlength(plz, N);
            m2 = strlength(ort, N);
            n2 = strlength(land, N);
            // Ermittlung der Länge des 2 Vornamen
            if(marker == 6) {
                o2 = strlength(vorn2, N);
            }
            // Ausgabe der Einzelstrings
            if(marker == 5) {
                printf("\n%d\t%s\n%d\t%s\n%d\t%s\n%d\t%s\n%d\t%s\n%d\t%s\n",i2 , vorn1, j2, nachn, k2, stra, l2, plz, m2, ort, n2, land);
            } else {
                printf("\n%d\t%s\n%d\t%s\n%d\t%s\n%d\t%s\n%d\t%s\n%d\t%s\n%d\t%s\n", i2, vorn1, o2, vorn2, j2,  nachn, k2, stra, l2, plz, m2, ort, n2, land);
            }
        }
        return 0;
    }
    // Ausgabe des Programms ohne Argument
    if(stderr == 0) {
        printf("This program, requires an argument.\nPlease type %s -h for more information.\n",argv[0]);
    }
    return 0;
}