int main(int argc, char **argv) { int i; if (argc != 3) { fprintf(stderr, "Must be called in form 'extract <filename> <dbref>'\n"); exit(1); } if ((input_file = fopen(argv[1], "r")) == NULL) { fprintf(stderr, "Could not open file '%d'\n", argv[1]); exit(1); } me = atoi(argv[2]); db_free(); db_read(input_file); fprintf(stderr, "dbtop = %d\n", db_top); printf("MUCK 2.2fb extract for dbref #%d\n", me); for (i = 0; i < db_top; i++) { if (OWNER(i) != me) continue; if (!(i % 256)) fprintf(stderr, "Checking object %d..\n", i); check_common(i); switch (db[i].flags & TYPE_MASK) { case TYPE_ROOM: check_room(i); break; case TYPE_THING: check_thing(i); break; case TYPE_EXIT: check_exit(i); break; case TYPE_PLAYER: check_player(i); break; case TYPE_PROGRAM: check_program(i); break; case TYPE_GARBAGE: break; default: break; } } fclose(input_file); fprintf(stderr, "Completed extract normally.\n"); return 0; }
CNV_RETN PtrConvertCommon( // CONVERT TO COMMON PTR PTREE expr ) // - expression { PTREE *r_left; // - reference( left node ) PTREE *r_right; // - reference( right node ) TYPE ltype; // - type on left TYPE rtype; // - type on right TYPE lptype; // - new ptr type on left TYPE rptype; // - new ptr type on right TYPE lbtype; // - base type on left TYPE rbtype; // - base type on right TYPE type; // - resultant type TYPE common; // - common base type CNV_RETN retn; // - conversion return r_left = &expr->u.subtree[0]; ltype = NodeType( *r_left ); r_right = &expr->u.subtree[1]; rtype = NodeType( *r_right ); if( same_ptr_types( ltype, rtype ) ) { type = ltype; if( CgTypeSize( ltype ) > CgTypeSize( rtype ) ) { expr->type = ltype; } else { expr->type = rtype; } retn = propogateNonZero( CNV_OK, expr ); } else if( ptr_to_void( ltype ) ) { retn = NodeCheckCnvPtrVoid( &expr, rtype, ltype ); retn = check_common( retn, expr, ltype ); } else if( ptr_to_void( rtype ) ) { retn = NodeCheckCnvPtrVoid( &expr, ltype, rtype ); retn = check_common( retn, expr, rtype ); } else{ lbtype = TypePointedAtModified( ltype ); rbtype = TypePointedAtModified( rtype ); switch( TypeCommonDerivation( lbtype, rbtype ) ) { case CTD_LEFT : case CTD_LEFT_VIRTUAL : retn = NodeConvertPtr( CNVPTR_DERIVED_ONLY, r_left, ltype, rtype ); retn = check_common( retn, expr, rtype ); break; case CTD_RIGHT : case CTD_RIGHT_VIRTUAL : retn = NodeConvertPtr( CNVPTR_DERIVED_ONLY, r_right, rtype, ltype ); retn = check_common( retn, expr, ltype ); break; case CTD_NO : common = TypeCommonBase( rbtype, lbtype ); if( common != NULL ) { lptype = TypePointedAtReplace( ltype, common ); rptype = TypePointedAtReplace( rtype, common ); /* TypeCommonBase verified everything so these convs will work*/ NodeConvertPtr( CNVPTR_DERIVED_ONLY, r_left, ltype, lptype ); NodeConvertPtr( CNVPTR_DERIVED_ONLY, r_right, rtype, rptype); expr->type = expr->u.subtree[0]->type; retn = propogateNonZero( CNV_OK, expr ); } else { retn = UserDefCnvToType( r_left, ltype, rtype ); if( retn == CNV_IMPOSSIBLE ) { retn = UserDefCnvToType( r_right, rtype, ltype ); retn = check_common( retn, expr, ltype ); } else { retn = check_common( retn, expr, rtype ); } } break; case CTD_RIGHT_AMBIGUOUS : ConversionTypesSet( rtype, ltype ); case CTD_LEFT_AMBIGUOUS : retn = CNV_AMBIGUOUS; break; case CTD_RIGHT_PRIVATE : ConversionTypesSet( rtype, ltype ); case CTD_LEFT_PRIVATE : retn = CNV_PRIVATE; break; case CTD_RIGHT_PROTECTED : ConversionTypesSet( rtype, ltype ); case CTD_LEFT_PROTECTED : retn = CNV_PROTECTED; break; } } return( retn ); }