model_server/project/src/proj_restore.cxx
// Returns: 1 on success
//          0 on failure
1 on success
0 on failure
1 on success 0 on failure
int prjParser::parse_line ()
{
    Initialize(prjParser::parse_line);
    if (lbuf[0] == 0)
	return 0;
    linenum ++;
    char *st = 0, *en;
    int ret = 0;
    en = lbuf+ strlen(lbuf) -1;
    if ( *en == '\n' )
       *en = 0;
    for (int ii = 0 ; lbuf[ii] ; ii ++) {
	if (!isspace(lbuf[ii])) {
	    st = &lbuf[ii];
	    en = st + 1;
	    break;
	}
    }
    if (!st || !*en) return 0;
    int lvl_indent = st - lbuf;
    level = lvl_indent / LVL_SPACES;
    if (st[0] == 'M' || st[0] == 'm' || st[0] == 'i' || st[0] == 'h' || st[0] == 's') {
	pline.is_proj = 0;
	pline.included = (st[0] == 'i') ? 1 : 0;
    } else if (st[0] == 'P' || st[0] == 'X' || st[0] == 'N') {
	pline.is_proj = 1;
	pline.pmod_type = PMOD_UNKNOWN;
	if (st[0] == 'X')
	    pline.pmod_type = PMOD_PDF;
	else if (st[0] == 'N')
	    pline.pmod_type = PMOD_NO;
	pline.sep = st[1];
    } else {
	err_msg = "Neither Project nor Module.";
	return 0;
    }
    ret = get_next (en, st, en);
    if (!ret) return 0;
    if (en) en[0] = 0;
    int numb = OSapi_atoi(st);
    if (en) en[0] = pline.sep;
    if (pline.is_proj)
	pline.proj_size = numb;
    else
	pline.lang = (enum fileLanguage)numb;
    ret = get_next (en, st, en);
    if (!ret) return 0;
    if (en) en[0] = 0;
    pline.left_name = dequote_str( st );
    if (en) en[0] = pline.sep;
    ret = get_next (en, st, en);
    if (!ret) return 0;
    if (en) en[0] = 0;
    ret = extract_flags( (char*)dequote_str(st), PRJ_phys);
    if (en) en[0] = pline.sep;
    if (!ret) {
	err_msg = "Wrong physical name syntax.";
	return 0;
    }
    ret = get_next (en, st, en);
    if (!ret) return 0;
    if (en) en[0] = 0;
    pline.right_name = dequote_str( st );
    if (en) en[0] = pline.sep;
    ret = get_next (en, st, en);
    if (!ret) return 0;
    if (en) en[0] = 0;
    ret = extract_flags( (char*)dequote_str(st), PRJ_model);
    if (en) en[0] = pline.sep;
    if (!ret) {
	err_msg = "Wrong model name syntax.";
	return 0;
    }
    return 1;
}
int prjParser :: parse_line ( ) { Initialize ( prjParser :: parse_line ) ; if ( lbuf [ 0 ] == 0 ) return 0 ; linenum ++ ; char * st = 0 , * en ; int ret = 0 ; en = lbuf + strlen ( lbuf ) - 1 ; if ( * en == ' \n ' ) * en = 0 ; for ( int ii = 0 ; lbuf [ ii ] ; ii ++ ) { if ( ! isspace ( lbuf [ ii ] ) ) { st = & lbuf [ ii ] ; en = st + 1 ; break ; } } if ( ! st || ! * en ) return 0 ; int lvl_indent = st - lbuf ; level = lvl_indent / LVL_SPACES ; if ( st [ 0 ] == ' ' || st [ 0 ] == ' ' || st [ 0 ] == ' ' || st [ 0 ] == ' ' || st [ 0 ] == ' ' ) { pline . is_proj = 0 ; pline . included = ( st [ 0 ] == ' ' ) ? 1 : 0 ; } else if ( st [ 0 ] == ' ' || st [ 0 ] == ' ' || st [ 0 ] == ' ' ) { pline . is_proj = 1 ; pline . pmod_type = PMOD_UNKNOWN ; if ( st [ 0 ] == ' ' ) pline . pmod_type = PMOD_PDF ; else if ( st [ 0 ] == ' ' ) pline . pmod_type = PMOD_NO ; pline . sep = st [ 1 ] ; } else { err_msg = " " ; return 0 ; } ret = get_next ( en , st , en ) ; if ( ! ret ) return 0 ; if ( en ) en [ 0 ] = 0 ; int numb = OSapi_atoi ( st ) ; if ( en ) en [ 0 ] = pline . sep ; if ( pline . is_proj ) pline . proj_size = numb ; else pline . lang = ( enum fileLanguage ) numb ; ret = get_next ( en , st , en ) ; if ( ! ret ) return 0 ; if ( en ) en [ 0 ] = 0 ; pline . left_name = dequote_str ( st ) ; if ( en ) en [ 0 ] = pline . sep ; ret = get_next ( en , st , en ) ; if ( ! ret ) return 0 ; if ( en ) en [ 0 ] = 0 ; ret = extract_flags ( ( char * ) dequote_str ( st ) , PRJ_phys ) ; if ( en ) en [ 0 ] = pline . sep ; if ( ! ret ) { err_msg = " " ; return 0 ; } ret = get_next ( en , st , en ) ; if ( ! ret ) return 0 ; if ( en ) en [ 0 ] = 0 ; pline . right_name = dequote_str ( st ) ; if ( en ) en [ 0 ] = pline . sep ; ret = get_next ( en , st , en ) ; if ( ! ret ) return 0 ; if ( en ) en [ 0 ] = 0 ; ret = extract_flags ( ( char * ) dequote_str ( st ) , PRJ_model ) ; if ( en ) en [ 0 ] = pline . sep ; if ( ! ret ) { err_msg = " " ; return 0 ; } return 1 ; }
Returns: 1 on success
0 on failure
Returns : 1 on success 0 on failure
// Title: [P X N] or [m s h i], indent is always spaces // language-or-size // left name // physical name // Right name (meta name) // Model name