Example #1
0
/*
 * Builds a filename with a complete path specifier from the environmental
 * variable PGPPATH.
 */
char *buildfilename(char *result, char *fname)
{
#ifdef MACTC5
	char const *s;
#else
    char const *s = "."; /* getenv(PGPPATH); */
#endif
    result[0] = '\0';
#ifdef MACTC5
    return(strcpy(result,fname));
#endif

    if (s && strlen(s) <= 50) {
	strcpy(result, s);
    }
#ifdef UNIX
    /* On Unix, default to $HOME/.pgp, otherwise, current directory. */
    else {
	s = getenv("HOME");
	if (s && strlen(s) <= 50) {
	    strcpy(result, s);
	    addslash(result);
	    strcat(result, ".pgp");
	}
    }
#endif				/* UNIX */

    addslash(result);
    strcat(result, fname);
    return result;
}				/* buildfilename */
Example #2
0
path *rmpthdir(path *pth, char *dir)
{
	if (strcmp("", dir) == 0) {
		return pth;
	}
	char* withslash = addslash(dir);
	path *current = pth;
	if (strcmp(current->dir, withslash) == 0) {
		path *toreturn = current->next;
		free(current->dir);
		free(current);
		free(withslash);
		return toreturn;
	}
	while (current->next != NULL) {
		if (strcmp(current->next->dir, withslash) == 0) {
			path *tmp = current->next;
			current->next = tmp->next;
			free(tmp->dir);
			free(tmp);

			free(withslash);
			return current;
		}
		current = current->next;
	}
	free(withslash);
	return pth;
}
Example #3
0
path *addpthdir(path *pth, char *dir)
{
	char *withslash = addslash(dir);
	if (hasdir( withslash, pth) == -1) {
		path *newpath = createpath(dir);
		newpath->next = pth->next;
		pth->next = newpath;
	}
	return pth;
}
Example #4
0
File: main.c Project: llxp/llxp
int main()
{
    //mysql_start();
    print_header();
    print_html_header(titel_);
    //var_copy=getenv("QUERY_STRING");
    parse_content(getdata_force("GET"), "=", "&", "POST");
    parse_content(getdata_force("POST"), "=", "&", "GET");
    //parse_content(getdata_force("POST"), "=", "&", "POST");
       // parse_content(getdata_force("POST"), "=", "&", 0);
//    printf("%s\n%s", getdata_force("GET"),getdata_force("POST"));
//char *post_query=(char*) malloc(100 * sizeof(char));
//char *get_query=(char*) malloc(strlen(default_string)*100* sizeof(char));
    //sprintf(post_query, "%s", getdata_force("POST"));
    //sprintf(get_query, "%s", getdata_force("GET"));
   // printf("%s", post_query);
    //strcpy(get_query, getdata_force("GET"));
    /*if(strcmp(_GET[0][0],"method")==0){
        if(strcmp(_GET[0][1], "normal")==0){
            if(strcmp(_GET[1][0],"action")==0){
                if(strcmp(_GET[1][1],"post")==0){

                    char *content_length = getenv("CONTENT_LENGTH");
                    if(content_length==NULL){

                        goto exit;
                    }
                    else{
                        size = (unsigned long) atoi(content_length);
                        if(size<=0){

                            goto exit;
                        }else{
                            content_post = (char *) malloc(size+1);
                            if(content_post==NULL){
                                free(content_post);
                                goto exit;
                            }*/
                            //scanf("%s", post_var);
                            //printf("%s", post_query);
                            //parse_content(post_query, "=", "&", "POST");
                            printf("<h1>!%s!!</h1>", _POST[0][1]);
                            //printf("Hallo!!!%s", _POST[0][1]);
                            //printf("%d", (int)strlen(*_POST[0]));
                           // for(a=0;a<(int)strlen(_POST[a]))
                            //for(b=0;b<(int)strlen(_POST[0][1]);b++){
                              //  stringReplace("+", "", _POST[0][1]);
                            //}
                            printf("\n%s=%s\n", _POST[0][0],_POST[0][1]);
                            add_tag("ul", "style={float:left;} id='left' class='left'");
                            addslash("ul");
                            //free(content_post);
                            //goto exit;

                        }
Example #5
0
int hasdir(char *dir, path *pth)
{
	path *crntpth = pth;
	char *withslash = addslash(dir);
	while (crntpth != NULL) {
		if (strcmp(withslash, crntpth->dir) == 0) {
			free(withslash);
			return 0;
		}
		crntpth = crntpth->next;
	}
	free(withslash);
	return -1;
}
Example #6
0
path *createpath(char *dir)
{
	path *pth;
	pth = (path *) malloc(sizeof(path));
	if (pth == NULL) {
		fprintf(stderr, "Error: Out of memory.\n");
		exit(1);
	}
	pth->next = NULL;
	pth->dir = addslash(dir);
	//printf("created path with dir = %s\n", pth->dir);

	return pth;
}
Example #7
0
/*
 * Builds a filename with a complete path specifier from the environmental
 * variable PGPPATH.
 */
char *buildFileName(char *result, const char *fname)
{
    char const *s = getenv(PGPPATH);

    result[0] = '\0';

    if (s && strlen(s) <= 50) {
        strcpy(result, s);
    }
#ifdef PGP_UNIX
    /* On Unix, default to $HOME/.pgp, otherwise, current directory. */
    else {
        s = getenv("HOME");
        if (s && strlen(s) <= 50) {
            strcpy(result, s);
            addslash(result);
            strcat(result, ".pgp");
        }
    }
#else if PGP_WIN32
    /* on Win32 (NT), try %USERPROFILE\Application Data\pgp,
       otherwise, %SYSTEMROOT\pgp directory. */
    else if ((s = getenv("USERPROFILE")) != NULL)
Example #8
0
bool Downloader::scanFtpDir(FtpDir *ftpDir, tstring destsubdir)
{
    Url url(ftpDir->url);
    url.internetOptions = internetOptions;
    
    updateFileName(url.components.lpszUrlPath);
    
    if(!url.connect(internet))
    {
        storeError();
        return false;
    }
    
    if(!FtpSetCurrentDirectory(url.connection, url.components.lpszUrlPath))
    {
        storeError();
        return false;
    }
    
    list<tstring> dirs;
    WIN32_FIND_DATA fd;

    TRACE(_T("Scanning FTP dir %s:"), ftpDir->url.c_str());
    HINTERNET handle = FtpFindFirstFile(url.connection, ftpDir->mask.c_str(), &fd, NULL, NULL);

    if(handle)
    {
        TRACE(_T("    (%s) %s"), (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _T("D") : _T("F"), fd.cFileName);
        updateFileName(tstring(fd.cFileName));

        if(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
        {
            tstring dirname(fd.cFileName);

            if(!(dirname.compare(_T(".")) == 0) && !(dirname.compare(_T("..")) == 0))
                dirs.push_back(dirname);
        }
        else
        {
            tstring fileUrl  = addslash(ftpDir->url);
            tstring fileName = addbackslash(ftpDir->destdir);
            fileUrl  += tstring(fd.cFileName);
            fileName += addbackslash(destsubdir);
            fileName += tstring(fd.cFileName);
            
            addFile(fileUrl, fileName, ((DWORDLONG)fd.nFileSizeHigh << 32) | fd.nFileSizeLow, ftpDir->compstr);
        }

        while(InternetFindNextFile(handle, &fd))
        {
            TRACE(_T("    (%s) %s"), (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _T("D") : _T("F"), fd.cFileName);
            updateFileName(tstring(fd.cFileName));

            if(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
            {
                tstring dirname(fd.cFileName);

                if(!(dirname.compare(_T(".")) == 0) && !(dirname.compare(_T("..")) == 0))
                    dirs.push_back(dirname);
            }
            else
            {
                tstring fileUrl  = addslash(ftpDir->url);
                tstring fileName = addbackslash(ftpDir->destdir);
                fileUrl  += tstring(fd.cFileName);
                fileName += addbackslash(destsubdir);
                fileName += tstring(fd.cFileName);
                
                addFile(fileUrl, fileName, ((DWORDLONG)fd.nFileSizeHigh << 32) | fd.nFileSizeLow, ftpDir->compstr);
            }
        }
    }

    url.disconnect();

    if(ftpDir->recursive && !dirs.empty())
    {
        for(list<tstring>::iterator i = dirs.begin(); i != dirs.end(); i++)
        {
            tstring dir = *i;

            tstring urlstr = addslash(ftpDir->url);
            urlstr += dir;
            FtpDir fdir(urlstr, ftpDir->mask, ftpDir->destdir, ftpDir->recursive, ftpDir->compstr);
            
            if(preserveFtpDirs)
            {
                tstring destdir(addbackslash(ftpDir->destdir));
                destdir += addbackslash(destsubdir);
                destdir += dir;
                TRACE(_T("Creating directory %s"), destdir.c_str());
                _tmkdir(destdir.c_str());

                tstring subdir = addbackslash(destsubdir);
                subdir += dir;
                scanFtpDir(&fdir, subdir);
            }
            else
                scanFtpDir(&fdir);
        }
    }

    return true;
}