Beispiel #1
0
int ListByAdministrator(int argc, char **argv)
{
  char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name;
  struct mqelem *top;

  type = strdup("USER");
  if (GetTypeFromUser("Type of member", "member", &type) == SUB_ERROR)
    return DM_NORMAL;

  sprintf(buf, "Name of %s", type);
  name = strdup(user);
  if (GetValueFromUser(buf, &name) == SUB_ERROR)
    return DM_NORMAL;

  switch (YesNoQuestion("Do you want a recursive search (y/n)", FALSE))
    {
    case TRUE:
      sprintf(temp_buf, "R%s", type);	/* "USER" to "RUSER" etc. */
      free(type);
      type = strdup(temp_buf);
      break;
    case FALSE:
      break;
    default:
      return DM_NORMAL;
    }

  top = GetListInfo(ACE_USE, type, name);
  Loop(top, PrintListAce);

  FreeQueue(top);
  return DM_NORMAL;
}
Beispiel #2
0
int UpdateList(int argc, char **argv)
{
  struct mqelem *top;

  top = GetListInfo(LIST, argv[1], (char *) NULL);
  QueryLoop(top, NullPrint, RealUpdateList, "Update the list");

  FreeQueue(top);
  return DM_NORMAL;
}
Beispiel #3
0
int ListByMember(int argc, char **argv)
{
  char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name, **info;
  Bool maillist, group, neither;
  struct mqelem *top, *elem;

  type = strdup("USER");
  if (GetTypeFromUser("Type of member", "member", &type) == SUB_ERROR)
    return DM_NORMAL;

  sprintf(buf, "Name of %s", type);
  name = strdup(user);
  if (GetValueFromUser(buf, &name) == SUB_ERROR)
    return DM_NORMAL;

  switch (YesNoQuestion("Do you want a recursive search (y/n)", TRUE))
    {
    case TRUE:
      sprintf(temp_buf, "R%s", type);	/* "USER" to "RUSER" etc. */
      free(type);
      type = strdup(temp_buf);
      break;
    case FALSE:
      break;
    default:
      return DM_NORMAL;
    }

  if ((maillist = YesNoQuestion("Show Lists that are Maillists (y/n) ?",
				TRUE)) == -1)
    return DM_NORMAL;
  if ((group = YesNoQuestion("Show Lists that are Groups (y/n) ?",
			     TRUE)) == -1)
    return DM_NORMAL;

  if ((neither = YesNoQuestion("Show Lists that are neither Maillists nor Groups (y/n) ?",
			       TRUE)) == -1)
    return DM_NORMAL;

  elem = top = GetListInfo(GLOM, type, name);

  while (elem)
    {
      info = elem->q_data;
      if ((maillist == TRUE && !strcmp(info[GLOM_MAILLIST], "1")) ||
	  (group == TRUE && !strcmp(info[GLOM_GROUP], "1")))
	Put_message(info[GLOM_NAME]);
      if (neither == TRUE && !strcmp(info[GLOM_MAILLIST], "0") &&
	   !strcmp(info[GLOM_GROUP], "0"))
	Put_message(info[GLOM_NAME]);
      elem = elem->q_forw;
    }
  FreeQueue(top);
  return DM_NORMAL;
}
Beispiel #4
0
int InterRemoveItemFromLists(int argc, char **argv)
{
  int status;
  char *type, *name, *args[10], buf[BUFSIZ];
  struct mqelem *top, *elem;

  type = strdup("USER");
  if (GetTypeFromUser("Type of member", "member", &type) == SUB_ERROR)
    return DM_NORMAL;

  sprintf(buf, "Name of %s", type);
  name = strdup(user);
  if (GetValueFromUser(buf, &name) == SUB_ERROR)
    return DM_NORMAL;

  if (!ValidName(name))
    return DM_NORMAL;

  top = elem = GetListInfo(GLOM, type, name);

  while (elem)
    {
      char line[BUFSIZ];
      char **info = elem->q_data;
      sprintf(line, "Delete %s %s from the list \"%s\" (y/n/q)? ", type,
	      name, info[GLOM_NAME]);
      switch (YesNoQuitQuestion(line, FALSE))
	{
	case TRUE:
	  Put_message("deleting...");
	  args[DM_LIST] = info[GLOM_NAME];
	  args[DM_TYPE] = type;
	  args[DM_MEMBER] = name;
	  if (!strcmp("MACHINE", type))
	      args[DM_MEMBER] = canonicalize_hostname(strdup(name));
	  if ((status = do_mr_query("delete_member_from_list", 3, args,
				    NULL, NULL)))
	    {
	      /* should probabally check to delete list. */
	      com_err(program_name, status, " in delete_member");
	    }
	  break;
	case FALSE:
	  break;
	default:
	  Put_message("Aborting...");
	  FreeQueue(top);
	  return DM_NORMAL;
	}
      elem = elem->q_forw;
    }
  FreeQueue(top);
  return DM_NORMAL;
}
Beispiel #5
0
int ShowListInfo(int argc, char **argv)
{
  struct mqelem *top, *list;

  top = list = GetListInfo(LIST, argv[1], NULL);
  while (list)
    {
      PrintListInfo(list->q_data);
      list = list->q_forw;
    }

  FreeQueue(top);
  return DM_NORMAL;
}
Beispiel #6
0
int
main(int argc, char *argv[]) {
    static VArgVector in_files;
    static VString out_filename;
    static VString filename;
    static VShort minval = 0;
    static VFloat fwhm = 4.0;
    static VOptionDescRec  options[] = {
        {"in", VStringRepn, 0, & in_files, VRequiredOpt, NULL, "Input files" },
        {"out", VStringRepn, 1, & out_filename, VRequiredOpt, NULL, "Output file" },
        {"design", VStringRepn, 1, (VPointer) &filename, VRequiredOpt, NULL, "Design file"},
        {
            "fwhm", VFloatRepn, 1, (VPointer) &fwhm, VOptionalOpt, NULL,
            "FWHM of temporal Gaussian filter in seconds"
        },
        {"minval", VShortRepn, 1, (VPointer) &minval, VOptionalOpt, NULL, "Signal threshold"}
    };
    FILE *fp = NULL, *f = NULL;
    VStringConst in_filename;
    VString ifilename;
    VAttrList list = NULL, list1 = NULL;
    VAttrList out_list = NULL, history_list = NULL;
    VAttrListPosn posn;
    VImage design = NULL;
    ListInfo *linfo;
    VLong itr = 0;
    VFloat sigma = 0, tr = 0;
    int  i, n, nimages;
   char prg_name[100];
	char ver[100];
	getLipsiaVersion(ver, sizeof(ver));
	sprintf(prg_name, "vcolorglm V%s", ver);
    fprintf(stderr, "%s\n", prg_name);
    /*
    ** parse command line
    */
    if(! VParseCommand(VNumber(options), options, & argc, argv)) {
        VReportUsage(argv[0], VNumber(options), options, NULL);
        exit(EXIT_FAILURE);
    }
    if(argc > 1) {
        VReportBadArgs(argc, argv);
        exit(EXIT_FAILURE);
    }
    /*
    ** read design matrix
    */
    fp = VOpenInputFile(filename, TRUE);
    list1 = VReadFile(fp, NULL);
    if(! list1)
        VError("Error reading design file");
    fclose(fp);
    n = 0;
    for(VFirstAttr(list1, & posn); VAttrExists(& posn); VNextAttr(& posn)) {
        if(VGetAttrRepn(& posn) != VImageRepn)
            continue;
        VGetAttrValue(& posn, NULL, VImageRepn, & design);
        if(VPixelRepn(design) != VFloatRepn /* && VPixelRepn(design) != VDoubleRepn */)
            continue;
        n++;
        break;
    }
    if(n == 0)
        VError(" design matrix not found ");
    /*
    ** get pre-coloring info
    */
    if(VGetAttr(VImageAttrList(design), "repetition_time", NULL, VLongRepn, &itr) != VAttrFound)
        VError(" TR info missing in header");
    tr = (float) itr / 1000.0;
    sigma = 0;
    if(tr > 0.001 && fwhm > 0.001) {
        fprintf(stderr, " TR: %.3f seconds\n", tr);
        sigma = fwhm / 2.35482;
        sigma /= tr;
        if(sigma < 0.1) {
            VWarning(" 'fwhm/sigma' too small (%.3f / %.3f), will be set to zero", fwhm, sigma);
            sigma = 0;
        }
    }
    /*
    ** Read each input file
    */
    nimages = in_files.number;
    linfo = (ListInfo *) VMalloc(sizeof(ListInfo) * nimages);
    for(i = 0; i < nimages; i++) {
        in_filename = ((VStringConst *) in_files.vector)[i];
        ifilename = VNewString(in_filename);
        fprintf(stderr, " file:  %s\n", ifilename);
        list = GetListInfo(ifilename, &linfo[i]);
        /* Create history */
        if(i == 0) {
            history_list = VReadHistory(&list);
            if(history_list == NULL)
                history_list = VCreateAttrList();
            VPrependHistory(VNumber(options), options, prg_name, &history_list);
        }
    }

    /*
    ** GLM
    */
    out_list = VRegression(linfo, nimages, minval, design, sigma, itr);


    /*
    **  Output:
    */
    VPrependAttr(out_list, "history", NULL, VAttrListRepn, history_list);
    f = VOpenOutputFile(out_filename, TRUE);
    if(!f)
        VError(" error opening outout file %s", out_filename);
    if(! VWriteFile(f, out_list))
        exit(1);
    fprintf(stderr, "%s: done.\n", argv[0]);
    return 0;
}