00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef _CRAY_ASSIGN_H
00038 #define _CRAY_ASSIGN_H
00039
00040
00041 #ifndef _LIB_INTERNAL
00042 #define _LIB_INTERNAL 1
00043 #endif
00044 #include <ffio.h>
00045 #include <liberrno.h>
00046 #include <stddef.h>
00047 #include <stdio.h>
00048 #include <cray/fortio.h>
00049 #include <cray/mtlock.h>
00050 #include <sys/param.h>
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #define AS_SKIPBAD 1
00065 #define AS_ACPTBAD 2
00066
00067 #define AS_FORTRAN77 1
00068 #define AS_FORTRAN90 2
00069 #define AS_IRIX_F77 3
00070 #define AS_IRIX_F90 4
00071
00072 #define AS_THREAD 1
00073 #define AS_PROCESS 2
00074 #define AS_TEAM 3
00075 #define AS_PRIVATE 4
00076 #define AS_GLOBAL 5
00077
00078
00079
00080
00081
00082 #define BYFILE 'f'
00083 #define BYGLOBAL 'g'
00084 #define BYPATTERN 'p'
00085 #define BYUNIT 'u'
00086
00087 #define MAX_FDC_SPEC 128
00088
00089 #define MAX_ASSIGN_LINE 5000
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 #define DECIMAL 10
00100
00101 #define AE_LIB 1
00102 #define AE_ASSIGN 2
00103 #define AE_ASGCMD 3
00104
00105
00106
00107
00108
00109 #define ASSIGN_ENV_VAR "FILENV"
00110 #define ASSIGN_OPT_VAR "_LIBASSIGNENV_"
00111 #define ASGCMD_ENV_VAR "_ASG_ATTR"
00112 #define PROCENVFLAG '$'
00113 #define DELIMSTR " # # "
00114
00115
00116
00117
00118
00119
00120 #define ASN_G_ALL 0001
00121 #define ASN_G_SF 0002
00122 #define ASN_G_SU 0004
00123 #define ASN_G_DF 0010
00124 #define ASN_G_DU 0020
00125 #define ASN_G_AQ 0040
00126 #define ASN_G_FF 0400
00127 #define ASN_G_MPI 01000
00128
00129
00130
00131
00132
00133
00134
00135 #define RETERR(_EH,_NUM) { \
00136 _lerror(_EH,_NUM); \
00137 errno = _NUM; \
00138 return(-1); \
00139 }
00140 #define RETERR1(_EH,_NUM,_D1) { \
00141 _lerror(_EH,_NUM,_D1); \
00142 errno = _NUM; \
00143 return(-1); \
00144 }
00145 #define RETERR2(_EH,_NUM,_D1,_D2) { \
00146 _lerror(_EH,_NUM,_D1,_D2); \
00147 errno = _NUM; \
00148 return(-1); \
00149 }
00150 #define ERRET(ee) { errno = ee; return(-1); }
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 #ifndef _CRAYMPP
00180
00181 #define ASSIGN_LOCK() MEM_LOCK(&_Ae_assign_lock)
00182 #define ASSIGN_UNLOCK() MEM_UNLOCK(&_Ae_assign_lock)
00183
00184 #else
00185
00186 #define ASSIGN_LOCK() { if (_num_pes() > 1) \
00187 MPP_LOCK(&_Ae_assign_lock); }
00188 #define ASSIGN_UNLOCK() { if (_num_pes() > 1) \
00189 MPP_UNLOCK(&_Ae_assign_lock); }
00190
00191 #endif
00192
00193
00194
00195
00196 #define _AE_SKIPWHITE(pp) { \
00197 register char cc; \
00198 cc = *pp; \
00199 while (isspace(cc) && cc != '\0') \
00200 cc = *++pp; \
00201 }
00202
00203
00204
00205
00206
00207 #define _AE_NULLINFO(P) ((void)memset((char*)P,0,sizeof(assign_info)))
00208
00209
00210
00211
00212 #ifdef DEBUG_ASSIGN
00213 #define ASN_DEBUG( ARGLIST ) printf ARGLIST
00214 #else
00215 #define ASN_DEBUG( ARGLIST )
00216 #endif
00217
00218
00219
00220
00221
00222
00223 #define AFLAGSIZE ((offsetof(assign_info, flagpad) + \
00224 sizeof(((assign_info*) 0)->flagpad)) )
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236 #define _ae_opt_control(ch) \
00237 ((ch)>='A' && (ch)<='z' && _Ae_letters[(ch)-'A'] == 'c')
00238
00239 #define _ae_opt_nooptval(ch) \
00240 ((ch)>='A' && (ch)<='z' && _Ae_letters[(ch)-'A'] == 'n')
00241
00242 #define _ae_opt_optval(ch) \
00243 ((ch)>='A' && (ch)<='z' && _Ae_letters[(ch)-'A'] == 'v')
00244
00245
00246
00247
00248
00249
00250
00251
00252 typedef struct {
00253 char type;
00254
00255
00256
00257 union {
00258 long unit;
00259 char *str;
00260 } u;
00261 } assign_obj_id;
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278 enum asn_flags {
00279 ATTR_SET = 1,
00280 ATTR_USED = 2
00281 };
00282
00283 typedef unsigned char aflg_t;
00284
00285 typedef struct assign_info_s {
00286
00287 aflg_t a_actfil_flg;
00288 aflg_t a_sdsfil_flg;
00289 aflg_t b_bufsiz_flg;
00290 aflg_t B_direct_flg;
00291 aflg_t c_contig_flg;
00292 aflg_t C_chrcnv_flg;
00293 aflg_t d_datrcv_flg;
00294 aflg_t D_fildes_flg;
00295 aflg_t f_fortst_flg;
00296 aflg_t F_filter_flg;
00297 aflg_t l_buflev_flg;
00298 aflg_t L_ldraw_flg;
00299 aflg_t m_multup_flg;
00300 aflg_t n_preall_flg;
00301 aflg_t n_stride_flg;
00302 aflg_t N_datcnv_flg;
00303 aflg_t o_UNUSED_flg;
00304 aflg_t P_ioscop_flg;
00305 aflg_t q_ocblks_flg;
00306 aflg_t pr_partit_flg;
00307 aflg_t r_raw_flg;
00308 aflg_t s_fstrct_flg;
00309 aflg_t S_comsep_flg;
00310 aflg_t t_tmpfil_flg;
00311 aflg_t T_utrunc_flg;
00312 aflg_t u_bufcnt_flg;
00313 aflg_t U_unicoslist_flg;
00314 aflg_t w_welfrm_flg;
00315 aflg_t W_compwidth_flg;
00316 aflg_t x_parallel_flg;
00317 aflg_t y_reptcnt_flg;
00318 aflg_t Y_nl_skip_flg;
00319 aflg_t Z_neg_zero_flg;
00320
00321 aflg_t flagpad[9];
00322
00323 char a_actfil[PATH_MAX];
00324
00325
00326
00327
00328
00329 int b_bufsiz;
00330
00331
00332
00333 int B_direct;
00334
00335
00336
00337 int c_contig;
00338
00339 int C_chrcnv;
00340
00341
00342 int d_datrcv;
00343
00344
00345
00346 int D_fildes;
00347
00348
00349 int f_fortst;
00350
00351 union spec_u
00352 F_filter[MAX_FDC_SPEC];
00353 int F_filter_len;
00354
00355 int l_buflev;
00356
00357
00358
00359
00360
00361 int L_ldraw;
00362
00363
00364
00365 int m_multup;
00366
00367
00368
00369
00370 int n_preall;
00371
00372
00373
00374 int n_stride;
00375
00376
00377
00378
00379 int N_datcnv;
00380
00381
00382 int o_UNUSED;
00383
00384 long pr_partit;
00385
00386
00387
00388
00389
00390 int P_ioscop;
00391
00392
00393
00394
00395 int q_ocblks;
00396
00397
00398 int r_raw;
00399
00400
00401
00402 int s_fstrct;
00403
00404
00405 int S_comsep;
00406
00407
00408
00409
00410 int t_tmpfil;
00411
00412 int T_utrunc;
00413
00414
00415
00416 int u_bufcnt;
00417
00418
00419
00420
00421 int U_unicoslist;
00422
00423
00424
00425
00426
00427 int w_welfrm;
00428
00429
00430
00431 int W_compwidth;
00432
00433
00434
00435
00436 int x_parallel;
00437
00438
00439
00440 int y_reptcnt;
00441
00442
00443
00444 int Y_nl_skip;
00445
00446
00447
00448 int Z_neg_zero;
00449
00450
00451
00452 int pad[10];
00453
00454 } assign_info;
00455
00456 typedef struct {
00457 unsigned I: 1;
00458 unsigned O: 1;
00459 unsigned R: 1;
00460 unsigned V: 1;
00461 unsigned v: 1;
00462 unsigned z: 1;
00463 int attrs;
00464 } assign_cntl;
00465
00466 typedef struct {
00467 char attrid;
00468 char *str;
00469 char *p;
00470 } attribute;
00471
00472
00473
00474
00475 typedef struct {
00476 assign_obj_id id;
00477 char *attr;
00478 } assign_record;
00479
00480
00481
00482
00483 typedef struct {
00484 int rec_cnt;
00485
00486 int rec_lim;
00487
00488 assign_record *ar;
00489 } assign_environment;
00490
00491
00492
00493
00494 typedef struct {
00495 assign_environment *env;
00496 long size;
00497 } aenv_stack;
00498
00499
00500 typedef struct {
00501 int iotype;
00502 union {
00503 struct {
00504 char access;
00505 char form;
00506 } fortio;
00507
00508 } u;
00509 } aio_desc;
00510
00511
00512
00513
00514
00515
00516 typedef struct tok_list_s {
00517 char *str;
00518 int code;
00519 } tok_list;
00520
00521
00522
00523
00524
00525
00526 typedef struct opt_table_s {
00527 int flg_off;
00528 int val_off;
00529 tok_list *tl;
00530 } opt_table;
00531
00532
00533
00534
00535
00536
00537 typedef struct parse_info_s {
00538 char *optname;
00539 int flg_off;
00540 int val_off;
00541 int (* pfunc)();
00542 tok_list *tl;
00543 unsigned sup: 1;
00544 char *desc;
00545 } parse_info;
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555 extern aenv_stack _Ae_env_stack;
00556 extern int _Ae_asgcmd;
00557 extern int _Ae_assign_cmd;
00558 #ifndef _CRAYMPP
00559 EXTERN_LOCK(_Ae_assign_lock)
00560 #else
00561 EXTERN_MPP_LOCK(_Ae_assign_lock)
00562 #endif
00563 extern char _Ae_letters[];
00564 extern parse_info _Ae_option_parse_info[];
00565
00566 extern char *_ae_build_envstring(assign_environment *aep);
00567
00568 extern void _ae_dealloc_env(assign_environment *aep);
00569
00570 extern void _ae_dealloc_recflds(assign_record *arp);
00571
00572 extern int _ae_externalize(int fromwhere, FILE *gfile,
00573 assign_environment *ap);
00574
00575 extern int _ae_externalize_file(FILE *gfile, assign_environment *ap);
00576
00577 extern int _ae_externalize_env(int fromwhere, assign_environment *ap);
00578
00579 extern int _ae_glob_code(char *str);
00580
00581 extern char *_ae_glob_str(int ga);
00582
00583 extern int _ae_insert(assign_obj_id *aoidp, char *attr, int attrlen,
00584 assign_environment *aep);
00585
00586 extern int _ae_internalize(FILE *gfile, assign_environment *aep);
00587
00588 extern int _ae_internalize_file(FILE *gfile, assign_environment *aep);
00589
00590 extern int _ae_internalize_env(assign_environment *aep, int ifasgcmd);
00591
00592 extern int _ae_match_pattern(const char *fname, assign_record **arpp,
00593 assign_environment *aep);
00594
00595 extern int _ae_select(assign_obj_id *aoidp, assign_record **arpp,
00596 assign_environment *aep);
00597
00598 extern void _ae_setupenv(assign_environment *aep);
00599
00600 extern char *_ae_glob_name(int ga);
00601
00602 extern int _asndir_split(char *buf, char **options, char **object,
00603 int ifasgcmd);
00604
00605 extern int _assign(char *opt_string, assign_obj_id *aop, int errmode);
00606
00607 extern int _assign_asgcmd_info(const char *fname, unum_t unum, int gamask,
00608 assign_info *aip, char **atstr, int catcherr);
00609
00610 extern FILE *_gae_open(char acc_mode, char res_mode, int *status);
00611
00612 extern void _gae_close(FILE *f);
00613
00614 extern int _get_a_options(int ifasgcmd, const char *fname, unum_t unum,
00615 int gamask, assign_info *aip, char **atstr,
00616 int errmode);
00617
00618 extern char *_lae_get_assign_file_name(int *estat);
00619
00620 extern char *_lae_get_assign_var_name(void);
00621
00622 extern int _lae_get_object(char *objtext, assign_obj_id *aoidp);
00623
00624 extern int _patmatch(const char *str, const char *pat);
00625
00626 extern void _unique_close(FILE *f);
00627
00628 extern FILE *_unique_open(char *fname, char mode, int *ostat);
00629
00630 extern int _lae_do_assign(int fromwhere, int assign_mode, char open_mode,
00631 char res_mode, assign_obj_id *aoidp,
00632 char *attr_string, int optcheck, int errmode);
00633
00634 extern int _lae_assign_mode(int fromwhere, assign_cntl *cnp, int numobj,
00635 int *amode, char *omode, char *rmode);
00636
00637 extern int _attrs_used(assign_info *aip, char **attrstr);
00638
00639 extern void _attr_clear_used(assign_info *aip);
00640
00641 extern int _ae_eclipse(char *attr1, int len1, char *attr2, int len2,
00642 char **newarp);
00643
00644 extern int _ae_parse(assign_obj_id *aiodp, char *attr, int attrlen,
00645 assign_info *aip, int warnmode, int errmode);
00646
00647 extern int _lae_process_opts(char *opt_string, char **attr_string,
00648 assign_cntl *cntlp);
00649
00650 extern int _ae_delete(assign_record *arp, assign_environment *aep);
00651
00652 extern void _lae_print_record(assign_record *arp);
00653
00654 extern int _ae_next(assign_record *prev, assign_record **next,
00655 assign_environment *aep);
00656
00657 extern int _ae_check_attr(assign_info *ai, int warnmode, int errmode);
00658
00659 extern void _ae_setoflags(assign_info *aip, int *flagmask);
00660
00661 #endif