Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
server:http
libcgic
match-lang.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File match-lang.diff of Package libcgic
diff -aur o/cgic.c n/cgic.c --- o/cgic.c 2004-11-15 17:57:59.000000000 +0100 +++ n/cgic.c 2011-07-20 21:11:11.024000066 +0200 @@ -63,7 +63,7 @@ char *cgiMultipartBoundary; char *cgiCookie; int cgiContentLength; -char *cgiAccept; +char *cgiAccept, *cgiAcceptCharset, *cgiAcceptEncoding, *cgiAcceptLanguage; char *cgiUserAgent; char *cgiReferrer; @@ -185,6 +185,9 @@ cgiGetenv(&cgiContentLengthString, "CONTENT_LENGTH"); cgiContentLength = atoi(cgiContentLengthString); cgiGetenv(&cgiAccept, "HTTP_ACCEPT"); + cgiGetenv(&cgiAcceptCharset, "HTTP_ACCEPT_CHARSET"); + cgiGetenv(&cgiAcceptEncoding, "HTTP_ACCEPT_ENCODING"); + cgiGetenv(&cgiAcceptLanguage, "HTTP_ACCEPT_LANGUAGE"); cgiGetenv(&cgiUserAgent, "HTTP_USER_AGENT"); cgiGetenv(&cgiReferrer, "HTTP_REFERER"); cgiGetenv(&cgiCookie, "HTTP_COOKIE"); @@ -1182,6 +1185,9 @@ free(cgiRemoteIdent); free(cgiContentType); free(cgiAccept); + free(cgiAcceptCharset); + free(cgiAcceptEncoding); + free(cgiAcceptLanguage); free(cgiUserAgent); free(cgiReferrer); } @@ -1194,11 +1200,11 @@ static cgiFormResultType cgiFormEntryString( cgiFormEntry *e, char *result, int max, int newlines); -static cgiFormEntry *cgiFormEntryFindFirst(char *name); +static cgiFormEntry *cgiFormEntryFindFirst(char const name []); static cgiFormEntry *cgiFormEntryFindNext(); cgiFormResultType cgiFormString( - char *name, char *result, int max) { + char const name [], char result [], int max) { cgiFormEntry *e; e = cgiFormEntryFindFirst(name); if (!e) { @@ -1209,7 +1215,7 @@ } cgiFormResultType cgiFormFileName( - char *name, char *result, int resultSpace) + char const name [], char result [], int resultSpace) { cgiFormEntry *e; int resultLen = 0; @@ -1237,7 +1243,7 @@ } cgiFormResultType cgiFormFileContentType( - char *name, char *result, int resultSpace) + char const name [], char result [], int resultSpace) { cgiFormEntry *e; int resultLen = 0; @@ -1267,7 +1273,7 @@ } cgiFormResultType cgiFormFileSize( - char *name, int *sizeP) + char const name [], int *sizeP) { cgiFormEntry *e; e = cgiFormEntryFindFirst(name); @@ -1294,7 +1300,7 @@ } cgiFile; cgiFormResultType cgiFormFileOpen( - char *name, cgiFilePtr *cfpp) + char const name [], cgiFilePtr *cfpp) { cgiFormEntry *e; cgiFilePtr cfp; @@ -1348,7 +1354,7 @@ } cgiFormResultType cgiFormStringNoNewlines( - char *name, char *result, int max) { + char const name [], char result [], int max) { cgiFormEntry *e; e = cgiFormEntryFindFirst(name); if (!e) { @@ -1359,7 +1365,7 @@ } cgiFormResultType cgiFormStringMultiple( - char *name, char ***result) { + char const name [], char ***result) { char **stringArray; cgiFormEntry *e; int i; @@ -1423,7 +1429,7 @@ } cgiFormResultType cgiFormStringSpaceNeeded( - char *name, int *result) { + char const name [], int *result) { cgiFormEntry *e; e = cgiFormEntryFindFirst(name); if (!e) { @@ -1435,7 +1441,7 @@ } static cgiFormResultType cgiFormEntryString( - cgiFormEntry *e, char *result, int max, int newlines) { + cgiFormEntry *e, char result [], int max, int newlines) { char *dp, *sp; int truncated = 0; int len = 0; @@ -1517,7 +1523,7 @@ static int cgiFirstNonspaceChar(char *s); cgiFormResultType cgiFormInteger( - char *name, int *result, int defaultV) { + char const name [], int *result, int defaultV) { cgiFormEntry *e; int ch; e = cgiFormEntryFindFirst(name); @@ -1540,7 +1546,7 @@ } cgiFormResultType cgiFormIntegerBounded( - char *name, int *result, int min, int max, int defaultV) { + char const name [], int *result, int min, int max, int defaultV) { cgiFormResultType error = cgiFormInteger(name, result, defaultV); if (error != cgiFormSuccess) { return error; @@ -1557,7 +1563,7 @@ } cgiFormResultType cgiFormDouble( - char *name, double *result, double defaultV) { + char const name [], double *result, double defaultV) { cgiFormEntry *e; int ch; e = cgiFormEntryFindFirst(name); @@ -1580,7 +1586,7 @@ } cgiFormResultType cgiFormDoubleBounded( - char *name, double *result, double min, double max, double defaultV) { + char const name [], double *result, double min, double max, double defaultV) { cgiFormResultType error = cgiFormDouble(name, result, defaultV); if (error != cgiFormSuccess) { return error; @@ -1597,7 +1603,7 @@ } cgiFormResultType cgiFormSelectSingle( - char *name, char **choicesText, int choicesTotal, + char const name [], char const * const choicesText [], int choicesTotal, int *result, int defaultV) { cgiFormEntry *e; @@ -1633,7 +1639,7 @@ } cgiFormResultType cgiFormSelectMultiple( - char *name, char **choicesText, int choicesTotal, + char const name [], char const *const choicesText [], int choicesTotal, int *result, int *invalid) { cgiFormEntry *e; @@ -1673,7 +1679,7 @@ } cgiFormResultType cgiFormCheckboxSingle( - char *name) + char const name []) { cgiFormEntry *e; e = cgiFormEntryFindFirst(name); @@ -1684,7 +1690,7 @@ } extern cgiFormResultType cgiFormCheckboxMultiple( - char *name, char **valuesText, int valuesTotal, + char const name [], char const *const valuesText [], int valuesTotal, int *result, int *invalid) { /* Implementation is identical to cgiFormSelectMultiple. */ @@ -1693,8 +1699,8 @@ } cgiFormResultType cgiFormRadio( - char *name, - char **valuesText, int valuesTotal, int *result, int defaultV) + char const name [], + char const *const valuesText [], int valuesTotal, int *result, int defaultV) { /* Implementation is identical to cgiFormSelectSingle. */ return cgiFormSelectSingle(name, valuesText, valuesTotal, @@ -1702,13 +1708,13 @@ } cgiFormResultType cgiCookieString( - char *name, - char *value, + char const name [], + char value [], int space) { char *p = cgiCookie; while (*p) { - char *n = name; + char const *n = name; /* 2.02: if cgiCookie is exactly equal to name, this can cause an overrun. The server probably wouldn't allow it, since a name without values makes no sense @@ -1775,7 +1781,7 @@ } cgiFormResultType cgiCookieInteger( - char *name, + char const name [], int *result, int defaultV) { @@ -1790,8 +1796,8 @@ return r; } -void cgiHeaderCookieSetInteger(char *name, int value, int secondsToLive, - char *path, char *domain) +void cgiHeaderCookieSetInteger(char const name [], int value, int secondsToLive, + char const path [], char const domain []) { char svalue[256]; sprintf(svalue, "%d", value); @@ -1823,8 +1829,8 @@ "Dec" }; -void cgiHeaderCookieSetString(char *name, char *value, int secondsToLive, - char *path, char *domain) +void cgiHeaderCookieSetString(char const name [], char const value [], int secondsToLive, + char const path [], char const domain []) { /* cgic 2.02: simpler and more widely compatible implementation. Thanks to Chunfu Lai. @@ -1855,15 +1861,15 @@ path); } -void cgiHeaderLocation(char *redirectUrl) { +void cgiHeaderLocation(char const redirectUrl []) { fprintf(cgiOut, "Location: %s\r\n\r\n", redirectUrl); } -void cgiHeaderStatus(int status, char *statusMessage) { +void cgiHeaderStatus(int status, char const statusMessage []) { fprintf(cgiOut, "Status: %d %s\r\n\r\n", status, statusMessage); } -void cgiHeaderContentType(char *mimeType) { +void cgiHeaderContentType(char const mimeType []) { fprintf(cgiOut, "Content-type: %s\r\n\r\n", mimeType); } @@ -1873,7 +1879,7 @@ #define CGIC_VERSION "2.0" -cgiEnvironmentResultType cgiWriteEnvironment(char *filename) { +cgiEnvironmentResultType cgiWriteEnvironment(char const filename []) { FILE *out; cgiFormEntry *e; /* Be sure to open in binary mode */ @@ -1936,6 +1942,15 @@ if (!cgiWriteString(out, cgiAccept)) { goto error; } + if (!cgiWriteString(out, cgiAcceptCharset)) { + goto error; + } + if (!cgiWriteString(out, cgiAcceptEncoding)) { + goto error; + } + if (!cgiWriteString(out, cgiAcceptLanguage)) { + goto error; + } if (!cgiWriteString(out, cgiUserAgent)) { goto error; } @@ -2023,7 +2038,7 @@ static int cgiReadInt(FILE *out, int *i); -cgiEnvironmentResultType cgiReadEnvironment(char *filename) { +cgiEnvironmentResultType cgiReadEnvironment(char const filename []) { FILE *in; cgiFormEntry *e = 0, *p; char *version; @@ -2098,6 +2113,15 @@ if (!cgiReadString(in, &cgiAccept)) { goto error; } + if (!cgiReadString(in, &cgiAcceptCharset)) { + goto error; + } + if (!cgiReadString(in, &cgiAcceptEncoding)) { + goto error; + } + if (!cgiReadString(in, &cgiAcceptLanguage)) { + goto error; + } if (!cgiReadString(in, &cgiUserAgent)) { goto error; } @@ -2301,10 +2325,10 @@ } } -static char *cgiFindTarget = 0; +static char const *cgiFindTarget = 0; static cgiFormEntry *cgiFindPos = 0; -static cgiFormEntry *cgiFormEntryFindFirst(char *name) { +static cgiFormEntry *cgiFormEntryFindFirst(char const name []) { cgiFindTarget = name; cgiFindPos = cgiFormEntryFirst; return cgiFormEntryFindNext(); @@ -2463,7 +2487,7 @@ } \ } -cgiFormResultType cgiHtmlEscapeData(char *data, int len) +cgiFormResultType cgiHtmlEscapeData(char const data [], int len) { while (len--) { if (*data == '<') { @@ -2490,7 +2514,7 @@ return cgiFormSuccess; } -cgiFormResultType cgiHtmlEscape(char *s) +cgiFormResultType cgiHtmlEscape(char const s []) { return cgiHtmlEscapeData(s, (int) strlen(s)); } @@ -2501,7 +2525,7 @@ 'data' is not null-terminated; 'len' is the number of bytes in 'data'. Returns cgiFormIO in the event of error, cgiFormSuccess otherwise. */ -cgiFormResultType cgiValueEscapeData(char *data, int len) +cgiFormResultType cgiValueEscapeData(char const data [], int len) { while (len--) { if (*data == '\"') { @@ -2518,9 +2542,9 @@ return cgiFormSuccess; } -cgiFormResultType cgiValueEscape(char *s) +cgiFormResultType cgiValueEscape(char const s []) { - return cgiValueEscapeData(s, (int) strlen(s)); + return cgiValueEscapeData(s, strlen(s)); } diff -aur o/cgic.h n/cgic.h --- o/cgic.h 2004-04-22 22:49:47.000000000 +0200 +++ n/cgic.h 2011-07-20 20:27:38.247999936 +0200 @@ -38,6 +38,7 @@ extern char *cgiAccept; extern char *cgiUserAgent; extern char *cgiReferrer; +extern char *cgiAcceptCharset, *cgiAcceptEncoding, *cgiAcceptLanguage; /* Cookies as sent to the server. You can also get them individually, or as a string array; see the documentation. */ @@ -91,75 +92,75 @@ cgic.html for documentation. */ extern cgiFormResultType cgiFormString( - char *name, char *result, int max); + char const name [], char result [], int max); extern cgiFormResultType cgiFormStringNoNewlines( - char *name, char *result, int max); + char const name [], char result [], int max); extern cgiFormResultType cgiFormStringSpaceNeeded( - char *name, int *length); + char const name [], int *length); extern cgiFormResultType cgiFormStringMultiple( - char *name, char ***ptrToStringArray); + char const name [], char ***ptrToStringArray); extern void cgiStringArrayFree(char **stringArray); extern cgiFormResultType cgiFormInteger( - char *name, int *result, int defaultV); + char const name [], int *result, int defaultV); extern cgiFormResultType cgiFormIntegerBounded( - char *name, int *result, int min, int max, int defaultV); + char const name [], int *result, int min, int max, int defaultV); extern cgiFormResultType cgiFormDouble( - char *name, double *result, double defaultV); + char const name [], double *result, double defaultV); extern cgiFormResultType cgiFormDoubleBounded( - char *name, double *result, double min, double max, double defaultV); + char const name[], double *result, double min, double max, double defaultV); extern cgiFormResultType cgiFormSelectSingle( - char *name, char **choicesText, int choicesTotal, + char const name [], char const *const choicesText [], int choicesTotal, int *result, int defaultV); extern cgiFormResultType cgiFormSelectMultiple( - char *name, char **choicesText, int choicesTotal, + char const name [], char const *const choicesText [], int choicesTotal, int *result, int *invalid); /* Just an alias; users have asked for this */ #define cgiFormSubmitClicked cgiFormCheckboxSingle extern cgiFormResultType cgiFormCheckboxSingle( - char *name); + char const name []); extern cgiFormResultType cgiFormCheckboxMultiple( - char *name, char **valuesText, int valuesTotal, + char const name [], char const *const valuesText [], int valuesTotal, int *result, int *invalid); extern cgiFormResultType cgiFormRadio( - char *name, char **valuesText, int valuesTotal, + char const name [], char const *const valuesText [], int valuesTotal, int *result, int defaultV); /* The paths returned by this function are the original names of files as reported by the uploading web browser and shoult NOT be blindly assumed to be "safe" names for server-side use! */ extern cgiFormResultType cgiFormFileName( - char *name, char *result, int max); + char const name [], char *result, int max); /* The content type of the uploaded file, as reported by the browser. It should NOT be assumed that browsers will never falsify such information. */ extern cgiFormResultType cgiFormFileContentType( - char *name, char *result, int max); + char const name [], char *result, int max); extern cgiFormResultType cgiFormFileSize( - char *name, int *sizeP); + char const name [], int *sizeP); typedef struct cgiFileStruct *cgiFilePtr; extern cgiFormResultType cgiFormFileOpen( - char *name, cgiFilePtr *cfpp); + char const name [], cgiFilePtr *cfpp); extern cgiFormResultType cgiFormFileRead( cgiFilePtr cfp, char *buffer, int bufferSize, int *gotP); @@ -168,10 +169,10 @@ cgiFilePtr cfp); extern cgiFormResultType cgiCookieString( - char *name, char *result, int max); + char const name [], char *result, int max); extern cgiFormResultType cgiCookieInteger( - char *name, int *result, int defaultV); + char const name [], int *result, int defaultV); cgiFormResultType cgiCookies( char ***ptrToStringArray); @@ -179,13 +180,18 @@ /* path can be null or empty in which case a path of / (entire site) is set. domain can be a single web site; if it is an entire domain, such as 'boutell.com', it should begin with a dot: '.boutell.com' */ -extern void cgiHeaderCookieSetString(char *name, char *value, - int secondsToLive, char *path, char *domain); -extern void cgiHeaderCookieSetInteger(char *name, int value, - int secondsToLive, char *path, char *domain); -extern void cgiHeaderLocation(char *redirectUrl); -extern void cgiHeaderStatus(int status, char *statusMessage); -extern void cgiHeaderContentType(char *mimeType); +extern void cgiHeaderCookieSetString(char const name [], char const value [], + int secondsToLive, char const path [], char const domain []); +extern void cgiHeaderCookieSetInteger(char const name [], int value, + int secondsToLive, char const path [], char const domain []); +extern void cgiHeaderLocation(char const redirectUrl []); +extern void cgiHeaderStatus(int status, char const statusMessage []); +extern void cgiHeaderContentType(char const mimeType []); + +struct lang_pref { char const *lp_lang; float lp_pref; }; +struct lang_pref_enum { char *lpe_next; struct lang_pref lpe_lp; }; + +extern void cgiMatchLanguage (struct lang_pref_enum *p_lpe, struct lang_pref const *const p_prov [02]); typedef enum { cgiEnvironmentIO, @@ -194,8 +200,8 @@ cgiEnvironmentWrongVersion } cgiEnvironmentResultType; -extern cgiEnvironmentResultType cgiWriteEnvironment(char *filename); -extern cgiEnvironmentResultType cgiReadEnvironment(char *filename); +extern cgiEnvironmentResultType cgiWriteEnvironment(char const filename []); +extern cgiEnvironmentResultType cgiReadEnvironment(char const filename []); extern int cgiMain(); @@ -205,20 +211,20 @@ /* Output string with the <, &, and > characters HTML-escaped. 's' is null-terminated. Returns cgiFormIO in the event of error, cgiFormSuccess otherwise. */ -cgiFormResultType cgiHtmlEscape(char *s); +cgiFormResultType cgiHtmlEscape(char const s []); /* Output data with the <, &, and > characters HTML-escaped. 'data' is not null-terminated; 'len' is the number of bytes in 'data'. Returns cgiFormIO in the event of error, cgiFormSuccess otherwise. */ -cgiFormResultType cgiHtmlEscapeData(char *data, int len); +cgiFormResultType cgiHtmlEscapeData(char const data [], int len); /* Output string with the " character HTML-escaped, and no other characters escaped. This is useful when outputting the contents of a tag attribute such as 'href' or 'src'. 's' is null-terminated. Returns cgiFormIO in the event of error, cgiFormSuccess otherwise. */ -cgiFormResultType cgiValueEscape(char *s); +cgiFormResultType cgiValueEscape(char const s []); /* Output data with the " character HTML-escaped, and no other characters escaped. This is useful when outputting @@ -226,7 +232,7 @@ 'data' is not null-terminated; 'len' is the number of bytes in 'data'. Returns cgiFormIO in the event of error, cgiFormSuccess otherwise. */ -cgiFormResultType cgiValueEscapeData(char *data, int len); +cgiFormResultType cgiValueEscapeData(char const data [], int len); #endif /* CGI_C */ diff -aur o/Makefile n/Makefile --- o/Makefile 2004-04-22 22:49:47.000000000 +0200 +++ n/Makefile 2011-07-20 21:15:12.555000066 +0200 @@ -1,29 +1,44 @@ CFLAGS=-g -Wall -CC=gcc -AR=ar -RANLIB=ranlib -LIBS=-L./ -lcgic +prefix=/usr/local +libdir=$(prefix)/lib +# <URL: https://savannah.gnu.org/support/index.php?107736 > +RANLIB = ranlib +INSTALL = install +INSTALL_DATA = $(INSTALL) -m=r +includedir=$(prefix)/include -all: libcgic.a cgictest.cgi capture +all: libcgic.a cgictest.cgi capture testvars.cgi install: libcgic.a - cp libcgic.a /usr/local/lib - cp cgic.h /usr/local/include - @echo libcgic.a is in /usr/local/lib. cgic.h is in /usr/local/include. - -libcgic.a: cgic.o cgic.h - rm -f libcgic.a - $(AR) rc libcgic.a cgic.o - $(RANLIB) libcgic.a + $(INSTALL) -d '$(DESTDIR)$(libdir)' '$(DESTDIR)$(includedir)' + $(INSTALL_DATA) '-t$(DESTDIR)$(libdir)' libcgic.a + $(INSTALL_DATA) '-t$(DESTDIR)$(includedir)' cgic.h + @echo '$< is in $(libdir). cgic.h is in $(includedir).' + +libcgic.a: libcgic.a(cgic.o) libcgic.a(langpref.o) + $(RANLIB) $@ + +cgic.o: cgic.c cgic.h + +langpref.o: langpref.c langcodes.c cgic.h + +langcodes.c: + @{ $(foreach lang, $(shell locale -a | grep '^[a-z][a-z]*_[A-Z][A-Z]*$$'), \ + echo ',"$(lang)"' && LANG=$(lang) locale -k charmap && ) true; } | sed>$@ -e 's/^charmap="/"./' #mingw32 and cygwin users: replace .cgi with .exe -cgictest.cgi: cgictest.o libcgic.a - gcc cgictest.o -o cgictest.cgi ${LIBS} +cgictest.cgi: cgictest + ln -Tf $< $@ + +testvars.cgi: testvars + ln -Tf $< $@ +cgictest: cgictest.o libcgic.a +testvars: testvars.o libcgic.a capture: capture.o libcgic.a - gcc capture.o -o capture ${LIBS} clean: - rm -f *.o *.a cgictest.cgi capture + $(RM) *.o *.a +.PHONY: all install clean
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor