Lines Matching refs:sc
21 static void script_free(script *sc) in script_free() argument
23 if (!sc) return; in script_free()
24 lua_close(sc->L); in script_free()
25 free(sc->name.ptr); in script_free()
26 free(sc->etag.ptr); in script_free()
27 free(sc); in script_free()
47 static lua_State *script_cache_load_script(script * const sc, int etag_flags) in script_cache_load_script() argument
52 stat_cache_entry * const sce = stat_cache_get_entry_open(&sc->name, 1); in script_cache_load_script()
53 buffer_clear(&sc->etag); in script_cache_load_script()
61 buffer_copy_buffer(&sc->etag, etag); in script_cache_load_script()
79 sc->req_env_init = (NULL != strstr(buf, "req_env")); in script_cache_load_script()
81 int rc = luaL_loadbuffer(sc->L, buf, (size_t)sz, sc->name.ptr); in script_cache_load_script()
86 return sc->L; in script_cache_load_script()
89 force_assert(lua_isfunction(sc->L, -1)); in script_cache_load_script()
90 return sc->L; in script_cache_load_script()
98 script * const sc = script_init(); in __attribute_nonnull__() local
102 cache->ptr[cache->used++] = sc; in __attribute_nonnull__()
104 buffer_copy_buffer(&sc->name, name); in __attribute_nonnull__()
105 sc->L = luaL_newstate(); in __attribute_nonnull__()
106 luaL_openlibs(sc->L); in __attribute_nonnull__()
107 return sc; in __attribute_nonnull__()
113 script * const sc = cache->ptr[i]; in script_cache_get_script() local
114 if (buffer_is_equal(&sc->name, name)) in script_cache_get_script()
115 return sc; in script_cache_get_script()
120 lua_State *script_cache_check_script(script * const sc, int etag_flags) in script_cache_check_script() argument
122 if (lua_gettop(sc->L) == 0) in script_cache_check_script()
123 return script_cache_load_script(sc, etag_flags); in script_cache_check_script()
128 stat_cache_entry * const sce = stat_cache_get_entry(&sc->name); in script_cache_check_script()
130 lua_settop(sc->L, 0); /* pop the old function; clear stack */ in script_cache_check_script()
131 return script_cache_load_script(sc, etag_flags); in script_cache_check_script()
135 if (NULL == etag || !buffer_is_equal(&sc->etag, etag)) { in script_cache_check_script()
137 return sc->L; in script_cache_check_script()
139 lua_settop(sc->L, 0); /* pop the old function; clear stack */ in script_cache_check_script()
140 return script_cache_load_script(sc, etag_flags); in script_cache_check_script()
143 return sc->L; in script_cache_check_script()