void * ESGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv) { if (!ESFTPRT(u)) return NULL; if ((s == gCoreVocab->RDF_name) && (type == RDF_STRING_TYPE) && (tv)) { char *pathname, *name = NULL; int16 n,len; if (pathname = copyString(resourceID(u))) { len = strlen(pathname); if (pathname[len-1] == '/') pathname[--len] = '\0'; n = revCharSearch('/', pathname); name = unescapeURL(&pathname[n+1]); freeMem(pathname); } return(name); } else if (u->rarg1 == NULL) possiblyAccessES(rdf, u, s, inversep); return null; }
char * nativeFilename(char *filename) { char *newName = NULL, *temp; int x = 0; if (filename == NULL) return(NULL); if ((newName = unescapeURL(filename)) != NULL) { if ((temp = convertFileURLToNSPRCopaceticPath(newName)) != NULL) { temp = copyString(temp); } freeMem(newName); newName = temp; #ifdef XP_WIN if (newName != NULL) { while (newName[x] != '\0') { if (newName[x] == '/') { newName[x] = '\\'; } ++x; } } #endif } return(newName); }
DB * CallDBOpenUsingFileURL(char *fileURL, int flags,int mode, DBTYPE type, const void *openinfo) { DB *result; char *path; char *escapedPath; if (fileURL == NULL) return NULL; escapedPath = unescapeURL(fileURL); #ifdef XP_MAC path = WH_FilePlatformName(convertFileURLToNSPRCopaceticPath(fileURL)); XP_ASSERT(path != NULL); #else path = convertFileURLToNSPRCopaceticPath(escapedPath); #endif result = dbopen(path, flags, mode, type, openinfo); #ifdef XP_MAC XP_FREE(path); #endif if (escapedPath != NULL) freeMem(escapedPath); return result; }
char* MCDepFileURL (char* url) { char* furl; int32 len; char* baz = "\\"; int32 n = 0; furl = convertFileURLToNSPRCopaceticPath(unescapeURL(url)); len = strlen(furl); #ifdef XP_WIN while (n < len) { if (furl[n] == '/') furl[n] = baz[0]; n++; } #endif return furl; }
int32 CallPRDeleteFileUsingFileURL(char *fileURL) { int32 result = -1; const char *path; char *escapedPath = unescapeURL(fileURL); path = convertFileURLToNSPRCopaceticPath(escapedPath); if (path != NULL) { result = PR_Delete(path); } if (escapedPath != NULL) freeMem(escapedPath); return result; }
int32 CallPRWriteAccessFileUsingFileURL(char *fileURL) { int32 result = -1; const char *path; char *escapedPath = unescapeURL(fileURL); path = convertFileURLToNSPRCopaceticPath(escapedPath); if (path != NULL) { result = PR_Access(path, PR_ACCESS_WRITE_OK); } if (escapedPath != NULL) freeMem(escapedPath); return result; }
PRDir * CallPROpenDirUsingFileURL(char *fileURL) { PRDir* result = NULL; const char *path; char *escapedPath = unescapeURL(fileURL); path = convertFileURLToNSPRCopaceticPath(escapedPath); if (path != NULL) { result = PR_OpenDir(path); } if (escapedPath != NULL) freeMem(escapedPath); return result; }
int32 CallPRMkDirUsingFileURL(char *dirURL, int mode) { int32 result=-1; const char *path; char *escapedPath = unescapeURL(dirURL); path = convertFileURLToNSPRCopaceticPath(escapedPath); if (path != NULL) { result = PR_MkDir(path,mode); } if (escapedPath != NULL) freeMem(escapedPath); return result; }
PRFileDesc * CallPROpenUsingFileURL(char *fileURL, PRIntn flags, PRIntn mode) { PRFileDesc* result = NULL; const char *path; char *escapedPath = unescapeURL(fileURL); path = convertFileURLToNSPRCopaceticPath(escapedPath); if (path != NULL) { result = PR_Open(path, flags, mode); } if (escapedPath != NULL) freeMem(escapedPath); return result; }
void CGI::processCGIData() { QString request_method; // retrieve request method request_method = getenv("REQUEST_METHOD"); // what is the request method (POST and GET supported) if (request_method == "POST") { // determine the length of the data QString content_length_str = getenv("CONTENT_LENGTH"); int content_length = content_length_str.toInt(); // allocate a buffer to hold the query char* query_str = new char[content_length + 1]; // open the data stream Q3TextStream postStream(stdin, QIODevice::ReadOnly); // set the encoding (required for readRawBytes to work) postStream.setEncoding(Q3TextStream::Latin1); // read the data into the allocated buffer postStream.readRawBytes(query_str, content_length); // make sure to NULL terminate the string query_str[content_length] = '\0'; // store the data query_string = query_str; // delete the temporary buffer delete query_str; } else if (request_method == "GET") { query_string = getenv("QUERY_STRING"); } else query_string = ""; // if there is a query string, proces the arguments from it. if (!query_string.isEmpty()) { QString name = ""; QString value = ""; int index = 0; int oldindex = 0; // frequently used regular expressions QRegExp paramEndExp("[&;]"); QRegExp paramPlusExp("\\+"); // iterate over the string finding name/value pairs do { // find the end of the parameter name (ends at '=') index = query_string.find('=', oldindex); if (index == -1) break; // extract the name from the query string name = query_string.mid(oldindex, (index - oldindex)); // replace +'s with spaces name.replace(paramPlusExp, " "); // unescape the string name = unescapeURL(name); // the new place to search from oldindex = index + 1; // find the end of the parameter pair (ends at '&') index = query_string.find(paramEndExp, oldindex); // extract the value from the query_string if (index != -1) value = query_string.mid(oldindex, (index - oldindex)); else value = query_string.mid(oldindex, (query_string.length() - oldindex)); // replace +'s with spaces value.replace(paramPlusExp, " "); // unescape the string value = unescapeURL(value); // the new oldindex oldindex = index + 1; if (value.isNull()) value = ""; // insert the parameter into the parameter list cgiParams.append(new CGIParam(name, value)); } while (index != -1); // while not out of parameters } }
MyClip * inputOPML( int *numOfClips, FILE *fp ) { char buf[65536], *p, *q; char tmp[65536]; char *note; int num = 1000; /* 暫定 */ int cnt = 0, block = 1; MyClip *mp = NULL; MyClip *newClip_p; int rate; if ( !numOfClips ) return ( mp ); *numOfClips = 0; while ( ( p = fgets( buf, 65536 - 1, fp ) ) != NULL ) { while ( (*p == ' ') || (*p == '\t') ) p++; if ( !strncmp( p, "</body>", 7 ) || !strncmp( p, "</opml>", 7 ) ) break; if ( strncmp( p, "<outline ", 9 ) != 0 ) continue; newClip_p = allocateMyClipIfNecessary( &mp, num, &block, cnt ); if ( !newClip_p ) break; mp = newClip_p; rate = 0; note = p; /* text [必須] */ q = strstr( note, "text=\"" ); if ( !q ) continue; p = q + 6; q = strchr( p, '"' ); while ( !q ) { /* '<outline text="' の直後に改行がある場合の救済措置 */ p = fgets( buf, 65536 - 1, fp ); if ( !p ) break; while ( (*p == ' ') || (*p == '\t') ) p++; q = strchr( p, '"' ); if ( q ) note = q; } if ( !p ) break; if ( q ) { strncpy( mp[cnt].title, p, q - p ); mp[cnt].title[q - p] = '\0'; p = q + 1; // MM/Memo 形式の title を扱うための処理 rate = getEvaluation( mp[cnt].title, UTF8 ); } /* url [必須] */ q = strstr( note, "url=\"" ); if ( q ) { q += 5; p = strchr( q, '"' ); if ( p ) { strncpy( tmp, q, p - q ); tmp[p - q] = '\0'; strcpy( mp[cnt].url, unescapeURL( tmp ) ); p++; } else p = q; } /* title [必須] */ q = strstr( note, "title=\"" ); if ( q ) { q += 7; p = strchr( q, '"' ); if ( p ) { strncpy( mp[cnt].tags, q, p - q ); mp[cnt].tags[p - q] = NUL; p++; } else p = q; } /* notes [必須] */ q = strstr( note, "notes=\"" ); if ( q ) { q += 7; p = strchr( q, '"' ); if ( p ) { strncpy( mp[cnt].comment, q, p - q ); mp[cnt].comment[p - q] = '\0'; p++; } else p = q; } /* date [必須] */ q = strstr( note, "date=\"" ); if ( q ) { q += 6; p = strchr( q, '"' ); if ( p ) { strncpy( tmp, q, p - q ); tmp[p - q] = '\0'; getDateTimeFromDateString( tmp, &(mp[cnt].yyyy), &(mp[cnt].mm), &(mp[cnt].dd), &(mp[cnt].HH), &(mp[cnt].MM), &(mp[cnt].SS) ); p++; } else p = q; } /* 以下は bookey 独自拡張 */ /* evaluation [optional] */ q = strstr( note, "evaluation=\"" ); if ( q ) { q += 12; mp[cnt].evaluation = atol( q ); p = strchr( q, '"' ); if ( !p ) p = q; } if ( mp[cnt].evaluation == 0 ) if ( rate > 0 ) mp[cnt].evaluation = rate; /* rating [optional] */ q = strstr( note, "rating=\"" ); if ( q ) { q += 8; mp[cnt].rating = atol( q ); p = strchr( q, '"' ); if ( !p ) p = q; } /* affirmation [optional] */ q = strstr( note, "affirmation=\"" ); if ( q ) { q += 13; if ( !strncmpi( q, "good", 4 ) ) mp[cnt].affirmation = AFF_GOOD; else if ( !strncmpi( q, "bad", 3 ) ) mp[cnt].affirmation = AFF_BAD; p = strchr( q, '"' ); if ( !p ) p = q; } /* publication [optional] */ q = strstr( note, "publication=\"" ); if ( q ) { q += 13; if ( !strncmpi( q, "friends", 7 ) ) mp[cnt].publication = PUB_FRIENDS; else if ( !strncmpi( q, "private", 7 ) ) mp[cnt].publication = PUB_PRIVATE; p = strchr( q, '"' ); if ( !p ) p = q; } cnt++; } if ( fp == stdin ) { clearerr( fp ); } *numOfClips = cnt; return ( mp ); }