Esempio n. 1
0
CString CBuildTarget::MakeOptions(const OptionsRelation Relation,
 const CString& ProjectOptions, const CString& TargetOptions)
{
 switch (Relation)
 {
  case CBuildTarget::orProject: return ProjectOptions;
  case CBuildTarget::orTarget:  return TargetOptions;
  case CBuildTarget::orTargetProject: return JoinStr(TargetOptions,ProjectOptions,' ');
  default:
  case CBuildTarget::orProjectTarget: return JoinStr(ProjectOptions,TargetOptions,' ');
 }
}
Esempio n. 2
0
char* MiniApache::GetGETVariable(char * name){
	char * varp = JoinStr(name, "=");
    int dlen = strlen(GET_data);
	int vlen = strlen(varp);
    int start = -1;
    char * sub;
    for (int i = 0; i < dlen; i++) { // Find variable
	    sub = SubStr(GET_data, i, i + vlen);
	    if (strcmp(varp, sub) == 0 && (i == 0 || GET_data[i-1] == '&')) {
 		    start = i + vlen;
 		    delete [] sub;
		    break;
	    }
	    delete [] sub;
    }
    if (start == -1) {
        start = dlen;
    }
    int end = FindChar(GET_data, '&', start, dlen);
    if (end == -1) {
        end = dlen;
    } 
    delete [] varp;
    char * retVal = SubStr(GET_data, start, end);
    return retVal; // Remember to delete [] retVal to not leak memory
}
Esempio n. 3
0
CString CBuildTarget::LibDirs(const CString& LibDirSwitch)
{
 CString result;
 for (int i = 0; i < m_LinkerDirectories.GetCount(); i++)
 {
  result = JoinStr(result,LibDirSwitch+m_LinkerDirectories[i],' ');
 }
 return result;
}
Esempio n. 4
0
CString CBuildTarget::ResDirs(const CString& IncDirSwitch)
{
 CString result;
 for (int i = 0; i < m_ResourceCompilerDirectories.GetCount(); i++)
 {
  result = JoinStr(result,IncDirSwitch+m_ResourceCompilerDirectories[i],' ');
 }
 return result;
}
Esempio n. 5
0
CString CBuildTarget::Libs(const CPlatform& Platform, const CString& LinkLibSwitch)
{
 CString result;
 for (int i = 0; i < m_LinkerLibraries.GetCount(); i++)
 {
  CString lib_name = m_LinkerLibraries[i];
  CString lib_ext = ExtractFileExt(lib_name);
  //if (lib_ext.IsEmpty()) // wrong for files with dots but without .a extension
  //if (lib_ext==AutoFileExtension(OS,CBuildTarget::ttStaticLibrary)) // a plaform may have several valid extensions
  if (Platform.IsStaticLibraryExtension(lib_ext))
  {
   result = JoinStr(result,lib_name,' ');
  }
  else
  {
   result = JoinStr(result,LinkLibSwitch+lib_name,' ');
  }
 }
 return result;
}
Esempio n. 6
0
bool MiniApache::TestIndexFile(){
	char* index = JoinStr(_storage_path, DEFAULT_INDEX_FILE);
	if (!SD.exists(index)){
		#if SERIAL_DEBUG == 1
			Serial.print("ERROR - Can't find index file!");
		#endif
		_error_status = 2;
		delete [] index;
		return false;
	}
	delete [] index;	
	return true;
}
Esempio n. 7
0
void MiniApache::ProcessRequest(){
	if (_serve_status == 3){ // Process request
		if (strcmp(request_path, "/") == 0 || strcmp(request_path, "") == 0) { // Redirect from '/' to DEFAULT_INDEX_FILE
			delete [] request_path;
			request_path = JoinStr(DEFAULT_INDEX_FILE, "");
		}
		char* file_path = JoinStr(_storage_path, request_path);
		_storageFile = SD.open(file_path);
		if (_storageFile){
			if (_storageFile.isDirectory()){ // List directory
				PrintHeader(200, "OK", "text/html", false);
				client.print("<html><head><title>");
				client.print(file_path);
				client.print("</title></head><body>List of ");
				client.print(file_path);
				client.println("<table><thead><tr><th>Name</th><th>Size</th></tr></thead><tbody><tr><td><a href=\"../\">../</a></td><td></td></tr>");
				while(true) {
					 File entry =  _storageFile.openNextFile();
					 if (!entry) break;
					 client.print("<tr><td><a href=\"");
					 client.print(entry.name());
					 if (entry.isDirectory()) client.print("/");
					 client.print("\">");
					 client.print(entry.name());
					 if (entry.isDirectory()) client.print("/");
					 client.print("</a></td><td>");
					 if (!entry.isDirectory()) {
					   client.print(entry.size(), DEC);
					   //client.print(" b");
					 }
					 client.println("</td></tr>");
					 entry.close();
				   }
				client.println("</tbody></table><hr>MiniApache</body></html>");
				_storageFile.close();
				ReportClientServed(200);
				
			} else { // Start serving file
				PrintHeader(200, "OK", GetMIMEType(file_path), true);
				_serve_status = 4;
			}
		} else { //File not found, Return 404 error
			TestIndexFile(); // Check if CD cardi is working
			PrintHeader(404, "Not Found", "text/html", true);
			client.println("<thml><hrad><title>File Not Found</title></head><body>404: File Not Found<br>");
			client.println(file_path);
			client.println("<hr>MiniApache</body></html>");
			ReportClientServed(404);
		}
		delete [] file_path;
    }
	if (_serve_status == 4){ // Read and write chunk of file
		int t;
		char T[CLIENT_CHUNK_SIZE];
		t = _storageFile.readBytes(T, CLIENT_CHUNK_SIZE);
		client.write(T, t);
		if (t < CLIENT_CHUNK_SIZE){
			ReportClientServed(200);
			_storageFile.close();
		}
	}
}
Esempio n. 8
0
Str Join(const LStr &l, const Str &del) {
  return JoinStr(l.begin(), l.end(), del);		   
}
Esempio n. 9
0
Str Join(const VStr &vec, const Str &del) {
  return JoinStr(vec.begin(), vec.end(), del);		   
}