@@ -678,40 +678,38 @@ XDI_required_metadata(XDIFile *xdifile) {
678
678
679
679
_EXPORT (int )
680
680
XDI_recommended_metadata (XDIFile * xdifile ) {
681
- int ret , i ;
682
-
683
- ret = pow (2 ,5 )- 1 ;
681
+ int ret , i , n , errcode , found ;
682
+ int n_rec = sizeof (RecommendedMetadata )/sizeof (char * );
683
+ char * words [2 ];
684
+ char thisword [100 ] = {'\0' };
685
+ int nwords ;
686
+
687
+ /* ret = pow(2,n_rec+1)-1; */
688
+ ret = (1 <<(n_rec )) - 1 ;
684
689
strcpy (xdifile -> error_message , "" );
685
690
686
- for (i = 0 ; i < xdifile -> nmetadata ; i ++ ) {
687
- if ((strcasecmp (xdifile -> meta_families [i ], "facility" ) == 0 ) && (strcasecmp (xdifile -> meta_keywords [i ], "name" ) == 0 )) {
688
- ret = ret - 1 ; /* 2^0 */
689
- continue ;
690
- }
691
- if ((strcasecmp (xdifile -> meta_families [i ], "facility" ) == 0 ) && (strcasecmp (xdifile -> meta_keywords [i ], "xray_source" ) == 0 )) {
692
- ret = ret - 2 ; /* 2^1 */
693
- continue ;
694
- }
695
- if ((strcasecmp (xdifile -> meta_families [i ], "beamline" ) == 0 ) && (strcasecmp (xdifile -> meta_keywords [i ], "name" ) == 0 )) {
696
- ret = ret - 4 ; /* 2^2 */
697
- continue ;
698
- }
699
- if ((strcasecmp (xdifile -> meta_families [i ], "scan" ) == 0 ) && (strcasecmp (xdifile -> meta_keywords [i ], "start_time" ) == 0 )) {
700
- ret = ret - 8 ; /* 2^3 */
701
- continue ;
691
+
692
+ for (n = 0 ; n < n_rec ; n ++ ) {
693
+ found = 0 ;
694
+ /* errcode = pow(2,n); */
695
+ errcode = 1 <<n ;
696
+ /* printf("%d %d %s\n", ret, errcode, RecommendedMetadata[n]); */
697
+ strcpy (thisword , RecommendedMetadata [n ]);
698
+ nwords = split_on (thisword , TOK_DOT , words );
699
+
700
+ for (i = 0 ; i < xdifile -> nmetadata ; i ++ ) {
701
+ if ((strcasecmp (xdifile -> meta_families [i ], words [0 ]) == 0 ) && (strcasecmp (xdifile -> meta_keywords [i ], words [1 ]) == 0 )) {
702
+ ret = ret - errcode ;
703
+ found = 1 ;
704
+ break ;
705
+ }
702
706
}
703
- if ((strcasecmp (xdifile -> meta_families [i ], "column" ) == 0 ) && (strcasecmp (xdifile -> meta_keywords [i ], "1" ) == 0 )) {
704
- ret = ret - 16 ; /* 2^4 */
705
- continue ;
707
+ if (found == 0 ) {
708
+ strcat (xdifile -> error_message , "Missing recommended metadata field: " );
709
+ strcat (xdifile -> error_message , RecommendedMetadata [n ]);
710
+ strcat (xdifile -> error_message , "\n" );
706
711
}
707
712
}
708
- /* printf("%d\n", ret); */
709
-
710
- if (ret & 1 ) { strcat (xdifile -> error_message , "Missing recommended metadata field: Facility.name\n" ); }
711
- if (ret & 2 ) { strcat (xdifile -> error_message , "Missing recommended metadata field: Facility.source\n" ); }
712
- if (ret & 4 ) { strcat (xdifile -> error_message , "Missing recommended metadata field: Beamline.name\n" ); }
713
- if (ret & 8 ) { strcat (xdifile -> error_message , "Missing recommended metadata field: Scan.start_time\n" ); }
714
- if (ret & 16 ) { strcat (xdifile -> error_message , "Missing recommended metadata field: Column.1\n" ); }
715
713
716
714
return ret ;
717
715
}
0 commit comments