Ejemplo n.º 1
0
void l_graphics_shader_register(lua_State *state) {
  moduleData.currentShaderRef = LUA_NOREF;
  l_tools_registerFuncsInModule(state, "graphics", shaderFreeFuncs);
  moduleData.shaderMT  = l_tools_makeTypeMetatable(state, shaderMetatableFuncs);

  slre_compile(&moduleData.fragmentSingleShaderDetectRegex, fragmentSingleShaderDetectRegexSrc);
  slre_compile(&moduleData.vertexShaderDetectRegex, vertexShaderDetectRegexSrc);
}
Ejemplo n.º 2
0
static int match_entry(ENTRY *ep, int flag,
		 int argc, char * const argv[])
{
	int arg;
	void *priv = NULL;

	for (arg = 0; arg < argc; ++arg) {
#ifdef CONFIG_REGEX
		struct slre slre;

		if (slre_compile(&slre, argv[arg]) == 0) {
			printf("Error compiling regex: %s\n", slre.err_str);
			return 0;
		}

		priv = (void *)&slre;
#endif
		if (flag & H_MATCH_KEY) {
			if (match_string(flag, ep->key, argv[arg], priv))
				return 1;
		}
		if (flag & H_MATCH_DATA) {
			if (match_string(flag, ep->data, argv[arg], priv))
				return 1;
		}
	}
	return 0;
}
Ejemplo n.º 3
0
Archivo: regex.c Proyecto: CoryXie/v7
V7_PRIVATE val_t Regex_ctor(struct v7 *v7, val_t this_obj, val_t args) {
  long argnum = v7_array_length(v7, args);
  if (argnum > 0) {
    val_t ro = to_string(v7, v7_array_get(v7, args, 0));
    size_t re_len, flags_len = 0;
    const char *re = v7_to_string(v7, &ro, &re_len), *flags = NULL;
    struct slre_prog *p = NULL;
    struct v7_regexp *rp;

    (void) this_obj;
    if (argnum > 1) {
      val_t fl = to_string(v7, v7_array_get(v7, args, 1));
      flags = v7_to_string(v7, &fl, &flags_len);
    }
    if (slre_compile(re, re_len, flags, flags_len, &p, 1) != SLRE_OK ||
        p == NULL) {
      throw_exception(v7, TYPE_ERROR, "Invalid regex");
      return v7_create_undefined();
    } else {
      rp = (struct v7_regexp *) malloc(sizeof(*rp));
      rp->regexp_string = v7_create_string(v7, re, re_len, 1);
      rp->compiled_regexp = p;
      rp->lastIndex = 0;

      return v7_pointer_to_value(rp) | V7_TAG_REGEXP;
    }
  }
  return v7_create_regexp(v7, "(?:)", 4, NULL, 0);
}
Ejemplo n.º 4
0
zrex_t *
zrex_new (const char *expression)
{
    zrex_t *self = (zrex_t *) zmalloc (sizeof (zrex_t));
    assert (self);
    self->strerror = "No error";
    if (expression) {
        //  Returns 1 on success, 0 on failure
        self->valid = (slre_compile (&self->slre, expression) == 1);
        if (!self->valid)
            self->strerror = self->slre.err_str;
        assert (self->slre.num_caps < MAX_HITS);
    }
    return self;
}
Ejemplo n.º 5
0
int re_match( int nPossCaptures, struct cap* captures, char* mExpression, char* mString )
{
	struct slre	slre;
	int len    = strlen(mString);
	init_captures(nPossCaptures, captures);
	
	if (!slre_compile(&slre, mExpression )) {
		printf("Error compiling RE: %s\n", slre.err_str);	
		return 0;		
	}
	else if (slre_match(&slre, mString, len, captures)) {
		return 1;
	} 
	else 
		return 0;
}
Ejemplo n.º 6
0
bool
zrex_eq (zrex_t *self, const char *text, const char *expression)
{
    assert (self);
    assert (text);
    assert (expression);

    //  Compile the new expression
    self->valid = (slre_compile (&self->slre, expression) == 1);
    if (!self->valid)
        self->strerror = self->slre.err_str;
    assert (self->slre.num_caps < MAX_HITS);

    //  zrex_matches takes care of the rest for us
    if (self->valid)
        return zrex_matches (self, text);
    else
        return false;
}
Ejemplo n.º 7
0
ortc_context* ortc_create_context(void){
  ortc_context *context = (ortc_context*)malloc(sizeof(ortc_context));
  if(context == NULL){
    fprintf(stderr, "malloc ortc_context failed\n");
    exit(EXIT_FAILURE);
  } 
  context->appKey = NULL;
  context->authToken = NULL;
  context->metadata = "";
  context->announcementSubChannel = "";
  _ortc_random_string(context->sessionId, 17);
  context->cluster = NULL;
  context->url = NULL;
  context->server = NULL;
  context->host = NULL;
  context->port = 0;
  context->useSSL = 0;

  context->heartbeat_counter = 0;
  context->virginConnect = 0;
  
  pthread_mutex_init(&context->mutex_msg, NULL);
  pthread_mutex_init(&context->mutex_cmd, NULL);
  pthread_mutex_init(&context->mutex_state, NULL);
  pthread_cond_init(&context->pcond, NULL);
  
  context->loop_active_throttle = 0;
  context->loop_active_communication = 0;
  context->loop_active_connecting = 0;
  context->loop_active_reconnecting = 0;
  context->loop_active_serverHeartbeat = 0;
  
  context->verifyPeerCert = 1;

  context->lws_context = NULL;
 
  context->multiparts = _ortc_dlist_init();
  context->channels = _ortc_dlist_init();
  context->permissions = _ortc_dlist_init();
  context->messagesToSend = _ortc_dlist_init();
  context->ortcCommands = _ortc_dlist_init();

  context->onConnected = NULL;
  context->onDisconnected = NULL;
  context->onSubscribed = NULL;
  context->onUnsubscribed = NULL;
  context->onException = NULL;
  context->onReconnecting = NULL;
  context->onReconnected = NULL;
  
  context->throttleCounter = 0;
  
  context->heartbeatActive = 0;
  context->heartbeatFails = 3;
  context->heartbeatTime = 15;
  context->state = DISCONNECTED;
  
  if (0 == slre_compile(&context->reOperation, ORTC_OPERATION_PATTERN)) {
    fprintf(stderr, "slre_compile() failed, returning error (%s) for pattern: %s\n", context->reOperation.err_str, ORTC_OPERATION_PATTERN);
    exit(EXIT_FAILURE);
  }
  if (0 == slre_compile(&context->rePermissions, ORTC_PERMISSIONS_PATTERN)) {
    fprintf(stderr, "slre_compile() failed, returning error (%s) for pattern: %s\n", context->rePermissions.err_str, ORTC_PERMISSIONS_PATTERN);
    exit(EXIT_FAILURE);
  }
  if (0 == slre_compile(&context->reChannel, ORTC_CHANNEL_PATTERN)) {
    fprintf(stderr, "slre_compile() failed, returning error (%s) for pattern: %s\n", context->reChannel.err_str, ORTC_CHANNEL_PATTERN);
    exit(EXIT_FAILURE);
  }
  if (0 == slre_compile(&context->reMessage, ORTC_MESSAGE_PATTERN)) {
    fprintf(stderr, "slre_compile() failed, returning error (%s) for pattern: %s\n", context->reMessage.err_str, ORTC_MESSAGE_PATTERN);
    exit(EXIT_FAILURE);
  }
  if (0 == slre_compile(&context->reMultipart, ORTC_MULTIPART_PATTERN)) {
    fprintf(stderr, "slre_compile() failed, returning error (%s) for pattern: %s\n", context->reMultipart.err_str, ORTC_MULTIPART_PATTERN);
    exit(EXIT_FAILURE);
  }
  if (0 == slre_compile(&context->reException, ORTC_EXCEPTION_PATTERN)) {
    fprintf(stderr, "slre_compile() failed, returning error (%s) for pattern: %s\n", context->reException.err_str, ORTC_EXCEPTION_PATTERN);
    exit(EXIT_FAILURE);
  }
  if (0 == slre_compile(&context->reValidUrl, ORTC_VALID_URL_PATTERN)) {
    fprintf(stderr, "slre_compile() failed, returning error (%s) for pattern: %s\n", context->reValidUrl.err_str, ORTC_VALID_URL_PATTERN);
    exit(EXIT_FAILURE);
  }
  if (0 == slre_compile(&context->reValidInput, ORTC_VALID_INPUT_PATTERN)) {
    fprintf(stderr, "slre_compile() failed, returning error (%s) for pattern: %s\n", context->reValidInput.err_str, ORTC_VALID_INPUT_PATTERN);
    exit(EXIT_FAILURE);
  }

  curl_global_init(CURL_GLOBAL_ALL);

  lws_set_log_level(0 /*7*/, NULL);

  _ortc_init_main_thread(context);
  
  return context;
}