make_hash(key, &probe_address, &probe_decrement, NAME_HASH_PRIME);
while (name_hashtable[probe_address] != NULL) {
if (strcmp(name_hashtable[probe_address], key) == 0) {
- return(probe_address);
+ return probe_address;
} else {
probe_address -= probe_decrement;
if ((int)probe_address < 0) {
}
}
name_hashtable[probe_address] = xstrdup(key);
- return(probe_address);
+ return probe_address;
}
/* this DOESNT add the key to the hashtable
}
}
}
- return(probe_address);
+ return probe_address;
}
/* Need to rethink version comparison, maybe the official dpkg has something i can use ? */
}
ret = 0;
cleanup_version_compare_part:
- return(ret);
+ return ret;
}
/* if ver1 < ver2 return -1,
ver2_ptr = ch_ver2;
}
if (epoch1 < epoch2) {
- return(-1);
+ return -1;
}
else if (epoch1 > epoch2) {
- return(1);
+ return 1;
}
/* Compare upstream version */
free(upstream_ver2);
if (result != 0) {
- return(result);
+ return result;
}
/* Compare debian versions */
- return(version_compare_part(deb_ver1, deb_ver2));
+ return version_compare_part(deb_ver1, deb_ver2);
}
static int test_version(const unsigned int version1, const unsigned int version2, const unsigned int operator)
{
const int version_result = version_compare(version1, version2);
switch (operator) {
- case (VER_ANY):
- return(TRUE);
- case (VER_EQUAL):
+ case VER_ANY:
+ return TRUE;
+ case VER_EQUAL:
if (version_result == 0) {
- return(TRUE);
+ return TRUE;
}
break;
- case (VER_LESS):
+ case VER_LESS:
if (version_result < 0) {
- return(TRUE);
+ return TRUE;
}
break;
- case (VER_LESS_EQUAL):
+ case VER_LESS_EQUAL:
if (version_result <= 0) {
- return(TRUE);
+ return TRUE;
}
break;
- case (VER_MORE):
+ case VER_MORE:
if (version_result > 0) {
- return(TRUE);
+ return TRUE;
}
break;
- case (VER_MORE_EQUAL):
+ case VER_MORE_EQUAL:
if (version_result >= 0) {
- return(TRUE);
+ return TRUE;
}
break;
}
- return(FALSE);
+ return FALSE;
}
while (package_hashtable[probe_address] != NULL) {
if (package_hashtable[probe_address]->name == name) {
if (operator == VER_ANY) {
- return(probe_address);
+ return probe_address;
}
if (test_version(package_hashtable[probe_address]->version, version, operator)) {
- return(probe_address);
+ return probe_address;
}
}
probe_address -= probe_decrement;
probe_address += PACKAGE_HASH_PRIME;
}
}
- return(probe_address);
+ return probe_address;
}
/*
static void free_package(common_node_t *node)
{
- unsigned short i;
+ unsigned i;
if (node) {
for (i = 0; i < node->num_of_edges; i++) {
free(node->edge[i]);
if (package_buffer == NULL) {
*field_name = NULL;
*field_value = NULL;
- return(-1);
+ return -1;
}
while (1) {
next_offset = offset + 1;
switch (package_buffer[offset]) {
- case('\0'):
+ case '\0':
exit_flag = TRUE;
break;
- case(':'):
+ case ':':
if (offset_name_end == 0) {
offset_name_end = offset;
offset_value_start = next_offset;
/* TODO: Name might still have trailing spaces if ':' isnt
* immediately after name */
break;
- case('\n'):
+ case '\n':
/* TODO: The char next_offset may be out of bounds */
if (package_buffer[next_offset] != ' ') {
exit_flag = TRUE;
break;
}
- case('\t'):
- case(' '):
+ case '\t':
+ case ' ':
/* increment the value start point if its a just filler */
if (offset_name_start == offset) {
offset_name_start++;
} else {
*field_value = NULL;
}
- return(next_offset);
+ return next_offset;
}
static unsigned int fill_package_struct(char *control_buffer)
new_node->version = search_name_hashtable("unknown");
while (field_start < buffer_length) {
- unsigned short field_num;
+ unsigned field_num;
field_start += read_package_field(&control_buffer[field_start],
&field_name, &field_value);
if (new_node->version == search_name_hashtable("unknown")) {
free_package(new_node);
- return(-1);
+ return -1;
}
num = search_package_hashtable(new_node->name, new_node->version, VER_EQUAL);
if (package_hashtable[num] == NULL) {
} else {
free_package(new_node);
}
- return(num);
+ return num;
}
/* if num = 1, it returns the want status, 2 returns flag, 3 returns status */
state_sub_string = xstrndup(status_string, len);
state_sub_num = search_name_hashtable(state_sub_string);
free(state_sub_string);
- return(state_sub_num);
+ return state_sub_num;
}
static void set_status(const unsigned int status_node_num, const char *new_value, const int position)
char *new_status;
switch (position) {
- case (1):
+ case 1:
want = new_value_num;
want_len = new_value_len;
break;
- case (2):
+ case 2:
flag = new_value_num;
flag_len = new_value_len;
break;
- case (3):
+ case 3:
status = new_value_num;
status_len = new_value_len;
break;
}
}
free(conflicts);
- return(TRUE);
+ return TRUE;
}
static char **create_list(const char *filename)
/* don't use [xw]fopen here, handle error ourself */
list_stream = fopen(filename, "r");
if (list_stream == NULL) {
- return(NULL);
+ return NULL;
}
while ((line = bb_get_chomped_line_from_file(list_stream)) != NULL) {
fclose(list_stream);
if (count == 0) {
- return(NULL);
+ return NULL;
} else {
file_list[count] = NULL;
- return(file_list);
+ return file_list;
}
}
int i,j;
if (remove_names == NULL) {
- return(FALSE);
+ return FALSE;
}
for (i = 0; remove_names[i] != NULL; i++) {
match_flag = FALSE;
}
}
}
- return(remove_flag);
+ return remove_flag;
}
static int run_package_script(const char *package_name, const char *script_type)
/* If the file doesnt exist is isnt a fatal */
result = lstat(script_path, &path_stat) < 0 ? EXIT_SUCCESS : system(script_path);
free(script_path);
- return(result);
+ return result;
}
static const char *all_control_files[] = {"preinst", "postinst", "prerm", "postrm",
static char **all_control_list(const char *package_name)
{
- unsigned short i = 0;
+ unsigned i = 0;
char **remove_files;
/* Create a list of all /var/lib/dpkg/info/<package> files */
i++;
}
- return(remove_files);
+ return remove_files;
}
static void free_array(char **array)
{
if (array) {
- unsigned short i = 0;
+ unsigned i = 0;
while (array[i]) {
free(array[i]);
i++;
ar_handle->filter = filter_accept_list_reassign;
ar_handle->src_fd = xopen(filename, O_RDONLY);
- return(ar_handle);
+ return ar_handle;
}
static void init_archive_deb_control(archive_handle_t *ar_handle)
unpack_ar_archive(ar_handle);
close(ar_handle->src_fd);
- return(ar_handle->sub_archive->buffer);
+ return ar_handle->sub_archive->buffer;
}
static void data_extract_all_prefix(archive_handle_t *archive_handle)
bb_show_usage();
}
}
- /* check for non-otion argument if expected */
+ /* check for non-option argument if expected */
if ((dpkg_opt == 0) || ((argc == optind) && !(dpkg_opt && dpkg_opt_list_installed))) {
bb_show_usage();
}
/* if the list action was given print the installed packages and exit */
if (dpkg_opt & dpkg_opt_list_installed) {
list_packages();
- return(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
/* Read arguments and store relevant info in structs */
free(name_hashtable);
}
- return(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}