274 printf(
"******Error in invoking h2root\n");
275 printf(
"===> h2root file.hbook file.root [compress] [tolower] [lrecl] [bufsize] [optcwn] \n");
276 printf(
" if file.root is not given it will be = file.root\n");
277 printf(
" compress = 1 by default (use 0 for no compression)\n");
278 printf(
" tolower = 1 by default (use 0 to keep case of column names)\n");
279 printf(
" lrecl =0 by default (must be specified if >8092)\n");
280 printf(
" bufsize = 8000 by default (branch buffer size)\n");
281 printf(
" for cwn ntuple only: optcwn = 1 (default) 1-byte int -> char, 2-byte int -> short, (use 0 to keep 4-byte int) \n");
288 char *file_in=argv[1];
291 int ier=0, record_size=0;
299 record_size = atoi(argv[5]);
305 compress = atoi(argv[3]);
310 Int_t nchf = strlen(file_in)+std::char_traits<char>::length(
".root")+1;
311 file_out=
new char[nchf];
312 strlcpy(file_out,file_in,nchf);
313 char *dot = strrchr(file_out,
'.');
314 if (dot) strcpy(dot+1,
"root");
315 else strlcat(file_out,
".root",nchf);
318#if defined(_HIUX_SOURCE) && !defined(__GNUC__)
319 hf_fint((
char *)
NULL);
330 constexpr auto chdir =
"example";
331 constexpr auto opt =
"px";
332 hropen(lun, chdir, file_in, opt, record_size, ier, strlen(chdir), strlen(file_in), strlen(opt));
337 if (ier)
printf (
" Error on hropen was %d \n", ier);
339 printf(
"Error cannot open input file: %s\n",file_in);
343 char root_file_title[2000];
344 snprintf(root_file_title,2000,
"HBOOK file: %s converted to ROOT",file_in);
348 printf(
"Error: can't open output file: %s \n",file_out);
371 printf(
" Converting directory %s\n",
dir);
376 for (
Int_t key=1;key<1000000;key++) {
398 printf(
"Error cannot read ID = %d\n",
id);
427 const Int_t kKLS = 26;
428 const Int_t kKNSD = 23;
439 for (
Int_t k=0;k<ndir;k++) {
442 for (i=0;i<17;i++) chdir[i] = 0;
444 uhtoc(ihdir[0],ncw,chdir,nch ,16);
446 uhtoc(ihdir[0],ncw,chdir,16,nch);
449 if (strchr(chdir,
'/')) {
450 printf(
"Sorry cannot convert directory name %s because it contains a slash\n",chdir);
453 strlcpy(hbookdir,chdir,17);
455 if (chdir[i] == 0)
continue;
456 if (chdir[i] !=
' ')
break;
620 float rmin[1000], rmax[1000];
625 printf(
" Converting RWN with ID= %d, nentries = %d\n",
id,
nentries);
633 chtag_out =
new char[nvar*kNchar+1];
636 chtag_out[nvar*kNchar]=0;
637 for (i=0;i<80;i++)
chtitl[i]=0;
639 hgiven(
id,
chtitl,nvar,chtag_out,rmin[0],rmax[0],80,kNchar);
641 hgiven(
id,
chtitl,80,nvar,chtag_out,kNchar,rmin[0],rmax[0]);
644 char *
name = chtag_out;
645 for (i=80;i>0;i--) {
if (
chtitl[i] ==
' ')
chtitl[i] = 0; }
648 for(i=0; i<nvar;i++) {
652 for (j=kNchar-2;j>0;j--) {
654 if (
name[j] ==
' ' && last == 0)
name[j] = 0;
660 for (j=0;j<kNchar;j++) {
661 if (
name[j] !=
' ')
break;
686 int nsub,itype,isize,ielem;
689 float rmin[1000], rmax[1000];
694 printf(
" Converting CWN with ID= %d, nentries = %d\n",
id,
nentries);
703 chtag_out =
new char[nvar*kNchar+1];
711 chtag_out[nvar*kNchar]=0;
712 for (i=0;i<80;i++)
chtitl[i]=0;
714 hgiven(
id,
chtitl,nvar,chtag_out,rmin[0],rmax[0],80,kNchar);
716 hgiven(
id,
chtitl,80,nvar,chtag_out,kNchar,rmin[0],rmax[0]);
733 strlcpy(oldblock,
"OLDBLOCK",512);
734 Int_t oldischar = -1;
735 for (i=80;i>0;i--) {
if (
chtitl[i] ==
' ')
chtitl[i] = 0; }
737 for(i=0; i<nvar;i++) {
740 memset(block,
' ',
sizeof(block));
741 block[
sizeof(block)-1] = 0;
742 memset(fullname,
' ',
sizeof(fullname));
743 fullname[
sizeof(fullname)-1]=0;
745 hntvar2(
id,i+1,
PASSCHAR(
name),
PASSCHAR(fullname),
PASSCHAR(block),nsub,itype,isize,nbits,ielem,512,1024,512);
750 for (j=510;j>0;j--) {
756 for (j=1022;j>0;j--) {
757 if(
golower && fullname[j-1] !=
'[') fullname[j] = tolower(fullname[j]);
759 if (
golower == 2) fullname[j] = tolower(fullname[j]);
760 if (fullname[j] ==
' ') fullname[j] = 0;
763 if (
golower == 2) fullname[0] = tolower(fullname[0]);
764 for (j=510;j>0;j--) {
765 if (block[j] ==
' ') block[j] = 0;
769 if( isize == 4 ) strlcat(fullname,
"/F",1024);
770 else if( isize == 8) strlcat(fullname,
"/D",1024);
780 strlcat(fullname,
"/I",1024);
783 strlcat(fullname,
"/S",1024);
786 strlcat(fullname,
"/B",1024);
791 strlcat(fullname,
"/I",1024);
799 strlcat(fullname,
"/i",1024);
802 strlcat(fullname,
"/s",1024);
805 strlcat(fullname,
"/b",1024);
810 strlcat(fullname,
"/i",1024);
818 if (itype == 4) strlcat(fullname,
"/b",1024);
819 if (itype == 5) strlcat(fullname,
"/C",1024);
820 printf(
"Creating branch:%s, block:%s, fullname:%s, nsub=%d, itype=%d, isize=%d, ielem=%d\n",
name,block,fullname,nsub,itype,isize,ielem);
822 if (itype == 5) ischar = 1;
824 if (ischar != oldischar || strcmp(oldblock,block) != 0) {
825 strlcpy(oldblock,block,512);
827 Int_t lblock = strlen(block);
839 if (itype == 4) {isabool++; boolflag[i] = bufpos; lenbool[i] = ielem;}
840 bufpos += isize*ielem;
841 if (ischar) {isachar++; charflag[i] = bufpos-1; lenchar[i] = isize*ielem;}
854 for (j=0;j<nvar;j++) {
857 for (
l=0;
l<lenbool[j];
l++) {
864 memcpy(&
bigbuf[cf],boolarr,lenbool[j]);
869 for (j=0;j<nvar;j++) {
873 if (
bigbuf[cf-1] !=
' ')
continue;
875 if (
bigbuf[cf-2] !=
' ')
continue;
884 for(
int k=0; k<nvar;k++) {
886 hntvar2(
id,k+1,
PASSCHAR(
name),
PASSCHAR(fullname),
PASSCHAR(block),nsub,itype,isize,nbits,ielem,32,64,32);
891 Int_t nBytesUsed = 4;
893 if ( itype == 2 || itype == 3) {
897 if( nbits > 8 ) nBytesUsed = 2;
902 if(nBytesUsed == 1) {
903 for(
Int_t index = 0; index < ielem; index++) {
905 bigbuf[bufpos + index*nBytesUsed ] =
bigbuf[bufpos + index * isize];
908 if(nBytesUsed == 2) {
909 for(
Int_t index = 0; index < ielem; index++) {
911 bigbuf[bufpos + index*nBytesUsed ] =
bigbuf[bufpos + index * isize];
912 bigbuf[bufpos + index*nBytesUsed+1 ] =
bigbuf[bufpos + index * isize+1];
916 bufpos += isize*ielem;