Example #1
0
/**
 * @brief checks the entry using subfunctions based on params, if passed, prints it
 *
 * @param path the path to be processed
 * @param params the parsed parameters
 * @param attr the entry attributes from lstat
 *
 * @returns EXIT_SUCCESS, EXIT_FAILURE
 */
int do_file(char *path, params_t *params, struct stat attr) {
  int printed = 0;

  do {
    /* ### FB: Mit ENUM Feld könnte hier ein switch genutzt werden und für mehr Übersicht sorgen. */
    /* filtering */
    if (params->type) {
      if (do_type(params->type, attr) != EXIT_SUCCESS) {
        return EXIT_SUCCESS; /* the entry didn't pass the check, do not print it */
      }
    }
    if (params->nouser) {
      if (do_nouser(attr) != EXIT_SUCCESS) {
        return EXIT_SUCCESS;
      }
    }
    if (params->user) {
      if (do_user(params->userid, attr) != EXIT_SUCCESS) {
        return EXIT_SUCCESS;
      }
    }
    if (params->name) {
      if (do_name(path, params->name) != EXIT_SUCCESS) {
        return EXIT_SUCCESS;
      }
    }
    if (params->path) {
      if (do_path(path, params->path) != EXIT_SUCCESS) {
        return EXIT_SUCCESS;
      }
    }
    /* printing */
    if (params->print) {
      if (do_print(path) != EXIT_SUCCESS) {
        return EXIT_FAILURE; /* a fatal error occurred */
      }
      printed = 1;
    }
    if (params->ls) {
      if (do_ls(path, attr) != EXIT_SUCCESS) {
        return EXIT_FAILURE;
      }
      printed = 1;
    }

    params = params->next;
  } while (params);

  if (printed == 0) {
    if (do_print(path) != EXIT_SUCCESS) {
      return EXIT_FAILURE;
    }
  }

  return EXIT_SUCCESS;
}
Example #2
0
File: main.c Project: amq/myfind
/**
 * @brief checks the entry using subfunctions based on params, if passed, prints it
 *
 * @param path the path to be processed
 * @param params the parsed parameters
 * @param attr the entry attributes from lstat
 *
 * @returns EXIT_SUCCESS, EXIT_FAILURE
 */
int do_file(char *path, params_t *params, struct stat attr) {
  int printed = 0;

  do {
    /* filtering */
    if (params->type) {
      if (do_type(params->type, attr) != EXIT_SUCCESS) {
        return EXIT_SUCCESS; /* the entry didn't pass the check, do not print it */
      }
    }
    if (params->nouser) {
      if (do_nouser(attr) != EXIT_SUCCESS) {
        return EXIT_SUCCESS;
      }
    }
    if (params->user) {
      if (do_user(params->userid, attr) != EXIT_SUCCESS) {
        return EXIT_SUCCESS;
      }
    }
    if (params->name) {
      if (do_name(path, params->name) != EXIT_SUCCESS) {
        return EXIT_SUCCESS;
      }
    }
    if (params->path) {
      if (do_path(path, params->path) != EXIT_SUCCESS) {
        return EXIT_SUCCESS;
      }
    }
    /* printing */
    if (params->print) {
      if (do_print(path) != EXIT_SUCCESS) {
        return EXIT_FAILURE; /* a fatal error occurred */
      }
      printed = 1;
    }
    if (params->ls) {
      if (do_ls(path, attr) != EXIT_SUCCESS) {
        return EXIT_FAILURE;
      }
      printed = 1;
    }

    params = params->next;
  } while (params);

  if (printed == 0) {
    if (do_print(path) != EXIT_SUCCESS) {
      return EXIT_FAILURE;
    }
  }

  return EXIT_SUCCESS;
}
Example #3
0
File: upsrw.c Project: AlexLov/nut
static void print_rw(const char *varname)
{
	const char	*tmp;

	printf("[%s]\n", varname);

	tmp = get_data("DESC", varname);

	if (tmp) {
		printf("%s\n", tmp);
	} else {
		printf("Description unavailable\n");
	}

	do_type(varname);

	printf("\n");
}
Example #4
0
static void do_service(config_t *cpe, config_t *config, struct rs_config *rs_config)
{
	struct rs_start *rs_start = &rs_config->rs_start;
	config_t *cp;

	/* At this point we expect one sublist that contains the varios
	 * resource allocations
	 */
	if (!(cpe->flags & CFG_SUBLIST))
	{
		fatal("do_service: expected list at %s:%d",
			cpe->file, cpe->line);
	}
	if (cpe->next != NULL)
	{
		cpe= cpe->next;
		fatal("do_service: expected end of list at %s:%d",
			cpe->file, cpe->line);
	}
	cpe= cpe->list;

	/* Process the list */
	for (cp= cpe; cp; cp= cp->next)
	{
		if (!(cp->flags & CFG_SUBLIST))
		{
			fatal("do_service: expected list at %s:%d",
				cp->file, cp->line);
		}
		cpe= cp->list;
		if ((cpe->flags & CFG_STRING) || (cpe->flags & CFG_SUBLIST))
		{
			fatal("do_service: expected word at %s:%d",
				cpe->file, cpe->line);
		}

		if (strcmp(cpe->word, KW_CLASS) == 0)
		{
			do_class(cpe->next, config, rs_config);
			continue;
		}
		if (strcmp(cpe->word, KW_UID) == 0)
		{
			do_uid(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_SIGMGR) == 0)
		{
			do_sigmgr(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_TYPE) == 0)
		{
			do_type(cpe->next, rs_config);
			continue;
		}
		if (strcmp(cpe->word, KW_DESCR) == 0)
		{
			do_descr(cpe->next, rs_config);
			continue;
		}
		if (strcmp(cpe->word, KW_SCHEDULER) == 0)
		{
			do_scheduler(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_PRIORITY) == 0)
		{
			do_priority(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_QUANTUM) == 0)
		{
			do_quantum(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_CPU) == 0)
		{
			do_cpu(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_IRQ) == 0)
		{
			do_irq(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_IO) == 0)
		{
			do_io(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_PCI) == 0)
		{
			do_pci(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_SYSTEM) == 0)
		{
			do_system(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_IPC) == 0)
		{
			do_ipc(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_VM) == 0)
		{
			do_vm(cpe->next, rs_start);
			continue;
		}
		if (strcmp(cpe->word, KW_CONTROL) == 0)
		{
			do_control(cpe->next, rs_start);
			continue;
		}
	}
}