return qsc;\r
}\r
\r
+/* WILL NOT allocate a new string if the identifier is already present. */\r
+int prepend_service_group_identifier(TCHAR *group, TCHAR **canon) {\r
+ if (! group || ! group[0] || group[0] == SC_GROUP_IDENTIFIER) {\r
+ *canon = group;\r
+ return 0;\r
+ }\r
+\r
+ size_t len = _tcslen(group) + 1;\r
+ *canon = (TCHAR *) HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(TCHAR));\r
+ if (! *canon) {\r
+ print_message(stderr, NSSM_MESSAGE_OUT_OF_MEMORY, _T("canon"), _T("prepend_service_group_identifier()"));\r
+ return 1;\r
+ }\r
+\r
+ TCHAR *s = *canon;\r
+ *s++ = SC_GROUP_IDENTIFIER;\r
+ memmove(s, group, len * sizeof(TCHAR));\r
+ (*canon)[len] = _T('\0');\r
+\r
+ return 0;\r
+}\r
+\r
+int append_to_dependencies(TCHAR *dependencies, unsigned long dependencieslen, TCHAR *string, TCHAR **newdependencies, unsigned long *newlen, int type) {\r
+ *newlen = 0;\r
+\r
+ TCHAR *canon = 0;\r
+ if (type == DEPENDENCY_GROUPS) {\r
+ if (prepend_service_group_identifier(string, &canon)) return 1;\r
+ }\r
+ else canon = string;\r
+ int ret = append_to_double_null(dependencies, dependencieslen, newdependencies, newlen, canon, 0, false);\r
+ if (canon && canon != string) HeapFree(GetProcessHeap(), 0, canon);\r
+\r
+ return ret;\r
+}\r
+\r
+int remove_from_dependencies(TCHAR *dependencies, unsigned long dependencieslen, TCHAR *string, TCHAR **newdependencies, unsigned long *newlen, int type) {\r
+ *newlen = 0;\r
+\r
+ TCHAR *canon = 0;\r
+ if (type == DEPENDENCY_GROUPS) {\r
+ if (prepend_service_group_identifier(string, &canon)) return 1;\r
+ }\r
+ else canon = string;\r
+ int ret = remove_from_double_null(dependencies, dependencieslen, newdependencies, newlen, canon, 0, false);\r
+ if (canon && canon != string) HeapFree(GetProcessHeap(), 0, canon);\r
+\r
+ return ret;\r
+}\r
+\r
int set_service_dependencies(const TCHAR *service_name, SC_HANDLE service_handle, TCHAR *buffer) {\r
TCHAR *dependencies = _T("");\r
unsigned long num_dependencies = 0;\r
SC_HANDLE open_service_manager(unsigned long);\r
SC_HANDLE open_service(SC_HANDLE, TCHAR *, unsigned long, TCHAR *, unsigned long);\r
QUERY_SERVICE_CONFIG *query_service_config(const TCHAR *, SC_HANDLE);\r
+int append_to_dependencies(TCHAR *, unsigned long, TCHAR *, TCHAR **, unsigned long *, int);\r
+int remove_from_dependencies(TCHAR *, unsigned long, TCHAR *, TCHAR **, unsigned long *, int);\r
int set_service_dependencies(const TCHAR *, SC_HANDLE, TCHAR *);\r
int get_service_dependencies(const TCHAR *, SC_HANDLE, TCHAR **, unsigned long *, int);\r
int get_service_dependencies(const TCHAR *, SC_HANDLE, TCHAR **, unsigned long *);\r