MCPcopy Create free account
hub / github.com/F-Stack/f-stack / db_script_set

Function db_script_set

freebsd/ddb/db_script.c:188–207  ·  view source on GitHub ↗

* Modify an existing script or add a new script with the specified script * name and contents. If there are no script slots available, an error will * be returned. */

Source from the content-addressed store, hash-verified

186 * be returned.
187 */
188static int
189db_script_set(const char *scriptname, const char *script)
190{
191 struct ddb_script *dsp;
192 int error;
193
194 error = db_script_valid(scriptname, script);
195 if (error)
196 return (error);
197 dsp = db_script_lookup(scriptname);
198 if (dsp == NULL) {
199 dsp = db_script_new();
200 if (dsp == NULL)
201 return (ENOSPC);
202 strlcpy(dsp->ds_scriptname, scriptname,
203 sizeof(dsp->ds_scriptname));
204 }
205 strlcpy(dsp->ds_script, script, sizeof(dsp->ds_script));
206 return (0);
207}
208
209/*
210 * Delete an existing script by name, if found.

Callers 2

db_script_cmdFunction · 0.85

Calls 4

db_script_validFunction · 0.85
db_script_lookupFunction · 0.85
db_script_newFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected