* 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. */
| 186 | * be returned. |
| 187 | */ |
| 188 | static int |
| 189 | db_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. |
no test coverage detected