示例#1
0
/** @brief Parse a uri
 *
 *  Check if the given uri points to a static file or a cgi script. The
 *  path to the static file or cgi path is stored in buf. When the uri
 *  points to a cgi script, the query string is stored in req->query.
 */
static void parse_uri(http_request_t* req, char* uri) {
    char *cgi_head = "/cgi/";
    char *query_start;

    query_start = strchr(uri, '?');
    if (query_start == NULL) {      // No query string
        strcpy(req->uri, uri);
        req->query[0] = '\0';
    } else {                // With query string
        strncpy(req->uri, uri, query_start - uri);
        req->uri[query_start - uri] = '\0';
        strcpy(req->query, query_start + 1);
    }

    if (startwith(uri, cgi_head)) {     // Cgi?
        req->is_cgi = 1;
        strcpy(req->path, req->uri + 4);
    } else {
        req->is_cgi = 0;
    }
}
示例#2
0
MinutiaRawSet minutiarawset_load(const char* const filepath, bool *success) {
  MinutiaRawSet set;
  FILE *file = fopen(filepath, "r");

  if (file) {
    char buffer[2048] = {'\0'};

    set.size = -1;
    while (fgets(buffer, 2048, file) != NULL) {
      /** printf("%s", buffer); */
      if (!startwith(buffer, "--")) {
        if (set.size < 0) {
          set.size = atoi(buffer);
          set.set = calloc(set.size, sizeof(MinutiaeRaw));
        } else if (strlen(buffer) >= 3){
          // TODO need to implement reading orientation
          int num = 0, x = 0, y = 0;
          sscanf(buffer, "p%d = (%d,%d)\n", &num, &x, &y);
          set.set[num-1] = minutiaeraw_create(x, y, 0);
        }
      }
      memset(buffer, '\0', 2048);
    }

    if (file)
      fclose(file);
    *success = 1;
    return set;
  } else {
#ifdef DEBUG
    printf("ERROR: Fail to open %s", filepath);
#endif
    *success = 0;
    return minutiarawset_create_empty();
  }
}
示例#3
0
/* { dg-do compile } */
/* { dg-options "-fgimple" } */

void __GIMPLE (startwith ("ccp1")) foo ()
{
  return;
}
示例#4
0
int w_sip_check(msg_t *_m, char *param1, char *param2)
{

        int ret = -1;
        int intval = 0;
        
        
        if(!strncmp("method", param1, strlen("method")))
        {                     
             if(param2 != NULL && _m->sip.methodString.s && _m->sip.methodString.len > 0
                 && !strncmp(_m->sip.methodString.s, param2, strlen(param2)))
             {             
                    ret = 1;             
             }
        } 
        else if(!strncmp("rmethod", param1, strlen("rmethod")))
        {                     
             if(param2 != NULL && _m->sip.cSeqMethodString.s && _m->sip.cSeqMethodString.len > 0
                 && !strncmp(_m->sip.cSeqMethodString.s, param2, strlen(param2)))
             {             
                    ret = 1;             
             }             
        }
        else if(!strncmp("from_user_suffix", param1, strlen("from_user_suffix")))
        {                     
             if(endswith(&_m->sip.fromUser, param2))
             {             
                    ret = 1;             
             }                          
        }
        else if(!strncmp("to_user_suffix", param1, strlen("to_user_suffix")))
        {                     
             if(endswith(&_m->sip.toUser, param2))
             {             
                    ret = 1;             
             }                          
        }
        else if(!strncmp("from_user_prefix", param1, strlen("from_user_prefix")))
        {                     
             if(startwith(&_m->sip.fromUser, param2))
             {             
                    ret = 1;             
             }                          
        }
        else if(!strncmp("to_user_prefix", param1, strlen("to_user_prefix")))
        {                     
             if(startwith(&_m->sip.toUser, param2))
             {             
                    ret = 1;             
             }                          
        }       
        else if(!strncmp("response", param1, strlen("response")))
        {                   
             if(param2 != NULL) intval = atoi(param2);                               
             if(_m->sip.responseCode ==  intval) ret = 1;
        }
        else if(!strncmp("response_gt", param1, strlen("response_gt")))
        {                   
             if(param2 != NULL) intval = atoi(param2);                               
             if(_m->sip.responseCode >=  intval) ret = 1;
        }
        else if(!strncmp("response_lt", param1, strlen("response_lt")))
        {                   
             if(param2 != NULL) intval = atoi(param2);                               
             if(_m->sip.responseCode <=  intval) ret = 1;
        }
        else {
            LERR("unknown variable [%s]\n", param1);
        }
                        
        return ret;
}