Ejemplo n.º 1
0
int sysinfo_req(void)
{
    INPUT *input = CGI_INIT();
    INPUT *tmp;

    if ((tmp = CGI_Find_Parameter(input, "appsjson"))) {
        FCGI_LOG("appsjson = %s\n", tmp->val);
    }

    if ((tmp = CGI_Find_Parameter(input, "sid")))
        FCGI_LOG("sid = %s\n", tmp->val);

    Sysinfo_To_JSON(2);
    CGI_RELEASE(input);
    return 0;
}
Ejemplo n.º 2
0
int qsync_prepare(void)
{
    INPUT *input = CGI_INIT();
    INPUT *tmp;
    if ((tmp=CGI_Find_Parameter(input, "func"))!=NULL){
        /* Here we do about other feature
        if( _session_auth(input) == -1)
            return -1;
        if (!strcmp(tmp->val, "qbox_get_max_log")){
            Start_JSON();
            op_qbox_get_max_log(input);
        }
        */
    }else if((tmp=CGI_Find_Parameter(input, "user")) != NULL){
        // Start_JSON();
        op_qbox_get_nas_uid(input);
    }

    CGI_RELEASE(input);
    return 0;
}
Ejemplo n.º 3
0
Archivo: ej.c Proyecto: jhbsz/LC4
void
do_ej(char *file, INPUT *input, ...)
{
    lang_construct_translator(LANG_MAP_FILE, nvram_safe_get("lang"));
    inital_prod();

    FILE *fp;
    char http_folder[128]={0}, pattern[512]={0};
    char *asp = NULL, *func = NULL, *end = NULL;
    int c, len = 0;

#define DO_EJ_PARA_MAX  8

    char paras[DO_EJ_PARA_MAX][SHORT_BUF_LEN];
    int i=0;
    va_list ap;
    char *para;

    if(!input) input = CGI_INIT();
    strcpy(http_folder, "/tmp/mnt/");
    strcat(http_folder, file);

    va_start(ap, input);
    para = va_arg(ap, char *);
    while (para && *para) {
        strcpy(paras[i], para);
        i++;
        if (i >= DO_EJ_PARA_MAX) {
            break;
        }
        para = va_arg(ap, char *);
    }

    fp = fopen(http_folder, "r");
    if( fp!=NULL ) {
        while ((c = getc(fp)) != EOF) {
            if (c == '$') {
                c = getc(fp);
                if (c == EOF) {
                    break;
                }
                if ((c - '0') < i && c - '0' >= 0) {
                    /* $0 ~ $i */
                    strcpy(&pattern[len], paras[c - '0']);
                    len += strlen(paras[c - '0']);
                } 
                else {
                    /* Not what we want to replace. */
                    sprintf(&pattern[len], "$%c", c);
                    len += 2;
                }
                pattern[len] = '\0';
                continue;
            }
            /* Add to pattern space */
            pattern[len++] = c;
            pattern[len] = '\0';
            if (!asp && !strncmp(pattern, "<%", len)) {
                if (len == 2)
                    asp = pattern + 2;
                continue;
            }

            if (asp) {
                if (unqstrstr(asp, "%>")) {
                    /* The iterator could be ended before the string "%>". */
                    for (func = asp; func < &pattern[len - 3]; func = end) {
                        /* Skip initial whitespace */
                        for (; isspace((int) *func); func++);
                            if (!(end = unqstrstr(func, ";")))
                                break;
                            *end++ = '\0';
                            call(func, input);
                    }
                    asp = NULL;
                    len = 0;
                }
                continue;
            }
            len = 0;
            //if(!strcmp(pattern,"\n")) {
            if((c == '\n') || (c == '\r')) {
                if(!pattern_is_newline) {
                    printf("%s", pattern);
                }
                pattern_is_newline = 1;
            } 
            else {
                pattern_is_newline = 0;
                printf("%s", pattern);
            }

        }
        fclose(fp);
    }
}