/* * Bridge: emit */ void T_emit( c_t * p_file ) { //printf("Emitting to file: %s\n", p_file); static int first = 0; if ( first == 0 ) { first = 1; if ( 0 == ( outputfile = fopen( p_file, "w" ) ) ) { T_print( "bad news could not open output file" ); T_exit( 1 ); } } fprintf( outputfile, "%s", buffer ); // printf("---\n"); // printf("%s", buffer); // printf("---\n"); T_clear(); }
/* * Bridge: emit */ void T_emit( c_t * p_file ) { FILE * outputfile; if ( strcmp( "stdout", p_file ) == 0 ) { outputfile = stdout; } else { // Create directories as needed. _mkdir( p_file ); // Open file. if ( 0 == ( outputfile = fopen( p_file, "w" ) ) ) { T_print( "bad news could not open output file" ); T_exit( 1 ); } } fprintf( outputfile, "%s", buffer ); T_clear(); }
void UserPostOoaInitializationCalloutf( int argc, char ** argv ) { char s[ ESCHER_SYS_MAX_STRING_LEN ], v[ 8 ][ ESCHER_SYS_MAX_STRING_LEN ], arg[ ESCHER_SYS_MAX_STRING_LEN ]; char * p, * q, * element, * value[8] = {v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]}; T_clear(); while ( ( p = fgets( s, ESCHER_SYS_MAX_STRING_LEN, stdin ) ) != NULL ) { int i, j; i = 0; p[ strlen(p) - 1 ] = 0; if ( ( q = strsep( &p, "," ) ) != NULL ) element = Escher_strcpy( element, q ); while ( ( q = strsep(&p, ",")) != NULL ) { masl_url_decode( value[ i ], q ); i++; } masl_in_populate( element, value ); } int validate = 0; int Validateonly = 0; char * indirname = 0; char * outdirname = 0; char * projectdomain = 0; int namecount = 0; char name[8][ESCHER_SYS_MAX_STRING_LEN] = {0,0,0,0,0,0,0,0}; { int c; opterr = 0; while ( ( c = getopt ( argc, argv, "vVi:o:d::p::" ) ) != -1 ) { switch ( c ) { case 'v': validate = 1; break; case 'V': Validateonly = 1; break; case 'i': indirname = optarg; break; case 'o': outdirname = optarg; break; case 'd': projectdomain = "domain"; if ( optarg ) strncpy( name[ namecount++ ], optarg, ESCHER_SYS_MAX_STRING_LEN ); break; case 'p': projectdomain = "project"; if ( optarg ) strncpy( name[ namecount++ ], optarg, ESCHER_SYS_MAX_STRING_LEN ); break; case '?': if ( 'o' == optopt ) { fprintf( stderr, "Option -%c requires an argument.\n", optopt ); } else if ( isprint (optopt) ) { fprintf( stderr, "Unknown option `-%c'.\n", optopt ); } else { fprintf( stderr, "Unknown option character `\\x%x'.\n", optopt ); } default: abort (); // die ignominiously } } } if ( validate || Validateonly ) { masl_gen_validate( "" ); } if ( ! Validateonly ) { if ( indirname ) { masl_file_op_infolder( indirname ); } if ( outdirname ) { masl_file_op_outfolder( outdirname ); } if ( projectdomain ) { int i = 0; while ( i < namecount ) masl_gen_render( projectdomain, name[ i++ ] ); } else { masl_gen_render( "project", "" ); masl_gen_render( "domain", "" ); } } exit(0); }