| 21 | }; |
| 22 | |
| 23 | static bool project_lock_key(const char *project, char out[PROJECT_LOCK_KEY_CAP]) { |
| 24 | if (!project || !project[0] || strcmp(project, "*") == 0) { |
| 25 | return false; |
| 26 | } |
| 27 | static const char prefix[] = "cbm-project-v1:"; |
| 28 | size_t prefix_length = sizeof(prefix) - 1U; |
| 29 | size_t project_length = strnlen(project, PROJECT_LOCK_KEY_CAP); |
| 30 | if (project_length == 0 || project_length >= PROJECT_LOCK_KEY_CAP || |
| 31 | prefix_length + project_length >= PROJECT_LOCK_KEY_CAP) { |
| 32 | return false; |
| 33 | } |
| 34 | memcpy(out, prefix, prefix_length); |
| 35 | for (size_t index = 0; index < project_length; index++) { |
| 36 | unsigned char ch = (unsigned char)project[index]; |
| 37 | out[prefix_length + index] = (char)(ch >= 'A' && ch <= 'Z' ? ch + ('a' - 'A') : ch); |
| 38 | } |
| 39 | out[prefix_length + project_length] = '\0'; |
| 40 | return true; |
| 41 | } |
| 42 | |
| 43 | cbm_project_lock_manager_t *cbm_project_lock_manager_new( |
| 44 | const cbm_daemon_ipc_endpoint_t *endpoint) { |
no outgoing calls
no test coverage detected