Exemplo n.º 1
0
static void
print_entry_short(struct get_entry_data *data, kadm5_principal_ent_t princ)
{
    char buf[1024];
    struct field_info *f;

    for(f = data->chead; f != NULL; f = f->next) {
	format_field(princ, f->ff->fieldvalue, f->ff->subvalue, buf, sizeof(buf), 1);
	rtbl_add_column_entry_by_id(data->table, f->ff->fieldvalue, buf);
    }
}
Exemplo n.º 2
0
static void
print_entry_long(struct get_entry_data *data, kadm5_principal_ent_t princ)
{
    char buf[1024];
    struct field_info *f;
    int width = 0;

    for(f = data->chead; f != NULL; f = f->next) {
	int w = strlen(f->header ? f->header : f->ff->def_longheader);
	if(w > width)
	    width = w;
    }
    for(f = data->chead; f != NULL; f = f->next) {
	format_field(princ, f->ff->fieldvalue, f->ff->subvalue, buf, sizeof(buf), 0);
	printf("%*s: %s\n", width, f->header ? f->header : f->ff->def_longheader, buf);
    }
    printf("\n");
}
Exemplo n.º 3
0
MARC_REC *FormatMARCrec(MARC_REC *rec, DISP_FORMAT *format, 
		       int displaynum, int maxlen, void (*output)())
{

  MARC_FIELD *fld;
  int  print_leader = FALSE;         /* special function flags */
  int  print_directory = FALSE;
  int  print_authority = FALSE;
  int  repeat = FALSE;
  int  list_format = FALSE;
  int  line_length;
  int  field_num = 1;
  char *line, *format_field(), *tcl_escape();
  DISP_FORMAT *f;
        
  line_length = maxlen;
        

  if (format == tcllistformat) {
    list_format = 1;
    line_length = 10000;  /* prevent wrapping */
  }
  
  if (list_format == 1) { /* do some special initialization */
    sprintf(linebuffer,"{%d {0 000 {", displaynum);
    strncat(linebuffer, (char *)rec->leader, sizeof(MARC_LEADER_OVER));
    strcat(linebuffer,"}}");
    outputline (output, linebuffer, line_length, 0 /* no indenting */,0);
  }

  if (format == htmlformat ||
      format == shorthtmlformat ||
      format == reviewhtmlformat) {
    list_format = 2;
    line_length = 10000;  /* prevent wrapping */
  }

  if (format == dcformat ||
      format == shortdcformat) {
    list_format = 3;      /* duplicate tags */
    line_length = 10000;  /* prevent wrapping */
  }


  for (f = format; f->newfield >=0 ; f++) {
    /* get the first field in the format */
    fld = GetField(rec, NULL, fieldbuffer, f->tags);
    
    /* if no field found, check for number format */
    if (fld == NULL && *f->tags == '#') {
      /* a pound sign means output the supplied */
      /* record number -- unless it is negative */
      if (displaynum >= 0) {
	sprintf(linebuffer,"%s%s%d%s", 
		f->label, f->beginpunct,displaynum, f->endpunct);
	/* assume it won't be longer than maxlen*/
	outputline (output, linebuffer, line_length, f->indent,0);
      }
    }	
    /* if no field found, check for number format */
    if (fld == NULL && *f->tags == '+') {
      /* a plus sign means output the supplied */
      /* label only                            */
      if (displaynum >= 0) {
	sprintf(linebuffer,"%s", f->label);
	/* assume it won't be longer than maxlen*/
	outputline (output, linebuffer, line_length, f->indent,0);
      }
    }	
    repeat = FALSE;
    
    while (fld) {
      if (f->print_all) {
	codeconvert(fieldbuffer);
	if (*f->label == '\0') {
	  sprintf(linebuffer,"%s %s%s%s", 
		  fld->tag, f->beginpunct,fieldbuffer, f->endpunct);
	}
	else {
	  sprintf(linebuffer,"%s %s%s%s", 
		  f->label, f->beginpunct,fieldbuffer, f->endpunct);
	}
	outputline (output, linebuffer, line_length, f->indent,0);
      }
      else  {/* more selective printing */
	line = format_field(fld,f,linebuffer,repeat,list_format, 
			    field_num, fieldbuffer);
	if (line) {
	  if (list_format == 2) {
	    line  = tcl_escape(line);	    
	    outputline (output, line, line_length, f->indent,0);
	  }
	  else
	    outputline (output, line, line_length, f->indent,0);
	}
      }
      /* more of the same tag set? */
      fld = GetField(NULL,fld->next,fieldbuffer,f->tags);
      if (fld) repeat = TRUE;
      field_num++;
    }
  }
  if (list_format == 1) { /* do ending brace to terminate the list */
    sprintf(linebuffer,"}");
    outputline (output, linebuffer, line_length, 0 /* no indenting */,0);
  }

  return(rec);
}