Example #1
0
void
HExtensionSet::Init()
{
		// clear the contents
	HExtensionSet e;
	swap(e);

		// and add the default pattern
	push_back(HFileExt("Text files", "*.txt;*.text"));
	push_back(HFileExt("All files", "*"));
}
Example #2
0
void
HExtensionSet::Init()
{
    // clear the contents
    HExtensionSet e;
    swap(e);

#if MINI_H_LIB
    // and add the default pattern
    push_back(HFileExt("Text files", "*.txt;*.text"));
    push_back(HFileExt("All files", "*"));
#else
    // and add the default pattern
    push_back(HFileExt(HStrings::GetIndString(7000, 0), "*.txt;*.text"));
    push_back(HFileExt(HStrings::GetIndString(7000, 1), "*"));
#endif
}
Example #3
0
static pei *HFileElab(const char *url, const char *file, size_t len, const char *range, const char *ct, const pei *lpei)
{
    long i, j, k, add;
    pei *ppei, *new;
    unsigned long bstart, bend, bdim;
    char *file_name, *tmp;
    FILE *fp, *fpr;
    size_t rd;
    bool complete;
    pei_component *cmpn;
    file_part *parts;
    long parts_dim;
    struct stat file_st;

    ppei = NULL;
    add = -1;
    
    /* reseacrh file */
    for (i=0; i!=list_dim; i++) {
        if (strcmp(url, list[i].url) == 0) {
            break;
        }
        else if (add == -1 && list[i].url[0] == '\0') {
            add = i;
        }
    }
    if (range != NULL) {
        sscanf(range, "%lu-%lu/%lu", &bstart, &bend, &bdim);
        bend = bstart+len-1;
    }
    else {
        LogPrintfPei(LV_DEBUG, lpei, "No range");
        bstart = 0;
        bend = bstart+len-1;
        bdim = len + 1; /* in this way the file is not completed (see comp_note) */
    }
    if (i == list_dim) {
        /* new file */
        if (add == -1) {
            add = list_dim;
            if (HFileExt() == -1) {
                LogPrintf(LV_ERROR, "Unable to extend file manager table!");
                return NULL;
            }
        }
        /* insert basic data */
        strcpy(list[add].url, url);
        sprintf(list[add].file, "%s/%s/httpfile_%lu_%p_%li", ProtTmpDir(), HTTPFILE_TMP_DIR, time(NULL), list, incr);
        sprintf(list[add].part_list, "%s/%s/httpfile_part_%lu_%p_%li", ProtTmpDir(), HTTPFILE_TMP_DIR, time(NULL), file, incr++);
        LogPrintf(LV_DEBUG, "File(%i): %s", bdim, list[add].part_list);
        if (ct != NULL) {
            sprintf(list[add].content_type, "%s", ct);
        }
        
        list[add].range = FALSE;
        fp = fopen(list[add].file, "w");
        if (fp != NULL) {
            tmp = xmalloc(HTTPFILE_FILE_DIM);
            memset(tmp, 0, HTTPFILE_FILE_DIM);
            for (j=0; j!=(long)(bdim/HTTPFILE_FILE_DIM); j++) {
                fwrite(tmp, 1, HTTPFILE_FILE_DIM, fp);
            }
            fwrite(tmp, 1, (bdim%HTTPFILE_FILE_DIM), fp);
            fclose(fp);
            xfree(tmp);
        }
        file_name = strrchr(url, '/');
        if (file_name == NULL) {
            file_name = strrchr(url, '\\');
        }
        if (file_name == NULL) {
            strcpy(list[add].file_name, url);
        }
        else {
            strcpy(list[add].file_name, file_name+1);
        }
        list[add].dim = bdim;
        list[add].len = 0;
        list[add].cnt = 0;
        /* create a PEI */
        PeiNew(&new, prot_id);
        list[add].ppei = new;
        PeiSetReturn(new, TRUE);
        PeiCapTime(new, lpei->time_cap);
        PeiMarker(new, lpei->serial);
        PeiStackFlow(new, lpei->stack);
        /* url */
        PeiNewComponent(&cmpn, pei_url_id);
        PeiCompCapTime(cmpn, lpei->time_cap);
        PeiCompAddStingBuff(cmpn, url);
        PeiAddComponent(new, cmpn);
        /* content type */
        if (ct != NULL) {
            PeiNewComponent(&cmpn, pei_content_type);
            PeiCompCapTime(cmpn, lpei->time_cap);
            PeiCompAddStingBuff(cmpn, ct);
            PeiAddComponent(new, cmpn);
        }
        
        i = add;
    }