186
186
val = ngx_palloc(r->pool, len);
187
187
if (val == NULL) {
188
return luaL_error(L, "memory allocation erorr");
188
return luaL_error(L, "memory allocation error");
191
191
ngx_memcpy(val, p, len);
365
365
ngx_http_lua_ffi_var_set(ngx_http_request_t *r, u_char *name_data,
366
366
size_t name_len, u_char *lowcase_buf, u_char *value, size_t value_len,
367
u_char *errbuf, size_t errlen)
367
u_char *errbuf, size_t *errlen)
373
373
ngx_http_core_main_conf_t *cmcf;
376
ngx_snprintf(errbuf, errlen, "no request object found");
376
*errlen = ngx_snprintf(errbuf, *errlen, "no request object found")
377
378
return NGX_ERROR;
380
if ((r)->connection->fd == -1) {
381
ngx_snprintf(errbuf, errlen, "API disabled in the current context");
381
if ((r)->connection->fd == (ngx_socket_t) -1) {
382
*errlen = ngx_snprintf(errbuf, *errlen,
383
"API disabled in the current context")
382
385
return NGX_ERROR;
396
399
if (!(v->flags & NGX_HTTP_VAR_CHANGEABLE)) {
397
400
dd("variable not changeable");
398
ngx_snprintf(errbuf, errlen, "variable \"%*s\" not changeable",
399
name_len, lowcase_buf);
401
*errlen = ngx_snprintf(errbuf, *errlen,
402
"variable \"%*s\" not changeable",
403
name_len, lowcase_buf)
400
405
return NGX_ERROR;
405
410
dd("set variables with set_handler");
407
412
if (value != NULL && value_len) {
408
vv = ngx_pnalloc(r->pool, sizeof(ngx_http_variable_value_t)
413
vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)
410
415
if (vv == NULL) {
477
ngx_snprintf(errbuf, errlen, "variable \"%*s\" cannot be assigned "
478
"a value", name_len, lowcase_buf);
483
*errlen = ngx_snprintf(errbuf, *errlen,
484
"variable \"%*s\" cannot be assigned "
485
"a value", name_len, lowcase_buf)
479
487
return NGX_ERROR;
482
490
/* variable not found */
484
ngx_snprintf(errbuf, errlen, "variable \"%*s\" not found for writing; "
485
"maybe it is a built-in variable that is not changeable "
486
"or you forgot to use \"set $%*s '';\" "
487
"in the config file to define it first",
488
name_len, lowcase_buf, name_len, lowcase_buf);
492
*errlen = ngx_snprintf(errbuf, *errlen,
493
"variable \"%*s\" not found for writing; "
494
"maybe it is a built-in variable that is not "
495
"changeable or you forgot to use \"set $%*s '';\" "
496
"in the config file to define it first",
497
name_len, lowcase_buf, name_len, lowcase_buf)
489
499
return NGX_ERROR;
493
ngx_snprintf(errbuf, errlen, "no memory");
503
*errlen = ngx_snprintf(errbuf, *errlen, "no memory") - errbuf;
494
504
return NGX_ERROR;
496
506
#endif /* NGX_LUA_NO_FFI_API */